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/time/time.h" | 5 #include "base/time/time.h" |
6 #include "media/audio/audio_power_monitor.h" | 6 #include "media/audio/audio_power_monitor.h" |
7 #include "media/base/audio_block_fifo.h" | 7 #include "media/base/audio_block_fifo.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 namespace media { | 10 namespace media { |
11 | 11 |
12 class AudioBlockFifoTest : public testing::Test { | 12 class AudioBlockFifoTest : public testing::Test { |
13 public: | 13 public: |
14 AudioBlockFifoTest() {} | 14 AudioBlockFifoTest() {} |
15 virtual ~AudioBlockFifoTest() {} | 15 ~AudioBlockFifoTest() override {} |
16 | 16 |
17 void PushAndVerify(AudioBlockFifo* fifo, int frames_to_push, | 17 void PushAndVerify(AudioBlockFifo* fifo, int frames_to_push, |
18 int channels, int block_frames, int max_frames) { | 18 int channels, int block_frames, int max_frames) { |
19 for (int filled_frames = max_frames - fifo->GetUnfilledFrames(); | 19 for (int filled_frames = max_frames - fifo->GetUnfilledFrames(); |
20 filled_frames + frames_to_push <= max_frames;) { | 20 filled_frames + frames_to_push <= max_frames;) { |
21 Push(fifo, frames_to_push, channels); | 21 Push(fifo, frames_to_push, channels); |
22 filled_frames += frames_to_push; | 22 filled_frames += frames_to_push; |
23 EXPECT_EQ(max_frames - filled_frames, fifo->GetUnfilledFrames()); | 23 EXPECT_EQ(max_frames - filled_frames, fifo->GetUnfilledFrames()); |
24 EXPECT_EQ(static_cast<int>(filled_frames / block_frames), | 24 EXPECT_EQ(static_cast<int>(filled_frames / block_frames), |
25 fifo->available_blocks()); | 25 fifo->available_blocks()); |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 expected_available_blocks); | 217 expected_available_blocks); |
218 } | 218 } |
219 | 219 |
220 // Fill up one block of buffer and consume it, FIFO should then be empty. | 220 // Fill up one block of buffer and consume it, FIFO should then be empty. |
221 const int available_frames = max_frames - expected_unfilled_frames; | 221 const int available_frames = max_frames - expected_unfilled_frames; |
222 Push(&fifo, frames - available_frames, channels); | 222 Push(&fifo, frames - available_frames, channels); |
223 ConsumeAndVerify(&fifo, max_frames, 0); | 223 ConsumeAndVerify(&fifo, max_frames, 0); |
224 } | 224 } |
225 | 225 |
226 } // namespace media | 226 } // namespace media |
OLD | NEW |