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

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

Issue 12662038: Revert 187936 "Pass more detailed audio hardware configuration i..." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1440/src/
Patch Set: Created 7 years, 9 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 } else if (sample_rate == 44100) { 151 } else if (sample_rate == 44100) {
152 // The resampler in WebRTC does not support 441 as input. We hard code 152 // The resampler in WebRTC does not support 441 as input. We hard code
153 // the size to 440 (~0.9977ms) instead and rely on the internal jitter 153 // the size to 440 (~0.9977ms) instead and rely on the internal jitter
154 // buffer in WebRTC to deal with the resulting drift. 154 // buffer in WebRTC to deal with the resulting drift.
155 // TODO(henrika): ensure that WebRTC supports 44100Hz and use 441 instead. 155 // TODO(henrika): ensure that WebRTC supports 44100Hz and use 441 instead.
156 buffer_size = 440; 156 buffer_size = 440;
157 } else { 157 } else {
158 return false; 158 return false;
159 } 159 }
160 160
161 int channels = ChannelLayoutToChannelCount(channel_layout);
162 source_params.Reset(media::AudioParameters::AUDIO_PCM_LOW_LATENCY, 161 source_params.Reset(media::AudioParameters::AUDIO_PCM_LOW_LATENCY,
163 channel_layout, channels, 0, 162 channel_layout, 0, sample_rate, 16, buffer_size);
164 sample_rate, 16, buffer_size);
165 163
166 // Set up audio parameters for the sink, i.e., the native audio output stream. 164 // Set up audio parameters for the sink, i.e., the native audio output stream.
167 // We strive to open up using native parameters to achieve best possible 165 // We strive to open up using native parameters to achieve best possible
168 // performance and to ensure that no FIFO is needed on the browser side to 166 // performance and to ensure that no FIFO is needed on the browser side to
169 // match the client request. Any mismatch between the source and the sink is 167 // match the client request. Any mismatch between the source and the sink is
170 // taken care of in this class instead using a pull FIFO. 168 // taken care of in this class instead using a pull FIFO.
171 169
172 media::AudioParameters sink_params; 170 media::AudioParameters sink_params;
173 171
174 buffer_size = hardware_config->GetOutputBufferSize(); 172 buffer_size = hardware_config->GetOutputBufferSize();
175 sink_params.Reset(media::AudioParameters::AUDIO_PCM_LOW_LATENCY, 173 sink_params.Reset(media::AudioParameters::AUDIO_PCM_LOW_LATENCY,
176 channel_layout, channels, 0, sample_rate, 16, buffer_size); 174 channel_layout, 0, sample_rate, 16, buffer_size);
177 175
178 // Create a FIFO if re-buffering is required to match the source input with 176 // Create a FIFO if re-buffering is required to match the source input with
179 // the sink request. The source acts as provider here and the sink as 177 // the sink request. The source acts as provider here and the sink as
180 // consumer. 178 // consumer.
181 if (source_params.frames_per_buffer() != sink_params.frames_per_buffer()) { 179 if (source_params.frames_per_buffer() != sink_params.frames_per_buffer()) {
182 DVLOG(1) << "Rebuffering from " << source_params.frames_per_buffer() 180 DVLOG(1) << "Rebuffering from " << source_params.frames_per_buffer()
183 << " to " << sink_params.frames_per_buffer(); 181 << " to " << sink_params.frames_per_buffer();
184 audio_fifo_.reset(new media::AudioPullFifo( 182 audio_fifo_.reset(new media::AudioPullFifo(
185 source_params.channels(), 183 source_params.channels(),
186 source_params.frames_per_buffer(), 184 source_params.frames_per_buffer(),
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 } 344 }
347 345
348 // De-interleave each channel and convert to 32-bit floating-point 346 // De-interleave each channel and convert to 32-bit floating-point
349 // with nominal range -1.0 -> +1.0 to match the callback format. 347 // with nominal range -1.0 -> +1.0 to match the callback format.
350 audio_bus->FromInterleaved(buffer_.get(), 348 audio_bus->FromInterleaved(buffer_.get(),
351 audio_bus->frames(), 349 audio_bus->frames(),
352 sizeof(buffer_[0])); 350 sizeof(buffer_[0]));
353 } 351 }
354 352
355 } // namespace content 353 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/webrtc_audio_device_unittest.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