]> git.sesse.net Git - vlc/commitdiff
AccessOutWrite is called very often, especially for TS. Don't store stats on each...
authorClément Stenac <zorglub@videolan.org>
Sat, 4 Feb 2006 00:08:50 +0000 (00:08 +0000)
committerClément Stenac <zorglub@videolan.org>
Sat, 4 Feb 2006 00:08:50 +0000 (00:08 +0000)
include/stream_output.h
src/stream_output/stream_output.c

index 7b8d863c78963a24d08003c9a5cfd6b30b424e44..641ec997a789302052555c7c199178259d8b0189 100644 (file)
@@ -106,6 +106,10 @@ struct sout_access_out_t
     char                    *psz_access;
     sout_cfg_t              *p_cfg;
 
+    int                      i_writes;
+    int64_t                  i_sent_bytes;      ///< This is a "local" counter that is reset each
+                                                // time it is transferred to stats
+
     char                    *psz_name;
     sout_access_out_sys_t   *p_sys;
     int                     (*pf_seek)( sout_access_out_t *, off_t );
index b9df817cbc60d9d63e2a006308f295e908c6a0ac..a673fd77a5152ada1dced883198b33dab29fdbe1 100644 (file)
@@ -309,6 +309,10 @@ sout_access_out_t *sout_AccessOutNew( sout_instance_t *p_sout,
     p_access->pf_read    = NULL;
     p_access->pf_write   = NULL;
     p_access->p_module   = NULL;
+
+    p_access->i_writes = 0;
+    p_access->i_sent_bytes = 0;
+
     vlc_object_attach( p_access, p_sout );
 
     p_access->p_module   =
@@ -367,21 +371,25 @@ int sout_AccessOutRead( sout_access_out_t *p_access, block_t *p_buffer )
 int sout_AccessOutWrite( sout_access_out_t *p_access, block_t *p_buffer )
 {
     int i_total;
-    if( p_access->p_libvlc->b_stats )
+    p_access->i_writes++;
+    p_access->i_sent_bytes += p_buffer->i_buffer;
+    if( p_access->p_libvlc->b_stats && p_access->i_writes % 10 == 0 )
     {
         /* Access_out -> sout_instance -> input_thread_t */
-        input_thread_t *p_input = 
-           (input_thread_t *)vlc_object_find( p_access, VLC_OBJECT_INPUT, 
+        input_thread_t *p_input =
+            (input_thread_t *)vlc_object_find( p_access, VLC_OBJECT_INPUT,
                                                FIND_PARENT );
         if( p_input )
         {
-            stats_UpdateInteger( p_input, "sout_sent_packets", 1 );
-            stats_UpdateInteger( p_input, "sout_sent_bytes", 
-                                 p_buffer->i_buffer );
-            stats_GetInteger( p_input, 
+            stats_UpdateInteger( p_input, "sout_sent_packets", 10 );
+            stats_UpdateInteger( p_input, "sout_sent_bytes",
+                                 p_access->i_sent_bytes );
+            stats_GetInteger( p_input,
                               p_access->p_parent->p_parent->i_object_id,
                               "sout_sent_bytes", &i_total );
             stats_UpdateFloat( p_input, "sout_send_bitrate", (float)i_total );
+
+            p_access->i_sent_bytes = 0;
             vlc_object_release( p_input );
         }
     }