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

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

Issue 11878032: Plumb |input_channels| all the way to AudioManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 10 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 | Annotate | Revision Log
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_audio_capturer.h" 5 #include "content/renderer/media/webrtc_audio_capturer.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 &kValidInputRates[0] + arraysize(kValidInputRates), 94 &kValidInputRates[0] + arraysize(kValidInputRates),
95 sample_rate) == 95 sample_rate) ==
96 &kValidInputRates[arraysize(kValidInputRates)]) { 96 &kValidInputRates[arraysize(kValidInputRates)]) {
97 DLOG(ERROR) << sample_rate << " is not a supported input rate."; 97 DLOG(ERROR) << sample_rate << " is not a supported input rate.";
98 return false; 98 return false;
99 } 99 }
100 100
101 int buffer_size = GetBufferSizeForSampleRate(sample_rate); 101 int buffer_size = GetBufferSizeForSampleRate(sample_rate);
102 102
103 // Configure audio parameters for the default source. 103 // Configure audio parameters for the default source.
104 params_.Reset(format, channel_layout, sample_rate, 16, buffer_size); 104 params_.Reset(format, channel_layout, 0, sample_rate, 16, buffer_size);
105 105
106 // Tell all sinks which format we use. 106 // Tell all sinks which format we use.
107 for (SinkList::const_iterator it = sinks_.begin(); 107 for (SinkList::const_iterator it = sinks_.begin();
108 it != sinks_.end(); ++it) { 108 it != sinks_.end(); ++it) {
109 (*it)->SetCaptureFormat(params_); 109 (*it)->SetCaptureFormat(params_);
110 } 110 }
111 111
112 buffer_.reset(new int16[params_.frames_per_buffer() * params_.channels()]); 112 buffer_.reset(new int16[params_.frames_per_buffer() * params_.channels()]);
113 113
114 // Create and configure the default audio capturing source. The |source_| 114 // Create and configure the default audio capturing source. The |source_|
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 // which would normally be used by default. 187 // which would normally be used by default.
188 188
189 int buffer_size = GetBufferSizeForSampleRate(sample_rate); 189 int buffer_size = GetBufferSizeForSampleRate(sample_rate);
190 if (!buffer_size) { 190 if (!buffer_size) {
191 DLOG(ERROR) << "Unsupported sample-rate: " << sample_rate; 191 DLOG(ERROR) << "Unsupported sample-rate: " << sample_rate;
192 return; 192 return;
193 } 193 }
194 194
195 params_.Reset(params_.format(), 195 params_.Reset(params_.format(),
196 channel_layout, 196 channel_layout,
197 0,
197 sample_rate, 198 sample_rate,
198 16, // ignored since the audio stack uses float32. 199 16, // ignored since the audio stack uses float32.
199 buffer_size); 200 buffer_size);
200 201
201 buffer_.reset(new int16[params_.frames_per_buffer() * params_.channels()]); 202 buffer_.reset(new int16[params_.frames_per_buffer() * params_.channels()]);
202 203
203 for (SinkList::const_iterator it = sinks_.begin(); 204 for (SinkList::const_iterator it = sinks_.begin();
204 it != sinks_.end(); ++it) { 205 it != sinks_.end(); ++it) {
205 (*it)->SetCaptureFormat(params_); 206 (*it)->SetCaptureFormat(params_);
206 } 207 }
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 // Inform the local renderer about the stopped device. 418 // Inform the local renderer about the stopped device.
418 // The renderer can then save resources by not asking for more data from 419 // The renderer can then save resources by not asking for more data from
419 // the stopped source. We are on the IO thread but the callback task will 420 // the stopped source. We are on the IO thread but the callback task will
420 // be posted on the message loop of the main render thread thanks to 421 // be posted on the message loop of the main render thread thanks to
421 // usage of BindToLoop() when the callback was initialized. 422 // usage of BindToLoop() when the callback was initialized.
422 if (!on_device_stopped_cb_.is_null()) 423 if (!on_device_stopped_cb_.is_null())
423 on_device_stopped_cb_.Run(); 424 on_device_stopped_cb_.Run();
424 } 425 }
425 426
426 } // namespace content 427 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/renderer_webaudiodevice_impl.cc ('k') | content/renderer/media/webrtc_audio_renderer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698