Chromium Code Reviews| 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_audio_renderer.h" | 5 #include "content/renderer/media/webrtc_audio_renderer.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 395 source_->AudioRendererThreadStopped(); | 395 source_->AudioRendererThreadStopped(); |
| 396 } | 396 } |
| 397 PrepareSink(); | 397 PrepareSink(); |
| 398 sink_->Start(); | 398 sink_->Start(); |
| 399 sink_->Play(); // Not all the sinks play on start. | 399 sink_->Play(); // Not all the sinks play on start. |
| 400 | 400 |
| 401 callback.Run(media::OUTPUT_DEVICE_STATUS_OK); | 401 callback.Run(media::OUTPUT_DEVICE_STATUS_OK); |
| 402 } | 402 } |
| 403 | 403 |
| 404 int WebRtcAudioRenderer::Render(media::AudioBus* audio_bus, | 404 int WebRtcAudioRenderer::Render(media::AudioBus* audio_bus, |
| 405 uint32_t frames_delayed, | 405 base::TimeDelta delay, |
| 406 base::TimeTicks delay_timestamp, | |
| 406 uint32_t frames_skipped) { | 407 uint32_t frames_skipped) { |
| 407 DCHECK(sink_->CurrentThreadIsRenderingThread()); | 408 DCHECK(sink_->CurrentThreadIsRenderingThread()); |
| 408 base::AutoLock auto_lock(lock_); | 409 base::AutoLock auto_lock(lock_); |
| 409 if (!source_) | 410 if (!source_) |
| 410 return 0; | 411 return 0; |
| 411 | 412 |
| 412 // TODO(grunell): Converting from frames to milliseconds will potentially lose | 413 // TODO(grunell): Using of milliseconds will potentially lose |
|
James West
2016/10/21 19:40:17
"Using of milliseconds" => "Using milliseconds"
| |
| 413 // hundreds of microseconds which may cause audio video drift. Update | 414 // hundreds of microseconds which may cause audio video drift. Update |
| 414 // this class and all usage of render delay msec -> frames (possibly even | 415 // this class and all usage of render delay msec -> frames (possibly even |
| 415 // using a double type for frames). See http://crbug.com/586540 | 416 // using a double type for frames). See http://crbug.com/586540 |
| 416 uint32_t audio_delay_milliseconds = static_cast<double>(frames_delayed) * | 417 int64_t audio_delay_milliseconds = delay.InMilliseconds(); |
|
miu
2016/10/23 01:19:15
No need to create a local variable here. Just assi
Mikhail
2016/10/24 19:50:23
Done.
miu
2016/10/24 22:45:52
Thanks for the "bonus" change! :)
| |
| 417 base::Time::kMillisecondsPerSecond / | |
| 418 sink_params_.sample_rate(); | |
| 419 | 418 |
| 420 DVLOG(2) << "WebRtcAudioRenderer::Render()"; | 419 DVLOG(2) << "WebRtcAudioRenderer::Render()"; |
| 421 DVLOG(2) << "audio_delay_milliseconds: " << audio_delay_milliseconds; | 420 DVLOG(2) << "audio_delay_milliseconds: " << audio_delay_milliseconds; |
| 422 | 421 |
| 423 DCHECK_LE(audio_delay_milliseconds, static_cast<uint32_t>(INT_MAX)); | 422 DCHECK_LE(audio_delay_milliseconds, static_cast<uint32_t>(INT_MAX)); |
| 424 audio_delay_milliseconds_ = static_cast<int>(audio_delay_milliseconds); | 423 audio_delay_milliseconds_ = static_cast<int>(audio_delay_milliseconds); |
| 425 | 424 |
| 426 // If there are skipped frames, pull and throw away the same amount. We always | 425 // If there are skipped frames, pull and throw away the same amount. We always |
| 427 // pull 10 ms of data from the source (see PrepareSink()), so the fifo is only | 426 // pull 10 ms of data from the source (see PrepareSink()), so the fifo is only |
| 428 // required if the number of frames to drop doesn't correspond to 10 ms. | 427 // required if the number of frames to drop doesn't correspond to 10 ms. |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 668 sink_params_ = new_sink_params; | 667 sink_params_ = new_sink_params; |
| 669 } | 668 } |
| 670 | 669 |
| 671 // Specify the latency info to be passed to the browser side. | 670 // Specify the latency info to be passed to the browser side. |
| 672 new_sink_params.set_latency_tag(AudioDeviceFactory::GetSourceLatencyType( | 671 new_sink_params.set_latency_tag(AudioDeviceFactory::GetSourceLatencyType( |
| 673 AudioDeviceFactory::AudioDeviceFactory::kSourceWebRtc)); | 672 AudioDeviceFactory::AudioDeviceFactory::kSourceWebRtc)); |
| 674 sink_->Initialize(new_sink_params, this); | 673 sink_->Initialize(new_sink_params, this); |
| 675 } | 674 } |
| 676 | 675 |
| 677 } // namespace content | 676 } // namespace content |
| OLD | NEW |