diff options
author | Chris Robinson <[email protected]> | 2014-05-19 01:54:52 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2014-05-19 01:54:52 -0700 |
commit | 7b782f6afa0d69459868c4bf954c1d42f0de08a7 (patch) | |
tree | a98a3ef4e5a649b11bcd7041f18be93b967bffc1 /Alc/mixer.c | |
parent | ef9dfe3772b7dd8db641ca841eb3704b23f9ac7e (diff) |
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.
Diffstat (limited to 'Alc/mixer.c')
-rw-r--r-- | Alc/mixer.c | 32 |
1 files changed, 18 insertions, 14 deletions
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); } |