Add DCHECK and documentation to disallow trying to read more than two audio channels in helper function.
Bug: webrtc:8741
Change-Id: Ib55b15bb1802b412be17ef8199d6112937502cd3
Reviewed-on: https://webrtc-review.googlesource.com/39263
Reviewed-by: Fredrik Solenberg <solenberg@webrtc.org>
Reviewed-by: Alex Loiko <aleloi@webrtc.org>
Commit-Queue: Alex Loiko <aleloi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21603}
diff --git a/modules/audio_processing/test/bitexactness_tools.cc b/modules/audio_processing/test/bitexactness_tools.cc
index c49bb50..0e9d369 100644
--- a/modules/audio_processing/test/bitexactness_tools.cc
+++ b/modules/audio_processing/test/bitexactness_tools.cc
@@ -57,6 +57,7 @@
size_t num_channels,
InputAudioFile* stereo_pcm_file,
rtc::ArrayView<float> data) {
+ RTC_DCHECK_LE(num_channels, 2);
RTC_DCHECK_EQ(data.size(), samples_per_channel * num_channels);
std::vector<int16_t> read_samples(samples_per_channel * 2);
stereo_pcm_file->Read(samples_per_channel * 2, read_samples.data());
diff --git a/modules/audio_processing/test/bitexactness_tools.h b/modules/audio_processing/test/bitexactness_tools.h
index eb5ee08..2d31132 100644
--- a/modules/audio_processing/test/bitexactness_tools.h
+++ b/modules/audio_processing/test/bitexactness_tools.h
@@ -29,7 +29,7 @@
// APM bitexactness test.
std::string GetApmCaptureTestVectorFileName(int sample_rate_hz);
-// Extract float samples from a pcm file.
+// Extract float samples of up to two channels from a pcm file.
void ReadFloatSamplesFromStereoFile(size_t samples_per_channel,
size_t num_channels,
InputAudioFile* stereo_pcm_file,