From b4c8c112182c67cfa08b7be397fe12e9374a214b Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Tue, 11 Feb 2025 23:02:55 -0800 Subject: [PATCH] DSP: Add format change checking to FreeSurround FreeSurround, like the Equalizer, which attempt to coalesce Audio Chunks into larger blocks of 4096 samples, must check if the audio format has changed between blocks, and stop stacking chunks together when a new format is detected. They will continue processing with less sample data than expected, as necessary. Signed-off-by: Christopher Snowhill --- Audio/Chain/DSP/DSPFSurroundNode.m | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Audio/Chain/DSP/DSPFSurroundNode.m b/Audio/Chain/DSP/DSPFSurroundNode.m index e48ec6c2b..cb3318339 100644 --- a/Audio/Chain/DSP/DSPFSurroundNode.m +++ b/Audio/Chain/DSP/DSPFSurroundNode.m @@ -198,6 +198,14 @@ static void * kDSPFSurroundNodeContext = &kDSPFSurroundNodeContext; float *samplePtr = resetStreamFormat ? &inBuffer[2048 * 2] : &inBuffer[0]; while(!stopping && totalFrameCount < totalRequestedSamples) { + AudioStreamBasicDescription newInputFormat; + uint32_t newChannelConfig; + if(![self peekFormat:&newInputFormat channelConfig:&newChannelConfig] || + memcmp(&newInputFormat, &inputFormat, sizeof(newInputFormat)) != 0 || + newChannelConfig != inputChannelConfig) { + break; + } + chunk = [self readChunkAsFloat32:totalRequestedSamples - totalFrameCount]; if(!chunk) { break;