| 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 #include <cmath> | 5 #include <cmath> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 | 56 |
| 57 void MultiChannelTest(int channels, int frames, double expected_max_rms_error, | 57 void MultiChannelTest(int channels, int frames, double expected_max_rms_error, |
| 58 double expected_max_error) { | 58 double expected_max_error) { |
| 59 InitializeAudioData(channels, frames); | 59 InitializeAudioData(channels, frames); |
| 60 MultiChannelResampler resampler( | 60 MultiChannelResampler resampler( |
| 61 channels, kScaleFactor, base::Bind( | 61 channels, kScaleFactor, base::Bind( |
| 62 &MultiChannelResamplerTest::ProvideInput, | 62 &MultiChannelResamplerTest::ProvideInput, |
| 63 base::Unretained(this))); | 63 base::Unretained(this))); |
| 64 resampler.Resample(audio_bus_.get(), frames); | 64 resampler.Resample(audio_bus_.get(), frames); |
| 65 TestValues(expected_max_rms_error, expected_max_error); | 65 TestValues(expected_max_rms_error, expected_max_error); |
| 66 |
| 67 // Verify Flush() of our internal state. |
| 68 EXPECT_NE(resampler.last_frame_count_, 0); |
| 69 resampler.Flush(); |
| 70 EXPECT_EQ(resampler.last_frame_count_, 0); |
| 66 } | 71 } |
| 67 | 72 |
| 68 void HighLatencyTest(int channels) { | 73 void HighLatencyTest(int channels) { |
| 69 MultiChannelTest(channels, kHighLatencySize, kHighLatencyMaxRMSError, | 74 MultiChannelTest(channels, kHighLatencySize, kHighLatencyMaxRMSError, |
| 70 kHighLatencyMaxError); | 75 kHighLatencyMaxError); |
| 71 } | 76 } |
| 72 | 77 |
| 73 void LowLatencyTest(int channels) { | 78 void LowLatencyTest(int channels) { |
| 74 MultiChannelTest(channels, kLowLatencySize, kLowLatencyMaxRMSError, | 79 MultiChannelTest(channels, kLowLatencySize, kLowLatencyMaxRMSError, |
| 75 kLowLatencyMaxError); | 80 kLowLatencyMaxError); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 TEST_P(MultiChannelResamplerTest, LowLatency) { | 116 TEST_P(MultiChannelResamplerTest, LowLatency) { |
| 112 LowLatencyTest(GetParam()); | 117 LowLatencyTest(GetParam()); |
| 113 } | 118 } |
| 114 | 119 |
| 115 // Test common channel layouts: mono, stereo, 5.1, 7.1. | 120 // Test common channel layouts: mono, stereo, 5.1, 7.1. |
| 116 INSTANTIATE_TEST_CASE_P( | 121 INSTANTIATE_TEST_CASE_P( |
| 117 MultiChannelResamplerTest, MultiChannelResamplerTest, | 122 MultiChannelResamplerTest, MultiChannelResamplerTest, |
| 118 testing::Values(1, 2, 6, 8)); | 123 testing::Values(1, 2, 6, 8)); |
| 119 | 124 |
| 120 } // namespace media | 125 } // namespace media |
| OLD | NEW |