From c120375fc6ce00023bb560b24f60c08252969d83 Mon Sep 17 00:00:00 2001 From: Benjamin Reis Date: Wed, 4 Jul 2018 11:51:51 +0200 Subject: [PATCH] begin dev --- Classes/AudioHelper.m | 2 +- Classes/LinphoneManager.m | 12 +++++------- Classes/ProviderDelegate.m | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/Classes/AudioHelper.m b/Classes/AudioHelper.m index d8e110899..dbc28f680 100644 --- a/Classes/AudioHelper.m +++ b/Classes/AudioHelper.m @@ -11,7 +11,7 @@ @implementation AudioHelper + (NSArray *)bluetoothRoutes { - return @[ AVAudioSessionPortBluetoothA2DP, AVAudioSessionPortBluetoothLE, AVAudioSessionPortBluetoothHFP ]; + return @[ AVAudioSessionPortBluetoothA2DP, AVAudioSessionPortBluetoothLE, AVAudioSessionPortBluetoothHFP, AVAudioSessionPortCarAudio ]; } + (AVAudioSessionPortDescription *)bluetoothAudioDevice { diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index 8fec2f9a8..6160c94b1 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -2460,10 +2460,9 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) { // -bluetooth headset disconnected or // -user wanted to use earpiece // the only thing we can assume is that when we lost a device, it must be a bluetooth one (strong hypothesis though) - if ([[notif.userInfo valueForKey:AVAudioSessionRouteChangeReasonKey] integerValue] == - AVAudioSessionRouteChangeReasonOldDeviceUnavailable) { + if ([[notif.userInfo valueForKey:AVAudioSessionRouteChangeReasonKey] integerValue] == AVAudioSessionRouteChangeReasonOldDeviceUnavailable) _bluetoothAvailable = NO; - } + AVAudioSessionRouteDescription *newRoute = [AVAudioSession sharedInstance].currentRoute; if (newRoute) { @@ -2474,11 +2473,10 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) { if (([[AudioHelper bluetoothRoutes] containsObject:route]) && !_speakerEnabled) { _bluetoothAvailable = TRUE; _bluetoothEnabled = TRUE; - } else { + } else _bluetoothEnabled = FALSE; - } - NSDictionary *dict = [NSDictionary - dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:_bluetoothAvailable], @"available", nil]; + + NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:_bluetoothAvailable], @"available", nil]; [NSNotificationCenter.defaultCenter postNotificationName:kLinphoneBluetoothAvailabilityUpdate object:self userInfo:dict]; diff --git a/Classes/ProviderDelegate.m b/Classes/ProviderDelegate.m index a3ee92e9f..108f0c8c7 100644 --- a/Classes/ProviderDelegate.m +++ b/Classes/ProviderDelegate.m @@ -52,7 +52,7 @@ - (void)configAudioSession:(AVAudioSession *)audioSession { NSError *err = nil; [audioSession setCategory:AVAudioSessionCategoryPlayAndRecord - withOptions:AVAudioSessionCategoryOptionAllowBluetooth + withOptions:AVAudioSessionCategoryOptionAllowBluetooth | AVAudioSessionCategoryOptionAllowBluetoothA2DP error:&err]; if (err) { LOGE(@"Unable to change audio category because : %@", err.localizedDescription);