]> git.sesse.net Git - vlc/blobdiff - src/playlist/playlist.c
* 2nd review of /src/* \ libvlc.h (refs #438)
[vlc] / src / playlist / playlist.c
index bde17ab55b84535e64fa111bea195e1f1b38e67d..c3195f4071c19c3070c2fa8674b82b8166369110 100644 (file)
@@ -5,7 +5,7 @@
  * $Id$
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
- *          Clément Stenac <zorglub@videolan.org>
+ *          Clément Stenac <zorglub@videolan.org>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -173,10 +173,12 @@ playlist_t * __playlist_Create ( vlc_object_t *p_parent )
     p_playlist->request.b_request = VLC_FALSE;
     p_playlist->status.i_status = PLAYLIST_STOPPED;
 
-
     p_playlist->i_sort = SORT_ID;
     p_playlist->i_order = ORDER_NORMAL;
 
+    p_playlist->p_stats = (global_stats_t *)malloc( sizeof( global_stats_t ) );
+    vlc_mutex_init( p_playlist, &p_playlist->p_stats->lock );
+
     /* Finally, launch the thread ! */
     if( vlc_thread_create( p_playlist, "playlist", RunThread,
                            VLC_THREAD_PRIORITY_LOW, VLC_TRUE ) )
@@ -269,6 +271,9 @@ int playlist_Destroy( playlist_t * p_playlist )
         free( p_view );
     }
 
+    if( p_playlist->p_stats )
+        free( p_playlist->p_stats );
+
     vlc_mutex_destroy( &p_playlist->gc_lock );
     vlc_object_destroy( p_playlist->p_preparse );
     vlc_object_destroy( p_playlist );
@@ -554,7 +559,7 @@ static mtime_t ObjectGarbageCollector( playlist_t *p_playlist, int i_type,
             }
             if( i_type == VLC_OBJECT_VOUT )
             {
-                msg_Dbg( p_playlist, "garbage collector destroying 1 vout" );
+                msg_Dbg( p_playlist, "garbage collector destroys 1 vout" );
                 vlc_object_detach( p_obj );
                 vlc_object_release( p_obj );
                 vout_Destroy( (vout_thread_t *)p_obj );
@@ -593,9 +598,15 @@ static void RunThread ( playlist_t *p_playlist )
         i_loops++;
         if( p_playlist->p_interaction )
         {
-            stats_TimerStart( p_playlist, "Interaction thread" );
+            stats_TimerStart( p_playlist, "Interaction thread",
+                              STATS_TIMER_INTERACTION );
             intf_InteractionManage( p_playlist );
-            stats_TimerStop( p_playlist, "Interaction thread" );
+            stats_TimerStop( p_playlist, STATS_TIMER_INTERACTION );
+        }
+
+        if( i_loops %5 == 0 && p_playlist->p_stats )
+        {
+            stats_ComputeGlobalStats( p_playlist, p_playlist->p_stats );
         }
 
         vlc_mutex_lock( &p_playlist->object_lock );
@@ -702,9 +713,10 @@ static void RunThread ( playlist_t *p_playlist )
         {
             /* Start another input.
              * Get the next item to play */
-            stats_TimerStart( p_playlist, "Playlist walk" );
+            stats_TimerStart( p_playlist, "Playlist walk",
+                              STATS_TIMER_PLAYLIST_WALK );
             p_item = NextItem( p_playlist );
-            stats_TimerStop( p_playlist, "Playlist walk" );
+            stats_TimerStop( p_playlist, STATS_TIMER_PLAYLIST_WALK );
 
             /* We must stop */
             if( p_item == NULL )
@@ -866,9 +878,10 @@ static void RunPreparse ( playlist_preparse_t *p_obj )
                     strncmp( p_current->input.psz_uri, "dshow:", 6 ) )
                 {
                     b_preparsed = VLC_TRUE;
-                    stats_TimerStart( p_playlist, "Preparse run" );
+                    stats_TimerStart( p_playlist, "Preparse run",
+                                      STATS_TIMER_PREPARSE );
                     input_Preparse( p_playlist, &p_current->input );
-                    stats_TimerStop( p_playlist, "Preparse run" );
+                    stats_TimerStop( p_playlist, STATS_TIMER_PREPARSE );
                 }
                 vlc_mutex_unlock( &p_playlist->object_lock );
                 if( b_preparsed )