| OLD | NEW |
| 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 |
| 11 #include "webrtc/modules/audio_device/fine_audio_buffer.h" | 11 #include "webrtc/modules/audio_device/fine_audio_buffer.h" |
| 12 | 12 |
| 13 #include <limits.h> | 13 #include <limits.h> |
| 14 #include <memory> | 14 #include <memory> |
| 15 | 15 |
| 16 #include "webrtc/base/array_view.h" |
| 16 #include "webrtc/modules/audio_device/mock_audio_device_buffer.h" | 17 #include "webrtc/modules/audio_device/mock_audio_device_buffer.h" |
| 17 #include "webrtc/test/gmock.h" | 18 #include "webrtc/test/gmock.h" |
| 18 #include "webrtc/test/gtest.h" | 19 #include "webrtc/test/gtest.h" |
| 19 | 20 |
| 20 using ::testing::_; | 21 using ::testing::_; |
| 21 using ::testing::AtLeast; | 22 using ::testing::AtLeast; |
| 22 using ::testing::InSequence; | 23 using ::testing::InSequence; |
| 23 using ::testing::Return; | 24 using ::testing::Return; |
| 24 | 25 |
| 25 namespace webrtc { | 26 namespace webrtc { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 .WillOnce(VerifyInputBuffer(j, kSamplesPer10Ms)) | 108 .WillOnce(VerifyInputBuffer(j, kSamplesPer10Ms)) |
| 108 .RetiresOnSaturation(); | 109 .RetiresOnSaturation(); |
| 109 } | 110 } |
| 110 } | 111 } |
| 111 EXPECT_CALL(audio_device_buffer, SetVQEData(_, _, _)) | 112 EXPECT_CALL(audio_device_buffer, SetVQEData(_, _, _)) |
| 112 .Times(kNumberOfUpdateBufferCalls - 1); | 113 .Times(kNumberOfUpdateBufferCalls - 1); |
| 113 EXPECT_CALL(audio_device_buffer, DeliverRecordedData()) | 114 EXPECT_CALL(audio_device_buffer, DeliverRecordedData()) |
| 114 .Times(kNumberOfUpdateBufferCalls - 1) | 115 .Times(kNumberOfUpdateBufferCalls - 1) |
| 115 .WillRepeatedly(Return(kSamplesPer10Ms)); | 116 .WillRepeatedly(Return(kSamplesPer10Ms)); |
| 116 | 117 |
| 117 FineAudioBuffer fine_buffer(&audio_device_buffer, kFrameSizeBytes, | 118 FineAudioBuffer fine_buffer(&audio_device_buffer, sample_rate, |
| 118 sample_rate); | 119 kFrameSizeBytes); |
| 119 | 120 |
| 120 std::unique_ptr<int8_t[]> out_buffer; | 121 int8_t out_buffer[kFrameSizeBytes]; |
| 121 out_buffer.reset(new int8_t[kFrameSizeBytes]); | 122 int8_t in_buffer[kFrameSizeBytes]; |
| 122 std::unique_ptr<int8_t[]> in_buffer; | |
| 123 in_buffer.reset(new int8_t[kFrameSizeBytes]); | |
| 124 for (int i = 0; i < kNumberOfFrames; ++i) { | 123 for (int i = 0; i < kNumberOfFrames; ++i) { |
| 125 fine_buffer.GetPlayoutData(out_buffer.get()); | 124 fine_buffer.GetPlayoutData( |
| 126 EXPECT_TRUE(VerifyBuffer(out_buffer.get(), i, kFrameSizeBytes)); | 125 rtc::ArrayView<int8_t>(out_buffer, kFrameSizeBytes)); |
| 127 UpdateInputBuffer(in_buffer.get(), i, kFrameSizeBytes); | 126 EXPECT_TRUE(VerifyBuffer(out_buffer, i, kFrameSizeBytes)); |
| 128 fine_buffer.DeliverRecordedData(in_buffer.get(), kFrameSizeBytes, 0, 0); | 127 UpdateInputBuffer(in_buffer, i, kFrameSizeBytes); |
| 128 fine_buffer.DeliverRecordedData( |
| 129 rtc::ArrayView<const int8_t>(in_buffer, kFrameSizeBytes), 0, 0); |
| 129 } | 130 } |
| 130 } | 131 } |
| 131 | 132 |
| 132 TEST(FineBufferTest, BufferLessThan10ms) { | 133 TEST(FineBufferTest, BufferLessThan10ms) { |
| 133 const int kSampleRate = 44100; | 134 const int kSampleRate = 44100; |
| 134 const int kSamplesPer10Ms = kSampleRate * 10 / 1000; | 135 const int kSamplesPer10Ms = kSampleRate * 10 / 1000; |
| 135 const int kFrameSizeSamples = kSamplesPer10Ms - 50; | 136 const int kFrameSizeSamples = kSamplesPer10Ms - 50; |
| 136 RunFineBufferTest(kSampleRate, kFrameSizeSamples); | 137 RunFineBufferTest(kSampleRate, kFrameSizeSamples); |
| 137 } | 138 } |
| 138 | 139 |
| 139 TEST(FineBufferTest, GreaterThan10ms) { | 140 TEST(FineBufferTest, GreaterThan10ms) { |
| 140 const int kSampleRate = 44100; | 141 const int kSampleRate = 44100; |
| 141 const int kSamplesPer10Ms = kSampleRate * 10 / 1000; | 142 const int kSamplesPer10Ms = kSampleRate * 10 / 1000; |
| 142 const int kFrameSizeSamples = kSamplesPer10Ms + 50; | 143 const int kFrameSizeSamples = kSamplesPer10Ms + 50; |
| 143 RunFineBufferTest(kSampleRate, kFrameSizeSamples); | 144 RunFineBufferTest(kSampleRate, kFrameSizeSamples); |
| 144 } | 145 } |
| 145 | 146 |
| 146 } // namespace webrtc | 147 } // namespace webrtc |
| OLD | NEW |