From 5bd61a8060701e1c0c6b70066f0e2f27b117ea43 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Cl=C3=A9ment=20Stenac?= Date: Sat, 21 Jan 2006 14:14:36 +0000 Subject: [PATCH] Audio - Refs:#473 --- include/aout_internal.h | 3 ++ include/vlc_messages.h | 4 +++ modules/gui/wxwidgets/dialogs/infopanels.cpp | 29 ++++++++++++++++++++ modules/gui/wxwidgets/dialogs/infopanels.hpp | 8 ++++-- src/audio_output/dec.c | 11 ++++++++ src/audio_output/input.c | 12 ++++++++ src/audio_output/mixer.c | 10 +++++++ src/input/input.c | 5 ++++ src/misc/stats.c | 19 +++++++++---- src/playlist/playlist.c | 2 +- 10 files changed, 94 insertions(+), 9 deletions(-) diff --git a/include/aout_internal.h b/include/aout_internal.h index e8e611266a..e7adf2687a 100644 --- a/include/aout_internal.h +++ b/include/aout_internal.h @@ -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; diff --git a/include/vlc_messages.h b/include/vlc_messages.h index 1d8ed739aa..c3a1889cd3 100644 --- a/include/vlc_messages.h +++ b/include/vlc_messages.h @@ -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*) ); diff --git a/modules/gui/wxwidgets/dialogs/infopanels.cpp b/modules/gui/wxwidgets/dialogs/infopanels.cpp index ed3c9610dc..e26dcea293 100644 --- a/modules/gui/wxwidgets/dialogs/infopanels.cpp +++ b/modules/gui/wxwidgets/dialogs/infopanels.cpp @@ -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(); diff --git a/modules/gui/wxwidgets/dialogs/infopanels.hpp b/modules/gui/wxwidgets/dialogs/infopanels.hpp index d0e1543e22..8de7f597f1 100644 --- a/modules/gui/wxwidgets/dialogs/infopanels.hpp +++ b/modules/gui/wxwidgets/dialogs/infopanels.hpp @@ -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 diff --git a/src/audio_output/dec.c b/src/audio_output/dec.c index ff613ab04b..be81b09909 100644 --- a/src/audio_output/dec.c +++ b/src/audio_output/dec.c @@ -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; diff --git a/src/audio_output/input.c b/src/audio_output/input.c index 5945570aef..8bae89cc06 100644 --- a/src/audio_output/input.c +++ b/src/audio_output/input.c @@ -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; } diff --git a/src/audio_output/mixer.c b/src/audio_output/mixer.c index 16631bf4b7..b59117d0b1 100644 --- a/src/audio_output/mixer.c +++ b/src/audio_output/mixer.c @@ -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; } diff --git a/src/input/input.c b/src/input/input.c index dacf0423fa..d7f47c8fad 100644 --- a/src/input/input.c +++ b/src/input/input.c @@ -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 ) ) { diff --git a/src/misc/stats.c b/src/misc/stats.c index ab89c06e53..594f954672 100644 --- a/src/misc/stats.c +++ b/src/misc/stats.c @@ -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 && diff --git a/src/playlist/playlist.c b/src/playlist/playlist.c index d3ef1e1f42..3e2272df4a 100644 --- a/src/playlist/playlist.c +++ b/src/playlist/playlist.c @@ -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 ); } -- 2.39.2