Commit 3f044fc6 authored by David Reid's avatar David Reid

iOS: Add support for configuring the size of the IO buffer.

parent fdf2a283
...@@ -31272,7 +31272,6 @@ static ma_result ma_device__untrack__coreaudio(ma_device* pDevice) ...@@ -31272,7 +31272,6 @@ static ma_result ma_device__untrack__coreaudio(ma_device* pDevice)
-(void)dealloc -(void)dealloc
{ {
[self remove_handler]; [self remove_handler];
[super dealloc];
} }
-(void)remove_handler -(void)remove_handler
...@@ -31428,8 +31427,6 @@ static ma_result ma_device_init_internal__coreaudio(ma_context* pContext, ma_dev ...@@ -31428,8 +31427,6 @@ static ma_result ma_device_init_internal__coreaudio(ma_context* pContext, ma_dev
AURenderCallbackStruct callbackInfo; AURenderCallbackStruct callbackInfo;
#if defined(MA_APPLE_DESKTOP) #if defined(MA_APPLE_DESKTOP)
AudioObjectID deviceObjectID; AudioObjectID deviceObjectID;
#else
UInt32 actualPeriodSizeInFramesSize = sizeof(actualPeriodSizeInFrames);
#endif #endif
/* This API should only be used for a single device type: playback or capture. No full-duplex mode. */ /* This API should only be used for a single device type: playback or capture. No full-duplex mode. */
...@@ -31714,13 +31711,16 @@ static ma_result ma_device_init_internal__coreaudio(ma_context* pContext, ma_dev ...@@ -31714,13 +31711,16 @@ static ma_result ma_device_init_internal__coreaudio(ma_context* pContext, ma_dev
} }
#else #else
/* /*
I don't know how to configure buffer sizes on iOS so for now we're not allowing it to be configured. Instead we're On iOS, the size of the IO buffer needs to be specified in seconds and is a floating point
just going to set it to the value of kAudioUnitProperty_MaximumFramesPerSlice. number. I don't trust any potential truncation errors due to converting from float to integer
so I'm going to explicitly set the actual period size to the next power of 2.
*/ */
status = ((ma_AudioUnitGetProperty_proc)pContext->coreaudio.AudioUnitGetProperty)(pData->audioUnit, kAudioUnitProperty_MaximumFramesPerSlice, kAudioUnitScope_Global, 0, &actualPeriodSizeInFrames, &actualPeriodSizeInFramesSize); @autoreleasepool {
if (status != noErr) { AVAudioSession* pAudioSession = [AVAudioSession sharedInstance];
((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit); MA_ASSERT(pAudioSession != NULL);
return ma_result_from_OSStatus(status);
[pAudioSession setPreferredIOBufferDuration:((float)actualPeriodSizeInFrames / pAudioSession.sampleRate) error:nil];
actualPeriodSizeInFrames = ma_next_power_of_2((ma_uint32)(pAudioSession.IOBufferDuration * pAudioSession.sampleRate));
} }
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment