diff --git a/Classes/AudioHelper.m b/Classes/AudioHelper.m index d8e110899..458aeb61f 100644 --- a/Classes/AudioHelper.m +++ b/Classes/AudioHelper.m @@ -11,7 +11,7 @@ @implementation AudioHelper + (NSArray *)bluetoothRoutes { - return @[ AVAudioSessionPortBluetoothA2DP, AVAudioSessionPortBluetoothLE, AVAudioSessionPortBluetoothHFP ]; + return @[AVAudioSessionPortBluetoothHFP, AVAudioSessionPortCarAudio, AVAudioSessionPortBluetoothA2DP, AVAudioSessionPortBluetoothLE ]; } + (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 a881f3c59..4328cba08 100644 --- a/Classes/ProviderDelegate.m +++ b/Classes/ProviderDelegate.m @@ -52,21 +52,11 @@ - (void)configAudioSession:(AVAudioSession *)audioSession { NSError *err = nil; [audioSession setCategory:AVAudioSessionCategoryPlayAndRecord - withOptions:AVAudioSessionCategoryOptionAllowBluetooth + mode:AVAudioSessionModeVoiceChat + options:AVAudioSessionCategoryOptionAllowBluetooth | AVAudioSessionCategoryOptionAllowBluetoothA2DP | AVAudioSessionCategoryOptionMixWithOthers error:&err]; if (err) { - LOGE(@"Unable to change audio category because : %@", err.localizedDescription); - err = nil; - } - [audioSession setMode:AVAudioSessionModeVoiceChat error:&err]; - if (err) { - LOGE(@"Unable to change audio mode because : %@", err.localizedDescription); - err = nil; - } - double sampleRate = 44100.0; - [audioSession setPreferredSampleRate:sampleRate error:&err]; - if (err) { - LOGE(@"Unable to change preferred sample rate because : %@", err.localizedDescription); + LOGE(@"Unable to change audio session because: %@", err.localizedDescription); err = nil; } } diff --git a/submodules/mediastreamer2 b/submodules/mediastreamer2 index 54a79f731..d4ad04b1d 160000 --- a/submodules/mediastreamer2 +++ b/submodules/mediastreamer2 @@ -1 +1 @@ -Subproject commit 54a79f731fea61d345dfff4f8fcb2fc390c2fed7 +Subproject commit d4ad04b1dcf2a321f90e315a3fdf293fccedcdb8