From 924f370bd7c2f849073ad43ad2320779c0ce28fc Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sat, 24 Jun 2023 11:13:23 -0400 Subject: [PATCH] pulseaudio: Fix deadlock in HotplugThread. If we wait for context subscription to finish, we might miss the signal telling us to terminate the thread...this can happen if an app initializes the audio subsystem and then quits immediately. So just go right into the main loop of the thread; the subscription will finish when it finishes and then events will flow. --- src/audio/pulseaudio/SDL_pulseaudio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/audio/pulseaudio/SDL_pulseaudio.c b/src/audio/pulseaudio/SDL_pulseaudio.c index 94e5ef445f..85dc8b5977 100644 --- a/src/audio/pulseaudio/SDL_pulseaudio.c +++ b/src/audio/pulseaudio/SDL_pulseaudio.c @@ -865,7 +865,7 @@ static int SDLCALL HotplugThread(void *data) SDL_SetThreadPriority(SDL_THREAD_PRIORITY_LOW); PULSEAUDIO_pa_threaded_mainloop_lock(pulseaudio_threaded_mainloop); PULSEAUDIO_pa_context_set_subscribe_callback(pulseaudio_context, HotplugCallback, NULL); - WaitForPulseOperation(PULSEAUDIO_pa_context_subscribe(pulseaudio_context, PA_SUBSCRIPTION_MASK_SINK | PA_SUBSCRIPTION_MASK_SOURCE, NULL, NULL)); + PULSEAUDIO_pa_operation_unref(PULSEAUDIO_pa_context_subscribe(pulseaudio_context, PA_SUBSCRIPTION_MASK_SINK | PA_SUBSCRIPTION_MASK_SOURCE, NULL, NULL)); while (SDL_AtomicGet(&pulseaudio_hotplug_thread_active)) { PULSEAUDIO_pa_threaded_mainloop_wait(pulseaudio_threaded_mainloop);