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

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

Issue 1304973005: Refactor AudioParameters member setting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: dalecurtis comments. 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_PI. 5 // MSVC++ requires this to be set before any other includes to get M_PI.
6 #define _USE_MATH_DEFINES 6 #define _USE_MATH_DEFINES
7 7
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 double epsilon_; 191 double epsilon_;
192 192
193 DISALLOW_COPY_AND_ASSIGN(AudioConverterTest); 193 DISALLOW_COPY_AND_ASSIGN(AudioConverterTest);
194 }; 194 };
195 195
196 // Ensure the buffer delay provided by AudioConverter is accurate. 196 // Ensure the buffer delay provided by AudioConverter is accurate.
197 TEST(AudioConverterTest, AudioDelayAndDiscreteChannelCount) { 197 TEST(AudioConverterTest, AudioDelayAndDiscreteChannelCount) {
198 // Choose input and output parameters such that the transform must make 198 // Choose input and output parameters such that the transform must make
199 // multiple calls to fill the buffer. 199 // multiple calls to fill the buffer.
200 AudioParameters input_parameters(AudioParameters::AUDIO_PCM_LINEAR, 200 AudioParameters input_parameters(AudioParameters::AUDIO_PCM_LINEAR,
201 CHANNEL_LAYOUT_DISCRETE, 10, kSampleRate, 201 CHANNEL_LAYOUT_DISCRETE, kSampleRate,
202 kBitsPerChannel, kLowLatencyBufferSize, 202 kBitsPerChannel, kLowLatencyBufferSize);
203 AudioParameters::NO_EFFECTS); 203 input_parameters.set_channels_for_discrete(10);
204 AudioParameters output_parameters(AudioParameters::AUDIO_PCM_LINEAR, 204 AudioParameters output_parameters(AudioParameters::AUDIO_PCM_LINEAR,
205 CHANNEL_LAYOUT_DISCRETE, 5, kSampleRate * 2, 205 CHANNEL_LAYOUT_DISCRETE, kSampleRate * 2,
206 kBitsPerChannel, kHighLatencyBufferSize, 206 kBitsPerChannel, kHighLatencyBufferSize);
207 AudioParameters::NO_EFFECTS); 207 output_parameters.set_channels_for_discrete(5);
208 208
209 AudioConverter converter(input_parameters, output_parameters, false); 209 AudioConverter converter(input_parameters, output_parameters, false);
210 FakeAudioRenderCallback callback(0.2); 210 FakeAudioRenderCallback callback(0.2);
211 scoped_ptr<AudioBus> audio_bus = AudioBus::Create(output_parameters); 211 scoped_ptr<AudioBus> audio_bus = AudioBus::Create(output_parameters);
212 converter.AddInput(&callback); 212 converter.AddInput(&callback);
213 converter.Convert(audio_bus.get()); 213 converter.Convert(audio_bus.get());
214 214
215 // Calculate the expected buffer delay for given AudioParameters. 215 // Calculate the expected buffer delay for given AudioParameters.
216 double input_sample_rate = input_parameters.sample_rate(); 216 double input_sample_rate = input_parameters.sample_rate();
217 int fill_count = 217 int fill_count =
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 // No resampling. No channel mixing. 255 // No resampling. No channel mixing.
256 std::tr1::make_tuple(44100, 44100, CHANNEL_LAYOUT_STEREO, 0.00000048), 256 std::tr1::make_tuple(44100, 44100, CHANNEL_LAYOUT_STEREO, 0.00000048),
257 257
258 // Upsampling. Channel upmixing. 258 // Upsampling. Channel upmixing.
259 std::tr1::make_tuple(44100, 48000, CHANNEL_LAYOUT_QUAD, 0.033), 259 std::tr1::make_tuple(44100, 48000, CHANNEL_LAYOUT_QUAD, 0.033),
260 260
261 // Downsampling. Channel downmixing. 261 // Downsampling. Channel downmixing.
262 std::tr1::make_tuple(48000, 41000, CHANNEL_LAYOUT_MONO, 0.042))); 262 std::tr1::make_tuple(48000, 41000, CHANNEL_LAYOUT_MONO, 0.042)));
263 263
264 } // namespace media 264 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698