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

Side by Side Diff: webrtc/common_audio/audio_ring_buffer_unittest.cc

Issue 1712513002: Replace scoped_ptr with unique_ptr in webrtc/common_audio/ (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase Created 4 years, 10 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 | « webrtc/common_audio/audio_ring_buffer.h ('k') | webrtc/common_audio/blocker.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 /* 1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include <memory>
12
11 #include "webrtc/common_audio/audio_ring_buffer.h" 13 #include "webrtc/common_audio/audio_ring_buffer.h"
12 14
13 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
14 #include "webrtc/common_audio/channel_buffer.h" 16 #include "webrtc/common_audio/channel_buffer.h"
15 17
16 namespace webrtc { 18 namespace webrtc {
17 19
18 class AudioRingBufferTest : 20 class AudioRingBufferTest :
19 public ::testing::TestWithParam< ::testing::tuple<int, int, int, int> > { 21 public ::testing::TestWithParam< ::testing::tuple<int, int, int, int> > {
20 }; 22 };
21 23
22 void ReadAndWriteTest(const ChannelBuffer<float>& input, 24 void ReadAndWriteTest(const ChannelBuffer<float>& input,
23 size_t num_write_chunk_frames, 25 size_t num_write_chunk_frames,
24 size_t num_read_chunk_frames, 26 size_t num_read_chunk_frames,
25 size_t buffer_frames, 27 size_t buffer_frames,
26 ChannelBuffer<float>* output) { 28 ChannelBuffer<float>* output) {
27 const size_t num_channels = input.num_channels(); 29 const size_t num_channels = input.num_channels();
28 const size_t total_frames = input.num_frames(); 30 const size_t total_frames = input.num_frames();
29 AudioRingBuffer buf(num_channels, buffer_frames); 31 AudioRingBuffer buf(num_channels, buffer_frames);
30 rtc::scoped_ptr<float* []> slice(new float* [num_channels]); 32 std::unique_ptr<float* []> slice(new float*[num_channels]);
31 33
32 size_t input_pos = 0; 34 size_t input_pos = 0;
33 size_t output_pos = 0; 35 size_t output_pos = 0;
34 while (input_pos + buf.WriteFramesAvailable() < total_frames) { 36 while (input_pos + buf.WriteFramesAvailable() < total_frames) {
35 // Write until the buffer is as full as possible. 37 // Write until the buffer is as full as possible.
36 while (buf.WriteFramesAvailable() >= num_write_chunk_frames) { 38 while (buf.WriteFramesAvailable() >= num_write_chunk_frames) {
37 buf.Write(input.Slice(slice.get(), input_pos), num_channels, 39 buf.Write(input.Slice(slice.get(), input_pos), num_channels,
38 num_write_chunk_frames); 40 num_write_chunk_frames);
39 input_pos += num_write_chunk_frames; 41 input_pos += num_write_chunk_frames;
40 } 42 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 buf.MoveReadPositionForward(3); 103 buf.MoveReadPositionForward(3);
102 ChannelBuffer<float> output(1, kNumChannels); 104 ChannelBuffer<float> output(1, kNumChannels);
103 buf.Read(output.channels(), kNumChannels, 1); 105 buf.Read(output.channels(), kNumChannels, 1);
104 EXPECT_EQ(4, output.channels()[0][0]); 106 EXPECT_EQ(4, output.channels()[0][0]);
105 buf.MoveReadPositionBackward(3); 107 buf.MoveReadPositionBackward(3);
106 buf.Read(output.channels(), kNumChannels, 1); 108 buf.Read(output.channels(), kNumChannels, 1);
107 EXPECT_EQ(2, output.channels()[0][0]); 109 EXPECT_EQ(2, output.channels()[0][0]);
108 } 110 }
109 111
110 } // namespace webrtc 112 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/common_audio/audio_ring_buffer.h ('k') | webrtc/common_audio/blocker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698