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

decoder: simplify audio path

DecoderPlayAudio() has no effects with a NULL block.
parent 34e54fee
...@@ -1073,7 +1073,7 @@ static void DecoderPlayAudio( decoder_t *p_dec, block_t *p_audio, ...@@ -1073,7 +1073,7 @@ static void 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_audio && p_audio->i_pts <= VLC_TS_INVALID ) // FIXME --VLC_TS_INVALID verify audio_output/* if( p_audio->i_pts <= VLC_TS_INVALID ) // FIXME --VLC_TS_INVALID verify audio_output/*
{ {
msg_Warn( p_dec, "non-dated audio buffer received" ); msg_Warn( p_dec, "non-dated audio buffer received" );
*pi_lost_sum += 1; *pi_lost_sum += 1;
...@@ -1083,58 +1083,47 @@ static void DecoderPlayAudio( decoder_t *p_dec, block_t *p_audio, ...@@ -1083,58 +1083,47 @@ static void DecoderPlayAudio( decoder_t *p_dec, block_t *p_audio,
/* */ /* */
vlc_mutex_lock( &p_owner->lock ); vlc_mutex_lock( &p_owner->lock );
race:
if( p_audio && p_owner->b_waiting ) if( p_owner->b_waiting )
{ {
p_owner->b_has_data = true; p_owner->b_has_data = true;
vlc_cond_signal( &p_owner->wait_acknowledge ); vlc_cond_signal( &p_owner->wait_acknowledge );
} }
for( ;; ) bool b_reject = DecoderWaitUnblock( p_dec );
{ bool b_paused = p_owner->b_paused;
bool b_paused;
bool b_reject = DecoderWaitUnblock( p_dec );
b_paused = p_owner->b_paused;
if (!p_audio)
break;
/* */
int i_rate = INPUT_RATE_DEFAULT;
DecoderFixTs( p_dec, &p_audio->i_pts, NULL, &p_audio->i_length, /* */
&i_rate, AOUT_MAX_ADVANCE_TIME ); int i_rate = INPUT_RATE_DEFAULT;
if( p_audio->i_pts <= VLC_TS_INVALID DecoderFixTs( p_dec, &p_audio->i_pts, NULL, &p_audio->i_length,
|| i_rate < INPUT_RATE_DEFAULT/AOUT_MAX_INPUT_RATE &i_rate, AOUT_MAX_ADVANCE_TIME );
|| i_rate > INPUT_RATE_DEFAULT*AOUT_MAX_INPUT_RATE )
b_reject = true;
DecoderWaitDate( p_dec, &b_reject, if( p_audio->i_pts <= VLC_TS_INVALID
p_audio->i_pts - AOUT_MAX_PREPARE_TIME ); || i_rate < INPUT_RATE_DEFAULT/AOUT_MAX_INPUT_RATE
|| i_rate > INPUT_RATE_DEFAULT*AOUT_MAX_INPUT_RATE )
b_reject = true;
if( unlikely(p_owner->b_paused != b_paused) ) DecoderWaitDate( p_dec, &b_reject,
continue; /* race with input thread? retry... */ p_audio->i_pts - AOUT_MAX_PREPARE_TIME );
if( p_aout == NULL )
b_reject = true;
if( !b_reject ) if( unlikely(p_owner->b_paused != b_paused) )
{ goto race; /* race with input thread? retry... */
assert( !p_owner->b_paused ); if( p_aout == NULL )
if( !aout_DecPlay( p_aout, p_audio, i_rate ) ) b_reject = true;
*pi_played_sum += 1;
*pi_lost_sum += aout_DecGetResetLost( p_aout );
}
else
{
msg_Dbg( p_dec, "discarded audio buffer" );
*pi_lost_sum += 1;
block_Release( p_audio );
}
break; if( !b_reject )
{
assert( !p_owner->b_paused );
if( !aout_DecPlay( p_aout, p_audio, i_rate ) )
*pi_played_sum += 1;
*pi_lost_sum += aout_DecGetResetLost( p_aout );
}
else
{
msg_Dbg( p_dec, "discarded audio buffer" );
*pi_lost_sum += 1;
block_Release( p_audio );
} }
vlc_mutex_unlock( &p_owner->lock ); vlc_mutex_unlock( &p_owner->lock );
} }
...@@ -1147,11 +1136,10 @@ static void DecoderDecodeAudio( decoder_t *p_dec, block_t *p_block ) ...@@ -1147,11 +1136,10 @@ static void DecoderDecodeAudio( decoder_t *p_dec, block_t *p_block )
int i_lost = 0; int i_lost = 0;
int i_played = 0; int i_played = 0;
if (!p_block) { if( p_block == NULL )
/* Play a NULL block to output buffered frames */ return; /* TODO: remove this check, drain audio decoders properly */
DecoderPlayAudio( p_dec, NULL, &i_played, &i_lost );
} while( (p_aout_buf = p_dec->pf_decode_audio( p_dec, &p_block )) )
else while( (p_aout_buf = p_dec->pf_decode_audio( p_dec, &p_block )) )
{ {
if( DecoderIsFlushing( p_dec ) ) if( DecoderIsFlushing( p_dec ) )
{ {
......
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