[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 <kode54@gmail.com>
lastfm
Christopher Snowhill 2022-06-26 01:09:55 -07:00
parent aa3673ed33
commit 378f710cee
1 changed files with 12 additions and 7 deletions

View File

@ -177,14 +177,19 @@ static OSStatus eqRenderCallback(void *inRefCon, AudioUnitRenderActionFlags *ioA
[currentPtsLock unlock]; [currentPtsLock unlock];
} }
if(r8bvis) { if(r8bvis) {
size_t inDone = 0;
int samplesProcessed; int samplesProcessed;
[currentPtsLock lock]; size_t totalDone = 0;
samplesProcessed = (int)r8bstate_resample(r8bvis, &visAudio[0], frameCount, &inDone, &visTemp[0], 8192); size_t inDone = 0;
[currentPtsLock unlock]; {
if(samplesProcessed) { [currentPtsLock lock];
[visController postVisPCM:&visTemp[0] amount:samplesProcessed]; 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) { } else if(r8bvis) {
for(;;) { for(;;) {