OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/wall_clock_time_source.h" | 5 #include "media/base/wall_clock_time_source.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 | 8 |
9 namespace media { | 9 namespace media { |
10 | 10 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 } | 43 } |
44 | 44 |
45 playback_rate_ = playback_rate; | 45 playback_rate_ = playback_rate; |
46 } | 46 } |
47 | 47 |
48 void WallClockTimeSource::SetMediaTime(base::TimeDelta time) { | 48 void WallClockTimeSource::SetMediaTime(base::TimeDelta time) { |
49 DVLOG(1) << __func__ << "(" << time.InMicroseconds() << ")"; | 49 DVLOG(1) << __func__ << "(" << time.InMicroseconds() << ")"; |
50 base::AutoLock auto_lock(lock_); | 50 base::AutoLock auto_lock(lock_); |
51 CHECK(!ticking_); | 51 CHECK(!ticking_); |
52 base_timestamp_ = time; | 52 base_timestamp_ = time; |
| 53 reference_time_ = base::TimeTicks(); |
53 } | 54 } |
54 | 55 |
55 base::TimeDelta WallClockTimeSource::CurrentMediaTime() { | 56 base::TimeDelta WallClockTimeSource::CurrentMediaTime() { |
56 base::AutoLock auto_lock(lock_); | 57 base::AutoLock auto_lock(lock_); |
57 return CurrentMediaTime_Locked(); | 58 return CurrentMediaTime_Locked(); |
58 } | 59 } |
59 | 60 |
60 bool WallClockTimeSource::GetWallClockTimes( | 61 bool WallClockTimeSource::GetWallClockTimes( |
61 const std::vector<base::TimeDelta>& media_timestamps, | 62 const std::vector<base::TimeDelta>& media_timestamps, |
62 std::vector<base::TimeTicks>* wall_clock_times) { | 63 std::vector<base::TimeTicks>* wall_clock_times) { |
(...skipping 22 matching lines...) Expand all Loading... |
85 if (!ticking_ || !playback_rate_) | 86 if (!ticking_ || !playback_rate_) |
86 return base_timestamp_; | 87 return base_timestamp_; |
87 | 88 |
88 base::TimeTicks now = tick_clock_->NowTicks(); | 89 base::TimeTicks now = tick_clock_->NowTicks(); |
89 return base_timestamp_ + | 90 return base_timestamp_ + |
90 base::TimeDelta::FromMicroseconds( | 91 base::TimeDelta::FromMicroseconds( |
91 (now - reference_time_).InMicroseconds() * playback_rate_); | 92 (now - reference_time_).InMicroseconds() * playback_rate_); |
92 } | 93 } |
93 | 94 |
94 } // namespace media | 95 } // namespace media |
OLD | NEW |