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

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

Issue 551273004: Sprinkle some DVLOGs in media::WallClockTimeSource. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 {
11 11
12 WallClockTimeSource::WallClockTimeSource() 12 WallClockTimeSource::WallClockTimeSource()
13 : tick_clock_(new base::DefaultTickClock()), 13 : tick_clock_(new base::DefaultTickClock()),
14 ticking_(false), 14 ticking_(false),
15 playback_rate_(1.0f) { 15 playback_rate_(1.0f) {
16 } 16 }
17 17
18 WallClockTimeSource::~WallClockTimeSource() { 18 WallClockTimeSource::~WallClockTimeSource() {
19 } 19 }
20 20
21 void WallClockTimeSource::StartTicking() { 21 void WallClockTimeSource::StartTicking() {
22 DVLOG(1) << __FUNCTION__;
22 base::AutoLock auto_lock(lock_); 23 base::AutoLock auto_lock(lock_);
23 DCHECK(!ticking_); 24 DCHECK(!ticking_);
24 ticking_ = true; 25 ticking_ = true;
25 reference_wall_ticks_ = tick_clock_->NowTicks(); 26 reference_wall_ticks_ = tick_clock_->NowTicks();
26 } 27 }
27 28
28 void WallClockTimeSource::StopTicking() { 29 void WallClockTimeSource::StopTicking() {
30 DVLOG(1) << __FUNCTION__;
29 base::AutoLock auto_lock(lock_); 31 base::AutoLock auto_lock(lock_);
30 DCHECK(ticking_); 32 DCHECK(ticking_);
31 base_time_ = CurrentMediaTime_Locked(); 33 base_time_ = CurrentMediaTime_Locked();
32 ticking_ = false; 34 ticking_ = false;
33 reference_wall_ticks_ = tick_clock_->NowTicks(); 35 reference_wall_ticks_ = tick_clock_->NowTicks();
34 } 36 }
35 37
36 void WallClockTimeSource::SetPlaybackRate(float playback_rate) { 38 void WallClockTimeSource::SetPlaybackRate(float playback_rate) {
39 DVLOG(1) << __FUNCTION__ << "(" << playback_rate << ")";
37 base::AutoLock auto_lock(lock_); 40 base::AutoLock auto_lock(lock_);
38 // Estimate current media time using old rate to use as a new base time for 41 // Estimate current media time using old rate to use as a new base time for
39 // the new rate. 42 // the new rate.
40 if (ticking_) { 43 if (ticking_) {
41 base_time_ = CurrentMediaTime_Locked(); 44 base_time_ = CurrentMediaTime_Locked();
42 reference_wall_ticks_ = tick_clock_->NowTicks(); 45 reference_wall_ticks_ = tick_clock_->NowTicks();
43 } 46 }
44 47
45 playback_rate_ = playback_rate; 48 playback_rate_ = playback_rate;
46 } 49 }
47 50
48 void WallClockTimeSource::SetMediaTime(base::TimeDelta time) { 51 void WallClockTimeSource::SetMediaTime(base::TimeDelta time) {
52 DVLOG(1) << __FUNCTION__ << "(" << time.InMicroseconds() << ")";
49 base::AutoLock auto_lock(lock_); 53 base::AutoLock auto_lock(lock_);
50 CHECK(!ticking_); 54 CHECK(!ticking_);
51 base_time_ = time; 55 base_time_ = time;
52 } 56 }
53 57
54 base::TimeDelta WallClockTimeSource::CurrentMediaTime() { 58 base::TimeDelta WallClockTimeSource::CurrentMediaTime() {
55 base::AutoLock auto_lock(lock_); 59 base::AutoLock auto_lock(lock_);
56 return CurrentMediaTime_Locked(); 60 return CurrentMediaTime_Locked();
57 } 61 }
58 62
(...skipping 11 matching lines...) Expand all
70 if (!ticking_) 74 if (!ticking_)
71 return base_time_; 75 return base_time_;
72 76
73 base::TimeTicks now = tick_clock_->NowTicks(); 77 base::TimeTicks now = tick_clock_->NowTicks();
74 return base_time_ + 78 return base_time_ +
75 base::TimeDelta::FromMicroseconds( 79 base::TimeDelta::FromMicroseconds(
76 (now - reference_wall_ticks_).InMicroseconds() * playback_rate_); 80 (now - reference_wall_ticks_).InMicroseconds() * playback_rate_);
77 } 81 }
78 82
79 } // namespace media 83 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698