Reland of Adding a some checks and switching out a few assert for RTC_[D]CHECK. (patchset #1 id:1 of https://codereview.webrtc.org/2018553002/ )

Adding a some checks and switching out a few assert for RTC_[D]CHECK.
These changes are around use of AudioFrame.data_ to help us catch issues earlier since assert() is left out in release builds, including builds with DCHECK enabled.  I've also added a few full-on CHECKs to avoid reading past buffer boundaries or continuing on in a failed state.

TBR=kjellander@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true

Committed: https://crrev.com/60c4e0ae8f124f08372645a95042f4a1246d7aa3
Cr-Commit-Position: refs/heads/master@{#12925}

Committed: https://crrev.com/5771beb265129082d31736259b7dc6ca037cff4d
Cr-Commit-Position: refs/heads/master@{#12926}

Committed: https://crrev.com/54e1c6a500e390e543bce7b78fae65eb9bb14ab6
Cr-Commit-Position: refs/heads/master@{#12927}

Committed: https://crrev.com/f9d2fe983fe196373850c55acd3dc3824add480e
Cr-Commit-Position: refs/heads/master@{#12928}

Committed: f4fc0ff6f9

Review URL: https://codereview.webrtc.org/2014973002 .

Cr-Commit-Position: refs/heads/master@{#12930}
This commit is contained in:
Tommi
2016-05-26 22:55:35 +02:00
parent f4fc0ff6f9
commit c47f0099ee

View File

@ -31,7 +31,10 @@ void CheckValidInitParams(int src_sample_rate_hz, int dst_sample_rate_hz,
RTC_DCHECK_LE(num_channels, 2u);
}
void CheckExpectedBufferSizes(size_t num_channels, int src_sample_rate,
void CheckExpectedBufferSizes(size_t src_length,
size_t dst_capacity,
size_t num_channels,
int src_sample_rate,
int dst_sample_rate) {
const size_t src_size_10ms = src_sample_rate * num_channels / 100;
const size_t dst_size_10ms = dst_sample_rate * num_channels / 100;
@ -94,8 +97,8 @@ int PushResampler<T>::InitializeIfNeeded(int src_sample_rate_hz,
template <typename T>
int PushResampler<T>::Resample(const T* src, size_t src_length, T* dst,
size_t dst_capacity) {
CheckExpectedBufferSizes(num_channels_, src_sample_rate_hz_,
dst_sample_rate_hz_)
CheckExpectedBufferSizes(src_length, dst_capacity, num_channels_,
src_sample_rate_hz_, dst_sample_rate_hz_);
if (src_sample_rate_hz_ == dst_sample_rate_hz_) {
// The old resampler provides this memcpy facility in the case of matching