Commit c5939bff authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

aout: fix lost block stats

Do not count dropped blocks as played.
parent b758d168
...@@ -81,6 +81,7 @@ typedef struct ...@@ -81,6 +81,7 @@ typedef struct
aout_request_vout_t request_vout; aout_request_vout_t request_vout;
atomic_uint buffers_lost; atomic_uint buffers_lost;
atomic_uint buffers_played;
atomic_uchar restart; atomic_uchar restart;
} aout_owner_t; } aout_owner_t;
...@@ -136,8 +137,8 @@ bool aout_ChangeFilterString( vlc_object_t *manager, vlc_object_t *aout, ...@@ -136,8 +137,8 @@ bool aout_ChangeFilterString( vlc_object_t *manager, vlc_object_t *aout,
int aout_DecNew(audio_output_t *, const audio_sample_format_t *, int aout_DecNew(audio_output_t *, const audio_sample_format_t *,
const audio_replay_gain_t *, const aout_request_vout_t *); const audio_replay_gain_t *, const aout_request_vout_t *);
void aout_DecDelete(audio_output_t *); void aout_DecDelete(audio_output_t *);
int aout_DecPlay(audio_output_t *, block_t *, int i_input_rate); void aout_DecPlay(audio_output_t *, block_t *, int i_input_rate);
unsigned aout_DecGetResetLost(audio_output_t *); void aout_DecGetResetStats(audio_output_t *, unsigned *, unsigned *);
void aout_DecChangePause(audio_output_t *, bool b_paused, mtime_t i_date); void aout_DecChangePause(audio_output_t *, bool b_paused, mtime_t i_date);
void aout_DecFlush(audio_output_t *, bool wait); void aout_DecFlush(audio_output_t *, bool wait);
void aout_RequestRestart (audio_output_t *, unsigned); void aout_RequestRestart (audio_output_t *, unsigned);
......
...@@ -108,6 +108,7 @@ error: ...@@ -108,6 +108,7 @@ error:
aout_OutputUnlock (p_aout); aout_OutputUnlock (p_aout);
atomic_init (&owner->buffers_lost, 0); atomic_init (&owner->buffers_lost, 0);
atomic_init (&owner->buffers_played, 0);
return 0; return 0;
} }
...@@ -338,7 +339,7 @@ static void aout_DecSynchronize (audio_output_t *aout, mtime_t dec_pts, ...@@ -338,7 +339,7 @@ static void aout_DecSynchronize (audio_output_t *aout, mtime_t dec_pts,
/***************************************************************************** /*****************************************************************************
* aout_DecPlay : filter & mix the decoded buffer * aout_DecPlay : filter & mix the decoded buffer
*****************************************************************************/ *****************************************************************************/
int aout_DecPlay (audio_output_t *aout, block_t *block, int input_rate) void aout_DecPlay (audio_output_t *aout, block_t *block, int input_rate)
{ {
aout_owner_t *owner = aout_owner (aout); aout_owner_t *owner = aout_owner (aout);
...@@ -384,9 +385,10 @@ int aout_DecPlay (audio_output_t *aout, block_t *block, int input_rate) ...@@ -384,9 +385,10 @@ int aout_DecPlay (audio_output_t *aout, block_t *block, int input_rate)
owner->sync.end = block->i_pts + block->i_length + 1; owner->sync.end = block->i_pts + block->i_length + 1;
owner->sync.discontinuity = false; owner->sync.discontinuity = false;
aout_OutputPlay (aout, block); aout_OutputPlay (aout, block);
atomic_fetch_add(&owner->buffers_played, 1);
out: out:
aout_OutputUnlock (aout); aout_OutputUnlock (aout);
return 0; return;
drop: drop:
owner->sync.discontinuity = true; owner->sync.discontinuity = true;
block_Release (block); block_Release (block);
...@@ -395,10 +397,13 @@ lost: ...@@ -395,10 +397,13 @@ lost:
goto out; goto out;
} }
unsigned aout_DecGetResetLost (audio_output_t *aout) void aout_DecGetResetStats(audio_output_t *aout, unsigned *restrict lost,
unsigned *restrict played)
{ {
aout_owner_t *owner = aout_owner (aout); aout_owner_t *owner = aout_owner (aout);
return atomic_exchange(&owner->buffers_lost, 0);
*lost = atomic_exchange(&owner->buffers_lost, 0);
*played = atomic_exchange(&owner->buffers_played, 0);
} }
void aout_DecChangePause (audio_output_t *aout, bool paused, mtime_t date) void aout_DecChangePause (audio_output_t *aout, bool paused, mtime_t date)
......
...@@ -1038,7 +1038,6 @@ static void DecoderProcessVideo( decoder_t *p_dec, block_t *p_block ) ...@@ -1038,7 +1038,6 @@ static void DecoderProcessVideo( decoder_t *p_dec, block_t *p_block )
} }
static int DecoderPlayAudio( decoder_t *p_dec, block_t *p_audio, static int DecoderPlayAudio( decoder_t *p_dec, block_t *p_audio,
unsigned *restrict pi_played_sum,
unsigned *restrict pi_lost_sum ) unsigned *restrict pi_lost_sum )
{ {
decoder_owner_sys_t *p_owner = p_dec->p_owner; decoder_owner_sys_t *p_owner = p_dec->p_owner;
...@@ -1093,35 +1092,40 @@ static int DecoderPlayAudio( decoder_t *p_dec, block_t *p_audio, ...@@ -1093,35 +1092,40 @@ static int DecoderPlayAudio( decoder_t *p_dec, block_t *p_audio,
audio_output_t *p_aout = p_owner->p_aout; audio_output_t *p_aout = p_owner->p_aout;
if( p_aout == NULL || p_audio->i_pts <= VLC_TS_INVALID if( p_aout != NULL && p_audio->i_pts > VLC_TS_INVALID
|| i_rate < INPUT_RATE_DEFAULT/AOUT_MAX_INPUT_RATE && i_rate >= INPUT_RATE_DEFAULT/AOUT_MAX_INPUT_RATE
|| i_rate > INPUT_RATE_DEFAULT*AOUT_MAX_INPUT_RATE && i_rate <= INPUT_RATE_DEFAULT*AOUT_MAX_INPUT_RATE
|| DecoderTimedWait( p_dec, p_audio->i_pts - AOUT_MAX_PREPARE_TIME ) ) && !DecoderTimedWait( p_dec, p_audio->i_pts - AOUT_MAX_PREPARE_TIME ) )
{
aout_DecPlay( p_aout, p_audio, i_rate );
}
else
{ {
msg_Dbg( p_dec, "discarded audio buffer" ); msg_Dbg( p_dec, "discarded audio buffer" );
*pi_lost_sum += 1; *pi_lost_sum += 1;
block_Release( p_audio ); block_Release( p_audio );
return 0;
} }
if( aout_DecPlay( p_aout, p_audio, i_rate ) == 0 )
*pi_played_sum += 1;
return 0; return 0;
} }
static void DecoderUpdateStatAudio( decoder_t *p_dec, unsigned decoded, static void DecoderUpdateStatAudio( decoder_t *p_dec, unsigned decoded,
unsigned lost, unsigned played ) unsigned lost )
{ {
decoder_owner_sys_t *p_owner = p_dec->p_owner; decoder_owner_sys_t *p_owner = p_dec->p_owner;
input_thread_t *p_input = p_owner->p_input; input_thread_t *p_input = p_owner->p_input;
unsigned played = 0;
/* Update ugly stat */ /* Update ugly stat */
if( p_input == NULL ) if( p_input == NULL )
return; return;
if( p_owner->p_aout != NULL ) if( p_owner->p_aout != NULL )
lost += aout_DecGetResetLost( p_owner->p_aout ); {
unsigned aout_lost;
aout_DecGetResetStats( p_owner->p_aout, &aout_lost, &played );
lost += aout_lost;
}
vlc_mutex_lock( &p_input->p->counters.counters_lock); vlc_mutex_lock( &p_input->p->counters.counters_lock);
stats_Update( p_input->p->counters.p_lost_abuffers, lost, NULL ); stats_Update( p_input->p->counters.p_lost_abuffers, lost, NULL );
...@@ -1132,11 +1136,11 @@ static void DecoderUpdateStatAudio( decoder_t *p_dec, unsigned decoded, ...@@ -1132,11 +1136,11 @@ static void DecoderUpdateStatAudio( decoder_t *p_dec, unsigned decoded,
static int DecoderQueueAudio( decoder_t *p_dec, block_t *p_aout_buf ) static int DecoderQueueAudio( decoder_t *p_dec, block_t *p_aout_buf )
{ {
unsigned i_lost = 0, i_played = 0; unsigned lost = 0;
int ret = DecoderPlayAudio( p_dec, p_aout_buf, &i_played, &i_lost ); int ret = DecoderPlayAudio( p_dec, p_aout_buf, &lost );
DecoderUpdateStatAudio( p_dec, 1, i_lost, i_played ); DecoderUpdateStatAudio( p_dec, 1, lost );
return ret; return ret;
} }
...@@ -1145,16 +1149,16 @@ static void DecoderDecodeAudio( decoder_t *p_dec, block_t *p_block ) ...@@ -1145,16 +1149,16 @@ static void DecoderDecodeAudio( decoder_t *p_dec, block_t *p_block )
{ {
block_t *p_aout_buf; block_t *p_aout_buf;
block_t **pp_block = p_block ? &p_block : NULL; block_t **pp_block = p_block ? &p_block : NULL;
unsigned i_decoded = 0, i_lost = 0, i_played = 0; unsigned decoded = 0, lost = 0;
while( (p_aout_buf = p_dec->pf_decode_audio( p_dec, pp_block ) ) ) while( (p_aout_buf = p_dec->pf_decode_audio( p_dec, pp_block ) ) )
{ {
i_decoded++; decoded++;
DecoderPlayAudio( p_dec, p_aout_buf, &i_played, &i_lost ); DecoderPlayAudio( p_dec, p_aout_buf, &lost );
} }
DecoderUpdateStatAudio( p_dec, i_decoded, i_lost, i_played ); DecoderUpdateStatAudio( p_dec, decoded, lost );
} }
/* This function process a audio block /* This function process a audio block
......
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