Chromium Code Reviews| Index: media/audio/audio_output_resampler.cc |
| diff --git a/media/audio/audio_output_resampler.cc b/media/audio/audio_output_resampler.cc |
| index c643b3e672c24ed086c07bf5d19262d396b66697..01ffbcdcf98b40224ec302e587e5583215929a7d 100644 |
| --- a/media/audio/audio_output_resampler.cc |
| +++ b/media/audio/audio_output_resampler.cc |
| @@ -6,6 +6,9 @@ |
| #include <stdint.h> |
| +#include <algorithm> |
| +#include <string> |
| + |
| #include "base/bind.h" |
| #include "base/bind_helpers.h" |
| #include "base/compiler_specific.h" |
| @@ -31,9 +34,9 @@ class OnMoreDataConverter |
| ~OnMoreDataConverter() override; |
| // AudioSourceCallback interface. |
| - int OnMoreData(AudioBus* dest, |
| - uint32_t total_bytes_delay, |
| - uint32_t frames_skipped) override; |
| + int OnMoreData(base::TimeTicks target_playout_time, |
| + int prior_frames_skipped, |
| + AudioBus* dest) override; |
| void OnError(AudioOutputStream* stream) override; |
| // Sets |source_callback_|. If this is not a new object, then Stop() must be |
| @@ -58,9 +61,9 @@ class OnMoreDataConverter |
| // Source callback. |
| AudioOutputStream::AudioSourceCallback* source_callback_; |
| - // Last |total_bytes_delay| received via OnMoreData(), used to correct |
| - // playback delay by ProvideInput() and passed on to |source_callback_|. |
| - uint32_t current_total_bytes_delay_; |
| + // Last |target_playout_time| received via OnMoreData() and passed on to |
| + // |source_callback_|. |
| + base::TimeTicks target_playout_time_; |
| const int input_bytes_per_frame_; |
| @@ -373,10 +376,10 @@ void OnMoreDataConverter::Stop() { |
| audio_converter_.RemoveInput(this); |
| } |
| -int OnMoreDataConverter::OnMoreData(AudioBus* dest, |
| - uint32_t total_bytes_delay, |
| - uint32_t frames_skipped) { |
| - current_total_bytes_delay_ = total_bytes_delay; |
| +int OnMoreDataConverter::OnMoreData(base::TimeTicks target_playout_time, |
| + int /* prior_frames_skipped */, |
| + AudioBus* dest) { |
| + target_playout_time_ = target_playout_time; |
| audio_converter_.Convert(dest); |
| // Always return the full number of frames requested, ProvideInput() |
| @@ -386,16 +389,9 @@ int OnMoreDataConverter::OnMoreData(AudioBus* dest, |
| double OnMoreDataConverter::ProvideInput(AudioBus* dest, |
| uint32_t frames_delayed) { |
| - // Adjust playback delay to include |frames_delayed|. |
| - // TODO(dalecurtis): Stop passing bytes around, it doesn't make sense since |
|
chcunningham
2016/07/29 01:21:09
Why is it ok for you to just drop frames_delayed?
jameswest
2016/08/26 02:08:47
Done.
|
| - // AudioBus is just float data. Use TimeDelta instead. |
| - uint32_t new_total_bytes_delay = base::saturated_cast<uint32_t>( |
| - io_ratio_ * |
| - (current_total_bytes_delay_ + frames_delayed * input_bytes_per_frame_)); |
| - |
| // Retrieve data from the original callback. |
| const int frames = |
| - source_callback_->OnMoreData(dest, new_total_bytes_delay, 0); |
| + source_callback_->OnMoreData(target_playout_time_, 0, dest); |
| // Zero any unfilled frames if anything was filled, otherwise we'll just |
| // return a volume of zero and let AudioConverter drop the output. |