diff --git a/sdk/objc/components/audio/RTCAudioSession.mm b/sdk/objc/components/audio/RTCAudioSession.mm index 843ce95ff3..057f62cf27 100644 --- a/sdk/objc/components/audio/RTCAudioSession.mm +++ b/sdk/objc/components/audio/RTCAudioSession.mm @@ -363,24 +363,27 @@ NSString * const kRTCAudioSessionOutputVolumeSelector = @"outputVolume"; } } if (success) { - if (shouldSetActive) { - self.isActive = active; - if (active && self.isInterrupted) { - self.isInterrupted = NO; - [self notifyDidEndInterruptionWithShouldResumeSession:YES]; - } - } if (active) { + if (shouldSetActive) { + self.isActive = active; + if (self.isInterrupted) { + self.isInterrupted = NO; + [self notifyDidEndInterruptionWithShouldResumeSession:YES]; + } + } [self incrementActivationCount]; + [self notifyDidSetActive:active]; } - [self notifyDidSetActive:active]; } else { RTCLogError(@"Failed to setActive:%d. Error: %@", active, error.localizedDescription); [self notifyFailedToSetActive:active error:error]; } - // Decrement activation count on deactivation whether or not it succeeded. + // Set isActive and decrement activation count on deactivation + // whether or not it succeeded. if (!active) { + self.isActive = active; + [self notifyDidSetActive:active]; [self decrementActivationCount]; } RTCLog(@"Number of current activations: %d", _activationCount);