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

Unified Diff: media/base/clock.cc

Issue 9155003: Fix media timeline so that thumb never exceeds buffered data (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 11 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
Index: media/base/clock.cc
diff --git a/media/base/clock.cc b/media/base/clock.cc
index aaa0c13e90741116039b8af04da6989260977a59..6e131c93ca880bbcf1d621234b5fc100dd37bede 100644
--- a/media/base/clock.cc
+++ b/media/base/clock.cc
@@ -45,22 +45,30 @@ void Clock::SetPlaybackRate(float playback_rate) {
playback_rate_ = playback_rate;
}
-void Clock::SetTime(const base::TimeDelta& time) {
- if (time == kNoTimestamp) {
+void Clock::SetTime(base::TimeDelta current_time, base::TimeDelta max_time) {
+ DCHECK_LE(current_time.ToInternalValue(), max_time.ToInternalValue());
acolwell GONE FROM CHROMIUM 2012/01/13 22:51:21 How about DCHECK(current_time <= max_time)? The To
vrk (LEFT CHROMIUM) 2012/01/21 00:54:14 Done.
+ if (current_time == kNoTimestamp) {
NOTREACHED();
return;
}
if (playing_) {
reference_ = GetTimeFromProvider();
}
- media_time_ = time;
+ media_time_ = current_time;
+ max_time_ = max_time;
}
base::TimeDelta Clock::Elapsed() const {
- if (!playing_) {
- return media_time_;
- }
- return ElapsedViaProvidedTime(GetTimeFromProvider());
+ base::TimeDelta elapsed =
+ playing_ ? ElapsedViaProvidedTime(GetTimeFromProvider()) : media_time_;
+
+ if (max_time_.ToInternalValue() > 0)
acolwell GONE FROM CHROMIUM 2012/01/13 22:51:21 How about using != kNoTimestamp instead of > 0?
vrk (LEFT CHROMIUM) 2012/01/21 00:54:14 Done.
+ elapsed = std::min(elapsed, max_time_);
+
+ if (duration_.ToInternalValue() > 0 && elapsed > duration_)
acolwell GONE FROM CHROMIUM 2012/01/13 22:51:21 How about using != kNoTimestamp instead of > 0?
vrk (LEFT CHROMIUM) 2012/01/21 00:54:14 Actually, I modified logic of this method to retur
+ return duration_;
+
+ return elapsed;
}
base::TimeDelta Clock::ElapsedViaProvidedTime(const base::Time& time) const {

Powered by Google App Engine
This is Rietveld 408576698