iOS: Try adding support for Bluetooth routing.

This commit is contained in:
David Reid
2019-11-02 10:35:28 +10:00
parent 07c26bb9f9
commit f560f4793d
+17 -1
View File
@@ -1993,6 +1993,10 @@ typedef struct
ma_bool32 tryAutoSpawn; /* Enables autospawning of the PulseAudio daemon if necessary. */
} pulse;
struct
{
ma_bool32 noBluetoothRouting;
} coreaudio;
struct
{
const char* pClientName;
ma_bool32 tryStartServer;
@@ -20401,9 +20405,21 @@ ma_result ma_context_init__coreaudio(const ma_context_config* pConfig, ma_contex
#if defined(MA_APPLE_MOBILE)
@autoreleasepool {
AVAudioSession* pAudioSession = [AVAudioSession sharedInstance];
AVAudioSessionCategoryOptions options = 0;
ma_assert(pAudioSession != NULL);
[pAudioSession setCategory: AVAudioSessionCategoryPlayAndRecord error:nil];
/*
Try enabling routing to Bluetooth devices. The AVAudioSessionCategoryOptionAllowBluetoothA2DP is only available
starting from iOS 10 so I'm doing a version check before enabling this.
*/
if (!pConfig->coreaudio.noBluetoothRouting) {
if ([[[UIDevice currentDevice] systemVersion] compare:@"10.0" options:NSNumericSearch] != NSOrderedAscending) {
options = 0x20; /* 0x20 = AVAudioSessionCategoryOptionAllowBluetoothA2DP */
}
}
[pAudioSession setCategory: AVAudioSessionCategoryPlayAndRecord withOptions:options error:nil];
/* By default we want miniaudio to use the speakers instead of the receiver. In the future this may be customizable. */
ma_bool32 useSpeakers = MA_TRUE;