diff options
-rw-r--r-- | Alc/ALu.c | 19 | ||||
-rw-r--r-- | Alc/effects/autowah.c | 10 | ||||
-rw-r--r-- | Alc/effects/chorus.c | 14 | ||||
-rw-r--r-- | Alc/effects/compressor.c | 4 | ||||
-rw-r--r-- | Alc/effects/dedicated.c | 4 | ||||
-rw-r--r-- | Alc/effects/distortion.c | 12 | ||||
-rw-r--r-- | Alc/effects/echo.c | 12 | ||||
-rw-r--r-- | Alc/effects/equalizer.c | 22 | ||||
-rw-r--r-- | Alc/effects/flanger.c | 14 | ||||
-rw-r--r-- | Alc/effects/modulator.c | 10 | ||||
-rw-r--r-- | Alc/effects/null.c | 2 | ||||
-rw-r--r-- | Alc/effects/reverb.c | 5 | ||||
-rw-r--r-- | OpenAL32/Include/alAuxEffectSlot.h | 5 | ||||
-rw-r--r-- | OpenAL32/Include/alListener.h | 6 | ||||
-rw-r--r-- | OpenAL32/alListener.c | 4 | ||||
-rw-r--r-- | OpenAL32/alState.c | 10 |
16 files changed, 81 insertions, 72 deletions
@@ -316,6 +316,10 @@ static ALboolean CalcListenerParams(ALCcontext *Context) Listener->Params.SpeedOfSound = ATOMIC_LOAD(&props->SpeedOfSound, almemory_order_relaxed) * ATOMIC_LOAD(&props->DopplerVelocity, almemory_order_relaxed); + Listener->Params.SourceDistanceModel = ATOMIC_LOAD(&props->SourceDistanceModel, + almemory_order_relaxed); + Listener->Params.DistanceModel = ATOMIC_LOAD(&props->DistanceModel, almemory_order_relaxed); + /* WARNING: A livelock is theoretically possible if another thread keeps * changing the freelist head without giving this a chance to actually swap * in the old container (practically impossible with this little code, @@ -341,12 +345,11 @@ static ALboolean CalcEffectSlotParams(ALeffectslot *slot, ALCdevice *device) slot->Params.Gain = ATOMIC_LOAD(&props->Gain, almemory_order_relaxed); 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(IsReverbEffect(slot->Params.EffectType)) { - slot->Params.RoomRolloff = slot->Params.EffectProps.Reverb.RoomRolloffFactor; - slot->Params.DecayTime = slot->Params.EffectProps.Reverb.DecayTime; - slot->Params.AirAbsorptionGainHF = slot->Params.EffectProps.Reverb.AirAbsorptionGainHF; + slot->Params.RoomRolloff = props->Props.Reverb.RoomRolloffFactor; + slot->Params.DecayTime = props->Props.Reverb.DecayTime; + slot->Params.AirAbsorptionGainHF = props->Props.Reverb.AirAbsorptionGainHF; } else { @@ -362,6 +365,8 @@ static ALboolean CalcEffectSlotParams(ALeffectslot *slot, ALCdevice *device) &props->State, slot->Params.EffectState, almemory_order_relaxed ); + V(slot->Params.EffectState,update)(device, slot, &props->Props); + /* WARNING: A livelock is theoretically possible if another thread keeps * changing the freelist head without giving this a chance to actually swap * in the old container (practically impossible with this little code, @@ -373,8 +378,6 @@ static ALboolean CalcEffectSlotParams(ALeffectslot *slot, ALCdevice *device) } while(ATOMIC_COMPARE_EXCHANGE_WEAK(struct ALeffectslotProps*, &slot->FreeList, &first, props) == 0); - V(slot->Params.EffectState,update)(device, slot); - return AL_TRUE; } @@ -961,8 +964,8 @@ ALvoid CalcSourceParams(ALvoice *voice, const ALsource *ALSource, const ALbuffer Attenuation = 1.0f; for(i = 0;i < NumSends;i++) RoomAttenuation[i] = 1.0f; - switch(ALContext->SourceDistanceModel ? ALSource->DistanceModel : - ALContext->DistanceModel) + switch(Listener->Params.SourceDistanceModel ? ALSource->DistanceModel : + Listener->Params.DistanceModel) { case InverseDistanceClamped: ClampedDist = clampf(ClampedDist, MinDist, MaxDist); diff --git a/Alc/effects/autowah.c b/Alc/effects/autowah.c index 1e7a8e29..648afc83 100644 --- a/Alc/effects/autowah.c +++ b/Alc/effects/autowah.c @@ -64,17 +64,17 @@ static ALboolean ALautowahState_deviceUpdate(ALautowahState *state, ALCdevice *d return AL_TRUE; } -static ALvoid ALautowahState_update(ALautowahState *state, const ALCdevice *device, const ALeffectslot *slot) +static ALvoid ALautowahState_update(ALautowahState *state, const ALCdevice *device, const ALeffectslot *slot, const ALeffectProps *props) { ALfloat attackTime, releaseTime; - attackTime = slot->Params.EffectProps.Autowah.AttackTime * state->Frequency; - releaseTime = slot->Params.EffectProps.Autowah.ReleaseTime * state->Frequency; + attackTime = props->Autowah.AttackTime * state->Frequency; + releaseTime = props->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->Params.EffectProps.Autowah.PeakGain; - state->Resonance = slot->Params.EffectProps.Autowah.Resonance; + state->PeakGain = props->Autowah.PeakGain; + state->Resonance = props->Autowah.Resonance; ComputeAmbientGains(device->Dry, slot->Params.Gain, state->Gain); } diff --git a/Alc/effects/chorus.c b/Alc/effects/chorus.c index 3eff95a4..e1cbba2d 100644 --- a/Alc/effects/chorus.c +++ b/Alc/effects/chorus.c @@ -92,14 +92,14 @@ static ALboolean ALchorusState_deviceUpdate(ALchorusState *state, ALCdevice *Dev return AL_TRUE; } -static ALvoid ALchorusState_update(ALchorusState *state, const ALCdevice *Device, const ALeffectslot *Slot) +static ALvoid ALchorusState_update(ALchorusState *state, const ALCdevice *Device, const ALeffectslot *Slot, const ALeffectProps *props) { ALfloat frequency = (ALfloat)Device->Frequency; ALfloat coeffs[MAX_AMBI_COEFFS]; ALfloat rate; ALint phase; - switch(Slot->Params.EffectProps.Chorus.Waveform) + switch(props->Chorus.Waveform) { case AL_CHORUS_WAVEFORM_TRIANGLE: state->waveform = CWF_Triangle; @@ -108,9 +108,9 @@ static ALvoid ALchorusState_update(ALchorusState *state, const ALCdevice *Device state->waveform = CWF_Sinusoid; break; } - state->depth = Slot->Params.EffectProps.Chorus.Depth; - state->feedback = Slot->Params.EffectProps.Chorus.Feedback; - state->delay = fastf2i(Slot->Params.EffectProps.Chorus.Delay * frequency); + state->depth = props->Chorus.Depth; + state->feedback = props->Chorus.Feedback; + state->delay = fastf2i(props->Chorus.Delay * frequency); /* Gains for left and right sides */ CalcXYZCoeffs(-1.0f, 0.0f, 0.0f, 0.0f, coeffs); @@ -118,8 +118,8 @@ static ALvoid ALchorusState_update(ALchorusState *state, const ALCdevice *Device CalcXYZCoeffs( 1.0f, 0.0f, 0.0f, 0.0f, coeffs); ComputePanningGains(Device->Dry, coeffs, Slot->Params.Gain, state->Gain[1]); - phase = Slot->Params.EffectProps.Chorus.Phase; - rate = Slot->Params.EffectProps.Chorus.Rate; + phase = props->Chorus.Phase; + rate = props->Chorus.Rate; if(!(rate > 0.0f)) { state->lfo_scale = 0.0f; diff --git a/Alc/effects/compressor.c b/Alc/effects/compressor.c index c501b3ba..6329d3f1 100644 --- a/Alc/effects/compressor.c +++ b/Alc/effects/compressor.c @@ -56,12 +56,12 @@ static ALboolean ALcompressorState_deviceUpdate(ALcompressorState *state, ALCdev return AL_TRUE; } -static ALvoid ALcompressorState_update(ALcompressorState *state, const ALCdevice *device, const ALeffectslot *slot) +static ALvoid ALcompressorState_update(ALcompressorState *state, const ALCdevice *device, const ALeffectslot *slot, const ALeffectProps *props) { aluMatrixf matrix; ALuint i; - state->Enabled = slot->Params.EffectProps.Compressor.OnOff; + state->Enabled = props->Compressor.OnOff; aluMatrixfSet(&matrix, 1.0f, 0.0f, 0.0f, 0.0f, diff --git a/Alc/effects/dedicated.c b/Alc/effects/dedicated.c index 34e5ed80..98dd560b 100644 --- a/Alc/effects/dedicated.c +++ b/Alc/effects/dedicated.c @@ -46,7 +46,7 @@ static ALboolean ALdedicatedState_deviceUpdate(ALdedicatedState *UNUSED(state), return AL_TRUE; } -static ALvoid ALdedicatedState_update(ALdedicatedState *state, const ALCdevice *device, const ALeffectslot *Slot) +static ALvoid ALdedicatedState_update(ALdedicatedState *state, const ALCdevice *device, const ALeffectslot *Slot, const ALeffectProps *props) { ALfloat Gain; ALuint i; @@ -54,7 +54,7 @@ static ALvoid ALdedicatedState_update(ALdedicatedState *state, const ALCdevice * for(i = 0;i < MAX_OUTPUT_CHANNELS;i++) state->gains[i] = 0.0f; - Gain = Slot->Params.Gain * Slot->Params.EffectProps.Dedicated.Gain; + Gain = Slot->Params.Gain * props->Dedicated.Gain; if(Slot->Params.EffectType == AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT) { int idx; diff --git a/Alc/effects/distortion.c b/Alc/effects/distortion.c index 534a817c..deec6092 100644 --- a/Alc/effects/distortion.c +++ b/Alc/effects/distortion.c @@ -53,7 +53,7 @@ static ALboolean ALdistortionState_deviceUpdate(ALdistortionState *UNUSED(state) return AL_TRUE; } -static ALvoid ALdistortionState_update(ALdistortionState *state, const ALCdevice *Device, const ALeffectslot *Slot) +static ALvoid ALdistortionState_update(ALdistortionState *state, const ALCdevice *Device, const ALeffectslot *Slot, const ALeffectProps *props) { ALfloat frequency = (ALfloat)Device->Frequency; ALfloat bandwidth; @@ -61,15 +61,15 @@ static ALvoid ALdistortionState_update(ALdistortionState *state, const ALCdevice ALfloat edge; /* Store distorted signal attenuation settings */ - state->attenuation = Slot->Params.EffectProps.Distortion.Gain; + state->attenuation = props->Distortion.Gain; /* Store waveshaper edge settings */ - edge = sinf(Slot->Params.EffectProps.Distortion.Edge * (F_PI_2)); + edge = sinf(props->Distortion.Edge * (F_PI_2)); edge = minf(edge, 0.99f); state->edge_coeff = 2.0f * edge / (1.0f-edge); /* Lowpass filter */ - cutoff = Slot->Params.EffectProps.Distortion.LowpassCutoff; + cutoff = props->Distortion.LowpassCutoff; /* Bandwidth value is constant in octaves */ bandwidth = (cutoff / 2.0f) / (cutoff * 0.67f); ALfilterState_setParams(&state->lowpass, ALfilterType_LowPass, 1.0f, @@ -77,9 +77,9 @@ static ALvoid ALdistortionState_update(ALdistortionState *state, const ALCdevice ); /* Bandpass filter */ - cutoff = Slot->Params.EffectProps.Distortion.EQCenter; + cutoff = props->Distortion.EQCenter; /* Convert bandwidth in Hz to octaves */ - bandwidth = Slot->Params.EffectProps.Distortion.EQBandwidth / (cutoff * 0.67f); + bandwidth = props->Distortion.EQBandwidth / (cutoff * 0.67f); ALfilterState_setParams(&state->bandpass, ALfilterType_BandPass, 1.0f, cutoff / (frequency*4.0f), calc_rcpQ_from_bandwidth(cutoff / (frequency*4.0f), bandwidth) ); diff --git a/Alc/effects/echo.c b/Alc/effects/echo.c index eea86f15..0632a44d 100644 --- a/Alc/effects/echo.c +++ b/Alc/effects/echo.c @@ -82,17 +82,17 @@ static ALboolean ALechoState_deviceUpdate(ALechoState *state, ALCdevice *Device) return AL_TRUE; } -static ALvoid ALechoState_update(ALechoState *state, const ALCdevice *Device, const ALeffectslot *Slot) +static ALvoid ALechoState_update(ALechoState *state, const ALCdevice *Device, const ALeffectslot *Slot, const ALeffectProps *props) { ALuint frequency = Device->Frequency; ALfloat coeffs[MAX_AMBI_COEFFS]; ALfloat gain, lrpan, spread; - 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[0].delay = fastf2u(props->Echo.Delay * frequency) + 1; + state->Tap[1].delay = fastf2u(props->Echo.LRDelay * frequency); state->Tap[1].delay += state->Tap[0].delay; - spread = Slot->Params.EffectProps.Echo.Spread; + spread = props->Echo.Spread; if(spread < 0.0f) lrpan = -1.0f; else lrpan = 1.0f; /* Convert echo spread (where 0 = omni, +/-1 = directional) to coverage @@ -100,9 +100,9 @@ static ALvoid ALechoState_update(ALechoState *state, const ALCdevice *Device, co */ spread = asinf(1.0f - fabsf(spread))*4.0f; - state->FeedGain = Slot->Params.EffectProps.Echo.Feedback; + state->FeedGain = props->Echo.Feedback; - gain = minf(1.0f - Slot->Params.EffectProps.Echo.Damping, 0.01f); + gain = minf(1.0f - props->Echo.Damping, 0.01f); ALfilterState_setParams(&state->Filter, ALfilterType_HighShelf, gain, LOWPASSFREQREF/frequency, calc_rcpQ_from_slope(gain, 0.75f)); diff --git a/Alc/effects/equalizer.c b/Alc/effects/equalizer.c index 94ee1853..25e36724 100644 --- a/Alc/effects/equalizer.c +++ b/Alc/effects/equalizer.c @@ -97,7 +97,7 @@ static ALboolean ALequalizerState_deviceUpdate(ALequalizerState *UNUSED(state), return AL_TRUE; } -static ALvoid ALequalizerState_update(ALequalizerState *state, const ALCdevice *device, const ALeffectslot *slot) +static ALvoid ALequalizerState_update(ALequalizerState *state, const ALCdevice *device, const ALeffectslot *slot, const ALeffectProps *props) { ALfloat frequency = (ALfloat)device->Frequency; ALfloat gain, freq_mult; @@ -121,8 +121,8 @@ static ALvoid ALequalizerState_update(ALequalizerState *state, const ALCdevice * * filters' gain is for the reference frequency, which is the centerpoint * of the transition band. */ - gain = sqrtf(slot->Params.EffectProps.Equalizer.LowGain); - freq_mult = slot->Params.EffectProps.Equalizer.LowCutoff/frequency; + gain = sqrtf(props->Equalizer.LowGain); + freq_mult = props->Equalizer.LowCutoff/frequency; ALfilterState_setParams(&state->filter[0][0], ALfilterType_LowShelf, gain, freq_mult, calc_rcpQ_from_slope(gain, 0.75f) ); @@ -137,11 +137,11 @@ static ALvoid ALequalizerState_update(ALequalizerState *state, const ALCdevice * state->filter[0][i].process = state->filter[0][0].process; } - gain = slot->Params.EffectProps.Equalizer.Mid1Gain; - freq_mult = slot->Params.EffectProps.Equalizer.Mid1Center/frequency; + gain = props->Equalizer.Mid1Gain; + freq_mult = props->Equalizer.Mid1Center/frequency; ALfilterState_setParams(&state->filter[1][0], ALfilterType_Peaking, gain, freq_mult, calc_rcpQ_from_bandwidth( - freq_mult, slot->Params.EffectProps.Equalizer.Mid1Width + freq_mult, props->Equalizer.Mid1Width ) ); for(i = 1;i < MAX_EFFECT_CHANNELS;i++) @@ -154,11 +154,11 @@ static ALvoid ALequalizerState_update(ALequalizerState *state, const ALCdevice * state->filter[1][i].process = state->filter[1][0].process; } - gain = slot->Params.EffectProps.Equalizer.Mid2Gain; - freq_mult = slot->Params.EffectProps.Equalizer.Mid2Center/frequency; + gain = props->Equalizer.Mid2Gain; + freq_mult = props->Equalizer.Mid2Center/frequency; ALfilterState_setParams(&state->filter[2][0], ALfilterType_Peaking, gain, freq_mult, calc_rcpQ_from_bandwidth( - freq_mult, slot->Params.EffectProps.Equalizer.Mid2Width + freq_mult, props->Equalizer.Mid2Width ) ); for(i = 1;i < MAX_EFFECT_CHANNELS;i++) @@ -171,8 +171,8 @@ static ALvoid ALequalizerState_update(ALequalizerState *state, const ALCdevice * state->filter[2][i].process = state->filter[2][0].process; } - gain = sqrtf(slot->Params.EffectProps.Equalizer.HighGain); - freq_mult = slot->Params.EffectProps.Equalizer.HighCutoff/frequency; + gain = sqrtf(props->Equalizer.HighGain); + freq_mult = props->Equalizer.HighCutoff/frequency; ALfilterState_setParams(&state->filter[3][0], ALfilterType_HighShelf, gain, freq_mult, calc_rcpQ_from_slope(gain, 0.75f) ); diff --git a/Alc/effects/flanger.c b/Alc/effects/flanger.c index 966622e6..7b55977e 100644 --- a/Alc/effects/flanger.c +++ b/Alc/effects/flanger.c @@ -92,14 +92,14 @@ static ALboolean ALflangerState_deviceUpdate(ALflangerState *state, ALCdevice *D return AL_TRUE; } -static ALvoid ALflangerState_update(ALflangerState *state, const ALCdevice *Device, const ALeffectslot *Slot) +static ALvoid ALflangerState_update(ALflangerState *state, const ALCdevice *Device, const ALeffectslot *Slot, const ALeffectProps *props) { ALfloat frequency = (ALfloat)Device->Frequency; ALfloat coeffs[MAX_AMBI_COEFFS]; ALfloat rate; ALint phase; - switch(Slot->Params.EffectProps.Flanger.Waveform) + switch(props->Flanger.Waveform) { case AL_FLANGER_WAVEFORM_TRIANGLE: state->waveform = FWF_Triangle; @@ -108,9 +108,9 @@ static ALvoid ALflangerState_update(ALflangerState *state, const ALCdevice *Devi state->waveform = FWF_Sinusoid; break; } - state->depth = Slot->Params.EffectProps.Flanger.Depth; - state->feedback = Slot->Params.EffectProps.Flanger.Feedback; - state->delay = fastf2i(Slot->Params.EffectProps.Flanger.Delay * frequency); + state->depth = props->Flanger.Depth; + state->feedback = props->Flanger.Feedback; + state->delay = fastf2i(props->Flanger.Delay * frequency); /* Gains for left and right sides */ CalcXYZCoeffs(-1.0f, 0.0f, 0.0f, 0.0f, coeffs); @@ -118,8 +118,8 @@ static ALvoid ALflangerState_update(ALflangerState *state, const ALCdevice *Devi CalcXYZCoeffs( 1.0f, 0.0f, 0.0f, 0.0f, coeffs); ComputePanningGains(Device->Dry, coeffs, Slot->Params.Gain, state->Gain[1]); - phase = Slot->Params.EffectProps.Flanger.Phase; - rate = Slot->Params.EffectProps.Flanger.Rate; + phase = props->Flanger.Phase; + rate = props->Flanger.Rate; if(!(rate > 0.0f)) { state->lfo_scale = 0.0f; diff --git a/Alc/effects/modulator.c b/Alc/effects/modulator.c index 5a96bb9d..0b0971b2 100644 --- a/Alc/effects/modulator.c +++ b/Alc/effects/modulator.c @@ -92,25 +92,25 @@ static ALboolean ALmodulatorState_deviceUpdate(ALmodulatorState *UNUSED(state), return AL_TRUE; } -static ALvoid ALmodulatorState_update(ALmodulatorState *state, const ALCdevice *Device, const ALeffectslot *Slot) +static ALvoid ALmodulatorState_update(ALmodulatorState *state, const ALCdevice *Device, const ALeffectslot *Slot, const ALeffectProps *props) { aluMatrixf matrix; ALfloat cw, a; ALuint i; - if(Slot->Params.EffectProps.Modulator.Waveform == AL_RING_MODULATOR_SINUSOID) + if(props->Modulator.Waveform == AL_RING_MODULATOR_SINUSOID) state->Process = ModulateSin; - else if(Slot->Params.EffectProps.Modulator.Waveform == AL_RING_MODULATOR_SAWTOOTH) + else if(props->Modulator.Waveform == AL_RING_MODULATOR_SAWTOOTH) state->Process = ModulateSaw; else /*if(Slot->Params.EffectProps.Modulator.Waveform == AL_RING_MODULATOR_SQUARE)*/ state->Process = ModulateSquare; - state->step = fastf2u(Slot->Params.EffectProps.Modulator.Frequency*WAVEFORM_FRACONE / + state->step = fastf2u(props->Modulator.Frequency*WAVEFORM_FRACONE / Device->Frequency); if(state->step == 0) state->step = 1; /* Custom filter coeffs, which match the old version instead of a low-shelf. */ - cw = cosf(F_TAU * Slot->Params.EffectProps.Modulator.HighPassCutoff / Device->Frequency); + cw = cosf(F_TAU * props->Modulator.HighPassCutoff / Device->Frequency); a = (2.0f-cw) - sqrtf(powf(2.0f-cw, 2.0f) - 1.0f); for(i = 0;i < MAX_EFFECT_CHANNELS;i++) diff --git a/Alc/effects/null.c b/Alc/effects/null.c index b90f75c9..a135b194 100644 --- a/Alc/effects/null.c +++ b/Alc/effects/null.c @@ -35,7 +35,7 @@ static ALboolean ALnullState_deviceUpdate(ALnullState* UNUSED(state), ALCdevice* /* This updates the effect state. This is called any time the effect is * (re)loaded into a slot. */ -static ALvoid ALnullState_update(ALnullState* UNUSED(state), const ALCdevice* UNUSED(device), const ALeffectslot* UNUSED(slot)) +static ALvoid ALnullState_update(ALnullState* UNUSED(state), const ALCdevice* UNUSED(device), const ALeffectslot* UNUSED(slot), const ALeffectProps* UNUSED(props)) { } diff --git a/Alc/effects/reverb.c b/Alc/effects/reverb.c index 0f851295..916469a8 100644 --- a/Alc/effects/reverb.c +++ b/Alc/effects/reverb.c @@ -173,7 +173,7 @@ static ALvoid ALreverbState_Destruct(ALreverbState *State) } static ALboolean ALreverbState_deviceUpdate(ALreverbState *State, ALCdevice *Device); -static ALvoid ALreverbState_update(ALreverbState *State, const ALCdevice *Device, const ALeffectslot *Slot); +static ALvoid ALreverbState_update(ALreverbState *State, const ALCdevice *Device, const ALeffectslot *Slot, const ALeffectProps *props); static ALvoid ALreverbState_processStandard(ALreverbState *State, ALuint SamplesToDo, const ALfloat *restrict SamplesIn, ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels); static ALvoid ALreverbState_processEax(ALreverbState *State, ALuint SamplesToDo, const ALfloat *restrict SamplesIn, ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels); static ALvoid ALreverbState_process(ALreverbState *State, ALuint SamplesToDo, const ALfloat (*restrict SamplesIn)[BUFFERSIZE], ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels); @@ -893,9 +893,8 @@ static ALvoid Update3DPanning(const ALCdevice *Device, const ALfloat *Reflection } } -static ALvoid ALreverbState_update(ALreverbState *State, const ALCdevice *Device, const ALeffectslot *Slot) +static ALvoid ALreverbState_update(ALreverbState *State, const ALCdevice *Device, const ALeffectslot *Slot, const ALeffectProps *props) { - const ALeffectProps *props = &Slot->Params.EffectProps; ALuint frequency = Device->Frequency; ALfloat lfscale, hfscale, hfRatio; ALfloat gain, gainlf, gainhf; diff --git a/OpenAL32/Include/alAuxEffectSlot.h b/OpenAL32/Include/alAuxEffectSlot.h index 85827746..28c0b46f 100644 --- a/OpenAL32/Include/alAuxEffectSlot.h +++ b/OpenAL32/Include/alAuxEffectSlot.h @@ -26,7 +26,7 @@ struct ALeffectStateVtable { void (*const Destruct)(ALeffectState *state); ALboolean (*const deviceUpdate)(ALeffectState *state, ALCdevice *device); - void (*const update)(ALeffectState *state, const ALCdevice *device, const struct ALeffectslot *slot); + void (*const update)(ALeffectState *state, const ALCdevice *device, const struct ALeffectslot *slot, const union ALeffectProps *props); void (*const process)(ALeffectState *state, ALuint samplesToDo, const ALfloat (*restrict samplesIn)[BUFFERSIZE], ALfloat (*restrict samplesOut)[BUFFERSIZE], ALuint numChannels); void (*const Delete)(void *ptr); @@ -35,7 +35,7 @@ struct ALeffectStateVtable { #define DEFINE_ALEFFECTSTATE_VTABLE(T) \ DECLARE_THUNK(T, ALeffectState, void, Destruct) \ DECLARE_THUNK1(T, ALeffectState, ALboolean, deviceUpdate, ALCdevice*) \ -DECLARE_THUNK2(T, ALeffectState, void, update, const ALCdevice*, const ALeffectslot*) \ +DECLARE_THUNK3(T, ALeffectState, void, update, const ALCdevice*, const ALeffectslot*, const ALeffectProps*) \ DECLARE_THUNK4(T, ALeffectState, void, process, ALuint, const ALfloatBUFFERSIZE*restrict, ALfloatBUFFERSIZE*restrict, ALuint) \ static void T##_ALeffectState_Delete(void *ptr) \ { return T##_Delete(STATIC_UPCAST(T, ALeffectState, (ALeffectState*)ptr)); } \ @@ -108,7 +108,6 @@ typedef struct ALeffectslot { ALboolean AuxSendAuto; ALenum EffectType; - ALeffectProps EffectProps; ALeffectState *EffectState; ALfloat RoomRolloff; /* Added to the source's room rolloff, not multiplied. */ diff --git a/OpenAL32/Include/alListener.h b/OpenAL32/Include/alListener.h index 75a3fb46..dee66720 100644 --- a/OpenAL32/Include/alListener.h +++ b/OpenAL32/Include/alListener.h @@ -20,6 +20,9 @@ struct ALlistenerProps { ATOMIC(ALfloat) DopplerVelocity; ATOMIC(ALfloat) SpeedOfSound; + ATOMIC(ALboolean) SourceDistanceModel; + ATOMIC(enum DistanceModel) DistanceModel; + ATOMIC(struct ALlistenerProps*) next; }; @@ -49,6 +52,9 @@ typedef struct ALlistener { ALfloat DopplerFactor; ALfloat SpeedOfSound; + + ALboolean SourceDistanceModel; + enum DistanceModel DistanceModel; } Params; } ALlistener; diff --git a/OpenAL32/alListener.c b/OpenAL32/alListener.c index b215f678..1c40c399 100644 --- a/OpenAL32/alListener.c +++ b/OpenAL32/alListener.c @@ -490,6 +490,10 @@ void UpdateListenerProps(ALCcontext *context) ATOMIC_STORE(&props->DopplerVelocity, context->DopplerVelocity, almemory_order_relaxed); ATOMIC_STORE(&props->SpeedOfSound, context->SpeedOfSound, almemory_order_relaxed); + ATOMIC_STORE(&props->SourceDistanceModel, context->SourceDistanceModel, + almemory_order_relaxed); + ATOMIC_STORE(&props->DistanceModel, context->DistanceModel, almemory_order_relaxed); + /* Set the new container for updating internal parameters. */ props = ATOMIC_EXCHANGE(struct ALlistenerProps*, &listener->Update, props, almemory_order_acq_rel); if(props) diff --git a/OpenAL32/alState.c b/OpenAL32/alState.c index 899dacd4..c0c2ca82 100644 --- a/OpenAL32/alState.c +++ b/OpenAL32/alState.c @@ -52,6 +52,7 @@ AL_API ALvoid AL_APIENTRY alEnable(ALenum capability) context = GetContextRef(); if(!context) return; + WriteLock(&context->PropLock); switch(capability) { case AL_SOURCE_DISTANCE_MODEL: @@ -61,12 +62,10 @@ AL_API ALvoid AL_APIENTRY alEnable(ALenum capability) default: SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done); } - /* HACK: Force sources to update by doing a listener update */ - ReadLock(&context->PropLock); UpdateListenerProps(context); - ReadUnlock(&context->PropLock); done: + WriteUnlock(&context->PropLock); ALCcontext_DecRef(context); } @@ -77,6 +76,7 @@ AL_API ALvoid AL_APIENTRY alDisable(ALenum capability) context = GetContextRef(); if(!context) return; + WriteLock(&context->PropLock); switch(capability) { case AL_SOURCE_DISTANCE_MODEL: @@ -86,12 +86,10 @@ AL_API ALvoid AL_APIENTRY alDisable(ALenum capability) default: SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done); } - /* HACK: Force sources to update by doing a listener update */ - ReadLock(&context->PropLock); UpdateListenerProps(context); - ReadUnlock(&context->PropLock); done: + WriteUnlock(&context->PropLock); ALCcontext_DecRef(context); } |