Skip to content

Commit

Permalink
react-native-webrtc#540 fix to not change the setted audio route when…
Browse files Browse the repository at this point in the history
… getAudioRoute called
  • Loading branch information
nagyszili committed Apr 1, 2022
1 parent 0939989 commit 96ebd25
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions ios/RNCallKeep/RNCallKeep.m
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,21 @@ + (void)setup:(NSDictionary *)options {
}

NSArray *ports = [RNCallKeep getAudioInputs];

BOOL isCategorySetted = [myAudioSession setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionAllowBluetooth |
AVAudioSessionCategoryOptionAllowBluetoothA2DP | AVAudioSessionCategoryOptionAllowAirPlay error:&err];
if (!isCategorySetted)
{
NSLog(@"setCategory failed");
[NSException raise:@"setCategory failed" format:@"error: %@", err];
}
BOOL isCategoryActivated = [myAudioSession setActive:YES error:&err];
if (!isCategoryActivated)
{
NSLog(@"setActive failed");
[NSException raise:@"setActive failed" format:@"error: %@", err];
}

for (AVAudioSessionPortDescription *port in ports) {
if ([port.portName isEqualToString:inputName]) {
BOOL isSetted = [myAudioSession setPreferredInput:(AVAudioSessionPortDescription *)port error:&err];
Expand Down Expand Up @@ -521,14 +536,6 @@ + (NSArray *) getAudioInputs

AVAudioSession* myAudioSession = [AVAudioSession sharedInstance];

BOOL isCategorySetted = [myAudioSession setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionAllowBluetooth |
AVAudioSessionCategoryOptionAllowBluetoothA2DP | AVAudioSessionCategoryOptionAllowAirPlay error:&err];
if (!isCategorySetted)
{
NSLog(@"setCategory failed");
[NSException raise:@"setCategory failed" format:@"error: %@", err];
}

BOOL isCategoryActivated = [myAudioSession setActive:YES error:&err];
if (!isCategoryActivated)
{
Expand Down

0 comments on commit 96ebd25

Please sign in to comment.