Don't lock the device state when preparing a new effect state
commitfddfbb6e74260a5f823749920ca1acc0e1bd4397
authorChris Robinson <chris.kcat@gmail.com>
Tue, 4 Jun 2024 00:33:43 +0000 (3 17:33 -0700)
committerChris Robinson <chris.kcat@gmail.com>
Tue, 4 Jun 2024 00:33:43 +0000 (3 17:33 -0700)
tree8bc098d02dad33771e8288ce37757f4fc1b5d209
parent6d5d9a8a85e83e6b38be650dfeed2add638699c0
Don't lock the device state when preparing a new effect state

There is technically a small race condition with the device getting reset on a
separate thread at the same time, but the way the locks get ordered would
otherwise risk a deadlock (alAuxiliaryEffectSloti first locks the context's
mPropLock and mEffectSlotLock before initEffect locks the device's StateLock,
while alcCreateContext and alcResetDeviceSOFT first locks the device's
StateLock before UpdateDeviceParams locks the context's mPropLock and
mEffectSlotLock).

In contrast, the race condition may (depending on timing) set up the effect
state with an older or mixed device format and assign invalid or null pointers,
which will get properly reset and cleaned up after the device is reconfigured
and before restarting.
al/auxeffectslot.cpp