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 "base/logging.h" | 5 #include "base/logging.h" |
6 #include "base/memory/ref_counted.h" | 6 #include "base/memory/ref_counted.h" |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "content/renderer/media/audio_renderer_mixer_manager.h" | 8 #include "content/renderer/media/audio_renderer_mixer_manager.h" |
9 #include "media/audio/audio_parameters.h" | |
10 #include "media/base/audio_hardware_config.h" | 9 #include "media/base/audio_hardware_config.h" |
11 #include "media/base/audio_renderer_mixer.h" | 10 #include "media/base/audio_renderer_mixer.h" |
12 #include "media/base/audio_renderer_mixer_input.h" | 11 #include "media/base/audio_renderer_mixer_input.h" |
13 #include "media/base/fake_audio_render_callback.h" | 12 #include "media/base/fake_audio_render_callback.h" |
14 #include "media/base/mock_audio_renderer_sink.h" | 13 #include "media/base/mock_audio_renderer_sink.h" |
15 #include "testing/gmock/include/gmock/gmock.h" | 14 #include "testing/gmock/include/gmock/gmock.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
17 | 16 |
18 namespace content { | 17 namespace content { |
19 | 18 |
20 static const int kBitsPerChannel = 16; | 19 static const int kBitsPerChannel = 16; |
21 static const int kSampleRate = 48000; | 20 static const int kSampleRate = 48000; |
22 static const int kBufferSize = 8192; | 21 static const int kBufferSize = 8192; |
23 static const media::ChannelLayout kChannelLayout = media::CHANNEL_LAYOUT_STEREO; | 22 static const media::ChannelLayout kChannelLayout = media::CHANNEL_LAYOUT_STEREO; |
24 | 23 |
25 static const int kRenderViewId = 123; | 24 static const int kRenderViewId = 123; |
26 static const int kAnotherRenderViewId = 456; | 25 static const int kAnotherRenderViewId = 456; |
27 | 26 |
28 using media::AudioParameters; | |
29 | |
30 class AudioRendererMixerManagerTest : public testing::Test { | 27 class AudioRendererMixerManagerTest : public testing::Test { |
31 public: | 28 public: |
32 AudioRendererMixerManagerTest() | 29 AudioRendererMixerManagerTest() |
33 : fake_config_(AudioParameters(), AudioParameters()) { | 30 : fake_config_(kBufferSize, kSampleRate, 0, media::CHANNEL_LAYOUT_NONE) { |
34 AudioParameters output_params( | |
35 media::AudioParameters::AUDIO_PCM_LOW_LATENCY, | |
36 media::CHANNEL_LAYOUT_STEREO, | |
37 kSampleRate, | |
38 16, | |
39 kBufferSize); | |
40 fake_config_.UpdateOutputConfig(output_params); | |
41 | |
42 manager_.reset(new AudioRendererMixerManager(&fake_config_)); | 31 manager_.reset(new AudioRendererMixerManager(&fake_config_)); |
43 | 32 |
44 // We don't want to deal with instantiating a real AudioOutputDevice since | 33 // We don't want to deal with instantiating a real AudioOutputDevice since |
45 // it's not important to our testing, so we inject a mock. | 34 // it's not important to our testing, so we inject a mock. |
46 mock_sink_ = new media::MockAudioRendererSink(); | 35 mock_sink_ = new media::MockAudioRendererSink(); |
47 manager_->SetAudioRendererSinkForTesting(mock_sink_); | 36 manager_->SetAudioRendererSinkForTesting(mock_sink_); |
48 } | 37 } |
49 | 38 |
50 media::AudioRendererMixer* GetMixer(int source_render_view_id, | 39 media::AudioRendererMixer* GetMixer(int source_render_view_id, |
51 const media::AudioParameters& params) { | 40 const media::AudioParameters& params) { |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 EXPECT_EQ(mixer_count(), 2); | 136 EXPECT_EQ(mixer_count(), 2); |
148 | 137 |
149 // Destroying the inputs should destroy the mixers. | 138 // Destroying the inputs should destroy the mixers. |
150 input = NULL; | 139 input = NULL; |
151 EXPECT_EQ(mixer_count(), 1); | 140 EXPECT_EQ(mixer_count(), 1); |
152 another_input = NULL; | 141 another_input = NULL; |
153 EXPECT_EQ(mixer_count(), 0); | 142 EXPECT_EQ(mixer_count(), 0); |
154 } | 143 } |
155 | 144 |
156 } // namespace content | 145 } // namespace content |
OLD | NEW |