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

Unified Diff: media/base/wall_clock_time_source.cc

Issue 2237243002: CL for perf tryjob on linux (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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/wall_clock_time_source.h ('k') | media/base/wall_clock_time_source_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/wall_clock_time_source.cc
diff --git a/media/base/wall_clock_time_source.cc b/media/base/wall_clock_time_source.cc
index 16a1a30fbbe5be784b9963965290d74e2aceadba..08429fdf8fc7db9257bbf56e6652429c95ffa57e 100644
--- a/media/base/wall_clock_time_source.cc
+++ b/media/base/wall_clock_time_source.cc
@@ -27,9 +27,8 @@ void WallClockTimeSource::StopTicking() {
DVLOG(1) << __func__;
base::AutoLock auto_lock(lock_);
DCHECK(ticking_);
- base_timestamp_ = CurrentMediaTime_Locked();
+ base_timestamp_ = CurrentMediaTime_Locked(&reference_time_);
ticking_ = false;
- reference_time_ = tick_clock_->NowTicks();
}
void WallClockTimeSource::SetPlaybackRate(double playback_rate) {
@@ -38,8 +37,7 @@ void WallClockTimeSource::SetPlaybackRate(double playback_rate) {
// Estimate current media time using old rate to use as a new base time for
// the new rate.
if (ticking_) {
- base_timestamp_ = CurrentMediaTime_Locked();
- reference_time_ = tick_clock_->NowTicks();
+ base_timestamp_ = CurrentMediaTime_Locked(&reference_time_);
}
playback_rate_ = playback_rate;
@@ -52,9 +50,10 @@ void WallClockTimeSource::SetMediaTime(base::TimeDelta time) {
base_timestamp_ = time;
}
-base::TimeDelta WallClockTimeSource::CurrentMediaTime() {
+base::TimeDelta WallClockTimeSource::CurrentMediaTime(
+ base::TimeTicks* reference) {
base::AutoLock auto_lock(lock_);
- return CurrentMediaTime_Locked();
+ return CurrentMediaTime_Locked(reference);
}
bool WallClockTimeSource::GetWallClockTimes(
@@ -80,15 +79,23 @@ bool WallClockTimeSource::GetWallClockTimes(
return playback_rate_ && ticking_;
}
-base::TimeDelta WallClockTimeSource::CurrentMediaTime_Locked() {
+base::TimeDelta WallClockTimeSource::CurrentMediaTime_Locked(
+ base::TimeTicks* reference) {
lock_.AssertAcquired();
- if (!ticking_ || !playback_rate_)
- return base_timestamp_;
- base::TimeTicks now = tick_clock_->NowTicks();
- return base_timestamp_ +
- base::TimeDelta::FromMicroseconds(
- (now - reference_time_).InMicroseconds() * playback_rate_);
+ base::TimeTicks now_ticks;
+ base::TimeDelta media_time = base_timestamp_;
+ if (ticking_ && playback_rate_) {
+ now_ticks = tick_clock_->NowTicks();
+ media_time += base::TimeDelta::FromMicroseconds(
+ (now_ticks - reference_time_).InMicroseconds() * playback_rate_);
+ }
+
+ if (reference) {
+ *reference = now_ticks.is_null() ? tick_clock_->NowTicks() : now_ticks;
+ }
+
+ return media_time;
}
} // namespace media
« no previous file with comments | « media/base/wall_clock_time_source.h ('k') | media/base/wall_clock_time_source_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698