diff options
author | Chris Robinson <[email protected]> | 2016-08-25 04:57:58 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2016-08-25 04:57:58 -0700 |
commit | 4e4e597fa54cc3498ae28bea9c2684e1fee05389 (patch) | |
tree | 16757d48abbc6f70ae37bd6903811dd465ff8447 /Alc/ALu.c | |
parent | 0fbf34fb4592aa29fcbf4e725719cb253e7d3a78 (diff) |
Track all references for effect states
This allows us to not have to play around with trying to avoid duplicate state
pointers, since the reference count will ensure they're deleted as appropriate.
The only caveat is that the mixer is not allowed to decrement references, since
that can cause the object to be freed (which the mixer code is not allowed to
do).
Diffstat (limited to 'Alc/ALu.c')
-rw-r--r-- | Alc/ALu.c | 15 |
1 files changed, 6 insertions, 9 deletions
@@ -319,18 +319,15 @@ static void CalcEffectSlotParams(ALeffectslot *slot, ALCdevice *device) slot->Params.DecayTime = 0.0f; slot->Params.AirAbsorptionGainHF = 1.0f; } - state = ATOMIC_EXCHANGE(ALeffectState*, &props->State, NULL, almemory_order_relaxed); - /* If the state object is changed, exchange it with the current one so it - * remains in the freelist and isn't leaked. + /* Swap effect states. No need to play with the ref counts since they keep + * the same number of refs. */ - if(state != slot->Params.EffectState) - { - ATOMIC_STORE(&props->State, slot->Params.EffectState, almemory_order_relaxed); - slot->Params.EffectState = state; - } + state = ATOMIC_EXCHANGE(ALeffectState*, &props->State, slot->Params.EffectState, + almemory_order_relaxed); + slot->Params.EffectState = state; - V(slot->Params.EffectState,update)(device, slot, &props->Props); + V(state,update)(device, slot, &props->Props); /* WARNING: A livelock is theoretically possible if another thread keeps * changing the freelist head without giving this a chance to actually swap |