mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-22 00:06:59 +02:00
iOS: Add support for configuring the size of the IO buffer.
This commit is contained in:
+9
-9
@@ -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
|
|||||||
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
|
|||||||
}
|
}
|
||||||
#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
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user