| Index: media/base/clock.cc
|
| diff --git a/media/base/clock.cc b/media/base/clock.cc
|
| deleted file mode 100644
|
| index 2c21267b0df3ae38e9e5c75591c39f21d3902792..0000000000000000000000000000000000000000
|
| --- a/media/base/clock.cc
|
| +++ /dev/null
|
| @@ -1,109 +0,0 @@
|
| -// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
| -// Use of this source code is governed by a BSD-style license that can be
|
| -// found in the LICENSE file.
|
| -
|
| -#include "media/base/clock.h"
|
| -
|
| -#include <algorithm>
|
| -
|
| -#include "base/logging.h"
|
| -#include "base/time/tick_clock.h"
|
| -#include "media/base/buffers.h"
|
| -
|
| -namespace media {
|
| -
|
| -Clock::Clock(base::TickClock* clock)
|
| - : clock_(clock),
|
| - playing_(false),
|
| - underflow_(false),
|
| - playback_rate_(1.0f),
|
| - max_time_(kNoTimestamp()) {
|
| - DCHECK(clock_);
|
| -}
|
| -
|
| -Clock::~Clock() {}
|
| -
|
| -bool Clock::IsPlaying() const {
|
| - return playing_;
|
| -}
|
| -
|
| -base::TimeDelta Clock::Play() {
|
| - DCHECK(!playing_);
|
| - UpdateReferencePoints();
|
| - playing_ = true;
|
| - return media_time_;
|
| -}
|
| -
|
| -base::TimeDelta Clock::Pause() {
|
| - DCHECK(playing_);
|
| - UpdateReferencePoints();
|
| - playing_ = false;
|
| - return media_time_;
|
| -}
|
| -
|
| -void Clock::SetPlaybackRate(float playback_rate) {
|
| - UpdateReferencePoints();
|
| - playback_rate_ = playback_rate;
|
| -}
|
| -
|
| -void Clock::SetTime(base::TimeDelta current_time, base::TimeDelta max_time) {
|
| - DCHECK(current_time <= max_time);
|
| - DCHECK(current_time != kNoTimestamp());
|
| -
|
| - UpdateReferencePoints(current_time);
|
| - max_time_ = ClampToValidTimeRange(max_time);
|
| - underflow_ = false;
|
| -}
|
| -
|
| -base::TimeDelta Clock::Elapsed() {
|
| - // The clock is not advancing, so return the last recorded time.
|
| - if (!playing_ || underflow_)
|
| - return media_time_;
|
| -
|
| - base::TimeDelta elapsed = EstimatedElapsedTime();
|
| - if (max_time_ != kNoTimestamp() && elapsed > max_time_) {
|
| - UpdateReferencePoints(max_time_);
|
| - underflow_ = true;
|
| - elapsed = max_time_;
|
| - }
|
| -
|
| - return elapsed;
|
| -}
|
| -
|
| -void Clock::SetMaxTime(base::TimeDelta max_time) {
|
| - DCHECK(max_time != kNoTimestamp());
|
| -
|
| - UpdateReferencePoints();
|
| - max_time_ = ClampToValidTimeRange(max_time);
|
| -
|
| - underflow_ = media_time_ > max_time_;
|
| - if (underflow_)
|
| - media_time_ = max_time_;
|
| -}
|
| -
|
| -base::TimeDelta Clock::ElapsedViaProvidedTime(
|
| - const base::TimeTicks& time) const {
|
| - // TODO(scherkus): floating point badness scaling time by playback rate.
|
| - int64 now_us = (time - reference_).InMicroseconds();
|
| - now_us = static_cast<int64>(now_us * playback_rate_);
|
| - return media_time_ + base::TimeDelta::FromMicroseconds(now_us);
|
| -}
|
| -
|
| -base::TimeDelta Clock::ClampToValidTimeRange(base::TimeDelta time) const {
|
| - return std::max(base::TimeDelta(), time);
|
| -}
|
| -
|
| -void Clock::UpdateReferencePoints() {
|
| - UpdateReferencePoints(Elapsed());
|
| -}
|
| -
|
| -void Clock::UpdateReferencePoints(base::TimeDelta current_time) {
|
| - media_time_ = ClampToValidTimeRange(current_time);
|
| - reference_ = clock_->NowTicks();
|
| -}
|
| -
|
| -base::TimeDelta Clock::EstimatedElapsedTime() {
|
| - return ClampToValidTimeRange(ElapsedViaProvidedTime(clock_->NowTicks()));
|
| -}
|
| -
|
| -} // namespace media
|
|
|