Commit d5264484 authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

stats: Support per object timer. (and implement stats_TimerClean()).

parent 8bd5140a
...@@ -195,6 +195,7 @@ struct counter_t ...@@ -195,6 +195,7 @@ struct counter_t
unsigned int i_id; unsigned int i_id;
char * psz_name; char * psz_name;
int i_type; int i_type;
void * p_obj;
int i_compute_type; int i_compute_type;
int i_samples; int i_samples;
counter_sample_t ** pp_samples; counter_sample_t ** pp_samples;
...@@ -370,7 +371,10 @@ VLC_EXPORT( void,__stats_TimerStart, (vlc_object_t*, const char *, unsigned int ...@@ -370,7 +371,10 @@ VLC_EXPORT( void,__stats_TimerStart, (vlc_object_t*, const char *, unsigned int
VLC_EXPORT( void,__stats_TimerStop, (vlc_object_t*, unsigned int) ); VLC_EXPORT( void,__stats_TimerStop, (vlc_object_t*, unsigned int) );
VLC_EXPORT( void,__stats_TimerDump, (vlc_object_t*, unsigned int) ); VLC_EXPORT( void,__stats_TimerDump, (vlc_object_t*, unsigned int) );
VLC_EXPORT( void,__stats_TimersDumpAll, (vlc_object_t*) ); VLC_EXPORT( void,__stats_TimersDumpAll, (vlc_object_t*) );
#define stats_TimersClean(a) __stats_TimersClean( VLC_OBJECT(a) ) #define stats_TimersCleanAll(a) __stats_TimersCleanAll( VLC_OBJECT(a) )
VLC_EXPORT( void, __stats_TimersClean, (vlc_object_t * ) ); VLC_EXPORT( void, __stats_TimersCleanAll, (vlc_object_t * ) );
#define stats_TimerClean(a,b) __stats_TimerClean( VLC_OBJECT(a), b )
VLC_EXPORT( void, __stats_TimerClean, (vlc_object_t *, int ) );
#endif #endif
...@@ -988,7 +988,7 @@ int libvlc_InternalCleanup( libvlc_int_t *p_libvlc ) ...@@ -988,7 +988,7 @@ int libvlc_InternalCleanup( libvlc_int_t *p_libvlc )
vlc_object_release( p_libvlc->p_interaction ); vlc_object_release( p_libvlc->p_interaction );
stats_TimersDumpAll( p_libvlc ); stats_TimersDumpAll( p_libvlc );
stats_TimersClean( p_libvlc ); stats_TimersCleanAll( p_libvlc );
/* Free announce handler(s?) */ /* Free announce handler(s?) */
while( (p_announce = vlc_object_find( p_libvlc, VLC_OBJECT_ANNOUNCE, while( (p_announce = vlc_object_find( p_libvlc, VLC_OBJECT_ANNOUNCE,
......
...@@ -142,6 +142,7 @@ int __stats_Get( vlc_object_t *p_this, counter_t *p_counter, vlc_value_t *val ) ...@@ -142,6 +142,7 @@ int __stats_Get( vlc_object_t *p_this, counter_t *p_counter, vlc_value_t *val )
input_stats_t *stats_NewInputStats( input_thread_t *p_input ) input_stats_t *stats_NewInputStats( input_thread_t *p_input )
{ {
(void)p_input;
input_stats_t *p_stats = malloc( sizeof(input_stats_t) ); input_stats_t *p_stats = malloc( sizeof(input_stats_t) );
if( !p_stats ) if( !p_stats )
...@@ -286,7 +287,8 @@ void __stats_TimerStart( vlc_object_t *p_obj, const char *psz_name, ...@@ -286,7 +287,8 @@ void __stats_TimerStart( vlc_object_t *p_obj, const char *psz_name,
for( i = 0 ; i < p_obj->p_libvlc->i_timers; i++ ) for( i = 0 ; i < p_obj->p_libvlc->i_timers; i++ )
{ {
if( p_obj->p_libvlc->pp_timers[i]->i_id == i_id ) if( p_obj->p_libvlc->pp_timers[i]->i_id == i_id
&& p_obj->p_libvlc->pp_timers[i]->p_obj == p_obj )
{ {
p_counter = p_obj->p_libvlc->pp_timers[i]; p_counter = p_obj->p_libvlc->pp_timers[i];
break; break;
...@@ -304,6 +306,7 @@ void __stats_TimerStart( vlc_object_t *p_obj, const char *psz_name, ...@@ -304,6 +306,7 @@ void __stats_TimerStart( vlc_object_t *p_obj, const char *psz_name,
} }
p_counter->psz_name = strdup( psz_name ); p_counter->psz_name = strdup( psz_name );
p_counter->i_id = i_id; p_counter->i_id = i_id;
p_counter->p_obj = p_obj;
INSERT_ELEM( p_obj->p_libvlc->pp_timers, p_obj->p_libvlc->i_timers, INSERT_ELEM( p_obj->p_libvlc->pp_timers, p_obj->p_libvlc->i_timers,
p_obj->p_libvlc->i_timers, p_counter ); p_obj->p_libvlc->i_timers, p_counter );
...@@ -320,7 +323,7 @@ void __stats_TimerStart( vlc_object_t *p_obj, const char *psz_name, ...@@ -320,7 +323,7 @@ void __stats_TimerStart( vlc_object_t *p_obj, const char *psz_name,
} }
if( p_counter->pp_samples[0]->value.b_bool == true ) if( p_counter->pp_samples[0]->value.b_bool == true )
{ {
msg_Warn( p_obj, "timer %s was already started !", psz_name ); msg_Warn( p_obj, "timer '%s' was already started !", psz_name );
vlc_mutex_unlock( &p_obj->p_libvlc->timer_lock ); vlc_mutex_unlock( &p_obj->p_libvlc->timer_lock );
return; return;
} }
...@@ -337,7 +340,8 @@ void __stats_TimerStop( vlc_object_t *p_obj, unsigned int i_id ) ...@@ -337,7 +340,8 @@ void __stats_TimerStop( vlc_object_t *p_obj, unsigned int i_id )
vlc_mutex_lock( &p_obj->p_libvlc->timer_lock ); vlc_mutex_lock( &p_obj->p_libvlc->timer_lock );
for( i = 0 ; i < p_obj->p_libvlc->i_timers; i++ ) for( i = 0 ; i < p_obj->p_libvlc->i_timers; i++ )
{ {
if( p_obj->p_libvlc->pp_timers[i]->i_id == i_id ) if( p_obj->p_libvlc->pp_timers[i]->i_id == i_id
&& p_obj->p_libvlc->pp_timers[i]->p_obj == p_obj )
{ {
p_counter = p_obj->p_libvlc->pp_timers[i]; p_counter = p_obj->p_libvlc->pp_timers[i];
break; break;
...@@ -364,7 +368,8 @@ void __stats_TimerDump( vlc_object_t *p_obj, unsigned int i_id ) ...@@ -364,7 +368,8 @@ void __stats_TimerDump( vlc_object_t *p_obj, unsigned int i_id )
vlc_mutex_lock( &p_obj->p_libvlc->timer_lock ); vlc_mutex_lock( &p_obj->p_libvlc->timer_lock );
for( i = 0 ; i < p_obj->p_libvlc->i_timers; i++ ) for( i = 0 ; i < p_obj->p_libvlc->i_timers; i++ )
{ {
if( p_obj->p_libvlc->pp_timers[i]->i_id == i_id ) if( p_obj->p_libvlc->pp_timers[i]->i_id == i_id
&& p_obj->p_libvlc->pp_timers[i]->p_obj == p_obj )
{ {
p_counter = p_obj->p_libvlc->pp_timers[i]; p_counter = p_obj->p_libvlc->pp_timers[i];
break; break;
...@@ -384,7 +389,24 @@ void __stats_TimersDumpAll( vlc_object_t *p_obj ) ...@@ -384,7 +389,24 @@ void __stats_TimersDumpAll( vlc_object_t *p_obj )
vlc_mutex_unlock( &p_obj->p_libvlc->timer_lock ); vlc_mutex_unlock( &p_obj->p_libvlc->timer_lock );
} }
void __stats_TimersClean( vlc_object_t *p_obj ) void __stats_TimerClean( vlc_object_t *p_obj, int i_id )
{
int i;
vlc_mutex_lock( &p_obj->p_libvlc->timer_lock );
for ( i = p_obj->p_libvlc->i_timers -1 ; i >= 0; i-- )
{
counter_t *p_counter = p_obj->p_libvlc->pp_timers[i];
if( p_counter->i_id == i_id && p_counter->p_obj == p_obj )
{
REMOVE_ELEM( p_obj->p_libvlc->pp_timers,
p_obj->p_libvlc->i_timers, i );
stats_CounterClean( p_counter );
}
}
vlc_mutex_unlock( &p_obj->p_libvlc->timer_lock );
}
void __stats_TimersCleanAll( vlc_object_t *p_obj )
{ {
int i; int i;
vlc_mutex_lock( &p_obj->p_libvlc->timer_lock ); vlc_mutex_lock( &p_obj->p_libvlc->timer_lock );
......
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