Revert "audio: Device threads don't increment physical device refcounts."

This reverts commit 76f81797b7.

This worked in the normal cases, but:

A device thread that calls SDL_DisconnectAudioDevice due to failure will fire
the disconnect event from the device thread...and if there's an event watcher
that uses that moment to close the device, we still end up in the same
situation, where the device thread tries to join on itself.

Better solutions are still pending.
This commit is contained in:
Ryan C. Gordon
2023-10-22 16:14:01 -04:00
parent e5a15f94e2
commit 33c9eeec7c
4 changed files with 10 additions and 2 deletions

View File

@@ -181,6 +181,8 @@ static int EMSCRIPTENAUDIO_OpenDevice(SDL_AudioDevice *device)
return SDL_OutOfMemory();
}
RefPhysicalAudioDevice(device); // CloseDevice will always unref this through SDL_AudioThreadFinalize, even if we failed to start the thread.
// limit to native freq
device->spec.freq = EM_ASM_INT({ return Module['SDL3'].audioContext.sampleRate; });