Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1239)

Unified Diff: media/base/clock.h

Issue 16823003: Replace erroneous use of base::Time with base::TimeTicks throughout media code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: s/PresubmitPromptWarning/PresubmitPromptOrNotify/ Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/base/audio_renderer_mixer_unittest.cc ('k') | media/base/clock.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/clock.h
diff --git a/media/base/clock.h b/media/base/clock.h
index 267666f668aeefc63682b7dcd4fc0e24ec7d2d14..6a86106c17781a38733f9c6585b67276909582c6 100644
--- a/media/base/clock.h
+++ b/media/base/clock.h
@@ -10,16 +10,16 @@
#include "media/base/media_export.h"
namespace base {
-class Clock;
+class TickClock;
} // namespace base
namespace media {
// A clock represents a single source of time to allow audio and video streams
// to synchronize with each other. Clock essentially tracks the media time with
-// respect to some other source of time, whether that may be the system clock or
-// updates via SetTime(). Clock uses linear interpolation to calculate the
-// current media time since the last time SetTime() was called.
+// respect to some other source of time, whether that may be the monotonic
+// system clock or updates via SetTime(). Clock uses linear interpolation to
+// calculate the current media time since the last time SetTime() was called.
//
// Clocks start off paused with a playback rate of 1.0f and a media time of 0.
//
@@ -28,9 +28,12 @@ namespace media {
// TODO(scherkus): Clock will some day be responsible for executing callbacks
// given a media time. This will be used primarily by video renderers. For now
// we'll keep using a poll-and-sleep solution.
+//
+// TODO(miu): Rename media::Clock to avoid confusion (and tripping up the media
+// PRESUBMIT script on future changes).
class MEDIA_EXPORT Clock {
public:
- explicit Clock(base::Clock* clock);
+ explicit Clock(base::TickClock* clock);
~Clock();
// Returns true if the clock is running.
@@ -88,13 +91,13 @@ class MEDIA_EXPORT Clock {
// the |max_time_| cap.
base::TimeDelta EstimatedElapsedTime();
- // Returns the current media time treating the given time as the latest
- // value as returned by |time_provider_|.
- base::TimeDelta ElapsedViaProvidedTime(const base::Time& time) const;
+ // Translates |time| into the current media time, based on the perspective of
+ // the monotonically-increasing system clock.
+ base::TimeDelta ElapsedViaProvidedTime(const base::TimeTicks& time) const;
base::TimeDelta ClampToValidTimeRange(base::TimeDelta time) const;
- base::Clock* const clock_;
+ base::TickClock* const clock_;
// Whether the clock is running.
bool playing_;
@@ -103,9 +106,9 @@ class MEDIA_EXPORT Clock {
// allowed.
bool underflow_;
- // The system clock time when this clock last starting playing or had its
- // time set via SetTime().
- base::Time reference_;
+ // The monotonic system clock time when this Clock last started playing or had
+ // its time set via SetTime().
+ base::TimeTicks reference_;
// Current accumulated amount of media time. The remaining portion must be
// calculated by comparing the system time to the reference time.
« no previous file with comments | « media/base/audio_renderer_mixer_unittest.cc ('k') | media/base/clock.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698