OLD | NEW |
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/renderers/audio_renderer_impl.h" | 5 #include "media/renderers/audio_renderer_impl.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 void DeliverRemainingAudio() { | 291 void DeliverRemainingAudio() { |
292 while (frames_remaining_in_buffer().value > 0) { | 292 while (frames_remaining_in_buffer().value > 0) { |
293 SatisfyPendingRead(InputFrames(256)); | 293 SatisfyPendingRead(InputFrames(256)); |
294 } | 294 } |
295 } | 295 } |
296 | 296 |
297 // Attempts to consume |requested_frames| frames from |renderer_|'s internal | 297 // Attempts to consume |requested_frames| frames from |renderer_|'s internal |
298 // buffer. Returns true if and only if all of |requested_frames| were able | 298 // buffer. Returns true if and only if all of |requested_frames| were able |
299 // to be consumed. | 299 // to be consumed. |
300 bool ConsumeBufferedData(OutputFrames requested_frames, | 300 bool ConsumeBufferedData(OutputFrames requested_frames, |
301 uint32_t delay_frames) { | 301 uint32_t frames_delayed) { |
302 std::unique_ptr<AudioBus> bus = | 302 std::unique_ptr<AudioBus> bus = |
303 AudioBus::Create(kChannels, requested_frames.value); | 303 AudioBus::Create(kChannels, requested_frames.value); |
304 int frames_read = 0; | 304 int frames_read = 0; |
305 EXPECT_TRUE(sink_->Render(bus.get(), delay_frames, &frames_read)); | 305 EXPECT_TRUE(sink_->Render(bus.get(), frames_delayed, &frames_read)); |
306 return frames_read == requested_frames.value; | 306 return frames_read == requested_frames.value; |
307 } | 307 } |
308 | 308 |
309 bool ConsumeBufferedData(OutputFrames requested_frames) { | 309 bool ConsumeBufferedData(OutputFrames requested_frames) { |
310 return ConsumeBufferedData(requested_frames, 0); | 310 return ConsumeBufferedData(requested_frames, 0); |
311 } | 311 } |
312 | 312 |
313 base::TimeTicks ConvertMediaTime(base::TimeDelta timestamp, | 313 base::TimeTicks ConvertMediaTime(base::TimeDelta timestamp, |
314 bool* is_time_moving) { | 314 bool* is_time_moving) { |
315 std::vector<base::TimeTicks> wall_clock_times; | 315 std::vector<base::TimeTicks> wall_clock_times; |
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
941 // Advance far enough that we shouldn't be clamped to current time (tested | 941 // Advance far enough that we shouldn't be clamped to current time (tested |
942 // already above). | 942 // already above). |
943 tick_clock_->Advance(kOneSecond); | 943 tick_clock_->Advance(kOneSecond); |
944 EXPECT_EQ( | 944 EXPECT_EQ( |
945 current_time + timestamp_helper.GetFrameDuration(frames_to_consume.value), | 945 current_time + timestamp_helper.GetFrameDuration(frames_to_consume.value), |
946 CurrentMediaWallClockTime(&is_time_moving)); | 946 CurrentMediaWallClockTime(&is_time_moving)); |
947 EXPECT_TRUE(is_time_moving); | 947 EXPECT_TRUE(is_time_moving); |
948 } | 948 } |
949 | 949 |
950 } // namespace media | 950 } // namespace media |
OLD | NEW |