mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-24 01:04:02 +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. */
|
ma_bool32 tryAutoSpawn; /* Enables autospawning of the PulseAudio daemon if necessary. */
|
||||||
} pulse;
|
} pulse;
|
||||||
struct
|
struct
|
||||||
|
{
|
||||||
|
ma_bool32 noBluetoothRouting;
|
||||||
|
} coreaudio;
|
||||||
|
struct
|
||||||
{
|
{
|
||||||
const char* pClientName;
|
const char* pClientName;
|
||||||
ma_bool32 tryStartServer;
|
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)
|
#if defined(MA_APPLE_MOBILE)
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
AVAudioSession* pAudioSession = [AVAudioSession sharedInstance];
|
AVAudioSession* pAudioSession = [AVAudioSession sharedInstance];
|
||||||
|
AVAudioSessionCategoryOptions options = 0;
|
||||||
|
|
||||||
ma_assert(pAudioSession != NULL);
|
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. */
|
/* 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;
|
ma_bool32 useSpeakers = MA_TRUE;
|
||||||
|
|||||||
Reference in New Issue
Block a user