]> git.sesse.net Git - vlc/commitdiff
Audio - Refs:#473
authorClément Stenac <zorglub@videolan.org>
Sat, 21 Jan 2006 14:14:36 +0000 (14:14 +0000)
committerClément Stenac <zorglub@videolan.org>
Sat, 21 Jan 2006 14:14:36 +0000 (14:14 +0000)
include/aout_internal.h
include/vlc_messages.h
modules/gui/wxwidgets/dialogs/infopanels.cpp
modules/gui/wxwidgets/dialogs/infopanels.hpp
src/audio_output/dec.c
src/audio_output/input.c
src/audio_output/mixer.c
src/input/input.c
src/misc/stats.c
src/playlist/playlist.c

index e8e611266a9334441e9975b5dc36e11f132f2dc9..e7adf2687a6130c921de581ec01300ebdc11733e 100644 (file)
@@ -150,6 +150,9 @@ struct aout_input_t
      * third-party. */
     vlc_mutex_t             lock;
 
+    /* The input thread that spawned this input */
+    input_thread_t         *p_input_thread;
+
     audio_sample_format_t   input;
     aout_alloc_t            input_alloc;
 
index 1d8ed739aae015ca622e33ba1c3dffe490b8d983..c3a1889cd3ec1b8ed8f9df2c9b13e2e391f20c66 100644 (file)
@@ -314,6 +314,10 @@ struct input_stats_t
     /* Vout */
     int i_displayed_pictures;
     int i_lost_pictures;
+
+    /* Aout */
+    int i_played_abuffers;
+    int i_lost_abuffers;
 };
 
 VLC_EXPORT( void, stats_ComputeInputStats, (input_thread_t*, input_stats_t*) );
index ed3c9610dc9739bbc2dd115598b7b6b1aca99168..e26dcea29312c908fe02ac387ec98df4c26fa477 100644 (file)
@@ -197,6 +197,31 @@ InputStatsInfoPanel::InputStatsInfoPanel( intf_thread_t *_p_intf,
     video_bsizer->Layout();
     sizer->Add( video_bsizer , 0, wxALL| wxGROW, 5 );
 
+   /* Aout */
+    wxStaticBox *audio_box = new wxStaticBox( this, -1,
+                                              wxU( _("Audio" ) ) );
+    audio_box->SetAutoLayout( TRUE );
+    audio_bsizer = new wxStaticBoxSizer( audio_box, wxVERTICAL );
+    audio_sizer = new wxFlexGridSizer( 2,3, 20 );
+
+#define AUDIO_ADD(txt,widget,dflt) \
+    { audio_sizer->Add ( new wxStaticText( this, -1, wxU(_( txt ) ) ),   \
+                         0, wxEXPAND|wxLEFT , 5  );                      \
+      widget = new wxStaticText( this, -1, wxU( dflt ) );                \
+      audio_sizer->Add( widget, 0, wxEXPAND|wxRIGHT, 5 );                \
+    }
+    AUDIO_ADD( "Decoded blocks", audio_decoded_text, "0" );
+    /* Hack to get enough size */
+    AUDIO_ADD( "Played buffers", played_abuffers_text,
+                                 "0                  " );
+    AUDIO_ADD( "Lost buffers", lost_abuffers_text, "0" );
+
+
+    audio_sizer->Layout();
+    audio_bsizer->Add( audio_sizer, 0, wxALL | wxGROW, 5 );
+    audio_bsizer->Layout();
+    sizer->Add( audio_bsizer , 0, wxALL| wxGROW, 5 );
+
     sizer->Layout();
     panel_sizer->Add( sizer, 0, wxEXPAND, 5 );
     panel_sizer->Layout();
@@ -228,6 +253,10 @@ void InputStatsInfoPanel::Update( input_item_t *p_item )
     UPDATE( displayed_text, "%5i", p_item->p_stats->i_displayed_pictures );
     UPDATE( lost_frames_text, "%5i", p_item->p_stats->i_lost_pictures );
 
+    UPDATE( audio_decoded_text, "%5i", p_item->p_stats->i_decoded_audio );
+    UPDATE( played_abuffers_text, "%5i", p_item->p_stats->i_played_abuffers );
+    UPDATE( lost_abuffers_text, "%5i", p_item->p_stats->i_lost_abuffers );
+
     vlc_mutex_unlock( &p_item->p_stats->lock );
 
     input_sizer->Layout();
index d0e1543e2272ca042e298348fbd5d84dd2c08b35..8de7f597f1eca9bc590d4507c93c813b70232ce6 100644 (file)
@@ -86,7 +86,6 @@ private:
 
     wxFlexGridSizer *input_sizer;
     wxStaticBoxSizer *input_bsizer;
-
     wxStaticText *read_bytes_text;
     wxStaticText *input_bitrate_text;
     wxStaticText *demux_bytes_text;
@@ -94,10 +93,15 @@ private:
 
     wxFlexGridSizer *video_sizer;
     wxStaticBoxSizer *video_bsizer;
-
     wxStaticText *video_decoded_text;
     wxStaticText *displayed_text;
     wxStaticText *lost_frames_text;
+
+    wxFlexGridSizer *audio_sizer;
+    wxStaticBoxSizer *audio_bsizer;
+    wxStaticText *audio_decoded_text;
+    wxStaticText *played_abuffers_text;
+    wxStaticText *lost_abuffers_text;
 };
 };
 #endif
index ff613ab04bd27fb1941262d727d69862959da0a4..be81b099095f3760487bb82bf91ee5d910820ff4 100644 (file)
@@ -134,12 +134,14 @@ static aout_input_t * DecNew( vlc_object_t * p_this, aout_instance_t * p_aout,
     {
         p_input->i_pts_delay = p_input_thread->i_pts_delay;
         p_input->i_pts_delay += p_input->i_desync;
+        p_input->p_input_thread = p_input_thread;
         vlc_object_release( p_input_thread );
     }
     else
     {
         p_input->i_pts_delay = DEFAULT_PTS_DELAY;
         p_input->i_pts_delay += p_input->i_desync;
+        p_input->p_input_thread = NULL;
     }
 
     return p_input;
@@ -308,6 +310,10 @@ int aout_DecPlay( aout_instance_t * p_aout, aout_input_t * p_input,
     {
         msg_Warn( p_aout, "received buffer in the future ("I64Fd")",
                   p_buffer->start_date - mdate());
+        if( p_input->p_input_thread )
+        {
+            stats_UpdateInteger( p_input->p_input_thread, "lost_abuffers", 1 );
+        }
         aout_BufferFree( p_buffer );
         return -1;
     }
@@ -358,6 +364,11 @@ int aout_DecPlay( aout_instance_t * p_aout, aout_input_t * p_input,
     /* Run the mixer if it is able to run. */
     vlc_mutex_lock( &p_aout->mixer_lock );
     aout_MixerRun( p_aout );
+    if( p_input->p_input_thread )
+    {
+        stats_UpdateInteger( p_input->p_input_thread,
+                            "played_abuffers", 1 );
+    }
     vlc_mutex_unlock( &p_aout->mixer_lock );
 
     return 0;
index 5945570aef4810324d879e3d0597bf9d531177b6..8bae89cc061f3dec21e08194e85ffa39f05eec9f 100644 (file)
@@ -445,6 +445,10 @@ int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
             p_input->pp_resamplers[0]->b_continuity = VLC_FALSE;
         }
         start_date = 0;
+        if( p_input->p_input_thread )
+        {
+            stats_UpdateInteger( p_input->p_input_thread, "lost_abuffers", 1 );
+        }
     }
 
     if ( p_buffer->start_date < mdate() + AOUT_MIN_PREPARE_TIME )
@@ -453,6 +457,10 @@ int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
          * can't present it anyway, so drop the buffer. */
         msg_Warn( p_aout, "PTS is out of range ("I64Fd"), dropping buffer",
                   mdate() - p_buffer->start_date );
+        if( p_input->p_input_thread )
+        {
+            stats_UpdateInteger( p_input->p_input_thread, "lost_abuffers", 1 );
+        }
         aout_BufferFree( p_buffer );
         p_input->i_resampling_type = AOUT_RESAMPLING_NONE;
         if ( p_input->i_nb_resamplers != 0 )
@@ -490,6 +498,10 @@ int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
         msg_Warn( p_aout, "audio drift is too big ("I64Fd"), dropping buffer",
                   start_date - p_buffer->start_date );
         aout_BufferFree( p_buffer );
+        if( p_input->p_input_thread )
+        {
+            stats_UpdateInteger( p_input->p_input_thread, "lost_abuffers", 1 );
+        }
         return 0;
     }
 
index 16631bf4b7eb738ac3f181de087690bddefc7ded..b59117d0b1d38b3f4015f9fa66798480dbfc5033 100644 (file)
@@ -140,6 +140,11 @@ static int MixBuffer( aout_instance_t * p_aout )
                           "trashing", mdate() - p_buffer->start_date );
                 p_buffer = aout_FifoPop( p_aout, p_fifo );
                 aout_BufferFree( p_buffer );
+                if( p_input->p_input_thread )
+                {
+//                    stats_UpdateInteger( p_input->p_input_thread,
+//                                         "lost_abuffers", 1 );
+                }
                 p_buffer = p_fifo->p_first;
                 p_input->p_first_byte_to_mix = NULL;
             }
@@ -197,6 +202,11 @@ static int MixBuffer( aout_instance_t * p_aout )
             msg_Warn( p_aout, "the mixer got a packet in the past ("I64Fd")",
                       start_date - p_buffer->end_date );
             aout_BufferFree( p_buffer );
+            if( p_input->p_input_thread )
+            {
+//                stats_UpdateInteger( p_input->p_input_thread,
+//                                     "lost_abuffers", 1 );
+            }
             p_fifo->p_first = p_buffer = p_next;
             p_input->p_first_byte_to_mix = NULL;
         }
index dacf0423fae4bf2bc03e844dee748f857e16f205..d7f47c8fade20f0131ab39e7c6e7d77096390bdd 100644 (file)
@@ -683,6 +683,7 @@ static int Init( input_thread_t * p_input, vlc_bool_t b_quick )
      */
     if( !b_quick )
     {
+        /* Prepare statistics */
         counter_t *p_counter;
         stats_Create( p_input, "read_bytes", VLC_VAR_INTEGER, STATS_COUNTER );
         stats_Create( p_input, "read_packets", VLC_VAR_INTEGER, STATS_COUNTER );
@@ -698,6 +699,10 @@ static int Init( input_thread_t * p_input, vlc_bool_t b_quick )
                                       "demux_bitrate" );
         if( p_counter ) p_counter->update_interval = 1000000;
 
+        stats_Create( p_input, "played_abuffers", VLC_VAR_INTEGER, STATS_COUNTER );
+        stats_Create( p_input, "lost_abuffers", VLC_VAR_INTEGER, STATS_COUNTER );
+
+        /* handle sout */
         psz = var_GetString( p_input, "sout" );
         if( *psz && strncasecmp( p_input->input.p_item->psz_uri, "vlc:", 4 ) )
         {
index ab89c06e534b837d91175622c06880017020f08c..594f954672ed503b27a83da057ed57d62b7626c0 100644 (file)
@@ -138,7 +138,6 @@ int __stats_Update( vlc_object_t *p_this, char *psz_name, vlc_value_t val )
     if( !p_handler ) return VLC_ENOMEM;
 
     vlc_mutex_lock( &p_handler->object_lock );
-
     /* Look for existing element */
     p_counter = GetCounter( p_handler, p_this->i_object_id,
                             psz_name );
@@ -177,7 +176,6 @@ int __stats_Get( vlc_object_t *p_this, int i_object_id, char *psz_name, vlc_valu
     if( !p_handler ) return VLC_ENOMEM;
     vlc_mutex_lock( &p_handler->object_lock );
 
-
     /* Look for existing element */
     p_counter = GetCounter( p_handler, i_object_id,
                             psz_name );
@@ -292,6 +290,12 @@ void stats_ComputeInputStats( input_thread_t *p_input,
     stats_GetInteger( p_input, p_input->i_object_id, "decoded_audio",
                       &p_stats->i_decoded_audio );
 
+    /* Aout - We store in p_input because aout is shared */
+    stats_GetInteger( p_input, p_input->i_object_id, "played_abuffers",
+                      &p_stats->i_played_abuffers );
+    stats_GetInteger( p_input, p_input->i_object_id, "lost_abuffers",
+                      &p_stats->i_lost_abuffers );
+
     /* Vouts */
     p_list = vlc_list_find( p_input, VLC_OBJECT_VOUT, FIND_CHILD );
     if( p_list )
@@ -311,6 +315,7 @@ void stats_ComputeInputStats( input_thread_t *p_input,
          }
         vlc_list_release( p_list );
     }
+
     vlc_mutex_unlock( &p_stats->lock );
 }
 
@@ -321,6 +326,7 @@ void stats_ReinitInputStats( input_stats_t *p_stats )
     p_stats->i_demux_read_packets = p_stats->i_demux_read_bytes =
     p_stats->f_demux_bitrate = p_stats->f_average_demux_bitrate =
     p_stats->i_displayed_pictures = p_stats->i_lost_pictures =
+    p_stats->i_played_abuffers = p_stats->i_lost_abuffers =
     p_stats->i_decoded_video = p_stats->i_decoded_audio = 0;
 }
 
@@ -329,13 +335,14 @@ void stats_DumpInputStats( input_stats_t *p_stats  )
     vlc_mutex_lock( &p_stats->lock );
     /* f_bitrate is in bytes / microsecond
      * *1000 => bytes / millisecond => kbytes / seconds */
-    fprintf( stderr, "Input : %i (%i bytes) - %f kB/s - "
-                     "Demux : %i (%i bytes) - %f kB/s - Vout : %i/%i\n",
+    fprintf( stderr, "Input : %i (%i bytes) - %f kB/s - Demux : %i (%i bytes) - %f kB/s\n"
+                     " - Vout : %i/%i - Aout : %i/%i\n",
                     p_stats->i_read_packets, p_stats->i_read_bytes,
                     p_stats->f_input_bitrate * 1000,
                     p_stats->i_demux_read_packets, p_stats->i_demux_read_bytes,
                     p_stats->f_demux_bitrate * 1000,
-                    p_stats->i_displayed_pictures, p_stats->i_lost_pictures );
+                    p_stats->i_displayed_pictures, p_stats->i_lost_pictures,
+                    p_stats->i_played_abuffers, p_stats->i_lost_abuffers );
     vlc_mutex_unlock( &p_stats->lock );
 }
 
@@ -477,7 +484,7 @@ static counter_t *GetCounter( stats_handler_t *p_handler, int i_object_id,
                              char *psz_name )
 {
     int i;
-    for( i = 0; i< p_handler->i_counters; i++ )
+   for( i = 0; i< p_handler->i_counters; i++ )
     {
         counter_t *p_counter = p_handler->pp_counters[i];
         if( p_counter->i_source_object == i_object_id &&
index d3ef1e1f427dce52e739239c3dc36d03656d2010..3e2272df4aaa8fb34b5a9be82522282eb9268b25 100644 (file)
@@ -625,7 +625,7 @@ static void RunThread ( playlist_t *p_playlist )
             {
                 stats_ComputeInputStats( p_playlist->p_input,
                                   p_playlist->p_input->input.p_item->p_stats );
-//               stats_DumpInputStats(
+//                stats_DumpInputStats(
 //                            p_playlist->p_input->input.p_item->p_stats );
             }