CoreAudio output: Fix buffer underruns on output that could result in buffer looping in CoreAudio, by feeding silence from the callback instead of returning incomplete or possibly empty buffers
parent
098650099e
commit
c6b112f512
|
@ -60,7 +60,16 @@ static OSStatus Sound_Renderer(void *inRefCon, AudioUnitRenderActionFlags *ioAc
|
|||
amountRead += amountRead2;
|
||||
}
|
||||
|
||||
ioData->mBuffers[0].mDataByteSize = amountRead;
|
||||
if (amountRead < amountToRead)
|
||||
{
|
||||
// Either underrun, or no data at all. Caller output tends to just
|
||||
// buffer loop if it doesn't get anything, so always produce a full
|
||||
// buffer, and silence anything we couldn't supply.
|
||||
memset(readPointer + amountRead, 0, amountToRead - amountRead);
|
||||
amountRead = amountToRead;
|
||||
}
|
||||
|
||||
//ioData->mBuffers[0].mDataByteSize = amountRead;
|
||||
ioData->mBuffers[0].mNumberChannels = output->deviceFormat.mChannelsPerFrame;
|
||||
ioData->mNumberBuffers = 1;
|
||||
|
||||
|
|
Loading…
Reference in New Issue