OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
6 #include "media/base/audio_buffer.h" | 6 #include "media/base/audio_buffer.h" |
7 #include "media/base/audio_buffer_converter.h" | 7 #include "media/base/audio_buffer_converter.h" |
8 #include "media/base/sinc_resampler.h" | 8 #include "media/base/sinc_resampler.h" |
9 #include "media/base/test_helpers.h" | 9 #include "media/base/test_helpers.h" |
10 #include "testing/gmock/include/gmock/gmock.h" | 10 #include "testing/gmock/include/gmock/gmock.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 | 12 |
13 namespace media { | 13 namespace media { |
14 | 14 |
15 // Important: Use an odd buffer size here so SIMD issues are caught. | 15 // Important: Use an odd buffer size here so SIMD issues are caught. |
16 const int kOutFrameSize = 441; | 16 const int kOutFrameSize = 441; |
17 const int kOutSampleRate = 44100; | 17 const int kOutSampleRate = 44100; |
18 const ChannelLayout kOutChannelLayout = CHANNEL_LAYOUT_STEREO; | 18 const ChannelLayout kOutChannelLayout = CHANNEL_LAYOUT_STEREO; |
19 const int kOutChannelCount = 2; | 19 const int kOutChannelCount = 2; |
20 | 20 |
21 static scoped_refptr<AudioBuffer> MakeTestBuffer(int sample_rate, | 21 static scoped_refptr<AudioBuffer> MakeTestBuffer(int sample_rate, |
22 ChannelLayout channel_layout, | 22 ChannelLayout channel_layout, |
23 int channel_count, | 23 int channel_count, |
24 int frames) { | 24 int frames) { |
25 return MakeAudioBuffer<uint8>(kSampleFormatU8, | 25 return MakeAudioBuffer<uint8_t>(kSampleFormatU8, channel_layout, |
26 channel_layout, | 26 channel_count, sample_rate, 0, 1, frames, |
27 channel_count, | 27 base::TimeDelta::FromSeconds(0)); |
28 sample_rate, | |
29 0, | |
30 1, | |
31 frames, | |
32 base::TimeDelta::FromSeconds(0)); | |
33 } | 28 } |
34 | 29 |
35 class AudioBufferConverterTest : public ::testing::Test { | 30 class AudioBufferConverterTest : public ::testing::Test { |
36 public: | 31 public: |
37 AudioBufferConverterTest() | 32 AudioBufferConverterTest() |
38 : input_frames_(0), | 33 : input_frames_(0), |
39 expected_output_frames_(0.0), | 34 expected_output_frames_(0.0), |
40 output_frames_(0), | 35 output_frames_(0), |
41 output_params_(AudioParameters::AUDIO_PCM_LOW_LATENCY, | 36 output_params_(AudioParameters::AUDIO_PCM_LOW_LATENCY, |
42 kOutChannelLayout, | 37 kOutChannelLayout, |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 | 237 |
243 // Since the input buffer size is a multiple of the input request size there | 238 // Since the input buffer size is a multiple of the input request size there |
244 // should never be any frames remaining at this point. | 239 // should never be any frames remaining at this point. |
245 ASSERT_EQ(kInputFrameSize % | 240 ASSERT_EQ(kInputFrameSize % |
246 audio_buffer_converter_->input_buffer_size_for_testing(), | 241 audio_buffer_converter_->input_buffer_size_for_testing(), |
247 0); | 242 0); |
248 EXPECT_EQ(0, audio_buffer_converter_->input_frames_left_for_testing()); | 243 EXPECT_EQ(0, audio_buffer_converter_->input_frames_left_for_testing()); |
249 } | 244 } |
250 | 245 |
251 } // namespace media | 246 } // namespace media |
OLD | NEW |