Commit 5bd61a80 authored by Clément Stenac's avatar Clément Stenac

Audio - Refs:#473

parent e328a29d
...@@ -150,6 +150,9 @@ struct aout_input_t ...@@ -150,6 +150,9 @@ struct aout_input_t
* third-party. */ * third-party. */
vlc_mutex_t lock; vlc_mutex_t lock;
/* The input thread that spawned this input */
input_thread_t *p_input_thread;
audio_sample_format_t input; audio_sample_format_t input;
aout_alloc_t input_alloc; aout_alloc_t input_alloc;
......
...@@ -314,6 +314,10 @@ struct input_stats_t ...@@ -314,6 +314,10 @@ struct input_stats_t
/* Vout */ /* Vout */
int i_displayed_pictures; int i_displayed_pictures;
int i_lost_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*) ); VLC_EXPORT( void, stats_ComputeInputStats, (input_thread_t*, input_stats_t*) );
......
...@@ -197,6 +197,31 @@ InputStatsInfoPanel::InputStatsInfoPanel( intf_thread_t *_p_intf, ...@@ -197,6 +197,31 @@ InputStatsInfoPanel::InputStatsInfoPanel( intf_thread_t *_p_intf,
video_bsizer->Layout(); video_bsizer->Layout();
sizer->Add( video_bsizer , 0, wxALL| wxGROW, 5 ); 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(); sizer->Layout();
panel_sizer->Add( sizer, 0, wxEXPAND, 5 ); panel_sizer->Add( sizer, 0, wxEXPAND, 5 );
panel_sizer->Layout(); panel_sizer->Layout();
...@@ -228,6 +253,10 @@ void InputStatsInfoPanel::Update( input_item_t *p_item ) ...@@ -228,6 +253,10 @@ void InputStatsInfoPanel::Update( input_item_t *p_item )
UPDATE( displayed_text, "%5i", p_item->p_stats->i_displayed_pictures ); UPDATE( displayed_text, "%5i", p_item->p_stats->i_displayed_pictures );
UPDATE( lost_frames_text, "%5i", p_item->p_stats->i_lost_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 ); vlc_mutex_unlock( &p_item->p_stats->lock );
input_sizer->Layout(); input_sizer->Layout();
......
...@@ -86,7 +86,6 @@ private: ...@@ -86,7 +86,6 @@ private:
wxFlexGridSizer *input_sizer; wxFlexGridSizer *input_sizer;
wxStaticBoxSizer *input_bsizer; wxStaticBoxSizer *input_bsizer;
wxStaticText *read_bytes_text; wxStaticText *read_bytes_text;
wxStaticText *input_bitrate_text; wxStaticText *input_bitrate_text;
wxStaticText *demux_bytes_text; wxStaticText *demux_bytes_text;
...@@ -94,10 +93,15 @@ private: ...@@ -94,10 +93,15 @@ private:
wxFlexGridSizer *video_sizer; wxFlexGridSizer *video_sizer;
wxStaticBoxSizer *video_bsizer; wxStaticBoxSizer *video_bsizer;
wxStaticText *video_decoded_text; wxStaticText *video_decoded_text;
wxStaticText *displayed_text; wxStaticText *displayed_text;
wxStaticText *lost_frames_text; wxStaticText *lost_frames_text;
wxFlexGridSizer *audio_sizer;
wxStaticBoxSizer *audio_bsizer;
wxStaticText *audio_decoded_text;
wxStaticText *played_abuffers_text;
wxStaticText *lost_abuffers_text;
}; };
}; };
#endif #endif
...@@ -134,12 +134,14 @@ static aout_input_t * DecNew( vlc_object_t * p_this, aout_instance_t * p_aout, ...@@ -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_thread->i_pts_delay;
p_input->i_pts_delay += p_input->i_desync; p_input->i_pts_delay += p_input->i_desync;
p_input->p_input_thread = p_input_thread;
vlc_object_release( p_input_thread ); vlc_object_release( p_input_thread );
} }
else else
{ {
p_input->i_pts_delay = DEFAULT_PTS_DELAY; p_input->i_pts_delay = DEFAULT_PTS_DELAY;
p_input->i_pts_delay += p_input->i_desync; p_input->i_pts_delay += p_input->i_desync;
p_input->p_input_thread = NULL;
} }
return p_input; return p_input;
...@@ -308,6 +310,10 @@ int aout_DecPlay( aout_instance_t * p_aout, aout_input_t * 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")", msg_Warn( p_aout, "received buffer in the future ("I64Fd")",
p_buffer->start_date - mdate()); 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 ); aout_BufferFree( p_buffer );
return -1; return -1;
} }
...@@ -358,6 +364,11 @@ int aout_DecPlay( aout_instance_t * p_aout, aout_input_t * p_input, ...@@ -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. */ /* Run the mixer if it is able to run. */
vlc_mutex_lock( &p_aout->mixer_lock ); vlc_mutex_lock( &p_aout->mixer_lock );
aout_MixerRun( p_aout ); 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 ); vlc_mutex_unlock( &p_aout->mixer_lock );
return 0; return 0;
......
...@@ -445,6 +445,10 @@ int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input, ...@@ -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; p_input->pp_resamplers[0]->b_continuity = VLC_FALSE;
} }
start_date = 0; 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 ) 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, ...@@ -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. */ * can't present it anyway, so drop the buffer. */
msg_Warn( p_aout, "PTS is out of range ("I64Fd"), dropping buffer", msg_Warn( p_aout, "PTS is out of range ("I64Fd"), dropping buffer",
mdate() - p_buffer->start_date ); 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 ); aout_BufferFree( p_buffer );
p_input->i_resampling_type = AOUT_RESAMPLING_NONE; p_input->i_resampling_type = AOUT_RESAMPLING_NONE;
if ( p_input->i_nb_resamplers != 0 ) if ( p_input->i_nb_resamplers != 0 )
...@@ -490,6 +498,10 @@ int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input, ...@@ -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", msg_Warn( p_aout, "audio drift is too big ("I64Fd"), dropping buffer",
start_date - p_buffer->start_date ); start_date - p_buffer->start_date );
aout_BufferFree( p_buffer ); aout_BufferFree( p_buffer );
if( p_input->p_input_thread )
{
stats_UpdateInteger( p_input->p_input_thread, "lost_abuffers", 1 );
}
return 0; return 0;
} }
......
...@@ -140,6 +140,11 @@ static int MixBuffer( aout_instance_t * p_aout ) ...@@ -140,6 +140,11 @@ static int MixBuffer( aout_instance_t * p_aout )
"trashing", mdate() - p_buffer->start_date ); "trashing", mdate() - p_buffer->start_date );
p_buffer = aout_FifoPop( p_aout, p_fifo ); p_buffer = aout_FifoPop( p_aout, p_fifo );
aout_BufferFree( p_buffer ); 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_buffer = p_fifo->p_first;
p_input->p_first_byte_to_mix = NULL; p_input->p_first_byte_to_mix = NULL;
} }
...@@ -197,6 +202,11 @@ static int MixBuffer( aout_instance_t * p_aout ) ...@@ -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")", msg_Warn( p_aout, "the mixer got a packet in the past ("I64Fd")",
start_date - p_buffer->end_date ); start_date - p_buffer->end_date );
aout_BufferFree( p_buffer ); 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_fifo->p_first = p_buffer = p_next;
p_input->p_first_byte_to_mix = NULL; p_input->p_first_byte_to_mix = NULL;
} }
......
...@@ -683,6 +683,7 @@ static int Init( input_thread_t * p_input, vlc_bool_t b_quick ) ...@@ -683,6 +683,7 @@ static int Init( input_thread_t * p_input, vlc_bool_t b_quick )
*/ */
if( !b_quick ) if( !b_quick )
{ {
/* Prepare statistics */
counter_t *p_counter; counter_t *p_counter;
stats_Create( p_input, "read_bytes", VLC_VAR_INTEGER, STATS_COUNTER ); stats_Create( p_input, "read_bytes", VLC_VAR_INTEGER, STATS_COUNTER );
stats_Create( p_input, "read_packets", 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 ) ...@@ -698,6 +699,10 @@ static int Init( input_thread_t * p_input, vlc_bool_t b_quick )
"demux_bitrate" ); "demux_bitrate" );
if( p_counter ) p_counter->update_interval = 1000000; 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" ); psz = var_GetString( p_input, "sout" );
if( *psz && strncasecmp( p_input->input.p_item->psz_uri, "vlc:", 4 ) ) if( *psz && strncasecmp( p_input->input.p_item->psz_uri, "vlc:", 4 ) )
{ {
......
...@@ -138,7 +138,6 @@ int __stats_Update( vlc_object_t *p_this, char *psz_name, vlc_value_t val ) ...@@ -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; if( !p_handler ) return VLC_ENOMEM;
vlc_mutex_lock( &p_handler->object_lock ); vlc_mutex_lock( &p_handler->object_lock );
/* Look for existing element */ /* Look for existing element */
p_counter = GetCounter( p_handler, p_this->i_object_id, p_counter = GetCounter( p_handler, p_this->i_object_id,
psz_name ); psz_name );
...@@ -177,7 +176,6 @@ int __stats_Get( vlc_object_t *p_this, int i_object_id, char *psz_name, vlc_valu ...@@ -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; if( !p_handler ) return VLC_ENOMEM;
vlc_mutex_lock( &p_handler->object_lock ); vlc_mutex_lock( &p_handler->object_lock );
/* Look for existing element */ /* Look for existing element */
p_counter = GetCounter( p_handler, i_object_id, p_counter = GetCounter( p_handler, i_object_id,
psz_name ); psz_name );
...@@ -292,6 +290,12 @@ void stats_ComputeInputStats( input_thread_t *p_input, ...@@ -292,6 +290,12 @@ void stats_ComputeInputStats( input_thread_t *p_input,
stats_GetInteger( p_input, p_input->i_object_id, "decoded_audio", stats_GetInteger( p_input, p_input->i_object_id, "decoded_audio",
&p_stats->i_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 */ /* Vouts */
p_list = vlc_list_find( p_input, VLC_OBJECT_VOUT, FIND_CHILD ); p_list = vlc_list_find( p_input, VLC_OBJECT_VOUT, FIND_CHILD );
if( p_list ) if( p_list )
...@@ -311,6 +315,7 @@ void stats_ComputeInputStats( input_thread_t *p_input, ...@@ -311,6 +315,7 @@ void stats_ComputeInputStats( input_thread_t *p_input,
} }
vlc_list_release( p_list ); vlc_list_release( p_list );
} }
vlc_mutex_unlock( &p_stats->lock ); vlc_mutex_unlock( &p_stats->lock );
} }
...@@ -321,6 +326,7 @@ void stats_ReinitInputStats( input_stats_t *p_stats ) ...@@ -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->i_demux_read_packets = p_stats->i_demux_read_bytes =
p_stats->f_demux_bitrate = p_stats->f_average_demux_bitrate = p_stats->f_demux_bitrate = p_stats->f_average_demux_bitrate =
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 =
p_stats->i_decoded_video = p_stats->i_decoded_audio = 0; p_stats->i_decoded_video = p_stats->i_decoded_audio = 0;
} }
...@@ -329,13 +335,14 @@ void stats_DumpInputStats( input_stats_t *p_stats ) ...@@ -329,13 +335,14 @@ void stats_DumpInputStats( input_stats_t *p_stats )
vlc_mutex_lock( &p_stats->lock ); vlc_mutex_lock( &p_stats->lock );
/* f_bitrate is in bytes / microsecond /* f_bitrate is in bytes / microsecond
* *1000 => bytes / millisecond => kbytes / seconds */ * *1000 => bytes / millisecond => kbytes / seconds */
fprintf( stderr, "Input : %i (%i bytes) - %f kB/s - " fprintf( stderr, "Input : %i (%i bytes) - %f kB/s - Demux : %i (%i bytes) - %f kB/s\n"
"Demux : %i (%i bytes) - %f kB/s - Vout : %i/%i\n", " - Vout : %i/%i - Aout : %i/%i\n",
p_stats->i_read_packets, p_stats->i_read_bytes, p_stats->i_read_packets, p_stats->i_read_bytes,
p_stats->f_input_bitrate * 1000, p_stats->f_input_bitrate * 1000,
p_stats->i_demux_read_packets, p_stats->i_demux_read_bytes, p_stats->i_demux_read_packets, p_stats->i_demux_read_bytes,
p_stats->f_demux_bitrate * 1000, 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 ); vlc_mutex_unlock( &p_stats->lock );
} }
...@@ -477,7 +484,7 @@ static counter_t *GetCounter( stats_handler_t *p_handler, int i_object_id, ...@@ -477,7 +484,7 @@ static counter_t *GetCounter( stats_handler_t *p_handler, int i_object_id,
char *psz_name ) char *psz_name )
{ {
int i; 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]; counter_t *p_counter = p_handler->pp_counters[i];
if( p_counter->i_source_object == i_object_id && if( p_counter->i_source_object == i_object_id &&
......
...@@ -625,7 +625,7 @@ static void RunThread ( playlist_t *p_playlist ) ...@@ -625,7 +625,7 @@ static void RunThread ( playlist_t *p_playlist )
{ {
stats_ComputeInputStats( p_playlist->p_input, stats_ComputeInputStats( p_playlist->p_input,
p_playlist->p_input->input.p_item->p_stats ); p_playlist->p_input->input.p_item->p_stats );
// stats_DumpInputStats( // stats_DumpInputStats(
// p_playlist->p_input->input.p_item->p_stats ); // p_playlist->p_input->input.p_item->p_stats );
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment