From a3c4f854895a87aab68c39843318b8df379f9275 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Tue, 6 Oct 2015 18:50:56 -0700 Subject: [PATCH] ALSA: fix deadlock under some circumstances If the write_callback came upon an error during the prepare phase, and never wrote any frames to the hardware buffer, and another thread tried to soundio_outstream_destroy, this would cause a deadlock. This is now fixed. --- src/alsa.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/alsa.cpp b/src/alsa.cpp index d1f675c..c9a60e1 100644 --- a/src/alsa.cpp +++ b/src/alsa.cpp @@ -1047,6 +1047,8 @@ static void outstream_thread_run(void *arg) { if ((snd_pcm_uframes_t)avail == osa->buffer_size_frames) { outstream->write_callback(outstream, 0, avail); + if (!osa->thread_exit_flag.test_and_set()) + return; continue; }