audio: fix late audio start

Regression since commit bbcd0b6a. This code is just cursed, because it's
a fragile state machine with no proper tests, and which could be done in
a much simpler way. Without doubt this change will cause a regression in
some ridiculous corner case as well.

Fixes #3610 (the cause of it, not the behavior it resulted in).
This commit is contained in:
wm4 2016-10-02 13:47:19 +02:00
parent 6f4d918cb7
commit 3a5cbf3907
1 changed files with 3 additions and 1 deletions

View File

@ -988,7 +988,9 @@ void fill_audio_out_buffers(struct MPContext *mpctx)
// If EOF was reached before, but now something can be decoded, try to
// restart audio properly. This helps with video files where audio starts
// later. Retrying is needed to get the correct sync PTS.
if (mpctx->audio_status >= STATUS_DRAINING && status == AD_OK) {
if (mpctx->audio_status >= STATUS_DRAINING &&
mp_audio_buffer_samples(ao_c->ao_buffer) > 0)
{
mpctx->audio_status = STATUS_SYNCING;
return; // retry on next iteration
}