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 // The format of these tests are to enqueue a known amount of data and then | 5 // The format of these tests are to enqueue a known amount of data and then |
6 // request the exact amount we expect in order to dequeue the known amount of | 6 // request the exact amount we expect in order to dequeue the known amount of |
7 // data. This ensures that for any rate we are consuming input data at the | 7 // data. This ensures that for any rate we are consuming input data at the |
8 // correct rate. We always pass in a very large destination buffer with the | 8 // correct rate. We always pass in a very large destination buffer with the |
9 // expectation that FillBuffer() will fill as much as it can but no more. | 9 // expectation that FillBuffer() will fill as much as it can but no more. |
10 | 10 |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 frames_enqueued_ += kFrameSize; | 144 frames_enqueued_ += kFrameSize; |
145 } | 145 } |
146 } | 146 } |
147 | 147 |
148 void CheckFakeData(AudioBus* audio_data, int frames_written) { | 148 void CheckFakeData(AudioBus* audio_data, int frames_written) { |
149 // Check each channel individually. | 149 // Check each channel individually. |
150 for (int ch = 0; ch < channels_; ++ch) { | 150 for (int ch = 0; ch < channels_; ++ch) { |
151 bool all_zero = true; | 151 bool all_zero = true; |
152 for (int i = 0; i < frames_written && all_zero; ++i) | 152 for (int i = 0; i < frames_written && all_zero; ++i) |
153 all_zero = audio_data->channel(ch)[i] == 0.0f; | 153 all_zero = audio_data->channel(ch)[i] == 0.0f; |
154 ASSERT_FALSE(all_zero) << " for channel " << ch; | 154 ASSERT_EQ(algorithm_.is_muted(), all_zero) << " for channel " << ch; |
155 } | 155 } |
156 } | 156 } |
157 | 157 |
158 int ComputeConsumedFrames(int initial_frames_enqueued, | 158 int ComputeConsumedFrames(int initial_frames_enqueued, |
159 int initial_frames_buffered) { | 159 int initial_frames_buffered) { |
160 int frame_delta = frames_enqueued_ - initial_frames_enqueued; | 160 int frame_delta = frames_enqueued_ - initial_frames_enqueued; |
161 int buffered_delta = algorithm_.frames_buffered() - initial_frames_buffered; | 161 int buffered_delta = algorithm_.frames_buffered() - initial_frames_buffered; |
162 int consumed = frame_delta - buffered_delta; | 162 int consumed = frame_delta - buffered_delta; |
163 CHECK_GE(consumed, 0); | 163 CHECK_GE(consumed, 0); |
164 return consumed; | 164 return consumed; |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 | 634 |
635 TEST_F(AudioRendererAlgorithmTest, WsolaSlowdown) { | 635 TEST_F(AudioRendererAlgorithmTest, WsolaSlowdown) { |
636 WsolaTest(0.6f); | 636 WsolaTest(0.6f); |
637 } | 637 } |
638 | 638 |
639 TEST_F(AudioRendererAlgorithmTest, WsolaSpeedup) { | 639 TEST_F(AudioRendererAlgorithmTest, WsolaSpeedup) { |
640 WsolaTest(1.6f); | 640 WsolaTest(1.6f); |
641 } | 641 } |
642 | 642 |
643 } // namespace media | 643 } // namespace media |
OLD | NEW |