Commit f3112de7 authored by Clément Stenac's avatar Clément Stenac

* Improve timers (Refs:#473)

* AccessOutWrite can be called with input already detached (Closes:#523)
parent 9c139c97
...@@ -940,6 +940,7 @@ int VLC_CleanUp( int i_object ) ...@@ -940,6 +940,7 @@ int VLC_CleanUp( int i_object )
while( ( p_stats = vlc_object_find( p_vlc, VLC_OBJECT_STATS, FIND_CHILD) )) while( ( p_stats = vlc_object_find( p_vlc, VLC_OBJECT_STATS, FIND_CHILD) ))
{ {
stats_TimersDumpAll( p_vlc );
stats_HandlerDestroy( p_stats ); stats_HandlerDestroy( p_stats );
vlc_object_detach( (vlc_object_t*) p_stats ); vlc_object_detach( (vlc_object_t*) p_stats );
vlc_object_release( (vlc_object_t *)p_stats ); vlc_object_release( (vlc_object_t *)p_stats );
......
...@@ -40,6 +40,8 @@ static int stats_CounterUpdate( stats_handler_t *p_handler, ...@@ -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_HandlerCreate( vlc_object_t *p_this );
static stats_handler_t *stats_HandlerGet( 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 * Exported functions
*****************************************************************************/ *****************************************************************************/
...@@ -444,36 +446,28 @@ void __stats_TimerStop( vlc_object_t *p_obj, const char *psz_name ) ...@@ -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 ) 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, counter_t *p_counter = stats_CounterGet( p_obj,
p_obj->p_vlc->i_object_id, p_obj->p_vlc->i_object_id,
psz_name ); psz_name );
if( !p_counter || p_counter->i_samples != 2 ) TimerDump( p_obj, p_counter, VLC_TRUE );
{
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 ) );
} }
void __stats_TimersDumpAll( vlc_object_t *p_obj ) 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 ) ...@@ -672,3 +666,41 @@ static stats_handler_t* stats_HandlerCreate( vlc_object_t *p_this )
return p_handler; 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 ) );
}
}
...@@ -593,7 +593,9 @@ static void RunThread ( playlist_t *p_playlist ) ...@@ -593,7 +593,9 @@ static void RunThread ( playlist_t *p_playlist )
i_loops++; i_loops++;
if( p_playlist->p_interaction ) if( p_playlist->p_interaction )
{ {
stats_TimerStart( p_playlist, "Interaction thread" );
intf_InteractionManage( p_playlist ); intf_InteractionManage( p_playlist );
stats_TimerStop( p_playlist, "Interaction thread" );
} }
vlc_mutex_lock( &p_playlist->object_lock ); vlc_mutex_lock( &p_playlist->object_lock );
...@@ -700,7 +702,9 @@ static void RunThread ( playlist_t *p_playlist ) ...@@ -700,7 +702,9 @@ static void RunThread ( playlist_t *p_playlist )
{ {
/* Start another input. /* Start another input.
* Get the next item to play */ * Get the next item to play */
stats_TimerStart( p_playlist, "Playlist walk" );
p_item = NextItem( p_playlist ); p_item = NextItem( p_playlist );
stats_TimerStop( p_playlist, "Playlist walk" );
/* We must stop */ /* We must stop */
if( p_item == NULL ) if( p_item == NULL )
...@@ -862,7 +866,9 @@ static void RunPreparse ( playlist_preparse_t *p_obj ) ...@@ -862,7 +866,9 @@ static void RunPreparse ( playlist_preparse_t *p_obj )
strncmp( p_current->input.psz_uri, "dshow:", 6 ) ) strncmp( p_current->input.psz_uri, "dshow:", 6 ) )
{ {
b_preparsed = VLC_TRUE; b_preparsed = VLC_TRUE;
stats_TimerStart( p_playlist, "Preparse run" );
input_Preparse( p_playlist, &p_current->input ); input_Preparse( p_playlist, &p_current->input );
stats_TimerStop( p_playlist, "Preparse run" );
} }
vlc_mutex_unlock( &p_playlist->object_lock ); vlc_mutex_unlock( &p_playlist->object_lock );
if( b_preparsed ) if( b_preparsed )
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <vlc/vlc.h> #include <vlc/vlc.h>
#include <vlc/sout.h> #include <vlc/sout.h>
#include <vlc/input.h>
#include "vlc_meta.h" #include "vlc_meta.h"
...@@ -367,15 +368,17 @@ int sout_AccessOutWrite( sout_access_out_t *p_access, block_t *p_buffer ) ...@@ -367,15 +368,17 @@ int sout_AccessOutWrite( sout_access_out_t *p_access, block_t *p_buffer )
{ {
int i_total; int i_total;
/* Access_out -> sout_instance -> input_thread_t */ /* Access_out -> sout_instance -> input_thread_t */
stats_UpdateInteger( p_access->p_parent->p_parent, input_thread_t *p_input = (input_thread_t *)vlc_object_find( p_access,
"sout_sent_packets", 1 ); VLC_OBJECT_INPUT, FIND_PARENT );
stats_UpdateInteger( p_access->p_parent->p_parent, if( p_input )
"sout_sent_bytes", p_buffer->i_buffer ); {
stats_GetInteger( p_access->p_parent->p_parent, stats_UpdateInteger( p_input, "sout_sent_packets", 1 );
p_access->p_parent->p_parent->i_object_id, 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 ); "sout_sent_bytes", &i_total );
stats_UpdateFloat( p_access->p_parent->p_parent, "sout_send_bitrate", stats_UpdateFloat( p_input, "sout_send_bitrate", (float)i_total );
(float)i_total ); vlc_object_release( p_input );
}
return p_access->pf_write( p_access, p_buffer ); return p_access->pf_write( p_access, p_buffer );
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment