From 0ed77ca7e2445dd13a4ddfb9523774bbeecc7a81 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 27 Nov 2014 10:19:28 +0100 Subject: 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. --- player/audio.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'player') diff --git a/player/audio.c b/player/audio.c index f2b49b190c..a1e1182e8a 100644 --- a/player/audio.c +++ b/player/audio.c @@ -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) { - mpctx->audio_status = STATUS_SYNCING; - mpctx->sleeptime = 0; + if (!mpctx->paused) { + mpctx->audio_status = STATUS_SYNCING; + mpctx->sleeptime = 0; + } return; // retry on next iteration } -- cgit v1.2.3