Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Unified Diff: webrtc/modules/audio_device/ios/objc/RTCAudioSession.mm

Issue 1778793005: Refactor AVAudioSession intialization code. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 ea7c546e8e9143decad7e60d08c729358ac155ca..b5db72c589a6005547d9610b89ff0864a7048776 100644
--- a/webrtc/modules/audio_device/ios/objc/RTCAudioSession.mm
+++ b/webrtc/modules/audio_device/ios/objc/RTCAudioSession.mm
@@ -27,6 +27,7 @@ NSInteger const kRTCAudioSessionErrorLockRequired = -1;
NSInteger _activationCount;
BOOL _isActive;
BOOL _isLocked;
+ BOOL _shouldDelayAudioConfiguration;
}
@synthesize session = _session;
@@ -90,6 +91,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 +266,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 +458,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 +484,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 ?

Powered by Google App Engine
This is Rietveld 408576698