From 7b782f6afa0d69459868c4bf954c1d42f0de08a7 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Mon, 19 May 2014 01:54:52 -0700 Subject: Return a sample pointer from DoFilters This allows us to avoid copying samples when no filtering is needed. Doing the same for resampling would require another temporary buffer in the device. --- Alc/mixer.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'Alc/mixer.c') diff --git a/Alc/mixer.c b/Alc/mixer.c index 7b0b9d30..04efcf44 100644 --- a/Alc/mixer.c +++ b/Alc/mixer.c @@ -84,23 +84,22 @@ static void SilenceData(ALfloat *dst, ALuint samples) } -static void DoFilters(ALfilterState *lpfilter, ALfilterState *hpfilter, - ALfloat *restrict dst, const ALfloat *restrict src, - ALuint numsamples, enum ActiveFilters type) +static const ALfloat *DoFilters(ALfilterState *lpfilter, ALfilterState *hpfilter, + ALfloat *restrict dst, const ALfloat *restrict src, + ALuint numsamples, enum ActiveFilters type) { ALuint i; switch(type) { case AF_None: - memcpy(dst, src, numsamples * sizeof(ALfloat)); break; case AF_LowPass: ALfilterState_process(lpfilter, dst, src, numsamples); - break; + return dst; case AF_HighPass: ALfilterState_process(hpfilter, dst, src, numsamples); - break; + return dst; case AF_BandPass: for(i = 0;i < numsamples;) @@ -112,8 +111,9 @@ static void DoFilters(ALfilterState *lpfilter, ALfilterState *hpfilter, ALfilterState_process(hpfilter, dst, temp, todo); i += todo; } - break; + return dst; } + return src; } @@ -346,11 +346,13 @@ ALvoid MixSource(ALactivesource *src, ALCdevice *Device, ALuint SamplesToDo) { DirectParams *parms = &src->Direct; + const ALfloat *samples; - DoFilters(&parms->LpFilter[chan], &parms->HpFilter[chan], SrcData, - ResampledData, DstBufferSize, parms->Filters[chan]); + samples = DoFilters(&parms->LpFilter[chan], &parms->HpFilter[chan], + SrcData, ResampledData, DstBufferSize, + parms->Filters[chan]); if(!src->IsHrtf) - src->Dry.Mix(parms->OutBuffer, SrcData, &parms->Mix.Gains[chan], + src->Dry.Mix(parms->OutBuffer, samples, &parms->Mix.Gains[chan], maxu(parms->Counter, OutPos) - OutPos, OutPos, DstBufferSize); else @@ -364,13 +366,15 @@ ALvoid MixSource(ALactivesource *src, ALCdevice *Device, ALuint SamplesToDo) for(j = 0;j < Device->NumAuxSends;j++) { SendParams *parms = &src->Send[j]; + const ALfloat *samples; + if(!parms->OutBuffer) continue; - DoFilters(&parms->LpFilter[chan], &parms->HpFilter[chan], - SrcData, ResampledData, DstBufferSize, - parms->Filters[chan]); - src->WetMix(parms->OutBuffer, SrcData, &parms->Gain, + samples = DoFilters(&parms->LpFilter[chan], &parms->HpFilter[chan], + SrcData, ResampledData, DstBufferSize, + parms->Filters[chan]); + src->WetMix(parms->OutBuffer, samples, &parms->Gain, maxu(parms->Counter, OutPos) - OutPos, OutPos, DstBufferSize); } -- cgit v1.2.3