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 <memory> |
8 #include <vector> | 9 #include <vector> |
9 | 10 |
10 #include "media/base/audio_bus.h" | 11 #include "media/base/audio_bus.h" |
11 #include "media/base/audio_shifter.h" | 12 #include "media/base/audio_shifter.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
13 | 14 |
14 namespace media { | 15 namespace media { |
15 | 16 |
16 const int kSampleRate = 48000; | 17 const int kSampleRate = 48000; |
17 const int kInputPacketSize = 48; | 18 const int kInputPacketSize = 48; |
(...skipping 16 matching lines...) Expand all Loading... |
34 expect_smooth_output_(true), | 35 expect_smooth_output_(true), |
35 input_sample_n_(0), | 36 input_sample_n_(0), |
36 output_sample_(0) { | 37 output_sample_(0) { |
37 } | 38 } |
38 | 39 |
39 void SetupInput(int size, base::TimeDelta rate) { | 40 void SetupInput(int size, base::TimeDelta rate) { |
40 input_size_ = size; | 41 input_size_ = size; |
41 input_rate_ = rate; | 42 input_rate_ = rate; |
42 } | 43 } |
43 | 44 |
44 scoped_ptr<AudioBus> CreateTestInput() { | 45 std::unique_ptr<AudioBus> CreateTestInput() { |
45 scoped_ptr<AudioBus> input(AudioBus::Create(2, input_size_)); | 46 std::unique_ptr<AudioBus> input(AudioBus::Create(2, input_size_)); |
46 for (size_t i = 0; i < input_size_; i++) { | 47 for (size_t i = 0; i < input_size_; i++) { |
47 input->channel(0)[i] = input->channel(1)[i] = input_sample_n_; | 48 input->channel(0)[i] = input->channel(1)[i] = input_sample_n_; |
48 input_sample_n_++; | 49 input_sample_n_++; |
49 } | 50 } |
50 if (tag_input_) { | 51 if (tag_input_) { |
51 input->channel(0)[0] = 10000000.0; | 52 input->channel(0)[0] = 10000000.0; |
52 tag_input_ = false; | 53 tag_input_ = false; |
53 expect_smooth_output_ = false; | 54 expect_smooth_output_ = false; |
54 } | 55 } |
55 return input; | 56 return input; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 | 140 |
140 protected: | 141 protected: |
141 AudioShifter shifter_; | 142 AudioShifter shifter_; |
142 base::TimeDelta input_rate_; | 143 base::TimeDelta input_rate_; |
143 base::TimeDelta output_rate_; | 144 base::TimeDelta output_rate_; |
144 base::TimeDelta end2end_latency_; | 145 base::TimeDelta end2end_latency_; |
145 base::TimeDelta playback_latency_; | 146 base::TimeDelta playback_latency_; |
146 base::TimeTicks time_to_push_; | 147 base::TimeTicks time_to_push_; |
147 base::TimeTicks time_to_pull_; | 148 base::TimeTicks time_to_pull_; |
148 base::TimeTicks now_; | 149 base::TimeTicks now_; |
149 scoped_ptr<AudioBus> test_input_; | 150 std::unique_ptr<AudioBus> test_input_; |
150 scoped_ptr<AudioBus> test_output_; | 151 std::unique_ptr<AudioBus> test_output_; |
151 std::vector<base::TimeTicks> silent_outputs_; | 152 std::vector<base::TimeTicks> silent_outputs_; |
152 std::vector<base::TimeTicks> skip_outputs_; | 153 std::vector<base::TimeTicks> skip_outputs_; |
153 std::vector<base::TimeTicks> marker_outputs_; | 154 std::vector<base::TimeTicks> marker_outputs_; |
154 size_t input_size_; | 155 size_t input_size_; |
155 bool tag_input_; | 156 bool tag_input_; |
156 bool expect_smooth_output_; | 157 bool expect_smooth_output_; |
157 size_t input_sample_n_; | 158 size_t input_sample_n_; |
158 double output_sample_; | 159 double output_sample_; |
159 }; | 160 }; |
160 | 161 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 , | 203 , |
203 AudioShifterTest, | 204 AudioShifterTest, |
204 ::testing::Combine(::testing::Range(0, 3), | 205 ::testing::Combine(::testing::Range(0, 3), |
205 ::testing::Range(0, 3), | 206 ::testing::Range(0, 3), |
206 ::testing::Range(0, 3), | 207 ::testing::Range(0, 3), |
207 ::testing::Bool())); | 208 ::testing::Bool())); |
208 | 209 |
209 #endif | 210 #endif |
210 | 211 |
211 } // namespace media | 212 } // namespace media |
OLD | NEW |