| OLD | NEW |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "media/base/audio_bus.h" | 10 #include "media/base/audio_bus.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 scoped_ptr<AudioBus> input(AudioBus::Create(2, input_size_)); | 45 scoped_ptr<AudioBus> input(AudioBus::Create(2, input_size_)); |
| 46 for (size_t i = 0; i < input_size_; i++) { | 46 for (size_t i = 0; i < input_size_; i++) { |
| 47 input->channel(0)[i] = input->channel(1)[i] = input_sample_n_; | 47 input->channel(0)[i] = input->channel(1)[i] = input_sample_n_; |
| 48 input_sample_n_++; | 48 input_sample_n_++; |
| 49 } | 49 } |
| 50 if (tag_input_) { | 50 if (tag_input_) { |
| 51 input->channel(0)[0] = 10000000.0; | 51 input->channel(0)[0] = 10000000.0; |
| 52 tag_input_ = false; | 52 tag_input_ = false; |
| 53 expect_smooth_output_ = false; | 53 expect_smooth_output_ = false; |
| 54 } | 54 } |
| 55 return input.Pass(); | 55 return input; |
| 56 } | 56 } |
| 57 | 57 |
| 58 void SetupOutput(int size, base::TimeDelta rate) { | 58 void SetupOutput(int size, base::TimeDelta rate) { |
| 59 test_output_ = AudioBus::Create(2, size); | 59 test_output_ = AudioBus::Create(2, size); |
| 60 output_rate_ = rate; | 60 output_rate_ = rate; |
| 61 } | 61 } |
| 62 | 62 |
| 63 void SetUp() override { | 63 void SetUp() override { |
| 64 SetupInput( | 64 SetupInput( |
| 65 kInputPacketSize + ::testing::get<0>(GetParam()) - 1, | 65 kInputPacketSize + ::testing::get<0>(GetParam()) - 1, |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 double output_sample_; | 158 double output_sample_; |
| 159 }; | 159 }; |
| 160 | 160 |
| 161 TEST_P(AudioShifterTest, TestSync) { | 161 TEST_P(AudioShifterTest, TestSync) { |
| 162 RunAndCheckSync(1000); | 162 RunAndCheckSync(1000); |
| 163 EXPECT_EQ(0UL, skip_outputs_.size()); | 163 EXPECT_EQ(0UL, skip_outputs_.size()); |
| 164 } | 164 } |
| 165 | 165 |
| 166 TEST_P(AudioShifterTest, TestSyncWithPush) { | 166 TEST_P(AudioShifterTest, TestSyncWithPush) { |
| 167 // Push some extra audio. | 167 // Push some extra audio. |
| 168 shifter_.Push(CreateTestInput().Pass(), now_ - base::TimeDelta(input_rate_)); | 168 shifter_.Push(CreateTestInput(), now_ - base::TimeDelta(input_rate_)); |
| 169 RunAndCheckSync(1000); | 169 RunAndCheckSync(1000); |
| 170 EXPECT_LE(skip_outputs_.size(), 2UL); | 170 EXPECT_LE(skip_outputs_.size(), 2UL); |
| 171 } | 171 } |
| 172 | 172 |
| 173 TEST_P(AudioShifterTest, TestSyncWithPull) { | 173 TEST_P(AudioShifterTest, TestSyncWithPull) { |
| 174 // Output should smooth out eventually, but that is not tested yet. | 174 // Output should smooth out eventually, but that is not tested yet. |
| 175 expect_smooth_output_ = false; | 175 expect_smooth_output_ = false; |
| 176 Run(100); | 176 Run(100); |
| 177 for (int i = 0; i < 100; i++) { | 177 for (int i = 0; i < 100; i++) { |
| 178 shifter_.Pull(test_output_.get(), | 178 shifter_.Pull(test_output_.get(), |
| (...skipping 23 matching lines...) Expand all Loading... |
| 202 , | 202 , |
| 203 AudioShifterTest, | 203 AudioShifterTest, |
| 204 ::testing::Combine(::testing::Range(0, 3), | 204 ::testing::Combine(::testing::Range(0, 3), |
| 205 ::testing::Range(0, 3), | 205 ::testing::Range(0, 3), |
| 206 ::testing::Range(0, 3), | 206 ::testing::Range(0, 3), |
| 207 ::testing::Bool())); | 207 ::testing::Bool())); |
| 208 | 208 |
| 209 #endif | 209 #endif |
| 210 | 210 |
| 211 } // namespace media | 211 } // namespace media |
| OLD | NEW |