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

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

Issue 99033003: Enable platform echo cancellation through the AudioRecord path. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix tests and remove SetDiscreteChannels. Created 7 years 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 class ChannelMixerTest : public testing::TestWithParam<ChannelMixerTestData> {}; 93 class ChannelMixerTest : public testing::TestWithParam<ChannelMixerTestData> {};
94 94
95 // Verify channels are mixed and scaled correctly. The test only works if all 95 // Verify channels are mixed and scaled correctly. The test only works if all
96 // output channels have the same value. 96 // output channels have the same value.
97 TEST_P(ChannelMixerTest, Mixing) { 97 TEST_P(ChannelMixerTest, Mixing) {
98 ChannelLayout input_layout = GetParam().input_layout; 98 ChannelLayout input_layout = GetParam().input_layout;
99 int input_channels = GetParam().input_channels; 99 int input_channels = GetParam().input_channels;
100 scoped_ptr<AudioBus> input_bus = AudioBus::Create(input_channels, kFrames); 100 scoped_ptr<AudioBus> input_bus = AudioBus::Create(input_channels, kFrames);
101 AudioParameters input_audio(AudioParameters::AUDIO_PCM_LINEAR, 101 AudioParameters input_audio(AudioParameters::AUDIO_PCM_LINEAR,
102 input_layout, 102 input_layout,
103 input_channels,
103 AudioParameters::kAudioCDSampleRate, 16, 104 AudioParameters::kAudioCDSampleRate, 16,
104 kFrames); 105 kFrames,
105 if (input_layout == CHANNEL_LAYOUT_DISCRETE) 106 AudioParameters::NO_EFFECTS);
106 input_audio.SetDiscreteChannels(input_channels);
107 107
108 ChannelLayout output_layout = GetParam().output_layout; 108 ChannelLayout output_layout = GetParam().output_layout;
109 int output_channels = GetParam().output_channels; 109 int output_channels = GetParam().output_channels;
110 scoped_ptr<AudioBus> output_bus = AudioBus::Create(output_channels, kFrames); 110 scoped_ptr<AudioBus> output_bus = AudioBus::Create(output_channels, kFrames);
111 AudioParameters output_audio(AudioParameters::AUDIO_PCM_LINEAR, 111 AudioParameters output_audio(AudioParameters::AUDIO_PCM_LINEAR,
112 output_layout, 112 output_layout,
113 output_channels,
113 AudioParameters::kAudioCDSampleRate, 16, 114 AudioParameters::kAudioCDSampleRate, 16,
114 kFrames); 115 kFrames,
115 if (output_layout == CHANNEL_LAYOUT_DISCRETE) 116 AudioParameters::NO_EFFECTS);
116 output_audio.SetDiscreteChannels(output_channels);
117 117
118 const float* channel_values = GetParam().channel_values; 118 const float* channel_values = GetParam().channel_values;
119 ASSERT_EQ(input_bus->channels(), GetParam().num_channel_values); 119 ASSERT_EQ(input_bus->channels(), GetParam().num_channel_values);
120 120
121 float expected_value = 0; 121 float expected_value = 0;
122 float scale = GetParam().scale; 122 float scale = GetParam().scale;
123 for (int ch = 0; ch < input_bus->channels(); ++ch) { 123 for (int ch = 0; ch < input_bus->channels(); ++ch) {
124 std::fill(input_bus->channel(ch), input_bus->channel(ch) + kFrames, 124 std::fill(input_bus->channel(ch), input_bus->channel(ch) + kFrames,
125 channel_values[ch]); 125 channel_values[ch]);
126 expected_value += channel_values[ch] * scale; 126 expected_value += channel_values[ch] * scale;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 kStereoToMonoValues, arraysize(kStereoToMonoValues)), 171 kStereoToMonoValues, arraysize(kStereoToMonoValues)),
172 ChannelMixerTestData(CHANNEL_LAYOUT_DISCRETE, 2, 172 ChannelMixerTestData(CHANNEL_LAYOUT_DISCRETE, 2,
173 CHANNEL_LAYOUT_DISCRETE, 5, 173 CHANNEL_LAYOUT_DISCRETE, 5,
174 kStereoToMonoValues, arraysize(kStereoToMonoValues)), 174 kStereoToMonoValues, arraysize(kStereoToMonoValues)),
175 ChannelMixerTestData(CHANNEL_LAYOUT_DISCRETE, 5, 175 ChannelMixerTestData(CHANNEL_LAYOUT_DISCRETE, 5,
176 CHANNEL_LAYOUT_DISCRETE, 2, 176 CHANNEL_LAYOUT_DISCRETE, 2,
177 kFiveDiscreteValues, arraysize(kFiveDiscreteValues)) 177 kFiveDiscreteValues, arraysize(kFiveDiscreteValues))
178 )); 178 ));
179 179
180 } // namespace media 180 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698