@@ -98,26 +98,22 @@ void AudioState::AddSendingStream(webrtc::AudioSendStream* stream,
9898 UpdateAudioTransportWithSendingStreams ();
9999
100100 // Make sure recording is initialized; start recording if enabled.
101- if (ShouldRecord ()) {
102- auto * adm = config_.audio_device_module .get ();
103- if (!adm->Recording ()) {
104- if (adm->InitRecording () == 0 ) {
105- if (recording_enabled_) {
106-
107- // TODO: Verify if the following windows only logic is still required.
101+ auto * adm = config_.audio_device_module .get ();
102+ if (!adm->Recording ()) {
103+ if (adm->InitRecording () == 0 ) {
104+ if (recording_enabled_) {
108105#if defined(WEBRTC_WIN)
109- if (adm->BuiltInAECIsAvailable () && !adm->Playing ()) {
110- if (!adm->PlayoutIsInitialized ()) {
111- adm->InitPlayout ();
112- }
113- adm->StartPlayout ();
106+ if (adm->BuiltInAECIsAvailable () && !adm->Playing ()) {
107+ if (!adm->PlayoutIsInitialized ()) {
108+ adm->InitPlayout ();
114109 }
115- #endif
116- adm->StartRecording ();
110+ adm->StartPlayout ();
117111 }
118- } else {
119- RTC_DLOG_F (LS_ERROR) << " Failed to initialize recording. " ;
112+ # endif
113+ adm-> StartRecording () ;
120114 }
115+ } else {
116+ RTC_DLOG_F (LS_ERROR) << " Failed to initialize recording." ;
121117 }
122118 }
123119}
@@ -127,10 +123,7 @@ void AudioState::RemoveSendingStream(webrtc::AudioSendStream* stream) {
127123 auto count = sending_streams_.erase (stream);
128124 RTC_DCHECK_EQ (1 , count);
129125 UpdateAudioTransportWithSendingStreams ();
130-
131- bool should_record = ShouldRecord ();
132- RTC_LOG (LS_INFO) << " RemoveSendingStream: should_record = " << should_record;
133- if (!should_record) {
126+ if (sending_streams_.empty ()) {
134127 config_.audio_device_module ->StopRecording ();
135128 }
136129}
@@ -158,7 +151,7 @@ void AudioState::SetRecording(bool enabled) {
158151 if (recording_enabled_ != enabled) {
159152 recording_enabled_ = enabled;
160153 if (enabled) {
161- if (ShouldRecord ()) {
154+ if (!sending_streams_. empty ()) {
162155 config_.audio_device_module ->StartRecording ();
163156 }
164157 } else {
@@ -218,43 +211,6 @@ void AudioState::UpdateNullAudioPollerState() {
218211 null_audio_poller_.Stop ();
219212 }
220213}
221-
222- void AudioState::OnMuteStreamChanged () {
223-
224- auto * adm = config_.audio_device_module .get ();
225- bool should_record = ShouldRecord ();
226-
227- RTC_LOG (LS_INFO) << " OnMuteStreamChanged: should_record = " << should_record;
228- if (should_record && !adm->Recording ()) {
229- if (adm->InitRecording () == 0 ) {
230- adm->StartRecording ();
231- }
232- } else if (!should_record && adm->Recording ()) {
233- adm->StopRecording ();
234- }
235- }
236-
237- bool AudioState::ShouldRecord () {
238- RTC_LOG (LS_INFO) << " ShouldRecord" ;
239- // no streams to send
240- if (sending_streams_.empty ()) {
241- RTC_LOG (LS_INFO) << " ShouldRecord: send stream = empty" ;
242- return false ;
243- }
244-
245- int stream_count = sending_streams_.size ();
246-
247- int muted_count = 0 ;
248- for (const auto & kv : sending_streams_) {
249- if (kv.first ->GetMuted ()) {
250- muted_count++;
251- }
252- }
253-
254- RTC_LOG (LS_INFO) << " ShouldRecord: " << muted_count << " muted, " << stream_count << " sending" ;
255- return muted_count != stream_count;
256- }
257-
258214} // namespace internal
259215
260216rtc::scoped_refptr<AudioState> AudioState::Create (
0 commit comments