Commit 7032788b authored by Clément Stenac's avatar Clément Stenac

Small stats improvements

parent 666dc088
...@@ -683,7 +683,8 @@ static int Init( input_thread_t * p_input, vlc_bool_t b_quick ) ...@@ -683,7 +683,8 @@ static int Init( input_thread_t * p_input, vlc_bool_t b_quick )
/* Prepare statistics */ /* Prepare statistics */
#define INIT_COUNTER( p, type, compute ) p_input->counters.p_##p = \ #define INIT_COUNTER( p, type, compute ) p_input->counters.p_##p = \
stats_CounterCreate( p_input, VLC_VAR_##type, STATS_##compute); stats_CounterCreate( p_input, VLC_VAR_##type, STATS_##compute);
if( p_this->p_libvlc->b_stats )
{
INIT_COUNTER( read_bytes, INTEGER, COUNTER ); INIT_COUNTER( read_bytes, INTEGER, COUNTER );
INIT_COUNTER( read_packets, INTEGER, COUNTER ); INIT_COUNTER( read_packets, INTEGER, COUNTER );
INIT_COUNTER( demux_read, INTEGER, COUNTER ); INIT_COUNTER( demux_read, INTEGER, COUNTER );
...@@ -703,6 +704,7 @@ static int Init( input_thread_t * p_input, vlc_bool_t b_quick ) ...@@ -703,6 +704,7 @@ static int Init( input_thread_t * p_input, vlc_bool_t b_quick )
p_input->counters.p_demux_bitrate->update_interval = 1000000; p_input->counters.p_demux_bitrate->update_interval = 1000000;
if( p_input->counters.p_input_bitrate ) if( p_input->counters.p_input_bitrate )
p_input->counters.p_input_bitrate->update_interval = 1000000; p_input->counters.p_input_bitrate->update_interval = 1000000;
}
vlc_mutex_init( p_input, &p_input->counters.counters_lock ); vlc_mutex_init( p_input, &p_input->counters.counters_lock );
/* handle sout */ /* handle sout */
...@@ -717,11 +719,15 @@ static int Init( input_thread_t * p_input, vlc_bool_t b_quick ) ...@@ -717,11 +719,15 @@ static int Init( input_thread_t * p_input, vlc_bool_t b_quick )
free( psz ); free( psz );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
if( p_input->p_libvlc->b_stats )
{
INIT_COUNTER( sout_sent_packets, INTEGER, COUNTER ); INIT_COUNTER( sout_sent_packets, INTEGER, COUNTER );
INIT_COUNTER (sout_sent_bytes, INTEGER, COUNTER ); INIT_COUNTER (sout_sent_bytes, INTEGER, COUNTER );
INIT_COUNTER( sout_send_bitrate, FLOAT, DERIVATIVE ); INIT_COUNTER( sout_send_bitrate, FLOAT, DERIVATIVE );
if( p_input->counters.p_sout_send_bitrate ) if( p_input->counters.p_sout_send_bitrate )
p_input->counters.p_sout_send_bitrate->update_interval = 1000000; p_input->counters.p_sout_send_bitrate->update_interval =
1000000;
}
} }
free( psz ); free( psz );
} }
......
...@@ -94,9 +94,7 @@ int __stats_Update( vlc_object_t *p_this, counter_t *p_counter, ...@@ -94,9 +94,7 @@ int __stats_Update( vlc_object_t *p_this, counter_t *p_counter,
*/ */
int __stats_Get( vlc_object_t *p_this, counter_t *p_counter, vlc_value_t *val ) int __stats_Get( vlc_object_t *p_this, counter_t *p_counter, vlc_value_t *val )
{ {
if( !p_this->p_libvlc->b_stats ) return VLC_EGENERIC; if( !p_this->p_libvlc->b_stats || p_counter->i_samples == 0 )
if( p_counter->i_samples == 0 )
{ {
val->i_int = val->f_float = 0.0; val->i_int = val->f_float = 0.0;
return VLC_EGENERIC; return VLC_EGENERIC;
......
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