aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/ALu.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2016-05-15 01:19:05 -0700
committerChris Robinson <[email protected]>2016-05-15 01:19:05 -0700
commit576c1116a65bd66effce6d92d1aa7e21d1dee83a (patch)
tree5b7137d90d74e005c9a042ed2c1eef8b4858d7b8 /Alc/ALu.c
parentb3338d25f6d4fd02935ac83d0d3f227b145307d1 (diff)
Avoid using a flag to specify if the effect state needs to be updated
This fixes a potential missed state change if an update with a new state got replaced with one that doesn't.
Diffstat (limited to 'Alc/ALu.c')
-rw-r--r--Alc/ALu.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/Alc/ALu.c b/Alc/ALu.c
index 2fffdcd9..329d01eb 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -336,6 +336,7 @@ static void CalcEffectSlotParams(ALeffectslot *slot, ALCdevice *device)
{
struct ALeffectslotProps *first;
struct ALeffectslotProps *props;
+ ALeffectState *state;
props = ATOMIC_EXCHANGE(struct ALeffectslotProps*, &slot->Update, NULL, almemory_order_acq_rel);
if(!props) return;
@@ -355,13 +356,16 @@ 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.
*/
- if(ATOMIC_LOAD(&props->UpdateState, almemory_order_relaxed))
- slot->Params.EffectState = ATOMIC_EXCHANGE(ALeffectState*,
- &props->State, slot->Params.EffectState, almemory_order_relaxed
- );
+ if(state != slot->Params.EffectState)
+ {
+ ATOMIC_STORE(&props->State, slot->Params.EffectState, almemory_order_relaxed);
+ slot->Params.EffectState = state;
+ }
V(slot->Params.EffectState,update)(device, slot, &props->Props);