From ae4c49ea6887d40c8ecc0b5db2f3b55763936072 Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Thu, 13 Feb 2025 20:58:07 -0800 Subject: [PATCH] Rubber Band DSP: Fix error checking for output The samples available function returns a signed integer, so it can apparently return negative on error, and the DSP was incorrectly casting this to an unsigned type, and thus attempting to buffer an inordinate number of samples and crashing. Signed-off-by: Christopher Snowhill --- Audio/Chain/DSP/DSPRubberbandNode.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Audio/Chain/DSP/DSPRubberbandNode.m b/Audio/Chain/DSP/DSPRubberbandNode.m index 543f0c8c7..dee87b5f0 100644 --- a/Audio/Chain/DSP/DSPRubberbandNode.m +++ b/Audio/Chain/DSP/DSPRubberbandNode.m @@ -441,7 +441,7 @@ static void * kDSPRubberbandNodeContext = &kDSPRubberbandNodeContext; rubberband_process(ts, (const float * const *)rsPtrs, len, endOfStream); - size_t samplesAvailable; + ssize_t samplesAvailable; if(!stopping && (samplesAvailable = rubberband_available(ts)) > 0) { while(!stopping && samplesAvailable > 0) { if(toDrop > 0) { @@ -492,7 +492,7 @@ static void * kDSPRubberbandNodeContext = &kDSPRubberbandNodeContext; if([chunk isHDCD]) [outputChunk setHDCD]; [outputChunk setStreamTimestamp:streamTimestamp]; [outputChunk setStreamTimeRatio:[chunk streamTimeRatio] * tempo]; - [outputChunk assignSamples:rsOutBuffer frameCount:samplesBuffered]; + [outputChunk assignSamples:&rsOutBuffer[0] frameCount:samplesBuffered]; samplesBuffered = 0; stretchOut += [outputChunk duration]; }