| Index: media/filters/audio_clock.cc
|
| diff --git a/media/filters/audio_clock.cc b/media/filters/audio_clock.cc
|
| index aebc5e55befef998107d99392bb5edfac6a798e4..d93db1df2ce7c718dbe333a327f8cf11fcbd14d5 100644
|
| --- a/media/filters/audio_clock.cc
|
| +++ b/media/filters/audio_clock.cc
|
| @@ -36,7 +36,7 @@ void AudioClock::WroteAudio(int frames_written,
|
|
|
| // First write: initialize buffer with silence.
|
| if (start_timestamp_ == front_timestamp_ && buffered_.empty())
|
| - PushBufferedAudioData(delay_frames, 0.0f);
|
| + PushBufferedAudioData(delay_frames, 0.0);
|
|
|
| // Move frames from |buffered_| into the computed timestamp based on
|
| // |delay_frames|.
|
| @@ -47,7 +47,7 @@ void AudioClock::WroteAudio(int frames_written,
|
| std::max(INT64_C(0), total_buffered_frames_ - delay_frames);
|
| front_timestamp_ += ComputeBufferedMediaTime(frames_played);
|
| PushBufferedAudioData(frames_written, playback_rate);
|
| - PushBufferedAudioData(frames_requested - frames_written, 0.0f);
|
| + PushBufferedAudioData(frames_requested - frames_written, 0.0);
|
| PopBufferedAudioData(frames_played);
|
|
|
| back_timestamp_ += base::TimeDelta::FromMicroseconds(
|
| @@ -80,6 +80,23 @@ void AudioClock::WroteAudio(int frames_written,
|
| microseconds_per_frame_);
|
| }
|
|
|
| +void AudioClock::CompensateForSuspendedWrites(base::TimeDelta elapsed,
|
| + int delay_frames) {
|
| + const int64_t frames_elapsed =
|
| + elapsed.InMicroseconds() / microseconds_per_frame_ + 0.5;
|
| +
|
| + // No need to do anything if we're within the limits of our played out audio
|
| + // or there are no delay frames, the next WroteAudio() call will expire
|
| + // everything correctly.
|
| + if (frames_elapsed < total_buffered_frames_ || !delay_frames)
|
| + return;
|
| +
|
| + // Otherwise, flush everything and prime with the delay frames.
|
| + WroteAudio(0, 0, 0, 0);
|
| + DCHECK(buffered_.empty());
|
| + PushBufferedAudioData(delay_frames, 0.0);
|
| +}
|
| +
|
| base::TimeDelta AudioClock::TimeUntilPlayback(base::TimeDelta timestamp) const {
|
| DCHECK_GE(timestamp, front_timestamp_);
|
| DCHECK_LE(timestamp, back_timestamp_);
|
|
|