From 530002e168c907bd3468cd0fefaec2565e248bbd Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Mon, 7 Aug 2017 01:38:26 -0700 Subject: Avoid re-selecting the direct HRTF mix function --- Alc/ALc.c | 1 + Alc/ALu.c | 37 ++++++++++++++++++++++--------------- OpenAL32/Include/alu.h | 2 ++ 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/Alc/ALc.c b/Alc/ALc.c index b367dd1d..a1c17087 100644 --- a/Alc/ALc.c +++ b/Alc/ALc.c @@ -1001,6 +1001,7 @@ static void alc_initconfig(void) #endif ConfigValueInt(NULL, NULL, "rt-prio", &RTPrioLevel); + aluInit(); aluInitMixer(); str = getenv("ALSOFT_TRAP_ERROR"); diff --git a/Alc/ALu.c b/Alc/ALu.c index 5230d4c6..8055ac91 100644 --- a/Alc/ALu.c +++ b/Alc/ALu.c @@ -43,18 +43,6 @@ #include "backends/base.h" -struct ChanMap { - enum Channel channel; - ALfloat angle; - ALfloat elevation; -}; - -/* Cone scalar */ -ALfloat ConeScale = 1.0f; - -/* Localized Z scalar for mono sources */ -ALfloat ZScale = 1.0f; - extern inline ALfloat minf(ALfloat a, ALfloat b); extern inline ALfloat maxf(ALfloat a, ALfloat b); extern inline ALfloat clampf(ALfloat val, ALfloat min, ALfloat max); @@ -92,6 +80,13 @@ extern inline void aluMatrixfSet(aluMatrixf *matrix, ALfloat m20, ALfloat m21, ALfloat m22, ALfloat m23, ALfloat m30, ALfloat m31, ALfloat m32, ALfloat m33); + +/* Cone scalar */ +ALfloat ConeScale = 1.0f; + +/* Localized Z scalar for mono sources */ +ALfloat ZScale = 1.0f; + const aluMatrixf IdentityMatrixf = {{ { 1.0f, 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f, 0.0f }, @@ -100,6 +95,15 @@ const aluMatrixf IdentityMatrixf = {{ }}; +struct ChanMap { + enum Channel channel; + ALfloat angle; + ALfloat elevation; +}; + +static HrtfDirectMixerFunc MixDirectHrtf = MixDirectHrtf_C; + + void DeinitVoice(ALvoice *voice) { struct ALvoiceProps *props; @@ -206,6 +210,11 @@ static aluVector aluMatrixfVector(const aluMatrixf *mtx, const aluVector *vec) } +void aluInit(void) +{ + MixDirectHrtf = SelectHrtfMixer(); +} + /* Prepares the interpolator for a given rate (determined by increment). A * result of AL_FALSE indicates that the filter output will completely cut * the input signal. @@ -1729,7 +1738,6 @@ void aluMixData(ALCdevice *device, ALvoid *OutBuffer, ALsizei NumSamples) if(device->HrtfHandle) { - HrtfDirectMixerFunc HrtfMix; DirectHrtfState *state; int lidx, ridx; @@ -1743,11 +1751,10 @@ void aluMixData(ALCdevice *device, ALvoid *OutBuffer, ALsizei NumSamples) ridx = GetChannelIdxByName(device->RealOut, FrontRight); assert(lidx != -1 && ridx != -1); - HrtfMix = SelectHrtfMixer(); state = device->Hrtf; for(c = 0;c < device->Dry.NumChannels;c++) { - HrtfMix(device->RealOut.Buffer[lidx], device->RealOut.Buffer[ridx], + MixDirectHrtf(device->RealOut.Buffer[lidx], device->RealOut.Buffer[ridx], device->Dry.Buffer[c], state->Offset, state->IrSize, SAFE_CONST(ALfloat2*,state->Chan[c].Coeffs), state->Chan[c].Values, SamplesToDo diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h index 794bdec9..b62bb024 100644 --- a/OpenAL32/Include/alu.h +++ b/OpenAL32/Include/alu.h @@ -403,6 +403,8 @@ enum HrtfRequestMode { Hrtf_Disable = 2, }; +void aluInit(void); + void aluInitMixer(void); MixerFunc SelectMixer(void); -- cgit v1.2.3