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

Partial rewrite of stats to avoid lookups (Closes:#693)

parent 7a6b8a51
...@@ -56,7 +56,9 @@ struct libvlc_t ...@@ -56,7 +56,9 @@ struct libvlc_t
/* Do stats ? - We keep this boolean to avoid unneeded lookups */ /* Do stats ? - We keep this boolean to avoid unneeded lookups */
vlc_bool_t b_stats; vlc_bool_t b_stats;
stats_handler_t *p_stats; vlc_mutex_t timer_lock;
int i_timers;
counter_t **pp_timers;
/* Arch-specific variables */ /* Arch-specific variables */
#if !defined( WIN32 ) #if !defined( WIN32 )
......
...@@ -77,6 +77,10 @@ struct httpd_host_t ...@@ -77,6 +77,10 @@ struct httpd_host_t
int i_port; int i_port;
int *fd; int *fd;
/* Statistics */
counter_t *p_active_counter;
counter_t *p_total_counter;
vlc_mutex_t lock; vlc_mutex_t lock;
/* all registered url (becarefull that 2 httpd_url_t could point at the same url) /* all registered url (becarefull that 2 httpd_url_t could point at the same url)
......
...@@ -421,6 +421,26 @@ struct input_thread_t ...@@ -421,6 +421,26 @@ struct input_thread_t
int i_slave; int i_slave;
input_source_t **slave; input_source_t **slave;
/* Stats counters */
struct {
counter_t *p_read_packets;
counter_t *p_read_bytes;
counter_t *p_input_bitrate;
counter_t *p_demux_read;
counter_t *p_demux_bitrate;
counter_t *p_decoded_audio;
counter_t *p_decoded_video;
counter_t *p_decoded_sub;
counter_t *p_sout_sent_packets;
counter_t *p_sout_sent_bytes;
counter_t *p_sout_send_bitrate;
counter_t *p_played_abuffers;
counter_t *p_lost_abuffers;
counter_t *p_displayed_pictures;
counter_t *p_lost_pictures;
vlc_mutex_t counters_lock;
} counters;
/* Buffer of pending actions */ /* Buffer of pending actions */
vlc_mutex_t lock_control; vlc_mutex_t lock_control;
int i_control; int i_control;
......
...@@ -228,8 +228,7 @@ struct counter_sample_t ...@@ -228,8 +228,7 @@ struct counter_sample_t
struct counter_t struct counter_t
{ {
/* The list is *NOT* sorted at the moment, it could be ... */ unsigned int i_id;
uint64_t i_index;
char * psz_name; char * psz_name;
int i_type; int i_type;
int i_compute_type; int i_compute_type;
...@@ -267,70 +266,58 @@ enum ...@@ -267,70 +266,58 @@ enum
STATS_TIMER_SKINS_PLAYTREE_IMAGE, STATS_TIMER_SKINS_PLAYTREE_IMAGE,
}; };
struct stats_handler_t #define stats_Update(a,b,c) __stats_Update( VLC_OBJECT(a), b, c )
{ VLC_EXPORT( int, __stats_Update, (vlc_object_t*, counter_t *, vlc_value_t, vlc_value_t *) );
VLC_COMMON_MEMBERS #define stats_CounterCreate(a,b,c) __stats_CounterCreate( VLC_OBJECT(a), b, c )
VLC_EXPORT( counter_t *, __stats_CounterCreate, (vlc_object_t*, int, int) );
int i_counters; #define stats_Get(a,b,c) __stats_Get( VLC_OBJECT(a), b, c)
counter_t **pp_counters; VLC_EXPORT( int, __stats_Get, (vlc_object_t*, counter_t *, vlc_value_t*) );
};
VLC_EXPORT( void, stats_HandlerDestroy, (stats_handler_t*) ); VLC_EXPORT (void, stats_CounterClean, (counter_t * ) );
#define stats_Update(a,b,c,d) __stats_Update( VLC_OBJECT( a ), b, c, d ) #define stats_GetInteger(a,b,c) __stats_GetInteger( VLC_OBJECT(a), b, c )
VLC_EXPORT( int, __stats_Update, (vlc_object_t*, unsigned int, vlc_value_t, vlc_value_t *) ); static inline int __stats_GetInteger( vlc_object_t *p_obj, counter_t *p_counter,
#define stats_Create(a,b,c,d,e) __stats_Create( VLC_OBJECT(a), b, c, d,e ) int *value )
VLC_EXPORT( int, __stats_Create, (vlc_object_t*, const char *, unsigned int, int, int) );
#define stats_Get(a,b,c,d) __stats_Get( VLC_OBJECT(a), b, c, d )
VLC_EXPORT( int, __stats_Get, (vlc_object_t*, int, unsigned int, vlc_value_t*) );
#define stats_CounterGet(a,b,c) __stats_CounterGet( VLC_OBJECT(a), b, c )
VLC_EXPORT( counter_t*, __stats_CounterGet, (vlc_object_t*, int, unsigned int ) );
#define stats_GetInteger(a,b,c,d) __stats_GetInteger( VLC_OBJECT(a), b, c, d )
static inline int __stats_GetInteger( vlc_object_t *p_obj, int i_id,
unsigned int i_counter, int *value )
{ {
int i_ret; int i_ret;
vlc_value_t val; val.i_int = 0; vlc_value_t val; val.i_int = 0;
i_ret = __stats_Get( p_obj, i_id, i_counter, &val ); i_ret = __stats_Get( p_obj, p_counter, &val );
*value = val.i_int; *value = val.i_int;
return i_ret; return i_ret;
} }
#define stats_GetFloat(a,b,c,d) __stats_GetFloat( VLC_OBJECT(a), b, c, d ) #define stats_GetFloat(a,b,c) __stats_GetFloat( VLC_OBJECT(a), b, c )
static inline int __stats_GetFloat( vlc_object_t *p_obj, int i_id, static inline int __stats_GetFloat( vlc_object_t *p_obj, counter_t *p_counter,
unsigned int i_counter, float *value ) float *value )
{ {
int i_ret; int i_ret;
vlc_value_t val; val.f_float = 0.0; vlc_value_t val; val.f_float = 0.0;
i_ret = __stats_Get( p_obj, i_id, i_counter, &val ); i_ret = __stats_Get( p_obj, p_counter, &val );
*value = val.f_float; *value = val.f_float;
return i_ret; return i_ret;
} }
#define stats_UpdateInteger(a,b,c,d) __stats_UpdateInteger( VLC_OBJECT(a),b,c,d ) #define stats_UpdateInteger(a,b,c,d) __stats_UpdateInteger( VLC_OBJECT(a),b,c,d )
static inline int __stats_UpdateInteger( vlc_object_t *p_obj, static inline int __stats_UpdateInteger( vlc_object_t *p_obj,counter_t *p_co,
unsigned int i_counter, int i, int i, int *pi_new )
int *pi_new )
{ {
int i_ret; int i_ret;
vlc_value_t val; vlc_value_t val;
vlc_value_t new_val; new_val.i_int = 0; vlc_value_t new_val; new_val.i_int = 0;
val.i_int = i; val.i_int = i;
i_ret = __stats_Update( p_obj, i_counter, val , &new_val ); i_ret = __stats_Update( p_obj, p_co, val, &new_val );
if( pi_new ) if( pi_new )
*pi_new = new_val.i_int; *pi_new = new_val.i_int;
return i_ret; return i_ret;
} }
#define stats_UpdateFloat(a,b,c,d) __stats_UpdateFloat( VLC_OBJECT(a),b,c,d ) #define stats_UpdateFloat(a,b,c,d) __stats_UpdateFloat( VLC_OBJECT(a),b,c,d )
static inline int __stats_UpdateFloat( vlc_object_t *p_obj, static inline int __stats_UpdateFloat( vlc_object_t *p_obj, counter_t *p_co,
unsigned int i_counter, float f, float f, float *pf_new )
float *pf_new )
{ {
vlc_value_t val; vlc_value_t val;
int i_ret; int i_ret;
vlc_value_t new_val;new_val.f_float = 0.0; vlc_value_t new_val;new_val.f_float = 0.0;
val.f_float = f; val.f_float = f;
i_ret = __stats_Update( p_obj, i_counter, val, &new_val ); i_ret = __stats_Update( p_obj, p_co, val, &new_val );
if( pf_new ) if( pf_new )
*pf_new = new_val.f_float; *pf_new = new_val.f_float;
return i_ret; return i_ret;
...@@ -413,3 +400,5 @@ VLC_EXPORT( void,__stats_TimerStart, (vlc_object_t*, const char *, unsigned int ...@@ -413,3 +400,5 @@ 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) )
VLC_EXPORT( void, __stats_TimersClean, (vlc_object_t * ) );
...@@ -438,16 +438,15 @@ struct module_symbols_t ...@@ -438,16 +438,15 @@ struct module_symbols_t
int (*__intf_UserProgress_inner) (vlc_object_t*, const char*, const char*, float); int (*__intf_UserProgress_inner) (vlc_object_t*, const char*, const char*, float);
void (*__intf_UserProgressUpdate_inner) (vlc_object_t*, int, const char*, float); void (*__intf_UserProgressUpdate_inner) (vlc_object_t*, int, const char*, float);
void (*__intf_UserHide_inner) (vlc_object_t *, int); void (*__intf_UserHide_inner) (vlc_object_t *, int);
int (*__stats_Create_inner) (vlc_object_t*, const char *, unsigned int, int, int); void *__stats_Create_deprecated;
int (*__stats_Update_inner) (vlc_object_t*, unsigned int, vlc_value_t, vlc_value_t *); int (*__stats_Update_inner) (vlc_object_t*, counter_t *, vlc_value_t, vlc_value_t *);
int (*__stats_Get_inner) (vlc_object_t*, int, unsigned int, vlc_value_t*); int (*__stats_Get_inner) (vlc_object_t*, counter_t *, vlc_value_t*);
void (*stats_ComputeInputStats_inner) (input_thread_t*, input_stats_t*); void (*stats_ComputeInputStats_inner) (input_thread_t*, input_stats_t*);
void (*stats_DumpInputStats_inner) (input_stats_t *); void (*stats_DumpInputStats_inner) (input_stats_t *);
void (*stats_ReinitInputStats_inner) (input_stats_t *); void (*stats_ReinitInputStats_inner) (input_stats_t *);
counter_t* (*__stats_CounterGet_inner) (vlc_object_t*, int, unsigned int);
void *__stats_CounterGet_deprecated; void *__stats_CounterGet_deprecated;
input_thread_t * (*__input_CreateThread2_inner) (vlc_object_t *, input_item_t *, char *); input_thread_t * (*__input_CreateThread2_inner) (vlc_object_t *, input_item_t *, char *);
void (*stats_HandlerDestroy_inner) (stats_handler_t*); void *stats_HandlerDestroy_deprecated;
vlc_t * (*vlc_current_object_inner) (int); vlc_t * (*vlc_current_object_inner) (int);
void (*__var_OptionParse_inner) (vlc_object_t *, const char *); void (*__var_OptionParse_inner) (vlc_object_t *, const char *);
void *__stats_TimerDumpAll_deprecated; void *__stats_TimerDumpAll_deprecated;
...@@ -514,6 +513,10 @@ struct module_symbols_t ...@@ -514,6 +513,10 @@ struct module_symbols_t
int (*__intf_UserStringInput_inner) (vlc_object_t*, const char*, const char*, char **); int (*__intf_UserStringInput_inner) (vlc_object_t*, const char*, const char*, char **);
void (*playlist_NodesCreateForSD_inner) (playlist_t *, char *, playlist_item_t **, playlist_item_t **); void (*playlist_NodesCreateForSD_inner) (playlist_t *, char *, playlist_item_t **, playlist_item_t **);
vlc_bool_t (*input_AddSubtitles_inner) (input_thread_t *, char *, vlc_bool_t); vlc_bool_t (*input_AddSubtitles_inner) (input_thread_t *, char *, vlc_bool_t);
counter_t * (*__stats_CounterCreate_inner) (vlc_object_t*, int, int);
void *stats_TimerClean_deprecated;
void *stats_TimersClean_deprecated;
void (*__stats_TimersClean_inner) (vlc_object_t *);
}; };
# if defined (__PLUGIN__) # if defined (__PLUGIN__)
# define aout_FiltersCreatePipeline (p_symbols)->aout_FiltersCreatePipeline_inner # define aout_FiltersCreatePipeline (p_symbols)->aout_FiltersCreatePipeline_inner
...@@ -909,15 +912,12 @@ struct module_symbols_t ...@@ -909,15 +912,12 @@ struct module_symbols_t
# define __intf_UserProgress (p_symbols)->__intf_UserProgress_inner # define __intf_UserProgress (p_symbols)->__intf_UserProgress_inner
# define __intf_UserProgressUpdate (p_symbols)->__intf_UserProgressUpdate_inner # define __intf_UserProgressUpdate (p_symbols)->__intf_UserProgressUpdate_inner
# define __intf_UserHide (p_symbols)->__intf_UserHide_inner # define __intf_UserHide (p_symbols)->__intf_UserHide_inner
# define __stats_Create (p_symbols)->__stats_Create_inner
# define __stats_Update (p_symbols)->__stats_Update_inner # define __stats_Update (p_symbols)->__stats_Update_inner
# define __stats_Get (p_symbols)->__stats_Get_inner # define __stats_Get (p_symbols)->__stats_Get_inner
# define stats_ComputeInputStats (p_symbols)->stats_ComputeInputStats_inner # define stats_ComputeInputStats (p_symbols)->stats_ComputeInputStats_inner
# define stats_DumpInputStats (p_symbols)->stats_DumpInputStats_inner # define stats_DumpInputStats (p_symbols)->stats_DumpInputStats_inner
# define stats_ReinitInputStats (p_symbols)->stats_ReinitInputStats_inner # define stats_ReinitInputStats (p_symbols)->stats_ReinitInputStats_inner
# define __stats_CounterGet (p_symbols)->__stats_CounterGet_inner
# define __input_CreateThread2 (p_symbols)->__input_CreateThread2_inner # define __input_CreateThread2 (p_symbols)->__input_CreateThread2_inner
# define stats_HandlerDestroy (p_symbols)->stats_HandlerDestroy_inner
# define vlc_current_object (p_symbols)->vlc_current_object_inner # define vlc_current_object (p_symbols)->vlc_current_object_inner
# define __var_OptionParse (p_symbols)->__var_OptionParse_inner # define __var_OptionParse (p_symbols)->__var_OptionParse_inner
# define __stats_TimerDump (p_symbols)->__stats_TimerDump_inner # define __stats_TimerDump (p_symbols)->__stats_TimerDump_inner
...@@ -982,6 +982,8 @@ struct module_symbols_t ...@@ -982,6 +982,8 @@ struct module_symbols_t
# define __intf_UserStringInput (p_symbols)->__intf_UserStringInput_inner # define __intf_UserStringInput (p_symbols)->__intf_UserStringInput_inner
# define playlist_NodesCreateForSD (p_symbols)->playlist_NodesCreateForSD_inner # define playlist_NodesCreateForSD (p_symbols)->playlist_NodesCreateForSD_inner
# define input_AddSubtitles (p_symbols)->input_AddSubtitles_inner # define input_AddSubtitles (p_symbols)->input_AddSubtitles_inner
# define __stats_CounterCreate (p_symbols)->__stats_CounterCreate_inner
# define __stats_TimersClean (p_symbols)->__stats_TimersClean_inner
# elif defined (HAVE_DYNAMIC_PLUGINS) && !defined (__BUILTIN__) # elif defined (HAVE_DYNAMIC_PLUGINS) && !defined (__BUILTIN__)
/****************************************************************** /******************************************************************
* STORE_SYMBOLS: store VLC APIs into p_symbols for plugin access. * STORE_SYMBOLS: store VLC APIs into p_symbols for plugin access.
...@@ -1380,15 +1382,12 @@ struct module_symbols_t ...@@ -1380,15 +1382,12 @@ struct module_symbols_t
((p_symbols)->__intf_UserProgress_inner) = __intf_UserProgress; \ ((p_symbols)->__intf_UserProgress_inner) = __intf_UserProgress; \
((p_symbols)->__intf_UserProgressUpdate_inner) = __intf_UserProgressUpdate; \ ((p_symbols)->__intf_UserProgressUpdate_inner) = __intf_UserProgressUpdate; \
((p_symbols)->__intf_UserHide_inner) = __intf_UserHide; \ ((p_symbols)->__intf_UserHide_inner) = __intf_UserHide; \
((p_symbols)->__stats_Create_inner) = __stats_Create; \
((p_symbols)->__stats_Update_inner) = __stats_Update; \ ((p_symbols)->__stats_Update_inner) = __stats_Update; \
((p_symbols)->__stats_Get_inner) = __stats_Get; \ ((p_symbols)->__stats_Get_inner) = __stats_Get; \
((p_symbols)->stats_ComputeInputStats_inner) = stats_ComputeInputStats; \ ((p_symbols)->stats_ComputeInputStats_inner) = stats_ComputeInputStats; \
((p_symbols)->stats_DumpInputStats_inner) = stats_DumpInputStats; \ ((p_symbols)->stats_DumpInputStats_inner) = stats_DumpInputStats; \
((p_symbols)->stats_ReinitInputStats_inner) = stats_ReinitInputStats; \ ((p_symbols)->stats_ReinitInputStats_inner) = stats_ReinitInputStats; \
((p_symbols)->__stats_CounterGet_inner) = __stats_CounterGet; \
((p_symbols)->__input_CreateThread2_inner) = __input_CreateThread2; \ ((p_symbols)->__input_CreateThread2_inner) = __input_CreateThread2; \
((p_symbols)->stats_HandlerDestroy_inner) = stats_HandlerDestroy; \
((p_symbols)->vlc_current_object_inner) = vlc_current_object; \ ((p_symbols)->vlc_current_object_inner) = vlc_current_object; \
((p_symbols)->__var_OptionParse_inner) = __var_OptionParse; \ ((p_symbols)->__var_OptionParse_inner) = __var_OptionParse; \
((p_symbols)->__stats_TimerDump_inner) = __stats_TimerDump; \ ((p_symbols)->__stats_TimerDump_inner) = __stats_TimerDump; \
...@@ -1453,6 +1452,8 @@ struct module_symbols_t ...@@ -1453,6 +1452,8 @@ struct module_symbols_t
((p_symbols)->__intf_UserStringInput_inner) = __intf_UserStringInput; \ ((p_symbols)->__intf_UserStringInput_inner) = __intf_UserStringInput; \
((p_symbols)->playlist_NodesCreateForSD_inner) = playlist_NodesCreateForSD; \ ((p_symbols)->playlist_NodesCreateForSD_inner) = playlist_NodesCreateForSD; \
((p_symbols)->input_AddSubtitles_inner) = input_AddSubtitles; \ ((p_symbols)->input_AddSubtitles_inner) = input_AddSubtitles; \
((p_symbols)->__stats_CounterCreate_inner) = __stats_CounterCreate; \
((p_symbols)->__stats_TimersClean_inner) = __stats_TimersClean; \
(p_symbols)->net_ConvertIPv4_deprecated = NULL; \ (p_symbols)->net_ConvertIPv4_deprecated = NULL; \
(p_symbols)->__playlist_ItemCopy_deprecated = NULL; \ (p_symbols)->__playlist_ItemCopy_deprecated = NULL; \
(p_symbols)->playlist_ItemAddParent_deprecated = NULL; \ (p_symbols)->playlist_ItemAddParent_deprecated = NULL; \
...@@ -1479,9 +1480,13 @@ struct module_symbols_t ...@@ -1479,9 +1480,13 @@ struct module_symbols_t
(p_symbols)->playlist_Sort_deprecated = NULL; \ (p_symbols)->playlist_Sort_deprecated = NULL; \
(p_symbols)->playlist_Move_deprecated = NULL; \ (p_symbols)->playlist_Move_deprecated = NULL; \
(p_symbols)->playlist_NodeRemoveParent_deprecated = NULL; \ (p_symbols)->playlist_NodeRemoveParent_deprecated = NULL; \
(p_symbols)->__stats_Create_deprecated = NULL; \
(p_symbols)->__stats_CounterGet_deprecated = NULL; \ (p_symbols)->__stats_CounterGet_deprecated = NULL; \
(p_symbols)->stats_HandlerDestroy_deprecated = NULL; \
(p_symbols)->__stats_TimerDumpAll_deprecated = NULL; \ (p_symbols)->__stats_TimerDumpAll_deprecated = NULL; \
(p_symbols)->playlist_ItemNewFromInput_deprecated = NULL; \ (p_symbols)->playlist_ItemNewFromInput_deprecated = NULL; \
(p_symbols)->stats_TimerClean_deprecated = NULL; \
(p_symbols)->stats_TimersClean_deprecated = NULL; \
# endif /* __PLUGIN__ */ # endif /* __PLUGIN__ */
#endif /* __VLC_SYMBOLS_H */ #endif /* __VLC_SYMBOLS_H */
...@@ -312,8 +312,11 @@ int aout_DecPlay( aout_instance_t * p_aout, aout_input_t * p_input, ...@@ -312,8 +312,11 @@ int aout_DecPlay( aout_instance_t * p_aout, aout_input_t * p_input,
p_buffer->start_date - mdate()); p_buffer->start_date - mdate());
if( p_input->p_input_thread ) if( p_input->p_input_thread )
{ {
stats_UpdateInteger( p_input->p_input_thread, STATS_LOST_ABUFFERS, 1, vlc_mutex_lock( &p_input->p_input_thread->counters.counters_lock);
NULL ); stats_UpdateInteger( p_aout,
p_input->p_input_thread->counters.p_lost_abuffers,
1, NULL );
vlc_mutex_unlock( &p_input->p_input_thread->counters.counters_lock);
} }
aout_BufferFree( p_buffer ); aout_BufferFree( p_buffer );
return -1; return -1;
...@@ -367,8 +370,11 @@ int aout_DecPlay( aout_instance_t * p_aout, aout_input_t * p_input, ...@@ -367,8 +370,11 @@ int aout_DecPlay( aout_instance_t * p_aout, aout_input_t * p_input,
aout_MixerRun( p_aout ); aout_MixerRun( p_aout );
if( p_input->p_input_thread ) if( p_input->p_input_thread )
{ {
stats_UpdateInteger( p_input->p_input_thread, vlc_mutex_lock( &p_input->p_input_thread->counters.counters_lock);
STATS_PLAYED_ABUFFERS, 1, NULL ); stats_UpdateInteger( p_aout,
p_input->p_input_thread->counters.p_lost_abuffers,
1, NULL );
vlc_mutex_unlock( &p_input->p_input_thread->counters.counters_lock);
} }
vlc_mutex_unlock( &p_aout->mixer_lock ); vlc_mutex_unlock( &p_aout->mixer_lock );
......
...@@ -449,8 +449,9 @@ int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input, ...@@ -449,8 +449,9 @@ int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
start_date = 0; start_date = 0;
if( p_input->p_input_thread ) if( p_input->p_input_thread )
{ {
stats_UpdateInteger( p_input->p_input_thread, STATS_LOST_ABUFFERS, 1, vlc_mutex_lock( &p_input->p_input_thread->counters.counters_lock);
NULL ); stats_UpdateInteger( p_aout, p_input->p_input_thread->counters.p_lost_abuffers, 1, NULL );
vlc_mutex_unlock( &p_input->p_input_thread->counters.counters_lock);
} }
} }
...@@ -462,8 +463,9 @@ int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input, ...@@ -462,8 +463,9 @@ int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
mdate() - p_buffer->start_date ); mdate() - p_buffer->start_date );
if( p_input->p_input_thread ) if( p_input->p_input_thread )
{ {
stats_UpdateInteger( p_input->p_input_thread, STATS_LOST_ABUFFERS, vlc_mutex_lock( &p_input->p_input_thread->counters.counters_lock);
1, NULL ); stats_UpdateInteger( p_aout, p_input->p_input_thread->counters.p_lost_abuffers, 1, NULL );
vlc_mutex_unlock( &p_input->p_input_thread->counters.counters_lock);
} }
aout_BufferFree( p_buffer ); aout_BufferFree( p_buffer );
p_input->i_resampling_type = AOUT_RESAMPLING_NONE; p_input->i_resampling_type = AOUT_RESAMPLING_NONE;
...@@ -504,8 +506,9 @@ int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input, ...@@ -504,8 +506,9 @@ int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
aout_BufferFree( p_buffer ); aout_BufferFree( p_buffer );
if( p_input->p_input_thread ) if( p_input->p_input_thread )
{ {
stats_UpdateInteger( p_input->p_input_thread, STATS_LOST_ABUFFERS, vlc_mutex_lock( &p_input->p_input_thread->counters.counters_lock);
1, NULL ); stats_UpdateInteger( p_aout, p_input->p_input_thread->counters.p_lost_abuffers, 1, NULL );
vlc_mutex_unlock( &p_input->p_input_thread->counters.counters_lock);
} }
return 0; return 0;
} }
......
...@@ -429,12 +429,6 @@ static decoder_t * CreateDecoder( input_thread_t *p_input, ...@@ -429,12 +429,6 @@ static decoder_t * CreateDecoder( input_thread_t *p_input,
vlc_object_attach( p_dec, p_input ); vlc_object_attach( p_dec, p_input );
stats_Create( p_dec->p_parent, "decoded_audio", STATS_DECODED_AUDIO,
VLC_VAR_INTEGER, STATS_COUNTER );
stats_Create( p_dec->p_parent, "decoded_video", STATS_DECODED_VIDEO,
VLC_VAR_INTEGER, STATS_COUNTER );
stats_Create( p_dec->p_parent, "decoded_sub", STATS_DECODED_SUB,
VLC_VAR_INTEGER, STATS_COUNTER );
/* Find a suitable decoder/packetizer module */ /* Find a suitable decoder/packetizer module */
if( i_object_type == VLC_OBJECT_DECODER ) if( i_object_type == VLC_OBJECT_DECODER )
p_dec->p_module = module_Need( p_dec, "decoder", "$codec", 0 ); p_dec->p_module = module_Need( p_dec, "decoder", "$codec", 0 );
...@@ -627,9 +621,14 @@ static int DecoderDecode( decoder_t *p_dec, block_t *p_block ) ...@@ -627,9 +621,14 @@ static int DecoderDecode( decoder_t *p_dec, block_t *p_block )
while( (p_aout_buf = p_dec->pf_decode_audio( p_dec, while( (p_aout_buf = p_dec->pf_decode_audio( p_dec,
&p_packetized_block )) ) &p_packetized_block )) )
{ {
stats_UpdateInteger( p_dec->p_parent, input_thread_t *p_i =(input_thread_t*)(p_dec->p_parent);
STATS_DECODED_AUDIO, 1, NULL ); vlc_mutex_lock( &p_i->counters.counters_lock );
/* FIXME the best would be to handle the case start_date < preroll < end_date stats_UpdateInteger( p_dec,
p_i->counters.p_decoded_audio, 1, NULL );
vlc_mutex_unlock( &p_i->counters.counters_lock );
/* FIXME the best would be to handle the case
* start_date < preroll < end_date
* but that's not easy with non raw audio stream */ * but that's not easy with non raw audio stream */
if( p_dec->p_owner->i_preroll_end > 0 && if( p_dec->p_owner->i_preroll_end > 0 &&
p_aout_buf->start_date < p_dec->p_owner->i_preroll_end ) p_aout_buf->start_date < p_dec->p_owner->i_preroll_end )
...@@ -652,7 +651,12 @@ static int DecoderDecode( decoder_t *p_dec, block_t *p_block ) ...@@ -652,7 +651,12 @@ static int DecoderDecode( decoder_t *p_dec, block_t *p_block )
} }
else while( (p_aout_buf = p_dec->pf_decode_audio( p_dec, &p_block )) ) else while( (p_aout_buf = p_dec->pf_decode_audio( p_dec, &p_block )) )
{ {
stats_UpdateInteger( p_dec->p_parent, STATS_DECODED_AUDIO, 1, NULL ); input_thread_t *p_i = (input_thread_t*)(p_dec->p_parent);
vlc_mutex_lock( &p_i->counters.counters_lock );
stats_UpdateInteger( p_dec,
p_i->counters.p_decoded_audio, 1, NULL );
vlc_mutex_unlock( &p_i->counters.counters_lock );
if( p_dec->p_owner->i_preroll_end > 0 && if( p_dec->p_owner->i_preroll_end > 0 &&
p_aout_buf->start_date < p_dec->p_owner->i_preroll_end ) p_aout_buf->start_date < p_dec->p_owner->i_preroll_end )
{ {
...@@ -698,8 +702,12 @@ static int DecoderDecode( decoder_t *p_dec, block_t *p_block ) ...@@ -698,8 +702,12 @@ static int DecoderDecode( decoder_t *p_dec, block_t *p_block )
while( (p_pic = p_dec->pf_decode_video( p_dec, while( (p_pic = p_dec->pf_decode_video( p_dec,
&p_packetized_block )) ) &p_packetized_block )) )
{ {
stats_UpdateInteger( p_dec->p_parent, STATS_DECODED_VIDEO, input_thread_t *p_i =(input_thread_t*)(p_dec->p_parent);
1, NULL ); vlc_mutex_lock( &p_i->counters.counters_lock );
stats_UpdateInteger( p_dec,
p_i->counters.p_decoded_video, 1, NULL );
vlc_mutex_unlock( &p_i->counters.counters_lock );
if( p_dec->p_owner->i_preroll_end > 0 && if( p_dec->p_owner->i_preroll_end > 0 &&
p_pic->date < p_dec->p_owner->i_preroll_end ) p_pic->date < p_dec->p_owner->i_preroll_end )
{ {
...@@ -720,7 +728,12 @@ static int DecoderDecode( decoder_t *p_dec, block_t *p_block ) ...@@ -720,7 +728,12 @@ static int DecoderDecode( decoder_t *p_dec, block_t *p_block )
} }
else while( (p_pic = p_dec->pf_decode_video( p_dec, &p_block )) ) else while( (p_pic = p_dec->pf_decode_video( p_dec, &p_block )) )
{ {
stats_UpdateInteger( p_dec->p_parent, STATS_DECODED_VIDEO, 1 , NULL); input_thread_t *p_i = (input_thread_t*)(p_dec->p_parent);
vlc_mutex_lock( &p_i->counters.counters_lock );
stats_UpdateInteger( p_dec,
p_i->counters.p_decoded_video, 1, NULL );
vlc_mutex_unlock( &p_i->counters.counters_lock );
if( p_dec->p_owner->i_preroll_end > 0 && if( p_dec->p_owner->i_preroll_end > 0 &&
p_pic->date < p_dec->p_owner->i_preroll_end ) p_pic->date < p_dec->p_owner->i_preroll_end )
{ {
...@@ -740,7 +753,12 @@ static int DecoderDecode( decoder_t *p_dec, block_t *p_block ) ...@@ -740,7 +753,12 @@ static int DecoderDecode( decoder_t *p_dec, block_t *p_block )
subpicture_t *p_spu; subpicture_t *p_spu;
while( (p_spu = p_dec->pf_decode_sub( p_dec, &p_block ) ) ) while( (p_spu = p_dec->pf_decode_sub( p_dec, &p_block ) ) )
{ {
stats_UpdateInteger( p_dec->p_parent, STATS_DECODED_SUB, 1 , NULL); input_thread_t *p_i = (input_thread_t*)(p_dec->p_parent);
vlc_mutex_lock( &p_i->counters.counters_lock );
stats_UpdateInteger( p_dec,
p_i->counters.p_decoded_sub, 1, NULL );
vlc_mutex_unlock( &p_i->counters.counters_lock );
if( p_dec->p_owner->i_preroll_end > 0 && if( p_dec->p_owner->i_preroll_end > 0 &&
p_spu->i_start < p_dec->p_owner->i_preroll_end && p_spu->i_start < p_dec->p_owner->i_preroll_end &&
( p_spu->i_stop <= 0 || p_spu->i_stop <= p_dec->p_owner->i_preroll_end ) ) ( p_spu->i_stop <= 0 || p_spu->i_stop <= p_dec->p_owner->i_preroll_end ) )
......
...@@ -1025,9 +1025,12 @@ static int EsOutSend( es_out_t *out, es_out_id_t *es, block_t *p_block ) ...@@ -1025,9 +1025,12 @@ static int EsOutSend( es_out_t *out, es_out_id_t *es, block_t *p_block )
if( p_input->p_libvlc->b_stats ) if( p_input->p_libvlc->b_stats )
{ {
stats_UpdateInteger( p_input, STATS_DEMUX_READ, p_block->i_buffer, vlc_mutex_lock( &p_input->counters.counters_lock );
&i_total ); stats_UpdateInteger( p_input, p_input->counters.p_demux_read,
stats_UpdateFloat( p_input , STATS_DEMUX_BITRATE, (float)i_total, NULL ); p_block->i_buffer, &i_total );
stats_UpdateFloat( p_input , p_input->counters.p_demux_bitrate,
(float)i_total, NULL );
vlc_mutex_unlock( &p_input->counters.counters_lock );
} }
/* Mark preroll blocks */ /* Mark preroll blocks */
......
...@@ -679,29 +679,27 @@ static int Init( input_thread_t * p_input, vlc_bool_t b_quick ) ...@@ -679,29 +679,27 @@ static int Init( input_thread_t * p_input, vlc_bool_t b_quick )
if( !b_quick ) if( !b_quick )
{ {
/* Prepare statistics */ /* Prepare statistics */
counter_t *p_counter; #define INIT_COUNTER( p, type, compute ) p_input->counters.p_##p = \
stats_Create( p_input, "read_bytes", STATS_READ_BYTES, stats_CounterCreate( p_input, VLC_VAR_##type, STATS_##compute);
VLC_VAR_INTEGER, STATS_COUNTER );
stats_Create( p_input, "read_packets", STATS_READ_PACKETS, INIT_COUNTER( read_bytes, INTEGER, COUNTER );
VLC_VAR_INTEGER, STATS_COUNTER ); INIT_COUNTER( read_packets, INTEGER, COUNTER );
stats_Create( p_input, "demux_read", STATS_DEMUX_READ, INIT_COUNTER( demux_read, INTEGER, COUNTER );
VLC_VAR_INTEGER, STATS_COUNTER ); INIT_COUNTER( input_bitrate, FLOAT, DERIVATIVE );
stats_Create( p_input, "input_bitrate", STATS_INPUT_BITRATE, INIT_COUNTER( demux_bitrate, FLOAT, DERIVATIVE );
VLC_VAR_FLOAT, STATS_DERIVATIVE ); INIT_COUNTER( played_abuffers, INTEGER, COUNTER );
stats_Create( p_input, "demux_bitrate", STATS_DEMUX_BITRATE, INIT_COUNTER( lost_abuffers, INTEGER, COUNTER );
VLC_VAR_FLOAT, STATS_DERIVATIVE ); INIT_COUNTER( displayed_pictures, INTEGER, COUNTER );
INIT_COUNTER( lost_pictures, INTEGER, COUNTER );
p_counter = stats_CounterGet( p_input, p_input->i_object_id, INIT_COUNTER( decoded_audio, INTEGER, COUNTER );
STATS_INPUT_BITRATE ); INIT_COUNTER( decoded_video, INTEGER, COUNTER );
if( p_counter ) p_counter->update_interval = 1000000; INIT_COUNTER( decoded_sub, INTEGER, COUNTER );
p_counter = stats_CounterGet( p_input, p_input->i_object_id, p_input->counters.p_sout_send_bitrate = NULL;
STATS_DEMUX_BITRATE ); p_input->counters.p_sout_sent_packets = NULL;
if( p_counter ) p_counter->update_interval = 1000000; p_input->counters.p_sout_sent_bytes = NULL;
p_input->counters.p_demux_bitrate->update_interval = 1000000;
stats_Create( p_input, "played_abuffers", STATS_PLAYED_ABUFFERS, p_input->counters.p_input_bitrate->update_interval = 1000000;
VLC_VAR_INTEGER, STATS_COUNTER ); vlc_mutex_init( p_input, &p_input->counters.counters_lock );
stats_Create( p_input, "lost_abuffers", STATS_LOST_ABUFFERS,
VLC_VAR_INTEGER, STATS_COUNTER );
/* handle sout */ /* handle sout */
psz = var_GetString( p_input, "sout" ); psz = var_GetString( p_input, "sout" );
...@@ -715,6 +713,10 @@ static int Init( input_thread_t * p_input, vlc_bool_t b_quick ) ...@@ -715,6 +713,10 @@ static int Init( input_thread_t * p_input, vlc_bool_t b_quick )
free( psz ); free( psz );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
INIT_COUNTER( sout_sent_packets, INTEGER, COUNTER );
INIT_COUNTER (sout_sent_bytes, INTEGER, COUNTER );
INIT_COUNTER( sout_send_bitrate, FLOAT, DERIVATIVE );
p_input->counters.p_sout_send_bitrate->update_interval = 1000000;
} }
free( psz ); free( psz );
} }
...@@ -1105,6 +1107,22 @@ static void End( input_thread_t * p_input ) ...@@ -1105,6 +1107,22 @@ static void End( input_thread_t * p_input )
if( p_input->p_es_out ) if( p_input->p_es_out )
input_EsOutDelete( p_input->p_es_out ); input_EsOutDelete( p_input->p_es_out );
#define CL_CO( c ) stats_CounterClean( p_input->counters.p_##c )
CL_CO( read_bytes );
CL_CO( read_packets );
CL_CO( demux_read );
CL_CO( input_bitrate );
CL_CO( demux_bitrate );
CL_CO( played_abuffers );
CL_CO( lost_abuffers );
CL_CO( displayed_pictures );
CL_CO( lost_pictures );
CL_CO( decoded_audio) ;
CL_CO( decoded_video );
CL_CO( decoded_sub) ;
CL_CO( read_bytes );
/* Close optional stream output instance */ /* Close optional stream output instance */
if( p_input->p_sout ) if( p_input->p_sout )
{ {
...@@ -1112,6 +1130,10 @@ static void End( input_thread_t * p_input ) ...@@ -1112,6 +1130,10 @@ static void End( input_thread_t * p_input )
vlc_object_find( p_input, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); vlc_object_find( p_input, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
vlc_value_t keep; vlc_value_t keep;
CL_CO( sout_sent_packets );
CL_CO( sout_sent_bytes );
CL_CO( sout_send_bitrate );
if( var_Get( p_input, "sout-keep", &keep ) >= 0 && keep.b_bool && p_pl ) if( var_Get( p_input, "sout-keep", &keep ) >= 0 && keep.b_bool && p_pl )
{ {
/* attach sout to the playlist */ /* attach sout to the playlist */
...@@ -1128,6 +1150,7 @@ static void End( input_thread_t * p_input ) ...@@ -1128,6 +1150,7 @@ static void End( input_thread_t * p_input )
vlc_object_release( p_pl ); vlc_object_release( p_pl );
} }
#undef CL_CO
/* Tell we're dead */ /* Tell we're dead */
p_input->b_dead = VLC_TRUE; p_input->b_dead = VLC_TRUE;
} }
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <vlc/vlc.h> #include <vlc/vlc.h>
#include <vlc/input.h> #include <vlc/input.h>
#include <assert.h>
#include "input_internal.h" #include "input_internal.h"
...@@ -1577,15 +1578,19 @@ static int AReadStream( stream_t *s, void *p_read, int i_read ) ...@@ -1577,15 +1578,19 @@ static int AReadStream( stream_t *s, void *p_read, int i_read )
int i_read_orig = i_read; int i_read_orig = i_read;
int i_total; int i_total;
input_thread_t *p_input = (input_thread_t *)s->p_parent->p_parent ;
assert( p_input );
if( !p_sys->i_list ) if( !p_sys->i_list )
{ {
i_read = p_access->pf_read( p_access, p_read, i_read ); i_read = p_access->pf_read( p_access, p_read, i_read );
stats_UpdateInteger( s->p_parent->p_parent , STATS_READ_BYTES, i_read, vlc_mutex_lock( &p_input->counters.counters_lock );
stats_UpdateInteger( s, p_input->counters.p_read_bytes, i_read,
&i_total ); &i_total );
stats_UpdateFloat( s->p_parent->p_parent ,