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

Side by Side Diff: media/base/clock.cc

Issue 9582017: Change Clock::SetMaxTime() to be safe even in the presence of slow pipelines. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/base/clock.h ('k') | media/base/pipeline.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/base/clock.h" 5 #include "media/base/clock.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "media/base/buffers.h" 8 #include "media/base/buffers.h"
9 9
10 namespace media { 10 namespace media {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 65
66 return elapsed; 66 return elapsed;
67 } 67 }
68 68
69 void Clock::SetMaxTime(base::TimeDelta max_time) { 69 void Clock::SetMaxTime(base::TimeDelta max_time) {
70 DCHECK(max_time != kNoTimestamp()); 70 DCHECK(max_time != kNoTimestamp());
71 71
72 UpdateReferencePoints(); 72 UpdateReferencePoints();
73 max_time_ = ClampToValidTimeRange(max_time); 73 max_time_ = ClampToValidTimeRange(max_time);
74 74
75 DCHECK(media_time_ <= max_time_); 75 underflow_ = media_time_ > max_time_;
76 underflow_ = false; 76 if (underflow_)
77 media_time_ = max_time_;
vrk (LEFT CHROMIUM) 2012/03/05 22:18:08 Technically this assignment is incorrect: you want
77 } 78 }
78 79
79 void Clock::SetDuration(base::TimeDelta duration) { 80 void Clock::SetDuration(base::TimeDelta duration) {
80 DCHECK(duration_ == kNoTimestamp()); 81 DCHECK(duration_ == kNoTimestamp());
81 DCHECK(duration > base::TimeDelta()); 82 DCHECK(duration > base::TimeDelta());
82 duration_ = duration; 83 duration_ = duration;
83 } 84 }
84 85
85 base::TimeDelta Clock::ElapsedViaProvidedTime(const base::Time& time) const { 86 base::TimeDelta Clock::ElapsedViaProvidedTime(const base::Time& time) const {
86 // TODO(scherkus): floating point badness scaling time by playback rate. 87 // TODO(scherkus): floating point badness scaling time by playback rate.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 playing_ = false; 131 playing_ = false;
131 playback_rate_ = 1.0f; 132 playback_rate_ = 1.0f;
132 max_time_ = kNoTimestamp(); 133 max_time_ = kNoTimestamp();
133 duration_ = kNoTimestamp(); 134 duration_ = kNoTimestamp();
134 media_time_ = base::TimeDelta(); 135 media_time_ = base::TimeDelta();
135 reference_ = base::Time(); 136 reference_ = base::Time();
136 underflow_ = false; 137 underflow_ = false;
137 } 138 }
138 139
139 } // namespace media 140 } // namespace media
OLDNEW
« no previous file with comments | « media/base/clock.h ('k') | media/base/pipeline.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698