@@ -114,7 +114,7 @@ - (instancetype)initWithAudioSession:(id)audioSession {
114
114
options: NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld
115
115
context: (__bridge void *)RTC_OBJC_TYPE (RTCAudioSession).class ];
116
116
117
- _isRecordingEnabled = [ self sessionCategoryIsRecordingEnabled ] ;
117
+ _activeCategory = _session. category ;
118
118
119
119
RTCLog (@" RTC_OBJC_TYPE(RTCAudioSession) (%p ): init." , self);
120
120
}
@@ -544,9 +544,9 @@ - (void)handleRouteChangeNotification:(NSNotification *)notification {
544
544
case AVAudioSessionRouteChangeReasonCategoryChange:
545
545
RTCLog (@" Audio route changed: CategoryChange to :%@ " , self.session .category );
546
546
{
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 " ) ;
550
550
[self notifyDidChangeAudioSessionRecordingEnabled ];
551
551
}
552
552
}
@@ -781,7 +781,6 @@ - (BOOL)unconfigureWebRTCSession:(NSError **)outError {
781
781
}
782
782
RTCLog (@" Unconfiguring audio session for WebRTC." );
783
783
[self setActive: NO error: outError];
784
- _isRecordingEnabled = NO ;
785
784
786
785
return YES ;
787
786
}
@@ -1015,9 +1014,4 @@ - (void)notifyDidChangeAudioSessionRecordingEnabled {
1015
1014
}
1016
1015
}
1017
1016
1018
- -(BOOL )sessionCategoryIsRecordingEnabled {
1019
- return [_session.category isEqualToString: AVAudioSessionCategoryPlayAndRecord] ||
1020
- [_session.category isEqualToString: AVAudioSessionCategoryRecord];
1021
- }
1022
-
1023
1017
@end
0 commit comments