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

Side by Side Diff: content/browser/renderer_host/media/audio_input_device_manager.cc

Issue 99033003: Enable platform echo cancellation through the AudioRecord path. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 7 years 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/browser/renderer_host/media/audio_input_device_manager.h" 5 #include "content/browser/renderer_host/media/audio_input_device_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "content/public/browser/browser_thread.h" 9 #include "content/public/browser/browser_thread.h"
10 #include "content/public/common/media_stream_request.h" 10 #include "content/public/common/media_stream_request.h"
(...skipping 17 matching lines...) Expand all
28 media::AudioManager* audio_manager) 28 media::AudioManager* audio_manager)
29 : listener_(NULL), 29 : listener_(NULL),
30 next_capture_session_id_(kFirstSessionId), 30 next_capture_session_id_(kFirstSessionId),
31 use_fake_device_(false), 31 use_fake_device_(false),
32 audio_manager_(audio_manager) { 32 audio_manager_(audio_manager) {
33 // TODO(xians): Remove this fake_device after the unittests do not need it. 33 // TODO(xians): Remove this fake_device after the unittests do not need it.
34 StreamDeviceInfo fake_device(MEDIA_DEVICE_AUDIO_CAPTURE, 34 StreamDeviceInfo fake_device(MEDIA_DEVICE_AUDIO_CAPTURE,
35 media::AudioManagerBase::kDefaultDeviceName, 35 media::AudioManagerBase::kDefaultDeviceName,
36 media::AudioManagerBase::kDefaultDeviceId, 36 media::AudioManagerBase::kDefaultDeviceId,
37 44100, media::CHANNEL_LAYOUT_STEREO, 37 44100, media::CHANNEL_LAYOUT_STEREO,
38 0); 38 0, false);
39 fake_device.session_id = kFakeOpenSessionId; 39 fake_device.session_id = kFakeOpenSessionId;
40 devices_.push_back(fake_device); 40 devices_.push_back(fake_device);
41 } 41 }
42 42
43 AudioInputDeviceManager::~AudioInputDeviceManager() { 43 AudioInputDeviceManager::~AudioInputDeviceManager() {
44 } 44 }
45 45
46 const StreamDeviceInfo* AudioInputDeviceManager::GetOpenedDeviceInfoById( 46 const StreamDeviceInfo* AudioInputDeviceManager::GetOpenedDeviceInfoById(
47 int session_id) { 47 int session_id) {
48 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 48 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 this, stream_type, base::Passed(&devices))); 163 this, stream_type, base::Passed(&devices)));
164 } 164 }
165 165
166 void AudioInputDeviceManager::OpenOnDeviceThread( 166 void AudioInputDeviceManager::OpenOnDeviceThread(
167 int session_id, const StreamDeviceInfo& info) { 167 int session_id, const StreamDeviceInfo& info) {
168 SCOPED_UMA_HISTOGRAM_TIMER( 168 SCOPED_UMA_HISTOGRAM_TIMER(
169 "Media.AudioInputDeviceManager.OpenOnDeviceThreadTime"); 169 "Media.AudioInputDeviceManager.OpenOnDeviceThreadTime");
170 DCHECK(IsOnDeviceThread()); 170 DCHECK(IsOnDeviceThread());
171 171
172 StreamDeviceInfo out(info.device.type, info.device.name, info.device.id, 172 StreamDeviceInfo out(info.device.type, info.device.name, info.device.id,
173 0, 0, 0); 173 0, 0, 0, false);
174 out.session_id = session_id; 174 out.session_id = session_id;
175 175
176 MediaStreamDevice::AudioDeviceParameters& input_params = out.device.input; 176 MediaStreamDevice::AudioDeviceParameters& input_params = out.device.input;
177 177
178 if (use_fake_device_) { 178 if (use_fake_device_) {
179 // Don't need to query the hardware information if using fake device. 179 // Don't need to query the hardware information if using fake device.
180 input_params.sample_rate = 44100; 180 input_params.sample_rate = 44100;
181 input_params.channel_layout = media::CHANNEL_LAYOUT_STEREO; 181 input_params.channel_layout = media::CHANNEL_LAYOUT_STEREO;
182 } else { 182 } else {
183 // Get the preferred sample rate and channel configuration for the 183 // Get the preferred sample rate and channel configuration for the
184 // audio device. 184 // audio device.
185 media::AudioParameters params = 185 media::AudioParameters params =
186 audio_manager_->GetInputStreamParameters(info.device.id); 186 audio_manager_->GetInputStreamParameters(info.device.id);
187 input_params.sample_rate = params.sample_rate(); 187 input_params.sample_rate = params.sample_rate();
188 input_params.channel_layout = params.channel_layout(); 188 input_params.channel_layout = params.channel_layout();
189 input_params.frames_per_buffer = params.frames_per_buffer(); 189 input_params.frames_per_buffer = params.frames_per_buffer();
190 input_params.use_platform_aec = params.use_platform_aec();
190 191
191 // Add preferred output device information if a matching output device 192 // Add preferred output device information if a matching output device
192 // exists. 193 // exists.
193 out.device.matched_output_device_id = 194 out.device.matched_output_device_id =
194 audio_manager_->GetAssociatedOutputDeviceID(info.device.id); 195 audio_manager_->GetAssociatedOutputDeviceID(info.device.id);
195 if (!out.device.matched_output_device_id.empty()) { 196 if (!out.device.matched_output_device_id.empty()) {
196 params = audio_manager_->GetOutputStreamParameters( 197 params = audio_manager_->GetOutputStreamParameters(
197 out.device.matched_output_device_id); 198 out.device.matched_output_device_id);
198 MediaStreamDevice::AudioDeviceParameters& matched_output_params = 199 MediaStreamDevice::AudioDeviceParameters& matched_output_params =
199 out.device.matched_output; 200 out.device.matched_output;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 for (StreamDeviceList::iterator i(devices_.begin()); i != devices_.end(); 249 for (StreamDeviceList::iterator i(devices_.begin()); i != devices_.end();
249 ++i) { 250 ++i) {
250 if (i->session_id == session_id) 251 if (i->session_id == session_id)
251 return i; 252 return i;
252 } 253 }
253 254
254 return devices_.end(); 255 return devices_.end();
255 } 256 }
256 257
257 } // namespace content 258 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698