Chromium Code Reviews| Index: media/audio/audio_output_controller.cc |
| diff --git a/media/audio/audio_output_controller.cc b/media/audio/audio_output_controller.cc |
| index 9b8f52387d8e7a4f638d73c7d1127ae2a2f394e2..80d6a71bfb942a57b10795caee0b750687925cd3 100644 |
| --- a/media/audio/audio_output_controller.cc |
| +++ b/media/audio/audio_output_controller.cc |
| @@ -6,6 +6,7 @@ |
| #include <stdint.h> |
| +#include <algorithm> |
| #include <limits> |
| #include "base/bind.h" |
| @@ -292,9 +293,9 @@ void AudioOutputController::DoReportError() { |
| handler_->OnError(); |
| } |
| -int AudioOutputController::OnMoreData(AudioBus* dest, |
| - uint32_t total_bytes_delay, |
| - uint32_t frames_skipped) { |
| +int AudioOutputController::OnMoreData(base::TimeTicks target_playout_time, |
| + int prior_frames_skipped, |
| + AudioBus* dest) { |
| TRACE_EVENT0("audio", "AudioOutputController::OnMoreData"); |
| // Indicate that we haven't wedged (at least not indefinitely, WedgeCheck() |
| @@ -306,9 +307,12 @@ int AudioOutputController::OnMoreData(AudioBus* dest, |
| sync_reader_->Read(dest); |
| + const base::TimeDelta delay = target_playout_time - base::TimeTicks::Now(); |
|
DaleCurtis
2016/07/27 18:25:55
Hmm, if you don't pipe this through to the rendere
jameswest
2016/07/27 23:07:50
We don't use this renderer for Cast multizone audi
DaleCurtis
2016/07/28 01:21:47
I thought this API was still used with WebAudio? O
jameswest
2016/07/28 02:09:39
It's not used for multizone audio playback, but I
chcunningham
2016/07/29 01:21:09
Should we be gaurding against negative values here
miu
2016/07/30 21:17:02
If negative delay creeps in, for output streams wh
jameswest
2016/08/26 02:08:47
There are some cases where the delay will be negat
chcunningham
2016/08/27 00:36:18
I'm fine with either approach. I slightly favor th
|
| + const int total_bytes_delay = delay.InSeconds() * params_.GetBytesPerSecond(); |
| const int frames = dest->frames(); |
| sync_reader_->UpdatePendingBytes( |
| - total_bytes_delay + frames * params_.GetBytesPerFrame(), frames_skipped); |
| + total_bytes_delay + frames * params_.GetBytesPerFrame(), |
| + prior_frames_skipped); |
| bool need_to_duplicate = false; |
| { |
| @@ -316,17 +320,12 @@ int AudioOutputController::OnMoreData(AudioBus* dest, |
| need_to_duplicate = !duplication_targets_.empty(); |
| } |
| if (need_to_duplicate) { |
| - const base::TimeTicks reference_time = |
| - base::TimeTicks::Now() + |
| - base::TimeDelta::FromMicroseconds(base::Time::kMicrosecondsPerSecond * |
| - total_bytes_delay / |
| - params_.GetBytesPerSecond()); |
| std::unique_ptr<AudioBus> copy(AudioBus::Create(params_)); |
| dest->CopyTo(copy.get()); |
| message_loop_->PostTask( |
| FROM_HERE, |
| base::Bind(&AudioOutputController::BroadcastDataToDuplicationTargets, |
| - this, base::Passed(©), reference_time)); |
| + this, base::Passed(©), target_playout_time)); |
| } |
| if (will_monitor_audio_levels()) |