I have an application for Mac OS X. I want to know how to port next chunk of code for iPhone:
AudioObjectPropertyAddress addr;
addr.mSelector = kAudioDevicePropertyBufferFrameSize;
addr.mScope = kAudioDevicePropertyScopeOutput;
addr.mElement = kAudioObjectPropertyElementWildcard;
uint32_t size = sizeof(uint32_t);
uint32_t buff_size = 0;
if(AudioObjectGetPropertyData(devId, &addr, 0, 0,
&size, &buff_size) == noErr)
return buff_size;
I think Audio Session Service will be usefull in this case but I can’t find function which let me get size of buffer in references.
If you are using the Audio Queue API, you provide the buffers of a size you determine using AudioQueueAllocateBuffer(). (Note that these AQ buffers might be filled from audio driver buffers of a different and opaque size.)
If you are using the RemoteIO Audio Unit, the OS decides on the actual buffer size, the OS can change the buffer size at runtime, and your audio callback has to be flexible enough to handle the buffer size given it, even if the size changes from callback to callback.
For RemoteIO, you can request a preferred buffer size using: AudioSessionSetProperty with kAudioSessionProperty_PreferredHardwareIOBufferDuration . You have to convert size into the equivalent duration (given your sample rate, etc.) But this request may or may not be honored by iOS.