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

Side by Side Diff: content/renderer/media/webrtc_audio_renderer.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_renderer.h" 5 #include "content/renderer/media/webrtc_audio_renderer.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "content/renderer/media/audio_device_factory.h" 10 #include "content/renderer/media/audio_device_factory.h"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 // The resampler in WebRTC does not support 441 as input. We hard code 150 // The resampler in WebRTC does not support 441 as input. We hard code
151 // the size to 440 (~0.9977ms) instead and rely on the internal jitter 151 // the size to 440 (~0.9977ms) instead and rely on the internal jitter
152 // buffer in WebRTC to deal with the resulting drift. 152 // buffer in WebRTC to deal with the resulting drift.
153 // TODO(henrika): ensure that WebRTC supports 44100Hz and use 441 instead. 153 // TODO(henrika): ensure that WebRTC supports 44100Hz and use 441 instead.
154 buffer_size = 440; 154 buffer_size = 440;
155 } else { 155 } else {
156 return false; 156 return false;
157 } 157 }
158 158
159 source_params.Reset(media::AudioParameters::AUDIO_PCM_LOW_LATENCY, 159 source_params.Reset(media::AudioParameters::AUDIO_PCM_LOW_LATENCY,
160 channel_layout, sample_rate, 16, buffer_size); 160 channel_layout, 0, sample_rate, 16, buffer_size);
161 161
162 // Set up audio parameters for the sink, i.e., the native audio output stream. 162 // Set up audio parameters for the sink, i.e., the native audio output stream.
163 // We strive to open up using native parameters to achieve best possible 163 // We strive to open up using native parameters to achieve best possible
164 // performance and to ensure that no FIFO is needed on the browser side to 164 // performance and to ensure that no FIFO is needed on the browser side to
165 // match the client request. Any mismatch between the source and the sink is 165 // match the client request. Any mismatch between the source and the sink is
166 // taken care of in this class instead using a pull FIFO. 166 // taken care of in this class instead using a pull FIFO.
167 167
168 media::AudioParameters sink_params; 168 media::AudioParameters sink_params;
169 169
170 buffer_size = hardware_config->GetOutputBufferSize(); 170 buffer_size = hardware_config->GetOutputBufferSize();
171 sink_params.Reset(media::AudioParameters::AUDIO_PCM_LOW_LATENCY, 171 sink_params.Reset(media::AudioParameters::AUDIO_PCM_LOW_LATENCY,
172 channel_layout, sample_rate, 16, buffer_size); 172 channel_layout, 0, sample_rate, 16, buffer_size);
173 173
174 // Create a FIFO if re-buffering is required to match the source input with 174 // Create a FIFO if re-buffering is required to match the source input with
175 // the sink request. The source acts as provider here and the sink as 175 // the sink request. The source acts as provider here and the sink as
176 // consumer. 176 // consumer.
177 if (source_params.frames_per_buffer() != sink_params.frames_per_buffer()) { 177 if (source_params.frames_per_buffer() != sink_params.frames_per_buffer()) {
178 DVLOG(1) << "Rebuffering from " << source_params.frames_per_buffer() 178 DVLOG(1) << "Rebuffering from " << source_params.frames_per_buffer()
179 << " to " << sink_params.frames_per_buffer(); 179 << " to " << sink_params.frames_per_buffer();
180 audio_fifo_.reset(new media::AudioPullFifo( 180 audio_fifo_.reset(new media::AudioPullFifo(
181 source_params.channels(), 181 source_params.channels(),
182 source_params.frames_per_buffer(), 182 source_params.frames_per_buffer(),
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 } 342 }
343 343
344 // De-interleave each channel and convert to 32-bit floating-point 344 // De-interleave each channel and convert to 32-bit floating-point
345 // with nominal range -1.0 -> +1.0 to match the callback format. 345 // with nominal range -1.0 -> +1.0 to match the callback format.
346 audio_bus->FromInterleaved(buffer_.get(), 346 audio_bus->FromInterleaved(buffer_.get(),
347 audio_bus->frames(), 347 audio_bus->frames(),
348 sizeof(buffer_[0])); 348 sizeof(buffer_[0]));
349 } 349 }
350 350
351 } // namespace content 351 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/webrtc_audio_capturer.cc ('k') | content/renderer/pepper/pepper_platform_audio_input_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698