webrtc/modules/audio_processing: Use RTC_DCHECK() instead of assert()

Review-Url: https://codereview.webrtc.org/2320053003
Cr-Commit-Position: refs/heads/master@{#14211}
This commit is contained in:
kwiberg
2016-09-14 05:23:22 -07:00
committed by Commit bot
parent 3a7f35b1c4
commit 9e2be5f292
27 changed files with 159 additions and 149 deletions

View File

@ -39,7 +39,7 @@ Agc::Agc()
Agc::~Agc() {}
float Agc::AnalyzePreproc(const int16_t* audio, size_t length) {
assert(length > 0);
RTC_DCHECK_GT(length, 0u);
size_t num_clipped = 0;
for (size_t i = 0; i < length; ++i) {
if (audio[i] == 32767 || audio[i] == -32768)
@ -62,7 +62,7 @@ int Agc::Process(const int16_t* audio, size_t length, int sample_rate_hz) {
bool Agc::GetRmsErrorDb(int* error) {
if (!error) {
assert(false);
RTC_NOTREACHED();
return false;
}

View File

@ -10,13 +10,13 @@
#include "webrtc/modules/audio_processing/agc/agc_manager_direct.h"
#include <cassert>
#include <cmath>
#ifdef WEBRTC_AGC_DEBUG_DUMP
#include <cstdio>
#endif
#include "webrtc/base/checks.h"
#include "webrtc/modules/audio_processing/agc/gain_map_internal.h"
#include "webrtc/modules/audio_processing/gain_control_impl.h"
#include "webrtc/modules/include/module_common_types.h"
@ -61,7 +61,8 @@ int ClampLevel(int mic_level) {
}
int LevelFromGainError(int gain_error, int level) {
assert(level >= 0 && level <= kMaxMicLevel);
RTC_DCHECK_GE(level, 0);
RTC_DCHECK_LE(level, kMaxMicLevel);
if (gain_error == 0) {
return level;
}
@ -90,7 +91,7 @@ class DebugFile {
public:
explicit DebugFile(const char* filename)
: file_(fopen(filename, "wb")) {
assert(file_);
RTC_DCHECK(file_);
}
~DebugFile() {
fclose(file_);
@ -245,7 +246,7 @@ void AgcManagerDirect::Process(const int16_t* audio,
if (agc_->Process(audio, length, sample_rate_hz) != 0) {
LOG(LS_ERROR) << "Agc::Process failed";
assert(false);
RTC_NOTREACHED();
}
UpdateGain();
@ -297,7 +298,7 @@ void AgcManagerDirect::SetLevel(int new_level) {
}
void AgcManagerDirect::SetMaxLevel(int level) {
assert(level >= kClippedLevelMin);
RTC_DCHECK_GE(level, kClippedLevelMin);
max_level_ = level;
// Scale the |kSurplusCompressionGain| linearly across the restricted
// level range.

View File

@ -13,6 +13,7 @@
#include <cmath>
#include <cstring>
#include "webrtc/base/checks.h"
#include "webrtc/modules/include/module_common_types.h"
namespace webrtc {
@ -101,7 +102,7 @@ void LoudnessHistogram::Update(double rms, double activity_probaility) {
// Doing nothing if buffer is not full, yet.
void LoudnessHistogram::RemoveOldestEntryAndUpdate() {
assert(len_circular_buffer_ > 0);
RTC_DCHECK_GT(len_circular_buffer_, 0);
// Do nothing if circular buffer is not full.
if (!buffer_is_full_)
return;
@ -114,7 +115,7 @@ void LoudnessHistogram::RemoveOldestEntryAndUpdate() {
void LoudnessHistogram::RemoveTransient() {
// Don't expect to be here if high-activity region is longer than
// |kTransientWidthThreshold| or there has not been any transient.
assert(len_high_activity_ <= kTransientWidthThreshold);
RTC_DCHECK_LE(len_high_activity_, kTransientWidthThreshold);
int index =
(buffer_index_ > 0) ? (buffer_index_ - 1) : len_circular_buffer_ - 1;
while (len_high_activity_ > 0) {