mirror of https://github.com/mpv-player/mpv
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.)
This commit is contained in:
parent
006c9694c0
commit
c440ee99a4
|
@ -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));
|
mp_audio_buffer_skip(ao_c->ao_buffer, MPMIN(skip, max));
|
||||||
// If something is left, we definitely reached the target time.
|
// If something is left, we definitely reached the target time.
|
||||||
end_sync |= sync_known && skip < max;
|
end_sync |= sync_known && skip < max;
|
||||||
|
working |= skip > 0;
|
||||||
} else if (skip < 0) {
|
} else if (skip < 0) {
|
||||||
if (-skip > playsize) { // heuristic against making the buffer too large
|
if (-skip > playsize) { // heuristic against making the buffer too large
|
||||||
ao_reset(mpctx->ao); // some AOs repeat data on underflow
|
ao_reset(mpctx->ao); // some AOs repeat data on underflow
|
||||||
|
|
Loading…
Reference in New Issue