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 // 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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 // |expected_audio_bus_|. | 190 // |expected_audio_bus_|. |
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, 10, |
201 CHANNEL_LAYOUT_DISCRETE, 10, kSampleRate, | 201 CHANNEL_LAYOUT_DISCRETE, kSampleRate, |
202 kBitsPerChannel, kLowLatencyBufferSize, | 202 kBitsPerChannel, kLowLatencyBufferSize); |
203 AudioParameters::NO_EFFECTS); | 203 AudioParameters output_parameters(AudioParameters::AUDIO_PCM_LINEAR, 5, |
204 AudioParameters output_parameters(AudioParameters::AUDIO_PCM_LINEAR, | 204 CHANNEL_LAYOUT_DISCRETE, kSampleRate * 2, |
205 CHANNEL_LAYOUT_DISCRETE, 5, kSampleRate * 2, | 205 kBitsPerChannel, kHighLatencyBufferSize); |
206 kBitsPerChannel, kHighLatencyBufferSize, | |
207 AudioParameters::NO_EFFECTS); | |
208 | 206 |
209 AudioConverter converter(input_parameters, output_parameters, false); | 207 AudioConverter converter(input_parameters, output_parameters, false); |
210 FakeAudioRenderCallback callback(0.2); | 208 FakeAudioRenderCallback callback(0.2); |
211 scoped_ptr<AudioBus> audio_bus = AudioBus::Create(output_parameters); | 209 scoped_ptr<AudioBus> audio_bus = AudioBus::Create(output_parameters); |
212 converter.AddInput(&callback); | 210 converter.AddInput(&callback); |
213 converter.Convert(audio_bus.get()); | 211 converter.Convert(audio_bus.get()); |
214 | 212 |
215 // Calculate the expected buffer delay for given AudioParameters. | 213 // Calculate the expected buffer delay for given AudioParameters. |
216 double input_sample_rate = input_parameters.sample_rate(); | 214 double input_sample_rate = input_parameters.sample_rate(); |
217 int fill_count = | 215 int fill_count = |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 // No resampling. No channel mixing. | 253 // No resampling. No channel mixing. |
256 std::tr1::make_tuple(44100, 44100, CHANNEL_LAYOUT_STEREO, 0.00000048), | 254 std::tr1::make_tuple(44100, 44100, CHANNEL_LAYOUT_STEREO, 0.00000048), |
257 | 255 |
258 // Upsampling. Channel upmixing. | 256 // Upsampling. Channel upmixing. |
259 std::tr1::make_tuple(44100, 48000, CHANNEL_LAYOUT_QUAD, 0.033), | 257 std::tr1::make_tuple(44100, 48000, CHANNEL_LAYOUT_QUAD, 0.033), |
260 | 258 |
261 // Downsampling. Channel downmixing. | 259 // Downsampling. Channel downmixing. |
262 std::tr1::make_tuple(48000, 41000, CHANNEL_LAYOUT_MONO, 0.042))); | 260 std::tr1::make_tuple(48000, 41000, CHANNEL_LAYOUT_MONO, 0.042))); |
263 | 261 |
264 } // namespace media | 262 } // namespace media |
OLD | NEW |