From 8c019c730250227d5a41634dcbd5e509e1a016cb Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Wed, 26 Mar 2025 19:03:26 -0700 Subject: [PATCH] Bug Fix: Include soxr latency in memory allocation This should be included, for safety purposes, in case the rounding up to the nearest multiple of 256 samples doesn't bump the buffer size enough. Signed-off-by: Christopher Snowhill --- Audio/Chain/ConverterNode.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Audio/Chain/ConverterNode.m b/Audio/Chain/ConverterNode.m index e6339993c..1a3ff53ee 100644 --- a/Audio/Chain/ConverterNode.m +++ b/Audio/Chain/ConverterNode.m @@ -269,6 +269,7 @@ void scale_by_volume(float *buffer, size_t count, float volume) { size_t inputSamples = ioNumberPackets / floatFormat.mBytesPerPacket; ioNumberPackets = (UInt32)inputSamples; ioNumberPackets = (UInt32)ceil((float)ioNumberPackets * sampleRatio); + ioNumberPackets += soxr_delay(soxr); ioNumberPackets = (ioNumberPackets + 255) & ~255; size_t newSize = ioNumberPackets * floatFormat.mBytesPerPacket; @@ -285,7 +286,6 @@ void scale_by_volume(float *buffer, size_t count, float volume) { size_t outputDone = 0; if(!skipResampler) { - ioNumberPackets += soxr_delay(soxr); soxr_process(soxr, (float *)(((uint8_t *)inputBuffer) + inpOffset), inputSamples, &inputDone, floatBuffer, ioNumberPackets, &outputDone); if(latencyEatenPost) {