| 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 #include "base/time/default_tick_clock.h" | 8 #include "base/time/default_tick_clock.h" |
| 9 | 9 |
| 10 namespace media { | 10 namespace media { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 base::TimeDelta WallClockTimeSource::CurrentMediaTime() { | 58 base::TimeDelta WallClockTimeSource::CurrentMediaTime() { |
| 59 base::AutoLock auto_lock(lock_); | 59 base::AutoLock auto_lock(lock_); |
| 60 return CurrentMediaTime_Locked(); | 60 return CurrentMediaTime_Locked(); |
| 61 } | 61 } |
| 62 | 62 |
| 63 base::TimeDelta WallClockTimeSource::CurrentMediaTimeForSyncingVideo() { | 63 base::TimeDelta WallClockTimeSource::CurrentMediaTimeForSyncingVideo() { |
| 64 return CurrentMediaTime(); | 64 return CurrentMediaTime(); |
| 65 } | 65 } |
| 66 | 66 |
| 67 void WallClockTimeSource::SetTickClockForTesting( | 67 void WallClockTimeSource::SetTickClockForTesting( |
| 68 scoped_ptr<base::TickClock> tick_clock) { | 68 const scoped_refptr<base::TickClock>& tick_clock) { |
| 69 tick_clock_.swap(tick_clock); | 69 tick_clock_ = tick_clock; |
| 70 } | 70 } |
| 71 | 71 |
| 72 base::TimeDelta WallClockTimeSource::CurrentMediaTime_Locked() { | 72 base::TimeDelta WallClockTimeSource::CurrentMediaTime_Locked() { |
| 73 lock_.AssertAcquired(); | 73 lock_.AssertAcquired(); |
| 74 if (!ticking_) | 74 if (!ticking_) |
| 75 return base_time_; | 75 return base_time_; |
| 76 | 76 |
| 77 base::TimeTicks now = tick_clock_->NowTicks(); | 77 base::TimeTicks now = tick_clock_->NowTicks(); |
| 78 return base_time_ + | 78 return base_time_ + |
| 79 base::TimeDelta::FromMicroseconds( | 79 base::TimeDelta::FromMicroseconds( |
| 80 (now - reference_wall_ticks_).InMicroseconds() * playback_rate_); | 80 (now - reference_wall_ticks_).InMicroseconds() * playback_rate_); |
| 81 } | 81 } |
| 82 | 82 |
| 83 } // namespace media | 83 } // namespace media |
| OLD | NEW |