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 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
686 EXPECT_TRUE(ConsumeBufferedData(frames_to_consume)); | 686 EXPECT_TRUE(ConsumeBufferedData(frames_to_consume)); |
687 | 687 |
688 // Time should change now that Render() has been called a second time. | 688 // Time should change now that Render() has been called a second time. |
689 timestamp_helper.AddFrames(frames_to_consume.value); | 689 timestamp_helper.AddFrames(frames_to_consume.value); |
690 EXPECT_EQ(timestamp_helper.GetTimestamp(), CurrentMediaTime()); | 690 EXPECT_EQ(timestamp_helper.GetTimestamp(), CurrentMediaTime()); |
691 | 691 |
692 // Advance current time well past all played audio to simulate an irregular or | 692 // Advance current time well past all played audio to simulate an irregular or |
693 // delayed OS callback. The value should be clamped to whats been rendered. | 693 // delayed OS callback. The value should be clamped to whats been rendered. |
694 timestamp_helper.AddFrames(frames_to_consume.value); | 694 timestamp_helper.AddFrames(frames_to_consume.value); |
695 tick_clock_->Advance(kConsumptionDuration * 2); | 695 tick_clock_->Advance(kConsumptionDuration * 2); |
696 const base::TimeDelta last_media_time = CurrentMediaTime(); | 696 EXPECT_EQ(timestamp_helper.GetTimestamp(), CurrentMediaTime()); |
697 EXPECT_EQ(timestamp_helper.GetTimestamp(), last_media_time); | |
698 | 697 |
699 // Consume some more audio data, but provide a delay value which is at odds | 698 // Consume some more audio data. |
700 // with the amount of time advanced so far; this would normally cause the | 699 EXPECT_TRUE(ConsumeBufferedData(frames_to_consume)); |
701 // media time to go backwards relative to its last value. | |
702 EXPECT_TRUE(ConsumeBufferedData(frames_to_consume, 1)); | |
703 | |
704 // Current time should never go backwards even for irregular OS callbacks and | |
705 // those with odd / wrong delay values. | |
706 EXPECT_EQ(last_media_time, CurrentMediaTime()); | |
707 | 700 |
708 // Stop ticking, the media time should be clamped to what's been rendered. | 701 // Stop ticking, the media time should be clamped to what's been rendered. |
709 StopTicking(); | 702 StopTicking(); |
710 EXPECT_EQ(timestamp_helper.GetTimestamp(), CurrentMediaTime()); | 703 EXPECT_EQ(timestamp_helper.GetTimestamp(), CurrentMediaTime()); |
711 tick_clock_->Advance(kConsumptionDuration * 2); | 704 tick_clock_->Advance(kConsumptionDuration * 2); |
712 timestamp_helper.AddFrames(frames_to_consume.value); | 705 timestamp_helper.AddFrames(frames_to_consume.value); |
713 EXPECT_EQ(timestamp_helper.GetTimestamp(), CurrentMediaTime()); | 706 EXPECT_EQ(timestamp_helper.GetTimestamp(), CurrentMediaTime()); |
714 } | 707 } |
715 | 708 |
716 TEST_F(AudioRendererImplTest, RenderingDelayedForEarlyStartTime) { | 709 TEST_F(AudioRendererImplTest, RenderingDelayedForEarlyStartTime) { |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
981 // Advance far enough that we shouldn't be clamped to current time (tested | 974 // Advance far enough that we shouldn't be clamped to current time (tested |
982 // already above). | 975 // already above). |
983 tick_clock_->Advance(kOneSecond); | 976 tick_clock_->Advance(kOneSecond); |
984 EXPECT_EQ( | 977 EXPECT_EQ( |
985 current_time + timestamp_helper.GetFrameDuration(frames_to_consume.value), | 978 current_time + timestamp_helper.GetFrameDuration(frames_to_consume.value), |
986 CurrentMediaWallClockTime(&is_time_moving)); | 979 CurrentMediaWallClockTime(&is_time_moving)); |
987 EXPECT_TRUE(is_time_moving); | 980 EXPECT_TRUE(is_time_moving); |
988 } | 981 } |
989 | 982 |
990 } // namespace media | 983 } // namespace media |
OLD | NEW |