OLD | NEW |
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_renderer.h" | 5 #include "content/renderer/media/webrtc_local_audio_renderer.h" |
6 | 6 |
7 #include "base/location.h" | 7 #include "base/location.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/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 | 255 |
256 DVLOG(1) << "WebRtcLocalAudioRenderer::ReconfigureSink()"; | 256 DVLOG(1) << "WebRtcLocalAudioRenderer::ReconfigureSink()"; |
257 | 257 |
258 if (source_params_.Equals(params)) | 258 if (source_params_.Equals(params)) |
259 return; | 259 return; |
260 | 260 |
261 // Reset the |source_params_|, |sink_params_| and |loopback_fifo_| to match | 261 // Reset the |source_params_|, |sink_params_| and |loopback_fifo_| to match |
262 // the new format. | 262 // the new format. |
263 | 263 |
264 source_params_ = params; | 264 source_params_ = params; |
265 | 265 sink_params_ = source_params_; |
266 sink_params_ = media::AudioParameters(source_params_.format(), | 266 sink_params_.set_frames_per_buffer(WebRtcAudioRenderer::GetOptimalBufferSize( |
267 source_params_.channel_layout(), source_params_.sample_rate(), | 267 source_params_.sample_rate(), frames_per_buffer_)); |
268 source_params_.bits_per_sample(), | |
269 WebRtcAudioRenderer::GetOptimalBufferSize(source_params_.sample_rate(), | |
270 frames_per_buffer_), | |
271 source_params_.effects()); | |
272 | |
273 { | 268 { |
274 // Note: The max buffer is fairly large, but will rarely be used. | 269 // Note: The max buffer is fairly large, but will rarely be used. |
275 // Cast needs the buffer to hold at least one second of audio. | 270 // Cast needs the buffer to hold at least one second of audio. |
276 // The clock accuracy is set to 20ms because clock accuracy is | 271 // The clock accuracy is set to 20ms because clock accuracy is |
277 // ~15ms on windows. | 272 // ~15ms on windows. |
278 media::AudioShifter* const new_shifter = new media::AudioShifter( | 273 media::AudioShifter* const new_shifter = new media::AudioShifter( |
279 base::TimeDelta::FromSeconds(2), | 274 base::TimeDelta::FromSeconds(2), |
280 base::TimeDelta::FromMilliseconds(20), | 275 base::TimeDelta::FromMilliseconds(20), |
281 base::TimeDelta::FromSeconds(20), | 276 base::TimeDelta::FromSeconds(20), |
282 source_params_.sample_rate(), | 277 source_params_.sample_rate(), |
(...skipping 11 matching lines...) Expand all Loading... |
294 if (sink_started_) { | 289 if (sink_started_) { |
295 sink_->Stop(); | 290 sink_->Stop(); |
296 sink_started_ = false; | 291 sink_started_ = false; |
297 } | 292 } |
298 | 293 |
299 sink_ = AudioDeviceFactory::NewOutputDevice(source_render_frame_id_); | 294 sink_ = AudioDeviceFactory::NewOutputDevice(source_render_frame_id_); |
300 MaybeStartSink(); | 295 MaybeStartSink(); |
301 } | 296 } |
302 | 297 |
303 } // namespace content | 298 } // namespace content |
OLD | NEW |