Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Side by Side Diff: media/base/audio_block_fifo_unittest.cc

Issue 1906423005: Replace scoped_ptr with std::unique_ptr in //media/base. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scopedptr-media-base: android Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/base/android/sdk_media_codec_bridge_unittest.cc ('k') | media/base/audio_buffer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stdint.h> 5 #include <stdint.h>
6 #include <memory>
6 7
7 #include "base/macros.h" 8 #include "base/macros.h"
8 #include "base/time/time.h" 9 #include "base/time/time.h"
9 #include "media/audio/audio_power_monitor.h" 10 #include "media/audio/audio_power_monitor.h"
10 #include "media/base/audio_block_fifo.h" 11 #include "media/base/audio_block_fifo.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
12 13
13 namespace media { 14 namespace media {
14 15
15 class AudioBlockFifoTest : public testing::Test { 16 class AudioBlockFifoTest : public testing::Test {
(...skipping 10 matching lines...) Expand all
26 EXPECT_EQ(max_frames - filled_frames, fifo->GetUnfilledFrames()); 27 EXPECT_EQ(max_frames - filled_frames, fifo->GetUnfilledFrames());
27 EXPECT_EQ(static_cast<int>(filled_frames / block_frames), 28 EXPECT_EQ(static_cast<int>(filled_frames / block_frames),
28 fifo->available_blocks()); 29 fifo->available_blocks());
29 } 30 }
30 } 31 }
31 32
32 void Push(AudioBlockFifo* fifo, int frames_to_push, int channels) { 33 void Push(AudioBlockFifo* fifo, int frames_to_push, int channels) {
33 DCHECK_LE(frames_to_push, fifo->GetUnfilledFrames()); 34 DCHECK_LE(frames_to_push, fifo->GetUnfilledFrames());
34 const int bytes_per_sample = 2; 35 const int bytes_per_sample = 2;
35 const int data_byte_size = bytes_per_sample * channels * frames_to_push; 36 const int data_byte_size = bytes_per_sample * channels * frames_to_push;
36 scoped_ptr<uint8_t[]> data(new uint8_t[data_byte_size]); 37 std::unique_ptr<uint8_t[]> data(new uint8_t[data_byte_size]);
37 memset(data.get(), 1, data_byte_size); 38 memset(data.get(), 1, data_byte_size);
38 fifo->Push(data.get(), frames_to_push, bytes_per_sample); 39 fifo->Push(data.get(), frames_to_push, bytes_per_sample);
39 } 40 }
40 41
41 void ConsumeAndVerify(AudioBlockFifo* fifo, int expected_unfilled_frames, 42 void ConsumeAndVerify(AudioBlockFifo* fifo, int expected_unfilled_frames,
42 int expected_available_blocks) { 43 int expected_available_blocks) {
43 const AudioBus* bus = fifo->Consume(); 44 const AudioBus* bus = fifo->Consume();
44 EXPECT_EQ(fifo->GetUnfilledFrames(), expected_unfilled_frames); 45 EXPECT_EQ(fifo->GetUnfilledFrames(), expected_unfilled_frames);
45 EXPECT_EQ(fifo->available_blocks(), expected_available_blocks); 46 EXPECT_EQ(fifo->available_blocks(), expected_available_blocks);
46 47
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 expected_available_blocks); 221 expected_available_blocks);
221 } 222 }
222 223
223 // Fill up one block of buffer and consume it, FIFO should then be empty. 224 // Fill up one block of buffer and consume it, FIFO should then be empty.
224 const int available_frames = max_frames - expected_unfilled_frames; 225 const int available_frames = max_frames - expected_unfilled_frames;
225 Push(&fifo, frames - available_frames, channels); 226 Push(&fifo, frames - available_frames, channels);
226 ConsumeAndVerify(&fifo, max_frames, 0); 227 ConsumeAndVerify(&fifo, max_frames, 0);
227 } 228 }
228 229
229 } // namespace media 230 } // namespace media
OLDNEW
« no previous file with comments | « media/base/android/sdk_media_codec_bridge_unittest.cc ('k') | media/base/audio_buffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698