]> git.sesse.net Git - vlc/commitdiff
Remove redundant object parameter to stats functions
authorRémi Denis-Courmont <remi@remlab.net>
Tue, 29 Nov 2011 18:00:02 +0000 (20:00 +0200)
committerRémi Denis-Courmont <remi@remlab.net>
Tue, 29 Nov 2011 18:00:02 +0000 (20:00 +0200)
src/input/decoder.c
src/input/es_out.c
src/input/input.c
src/input/stream.c
src/libvlc.h
src/misc/stats.c
src/network/httpd.c

index ad6d37ceb486d7a61d164b7ec08f77f0805706f7..aba9d723ed9b0955f543437773fd8fcfa3e8683a 100644 (file)
@@ -1328,11 +1328,11 @@ static void DecoderDecodeAudio( decoder_t *p_dec, block_t *p_block )
     {
         vlc_mutex_lock( &p_input->p->counters.counters_lock);
 
-        stats_UpdateInteger( p_dec, p_input->p->counters.p_lost_abuffers,
+        stats_UpdateInteger( p_input->p->counters.p_lost_abuffers,
                              i_lost, NULL );
-        stats_UpdateInteger( p_dec, p_input->p->counters.p_played_abuffers,
+        stats_UpdateInteger( p_input->p->counters.p_played_abuffers,
                              i_played, NULL );
-        stats_UpdateInteger( p_dec, p_input->p->counters.p_decoded_audio,
+        stats_UpdateInteger( p_input->p->counters.p_decoded_audio,
                              i_decoded, NULL );
 
         vlc_mutex_unlock( &p_input->p->counters.counters_lock);
@@ -1557,12 +1557,12 @@ static void DecoderDecodeVideo( decoder_t *p_dec, block_t *p_block )
     {
         vlc_mutex_lock( &p_input->p->counters.counters_lock );
 
-        stats_UpdateInteger( p_dec, p_input->p->counters.p_decoded_video,
+        stats_UpdateInteger( p_input->p->counters.p_decoded_video,
                              i_decoded, NULL );
-        stats_UpdateInteger( p_dec, p_input->p->counters.p_lost_pictures,
+        stats_UpdateInteger( p_input->p->counters.p_lost_pictures,
                              i_lost , NULL);
 
-        stats_UpdateInteger( p_dec, p_input->p->counters.p_displayed_pictures,
+        stats_UpdateInteger( p_input->p->counters.p_displayed_pictures,
                              i_displayed, NULL);
 
         vlc_mutex_unlock( &p_input->p->counters.counters_lock );
@@ -1956,8 +1956,7 @@ static void DecoderProcessSpu( decoder_t *p_dec, block_t *p_block, bool b_flush
         if( p_input != NULL )
         {
             vlc_mutex_lock( &p_input->p->counters.counters_lock );
-            stats_UpdateInteger( p_dec, p_input->p->counters.p_decoded_sub, 1,
-                                 NULL );
+            stats_UpdateInteger( p_input->p->counters.p_decoded_sub, 1, NULL );
             vlc_mutex_unlock( &p_input->p->counters.counters_lock );
         }
 
index 9ae8b36170a570264cbcdb10a0ac753ab1e2fad8..7caff19e7731986292a084ae27968b9732320677 100644 (file)
@@ -1925,21 +1925,21 @@ static int EsOutSend( es_out_t *out, es_out_id_t *es, block_t *p_block )
     if( libvlc_stats( p_input ) )
     {
         vlc_mutex_lock( &p_input->p->counters.counters_lock );
-        stats_UpdateInteger( p_input, p_input->p->counters.p_demux_read,
+        stats_UpdateInteger( p_input->p->counters.p_demux_read,
                              p_block->i_buffer, &i_total );
-        stats_UpdateFloat( p_input , p_input->p->counters.p_demux_bitrate,
+        stats_UpdateFloat( p_input->p->counters.p_demux_bitrate,
                            (float)i_total, NULL );
 
         /* Update number of corrupted data packats */
         if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
         {
-            stats_UpdateInteger( p_input, p_input->p->counters.p_demux_corrupted,
+            stats_UpdateInteger( p_input->p->counters.p_demux_corrupted,
                                  1, NULL );
         }
         /* Update number of discontinuities */
         if( p_block->i_flags & BLOCK_FLAG_DISCONTINUITY )
         {
-            stats_UpdateInteger( p_input, p_input->p->counters.p_demux_discontinuity,
+            stats_UpdateInteger( p_input->p->counters.p_demux_discontinuity,
                                  1, NULL );
         }
         vlc_mutex_unlock( &p_input->p->counters.counters_lock );
index 2668bb56f4b92f245ce2148eb5e231b886626a73..568599dda2b0211d379c2c3404059ca160ee48e3 100644 (file)
@@ -852,7 +852,7 @@ static void InitStatistics( input_thread_t * p_input )
 
     /* Prepare statistics */
 #define INIT_COUNTER( c, type, compute ) p_input->p->counters.p_##c = \
- stats_CounterCreate( p_input, VLC_VAR_##type, STATS_##compute);
+ stats_CounterCreate( VLC_VAR_##type, STATS_##compute);
     if( libvlc_stats( p_input ) )
     {
         INIT_COUNTER( read_bytes, INTEGER, COUNTER );
@@ -3202,7 +3202,7 @@ void input_UpdateStatistic( input_thread_t *p_input,
     vlc_mutex_lock( &p_input->p->counters.counters_lock);
     switch( i_type )
     {
-#define I(c) stats_UpdateInteger( p_input, p_input->p->counters.c, i_delta, NULL )
+#define I(c) stats_UpdateInteger( p_input->p->counters.c, i_delta, NULL )
     case INPUT_STATISTIC_DECODED_VIDEO:
         I(p_decoded_video);
         break;
@@ -3220,8 +3220,8 @@ void input_UpdateStatistic( input_thread_t *p_input,
     {
         int i_bytes; /* That's pretty stupid to define it as an integer, it will overflow
                         really fast ... */
-        if( !stats_UpdateInteger( p_input, p_input->p->counters.p_sout_sent_bytes, i_delta, &i_bytes ) )
-            stats_UpdateFloat( p_input, p_input->p->counters.p_sout_send_bitrate, i_bytes, NULL );
+        if( !stats_UpdateInteger( p_input->p->counters.p_sout_sent_bytes, i_delta, &i_bytes ) )
+            stats_UpdateFloat( p_input->p->counters.p_sout_send_bitrate, i_bytes, NULL );
         break;
     }
     default:
index 1d9ae1bcb024bceb5fe7adcc8153eda1bba16441..507a221418be8f2ce0d8f6ca36d51c709c0b7e30 100644 (file)
@@ -1690,11 +1690,11 @@ static int AReadStream( stream_t *s, void *p_read, unsigned int i_read )
         if( p_input )
         {
             vlc_mutex_lock( &p_input->p->counters.counters_lock );
-            stats_UpdateInteger( s, p_input->p->counters.p_read_bytes, i_read,
+            stats_UpdateInteger( p_input->p->counters.p_read_bytes, i_read,
                              &i_total );
-            stats_UpdateFloat( s, p_input->p->counters.p_input_bitrate,
+            stats_UpdateFloat( p_input->p->counters.p_input_bitrate,
                            (float)i_total, NULL );
-            stats_UpdateInteger( s, p_input->p->counters.p_read_packets, 1, NULL );
+            stats_UpdateInteger( p_input->p->counters.p_read_packets, 1, NULL );
             vlc_mutex_unlock( &p_input->p->counters.counters_lock );
         }
         return i_read;
@@ -1730,10 +1730,10 @@ static int AReadStream( stream_t *s, void *p_read, unsigned int i_read )
     if( p_input )
     {
         vlc_mutex_lock( &p_input->p->counters.counters_lock );
-        stats_UpdateInteger( s, p_input->p->counters.p_read_bytes, i_read, &i_total );
-        stats_UpdateFloat( s, p_input->p->counters.p_input_bitrate,
+        stats_UpdateInteger( p_input->p->counters.p_read_bytes, i_read, &i_total );
+        stats_UpdateFloat( p_input->p->counters.p_input_bitrate,
                        (float)i_total, NULL );
-        stats_UpdateInteger( s, p_input->p->counters.p_read_packets, 1, NULL );
+        stats_UpdateInteger( p_input->p->counters.p_read_packets, 1, NULL );
         vlc_mutex_unlock( &p_input->p->counters.counters_lock );
     }
     return i_read;
@@ -1757,11 +1757,11 @@ static block_t *AReadBlock( stream_t *s, bool *pb_eof )
         if( p_input && p_block && libvlc_stats (p_access) )
         {
             vlc_mutex_lock( &p_input->p->counters.counters_lock );
-            stats_UpdateInteger( s, p_input->p->counters.p_read_bytes,
+            stats_UpdateInteger( p_input->p->counters.p_read_bytes,
                                  p_block->i_buffer, &i_total );
-            stats_UpdateFloat( s, p_input->p->counters.p_input_bitrate,
+            stats_UpdateFloat( p_input->p->counters.p_input_bitrate,
                               (float)i_total, NULL );
-            stats_UpdateInteger( s, p_input->p->counters.p_read_packets, 1, NULL );
+            stats_UpdateInteger( p_input->p->counters.p_read_packets, 1, NULL );
             vlc_mutex_unlock( &p_input->p->counters.counters_lock );
         }
         return p_block;
@@ -1798,11 +1798,11 @@ static block_t *AReadBlock( stream_t *s, bool *pb_eof )
         if( p_input )
         {
             vlc_mutex_lock( &p_input->p->counters.counters_lock );
-            stats_UpdateInteger( s, p_input->p->counters.p_read_bytes,
+            stats_UpdateInteger( p_input->p->counters.p_read_bytes,
                                  p_block->i_buffer, &i_total );
-            stats_UpdateFloat( s, p_input->p->counters.p_input_bitrate,
+            stats_UpdateFloat( p_input->p->counters.p_input_bitrate,
                               (float)i_total, NULL );
-            stats_UpdateInteger( s, p_input->p->counters.p_read_packets,
+            stats_UpdateInteger( p_input->p->counters.p_read_packets,
                                  1 , NULL);
             vlc_mutex_unlock( &p_input->p->counters.counters_lock );
         }
index ed7a7555fff5a2875172fe96ceb76e93331edf58..5c52be9342f5a866c07fb7fb250ca5f2c0735b8e 100644 (file)
@@ -222,67 +222,57 @@ void var_OptionParse (vlc_object_t *, const char *, bool trusted);
 /*
  * Stats stuff
  */
-int stats_Update (vlc_object_t*, counter_t *, vlc_value_t, vlc_value_t *);
-counter_t * stats_CounterCreate (vlc_object_t*, int, int);
-#define stats_CounterCreate(a,b,c) stats_CounterCreate( VLC_OBJECT(a), b, c )
-int stats_Get (vlc_object_t*, counter_t *, vlc_value_t*);
-#define stats_Get(a,b,c) stats_Get( VLC_OBJECT(a), b, c)
+int stats_Update (counter_t *, vlc_value_t, vlc_value_t *);
+counter_t * stats_CounterCreate (int, int);
+int stats_Get (counter_t *, vlc_value_t*);
 
 void stats_CounterClean (counter_t * );
 
-static inline int stats_GetInteger( vlc_object_t *p_obj, counter_t *p_counter,
-                                    int64_t *value )
+static inline int stats_GetInteger( counter_t *p_counter, int64_t *value )
 {
     int i_ret;
     vlc_value_t val; val.i_int = 0;
     if( !p_counter ) return VLC_EGENERIC;
-    i_ret = stats_Get( p_obj, p_counter, &val );
+    i_ret = stats_Get( p_counter, &val );
     *value = val.i_int;
     return i_ret;
 }
-#define stats_GetInteger(a,b,c) stats_GetInteger( VLC_OBJECT(a), b, c )
 
-static inline int stats_GetFloat( vlc_object_t *p_obj, counter_t *p_counter,
-                                    float *value )
+static inline int stats_GetFloat( counter_t *p_counter, float *value )
 {
     int i_ret;
     vlc_value_t val; val.f_float = 0.0;
     if( !p_counter ) return VLC_EGENERIC;
-    i_ret = stats_Get( p_obj, p_counter, &val );
+    i_ret = stats_Get( p_counter, &val );
     *value = val.f_float;
     return i_ret;
 }
-#define stats_GetFloat(a,b,c) stats_GetFloat( VLC_OBJECT(a), b, c )
 
-static inline int stats_UpdateInteger( vlc_object_t *p_obj,counter_t *p_co,
-                                         int i, int *pi_new )
+static inline int stats_UpdateInteger( counter_t *p_co, int i, int *pi_new )
 {
     int i_ret;
     vlc_value_t val;
     vlc_value_t new_val; new_val.i_int = 0;
     if( !p_co ) return VLC_EGENERIC;
     val.i_int = i;
-    i_ret = stats_Update( p_obj, p_co, val, &new_val );
+    i_ret = stats_Update( p_co, val, &new_val );
     if( pi_new )
         *pi_new = new_val.i_int;
     return i_ret;
 }
-#define stats_UpdateInteger(a,b,c,d) stats_UpdateInteger( VLC_OBJECT(a),b,c,d )
 
-static inline int stats_UpdateFloat( vlc_object_t *p_obj, counter_t *p_co,
-                                       float f, float *pf_new )
+static inline int stats_UpdateFloat( counter_t *p_co, float f, float *pf_new )
 {
     vlc_value_t val;
     int i_ret;
     vlc_value_t new_val;new_val.f_float = 0.0;
     if( !p_co ) return VLC_EGENERIC;
     val.f_float = f;
-    i_ret =  stats_Update( p_obj, p_co, val, &new_val );
+    i_ret =  stats_Update( p_co, val, &new_val );
     if( pf_new )
         *pf_new = new_val.f_float;
     return i_ret;
 }
-#define stats_UpdateFloat(a,b,c,d) stats_UpdateFloat( VLC_OBJECT(a),b,c,d )
 
 void stats_ComputeInputStats(input_thread_t*, input_stats_t*);
 void stats_ReinitInputStats(input_stats_t *);
index 70b03f94aedcb7b1dea1b794d98fadfcfb62f0e3..60d77a21cbc2ee4df314894c7395c8ede9df0def 100644 (file)
 /*****************************************************************************
  * Local prototypes
  *****************************************************************************/
-static int CounterUpdate( vlc_object_t *p_this,
-                          counter_t *p_counter,
+static int CounterUpdate( counter_t *p_counter,
                           vlc_value_t val, vlc_value_t * );
 
 /*****************************************************************************
  * Exported functions
  *****************************************************************************/
 
-#undef stats_CounterCreate
 /**
  * Create a statistics counter
- * \param p_this a VLC object
  * \param i_type the type of stored data. One of VLC_VAR_STRING,
  * VLC_VAR_INTEGER, VLC_VAR_FLOAT
  * \param i_compute_type the aggregation type. One of STATS_LAST (always
@@ -56,11 +53,9 @@ static int CounterUpdate( vlc_object_t *p_this,
  * STATS_MAX (keep the maximum passed value), STATS_MIN, or STATS_DERIVATIVE
  * (keep a time derivative of the value)
  */
-counter_t * stats_CounterCreate( vlc_object_t *p_this,
-                                   int i_type, int i_compute_type )
+counter_t * stats_CounterCreate( int i_type, int i_compute_type )
 {
     counter_t *p_counter = (counter_t*) malloc( sizeof( counter_t ) ) ;
-    (void)p_this;
 
     if( !p_counter ) return NULL;
     p_counter->i_compute_type = i_compute_type;
@@ -75,20 +70,18 @@ counter_t * stats_CounterCreate( vlc_object_t *p_this,
 }
 
 /** Update a counter element with new values
- * \param p_this a VLC object
  * \param p_counter the counter to update
  * \param val the vlc_value union containing the new value to aggregate. For
  * more information on how data is aggregated, \see stats_Create
  * \param val_new a pointer that will be filled with new data
  */
-int stats_Update( vlc_object_t *p_this, counter_t *p_counter,
+int stats_Update( counter_t *p_counter,
                   vlc_value_t val, vlc_value_t *val_new )
 {
-    if( !libvlc_stats (p_this) || !p_counter ) return VLC_EGENERIC;
-    return CounterUpdate( p_this, p_counter, val, val_new );
+    if( !p_counter ) return VLC_EGENERIC;
+    return CounterUpdate( p_counter, val, val_new );
 }
 
-#undef stats_Get
 /** Get the aggregated value for a counter
  * \param p_this an object
  * \param p_counter the counter
@@ -96,9 +89,9 @@ int stats_Update( vlc_object_t *p_this, counter_t *p_counter,
  * retrieved value
  * \return an error code
  */
-int stats_Get( vlc_object_t *p_this, counter_t *p_counter, vlc_value_t *val )
+int stats_Get( counter_t *p_counter, vlc_value_t *val )
 {
-    if( !libvlc_stats (p_this) || !p_counter || p_counter->i_samples == 0 )
+    if( !p_counter || p_counter->i_samples == 0 )
     {
         val->i_int = 0;
         return VLC_EGENERIC;
@@ -158,48 +151,48 @@ void stats_ComputeInputStats( input_thread_t *p_input, input_stats_t *p_stats )
     vlc_mutex_lock( &p_stats->lock );
 
     /* Input */
-    stats_GetInteger( p_input, p_input->p->counters.p_read_packets,
+    stats_GetInteger( p_input->p->counters.p_read_packets,
                       &p_stats->i_read_packets );
-    stats_GetInteger( p_input, p_input->p->counters.p_read_bytes,
+    stats_GetInteger( p_input->p->counters.p_read_bytes,
                       &p_stats->i_read_bytes );
-    stats_GetFloat( p_input, p_input->p->counters.p_input_bitrate,
+    stats_GetFloat( p_input->p->counters.p_input_bitrate,
                     &p_stats->f_input_bitrate );
-    stats_GetInteger( p_input, p_input->p->counters.p_demux_read,
+    stats_GetInteger( p_input->p->counters.p_demux_read,
                       &p_stats->i_demux_read_bytes );
-    stats_GetFloat( p_input, p_input->p->counters.p_demux_bitrate,
+    stats_GetFloat( p_input->p->counters.p_demux_bitrate,
                     &p_stats->f_demux_bitrate );
-    stats_GetInteger( p_input, p_input->p->counters.p_demux_corrupted,
+    stats_GetInteger( p_input->p->counters.p_demux_corrupted,
                       &p_stats->i_demux_corrupted );
-    stats_GetInteger( p_input, p_input->p->counters.p_demux_discontinuity,
+    stats_GetInteger( p_input->p->counters.p_demux_discontinuity,
                       &p_stats->i_demux_discontinuity );
 
     /* Decoders */
-    stats_GetInteger( p_input, p_input->p->counters.p_decoded_video,
+    stats_GetInteger( p_input->p->counters.p_decoded_video,
                       &p_stats->i_decoded_video );
-    stats_GetInteger( p_input, p_input->p->counters.p_decoded_audio,
+    stats_GetInteger( p_input->p->counters.p_decoded_audio,
                       &p_stats->i_decoded_audio );
 
     /* Sout */
     if( p_input->p->counters.p_sout_send_bitrate )
     {
-        stats_GetInteger( p_input, p_input->p->counters.p_sout_sent_packets,
+        stats_GetInteger( p_input->p->counters.p_sout_sent_packets,
                           &p_stats->i_sent_packets );
-        stats_GetInteger( p_input, p_input->p->counters.p_sout_sent_bytes,
+        stats_GetInteger( p_input->p->counters.p_sout_sent_bytes,
                           &p_stats->i_sent_bytes );
-        stats_GetFloat  ( p_input, p_input->p->counters.p_sout_send_bitrate,
+        stats_GetFloat  ( p_input->p->counters.p_sout_send_bitrate,
                           &p_stats->f_send_bitrate );
     }
 
     /* Aout */
-    stats_GetInteger( p_input, p_input->p->counters.p_played_abuffers,
+    stats_GetInteger( p_input->p->counters.p_played_abuffers,
                       &p_stats->i_played_abuffers );
-    stats_GetInteger( p_input, p_input->p->counters.p_lost_abuffers,
+    stats_GetInteger( p_input->p->counters.p_lost_abuffers,
                       &p_stats->i_lost_abuffers );
 
     /* Vouts */
-    stats_GetInteger( p_input, p_input->p->counters.p_displayed_pictures,
+    stats_GetInteger( p_input->p->counters.p_displayed_pictures,
                       &p_stats->i_displayed_pictures );
-    stats_GetInteger( p_input, p_input->p->counters.p_lost_pictures,
+    stats_GetInteger( p_input->p->counters.p_lost_pictures,
                       &p_stats->i_lost_pictures );
 
     vlc_mutex_unlock( &p_stats->lock );
@@ -251,8 +244,7 @@ void stats_CounterClean( counter_t *p_c )
  * \param val the "new" value
  * \return an error code
  */
-static int CounterUpdate( vlc_object_t *p_handler,
-                          counter_t *p_counter,
+static int CounterUpdate( counter_t *p_counter,
                           vlc_value_t val, vlc_value_t *new_val )
 {
     switch( p_counter->i_compute_type )
@@ -266,12 +258,6 @@ static int CounterUpdate( vlc_object_t *p_handler,
             return VLC_EGENERIC;
         }
         p_counter->last_update = now;
-        if( p_counter->i_type != VLC_VAR_FLOAT &&
-            p_counter->i_type != VLC_VAR_INTEGER )
-        {
-            msg_Err( p_handler, "Unable to compute DERIVATIVE for this type");
-            return VLC_EGENERIC;
-        }
         /* Insert the new one at the beginning */
         p_new = (counter_sample_t*)malloc( sizeof( counter_sample_t ) );
         p_new->value = val;
@@ -288,11 +274,6 @@ static int CounterUpdate( vlc_object_t *p_handler,
         break;
     }
     case STATS_COUNTER:
-        if( p_counter->i_samples > 1)
-        {
-            msg_Err( p_handler, "LAST counter has several samples !" );
-            return VLC_EGENERIC;
-        }
         if( p_counter->i_samples == 0 )
         {
             counter_sample_t *p_new = (counter_sample_t*)malloc(
index 30bce236a31215a15993ae497daf48105229d28d..16bad68f4e9c422fa311224df517de9a1b53446c 100644 (file)
@@ -2017,8 +2017,8 @@ static void httpd_ClientTlsHsOut( httpd_client_t *cl )
 static void* httpd_HostThread( void *data )
 {
     httpd_host_t *host = data;
-    counter_t *p_total_counter = stats_CounterCreate( host, VLC_VAR_INTEGER, STATS_COUNTER );
-    counter_t *p_active_counter = stats_CounterCreate( host, VLC_VAR_INTEGER, STATS_COUNTER );
+    counter_t *p_total_counter = stats_CounterCreate( VLC_VAR_INTEGER, STATS_COUNTER );
+    counter_t *p_active_counter = stats_CounterCreate( VLC_VAR_INTEGER, STATS_COUNTER );
     int evfd = vlc_object_waitpipe( VLC_OBJECT( host ) );
 
     for( ;; )
@@ -2049,7 +2049,7 @@ static void* httpd_HostThread( void *data )
                     cl->i_activity_date+cl->i_activity_timeout < now) ) ) )
             {
                 httpd_ClientClean( cl );
-                stats_UpdateInteger( host, p_active_counter, -1, NULL );
+                stats_UpdateInteger( p_active_counter, -1, NULL );
                 TAB_REMOVE( host->i_client, host->client, cl );
                 free( cl );
                 i_client--;
@@ -2472,8 +2472,8 @@ static void* httpd_HostThread( void *data )
             else
                 p_tls = NULL;
 
-            stats_UpdateInteger( host, p_total_counter, 1, NULL );
-            stats_UpdateInteger( host, p_active_counter, 1, NULL );
+            stats_UpdateInteger( p_total_counter, 1, NULL );
+            stats_UpdateInteger( p_active_counter, 1, NULL );
             cl = httpd_ClientNew( fd, p_tls, now );
             vlc_mutex_lock( &host->lock );
             TAB_APPEND( host->i_client, host->client, cl );