RTCAudioSession
IntroductionProxy class for AVAudioSession that adds a locking mechanism similar to AVCaptureDevice. This is used to that interleaving configurations between WebRTC and the application layer are avoided. Only setter methods are currently proxied. Getters can be accessed directly off AVAudioSession. RTCAudioSession also coordinates activation so that the audio session is activated only once. See |setActive:error:|. Methods
addDelegate:- (void)addDelegate:(id<RTCAudioSessionDelegate>)delegate; DiscussionAdds a delegate, which is held weakly. Even though it's held weakly, callers should still call |removeDelegate| when it's no longer required to ensure proper dealloc. This is due to internal use of an NSHashTable. lockForConfiguration- (void)lockForConfiguration; DiscussionRequest exclusive access to the audio session for configuration. This call will block if the lock is held by another object. removeDelegate:- (void)removeDelegate:(id<RTCAudioSessionDelegate>)delegate; DiscussionRemoves an added delegate. setActive:error:- (BOOL)setActive:(BOOL)active error:(NSError **)outError; DiscussionIf |active|, activates the audio session if it isn't already active. Successful calls must be balanced with a setActive:NO when activation is no longer required. If not |active|, deactivates the audio session if one is active and this is the last balanced call. When deactivating, the AVAudioSessionSetActiveOptionNotifyOthersOnDeactivation option is passed to AVAudioSession. sharedInstance+ (instancetype)sharedInstance; DiscussionDefault constructor. Do not call init. unlockForConfiguration- (void)unlockForConfiguration; DiscussionRelinquishes exclusive access to the audio session. PropertiesinputDataSource@property(readonly, nullable) AVAudioSessionDataSourceDescription *inputDataSource; DiscussionNSArray<AVAudioSessionDataSourceDescription *> * inputDataSources; isActive@property(nonatomic, readonly) BOOL isActive; DiscussionOur best guess at whether the session is active based on results of calls to AVAudioSession. isLocked@property(nonatomic, readonly) BOOL isLocked; DiscussionWhether RTCAudioSession is currently locked for configuration. outputDataSource@property(readonly, nullable) AVAudioSessionDataSourceDescription *outputDataSource; DiscussionNSArray<AVAudioSessionDataSourceDescription *> * outputDataSources; session@property(nonatomic, readonly) AVAudioSession *session; DiscussionConvenience property to access the AVAudioSession singleton. Callers should not call setters on AVAudioSession directly, but other method invocations are fine. |