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

Unified Diff: webrtc/modules/audio_device/fine_audio_buffer_unittest.cc

Issue 2894873002: Improved audio buffer handling for iOS (Closed)
Patch Set: rebased Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_device/fine_audio_buffer_unittest.cc
diff --git a/webrtc/modules/audio_device/fine_audio_buffer_unittest.cc b/webrtc/modules/audio_device/fine_audio_buffer_unittest.cc
index 535f16816cb4998230d6394d14b2af9c88007ea6..c7fef57097ce6417a573b9360001ed281714561d 100644
--- a/webrtc/modules/audio_device/fine_audio_buffer_unittest.cc
+++ b/webrtc/modules/audio_device/fine_audio_buffer_unittest.cc
@@ -13,6 +13,7 @@
#include <limits.h>
#include <memory>
+#include "webrtc/base/array_view.h"
#include "webrtc/modules/audio_device/mock_audio_device_buffer.h"
#include "webrtc/test/gmock.h"
#include "webrtc/test/gtest.h"
@@ -24,6 +25,9 @@ using ::testing::Return;
namespace webrtc {
+const int kSampleRate = 44100;
+const int kSamplesPer10Ms = kSampleRate * 10 / 1000;
+
// The fake audio data is 0,1,..SCHAR_MAX-1,0,1,... This is to make it easy
// to detect errors. This function verifies that the buffers contain such data.
// E.g. if there are two buffers of size 3, buffer 1 would contain 0,1,2 and
@@ -80,8 +84,7 @@ ACTION_P2(VerifyInputBuffer, iteration, samples_per_10_ms) {
return 0;
}
-void RunFineBufferTest(int sample_rate, int frame_size_in_samples) {
- const int kSamplesPer10Ms = sample_rate * 10 / 1000;
+void RunFineBufferTest(int frame_size_in_samples) {
const int kFrameSizeBytes =
frame_size_in_samples * static_cast<int>(sizeof(int16_t));
const int kNumberOfFrames = 5;
@@ -114,33 +117,29 @@ void RunFineBufferTest(int sample_rate, int frame_size_in_samples) {
.Times(kNumberOfUpdateBufferCalls - 1)
.WillRepeatedly(Return(kSamplesPer10Ms));
- FineAudioBuffer fine_buffer(&audio_device_buffer, kFrameSizeBytes,
- sample_rate);
+ FineAudioBuffer fine_buffer(&audio_device_buffer, kSampleRate,
+ kFrameSizeBytes);
+ std::unique_ptr<int8_t[]> out_buffer(new int8_t[kFrameSizeBytes]);
+ std::unique_ptr<int8_t[]> in_buffer(new int8_t[kFrameSizeBytes]);
- std::unique_ptr<int8_t[]> out_buffer;
- out_buffer.reset(new int8_t[kFrameSizeBytes]);
- std::unique_ptr<int8_t[]> in_buffer;
- in_buffer.reset(new int8_t[kFrameSizeBytes]);
for (int i = 0; i < kNumberOfFrames; ++i) {
- fine_buffer.GetPlayoutData(out_buffer.get());
+ fine_buffer.GetPlayoutData(
+ rtc::ArrayView<int8_t>(out_buffer.get(), kFrameSizeBytes));
EXPECT_TRUE(VerifyBuffer(out_buffer.get(), i, kFrameSizeBytes));
UpdateInputBuffer(in_buffer.get(), i, kFrameSizeBytes);
- fine_buffer.DeliverRecordedData(in_buffer.get(), kFrameSizeBytes, 0, 0);
+ fine_buffer.DeliverRecordedData(
+ rtc::ArrayView<const int8_t>(in_buffer.get(), kFrameSizeBytes), 0, 0);
}
}
TEST(FineBufferTest, BufferLessThan10ms) {
- const int kSampleRate = 44100;
- const int kSamplesPer10Ms = kSampleRate * 10 / 1000;
const int kFrameSizeSamples = kSamplesPer10Ms - 50;
- RunFineBufferTest(kSampleRate, kFrameSizeSamples);
+ RunFineBufferTest(kFrameSizeSamples);
}
TEST(FineBufferTest, GreaterThan10ms) {
- const int kSampleRate = 44100;
- const int kSamplesPer10Ms = kSampleRate * 10 / 1000;
const int kFrameSizeSamples = kSamplesPer10Ms + 50;
- RunFineBufferTest(kSampleRate, kFrameSizeSamples);
+ RunFineBufferTest(kFrameSizeSamples);
}
} // namespace webrtc
« no previous file with comments | « webrtc/modules/audio_device/fine_audio_buffer.cc ('k') | webrtc/modules/audio_device/ios/audio_device_ios.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698