From 893ffe9a84d497d38e6e472b0cffbd9c37e0c366 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 29 May 2019 21:58:37 -0700 Subject: Use span for MixSamples --- Alc/mixer/mixer_c.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'Alc/mixer/mixer_c.cpp') diff --git a/Alc/mixer/mixer_c.cpp b/Alc/mixer/mixer_c.cpp index d1bbd25e..9e8f2ad5 100644 --- a/Alc/mixer/mixer_c.cpp +++ b/Alc/mixer/mixer_c.cpp @@ -144,21 +144,20 @@ void MixDirectHrtf_(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, template<> -void Mix_(const ALfloat *data, const ALsizei OutChans, ALfloat (*OutBuffer)[BUFFERSIZE], +void Mix_(const ALfloat *data, const al::span OutBuffer, ALfloat *CurrentGains, const ALfloat *TargetGains, const ALsizei Counter, const ALsizei OutPos, const ALsizei BufferSize) { - ASSUME(OutChans > 0); ASSUME(BufferSize > 0); const ALfloat delta{(Counter > 0) ? 1.0f / static_cast(Counter) : 0.0f}; - for(ALsizei c{0};c < OutChans;c++) + for(FloatBufferLine &output : OutBuffer) { - ALfloat *RESTRICT dst{&OutBuffer[c][OutPos]}; - ALsizei pos{0}; - ALfloat gain{CurrentGains[c]}; + ALfloat *RESTRICT dst{output.data()+OutPos}; + ALfloat gain{*CurrentGains}; + const ALfloat diff{*TargetGains - gain}; - const ALfloat diff{TargetGains[c] - gain}; + ALsizei pos{0}; if(std::fabs(diff) > std::numeric_limits::epsilon()) { ALsizei minsize{mini(BufferSize, Counter)}; @@ -170,11 +169,13 @@ void Mix_(const ALfloat *data, const ALsizei OutChans, ALfloat (*OutBuffer step_count += 1.0f; } if(pos == Counter) - gain = TargetGains[c]; + gain = *TargetGains; else gain += step*step_count; - CurrentGains[c] = gain; + *CurrentGains = gain; } + ++CurrentGains; + ++TargetGains; if(!(std::fabs(gain) > GAIN_SILENCE_THRESHOLD)) continue; -- cgit v1.2.3