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/echo.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/echo.c')
-rw-r--r-- | Alc/effects/echo.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/Alc/effects/echo.c b/Alc/effects/echo.c index 8600db70..eea86f15 100644 --- a/Alc/effects/echo.c +++ b/Alc/effects/echo.c @@ -54,6 +54,7 @@ static ALvoid ALechoState_Destruct(ALechoState *state) { free(state->SampleBuffer); state->SampleBuffer = NULL; + ALeffectState_Destruct(STATIC_CAST(ALeffectState,state)); } static ALboolean ALechoState_deviceUpdate(ALechoState *state, ALCdevice *Device) @@ -87,11 +88,11 @@ static ALvoid ALechoState_update(ALechoState *state, const ALCdevice *Device, co ALfloat coeffs[MAX_AMBI_COEFFS]; ALfloat gain, lrpan, spread; - state->Tap[0].delay = fastf2u(Slot->EffectProps.Echo.Delay * frequency) + 1; - state->Tap[1].delay = fastf2u(Slot->EffectProps.Echo.LRDelay * frequency); + state->Tap[0].delay = fastf2u(Slot->Params.EffectProps.Echo.Delay * frequency) + 1; + state->Tap[1].delay = fastf2u(Slot->Params.EffectProps.Echo.LRDelay * frequency); state->Tap[1].delay += state->Tap[0].delay; - spread = Slot->EffectProps.Echo.Spread; + spread = Slot->Params.EffectProps.Echo.Spread; if(spread < 0.0f) lrpan = -1.0f; else lrpan = 1.0f; /* Convert echo spread (where 0 = omni, +/-1 = directional) to coverage @@ -99,14 +100,14 @@ static ALvoid ALechoState_update(ALechoState *state, const ALCdevice *Device, co */ spread = asinf(1.0f - fabsf(spread))*4.0f; - state->FeedGain = Slot->EffectProps.Echo.Feedback; + state->FeedGain = Slot->Params.EffectProps.Echo.Feedback; - gain = minf(1.0f - Slot->EffectProps.Echo.Damping, 0.01f); + gain = minf(1.0f - Slot->Params.EffectProps.Echo.Damping, 0.01f); ALfilterState_setParams(&state->Filter, ALfilterType_HighShelf, gain, LOWPASSFREQREF/frequency, calc_rcpQ_from_slope(gain, 0.75f)); - gain = Slot->Gain; + gain = Slot->Params.Gain; /* First tap panning */ CalcXYZCoeffs(-lrpan, 0.0f, 0.0f, spread, coeffs); |