]> git.sesse.net Git - vlc/commitdiff
* Improve timers (Refs:#473)
authorClément Stenac <zorglub@videolan.org>
Fri, 27 Jan 2006 18:28:45 +0000 (18:28 +0000)
committerClément Stenac <zorglub@videolan.org>
Fri, 27 Jan 2006 18:28:45 +0000 (18:28 +0000)
* AccessOutWrite can be called with input already detached (Closes:#523)

src/libvlc.c
src/misc/stats.c
src/playlist/playlist.c
src/stream_output/stream_output.c

index 06ea4a25fa230c44055a8a4c3c72200458162fd1..b09edba64d3c77f395271a88c2e53ef4c3847930 100644 (file)
@@ -940,6 +940,7 @@ int VLC_CleanUp( int i_object )
 
     while( ( p_stats = vlc_object_find( p_vlc, VLC_OBJECT_STATS, FIND_CHILD) ))
     {
+        stats_TimersDumpAll( p_vlc );
         stats_HandlerDestroy( p_stats );
         vlc_object_detach( (vlc_object_t*) p_stats );
         vlc_object_release( (vlc_object_t *)p_stats );
index d24ba179c74279866f3fdea3b2ca5892682e9eb9..62d5eba9bd691aef52ba784e1067382f9bed29d2 100644 (file)
@@ -40,6 +40,8 @@ static int stats_CounterUpdate( stats_handler_t *p_handler,
 static stats_handler_t* stats_HandlerCreate( vlc_object_t *p_this );
 static stats_handler_t *stats_HandlerGet( vlc_object_t *p_this );
 
+static void TimerDump( vlc_object_t *p_this, counter_t *p_counter, vlc_bool_t);
+
 /*****************************************************************************
  * Exported functions
  *****************************************************************************/
@@ -444,36 +446,28 @@ void __stats_TimerStop( vlc_object_t *p_obj, const char *psz_name )
 
 void __stats_TimerDump( vlc_object_t *p_obj, const char *psz_name )
 {
-    mtime_t last, total;
-    int i_total;
     counter_t *p_counter = stats_CounterGet( p_obj,
                                              p_obj->p_vlc->i_object_id,
                                              psz_name );
-    if( !p_counter || p_counter->i_samples != 2 )
-    {
-        msg_Err( p_obj, "timer %s does not exist", psz_name );
-        return;
-    }
-    i_total = p_counter->pp_samples[1]->value.i_int;
-    total = p_counter->pp_samples[1]->date;
-    if( p_counter->pp_samples[0]->value.b_bool == VLC_TRUE )
-    {
-        last = mdate() - p_counter->pp_samples[0]->date;
-        i_total += 1;
-        total += last;
-    }
-    else
-    {
-        last = p_counter->pp_samples[0]->date;
-    }
-    msg_Dbg( p_obj, "TIMER %s : %.3f ms - Total %.3f ms / %i intvls (Avg %.3f ms)",
-             psz_name, (float)last/1000, (float)total/1000, i_total,
-             (float)(total)/(1000*(float)i_total ) );
+    TimerDump( p_obj, p_counter, VLC_TRUE );
 }
 
+
 void __stats_TimersDumpAll( vlc_object_t *p_obj )
 {
+    int i;
+    stats_handler_t *p_handler = stats_HandlerGet( p_obj );
+    if( !p_handler ) return;
 
+    vlc_mutex_lock( &p_handler->object_lock );
+    for ( i = 0 ; i< p_handler->i_counters; i++ )
+    {
+        if( p_handler->pp_counters[i]->i_compute_type == STATS_TIMER )
+        {
+            TimerDump( p_obj, p_handler->pp_counters[i], VLC_FALSE );
+        }
+    }
+    vlc_mutex_unlock( &p_handler->object_lock );
 }
 
 
@@ -672,3 +666,41 @@ static stats_handler_t* stats_HandlerCreate( vlc_object_t *p_this )
 
     return p_handler;
 }
+
+static void TimerDump( vlc_object_t *p_obj, counter_t *p_counter,
+                       vlc_bool_t b_total )
+{
+    mtime_t last, total;
+    int i_total;
+    if( !p_counter || p_counter->i_samples != 2 )
+    {
+        msg_Err( p_obj, "timer %s does not exist", p_counter->psz_name );
+        return;
+    }
+    i_total = p_counter->pp_samples[1]->value.i_int;
+    total = p_counter->pp_samples[1]->date;
+    if( p_counter->pp_samples[0]->value.b_bool == VLC_TRUE )
+    {
+        last = mdate() - p_counter->pp_samples[0]->date;
+        i_total += 1;
+        total += last;
+    }
+    else
+    {
+        last = p_counter->pp_samples[0]->date;
+    }
+    if( b_total )
+    {
+        msg_Dbg( p_obj,
+             "TIMER %s : %.3f ms - Total %.3f ms / %i intvls (Avg %.3f ms)",
+             p_counter->psz_name, (float)last/1000, (float)total/1000, i_total,
+             (float)(total)/(1000*(float)i_total ) );
+    }
+    else
+    {
+        msg_Dbg( p_obj,
+             "TIMER %s : Total %.3f ms / %i intvls (Avg %.3f ms)",
+             p_counter->psz_name, (float)total/1000, i_total,
+             (float)(total)/(1000*(float)i_total ) );
+    }
+}
index 5fffcbc3282513dfdc53efde3d3440a0f9ffd4c2..bde17ab55b84535e64fa111bea195e1f1b38e67d 100644 (file)
@@ -593,7 +593,9 @@ static void RunThread ( playlist_t *p_playlist )
         i_loops++;
         if( p_playlist->p_interaction )
         {
+            stats_TimerStart( p_playlist, "Interaction thread" );
             intf_InteractionManage( p_playlist );
+            stats_TimerStop( p_playlist, "Interaction thread" );
         }
 
         vlc_mutex_lock( &p_playlist->object_lock );
@@ -700,7 +702,9 @@ static void RunThread ( playlist_t *p_playlist )
         {
             /* Start another input.
              * Get the next item to play */
+            stats_TimerStart( p_playlist, "Playlist walk" );
             p_item = NextItem( p_playlist );
+            stats_TimerStop( p_playlist, "Playlist walk" );
 
             /* We must stop */
             if( p_item == NULL )
@@ -862,7 +866,9 @@ 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" );
                     input_Preparse( p_playlist, &p_current->input );
+                    stats_TimerStop( p_playlist, "Preparse run" );
                 }
                 vlc_mutex_unlock( &p_playlist->object_lock );
                 if( b_preparsed )
index d01d1cac5356b677408da005087084b236e4d141..0155895d1a40c0ef27291a22be141c6c563edb94 100644 (file)
@@ -32,6 +32,7 @@
 
 #include <vlc/vlc.h>
 #include <vlc/sout.h>
+#include <vlc/input.h>
 
 #include "vlc_meta.h"
 
@@ -367,15 +368,17 @@ int sout_AccessOutWrite( sout_access_out_t *p_access, block_t *p_buffer )
 {
     int i_total;
     /* Access_out -> sout_instance -> input_thread_t */
-    stats_UpdateInteger( p_access->p_parent->p_parent,
-                  "sout_sent_packets", 1 );
-    stats_UpdateInteger( p_access->p_parent->p_parent,
-                  "sout_sent_bytes", p_buffer->i_buffer );
-    stats_GetInteger( p_access->p_parent->p_parent,
-                      p_access->p_parent->p_parent->i_object_id,
-                      "sout_sent_bytes", &i_total );
-    stats_UpdateFloat( p_access->p_parent->p_parent, "sout_send_bitrate",
-                       (float)i_total );
+    input_thread_t *p_input = (input_thread_t *)vlc_object_find( p_access,
+                                        VLC_OBJECT_INPUT, FIND_PARENT );
+    if( p_input )
+    {
+        stats_UpdateInteger( p_input, "sout_sent_packets", 1 );
+        stats_UpdateInteger( p_input, "sout_sent_bytes", p_buffer->i_buffer );
+        stats_GetInteger( p_input, p_access->p_parent->p_parent->i_object_id,
+                          "sout_sent_bytes", &i_total );
+        stats_UpdateFloat( p_input, "sout_send_bitrate", (float)i_total );
+        vlc_object_release( p_input );
+    }
     return p_access->pf_write( p_access, p_buffer );
 }