From 4030c65c30995c8b0920f9e01454cae5c792fc49 Mon Sep 17 00:00:00 2001 From: Sam Zackrisson Date: Fri, 12 Jan 2018 13:47:53 +0100 Subject: [PATCH] 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 Reviewed-by: Alex Loiko Commit-Queue: Alex Loiko Cr-Commit-Position: refs/heads/master@{#21603} --- modules/audio_processing/test/bitexactness_tools.cc | 1 + modules/audio_processing/test/bitexactness_tools.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/audio_processing/test/bitexactness_tools.cc b/modules/audio_processing/test/bitexactness_tools.cc index c49bb5099f..0e9d369452 100644 --- a/modules/audio_processing/test/bitexactness_tools.cc +++ b/modules/audio_processing/test/bitexactness_tools.cc @@ -57,6 +57,7 @@ void ReadFloatSamplesFromStereoFile(size_t samples_per_channel, size_t num_channels, InputAudioFile* stereo_pcm_file, rtc::ArrayView data) { + RTC_DCHECK_LE(num_channels, 2); RTC_DCHECK_EQ(data.size(), samples_per_channel * num_channels); std::vector 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 eb5ee081c3..2d3113276d 100644 --- a/modules/audio_processing/test/bitexactness_tools.h +++ b/modules/audio_processing/test/bitexactness_tools.h @@ -29,7 +29,7 @@ std::string GetApmRenderTestVectorFileName(int sample_rate_hz); // 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,