From c440ee99a4dddb5458c75339cf8cef947a55edef Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 31 Jan 2016 22:02:02 +0100 Subject: 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.) --- player/audio.c | 1 + 1 file changed, 1 insertion(+) (limited to 'player') 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 -- cgit v1.2.3