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

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

Issue 1172163004: Reformat existing code. There should be no functional effects. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Resync Created 5 years, 6 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
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
(...skipping 30 matching lines...) Expand all
41 // Read until the buffer is as empty as possible. 41 // Read until the buffer is as empty as possible.
42 while (buf.ReadFramesAvailable() >= num_read_chunk_frames) { 42 while (buf.ReadFramesAvailable() >= num_read_chunk_frames) {
43 EXPECT_LT(output_pos, total_frames); 43 EXPECT_LT(output_pos, total_frames);
44 buf.Read(output->Slice(slice.get(), static_cast<int>(output_pos)), 44 buf.Read(output->Slice(slice.get(), static_cast<int>(output_pos)),
45 num_channels, num_read_chunk_frames); 45 num_channels, num_read_chunk_frames);
46 output_pos += num_read_chunk_frames; 46 output_pos += num_read_chunk_frames;
47 } 47 }
48 } 48 }
49 49
50 // Write and read the last bit. 50 // Write and read the last bit.
51 if (input_pos < total_frames) 51 if (input_pos < total_frames) {
52 buf.Write(input.Slice(slice.get(), static_cast<int>(input_pos)), 52 buf.Write(input.Slice(slice.get(), static_cast<int>(input_pos)),
53 num_channels, total_frames - input_pos); 53 num_channels, total_frames - input_pos);
54 if (buf.ReadFramesAvailable()) 54 }
55 if (buf.ReadFramesAvailable()) {
55 buf.Read(output->Slice(slice.get(), static_cast<int>(output_pos)), 56 buf.Read(output->Slice(slice.get(), static_cast<int>(output_pos)),
56 num_channels, buf.ReadFramesAvailable()); 57 num_channels, buf.ReadFramesAvailable());
58 }
57 EXPECT_EQ(0u, buf.ReadFramesAvailable()); 59 EXPECT_EQ(0u, buf.ReadFramesAvailable());
58 } 60 }
59 61
60 TEST_P(AudioRingBufferTest, ReadDataMatchesWrittenData) { 62 TEST_P(AudioRingBufferTest, ReadDataMatchesWrittenData) {
61 const size_t kFrames = 5000; 63 const size_t kFrames = 5000;
62 const size_t num_channels = ::testing::get<3>(GetParam()); 64 const size_t num_channels = ::testing::get<3>(GetParam());
63 65
64 // Initialize the input data to an increasing sequence. 66 // Initialize the input data to an increasing sequence.
65 ChannelBuffer<float> input(kFrames, static_cast<int>(num_channels)); 67 ChannelBuffer<float> input(kFrames, static_cast<int>(num_channels));
66 for (size_t i = 0; i < num_channels; ++i) 68 for (size_t i = 0; i < num_channels; ++i)
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 buf.MoveReadPosition(3); 101 buf.MoveReadPosition(3);
100 ChannelBuffer<float> output(1, kNumChannels); 102 ChannelBuffer<float> output(1, kNumChannels);
101 buf.Read(output.channels(), kNumChannels, 1); 103 buf.Read(output.channels(), kNumChannels, 1);
102 EXPECT_EQ(4, output.channels()[0][0]); 104 EXPECT_EQ(4, output.channels()[0][0]);
103 buf.MoveReadPosition(-3); 105 buf.MoveReadPosition(-3);
104 buf.Read(output.channels(), kNumChannels, 1); 106 buf.Read(output.channels(), kNumChannels, 1);
105 EXPECT_EQ(2, output.channels()[0][0]); 107 EXPECT_EQ(2, output.channels()[0][0]);
106 } 108 }
107 109
108 } // namespace webrtc 110 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698