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 <stddef.h> |
| 8 |
7 #include <algorithm> | 9 #include <algorithm> |
8 | 10 |
9 #include "base/logging.h" | 11 #include "base/logging.h" |
10 | 12 |
11 namespace media { | 13 namespace media { |
12 | 14 |
13 AudioClock::AudioClock(base::TimeDelta start_timestamp, int sample_rate) | 15 AudioClock::AudioClock(base::TimeDelta start_timestamp, int sample_rate) |
14 : start_timestamp_(start_timestamp), | 16 : start_timestamp_(start_timestamp), |
15 microseconds_per_frame_( | 17 microseconds_per_frame_( |
16 static_cast<double>(base::Time::kMicrosecondsPerSecond) / | 18 static_cast<double>(base::Time::kMicrosecondsPerSecond) / |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 | 180 |
179 base::TimeDelta AudioClock::ComputeBufferedMediaDuration() const { | 181 base::TimeDelta AudioClock::ComputeBufferedMediaDuration() const { |
180 double scaled_frames = 0; | 182 double scaled_frames = 0; |
181 for (const auto& buffer : buffered_) | 183 for (const auto& buffer : buffered_) |
182 scaled_frames += buffer.frames * buffer.playback_rate; | 184 scaled_frames += buffer.frames * buffer.playback_rate; |
183 return base::TimeDelta::FromMicroseconds(scaled_frames * | 185 return base::TimeDelta::FromMicroseconds(scaled_frames * |
184 microseconds_per_frame_); | 186 microseconds_per_frame_); |
185 } | 187 } |
186 | 188 |
187 } // namespace media | 189 } // namespace media |
OLD | NEW |