@@ -114,7 +114,7 @@ - (instancetype)initWithAudioSession:(id)audioSession {
114114 options: NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld
115115 context: (__bridge void *)RTC_OBJC_TYPE (RTCAudioSession).class ];
116116
117- _isRecordingEnabled = [ self sessionCategoryIsRecordingEnabled ] ;
117+ _activeCategory = _session. category ;
118118
119119 RTCLog (@" RTC_OBJC_TYPE(RTCAudioSession) (%p ): init." , self);
120120 }
@@ -544,9 +544,9 @@ - (void)handleRouteChangeNotification:(NSNotification *)notification {
544544 case AVAudioSessionRouteChangeReasonCategoryChange:
545545 RTCLog (@" Audio route changed: CategoryChange to :%@ " , self.session .category );
546546 {
547- BOOL newValue = [ self sessionCategoryIsRecordingEnabled ];
548- if (_isRecordingEnabled != newValue) {
549- _isRecordingEnabled = newValue ;
547+ if (![_session.category isEqualToString: _activeCategory]) {
548+ _activeCategory = _session. category ;
549+ RTCLog ( @" Audio route changed: Restarting Audio Unit " ) ;
550550 [self notifyDidChangeAudioSessionRecordingEnabled ];
551551 }
552552 }
@@ -781,7 +781,6 @@ - (BOOL)unconfigureWebRTCSession:(NSError **)outError {
781781 }
782782 RTCLog (@" Unconfiguring audio session for WebRTC." );
783783 [self setActive: NO error: outError];
784- _isRecordingEnabled = NO ;
785784
786785 return YES ;
787786}
@@ -1015,9 +1014,4 @@ - (void)notifyDidChangeAudioSessionRecordingEnabled {
10151014 }
10161015}
10171016
1018- -(BOOL )sessionCategoryIsRecordingEnabled {
1019- return [_session.category isEqualToString: AVAudioSessionCategoryPlayAndRecord] ||
1020- [_session.category isEqualToString: AVAudioSessionCategoryRecord];
1021- }
1022-
10231017@end
0 commit comments