From 378f710cee077e7cabf2bf00fd968db1de8cc0a9 Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Sun, 26 Jun 2022 01:09:55 -0700 Subject: [PATCH] [Visualization] Resample more audio if present If upsampling the audio by a significant factor, it may be necessary to process more than one buffer at a time, rather than lose input. Signed-off-by: Christopher Snowhill --- Audio/Output/OutputAVFoundation.m | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/Audio/Output/OutputAVFoundation.m b/Audio/Output/OutputAVFoundation.m index c43ea55e2..e4d157228 100644 --- a/Audio/Output/OutputAVFoundation.m +++ b/Audio/Output/OutputAVFoundation.m @@ -177,14 +177,19 @@ static OSStatus eqRenderCallback(void *inRefCon, AudioUnitRenderActionFlags *ioA [currentPtsLock unlock]; } if(r8bvis) { - size_t inDone = 0; int samplesProcessed; - [currentPtsLock lock]; - samplesProcessed = (int)r8bstate_resample(r8bvis, &visAudio[0], frameCount, &inDone, &visTemp[0], 8192); - [currentPtsLock unlock]; - if(samplesProcessed) { - [visController postVisPCM:&visTemp[0] amount:samplesProcessed]; - } + size_t totalDone = 0; + size_t inDone = 0; + { + [currentPtsLock lock]; + samplesProcessed = (int)r8bstate_resample(r8bvis, &visAudio[totalDone], frameCount, &inDone, &visTemp[0], 8192); + [currentPtsLock unlock]; + if(samplesProcessed) { + [visController postVisPCM:&visTemp[0] amount:samplesProcessed]; + } + totalDone += inDone; + frameCount -= inDone; + } while(samplesProcessed && frameCount); } } else if(r8bvis) { for(;;) {