SDL: pulseaudio: Hotplug thread fixes. (e9efc)

From e9efcfb428c6cf4ee49b249fb099981445685e0d Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Thu, 12 Sep 2024 18:00:58 -0400
Subject: [PATCH] pulseaudio: Hotplug thread fixes.

This used a tiny stack, which apparently upsets Blender for various
technical reasons. Instead, just use the default stack size, which should
give it plenty of space to work.

If the thread failed to create, we would then wait on a semaphore that would
never trigger, so don't do that anymore!

Fixes #10806.

(cherry-picked from commit b7dc30ca24650a22de61c0c4ab28f7cb5905dee9)

(cherry picked from commit 58f2586b4463b5b7e637b9b54798b4d6f0375c51)
---
 src/audio/pulseaudio/SDL_pulseaudio.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/audio/pulseaudio/SDL_pulseaudio.c b/src/audio/pulseaudio/SDL_pulseaudio.c
index 5039d0547a2ea..f34deb0ec1d05 100644
--- a/src/audio/pulseaudio/SDL_pulseaudio.c
+++ b/src/audio/pulseaudio/SDL_pulseaudio.c
@@ -897,8 +897,12 @@ static void PULSEAUDIO_DetectDevices(void)
 
     /* ok, we have a sane list, let's set up hotplug notifications now... */
     SDL_AtomicSet(&pulseaudio_hotplug_thread_active, 1);
-    pulseaudio_hotplug_thread = SDL_CreateThreadInternal(HotplugThread, "PulseHotplug", 256 * 1024, ready_sem);  /* !!! FIXME: this can probably survive in significantly less stack space. */
-    SDL_SemWait(ready_sem);
+    pulseaudio_hotplug_thread = SDL_CreateThreadInternal(HotplugThread, "PulseHotplug", 0, ready_sem);
+    if (pulseaudio_hotplug_thread) {
+        SDL_SemWait(ready_sem);
+    } else {
+        SDL_AtomicSet(&pulseaudio_hotplug_thread_active, 0);  // thread failed to start, we'll go on without hotplug.
+    }
     SDL_DestroySemaphore(ready_sem);
 }