mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-16 23:06:03 +00:00
audio: Fixed race condition in subsystem shutdown.
This makes sure new devices can't be created when we're in the process of shutting down.
This commit is contained in:
@@ -246,7 +246,10 @@ static SDL_AudioDevice *CreatePhysicalAudioDevice(const char *name, SDL_bool isc
|
||||
{
|
||||
SDL_assert(name != NULL);
|
||||
|
||||
if (SDL_AtomicGet(¤t_audio.shutting_down)) {
|
||||
SDL_LockRWLockForReading(current_audio.device_list_lock);
|
||||
const int shutting_down = SDL_AtomicGet(¤t_audio.shutting_down);
|
||||
SDL_UnlockRWLock(current_audio.device_list_lock);
|
||||
if (shutting_down) {
|
||||
return NULL; // we're shutting down, don't add any devices that are hotplugged at the last possible moment.
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user