]> git.sesse.net Git - vlc/blobdiff - src/misc/stats.c
Some old stats fixes
[vlc] / src / misc / stats.c
index 87d3a1308ea0fa29070634b04bcae2f6dfe1e917..d4f0beae06c96db4b3eb20c8c5229a0fff3bd88a 100644 (file)
@@ -54,10 +54,7 @@ static void TimerDump( vlc_object_t *p_this, counter_t *p_counter, vlc_bool_t);
 counter_t * __stats_CounterCreate( vlc_object_t *p_this,
                                    int i_type, int i_compute_type )
 {
-    counter_t *p_counter;
-    if( !p_this->p_libvlc->b_stats ) return NULL;
-
-    p_counter = (counter_t*) malloc( sizeof( counter_t ) ) ;
+    counter_t *p_counter = (counter_t*) malloc( sizeof( counter_t ) ) ;
 
     p_counter->i_compute_type = i_compute_type;
     p_counter->i_type = i_type;
@@ -81,7 +78,7 @@ counter_t * __stats_CounterCreate( vlc_object_t *p_this,
 int __stats_Update( vlc_object_t *p_this, counter_t *p_counter,
                     vlc_value_t val, vlc_value_t *val_new )
 {
-    if( !p_this->p_libvlc->b_stats ) return VLC_EGENERIC;
+    if( !p_this->p_libvlc->b_stats || !p_counter ) return VLC_EGENERIC;
     return CounterUpdate( p_this, p_counter, val, val_new );
 }
 
@@ -94,9 +91,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 )
 {
-    if( !p_this->p_libvlc->b_stats ) return VLC_EGENERIC;
-
-    if( p_counter->i_samples == 0 )
+    if( !p_this->p_libvlc->b_stats || !p_counter || p_counter->i_samples == 0 )
     {
         val->i_int = val->f_float = 0.0;
         return VLC_EGENERIC;
@@ -147,7 +142,7 @@ void stats_ComputeInputStats( input_thread_t *p_input, input_stats_t *p_stats )
     /* Input */
     stats_GetInteger( p_input, p_input->counters.p_read_packets,
                       &p_stats->i_read_packets );
-    stats_GetInteger( p_input, p_input->counters.p_read_bytes, 
+    stats_GetInteger( p_input, p_input->counters.p_read_bytes,
                       &p_stats->i_read_bytes );
     stats_GetFloat( p_input, p_input->counters.p_input_bitrate,
                     &p_stats->f_input_bitrate );