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 "ipc/ipc_message.h" | 9 #include "ipc/ipc_message.h" |
10 #include "media/audio/audio_parameters.h" | 10 #include "media/audio/audio_parameters.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 // each. Note: Under normal conditions, each mixer would get its own sink! | 126 // each. Note: Under normal conditions, each mixer would get its own sink! |
127 EXPECT_CALL(*mock_sink_.get(), Start()).Times(2); | 127 EXPECT_CALL(*mock_sink_.get(), Start()).Times(2); |
128 EXPECT_CALL(*mock_sink_.get(), Stop()).Times(2); | 128 EXPECT_CALL(*mock_sink_.get(), Stop()).Times(2); |
129 | 129 |
130 media::AudioParameters params( | 130 media::AudioParameters params( |
131 media::AudioParameters::AUDIO_PCM_LINEAR, kChannelLayout, kSampleRate, | 131 media::AudioParameters::AUDIO_PCM_LINEAR, kChannelLayout, kSampleRate, |
132 kBitsPerChannel, kBufferSize); | 132 kBitsPerChannel, kBufferSize); |
133 | 133 |
134 // Create two mixer inputs and ensure this doesn't instantiate any mixers yet. | 134 // Create two mixer inputs and ensure this doesn't instantiate any mixers yet. |
135 EXPECT_EQ(mixer_count(), 0); | 135 EXPECT_EQ(mixer_count(), 0); |
| 136 media::FakeAudioRenderCallback callback(0); |
136 scoped_refptr<media::AudioRendererMixerInput> input( | 137 scoped_refptr<media::AudioRendererMixerInput> input( |
137 manager_->CreateInput(kRenderViewId, kRenderFrameId)); | 138 manager_->CreateInput(kRenderViewId, kRenderFrameId)); |
| 139 input->Initialize(params, &callback); |
138 EXPECT_EQ(mixer_count(), 0); | 140 EXPECT_EQ(mixer_count(), 0); |
| 141 media::FakeAudioRenderCallback another_callback(1); |
139 scoped_refptr<media::AudioRendererMixerInput> another_input( | 142 scoped_refptr<media::AudioRendererMixerInput> another_input( |
140 manager_->CreateInput(kAnotherRenderViewId, kAnotherRenderFrameId)); | 143 manager_->CreateInput(kAnotherRenderViewId, kAnotherRenderFrameId)); |
| 144 another_input->Initialize(params, &another_callback); |
141 EXPECT_EQ(mixer_count(), 0); | 145 EXPECT_EQ(mixer_count(), 0); |
142 | 146 |
143 // Implicitly test that AudioRendererMixerInput was provided with the expected | 147 // Implicitly test that AudioRendererMixerInput was provided with the expected |
144 // callbacks needed to acquire an AudioRendererMixer and remove it. | 148 // callbacks needed to acquire an AudioRendererMixer and remove it. |
145 media::FakeAudioRenderCallback callback(0); | 149 input->Start(); |
146 input->Initialize(params, &callback); | |
147 EXPECT_EQ(mixer_count(), 1); | 150 EXPECT_EQ(mixer_count(), 1); |
148 media::FakeAudioRenderCallback another_callback(1); | 151 another_input->Start(); |
149 another_input->Initialize(params, &another_callback); | |
150 EXPECT_EQ(mixer_count(), 2); | 152 EXPECT_EQ(mixer_count(), 2); |
151 | 153 |
152 // Destroying the inputs should destroy the mixers. | 154 // Destroying the inputs should destroy the mixers. |
153 input->Stop(); | 155 input->Stop(); |
154 input = NULL; | 156 input = NULL; |
155 EXPECT_EQ(mixer_count(), 1); | 157 EXPECT_EQ(mixer_count(), 1); |
156 another_input->Stop(); | 158 another_input->Stop(); |
157 another_input = NULL; | 159 another_input = NULL; |
158 EXPECT_EQ(mixer_count(), 0); | 160 EXPECT_EQ(mixer_count(), 0); |
159 } | 161 } |
160 | 162 |
161 } // namespace content | 163 } // namespace content |
OLD | NEW |