From 0467c531fa7af52af3522802abd14bf03fd5b882 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Fri, 3 Oct 2025 09:36:31 -0400 Subject: [PATCH] wasapi: Check for a NULL device during disconnect handling. This is probably something we already cleaned up that has something running in an unexpected order now that we've moved disconnect work to the main thread. --- 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 cbd643efee..0a06f2c6d6 100644 --- a/src/audio/wasapi/SDL_wasapi.c +++ b/src/audio/wasapi/SDL_wasapi.c @@ -343,7 +343,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->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. } }