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

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

Issue 173072: Suppress slider thumb jumping around during seeking... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « media/base/buffers.cc ('k') | media/base/pipeline_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "base/logging.h" 5 #include "base/logging.h"
6 #include "media/base/buffers.h"
6 #include "media/base/clock_impl.h" 7 #include "media/base/clock_impl.h"
7 8
8 namespace media { 9 namespace media {
9 10
10 ClockImpl::ClockImpl(TimeProvider* time_provider) 11 ClockImpl::ClockImpl(TimeProvider* time_provider)
11 : time_provider_(time_provider), 12 : time_provider_(time_provider),
12 playing_(false), 13 playing_(false),
13 playback_rate_(1.0f) { 14 playback_rate_(1.0f) {
14 } 15 }
15 16
16 ClockImpl::~ClockImpl() { 17 ClockImpl::~ClockImpl() {
17 } 18 }
18 19
19 base::TimeDelta ClockImpl::Play() { 20 base::TimeDelta ClockImpl::Play() {
20 DCHECK(!playing_); 21 DCHECK(!playing_);
21 reference_ = time_provider_(); 22 reference_ = time_provider_();
22 playing_ = true; 23 playing_ = true;
23 return media_time_; 24 return media_time_;
24 } 25 }
25 26
26 base::TimeDelta ClockImpl::Pause() { 27 base::TimeDelta ClockImpl::Pause() {
27 DCHECK(playing_); 28 DCHECK(playing_);
28 // Save our new accumulated amount of media time. 29 // Save our new accumulated amount of media time.
29 media_time_ = Elapsed(); 30 media_time_ = Elapsed();
30 playing_ = false; 31 playing_ = false;
31 return media_time_; 32 return media_time_;
32 } 33 }
33 34
34 void ClockImpl::SetTime(const base::TimeDelta& time) { 35 void ClockImpl::SetTime(const base::TimeDelta& time) {
36 if (time == StreamSample::kInvalidTimestamp) {
37 NOTREACHED();
38 return;
39 }
35 if (playing_) { 40 if (playing_) {
36 reference_ = time_provider_(); 41 reference_ = time_provider_();
37 } 42 }
38 media_time_ = time; 43 media_time_ = time;
39 } 44 }
40 45
41 void ClockImpl::SetPlaybackRate(float playback_rate) { 46 void ClockImpl::SetPlaybackRate(float playback_rate) {
42 if (playing_) { 47 if (playing_) {
43 base::Time time = time_provider_(); 48 base::Time time = time_provider_();
44 media_time_ = ElapsedViaProvidedTime(time); 49 media_time_ = ElapsedViaProvidedTime(time);
(...skipping 11 matching lines...) Expand all
56 61
57 base::TimeDelta ClockImpl::ElapsedViaProvidedTime( 62 base::TimeDelta ClockImpl::ElapsedViaProvidedTime(
58 const base::Time& time) const { 63 const base::Time& time) const {
59 // TODO(scherkus): floating point badness scaling time by playback rate. 64 // TODO(scherkus): floating point badness scaling time by playback rate.
60 int64 now_us = (time - reference_).InMicroseconds(); 65 int64 now_us = (time - reference_).InMicroseconds();
61 now_us = static_cast<int64>(now_us * playback_rate_); 66 now_us = static_cast<int64>(now_us * playback_rate_);
62 return media_time_ + base::TimeDelta::FromMicroseconds(now_us); 67 return media_time_ + base::TimeDelta::FromMicroseconds(now_us);
63 } 68 }
64 69
65 } // namespace media 70 } // namespace media
OLDNEW
« no previous file with comments | « media/base/buffers.cc ('k') | media/base/pipeline_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698