Index: media/base/time_delta_interpolator.cc |
diff --git a/media/base/clock.cc b/media/base/time_delta_interpolator.cc |
similarity index 55% |
rename from media/base/clock.cc |
rename to media/base/time_delta_interpolator.cc |
index 2c21267b0df3ae38e9e5c75591c39f21d3902792..87457172279c5231a44e40749bd64583cb2d3464 100644 |
--- a/media/base/clock.cc |
+++ b/media/base/time_delta_interpolator.cc |
@@ -2,7 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "media/base/clock.h" |
+#include "media/base/time_delta_interpolator.h" |
#include <algorithm> |
@@ -12,41 +12,38 @@ |
namespace media { |
-Clock::Clock(base::TickClock* clock) |
- : clock_(clock), |
- playing_(false), |
+TimeDeltaInterpolator::TimeDeltaInterpolator(base::TickClock* tick_clock) |
+ : tick_clock_(tick_clock), |
+ interpolating_(false), |
underflow_(false), |
playback_rate_(1.0f), |
max_time_(kNoTimestamp()) { |
- DCHECK(clock_); |
+ DCHECK(tick_clock_); |
} |
-Clock::~Clock() {} |
+TimeDeltaInterpolator::~TimeDeltaInterpolator() {} |
-bool Clock::IsPlaying() const { |
- return playing_; |
-} |
- |
-base::TimeDelta Clock::Play() { |
- DCHECK(!playing_); |
+base::TimeDelta TimeDeltaInterpolator::StartInterpolating() { |
+ DCHECK(!interpolating_); |
UpdateReferencePoints(); |
- playing_ = true; |
+ interpolating_ = true; |
return media_time_; |
} |
-base::TimeDelta Clock::Pause() { |
- DCHECK(playing_); |
+base::TimeDelta TimeDeltaInterpolator::StopInterpolating() { |
+ DCHECK(interpolating_); |
UpdateReferencePoints(); |
- playing_ = false; |
+ interpolating_ = false; |
return media_time_; |
} |
-void Clock::SetPlaybackRate(float playback_rate) { |
+void TimeDeltaInterpolator::SetPlaybackRate(float playback_rate) { |
UpdateReferencePoints(); |
playback_rate_ = playback_rate; |
} |
-void Clock::SetTime(base::TimeDelta current_time, base::TimeDelta max_time) { |
+void TimeDeltaInterpolator::SetTime(base::TimeDelta current_time, |
+ base::TimeDelta max_time) { |
DCHECK(current_time <= max_time); |
DCHECK(current_time != kNoTimestamp()); |
@@ -55,9 +52,9 @@ void Clock::SetTime(base::TimeDelta current_time, base::TimeDelta max_time) { |
underflow_ = false; |
} |
-base::TimeDelta Clock::Elapsed() { |
+base::TimeDelta TimeDeltaInterpolator::GetInterpolatedTime() { |
// The clock is not advancing, so return the last recorded time. |
- if (!playing_ || underflow_) |
+ if (!interpolating_ || underflow_) |
acolwell GONE FROM CHROMIUM
2014/07/09 00:42:46
hmm.. seems like we should merge these into a sing
scherkus (not reviewing)
2014/07/09 01:54:32
I noticed the same thing but wanted to keep this C
|
return media_time_; |
base::TimeDelta elapsed = EstimatedElapsedTime(); |
@@ -70,7 +67,7 @@ base::TimeDelta Clock::Elapsed() { |
return elapsed; |
} |
-void Clock::SetMaxTime(base::TimeDelta max_time) { |
+void TimeDeltaInterpolator::SetMaxTime(base::TimeDelta max_time) { |
DCHECK(max_time != kNoTimestamp()); |
UpdateReferencePoints(); |
@@ -81,7 +78,7 @@ void Clock::SetMaxTime(base::TimeDelta max_time) { |
media_time_ = max_time_; |
} |
-base::TimeDelta Clock::ElapsedViaProvidedTime( |
+base::TimeDelta TimeDeltaInterpolator::ElapsedViaProvidedTime( |
const base::TimeTicks& time) const { |
// TODO(scherkus): floating point badness scaling time by playback rate. |
int64 now_us = (time - reference_).InMicroseconds(); |
@@ -89,21 +86,23 @@ base::TimeDelta Clock::ElapsedViaProvidedTime( |
return media_time_ + base::TimeDelta::FromMicroseconds(now_us); |
} |
-base::TimeDelta Clock::ClampToValidTimeRange(base::TimeDelta time) const { |
+base::TimeDelta TimeDeltaInterpolator::ClampToValidTimeRange( |
+ base::TimeDelta time) const { |
return std::max(base::TimeDelta(), time); |
} |
-void Clock::UpdateReferencePoints() { |
- UpdateReferencePoints(Elapsed()); |
+void TimeDeltaInterpolator::UpdateReferencePoints() { |
+ UpdateReferencePoints(GetInterpolatedTime()); |
} |
-void Clock::UpdateReferencePoints(base::TimeDelta current_time) { |
+void TimeDeltaInterpolator::UpdateReferencePoints( |
+ base::TimeDelta current_time) { |
media_time_ = ClampToValidTimeRange(current_time); |
- reference_ = clock_->NowTicks(); |
+ reference_ = tick_clock_->NowTicks(); |
} |
-base::TimeDelta Clock::EstimatedElapsedTime() { |
- return ClampToValidTimeRange(ElapsedViaProvidedTime(clock_->NowTicks())); |
+base::TimeDelta TimeDeltaInterpolator::EstimatedElapsedTime() { |
+ return ClampToValidTimeRange(ElapsedViaProvidedTime(tick_clock_->NowTicks())); |
} |
} // namespace media |