mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-21 15:56:58 +02:00
iOS: Try adding support for Bluetooth routing.
This commit is contained in:
+17
-1
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user