aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/alu.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-12-23 17:56:01 -0800
committerChris Robinson <[email protected]>2018-12-23 17:56:01 -0800
commit1f966c11ef5728b446203212b62191ab440a1ee3 (patch)
treee640017366e334239fed6e309f1c8f052774aa8c /Alc/alu.cpp
parent11d815cfd304da3f1a0fd4178db932ad6c47d8ce (diff)
Add some more ASSUMEs
Diffstat (limited to 'Alc/alu.cpp')
-rw-r--r--Alc/alu.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/Alc/alu.cpp b/Alc/alu.cpp
index 3ea82354..45c47008 100644
--- a/Alc/alu.cpp
+++ b/Alc/alu.cpp
@@ -1514,8 +1514,12 @@ void ProcessContext(ALCcontext *ctx, const ALsizei SamplesToDo)
void ApplyStablizer(FrontStablizer *Stablizer, ALfloat (*RESTRICT Buffer)[BUFFERSIZE],
- int lidx, int ridx, int cidx, ALsizei SamplesToDo, ALsizei NumChannels)
+ int lidx, int ridx, int cidx, const ALsizei SamplesToDo,
+ const ALsizei NumChannels)
{
+ ASSUME(SamplesToDo > 0);
+ ASSUME(NumChannels > 0);
+
/* Apply an all-pass to all channels, except the front-left and front-
* right, so they maintain the same relative phase.
*/
@@ -1558,6 +1562,9 @@ void ApplyStablizer(FrontStablizer *Stablizer, ALfloat (*RESTRICT Buffer)[BUFFER
void ApplyDistanceComp(ALfloat (*RESTRICT Samples)[BUFFERSIZE], const DistanceComp &distcomp,
ALfloat *RESTRICT Values, ALsizei SamplesToDo, ALsizei numchans)
{
+ ASSUME(SamplesToDo > 0);
+ ASSUME(numchans > 0);
+
for(ALsizei c{0};c < numchans;c++)
{
ALfloat *RESTRICT inout{Samples[c]};
@@ -1565,12 +1572,12 @@ void ApplyDistanceComp(ALfloat (*RESTRICT Samples)[BUFFERSIZE], const DistanceCo
const ALsizei base{distcomp[c].Length};
ALfloat *RESTRICT distbuf{distcomp[c].Buffer};
- if(base == 0)
+ if(base <= 0)
{
if(gain < 1.0f)
- std::for_each(inout, inout+SamplesToDo,
- [gain](ALfloat &in) noexcept -> void
- { in *= gain; }
+ std::transform(inout, inout+SamplesToDo, inout,
+ [gain](const ALfloat in) noexcept -> ALfloat
+ { return in * gain; }
);
continue;
}
@@ -1588,7 +1595,7 @@ void ApplyDistanceComp(ALfloat (*RESTRICT Samples)[BUFFERSIZE], const DistanceCo
std::copy_n(inout, SamplesToDo, out);
}
std::transform<ALfloat*RESTRICT>(Values, Values+SamplesToDo, inout,
- [gain](ALfloat in) noexcept -> ALfloat { return in * gain; }
+ [gain](const ALfloat in) noexcept -> ALfloat { return in * gain; }
);
}
}