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

Side by Side Diff: media/base/channel_mixer_unittest.cc

Issue 1275783003: Add a virtual beamforming audio device on ChromeOS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use a vector instead of a string. Created 5 years, 3 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 // MSVC++ requires this to be set before any other includes to get M_SQRT1_2. 5 // MSVC++ requires this to be set before any other includes to get M_SQRT1_2.
6 #define _USE_MATH_DEFINES 6 #define _USE_MATH_DEFINES
7 7
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 98
99 class ChannelMixerTest : public testing::TestWithParam<ChannelMixerTestData> {}; 99 class ChannelMixerTest : public testing::TestWithParam<ChannelMixerTestData> {};
100 100
101 // Verify channels are mixed and scaled correctly. The test only works if all 101 // Verify channels are mixed and scaled correctly. The test only works if all
102 // output channels have the same value. 102 // output channels have the same value.
103 TEST_P(ChannelMixerTest, Mixing) { 103 TEST_P(ChannelMixerTest, Mixing) {
104 ChannelLayout input_layout = GetParam().input_layout; 104 ChannelLayout input_layout = GetParam().input_layout;
105 int input_channels = GetParam().input_channels; 105 int input_channels = GetParam().input_channels;
106 scoped_ptr<AudioBus> input_bus = AudioBus::Create(input_channels, kFrames); 106 scoped_ptr<AudioBus> input_bus = AudioBus::Create(input_channels, kFrames);
107 AudioParameters input_audio(AudioParameters::AUDIO_PCM_LINEAR, 107 AudioParameters input_audio(AudioParameters::AUDIO_PCM_LINEAR,
108 input_layout, 108 input_layout == CHANNEL_LAYOUT_DISCRETE
109 input_layout == CHANNEL_LAYOUT_DISCRETE ? 109 ? input_channels
110 input_channels : 110 : ChannelLayoutToChannelCount(input_layout),
111 ChannelLayoutToChannelCount(input_layout), 111 input_layout, AudioParameters::kAudioCDSampleRate,
112 AudioParameters::kAudioCDSampleRate, 16, 112 16, kFrames);
113 kFrames,
114 AudioParameters::NO_EFFECTS);
115 113
116 ChannelLayout output_layout = GetParam().output_layout; 114 ChannelLayout output_layout = GetParam().output_layout;
117 int output_channels = GetParam().output_channels; 115 int output_channels = GetParam().output_channels;
118 scoped_ptr<AudioBus> output_bus = AudioBus::Create(output_channels, kFrames); 116 scoped_ptr<AudioBus> output_bus = AudioBus::Create(output_channels, kFrames);
119 AudioParameters output_audio(AudioParameters::AUDIO_PCM_LINEAR, 117 AudioParameters output_audio(
120 output_layout, 118 AudioParameters::AUDIO_PCM_LINEAR,
121 output_layout == CHANNEL_LAYOUT_DISCRETE ? 119 output_layout == CHANNEL_LAYOUT_DISCRETE
122 output_channels : 120 ? output_channels
123 ChannelLayoutToChannelCount(output_layout), 121 : ChannelLayoutToChannelCount(output_layout),
124 AudioParameters::kAudioCDSampleRate, 16, 122 output_layout, AudioParameters::kAudioCDSampleRate, 16, kFrames);
125 kFrames,
126 AudioParameters::NO_EFFECTS);
127 123
128 const float* channel_values = GetParam().channel_values; 124 const float* channel_values = GetParam().channel_values;
129 ASSERT_EQ(input_bus->channels(), GetParam().num_channel_values); 125 ASSERT_EQ(input_bus->channels(), GetParam().num_channel_values);
130 126
131 float expected_value = 0; 127 float expected_value = 0;
132 float scale = GetParam().scale; 128 float scale = GetParam().scale;
133 for (int ch = 0; ch < input_bus->channels(); ++ch) { 129 for (int ch = 0; ch < input_bus->channels(); ++ch) {
134 std::fill(input_bus->channel(ch), input_bus->channel(ch) + kFrames, 130 std::fill(input_bus->channel(ch), input_bus->channel(ch) + kFrames,
135 channel_values[ch]); 131 channel_values[ch]);
136 expected_value += channel_values[ch] * scale; 132 expected_value += channel_values[ch] * scale;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 kStereoToMonoValues, arraysize(kStereoToMonoValues)), 177 kStereoToMonoValues, arraysize(kStereoToMonoValues)),
182 ChannelMixerTestData(CHANNEL_LAYOUT_DISCRETE, 2, 178 ChannelMixerTestData(CHANNEL_LAYOUT_DISCRETE, 2,
183 CHANNEL_LAYOUT_DISCRETE, 5, 179 CHANNEL_LAYOUT_DISCRETE, 5,
184 kStereoToMonoValues, arraysize(kStereoToMonoValues)), 180 kStereoToMonoValues, arraysize(kStereoToMonoValues)),
185 ChannelMixerTestData(CHANNEL_LAYOUT_DISCRETE, 5, 181 ChannelMixerTestData(CHANNEL_LAYOUT_DISCRETE, 5,
186 CHANNEL_LAYOUT_DISCRETE, 2, 182 CHANNEL_LAYOUT_DISCRETE, 2,
187 kFiveDiscreteValues, arraysize(kFiveDiscreteValues)) 183 kFiveDiscreteValues, arraysize(kFiveDiscreteValues))
188 )); 184 ));
189 185
190 } // namespace media 186 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698