From 5a50c46c22e7e6c5f119613584d826bc7b7b4a61 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 14 Feb 2017 19:59:39 -0800 Subject: Make ALsourceProps' Send array dynamically sized ALsourceProps' Send[] array is placed at the end of the struct, and given an indeterminate size. Extra space is allocated at the end of each struct given the number of auxiliary sends set for the device. --- Alc/ALu.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'Alc/ALu.c') diff --git a/Alc/ALu.c b/Alc/ALu.c index 31dd6271..3cb02f84 100644 --- a/Alc/ALu.c +++ b/Alc/ALu.c @@ -807,14 +807,6 @@ static void CalcAttnSourceParams(ALvoice *voice, const struct ALsourceProps *pro ALint NumSends; ALint i; - DryGainHF = 1.0f; - DryGainLF = 1.0f; - for(i = 0;i < MAX_SENDS;i++) - { - WetGainHF[i] = 1.0f; - WetGainLF[i] = 1.0f; - } - /* Get context/device properties */ DopplerFactor = Listener->Params.DopplerFactor; SpeedOfSound = Listener->Params.SpeedOfSound; @@ -989,8 +981,14 @@ static void CalcAttnSourceParams(ALvoice *voice, const struct ALsourceProps *pro /* Source Gain + Attenuation */ DryGain = SourceVolume * Attenuation; + DryGainHF = 1.0f; + DryGainLF = 1.0f; for(i = 0;i < NumSends;i++) + { WetGain[i] = SourceVolume * RoomAttenuation[i]; + WetGainHF[i] = 1.0f; + WetGainLF[i] = 1.0f; + } /* Distance-based air absorption */ if(AirAbsorptionFactor > 0.0f && ClampedDist > MinDist) @@ -1284,7 +1282,9 @@ static void CalcSourceParams(ALvoice *voice, ALCcontext *context, ALboolean forc if(props) { - voice->Props = *props; + memcpy(voice->Props, props, + offsetof(struct ALsourceProps, Send[context->Device->NumAuxSends]) + ); ATOMIC_REPLACE_HEAD(struct ALsourceProps*, &source->FreeList, props); } @@ -1296,9 +1296,9 @@ static void CalcSourceParams(ALvoice *voice, ALCcontext *context, ALboolean forc if((buffer=BufferListItem->buffer) != NULL) { if(buffer->FmtChannels == FmtMono) - CalcAttnSourceParams(voice, &voice->Props, buffer, context); + CalcAttnSourceParams(voice, voice->Props, buffer, context); else - CalcNonAttnSourceParams(voice, &voice->Props, buffer, context); + CalcNonAttnSourceParams(voice, voice->Props, buffer, context); break; } BufferListItem = BufferListItem->next; -- cgit v1.2.3