OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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 |
OLD | NEW |