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 #include <vector> |
9 | 10 |
10 #include "base/bind.h" | 11 #include "base/bind.h" |
11 #include "base/callback_helpers.h" | 12 #include "base/callback_helpers.h" |
12 #include "base/format_macros.h" | 13 #include "base/format_macros.h" |
13 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/ptr_util.h" |
14 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
15 #include "base/single_thread_task_runner.h" | 17 #include "base/single_thread_task_runner.h" |
16 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
17 #include "base/test/simple_test_tick_clock.h" | 19 #include "base/test/simple_test_tick_clock.h" |
18 #include "media/base/audio_buffer_converter.h" | 20 #include "media/base/audio_buffer_converter.h" |
19 #include "media/base/fake_audio_renderer_sink.h" | 21 #include "media/base/fake_audio_renderer_sink.h" |
20 #include "media/base/gmock_callback_support.h" | 22 #include "media/base/gmock_callback_support.h" |
21 #include "media/base/media_util.h" | 23 #include "media/base/media_util.h" |
22 #include "media/base/mock_filters.h" | 24 #include "media/base/mock_filters.h" |
23 #include "media/base/test_helpers.h" | 25 #include "media/base/test_helpers.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 static double kOutputMicrosPerFrame = | 61 static double kOutputMicrosPerFrame = |
60 static_cast<double>(base::Time::kMicrosecondsPerSecond) / | 62 static_cast<double>(base::Time::kMicrosecondsPerSecond) / |
61 kOutputSamplesPerSecond; | 63 kOutputSamplesPerSecond; |
62 | 64 |
63 ACTION_P(EnterPendingDecoderInitStateAction, test) { | 65 ACTION_P(EnterPendingDecoderInitStateAction, test) { |
64 test->EnterPendingDecoderInitState(arg2); | 66 test->EnterPendingDecoderInitState(arg2); |
65 } | 67 } |
66 | 68 |
67 class AudioRendererImplTest : public ::testing::Test, public RendererClient { | 69 class AudioRendererImplTest : public ::testing::Test, public RendererClient { |
68 public: | 70 public: |
69 ScopedVector<AudioDecoder> CreateAudioDecoderForTest() { | 71 std::vector<std::unique_ptr<AudioDecoder>> CreateAudioDecoderForTest() { |
70 MockAudioDecoder* decoder = new MockAudioDecoder(); | 72 auto decoder = base::MakeUnique<MockAudioDecoder>(); |
71 if (!enter_pending_decoder_init_) { | 73 if (!enter_pending_decoder_init_) { |
72 EXPECT_CALL(*decoder, Initialize(_, _, _, _)) | 74 EXPECT_CALL(*decoder, Initialize(_, _, _, _)) |
73 .WillOnce(DoAll(SaveArg<3>(&output_cb_), | 75 .WillOnce(DoAll(SaveArg<3>(&output_cb_), |
74 RunCallback<2>(expected_init_result_))); | 76 RunCallback<2>(expected_init_result_))); |
75 } else { | 77 } else { |
76 EXPECT_CALL(*decoder, Initialize(_, _, _, _)) | 78 EXPECT_CALL(*decoder, Initialize(_, _, _, _)) |
77 .WillOnce(EnterPendingDecoderInitStateAction(this)); | 79 .WillOnce(EnterPendingDecoderInitStateAction(this)); |
78 } | 80 } |
79 EXPECT_CALL(*decoder, Decode(_, _)) | 81 EXPECT_CALL(*decoder, Decode(_, _)) |
80 .WillRepeatedly(Invoke(this, &AudioRendererImplTest::DecodeDecoder)); | 82 .WillRepeatedly(Invoke(this, &AudioRendererImplTest::DecodeDecoder)); |
81 EXPECT_CALL(*decoder, Reset(_)) | 83 EXPECT_CALL(*decoder, Reset(_)) |
82 .WillRepeatedly(Invoke(this, &AudioRendererImplTest::ResetDecoder)); | 84 .WillRepeatedly(Invoke(this, &AudioRendererImplTest::ResetDecoder)); |
83 ScopedVector<AudioDecoder> decoders; | 85 std::vector<std::unique_ptr<AudioDecoder>> decoders; |
84 decoders.push_back(decoder); | 86 decoders.push_back(std::move(decoder)); |
85 return decoders; | 87 return decoders; |
86 } | 88 } |
87 | 89 |
88 // Give the decoder some non-garbage media properties. | 90 // Give the decoder some non-garbage media properties. |
89 AudioRendererImplTest() | 91 AudioRendererImplTest() |
90 : hardware_params_(AudioParameters::AUDIO_PCM_LOW_LATENCY, | 92 : hardware_params_(AudioParameters::AUDIO_PCM_LOW_LATENCY, |
91 kChannelLayout, | 93 kChannelLayout, |
92 kOutputSamplesPerSecond, | 94 kOutputSamplesPerSecond, |
93 SampleFormatToBytesPerChannel(kSampleFormat) * 8, | 95 SampleFormatToBytesPerChannel(kSampleFormat) * 8, |
94 512), | 96 512), |
(...skipping 996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1091 // Advance far enough that we shouldn't be clamped to current time (tested | 1093 // Advance far enough that we shouldn't be clamped to current time (tested |
1092 // already above). | 1094 // already above). |
1093 tick_clock_->Advance(kOneSecond); | 1095 tick_clock_->Advance(kOneSecond); |
1094 EXPECT_EQ( | 1096 EXPECT_EQ( |
1095 current_time + timestamp_helper.GetFrameDuration(frames_to_consume.value), | 1097 current_time + timestamp_helper.GetFrameDuration(frames_to_consume.value), |
1096 CurrentMediaWallClockTime(&is_time_moving)); | 1098 CurrentMediaWallClockTime(&is_time_moving)); |
1097 EXPECT_TRUE(is_time_moving); | 1099 EXPECT_TRUE(is_time_moving); |
1098 } | 1100 } |
1099 | 1101 |
1100 } // namespace media | 1102 } // namespace media |
OLD | NEW |