[vlc-commits] aout: fix lost block stats
Rémi Denis-Courmont
git at videolan.org
Tue Jan 26 19:29:02 CET 2016
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Jan 26 20:25:57 2016 +0200| [c5939bffc48bcd712d6e28f5d1db426dabbc213f] | committer: Rémi Denis-Courmont
aout: fix lost block stats
Do not count dropped blocks as played.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c5939bffc48bcd712d6e28f5d1db426dabbc213f
---
src/audio_output/aout_internal.h | 5 +++--
src/audio_output/dec.c | 13 ++++++++----
src/input/decoder.c | 42 +++++++++++++++++++++-----------------
3 files changed, 35 insertions(+), 25 deletions(-)
diff --git a/src/audio_output/aout_internal.h b/src/audio_output/aout_internal.h
index 8cfcf33..4990597 100644
--- a/src/audio_output/aout_internal.h
+++ b/src/audio_output/aout_internal.h
@@ -81,6 +81,7 @@ typedef struct
aout_request_vout_t request_vout;
atomic_uint buffers_lost;
+ atomic_uint buffers_played;
atomic_uchar restart;
} aout_owner_t;
@@ -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 *,
const audio_replay_gain_t *, const aout_request_vout_t *);
void aout_DecDelete(audio_output_t *);
-int aout_DecPlay(audio_output_t *, block_t *, int i_input_rate);
-unsigned aout_DecGetResetLost(audio_output_t *);
+void aout_DecPlay(audio_output_t *, block_t *, int i_input_rate);
+void aout_DecGetResetStats(audio_output_t *, unsigned *, unsigned *);
void aout_DecChangePause(audio_output_t *, bool b_paused, mtime_t i_date);
void aout_DecFlush(audio_output_t *, bool wait);
void aout_RequestRestart (audio_output_t *, unsigned);
diff --git a/src/audio_output/dec.c b/src/audio_output/dec.c
index 50ad86d..84c2f60 100644
--- a/src/audio_output/dec.c
+++ b/src/audio_output/dec.c
@@ -108,6 +108,7 @@ error:
aout_OutputUnlock (p_aout);
atomic_init (&owner->buffers_lost, 0);
+ atomic_init (&owner->buffers_played, 0);
return 0;
}
@@ -338,7 +339,7 @@ static void aout_DecSynchronize (audio_output_t *aout, mtime_t dec_pts,
/*****************************************************************************
* 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);
@@ -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.discontinuity = false;
aout_OutputPlay (aout, block);
+ atomic_fetch_add(&owner->buffers_played, 1);
out:
aout_OutputUnlock (aout);
- return 0;
+ return;
drop:
owner->sync.discontinuity = true;
block_Release (block);
@@ -395,10 +397,13 @@ lost:
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);
- 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)
diff --git a/src/input/decoder.c b/src/input/decoder.c
index 8ef1fd5..77b3fb1 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -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,
- unsigned *restrict pi_played_sum,
unsigned *restrict pi_lost_sum )
{
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,
audio_output_t *p_aout = p_owner->p_aout;
- 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
- || DecoderTimedWait( p_dec, p_audio->i_pts - AOUT_MAX_PREPARE_TIME ) )
+ 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
+ && !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" );
*pi_lost_sum += 1;
block_Release( p_audio );
- return 0;
}
-
- if( aout_DecPlay( p_aout, p_audio, i_rate ) == 0 )
- *pi_played_sum += 1;
-
return 0;
}
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;
input_thread_t *p_input = p_owner->p_input;
+ unsigned played = 0;
/* Update ugly stat */
if( p_input == NULL )
return;
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);
stats_Update( p_input->p->counters.p_lost_abuffers, lost, NULL );
@@ -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 )
{
- 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;
}
@@ -1145,16 +1149,16 @@ static void DecoderDecodeAudio( decoder_t *p_dec, block_t *p_block )
{
block_t *p_aout_buf;
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 ) ) )
{
- 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
More information about the vlc-commits
mailing list