audio: fix resync issue different

Commit 10915000 attempted to fix wasting CPU when resyncing and no new
data was actually coming from the demuxer. The fix assumed that at this
point it would have reached the sync point, but since the code attempts
weird incremental decoding, this wasn't actually true. So it broke
seeking in addition to removing the CPU waste.

Try something else. This time, we essentially only wakeup again if
data was read (i.e. audio_decode() returned successfully).
This commit is contained in:
wm4 2015-05-19 23:23:17 +02:00
parent 36529bc6f7
commit 402fe381d7
1 changed files with 3 additions and 1 deletions

View File

@ -478,6 +478,7 @@ static void do_fill_audio_out_buffers(struct MPContext *mpctx, double endpts)
}
int status = AD_OK;
bool working = false;
if (playsize > mp_audio_buffer_samples(mpctx->ao_buffer)) {
status = audio_decode(d_audio, mpctx->ao_buffer, playsize);
if (status == AD_WAIT)
@ -495,6 +496,7 @@ static void do_fill_audio_out_buffers(struct MPContext *mpctx, double endpts)
}
if (status == AD_ERR)
mpctx->sleeptime = 0;
working = true;
}
// If EOF was reached before, but now something can be decoded, try to
@ -527,7 +529,7 @@ static void do_fill_audio_out_buffers(struct MPContext *mpctx, double endpts)
mpctx->audio_status = STATUS_FILLING;
if (status != AD_OK && !mp_audio_buffer_samples(mpctx->ao_buffer))
mpctx->audio_status = STATUS_EOF;
if (mpctx->audio_status != STATUS_SYNCING)
if (working)
mpctx->sleeptime = 0;
return; // continue on next iteration
}