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/flanger.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/flanger.c')
-rw-r--r-- | Alc/effects/flanger.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/Alc/effects/flanger.c b/Alc/effects/flanger.c index a71eb9c2..966622e6 100644 --- a/Alc/effects/flanger.c +++ b/Alc/effects/flanger.c @@ -60,6 +60,7 @@ static ALvoid ALflangerState_Destruct(ALflangerState *state) free(state->SampleBuffer[0]); state->SampleBuffer[0] = NULL; state->SampleBuffer[1] = NULL; + ALeffectState_Destruct(STATIC_CAST(ALeffectState,state)); } static ALboolean ALflangerState_deviceUpdate(ALflangerState *state, ALCdevice *Device) @@ -98,7 +99,7 @@ static ALvoid ALflangerState_update(ALflangerState *state, const ALCdevice *Devi ALfloat rate; ALint phase; - switch(Slot->EffectProps.Flanger.Waveform) + switch(Slot->Params.EffectProps.Flanger.Waveform) { case AL_FLANGER_WAVEFORM_TRIANGLE: state->waveform = FWF_Triangle; @@ -107,18 +108,18 @@ static ALvoid ALflangerState_update(ALflangerState *state, const ALCdevice *Devi state->waveform = FWF_Sinusoid; break; } - state->depth = Slot->EffectProps.Flanger.Depth; - state->feedback = Slot->EffectProps.Flanger.Feedback; - state->delay = fastf2i(Slot->EffectProps.Flanger.Delay * frequency); + state->depth = Slot->Params.EffectProps.Flanger.Depth; + state->feedback = Slot->Params.EffectProps.Flanger.Feedback; + state->delay = fastf2i(Slot->Params.EffectProps.Flanger.Delay * frequency); /* Gains for left and right sides */ CalcXYZCoeffs(-1.0f, 0.0f, 0.0f, 0.0f, coeffs); - ComputePanningGains(Device->Dry, coeffs, Slot->Gain, state->Gain[0]); + ComputePanningGains(Device->Dry, coeffs, Slot->Params.Gain, state->Gain[0]); CalcXYZCoeffs( 1.0f, 0.0f, 0.0f, 0.0f, coeffs); - ComputePanningGains(Device->Dry, coeffs, Slot->Gain, state->Gain[1]); + ComputePanningGains(Device->Dry, coeffs, Slot->Params.Gain, state->Gain[1]); - phase = Slot->EffectProps.Flanger.Phase; - rate = Slot->EffectProps.Flanger.Rate; + phase = Slot->Params.EffectProps.Flanger.Phase; + rate = Slot->Params.EffectProps.Flanger.Rate; if(!(rate > 0.0f)) { state->lfo_scale = 0.0f; |