fix(ios) avoid reapplying config when audio category doesn't change

This commit is contained in:
Saúl Ibarra Corretgé 2022-04-08 10:47:10 +02:00 committed by Saúl Ibarra Corretgé
parent 3097ac8cc4
commit cc5f65f58f
1 changed files with 8 additions and 3 deletions

View File

@ -259,10 +259,16 @@ RCT_EXPORT_METHOD(updateDeviceList) {
self->forceSpeaker = NO;
self->forceEarpiece = NO;
break;
case AVAudioSessionRouteChangeReasonCategoryChange:
case AVAudioSessionRouteChangeReasonCategoryChange: {
// The category has changed. Check if it's the one we want and adjust as
// needed.
RTCAudioSessionConfiguration *currentConfig = [self configForMode:self->activeMode];
if ([session.category isEqualToString:currentConfig.category]) {
// We are in the desired category, nothing to do here.
return;
}
break;
}
default:
return;
}
@ -275,7 +281,6 @@ RCT_EXPORT_METHOD(updateDeviceList) {
RTCAudioSessionConfiguration *config = [self configForMode:self->activeMode];
[self setConfig:config error:nil];
if (self->forceSpeaker && !self->isSpeakerOn) {
RTCAudioSession *session = JitsiAudioSession.rtcAudioSession;
[session lockForConfiguration];
[session overrideOutputAudioPort:AVAudioSessionPortOverrideSpeaker error:nil];
[session unlockForConfiguration];