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

Side by Side Diff: webrtc/modules/audio_device/fine_audio_buffer_unittest.cc

Issue 2715963002: Simplifies FineAudioBuffer by using rtc::Buffer (Closed)
Patch Set: Improvements Created 3 years, 9 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) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 EXPECT_CALL(audio_device_buffer, SetVQEData(_, _, _)) 111 EXPECT_CALL(audio_device_buffer, SetVQEData(_, _, _))
112 .Times(kNumberOfUpdateBufferCalls - 1); 112 .Times(kNumberOfUpdateBufferCalls - 1);
113 EXPECT_CALL(audio_device_buffer, DeliverRecordedData()) 113 EXPECT_CALL(audio_device_buffer, DeliverRecordedData())
114 .Times(kNumberOfUpdateBufferCalls - 1) 114 .Times(kNumberOfUpdateBufferCalls - 1)
115 .WillRepeatedly(Return(kSamplesPer10Ms)); 115 .WillRepeatedly(Return(kSamplesPer10Ms));
116 116
117 FineAudioBuffer fine_buffer(&audio_device_buffer, kFrameSizeBytes, 117 FineAudioBuffer fine_buffer(&audio_device_buffer, kFrameSizeBytes,
118 sample_rate); 118 sample_rate);
119 119
120 std::unique_ptr<int8_t[]> out_buffer; 120 std::unique_ptr<int8_t[]> out_buffer;
121 out_buffer.reset(new int8_t[fine_buffer.RequiredPlayoutBufferSizeBytes()]); 121 out_buffer.reset(new int8_t[kFrameSizeBytes]);
122 std::unique_ptr<int8_t[]> in_buffer; 122 std::unique_ptr<int8_t[]> in_buffer;
123 in_buffer.reset(new int8_t[kFrameSizeBytes]); 123 in_buffer.reset(new int8_t[kFrameSizeBytes]);
124 for (int i = 0; i < kNumberOfFrames; ++i) { 124 for (int i = 0; i < kNumberOfFrames; ++i) {
125 fine_buffer.GetPlayoutData(out_buffer.get()); 125 fine_buffer.GetPlayoutData(out_buffer.get());
126 EXPECT_TRUE(VerifyBuffer(out_buffer.get(), i, kFrameSizeBytes)); 126 EXPECT_TRUE(VerifyBuffer(out_buffer.get(), i, kFrameSizeBytes));
127 UpdateInputBuffer(in_buffer.get(), i, kFrameSizeBytes); 127 UpdateInputBuffer(in_buffer.get(), i, kFrameSizeBytes);
128 fine_buffer.DeliverRecordedData(in_buffer.get(), kFrameSizeBytes, 0, 0); 128 fine_buffer.DeliverRecordedData(in_buffer.get(), kFrameSizeBytes, 0, 0);
129 } 129 }
130 } 130 }
131 131
132 TEST(FineBufferTest, BufferLessThan10ms) { 132 TEST(FineBufferTest, BufferLessThan10ms) {
133 const int kSampleRate = 44100; 133 const int kSampleRate = 44100;
134 const int kSamplesPer10Ms = kSampleRate * 10 / 1000; 134 const int kSamplesPer10Ms = kSampleRate * 10 / 1000;
135 const int kFrameSizeSamples = kSamplesPer10Ms - 50; 135 const int kFrameSizeSamples = kSamplesPer10Ms - 50;
136 RunFineBufferTest(kSampleRate, kFrameSizeSamples); 136 RunFineBufferTest(kSampleRate, kFrameSizeSamples);
137 } 137 }
138 138
139 TEST(FineBufferTest, GreaterThan10ms) { 139 TEST(FineBufferTest, GreaterThan10ms) {
140 const int kSampleRate = 44100; 140 const int kSampleRate = 44100;
141 const int kSamplesPer10Ms = kSampleRate * 10 / 1000; 141 const int kSamplesPer10Ms = kSampleRate * 10 / 1000;
142 const int kFrameSizeSamples = kSamplesPer10Ms + 50; 142 const int kFrameSizeSamples = kSamplesPer10Ms + 50;
143 RunFineBufferTest(kSampleRate, kFrameSizeSamples); 143 RunFineBufferTest(kSampleRate, kFrameSizeSamples);
144 } 144 }
145 145
146 } // namespace webrtc 146 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698