Merge branch 'feature/fix_bluetooth'

This commit is contained in:
Benjamin Reis 2018-07-05 13:24:48 +02:00
commit edb7cd5255
4 changed files with 10 additions and 22 deletions

View file

@ -11,7 +11,7 @@
@implementation AudioHelper
+ (NSArray *)bluetoothRoutes {
return @[ AVAudioSessionPortBluetoothA2DP, AVAudioSessionPortBluetoothLE, AVAudioSessionPortBluetoothHFP ];
return @[AVAudioSessionPortBluetoothHFP, AVAudioSessionPortCarAudio, AVAudioSessionPortBluetoothA2DP, AVAudioSessionPortBluetoothLE ];
}
+ (AVAudioSessionPortDescription *)bluetoothAudioDevice {

View file

@ -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];

View file

@ -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;
}
}

@ -1 +1 @@
Subproject commit 54a79f731fea61d345dfff4f8fcb2fc390c2fed7
Subproject commit d4ad04b1dcf2a321f90e315a3fdf293fccedcdb8