Index: webrtc/modules/audio_device/ios/objc/RTCAudioSession.mm |
diff --git a/webrtc/modules/audio_device/ios/objc/RTCAudioSession.mm b/webrtc/modules/audio_device/ios/objc/RTCAudioSession.mm |
index 83189b900c8104fbc2bf9d69e79645ea1e291248..b80a7fd255e3ac48d11fa3ac68c67e9b706ecbad 100644 |
--- a/webrtc/modules/audio_device/ios/objc/RTCAudioSession.mm |
+++ b/webrtc/modules/audio_device/ios/objc/RTCAudioSession.mm |
@@ -18,6 +18,7 @@ |
NSString * const kRTCAudioSessionErrorDomain = @"org.webrtc.RTCAudioSession"; |
NSInteger const kRTCAudioSessionErrorLockRequired = -1; |
+NSInteger const kRTCAudioSessionErrorConfiguration = -2; |
// This class needs to be thread-safe because it is accessed from many threads. |
// TODO(tkchin): Consider more granular locking. We're not expecting a lot of |
@@ -29,6 +30,7 @@ NSInteger const kRTCAudioSessionErrorLockRequired = -1; |
NSInteger _activationCount; |
NSInteger _lockRecursionCount; |
BOOL _isActive; |
+ BOOL _shouldDelayAudioConfiguration; |
} |
@synthesize session = _session; |
@@ -91,6 +93,21 @@ NSInteger const kRTCAudioSessionErrorLockRequired = -1; |
} |
} |
+- (void)setShouldDelayAudioConfiguration:(BOOL)shouldDelayAudioConfiguration { |
+ @synchronized(self) { |
+ if (_shouldDelayAudioConfiguration == shouldDelayAudioConfiguration) { |
+ return; |
+ } |
+ _shouldDelayAudioConfiguration = shouldDelayAudioConfiguration; |
+ } |
+} |
+ |
+- (BOOL)shouldDelayAudioConfiguration { |
+ @synchronized(self) { |
+ return _shouldDelayAudioConfiguration; |
+ } |
+} |
+ |
- (void)addDelegate:(id<RTCAudioSessionDelegate>)delegate { |
@synchronized(self) { |
[_delegates addObject:delegate]; |
@@ -250,7 +267,8 @@ NSInteger const kRTCAudioSessionErrorLockRequired = -1; |
[self incrementActivationCount]; |
} |
} else { |
- RTCLogError(@"Failed to setActive:%d. Error: %@", active, error); |
+ RTCLogError(@"Failed to setActive:%d. Error: %@", |
+ active, error.localizedDescription); |
} |
// Decrement activation count on deactivation whether or not it succeeded. |
if (!active) { |
@@ -441,18 +459,6 @@ NSInteger const kRTCAudioSessionErrorLockRequired = -1; |
return error; |
} |
-- (BOOL)checkLock:(NSError **)outError { |
- // Check ivar instead of trying to acquire lock so that we won't accidentally |
- // acquire lock if it hasn't already been called. |
- if (!self.isLocked) { |
- if (outError) { |
- *outError = [RTCAudioSession lockError]; |
- } |
- return NO; |
- } |
- return YES; |
-} |
- |
- (NSSet *)delegates { |
@synchronized(self) { |
return _delegates.setRepresentation; |
@@ -479,6 +485,18 @@ NSInteger const kRTCAudioSessionErrorLockRequired = -1; |
} |
} |
+- (BOOL)checkLock:(NSError **)outError { |
+ // Check ivar instead of trying to acquire lock so that we won't accidentally |
+ // acquire lock if it hasn't already been called. |
+ if (!self.isLocked) { |
+ if (outError) { |
+ *outError = [RTCAudioSession lockError]; |
+ } |
+ return NO; |
+ } |
+ return YES; |
+} |
+ |
- (void)updateAudioSessionAfterEvent { |
BOOL shouldActivate = self.activationCount > 0; |
AVAudioSessionSetActiveOptions options = shouldActivate ? |