From 7ad4f753a42a4ff9c4ce2be0a848f8aaccb86454 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sat, 29 Sep 2018 19:39:49 -0700 Subject: [PATCH] Fix some length ranges --- Alc/mastering.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Alc/mastering.c b/Alc/mastering.c index fb831f46..b92390bb 100644 --- a/Alc/mastering.c +++ b/Alc/mastering.c @@ -356,8 +356,14 @@ Compressor* CompressorInit(const ALuint NumChans, const ALuint SampleRate, ALsizei hold; size_t size; - lookAhead = (ALsizei)clampf(roundf(LookAheadTime*SampleRate), 0.0f, BUFFERSIZE); - hold = (ALsizei)clampf(roundf(HoldTime*SampleRate), 0.0f, BUFFERSIZE); + lookAhead = (ALsizei)clampf(roundf(LookAheadTime*SampleRate), 0.0f, BUFFERSIZE-1); + hold = (ALsizei)clampf(roundf(HoldTime*SampleRate), 0.0f, BUFFERSIZE-1); + /* The sliding hold implementation doesn't handle a length of 1. A 1-sample + * hold is useless anyway, it would only ever give back what was just given + * to it. + */ + if(hold == 1) + hold = 0; size = sizeof(*Comp); if(lookAhead > 0)