Use std::array<> consistently for reusable audio buffers.
This is a minor change for places where we use
AudioFrame::kMaxDataSizeSamples sized intermediary buffers. The change
uses `std::array<>` instead of C style arrays which allows for use
of utility templates that incorporate type based buffer size checking.
Also adding `ClearSamples()` method, which complements CopySamples.
Bug: chromium:335805780
Change-Id: I813feb32937e020ceb9ca4b00632dc90907c93fb
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/351681
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Reviewed-by: Per Ã…hgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#42400}
diff --git a/audio/remix_resample.cc b/audio/remix_resample.cc
index 26d0c85..fdea627 100644
--- a/audio/remix_resample.cc
+++ b/audio/remix_resample.cc
@@ -10,6 +10,8 @@
#include "audio/remix_resample.h"
+#include <array>
+
#include "api/audio/audio_frame.h"
#include "audio/utility/audio_frame_operations.h"
#include "common_audio/resampler/include/push_resampler.h"
@@ -40,7 +42,7 @@
AudioFrame* dst_frame) {
const int16_t* audio_ptr = src_data;
size_t audio_ptr_num_channels = num_channels;
- int16_t downmixed_audio[AudioFrame::kMaxDataSizeSamples];
+ std::array<int16_t, AudioFrame::kMaxDataSizeSamples> downmixed_audio;
// Downmix before resampling.
if (num_channels > dst_frame->num_channels_) {
@@ -54,7 +56,7 @@
num_channels),
InterleavedView<int16_t>(&downmixed_audio[0], samples_per_channel,
dst_frame->num_channels_));
- audio_ptr = downmixed_audio;
+ audio_ptr = downmixed_audio.data();
audio_ptr_num_channels = dst_frame->num_channels_;
}