summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-01-31 22:02:02 +0100
committerwm4 <wm4@nowhere>2016-01-31 22:02:02 +0100
commitc440ee99a4dddb5458c75339cf8cef947a55edef (patch)
treea7f41c892b42d54d9eddfa5dabf24290898a511c
parent006c9694c0990a05eb8f967448489958b6d7a5e8 (diff)
downloadmpv-c440ee99a4dddb5458c75339cf8cef947a55edef.tar.bz2
mpv-c440ee99a4dddb5458c75339cf8cef947a55edef.tar.xz
audio: fix a case of going to sleep before playback start
This code is tricky because it has to wakeup the mainloop to make progressing during syncing audio, but also has to avoid waking it up when it's not needed. Failure to do so either burns CPU by not ever going to sleep, or causes apparent "freezes" by going to sleep (and it will continue if the mainloop is woken up e.g. due to user input). In this case, simply starting A/V playback with --start=5 and removing an unrelated wakeup in osd.c can trigger such a "freeze". The unrelated wakeup did hide this bug, nonetheless it's a bug. (Can't wait to rewrite this shitty audio resync code. And it's all my fault.)
-rw-r--r--player/audio.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/player/audio.c b/player/audio.c
index d6cfd4fb61..a4c43a0e93 100644
--- a/player/audio.c
+++ b/player/audio.c
@@ -772,6 +772,7 @@ void fill_audio_out_buffers(struct MPContext *mpctx, double endpts)
mp_audio_buffer_skip(ao_c->ao_buffer, MPMIN(skip, max));
// If something is left, we definitely reached the target time.
end_sync |= sync_known && skip < max;
+ working |= skip > 0;
} else if (skip < 0) {
if (-skip > playsize) { // heuristic against making the buffer too large
ao_reset(mpctx->ao); // some AOs repeat data on underflow