From 10a9bc62bf859ad3b97be9bda36fb0a737175774 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 16 Jan 2008 12:43:25 -0800 Subject: [PATCH] Store a reference to the effect slot in a source's send, not a copy --- Alc/ALu.c | 24 +++++++++++++----------- OpenAL32/Include/alSource.h | 2 +- OpenAL32/alSource.c | 8 +------- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/Alc/ALu.c b/Alc/ALu.c index dda46631..0c02b778 100644 --- a/Alc/ALu.c +++ b/Alc/ALu.c @@ -259,7 +259,7 @@ static ALvoid CalcSourceParams(ALCcontext *ALContext, ALsource *ALSource, ALfloat *pitch, ALfloat *drygainhf, ALfloat *wetgainhf) { - ALfloat InnerAngle,OuterAngle,Angle,Distance,DryMix,WetMix; + ALfloat InnerAngle,OuterAngle,Angle,Distance,DryMix,WetMix=0.0f; ALfloat Direction[3],Position[3],SourceToListener[3]; ALfloat MinVolume,MaxVolume,MinDist,MaxDist,Rolloff,OuterGainHF; ALfloat ConeVolume,SourceVolume,PanningFB,PanningLR,ListenerGain; @@ -368,9 +368,10 @@ static ALvoid CalcSourceParams(ALCcontext *ALContext, ALsource *ALSource, // Source Gain + Attenuation DryMix = SourceVolume * flAttenuation; - WetMix = SourceVolume * ((ALSource->WetGainAuto && - ALSource->Send[0].Slot.AuxSendAuto) ? - RoomAttenuation : 1.0f); + if(ALSource->Send[0].Slot) + WetMix = SourceVolume * ((ALSource->WetGainAuto && + ALSource->Send[0].Slot->AuxSendAuto) ? + RoomAttenuation : 1.0f); // Clamp to Min/Max Gain DryMix = __min(DryMix,MaxVolume); @@ -470,7 +471,8 @@ static ALvoid CalcSourceParams(ALCcontext *ALContext, ALsource *ALSource, DryGainHF *= pow(ALSource->AirAbsorptionFactor * AIRABSORBGAINHF, Distance * MetersPerUnit); - WetMix *= ALSource->Send[0].Slot.Gain; + if(ALSource->Send[0].Slot) + WetMix *= ALSource->Send[0].Slot->Gain; //7. Convert normalized position into pannings, then into channel volumes aluNormalize(Position); @@ -479,7 +481,7 @@ static ALvoid CalcSourceParams(ALCcontext *ALContext, ALsource *ALSource, case 1: drysend[FRONT_LEFT] = ConeVolume * ListenerGain * DryMix * aluSqrt(1.0f); //Direct drysend[FRONT_RIGHT] = ConeVolume * ListenerGain * DryMix * aluSqrt(1.0f); //Direct - if(ALSource->Send[0].Slot.effectslot) + if(ALSource->Send[0].Slot) { wetsend[FRONT_LEFT] = ListenerGain * WetMix * aluSqrt(1.0f); //Room wetsend[FRONT_RIGHT] = ListenerGain * WetMix * aluSqrt(1.0f); //Room @@ -495,7 +497,7 @@ static ALvoid CalcSourceParams(ALCcontext *ALContext, ALsource *ALSource, PanningLR = 0.5f + 0.5f*Position[0]; drysend[FRONT_LEFT] = ConeVolume * ListenerGain * DryMix * aluSqrt(1.0f-PanningLR); //L Direct drysend[FRONT_RIGHT] = ConeVolume * ListenerGain * DryMix * aluSqrt( PanningLR); //R Direct - if(ALSource->Send[0].Slot.effectslot) + if(ALSource->Send[0].Slot) { wetsend[FRONT_LEFT] = ListenerGain * WetMix * aluSqrt(1.0f-PanningLR); //L Room wetsend[FRONT_RIGHT] = ListenerGain * WetMix * aluSqrt( PanningLR); //R Room @@ -521,7 +523,7 @@ static ALvoid CalcSourceParams(ALCcontext *ALContext, ALsource *ALSource, drysend[FRONT_RIGHT] = ConeVolume * ListenerGain * DryMix * aluSqrt(( PanningLR)*(1.0f-PanningFB)); drysend[BACK_LEFT] = ConeVolume * ListenerGain * DryMix * aluSqrt((1.0f-PanningLR)*( PanningFB)); drysend[BACK_RIGHT] = ConeVolume * ListenerGain * DryMix * aluSqrt(( PanningLR)*( PanningFB)); - if(ALSource->Send[0].Slot.effectslot) + if(ALSource->Send[0].Slot) { wetsend[FRONT_LEFT] = ListenerGain * WetMix * aluSqrt((1.0f-PanningLR)*(1.0f-PanningFB)); wetsend[FRONT_RIGHT] = ListenerGain * WetMix * aluSqrt(( PanningLR)*(1.0f-PanningFB)); @@ -553,7 +555,7 @@ static ALvoid CalcSourceParams(ALCcontext *ALContext, ALsource *ALSource, drysend[SIDE_RIGHT] = ConeVolume * ListenerGain * DryMix * aluSqrt(( PanningLR)*( PanningFB)); drysend[FRONT_LEFT] = 0.0f; drysend[FRONT_RIGHT] = 0.0f; - if(ALSource->Send[0].Slot.effectslot) + if(ALSource->Send[0].Slot) { wetsend[BACK_LEFT] = ListenerGain * WetMix * aluSqrt((1.0f-PanningLR)*(1.0f-PanningFB)); wetsend[BACK_RIGHT] = ListenerGain * WetMix * aluSqrt(( PanningLR)*(1.0f-PanningFB)); @@ -581,7 +583,7 @@ static ALvoid CalcSourceParams(ALCcontext *ALContext, ALsource *ALSource, drysend[SIDE_RIGHT] = ConeVolume * ListenerGain * DryMix * aluSqrt(( PanningLR)*( PanningFB)); drysend[BACK_LEFT] = 0.0f; drysend[BACK_RIGHT] = 0.0f; - if(ALSource->Send[0].Slot.effectslot) + if(ALSource->Send[0].Slot) { wetsend[FRONT_LEFT] = ListenerGain * WetMix * aluSqrt((1.0f-PanningLR)*(1.0f-PanningFB)); wetsend[FRONT_RIGHT] = ListenerGain * WetMix * aluSqrt(( PanningLR)*(1.0f-PanningFB)); @@ -622,7 +624,7 @@ static ALvoid CalcSourceParams(ALCcontext *ALContext, ALsource *ALSource, drysend[BACK_RIGHT] = SourceVolume * 1.0f * ListenerGain; drysend[CENTER] = SourceVolume * 1.0f * ListenerGain; drysend[LFE] = SourceVolume * 1.0f * ListenerGain; - if(ALSource->Send[0].Slot.effectslot) + if(ALSource->Send[0].Slot) { wetsend[FRONT_LEFT] = SourceVolume * 0.0f * ListenerGain; wetsend[FRONT_RIGHT] = SourceVolume * 0.0f * ListenerGain; diff --git a/OpenAL32/Include/alSource.h b/OpenAL32/Include/alSource.h index 09651fa5..f6a4619a 100644 --- a/OpenAL32/Include/alSource.h +++ b/OpenAL32/Include/alSource.h @@ -67,7 +67,7 @@ typedef struct ALsource ALfilter DirectFilter; struct { - ALeffectslot Slot; + ALeffectslot *Slot; ALfilter WetFilter; } Send[MAX_SENDS]; diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c index 85db43c2..69da0df4 100644 --- a/OpenAL32/alSource.c +++ b/OpenAL32/alSource.c @@ -745,13 +745,7 @@ ALAPI void ALAPIENTRY alSource3i(ALuint source, ALenum eParam, ALint lValue1, AL ALeffectslot *ALEffectSlot = (ALeffectslot*)ALTHUNK_LOOKUPENTRY(lValue1); ALfilter *ALFilter = (ALfilter*)ALTHUNK_LOOKUPENTRY(lValue3); - if(!ALEffectSlot) - { - /* Disable slot */ - pSource->Send[lValue2].Slot.effectslot = 0; - } - else - memcpy(&pSource->Send[lValue2].Slot, ALEffectSlot, sizeof(*ALEffectSlot)); + pSource->Send[lValue2].Slot = ALEffectSlot; if(!ALFilter) {