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 <kode54@gmail.com>
This commit is contained in:
Christopher Snowhill 2025-02-11 23:02:55 -08:00
parent ce2bedf478
commit 92dbe351af

View file

@ -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;