diff options
author | Chris Robinson <[email protected]> | 2016-05-12 19:05:06 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2016-05-12 19:05:06 -0700 |
commit | 210e150601d9b458d446483f5f16e1e67cc6e3ba (patch) | |
tree | c7230d482b5628b334845a1f735ef3d1a42d5a98 /Alc | |
parent | ef0d4f8210fe6aa65b9df96f3b64bf6f355e845a (diff) |
Avoid updating the effect state object if it's not changed
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/ALc.c | 24 | ||||
-rw-r--r-- | Alc/ALu.c | 15 |
2 files changed, 19 insertions, 20 deletions
@@ -2066,7 +2066,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) RestoreFPUMode(&oldMode); return ALC_INVALID_DEVICE; } - UpdateEffectSlotProps(slot); + UpdateEffectSlotProps(slot, AL_FALSE); } context = ATOMIC_LOAD(&device->ContextList); @@ -2078,17 +2078,18 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) for(pos = 0;pos < context->EffectSlotMap.size;pos++) { ALeffectslot *slot = context->EffectSlotMap.array[pos].value; + ALeffectState *state = slot->Params.EffectState; - slot->Params.EffectState->OutBuffer = device->Dry.Buffer; - slot->Params.EffectState->OutChannels = device->Dry.NumChannels; - if(V(slot->Params.EffectState,deviceUpdate)(device) == AL_FALSE) + state->OutBuffer = device->Dry.Buffer; + state->OutChannels = device->Dry.NumChannels; + if(V(state,deviceUpdate)(device) == AL_FALSE) { UnlockUIntMapRead(&context->EffectSlotMap); V0(device->Backend,unlock)(); RestoreFPUMode(&oldMode); return ALC_INVALID_DEVICE; } - UpdateEffectSlotProps(slot); + UpdateEffectSlotProps(slot, AL_FALSE); } UnlockUIntMapRead(&context->EffectSlotMap); @@ -3487,16 +3488,15 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName) device->DefaultSlot = NULL; ERR("Failed to initialize the default effect slot\n"); } - else if(InitializeEffect(device, device->DefaultSlot, &DefaultEffect) != AL_NO_ERROR) - { - DeinitEffectSlot(device->DefaultSlot); - device->DefaultSlot = NULL; - ERR("Failed to initialize the default effect\n"); - } else { aluInitEffectPanning(device->DefaultSlot); - UpdateEffectSlotProps(device->DefaultSlot); + if(InitializeEffect(device, device->DefaultSlot, &DefaultEffect) != AL_NO_ERROR) + { + DeinitEffectSlot(device->DefaultSlot); + device->DefaultSlot = NULL; + ERR("Failed to initialize the default effect\n"); + } } } @@ -342,14 +342,6 @@ static ALboolean CalcEffectSlotParams(ALeffectslot *slot, ALCdevice *device) slot->Params.AuxSendAuto = ATOMIC_LOAD(&props->AuxSendAuto, almemory_order_relaxed); slot->Params.EffectType = ATOMIC_LOAD(&props->Type, almemory_order_relaxed); memcpy(&slot->Params.EffectProps, &props->Props, sizeof(props->Props)); - /* If the existing state object is different from the one being set, - * exchange it so it remains in the freelist and isn't leaked. - */ - if(slot->Params.EffectState == ATOMIC_LOAD(&props->State, almemory_order_relaxed)) - slot->Params.EffectState = NULL; - slot->Params.EffectState = ATOMIC_EXCHANGE(ALeffectState*, - &props->State, slot->Params.EffectState, almemory_order_relaxed - ); if(IsReverbEffect(slot->Params.EffectType)) { slot->Params.RoomRolloff = slot->Params.EffectProps.Reverb.RoomRolloffFactor; @@ -362,6 +354,13 @@ static ALboolean CalcEffectSlotParams(ALeffectslot *slot, ALCdevice *device) slot->Params.DecayTime = 0.0f; slot->Params.AirAbsorptionGainHF = 1.0f; } + /* 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 + ); V(slot->Params.EffectState,update)(device, slot); |