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" |
| 6 |
| 7 #include <utility> |
| 8 |
5 #include "base/bind.h" | 9 #include "base/bind.h" |
6 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
7 #include "base/format_macros.h" | 11 #include "base/format_macros.h" |
8 #include "base/macros.h" | 12 #include "base/macros.h" |
9 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
10 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
11 #include "base/test/simple_test_tick_clock.h" | 15 #include "base/test/simple_test_tick_clock.h" |
12 #include "media/base/audio_buffer_converter.h" | 16 #include "media/base/audio_buffer_converter.h" |
13 #include "media/base/audio_hardware_config.h" | 17 #include "media/base/audio_hardware_config.h" |
14 #include "media/base/audio_splicer.h" | 18 #include "media/base/audio_splicer.h" |
15 #include "media/base/fake_audio_renderer_sink.h" | 19 #include "media/base/fake_audio_renderer_sink.h" |
16 #include "media/base/gmock_callback_support.h" | 20 #include "media/base/gmock_callback_support.h" |
17 #include "media/base/media_util.h" | 21 #include "media/base/media_util.h" |
18 #include "media/base/mock_filters.h" | 22 #include "media/base/mock_filters.h" |
19 #include "media/base/test_helpers.h" | 23 #include "media/base/test_helpers.h" |
20 #include "media/renderers/audio_renderer_impl.h" | |
21 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
22 | 25 |
23 using ::base::TimeDelta; | 26 using ::base::TimeDelta; |
24 using ::testing::_; | 27 using ::testing::_; |
25 using ::testing::Return; | 28 using ::testing::Return; |
26 using ::testing::SaveArg; | 29 using ::testing::SaveArg; |
27 | 30 |
28 namespace media { | 31 namespace media { |
29 | 32 |
30 namespace { | 33 namespace { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 AudioParameters out_params(AudioParameters::AUDIO_PCM_LOW_LATENCY, | 93 AudioParameters out_params(AudioParameters::AUDIO_PCM_LOW_LATENCY, |
91 kChannelLayout, | 94 kChannelLayout, |
92 kOutputSamplesPerSecond, | 95 kOutputSamplesPerSecond, |
93 SampleFormatToBytesPerChannel(kSampleFormat) * 8, | 96 SampleFormatToBytesPerChannel(kSampleFormat) * 8, |
94 512); | 97 512); |
95 hardware_config_.UpdateOutputConfig(out_params); | 98 hardware_config_.UpdateOutputConfig(out_params); |
96 ScopedVector<AudioDecoder> decoders; | 99 ScopedVector<AudioDecoder> decoders; |
97 decoders.push_back(decoder_); | 100 decoders.push_back(decoder_); |
98 sink_ = new FakeAudioRendererSink(); | 101 sink_ = new FakeAudioRendererSink(); |
99 renderer_.reset(new AudioRendererImpl(message_loop_.task_runner(), | 102 renderer_.reset(new AudioRendererImpl(message_loop_.task_runner(), |
100 sink_.get(), | 103 sink_.get(), std::move(decoders), |
101 decoders.Pass(), | 104 hardware_config_, new MediaLog())); |
102 hardware_config_, | |
103 new MediaLog())); | |
104 renderer_->tick_clock_.reset(tick_clock_); | 105 renderer_->tick_clock_.reset(tick_clock_); |
105 tick_clock_->Advance(base::TimeDelta::FromSeconds(1)); | 106 tick_clock_->Advance(base::TimeDelta::FromSeconds(1)); |
106 } | 107 } |
107 | 108 |
108 virtual ~AudioRendererImplTest() { | 109 virtual ~AudioRendererImplTest() { |
109 SCOPED_TRACE("~AudioRendererImplTest()"); | 110 SCOPED_TRACE("~AudioRendererImplTest()"); |
110 } | 111 } |
111 | 112 |
112 void ExpectUnsupportedAudioDecoder() { | 113 void ExpectUnsupportedAudioDecoder() { |
113 EXPECT_CALL(*decoder_, Initialize(_, _, _, _)) | 114 EXPECT_CALL(*decoder_, Initialize(_, _, _, _)) |
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
884 // Advance far enough that we shouldn't be clamped to current time (tested | 885 // Advance far enough that we shouldn't be clamped to current time (tested |
885 // already above). | 886 // already above). |
886 tick_clock_->Advance(kOneSecond); | 887 tick_clock_->Advance(kOneSecond); |
887 EXPECT_EQ( | 888 EXPECT_EQ( |
888 current_time + timestamp_helper.GetFrameDuration(frames_to_consume.value), | 889 current_time + timestamp_helper.GetFrameDuration(frames_to_consume.value), |
889 CurrentMediaWallClockTime(&is_time_moving)); | 890 CurrentMediaWallClockTime(&is_time_moving)); |
890 EXPECT_TRUE(is_time_moving); | 891 EXPECT_TRUE(is_time_moving); |
891 } | 892 } |
892 | 893 |
893 } // namespace media | 894 } // namespace media |
OLD | NEW |