From c67f36dd18f22dc027af129098a998866e4c2a33 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 4 Jun 2020 12:42:13 +0200 Subject: audio: fix deadlock on draining The playback thread may obviously still fill the AO'S entire audio buffer, which means it unset p->draining, which makes no sense and broke ao_drain(). So just don't unset it here. Not sure if this really fixes this, it was hard to reproduce. Regression due to the recent changes. There are probably many more bugs like this. Stupid asynchronous nightmare state machine. Give me a language that supports formal verification (in presence of concurrency) or something. --- audio/out/buffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/audio/out/buffer.c b/audio/out/buffer.c index c69ef6d813..dc053c3e2c 100644 --- a/audio/out/buffer.c +++ b/audio/out/buffer.c @@ -632,7 +632,7 @@ static void ao_play_data(struct ao *ao) bool ok = true; int written = 0; if (samples) { - p->draining = is_eof; + p->draining |= is_eof; MP_STATS(ao, "start ao fill"); ok = ao->driver->write(ao, planes, samples); MP_STATS(ao, "end ao fill"); -- cgit v1.2.3