diff options
author | Chris Robinson <[email protected]> | 2016-05-15 01:19:05 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2016-05-15 01:19:05 -0700 |
commit | 576c1116a65bd66effce6d92d1aa7e21d1dee83a (patch) | |
tree | 5b7137d90d74e005c9a042ed2c1eef8b4858d7b8 /OpenAL32/alAuxEffectSlot.c | |
parent | b3338d25f6d4fd02935ac83d0d3f227b145307d1 (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 'OpenAL32/alAuxEffectSlot.c')
-rw-r--r-- | OpenAL32/alAuxEffectSlot.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/OpenAL32/alAuxEffectSlot.c b/OpenAL32/alAuxEffectSlot.c index 6d1423db..0dd6a53f 100644 --- a/OpenAL32/alAuxEffectSlot.c +++ b/OpenAL32/alAuxEffectSlot.c @@ -201,7 +201,7 @@ AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSloti(ALuint effectslot, ALenum param if(!(value == AL_TRUE || value == AL_FALSE)) SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done); slot->AuxSendAuto = value; - UpdateEffectSlotProps(slot, AL_FALSE); + UpdateEffectSlotProps(slot); if(!ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire)) UpdateAllSourceProps(context); break; @@ -264,7 +264,7 @@ AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotf(ALuint effectslot, ALenum param default: SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done); } - UpdateEffectSlotProps(slot, AL_FALSE); + UpdateEffectSlotProps(slot); done: WriteUnlock(&context->PropLock); @@ -502,12 +502,12 @@ ALenum InitializeEffect(ALCdevice *Device, ALeffectslot *EffectSlot, ALeffect *e } EffectSlot->Effect.State = State; - UpdateEffectSlotProps(EffectSlot, AL_TRUE); + UpdateEffectSlotProps(EffectSlot); } else if(effect) { memcpy(&EffectSlot->Effect.Props, &effect->Props, sizeof(EffectSlot->Effect.Props)); - UpdateEffectSlotProps(EffectSlot, AL_FALSE); + UpdateEffectSlotProps(EffectSlot); } return AL_NO_ERROR; @@ -556,7 +556,8 @@ void DeinitEffectSlot(ALeffectslot *slot) { ALeffectState *state; state = ATOMIC_LOAD(&props->State, almemory_order_relaxed); - DELETE_OBJ(state); + if(state != slot->Params.EffectState) + DELETE_OBJ(state); TRACE("Freed unapplied AuxiliaryEffectSlot update %p\n", props); al_free(props); } @@ -577,7 +578,7 @@ void DeinitEffectSlot(ALeffectslot *slot) DELETE_OBJ(slot->Params.EffectState); } -void UpdateEffectSlotProps(ALeffectslot *slot, ALboolean withstate) +void UpdateEffectSlotProps(ALeffectslot *slot) { struct ALeffectslotProps *props; ALeffectState *oldstate; @@ -605,10 +606,8 @@ void UpdateEffectSlotProps(ALeffectslot *slot, ALboolean withstate) /* Swap out any stale effect state object there may be in the container, to * delete it. */ - ATOMIC_STORE(&props->UpdateState, withstate, almemory_order_relaxed); - oldstate = ATOMIC_EXCHANGE(ALeffectState*, &props->State, - withstate ? slot->Effect.State : NULL, almemory_order_relaxed - ); + oldstate = ATOMIC_EXCHANGE(ALeffectState*, &props->State, slot->Effect.State, + almemory_order_relaxed); /* Set the new container for updating internal parameters. */ props = ATOMIC_EXCHANGE(struct ALeffectslotProps*, &slot->Update, props, |