Hi!
[Sorry, posting again. I was unable to reply in the original post due to forum internal error.]
We have a strange problem with sound playback in our game. We use single Remote I/O unit for sound output and mix all the sounds by ourselves for cross platform reasons.
Then we discovered strange FPS spikes when the game renders almost static frame on iPhone 7, iOS 10.1.1. If we disable sound completelly (no audio units created at all) - spikes disapear. After that we enabled sound back, but removed all the code from unit's Render callback and left only memset to fill buffers with silence:
AudioBuffer *pAudioUnitBuffer0 = &ioData->mBuffers[0];
AudioBuffer *pAudioUnitBuffer1 = &ioData->mBuffers[1];
int Size = pAudioUnitBuffer0->mDataByteSize;
memset(pAudioUnitBuffer0->mData, 0, Size);
memset(pAudioUnitBuffer1->mData, 0, Size);
return noErr;
Spikes appeared again. Then we tried disable audio unit and added code to play long single buffer with OpenAL - no spikes!
How is that possible that high level API gives less overhead than lowest level API - Remove I/O Audio Unit?
The bug only reproduces on iPhone 7 iOS 10.1.1 device for us. We're not sure yet: is this an iOS 10.1.1 bug or iPhone 7 device bug.
Used Remote I/O stream format:
AudioStreamBasicDescription FormatDesc;
memset(&FormatDesc, 0, sizeof(FormatDesc));
FormatDesc.mFormatID = kAudioFormatLinearPCM;
FormatDesc.mFormatFlags = 0;
FormatDesc.mSampleRate = Freq;
FormatDesc.mChannelsPerFrame = 2;
FormatDesc.mBitsPerChannel = 32;
FormatDesc.mFramesPerPacket = 1;
FormatDesc.mBytesPerPacket = FormatDesc.mBitsPerChannel / 8;
FormatDesc.mBytesPerFrame = FormatDesc.mBitsPerChannel / 8;
// "We're back to non-interleaved 32-bit floats on both platforms"
// http://asciiwwdc.com/2014/sessions/501
FormatDesc.mFormatFlags |= kAudioFormatFlagIsFloat;
FormatDesc.mFormatFlags |= kLinearPCMFormatFlagIsNonInterleaved;
FormatDesc.mFormatFlags |= kAudioFormatFlagsNativeEndian;
FormatDesc.mFormatFlags |= kAudioFormatFlagIsPacked;
if (AudioUnitSetProperty(
m_AudioUnit,
kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Input,
0,
(void *) &FormatDesc,
sizeof(AudioStreamBasicDescription)) != noErr)
...
Andrew.