Audio: fix potential exit deadlock

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2024-05-13 07:54:14 +02:00
parent 36f21d5c4d
commit 194fe8a451

View file

@ -245,6 +245,14 @@ fn writeFn(audio_opaque: ?*anyopaque, output: []u8) void {
break :l; break :l;
} }
audio.state().output_mu.unlock(); audio.state().output_mu.unlock();
// Handle potential exit
audio.state().running_mu.lock();
if (!audio.state().running) {
audio.state().running_mu.unlock();
@memset(output, 0);
return;
}
} }
} }
if (read_slice.len > output.len) { if (read_slice.len > output.len) {