From 31357723267143f3e82ff5ce17df5512cd0e3335 Mon Sep 17 00:00:00 2001 From: Abby Yeh Date: Tue, 9 Mar 2021 01:55:31 +0800 Subject: [PATCH] Changed setActive of RTCAudio Session, and it's working Bug: webrtc:12018 Change-Id: I7ee5cf2df406e7a6d0edf1a95a3665c4b1d6958b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/210720 Reviewed-by: Peter Hanspers Commit-Queue: Abby Yeh Cr-Commit-Position: refs/heads/master@{#33429} --- sdk/objc/components/audio/RTCAudioSession.mm | 21 +++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) 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);