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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "media/base/buffers.h" | 10 #include "media/base/buffers.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 | 73 |
74 UpdateReferencePoints(); | 74 UpdateReferencePoints(); |
75 max_time_ = ClampToValidTimeRange(max_time); | 75 max_time_ = ClampToValidTimeRange(max_time); |
76 | 76 |
77 underflow_ = media_time_ > max_time_; | 77 underflow_ = media_time_ > max_time_; |
78 if (underflow_) | 78 if (underflow_) |
79 media_time_ = max_time_; | 79 media_time_ = max_time_; |
80 } | 80 } |
81 | 81 |
82 void Clock::SetDuration(base::TimeDelta duration) { | 82 void Clock::SetDuration(base::TimeDelta duration) { |
83 DCHECK(duration_ == kNoTimestamp() || duration_ == kInfiniteDuration()); | |
84 DCHECK(duration > base::TimeDelta()); | 83 DCHECK(duration > base::TimeDelta()); |
85 duration_ = duration; | 84 duration_ = duration; |
86 } | 85 } |
87 | 86 |
88 base::TimeDelta Clock::ElapsedViaProvidedTime(const base::Time& time) const { | 87 base::TimeDelta Clock::ElapsedViaProvidedTime(const base::Time& time) const { |
89 // TODO(scherkus): floating point badness scaling time by playback rate. | 88 // TODO(scherkus): floating point badness scaling time by playback rate. |
90 int64 now_us = (time - reference_).InMicroseconds(); | 89 int64 now_us = (time - reference_).InMicroseconds(); |
91 now_us = static_cast<int64>(now_us * playback_rate_); | 90 now_us = static_cast<int64>(now_us * playback_rate_); |
92 return media_time_ + base::TimeDelta::FromMicroseconds(now_us); | 91 return media_time_ + base::TimeDelta::FromMicroseconds(now_us); |
93 } | 92 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 playing_ = false; | 132 playing_ = false; |
134 playback_rate_ = 1.0f; | 133 playback_rate_ = 1.0f; |
135 max_time_ = kNoTimestamp(); | 134 max_time_ = kNoTimestamp(); |
136 duration_ = kNoTimestamp(); | 135 duration_ = kNoTimestamp(); |
137 media_time_ = base::TimeDelta(); | 136 media_time_ = base::TimeDelta(); |
138 reference_ = base::Time(); | 137 reference_ = base::Time(); |
139 underflow_ = false; | 138 underflow_ = false; |
140 } | 139 } |
141 | 140 |
142 } // namespace media | 141 } // namespace media |
OLD | NEW |