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

Side by Side Diff: content/renderer/media/webrtc_local_audio_track.cc

Issue 24742007: When an audio track is disabled, still pass the data to webrtc for audio processing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/media/webrtc_local_audio_track.h" 5 #include "content/renderer/media/webrtc_local_audio_track.h"
6 6
7 #include "content/renderer/media/webaudio_capturer_source.h" 7 #include "content/renderer/media/webaudio_capturer_source.h"
8 #include "content/renderer/media/webrtc_audio_capturer.h" 8 #include "content/renderer/media/webrtc_audio_capturer.h"
9 #include "content/renderer/media/webrtc_audio_capturer_sink_owner.h" 9 #include "content/renderer/media/webrtc_audio_capturer_sink_owner.h"
10 #include "content/renderer/media/webrtc_local_audio_source_provider.h" 10 #include "content/renderer/media/webrtc_local_audio_source_provider.h"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 int audio_delay_milliseconds, 147 int audio_delay_milliseconds,
148 int volume, 148 int volume,
149 bool key_pressed) { 149 bool key_pressed) {
150 scoped_refptr<WebRtcAudioCapturer> capturer; 150 scoped_refptr<WebRtcAudioCapturer> capturer;
151 std::vector<int> voe_channels; 151 std::vector<int> voe_channels;
152 int sample_rate = 0; 152 int sample_rate = 0;
153 int number_of_channels = 0; 153 int number_of_channels = 0;
154 int number_of_frames = 0; 154 int number_of_frames = 0;
155 SinkList sinks; 155 SinkList sinks;
156 scoped_refptr<ConfiguredBuffer> current_buffer; 156 scoped_refptr<ConfiguredBuffer> current_buffer;
157 bool disabled = false;
157 { 158 {
158 base::AutoLock auto_lock(lock_); 159 base::AutoLock auto_lock(lock_);
159 // When the track is disabled, we simply return here. 160 disabled = !enabled();
160 // TODO(xians): Figure out if we should feed zero to sinks instead, in
161 // order to inject VAD data in such case.
162 if (!enabled())
163 return;
164
165 capturer = capturer_; 161 capturer = capturer_;
166 voe_channels = voe_channels_; 162 voe_channels = voe_channels_;
167 current_buffer = buffer_; 163 current_buffer = buffer_;
168 sample_rate = current_buffer->params().sample_rate(); 164 sample_rate = current_buffer->params().sample_rate();
169 number_of_channels = current_buffer->params().channels(); 165 number_of_channels = current_buffer->params().channels();
170 number_of_frames = current_buffer->sink_buffer_size(); 166 number_of_frames = current_buffer->sink_buffer_size();
171 sinks = sinks_; 167 sinks = sinks_;
172 } 168 }
173 169
174 // Push the data to the fifo. 170 // Push the data to the fifo.
175 current_buffer->Push(audio_source); 171 current_buffer->Push(audio_source);
176 // Only turn off the audio processing when the constrain is set to false as 172 // Only turn off the audio processing when the constrain is set to false as
177 // well as there is no correct delay value. 173 // well as there is no correct delay value.
178 bool need_audio_processing = need_audio_processing_ ? 174 bool need_audio_processing = need_audio_processing_ ?
179 need_audio_processing_ : (audio_delay_milliseconds != 0); 175 need_audio_processing_ : (audio_delay_milliseconds != 0);
180 int current_volume = volume; 176 int current_volume = disabled ? 0 : volume;
no longer working on chromium 2013/09/27 20:22:52 Note that you are fooling the AGC, please test thi
ajm 2013/09/27 22:54:40 This doesn't look good. You shouldn't be messing a
181 while (current_buffer->Consume()) { 177 while (current_buffer->Consume()) {
182 // Feed the data to the sinks. 178 // Feed the data to the sinks.
183 for (SinkList::const_iterator it = sinks.begin(); it != sinks.end(); ++it) { 179 for (SinkList::const_iterator it = sinks.begin(); it != sinks.end(); ++it) {
184 int new_volume = (*it)->CaptureData(voe_channels, 180 int new_volume = (*it)->CaptureData(voe_channels,
185 current_buffer->buffer(), 181 current_buffer->buffer(),
186 sample_rate, 182 sample_rate,
187 number_of_channels, 183 number_of_channels,
188 number_of_frames, 184 number_of_frames,
189 audio_delay_milliseconds, 185 audio_delay_milliseconds,
190 current_volume, 186 current_volume,
191 need_audio_processing, 187 need_audio_processing,
192 key_pressed); 188 key_pressed);
193 if (new_volume != 0 && capturer.get()) { 189 if (!disabled && new_volume != 0 && capturer.get()) {
194 // Feed the new volume to WebRtc while changing the volume on the 190 // Feed the new volume to WebRtc while changing the volume on the
195 // browser. 191 // browser.
196 capturer->SetVolume(new_volume); 192 capturer->SetVolume(new_volume);
197 current_volume = new_volume; 193 current_volume = new_volume;
198 } 194 }
199 } 195 }
200 } 196 }
201 } 197 }
202 198
203 void WebRtcLocalAudioTrack::SetCaptureFormat( 199 void WebRtcLocalAudioTrack::SetCaptureFormat(
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 sinks = sinks_; 336 sinks = sinks_;
341 webaudio_source_ = NULL; 337 webaudio_source_ = NULL;
342 capturer_ = NULL; 338 capturer_ = NULL;
343 } 339 }
344 340
345 for (SinkList::const_iterator it = sinks.begin(); it != sinks.end(); ++it) 341 for (SinkList::const_iterator it = sinks.begin(); it != sinks.end(); ++it)
346 (*it)->Reset(); 342 (*it)->Reset();
347 } 343 }
348 344
349 } // namespace content 345 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698