Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: content/renderer/media/audio_renderer_mixer_manager_unittest.cc

Issue 2752323002: Support Opus Ambisonics playback (Closed)
Patch Set: +pipeline integration tests, +test media, minor fixes Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "content/renderer/media/audio_renderer_mixer_manager.h" 5 #include "content/renderer/media/audio_renderer_mixer_manager.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 14 matching lines...) Expand all
25 namespace content { 25 namespace content {
26 26
27 namespace { 27 namespace {
28 const int kBitsPerChannel = 16; 28 const int kBitsPerChannel = 16;
29 const int kSampleRate = 48000; 29 const int kSampleRate = 48000;
30 const int kBufferSize = 8192; 30 const int kBufferSize = 8192;
31 const int kHardwareSampleRate = 44100; 31 const int kHardwareSampleRate = 44100;
32 const int kHardwareBufferSize = 128; 32 const int kHardwareBufferSize = 128;
33 const media::ChannelLayout kChannelLayout = media::CHANNEL_LAYOUT_STEREO; 33 const media::ChannelLayout kChannelLayout = media::CHANNEL_LAYOUT_STEREO;
34 const media::ChannelLayout kAnotherChannelLayout = media::CHANNEL_LAYOUT_2_1; 34 const media::ChannelLayout kAnotherChannelLayout = media::CHANNEL_LAYOUT_2_1;
35 const media::ChannelLayout kDiscreteChannelLayout =
36 media::CHANNEL_LAYOUT_DISCRETE;
35 const char* const kDefaultDeviceId = 37 const char* const kDefaultDeviceId =
36 media::AudioDeviceDescription::kDefaultDeviceId; 38 media::AudioDeviceDescription::kDefaultDeviceId;
37 const char kAnotherDeviceId[] = "another-device-id"; 39 const char kAnotherDeviceId[] = "another-device-id";
38 const char kMatchedDeviceId[] = "matched-device-id"; 40 const char kMatchedDeviceId[] = "matched-device-id";
39 const char kNonexistentDeviceId[] = "nonexistent-device-id"; 41 const char kNonexistentDeviceId[] = "nonexistent-device-id";
40 42
41 const int kRenderFrameId = 124; 43 const int kRenderFrameId = 124;
42 const int kAnotherRenderFrameId = 678; 44 const int kAnotherRenderFrameId = 678;
43 } // namespace; 45 } // namespace;
44 46
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 const url::Origin kSecurityOrigin; 171 const url::Origin kSecurityOrigin;
170 const url::Origin kSecurityOrigin2; 172 const url::Origin kSecurityOrigin2;
171 173
172 private: 174 private:
173 DISALLOW_COPY_AND_ASSIGN(AudioRendererMixerManagerTest); 175 DISALLOW_COPY_AND_ASSIGN(AudioRendererMixerManagerTest);
174 }; 176 };
175 177
176 // Verify GetMixer() and ReturnMixer() both work as expected; particularly with 178 // Verify GetMixer() and ReturnMixer() both work as expected; particularly with
177 // respect to the explicit ref counting done. 179 // respect to the explicit ref counting done.
178 TEST_F(AudioRendererMixerManagerTest, GetReturnMixer) { 180 TEST_F(AudioRendererMixerManagerTest, GetReturnMixer) {
179 // Since we're testing two different sets of parameters, we expect 181 // Since we're testing three different sets of parameters, we expect
180 // AudioRendererMixerManager to call Start and Stop on our mock twice. 182 // AudioRendererMixerManager to call Start and Stop on our mock three times.
181 EXPECT_CALL(*mock_sink_.get(), Start()).Times(2); 183 EXPECT_CALL(*mock_sink_.get(), Start()).Times(3);
182 EXPECT_CALL(*mock_sink_.get(), Stop()).Times(2); 184 EXPECT_CALL(*mock_sink_.get(), Stop()).Times(3);
183 185
184 // We expect 2 mixers to be created; each of them should release the sink. 186 // We expect 3 mixers to be created; each of them should release the sink.
185 EXPECT_CALL(*this, ReleaseSinkPtr(mock_sink_.get())).Times(2); 187 EXPECT_CALL(*this, ReleaseSinkPtr(mock_sink_.get())).Times(3);
186 188
187 // There should be no mixers outstanding to start with. 189 // There should be no mixers outstanding to start with.
188 EXPECT_EQ(0, mixer_count()); 190 EXPECT_EQ(0, mixer_count());
189 191
190 media::AudioParameters params1(media::AudioParameters::AUDIO_PCM_LINEAR, 192 media::AudioParameters params1(media::AudioParameters::AUDIO_PCM_LINEAR,
191 kChannelLayout, kSampleRate, kBitsPerChannel, 193 kChannelLayout, kSampleRate, kBitsPerChannel,
192 kBufferSize); 194 kBufferSize);
193 195
194 media::AudioRendererMixer* mixer1 = 196 media::AudioRendererMixer* mixer1 =
195 GetMixer(kRenderFrameId, params1, AudioLatency::LATENCY_PLAYBACK, 197 GetMixer(kRenderFrameId, params1, AudioLatency::LATENCY_PLAYBACK,
(...skipping 21 matching lines...) Expand all
217 EXPECT_EQ(2, mixer_count()); 219 EXPECT_EQ(2, mixer_count());
218 220
219 // Different parameters should result in a different mixer1. 221 // Different parameters should result in a different mixer1.
220 EXPECT_NE(mixer1, mixer2); 222 EXPECT_NE(mixer1, mixer2);
221 223
222 // Return both outstanding mixers. 224 // Return both outstanding mixers.
223 ReturnMixer(mixer1); 225 ReturnMixer(mixer1);
224 EXPECT_EQ(1, mixer_count()); 226 EXPECT_EQ(1, mixer_count());
225 ReturnMixer(mixer2); 227 ReturnMixer(mixer2);
226 EXPECT_EQ(0, mixer_count()); 228 EXPECT_EQ(0, mixer_count());
229
230 // An input with CHANNEL_LAYOUT_DISCRETE should yield a mixer that defaults
231 // to the hardware channel layout.
232 media::AudioParameters params3(AudioParameters::AUDIO_PCM_LINEAR,
233 kDiscreteChannelLayout, kSampleRate * 2,
234 kBitsPerChannel, kBufferSize * 2);
235 media::AudioRendererMixer* mixer3 =
236 GetMixer(kRenderFrameId, params3, AudioLatency::LATENCY_PLAYBACK,
237 kDefaultDeviceId, kSecurityOrigin, nullptr);
238 ASSERT_TRUE(mixer3);
239 EXPECT_EQ(1, mixer_count());
240 EXPECT_EQ(mock_sink_->GetOutputDeviceInfo().output_params().channel_layout(),
241 mixer3->GetOutputParamsForTesting().channel_layout());
242
243 // Return the final mixer.
244 ReturnMixer(mixer3);
245 EXPECT_EQ(0, mixer_count());
227 } 246 }
228 247
229 // Verify GetMixer() correctly deduplicates mixer with irrelevant AudioParameter 248 // Verify GetMixer() correctly deduplicates mixer with irrelevant AudioParameter
230 // differences. 249 // differences.
231 TEST_F(AudioRendererMixerManagerTest, MixerReuse) { 250 TEST_F(AudioRendererMixerManagerTest, MixerReuse) {
232 EXPECT_CALL(*mock_sink_.get(), Start()).Times(2); 251 EXPECT_CALL(*mock_sink_.get(), Start()).Times(2);
233 EXPECT_CALL(*mock_sink_.get(), Stop()).Times(2); 252 EXPECT_CALL(*mock_sink_.get(), Stop()).Times(2);
234 EXPECT_EQ(mixer_count(), 0); 253 EXPECT_EQ(mixer_count(), 0);
235 254
236 // We expect 2 mixers to be created; each of them should release the sink. 255 // We expect 2 mixers to be created; each of them should release the sink.
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
822 EXPECT_EQ(2048, mixer->GetOutputParamsForTesting().frames_per_buffer()); 841 EXPECT_EQ(2048, mixer->GetOutputParamsForTesting().frames_per_buffer());
823 #else 842 #else
824 // Expect hardware buffer size. 843 // Expect hardware buffer size.
825 EXPECT_EQ(128, mixer->GetOutputParamsForTesting().frames_per_buffer()); 844 EXPECT_EQ(128, mixer->GetOutputParamsForTesting().frames_per_buffer());
826 #endif 845 #endif
827 846
828 ReturnMixer(mixer); 847 ReturnMixer(mixer);
829 } 848 }
830 849
831 } // namespace content 850 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698