SDL: wasapi: Don't ignore device disconnect events on unopened devices.

From b9c790949e4ff6bc26813b437d477da694269ef5 Mon Sep 17 00:00:00 2001
From: unknown <[EMAIL REDACTED]>
Date: Sun, 9 Nov 2025 01:10:38 -0500
Subject: [PATCH] wasapi: Don't ignore device disconnect events on unopened
 devices.

Reference Issue #13317.
---
 src/audio/wasapi/SDL_wasapi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/audio/wasapi/SDL_wasapi.c b/src/audio/wasapi/SDL_wasapi.c
index 8a9907eb65518..b641d01eb25b1 100644
--- a/src/audio/wasapi/SDL_wasapi.c
+++ b/src/audio/wasapi/SDL_wasapi.c
@@ -347,7 +347,7 @@ static void WASAPI_DetectDevices(SDL_AudioDevice **default_playback, SDL_AudioDe
 void WASAPI_DisconnectDevice(SDL_AudioDevice *device)
 {
     // don't block in here; IMMDevice's own thread needs to return or everything will deadlock.
-    if (device && device->hidden && SDL_CompareAndSwapAtomicInt(&device->hidden->device_disconnecting, 0, 1)) {
+    if (device && (!device->hidden || SDL_CompareAndSwapAtomicInt(&device->hidden->device_disconnecting, 0, 1))) {
         SDL_AudioDeviceDisconnected(device); // this proxies the work to the main thread now, so no point in proxying to the management thread.
     }
 }