Index: media/filters/audio_clock.h |
diff --git a/media/filters/audio_clock.h b/media/filters/audio_clock.h |
index 024c7915006d7486613e5c5c7dba8daf2a677749..01c7ca04da5bb98aeabb5d0891446d7127662805 100644 |
--- a/media/filters/audio_clock.h |
+++ b/media/filters/audio_clock.h |
@@ -7,6 +7,7 @@ |
#include <stdint.h> |
+#include <cmath> |
#include <deque> |
#include "base/macros.h" |
@@ -89,8 +90,14 @@ class MEDIA_EXPORT AudioClock { |
// |start_timestamp| since no amount of media frames tracked |
// media data has been played yet. by AudioClock, which would be |
// 1000 + 500 + 250 = 1750 ms. |
- base::TimeDelta front_timestamp() const { return front_timestamp_; } |
- base::TimeDelta back_timestamp() const { return back_timestamp_; } |
+ base::TimeDelta front_timestamp() const { |
+ return base::TimeDelta::FromMicroseconds( |
+ std::round(front_timestamp_micros_)); |
+ } |
+ base::TimeDelta back_timestamp() const { |
+ return base::TimeDelta::FromMicroseconds( |
+ std::round(back_timestamp_micros_)); |
+ } |
// Returns the amount of wall time until |timestamp| will be played by the |
// audio hardware. |
@@ -117,7 +124,7 @@ class MEDIA_EXPORT AudioClock { |
// Helpers for operating on |buffered_|. |
void PushBufferedAudioData(int64_t frames, double playback_rate); |
void PopBufferedAudioData(int64_t frames); |
- base::TimeDelta ComputeBufferedMediaDuration() const; |
+ double ComputeBufferedMediaDurationMicros() const; |
const base::TimeDelta start_timestamp_; |
const double microseconds_per_frame_; |
@@ -125,8 +132,13 @@ class MEDIA_EXPORT AudioClock { |
std::deque<AudioData> buffered_; |
int64_t total_buffered_frames_; |
- base::TimeDelta front_timestamp_; |
- base::TimeDelta back_timestamp_; |
+ // Use double rather than TimeDelta to avoid loss of partial microseconds when |
+ // converting between frames-written/delayed and time-passed (see WroteAudio). |
DaleCurtis
2016/02/18 01:48:33
WroteAudio().
chcunningham
2016/02/18 20:43:37
Done.
|
+ // Particularly for back_timestamp,which accumulates more time with each call |
DaleCurtis
2016/02/18 01:48:33
Use || around variable names and space after ","
chcunningham
2016/02/18 20:43:37
Done.
|
+ // to WroteAudio, the loss of precision can accumulate to create noticeable |
DaleCurtis
2016/02/18 01:48:33
WroteAudio()
chcunningham
2016/02/18 20:43:37
Done.
|
+ // audio/video sync drift for longer (2-3 hr) videos. http://crbug.com/564604 |
+ double front_timestamp_micros_; |
+ double back_timestamp_micros_; |
DISALLOW_COPY_AND_ASSIGN(AudioClock); |
}; |