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 "media/base/audio_converter.h" | 8 #include "media/base/audio_converter.h" |
9 | 9 |
10 #include <stddef.h> | 10 #include <stddef.h> |
11 | 11 |
12 #include <cmath> | 12 #include <cmath> |
13 #include <memory> | 13 #include <memory> |
14 | 14 |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/memory/scoped_vector.h" | 16 #include "base/memory/scoped_vector.h" |
17 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
| 18 #include "media/base/audio_timestamp_helper.h" |
18 #include "media/base/fake_audio_render_callback.h" | 19 #include "media/base/fake_audio_render_callback.h" |
19 #include "testing/gmock/include/gmock/gmock.h" | 20 #include "testing/gmock/include/gmock/gmock.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
21 | 22 |
22 namespace media { | 23 namespace media { |
23 | 24 |
24 // Parameters which control the many input case tests. | 25 // Parameters which control the many input case tests. |
25 static const int kConvertInputs = 8; | 26 static const int kConvertInputs = 8; |
26 static const int kConvertCycles = 3; | 27 static const int kConvertCycles = 3; |
27 | 28 |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 // (output_parameters.frames_per_buffer() * input_sample_rate / | 223 // (output_parameters.frames_per_buffer() * input_sample_rate / |
223 // output_parameters.sample_rate()) / | 224 // output_parameters.sample_rate()) / |
224 // input_parameters.frames_per_buffer(); | 225 // input_parameters.frames_per_buffer(); |
225 // | 226 // |
226 // This magic number is the accumulated MultiChannelResampler delay after | 227 // This magic number is the accumulated MultiChannelResampler delay after |
227 // |fill_count| (4) callbacks to provide input. The number of frames delayed | 228 // |fill_count| (4) callbacks to provide input. The number of frames delayed |
228 // is an implementation detail of the SincResampler chunk size (480 for the | 229 // is an implementation detail of the SincResampler chunk size (480 for the |
229 // first two callbacks, 512 for the last two callbacks). See | 230 // first two callbacks, 512 for the last two callbacks). See |
230 // SincResampler.ChunkSize(). | 231 // SincResampler.ChunkSize(). |
231 int kExpectedDelay = 992; | 232 int kExpectedDelay = 992; |
232 | 233 auto expected_delay = |
233 EXPECT_EQ(kExpectedDelay, callback.last_frames_delayed()); | 234 AudioTimestampHelper::FramesToTime(kExpectedDelay, kSampleRate); |
| 235 EXPECT_EQ(expected_delay, callback.last_delay()); |
234 EXPECT_EQ(input_parameters.channels(), callback.last_channel_count()); | 236 EXPECT_EQ(input_parameters.channels(), callback.last_channel_count()); |
235 } | 237 } |
236 | 238 |
237 TEST_P(AudioConverterTest, ArbitraryOutputRequestSize) { | 239 TEST_P(AudioConverterTest, ArbitraryOutputRequestSize) { |
238 // Resize output bus to be half of |output_parameters_|'s frames_per_buffer(). | 240 // Resize output bus to be half of |output_parameters_|'s frames_per_buffer(). |
239 audio_bus_ = AudioBus::Create(output_parameters_.channels(), | 241 audio_bus_ = AudioBus::Create(output_parameters_.channels(), |
240 output_parameters_.frames_per_buffer() / 2); | 242 output_parameters_.frames_per_buffer() / 2); |
241 RunTest(1); | 243 RunTest(1); |
242 } | 244 } |
243 | 245 |
(...skipping 15 matching lines...) Expand all Loading... |
259 // No resampling. No channel mixing. | 261 // No resampling. No channel mixing. |
260 std::tr1::make_tuple(44100, 44100, CHANNEL_LAYOUT_STEREO, 0.00000048), | 262 std::tr1::make_tuple(44100, 44100, CHANNEL_LAYOUT_STEREO, 0.00000048), |
261 | 263 |
262 // Upsampling. Channel upmixing. | 264 // Upsampling. Channel upmixing. |
263 std::tr1::make_tuple(44100, 48000, CHANNEL_LAYOUT_QUAD, 0.033), | 265 std::tr1::make_tuple(44100, 48000, CHANNEL_LAYOUT_QUAD, 0.033), |
264 | 266 |
265 // Downsampling. Channel downmixing. | 267 // Downsampling. Channel downmixing. |
266 std::tr1::make_tuple(48000, 41000, CHANNEL_LAYOUT_MONO, 0.042))); | 268 std::tr1::make_tuple(48000, 41000, CHANNEL_LAYOUT_MONO, 0.042))); |
267 | 269 |
268 } // namespace media | 270 } // namespace media |
OLD | NEW |