Cog Audio: Change output callback to always retry reading for sample data until the requested buffer is filled, or until the playback either ends or is torn down. This prevents gaps when the preceding ring buffer wraps around.

CQTexperiment
Christopher Snowhill 2022-01-13 23:02:01 -08:00
parent 92d29e7acf
commit e6124335d1
1 changed files with 3 additions and 1 deletions

View File

@ -361,7 +361,9 @@ default_device_changed(AudioObjectID inObjectID, UInt32 inNumberAddresses, const
amountRead = [outputController readData:(readPointer) amount:amountToRead];
if ((amountRead < amountToRead) && [outputController endOfStream] == NO) //Try one more time! for track changes!
// Try repeatedly! Buffer wraps can cause a slight data shortage, as can
// unexpected track changes.
while ((amountRead < amountToRead) && [outputController endOfStream] == NO && [outputController shouldContinue] == YES)
{
int amountRead2; //Use this since return type of readdata isnt known...may want to fix then can do a simple += to readdata
amountRead2 = [outputController readData:(readPointer+amountRead) amount:amountToRead-amountRead];