summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorfischman@chromium.org <fischman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-02 21:49:44 +0000
committerfischman@chromium.org <fischman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-02 21:49:44 +0000
commit1276e6153b5663abed0daa2af744dd49459d5439 (patch)
tree63d0bede6c99a9703ab48b0fd6d0cb1c8e2456bd /media
parentcaf539f14503bf82261cf8b86428ab5e7462964f (diff)
downloadchromium_src-1276e6153b5663abed0daa2af744dd49459d5439.zip
chromium_src-1276e6153b5663abed0daa2af744dd49459d5439.tar.gz
chromium_src-1276e6153b5663abed0daa2af744dd49459d5439.tar.bz2
Change Clock::SetMaxTime() to be safe even in the presence of slow pipelines.
Before this CL the contract of SetMaxTime was unsatisfiable; a clock client could check that the max_time it was about to set wasn't greater than Elapsed() before calling SetMaxTime(), but between the time that check was done and the DCHECK inside SetMaxTime, time could move forward! After this CL, SetMaxTime() is allowed to move the media_time_ backward and set the underflow_ bit if the pipeline is slow enough. BUG=113037,chromium-os:26939 TEST=A Debug binary on an underpowered ARM crosbook with no audio device plays back correctly. Review URL: http://codereview.chromium.org/9582017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@124739 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r--media/base/clock.cc5
-rw-r--r--media/base/clock.h3
-rw-r--r--media/base/pipeline.cc1
3 files changed, 4 insertions, 5 deletions
diff --git a/media/base/clock.cc b/media/base/clock.cc
index 2517d1d..e57d280 100644
--- a/media/base/clock.cc
+++ b/media/base/clock.cc
@@ -72,8 +72,9 @@ void Clock::SetMaxTime(base::TimeDelta max_time) {
UpdateReferencePoints();
max_time_ = ClampToValidTimeRange(max_time);
- DCHECK(media_time_ <= max_time_);
- underflow_ = false;
+ underflow_ = media_time_ > max_time_;
+ if (underflow_)
+ media_time_ = max_time_;
}
void Clock::SetDuration(base::TimeDelta duration) {
diff --git a/media/base/clock.h b/media/base/clock.h
index 2854cb8..a5dff4d 100644
--- a/media/base/clock.h
+++ b/media/base/clock.h
@@ -56,8 +56,7 @@ class MEDIA_EXPORT Clock {
// set to 0 (before SetDuration() is called).
void SetTime(base::TimeDelta current_time, base::TimeDelta max_time);
- // Sets the |max_time| to be returned by a call to Elapsed(). |max_time| must
- // be greater than or equal to the current Elapsed() time.
+ // Sets the |max_time| to be returned by a call to Elapsed().
void SetMaxTime(base::TimeDelta max_time);
// Returns the current elapsed media time. Returns 0 if SetDuration() has
diff --git a/media/base/pipeline.cc b/media/base/pipeline.cc
index 2a7ca39..9da3df1 100644
--- a/media/base/pipeline.cc
+++ b/media/base/pipeline.cc
@@ -467,7 +467,6 @@ void Pipeline::OnVideoTimeUpdate(base::TimeDelta max_time) {
return;
DCHECK(!waiting_for_clock_update_);
- DCHECK(clock_->Elapsed() <= max_time);
clock_->SetMaxTime(max_time);
}