audio: fix busy loop when seeking while paused

When playing paused, the amount of decoded audio is limited to a small
amount (1 sample), because we don't write any audio to the AO when
paused. The small amount could trigger the case of the wanted audio
being too far in the future in the PTS sync code, which set the audio
status to STATUS_DRAINING, which in turn triggered the EOF code in the
next iteration. This was ok, but unfortunately, this triggered another
retry in order to check resuming from EOF by setting the status to
STATUS_SYNCING, which in turn lead to the busy loop by alternating
between the 2 states. So don't try resyncing while paused.

Since the PTS syncing code also calls ao_reset(), this could cause the
pulseaudio daemon to consume some CPU time as well.

This was caused by commit 33b57f55. Before that, the playloop was merely
run more often, but didn't cause any problems.

Fixes #1288.
This commit is contained in:
wm4 2014-11-27 10:19:28 +01:00
parent a98f88a12f
commit 0ed77ca7e2
1 changed files with 4 additions and 2 deletions

View File

@ -514,8 +514,10 @@ static void do_fill_audio_out_buffers(struct MPContext *mpctx, double endpts)
// 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->paused) {
mpctx->audio_status = STATUS_SYNCING;
mpctx->sleeptime = 0;
}
return; // retry on next iteration
}