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

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

Issue 10800041: Update media duration if data is appended after the previous duration (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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 | « no previous file | media/base/data_source.h » ('j') | media/base/data_source.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | media/base/data_source.h » ('j') | media/base/data_source.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698