From 402fe381d7a94c8596d1bed0c8e089b08a298e85 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 19 May 2015 23:23:17 +0200 Subject: 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). --- player/audio.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'player/audio.c') diff --git a/player/audio.c b/player/audio.c index 7691b32563..034325594f 100644 --- a/player/audio.c +++ b/player/audio.c @@ -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 } -- cgit v1.2.3