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/filters/audio_clock.h" | 5 #include "media/filters/audio_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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
74 } | 74 } |
75 | 75 |
76 contiguous_audio_data_buffered_ = base::TimeDelta::FromMicroseconds( | 76 contiguous_audio_data_buffered_ = base::TimeDelta::FromMicroseconds( |
77 scaled_frames * microseconds_per_frame_); | 77 scaled_frames * microseconds_per_frame_); |
78 contiguous_audio_data_buffered_at_same_rate_ = | 78 contiguous_audio_data_buffered_at_same_rate_ = |
79 base::TimeDelta::FromMicroseconds(scaled_frames_at_same_rate * | 79 base::TimeDelta::FromMicroseconds(scaled_frames_at_same_rate * |
80 microseconds_per_frame_); | 80 microseconds_per_frame_); |
81 } | 81 } |
82 | 82 |
83 base::TimeDelta AudioClock::TimeUntilPlayback(base::TimeDelta timestamp) const { | 83 base::TimeDelta AudioClock::TimeUntilPlayback(base::TimeDelta timestamp) const { |
84 DCHECK(timestamp >= front_timestamp_); | 84 DCHECK(timestamp >= front_timestamp_) << ": " << timestamp << ", " |
DaleCurtis
2015/04/28 18:28:12
I think you can just use DCHECK_GE() now?
xhwang
2015/04/28 19:51:14
Done.
| |
85 DCHECK(timestamp <= back_timestamp_); | 85 << front_timestamp_; |
86 DCHECK(timestamp <= back_timestamp_) << ": " << timestamp << ", " | |
87 << back_timestamp_; | |
86 | 88 |
87 int64_t frames_until_timestamp = 0; | 89 int64_t frames_until_timestamp = 0; |
88 double timestamp_us = timestamp.InMicroseconds(); | 90 double timestamp_us = timestamp.InMicroseconds(); |
89 double media_time_us = front_timestamp_.InMicroseconds(); | 91 double media_time_us = front_timestamp_.InMicroseconds(); |
90 | 92 |
91 for (size_t i = 0; i < buffered_.size(); ++i) { | 93 for (size_t i = 0; i < buffered_.size(); ++i) { |
92 // Leading silence is always accounted prior to anything else. | 94 // Leading silence is always accounted prior to anything else. |
93 if (buffered_[i].playback_rate == 0) { | 95 if (buffered_[i].playback_rate == 0) { |
94 frames_until_timestamp += buffered_[i].frames; | 96 frames_until_timestamp += buffered_[i].frames; |
95 continue; | 97 continue; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
159 int64_t min_frames = std::min(buffered_[i].frames, frames); | 161 int64_t min_frames = std::min(buffered_[i].frames, frames); |
160 scaled_frames += min_frames * buffered_[i].playback_rate; | 162 scaled_frames += min_frames * buffered_[i].playback_rate; |
161 frames -= min_frames; | 163 frames -= min_frames; |
162 } | 164 } |
163 | 165 |
164 return base::TimeDelta::FromMicroseconds(scaled_frames * | 166 return base::TimeDelta::FromMicroseconds(scaled_frames * |
165 microseconds_per_frame_); | 167 microseconds_per_frame_); |
166 } | 168 } |
167 | 169 |
168 } // namespace media | 170 } // namespace media |
OLD | NEW |