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

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

Issue 1726043002: Revert of Replace scoped_ptr with unique_ptr in webrtc/common_audio/ (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: 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
13 #include "webrtc/common_audio/audio_ring_buffer.h" 11 #include "webrtc/common_audio/audio_ring_buffer.h"
14 12
15 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
16 #include "webrtc/common_audio/channel_buffer.h" 14 #include "webrtc/common_audio/channel_buffer.h"
17 15
18 namespace webrtc { 16 namespace webrtc {
19 17
20 class AudioRingBufferTest : 18 class AudioRingBufferTest :
21 public ::testing::TestWithParam< ::testing::tuple<int, int, int, int> > { 19 public ::testing::TestWithParam< ::testing::tuple<int, int, int, int> > {
22 }; 20 };
23 21
24 void ReadAndWriteTest(const ChannelBuffer<float>& input, 22 void ReadAndWriteTest(const ChannelBuffer<float>& input,
25 size_t num_write_chunk_frames, 23 size_t num_write_chunk_frames,
26 size_t num_read_chunk_frames, 24 size_t num_read_chunk_frames,
27 size_t buffer_frames, 25 size_t buffer_frames,
28 ChannelBuffer<float>* output) { 26 ChannelBuffer<float>* output) {
29 const size_t num_channels = input.num_channels(); 27 const size_t num_channels = input.num_channels();
30 const size_t total_frames = input.num_frames(); 28 const size_t total_frames = input.num_frames();
31 AudioRingBuffer buf(num_channels, buffer_frames); 29 AudioRingBuffer buf(num_channels, buffer_frames);
32 std::unique_ptr<float* []> slice(new float*[num_channels]); 30 rtc::scoped_ptr<float* []> slice(new float* [num_channels]);
33 31
34 size_t input_pos = 0; 32 size_t input_pos = 0;
35 size_t output_pos = 0; 33 size_t output_pos = 0;
36 while (input_pos + buf.WriteFramesAvailable() < total_frames) { 34 while (input_pos + buf.WriteFramesAvailable() < total_frames) {
37 // Write until the buffer is as full as possible. 35 // Write until the buffer is as full as possible.
38 while (buf.WriteFramesAvailable() >= num_write_chunk_frames) { 36 while (buf.WriteFramesAvailable() >= num_write_chunk_frames) {
39 buf.Write(input.Slice(slice.get(), input_pos), num_channels, 37 buf.Write(input.Slice(slice.get(), input_pos), num_channels,
40 num_write_chunk_frames); 38 num_write_chunk_frames);
41 input_pos += num_write_chunk_frames; 39 input_pos += num_write_chunk_frames;
42 } 40 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 buf.MoveReadPositionForward(3); 101 buf.MoveReadPositionForward(3);
104 ChannelBuffer<float> output(1, kNumChannels); 102 ChannelBuffer<float> output(1, kNumChannels);
105 buf.Read(output.channels(), kNumChannels, 1); 103 buf.Read(output.channels(), kNumChannels, 1);
106 EXPECT_EQ(4, output.channels()[0][0]); 104 EXPECT_EQ(4, output.channels()[0][0]);
107 buf.MoveReadPositionBackward(3); 105 buf.MoveReadPositionBackward(3);
108 buf.Read(output.channels(), kNumChannels, 1); 106 buf.Read(output.channels(), kNumChannels, 1);
109 EXPECT_EQ(2, output.channels()[0][0]); 107 EXPECT_EQ(2, output.channels()[0][0]);
110 } 108 }
111 109
112 } // namespace webrtc 110 } // 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