From ae0f9672fff8baebbdd9183140bfe07ad8829917 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 10 Sep 2024 20:41:07 +0100 Subject: [PATCH] pipewire: If hotplug initialization fails, clean up any partial success hotplug_loop_init() calls pw_context_new(), which creates a thread internally (for the "data loop"). It also creates a thread of its own, the `hotplug_loop`. Both of these threads are running code from libpipewire, so before we can allow the Pipewire library to be unloaded, we need to destroy the context with pw_context_destroy() and destroy the `hotplug_loop` with pw_thread_loop_destroy(). Resolves: https://github.com/libsdl-org/SDL/issues/10787 Signed-off-by: Simon McVittie --- src/audio/pipewire/SDL_pipewire.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/audio/pipewire/SDL_pipewire.c b/src/audio/pipewire/SDL_pipewire.c index 67b6d8704407d..49249b1cdae7b 100644 --- a/src/audio/pipewire/SDL_pipewire.c +++ b/src/audio/pipewire/SDL_pipewire.c @@ -1252,6 +1252,7 @@ static bool PipewireInitialize(SDL_AudioDriverImpl *impl) } if (!hotplug_loop_init()) { + hotplug_loop_destroy(); PIPEWIRE_Deinitialize(); return false; }