diff options
author | Chris Robinson <[email protected]> | 2016-05-12 18:26:33 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2016-05-12 18:41:33 -0700 |
commit | ef0d4f8210fe6aa65b9df96f3b64bf6f355e845a (patch) | |
tree | 401b74c7c7291229397883c73d4ad2c382275b7e /Alc/effects/autowah.c | |
parent | 186b54aa3d5f1398a384fa318aa000210d82437e (diff) |
Provide (mostly) lockless updates for effect slots
Similar to the listener, separate containers are provided atomically for the
mixer thread to apply updates without needing to block, and a free-list is used
to reuse container objects.
A couple things to note. First, the lock is still used when the effect state's
deviceUpdate method is called to prevent asynchronous calls to reset the device
from interfering. This can be fixed by using the list lock in ALc.c instead.
Secondly, old effect states aren't immediately deleted when the effect type
changes (the actual type, not just its properties). This is because the mixer
thread is intended to be real-time safe, and so can't be freeing anything. They
are cleared away when updates reuse the container they were kept in, and they
don't incur any extra processing cost, but there may be cases where the memory
is kept around until the effect slot is deleted.
Diffstat (limited to 'Alc/effects/autowah.c')
-rw-r--r-- | Alc/effects/autowah.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/Alc/effects/autowah.c b/Alc/effects/autowah.c index 7c5abfb1..1e7a8e29 100644 --- a/Alc/effects/autowah.c +++ b/Alc/effects/autowah.c @@ -53,8 +53,9 @@ typedef struct ALautowahState { ALfilterState LowPass; } ALautowahState; -static ALvoid ALautowahState_Destruct(ALautowahState *UNUSED(state)) +static ALvoid ALautowahState_Destruct(ALautowahState *state) { + ALeffectState_Destruct(STATIC_CAST(ALeffectState,state)); } static ALboolean ALautowahState_deviceUpdate(ALautowahState *state, ALCdevice *device) @@ -67,15 +68,15 @@ static ALvoid ALautowahState_update(ALautowahState *state, const ALCdevice *devi { ALfloat attackTime, releaseTime; - attackTime = slot->EffectProps.Autowah.AttackTime * state->Frequency; - releaseTime = slot->EffectProps.Autowah.ReleaseTime * state->Frequency; + attackTime = slot->Params.EffectProps.Autowah.AttackTime * state->Frequency; + releaseTime = slot->Params.EffectProps.Autowah.ReleaseTime * state->Frequency; state->AttackRate = powf(1.0f/GAIN_SILENCE_THRESHOLD, 1.0f/attackTime); state->ReleaseRate = powf(GAIN_SILENCE_THRESHOLD/1.0f, 1.0f/releaseTime); - state->PeakGain = slot->EffectProps.Autowah.PeakGain; - state->Resonance = slot->EffectProps.Autowah.Resonance; + state->PeakGain = slot->Params.EffectProps.Autowah.PeakGain; + state->Resonance = slot->Params.EffectProps.Autowah.Resonance; - ComputeAmbientGains(device->Dry, slot->Gain, state->Gain); + ComputeAmbientGains(device->Dry, slot->Params.Gain, state->Gain); } static ALvoid ALautowahState_process(ALautowahState *state, ALuint SamplesToDo, const ALfloat (*restrict SamplesIn)[BUFFERSIZE], ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels) |