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

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

Cr-Commit-Position: refs/heads/master@{#12925}
This commit is contained in:
Tommi 2016-05-26 21:35:27 +02:00
parent 6f8d686d35
commit 60c4e0ae8f
2 changed files with 1 additions and 17 deletions

View File

@ -2995,6 +2995,7 @@ uint32_t Channel::PrepareEncodeAndSend(int mixingFrequency) {
if (_includeAudioLevelIndication) {
size_t length =
_audioFrame.samples_per_channel_ * _audioFrame.num_channels_;
RTC_CHECK_LE(length, sizeof(_audioFrame.data_));
if (is_muted && previous_frame_muted_) {
rms_level_.ProcessMuted(length);
} else {

View File

@ -107,20 +107,3 @@ TEST_F(ExternalMediaTest,
EXPECT_EQ(0, voe_xmedia_->SetExternalMixing(channel_, false));
ResumePlaying();
}
TEST_F(ExternalMediaTest,
ExternalMixingResamplingToInvalidFrequenciesFails) {
const int kInvalidFrequencies[] = {-8000, -1};
webrtc::AudioFrame frame;
PausePlaying();
EXPECT_EQ(0, voe_xmedia_->SetExternalMixing(channel_, true));
ResumePlaying();
for (size_t i = 0; i < arraysize(kInvalidFrequencies); i++) {
int f = kInvalidFrequencies[i];
EXPECT_EQ(-1, voe_xmedia_->GetAudioFrame(channel_, f, &frame))
<< "Resampling fails for freq=" << f;
}
PausePlaying();
EXPECT_EQ(0, voe_xmedia_->SetExternalMixing(channel_, false));
ResumePlaying();
}