Replace assert() with RTC_DCHECK().
CL partially auto-generated with:
git grep -l "\bassert(" | grep "\.[c|h]" | \
xargs sed -i 's/\bassert(/RTC_DCHECK(/g'
And with:
git grep -l "RTC_DCHECK(false)" | \
xargs sed -i 's/RTC_DCHECK(false)/RTC_NOTREACHED()/g'
With some manual changes to include "rtc_base/checks.h" where
needed.
A follow-up CL will remove assert() from Obj-C code as well
and remove the #include of <assert.h>.
The choice to replace with RTC_DCHECK is because assert()
is because RTC_DCHECK has similar behavior as assert()
based on NDEBUG.
This CL also contains manual changes to switch from
basic RTC_DCHECK to other (preferred) versions like
RTC_DCHECK_GT (and similar).
Bug: webrtc:6779
Change-Id: I00bed8886e03d685a2f42324e34aef2c9b7a63b0
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/224846
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34442}
diff --git a/api/audio_codecs/audio_decoder.cc b/api/audio_codecs/audio_decoder.cc
index 97cda27..4b18b4a 100644
--- a/api/audio_codecs/audio_decoder.cc
+++ b/api/audio_codecs/audio_decoder.cc
@@ -162,7 +162,7 @@
case 2:
return kComfortNoise;
default:
- assert(false);
+ RTC_NOTREACHED();
return kSpeech;
}
}
diff --git a/examples/BUILD.gn b/examples/BUILD.gn
index ab3dff0..b109d903 100644
--- a/examples/BUILD.gn
+++ b/examples/BUILD.gn
@@ -760,6 +760,7 @@
"peerconnection/server/utils.h",
]
deps = [
+ "../rtc_base:checks",
"../rtc_base:rtc_base_approved",
"../system_wrappers:field_trial",
"../test:field_trial",
diff --git a/examples/peerconnection/server/data_socket.cc b/examples/peerconnection/server/data_socket.cc
index ced0fd1..2d595a0 100644
--- a/examples/peerconnection/server/data_socket.cc
+++ b/examples/peerconnection/server/data_socket.cc
@@ -10,7 +10,6 @@
#include "examples/peerconnection/server/data_socket.h"
-#include <assert.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
@@ -20,6 +19,7 @@
#endif
#include "examples/peerconnection/server/utils.h"
+#include "rtc_base/checks.h"
static const char kHeaderTerminator[] = "\r\n\r\n";
static const int kHeaderTerminatorLength = sizeof(kHeaderTerminator) - 1;
@@ -53,7 +53,7 @@
//
bool SocketBase::Create() {
- assert(!valid());
+ RTC_DCHECK(!valid());
socket_ = ::socket(AF_INET, SOCK_STREAM, 0);
return valid();
}
@@ -77,7 +77,7 @@
}
bool DataSocket::PathEquals(const char* path) const {
- assert(path);
+ RTC_DCHECK(path);
size_t args = request_path_.find('?');
if (args != std::string::npos)
return request_path_.substr(0, args).compare(path) == 0;
@@ -85,7 +85,7 @@
}
bool DataSocket::OnDataAvailable(bool* close_socket) {
- assert(valid());
+ RTC_DCHECK(valid());
char buffer[0xfff] = {0};
int bytes = recv(socket_, buffer, sizeof(buffer), 0);
if (bytes == SOCKET_ERROR || bytes == 0) {
@@ -125,8 +125,8 @@
const std::string& content_type,
const std::string& extra_headers,
const std::string& data) const {
- assert(valid());
- assert(!status.empty());
+ RTC_DCHECK(valid());
+ RTC_DCHECK(!status.empty());
std::string buffer("HTTP/1.1 " + status + "\r\n");
buffer +=
@@ -165,8 +165,8 @@
}
bool DataSocket::ParseHeaders() {
- assert(!request_headers_.empty());
- assert(method_ == INVALID);
+ RTC_DCHECK(!request_headers_.empty());
+ RTC_DCHECK_EQ(method_, INVALID);
size_t i = request_headers_.find("\r\n");
if (i == std::string::npos)
return false;
@@ -174,8 +174,8 @@
if (!ParseMethodAndPath(request_headers_.data(), i))
return false;
- assert(method_ != INVALID);
- assert(!request_path_.empty());
+ RTC_DCHECK_NE(method_, INVALID);
+ RTC_DCHECK(!request_path_.empty());
if (method_ == POST) {
const char* headers = request_headers_.data() + i + 2;
@@ -225,8 +225,8 @@
}
bool DataSocket::ParseContentLengthAndType(const char* headers, size_t length) {
- assert(content_length_ == 0);
- assert(content_type_.empty());
+ RTC_DCHECK_EQ(content_length_, 0);
+ RTC_DCHECK(content_type_.empty());
const char* end = headers + length;
while (headers && headers < end) {
@@ -267,7 +267,7 @@
//
bool ListeningSocket::Listen(unsigned short port) {
- assert(valid());
+ RTC_DCHECK(valid());
int enabled = 1;
setsockopt(socket_, SOL_SOCKET, SO_REUSEADDR,
reinterpret_cast<const char*>(&enabled), sizeof(enabled));
@@ -284,7 +284,7 @@
}
DataSocket* ListeningSocket::Accept() const {
- assert(valid());
+ RTC_DCHECK(valid());
struct sockaddr_in addr = {0};
socklen_t size = sizeof(addr);
NativeSocket client =
diff --git a/examples/peerconnection/server/main.cc b/examples/peerconnection/server/main.cc
index b80e4d8..50b8c23 100644
--- a/examples/peerconnection/server/main.cc
+++ b/examples/peerconnection/server/main.cc
@@ -8,7 +8,6 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#if defined(WEBRTC_POSIX)
@@ -24,6 +23,7 @@
#include "absl/flags/usage.h"
#include "examples/peerconnection/server/data_socket.h"
#include "examples/peerconnection/server/peer_channel.h"
+#include "rtc_base/checks.h"
#include "system_wrappers/include/field_trial.h"
#include "test/field_trial.h"
@@ -41,8 +41,8 @@
static const size_t kMaxConnections = (FD_SETSIZE - 2);
void HandleBrowserRequest(DataSocket* ds, bool* quit) {
- assert(ds && ds->valid());
- assert(quit);
+ RTC_DCHECK(ds && ds->valid());
+ RTC_DCHECK(quit);
const std::string& path = ds->request_path();
@@ -162,7 +162,7 @@
if (socket_done) {
printf("Disconnecting socket\n");
clients.OnClosing(s);
- assert(s->valid()); // Close must not have been called yet.
+ RTC_DCHECK(s->valid()); // Close must not have been called yet.
FD_CLR(s->socket(), &socket_set);
delete (*i);
i = sockets.erase(i);
diff --git a/examples/peerconnection/server/peer_channel.cc b/examples/peerconnection/server/peer_channel.cc
index be0f282..f53820c 100644
--- a/examples/peerconnection/server/peer_channel.cc
+++ b/examples/peerconnection/server/peer_channel.cc
@@ -10,7 +10,6 @@
#include "examples/peerconnection/server/peer_channel.h"
-#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
@@ -18,6 +17,7 @@
#include "examples/peerconnection/server/data_socket.h"
#include "examples/peerconnection/server/utils.h"
+#include "rtc_base/checks.h"
// Set to the peer id of the originator when messages are being
// exchanged between peers, but set to the id of the receiving peer
@@ -57,9 +57,9 @@
id_(++s_member_id_),
connected_(true),
timestamp_(time(NULL)) {
- assert(socket);
- assert(socket->method() == DataSocket::GET);
- assert(socket->PathEquals("/sign_in"));
+ RTC_DCHECK(socket);
+ RTC_DCHECK_EQ(socket->method(), DataSocket::GET);
+ RTC_DCHECK(socket->PathEquals("/sign_in"));
name_ = socket->request_arguments();
if (name_.empty())
name_ = "peer_" + int2str(id_);
@@ -85,14 +85,14 @@
}
bool ChannelMember::NotifyOfOtherMember(const ChannelMember& other) {
- assert(&other != this);
+ RTC_DCHECK_NE(&other, this);
QueueResponse("200 OK", "text/plain", GetPeerIdHeader(), other.GetEntry());
return true;
}
// Returns a string in the form "name,id,connected\n".
std::string ChannelMember::GetEntry() const {
- assert(name_.length() <= kMaxNameLength);
+ RTC_DCHECK(name_.length() <= kMaxNameLength);
// name, 11-digit int, 1-digit bool, newline, null
char entry[kMaxNameLength + 15];
@@ -102,8 +102,8 @@
}
void ChannelMember::ForwardRequestToPeer(DataSocket* ds, ChannelMember* peer) {
- assert(peer);
- assert(ds);
+ RTC_DCHECK(peer);
+ RTC_DCHECK(ds);
std::string extra_headers(GetPeerIdHeader());
@@ -129,8 +129,8 @@
const std::string& extra_headers,
const std::string& data) {
if (waiting_socket_) {
- assert(queue_.empty());
- assert(waiting_socket_->method() == DataSocket::GET);
+ RTC_DCHECK(queue_.empty());
+ RTC_DCHECK_EQ(waiting_socket_->method(), DataSocket::GET);
bool ok =
waiting_socket_->Send(status, true, content_type, extra_headers, data);
if (!ok) {
@@ -149,9 +149,9 @@
}
void ChannelMember::SetWaitingSocket(DataSocket* ds) {
- assert(ds->method() == DataSocket::GET);
+ RTC_DCHECK_EQ(ds->method(), DataSocket::GET);
if (ds && !queue_.empty()) {
- assert(waiting_socket_ == NULL);
+ RTC_DCHECK(!waiting_socket_);
const QueuedResponse& response = queue_.front();
ds->Send(response.status, true, response.content_type,
response.extra_headers, response.data);
@@ -167,13 +167,13 @@
// static
bool PeerChannel::IsPeerConnection(const DataSocket* ds) {
- assert(ds);
+ RTC_DCHECK(ds);
return (ds->method() == DataSocket::POST && ds->content_length() > 0) ||
(ds->method() == DataSocket::GET && ds->PathEquals("/sign_in"));
}
ChannelMember* PeerChannel::Lookup(DataSocket* ds) const {
- assert(ds);
+ RTC_DCHECK(ds);
if (ds->method() != DataSocket::GET && ds->method() != DataSocket::POST)
return NULL;
@@ -209,7 +209,7 @@
}
ChannelMember* PeerChannel::IsTargetedRequest(const DataSocket* ds) const {
- assert(ds);
+ RTC_DCHECK(ds);
// Regardless of GET or POST, we look for the peer_id parameter
// only in the request_path.
const std::string& path = ds->request_path();
@@ -239,7 +239,7 @@
}
bool PeerChannel::AddMember(DataSocket* ds) {
- assert(IsPeerConnection(ds));
+ RTC_DCHECK(IsPeerConnection(ds));
ChannelMember* new_guy = new ChannelMember(ds);
Members failures;
BroadcastChangedState(*new_guy, &failures);
@@ -308,7 +308,7 @@
void PeerChannel::BroadcastChangedState(const ChannelMember& member,
Members* delivery_failures) {
// This function should be called prior to DataSocket::Close().
- assert(delivery_failures);
+ RTC_DCHECK(delivery_failures);
if (!member.connected()) {
printf("Member disconnected: %s\n", member.name().c_str());
@@ -329,12 +329,12 @@
}
void PeerChannel::HandleDeliveryFailures(Members* failures) {
- assert(failures);
+ RTC_DCHECK(failures);
while (!failures->empty()) {
Members::iterator i = failures->begin();
ChannelMember* member = *i;
- assert(!member->connected());
+ RTC_DCHECK(!member->connected());
failures->erase(i);
BroadcastChangedState(*member, failures);
delete member;
@@ -344,14 +344,14 @@
// Builds a simple list of "name,id\n" entries for each member.
std::string PeerChannel::BuildResponseForNewMember(const ChannelMember& member,
std::string* content_type) {
- assert(content_type);
+ RTC_DCHECK(content_type);
*content_type = "text/plain";
// The peer itself will always be the first entry.
std::string response(member.GetEntry());
for (Members::iterator i = members_.begin(); i != members_.end(); ++i) {
if (member.id() != (*i)->id()) {
- assert((*i)->connected());
+ RTC_DCHECK((*i)->connected());
response += (*i)->GetEntry();
}
}
diff --git a/modules/audio_coding/BUILD.gn b/modules/audio_coding/BUILD.gn
index 28d30d3..d1d1726 100644
--- a/modules/audio_coding/BUILD.gn
+++ b/modules/audio_coding/BUILD.gn
@@ -1606,6 +1606,7 @@
deps += [
":isac_fix",
":webrtc_opus",
+ "../../rtc_base:checks",
"../../rtc_base:rtc_base_approved",
"../../test:test_main",
"../../test:test_support",
diff --git a/modules/audio_coding/acm2/acm_receiver_unittest.cc b/modules/audio_coding/acm2/acm_receiver_unittest.cc
index a8da77e..2338a53 100644
--- a/modules/audio_coding/acm2/acm_receiver_unittest.cc
+++ b/modules/audio_coding/acm2/acm_receiver_unittest.cc
@@ -119,7 +119,7 @@
rtp_header_,
rtc::ArrayView<const uint8_t>(payload_data, payload_len_bytes));
if (ret_val < 0) {
- assert(false);
+ RTC_NOTREACHED();
return -1;
}
rtp_header_.sequenceNumber++;
diff --git a/modules/audio_coding/acm2/acm_resampler.cc b/modules/audio_coding/acm2/acm_resampler.cc
index ca3583e..367ec2b 100644
--- a/modules/audio_coding/acm2/acm_resampler.cc
+++ b/modules/audio_coding/acm2/acm_resampler.cc
@@ -31,7 +31,7 @@
size_t in_length = in_freq_hz * num_audio_channels / 100;
if (in_freq_hz == out_freq_hz) {
if (out_capacity_samples < in_length) {
- assert(false);
+ RTC_NOTREACHED();
return -1;
}
memcpy(out_audio, in_audio, in_length * sizeof(int16_t));
diff --git a/modules/audio_coding/acm2/acm_send_test.cc b/modules/audio_coding/acm2/acm_send_test.cc
index 6f395d6..cda668d 100644
--- a/modules/audio_coding/acm2/acm_send_test.cc
+++ b/modules/audio_coding/acm2/acm_send_test.cc
@@ -51,8 +51,8 @@
input_frame_.sample_rate_hz_ = source_rate_hz_;
input_frame_.num_channels_ = 1;
input_frame_.samples_per_channel_ = input_block_size_samples_;
- assert(input_block_size_samples_ * input_frame_.num_channels_ <=
- AudioFrame::kMaxDataSizeSamples);
+ RTC_DCHECK_LE(input_block_size_samples_ * input_frame_.num_channels_,
+ AudioFrame::kMaxDataSizeSamples);
acm_->RegisterTransportCallback(this);
}
@@ -81,8 +81,8 @@
factory->MakeAudioEncoder(payload_type, format, absl::nullopt));
codec_registered_ = true;
input_frame_.num_channels_ = num_channels;
- assert(input_block_size_samples_ * input_frame_.num_channels_ <=
- AudioFrame::kMaxDataSizeSamples);
+ RTC_DCHECK_LE(input_block_size_samples_ * input_frame_.num_channels_,
+ AudioFrame::kMaxDataSizeSamples);
return codec_registered_;
}
@@ -90,13 +90,13 @@
std::unique_ptr<AudioEncoder> external_speech_encoder) {
input_frame_.num_channels_ = external_speech_encoder->NumChannels();
acm_->SetEncoder(std::move(external_speech_encoder));
- assert(input_block_size_samples_ * input_frame_.num_channels_ <=
- AudioFrame::kMaxDataSizeSamples);
+ RTC_DCHECK_LE(input_block_size_samples_ * input_frame_.num_channels_,
+ AudioFrame::kMaxDataSizeSamples);
codec_registered_ = true;
}
std::unique_ptr<Packet> AcmSendTestOldApi::NextPacket() {
- assert(codec_registered_);
+ RTC_DCHECK(codec_registered_);
if (filter_.test(static_cast<size_t>(payload_type_))) {
// This payload type should be filtered out. Since the payload type is the
// same throughout the whole test run, no packet at all will be delivered.
@@ -133,7 +133,7 @@
payload_type_ = payload_type;
timestamp_ = timestamp;
last_payload_vec_.assign(payload_data, payload_data + payload_len_bytes);
- assert(last_payload_vec_.size() == payload_len_bytes);
+ RTC_DCHECK_EQ(last_payload_vec_.size(), payload_len_bytes);
data_to_send_ = true;
return 0;
}
diff --git a/modules/audio_coding/acm2/audio_coding_module.cc b/modules/audio_coding/acm2/audio_coding_module.cc
index 648ae6e..7d0f4d1 100644
--- a/modules/audio_coding/acm2/audio_coding_module.cc
+++ b/modules/audio_coding/acm2/audio_coding_module.cc
@@ -343,13 +343,13 @@
int AudioCodingModuleImpl::Add10MsDataInternal(const AudioFrame& audio_frame,
InputData* input_data) {
if (audio_frame.samples_per_channel_ == 0) {
- assert(false);
+ RTC_NOTREACHED();
RTC_LOG(LS_ERROR) << "Cannot Add 10 ms audio, payload length is zero";
return -1;
}
if (audio_frame.sample_rate_hz_ > kMaxInputSampleRateHz) {
- assert(false);
+ RTC_NOTREACHED();
RTC_LOG(LS_ERROR) << "Cannot Add 10 ms audio, input frequency not valid";
return -1;
}
diff --git a/modules/audio_coding/codecs/isac/fix/test/isac_speed_test.cc b/modules/audio_coding/codecs/isac/fix/test/isac_speed_test.cc
index 2075263..903ac64 100644
--- a/modules/audio_coding/codecs/isac/fix/test/isac_speed_test.cc
+++ b/modules/audio_coding/codecs/isac/fix/test/isac_speed_test.cc
@@ -11,6 +11,7 @@
#include "modules/audio_coding/codecs/isac/fix/include/isacfix.h"
#include "modules/audio_coding/codecs/isac/fix/source/settings.h"
#include "modules/audio_coding/codecs/tools/audio_codec_speed_test.h"
+#include "rtc_base/checks.h"
using std::string;
@@ -83,7 +84,7 @@
}
clocks = clock() - clocks;
*encoded_bytes = static_cast<size_t>(value);
- assert(*encoded_bytes <= max_bytes);
+ RTC_DCHECK_LE(*encoded_bytes, max_bytes);
return 1000.0 * clocks / CLOCKS_PER_SEC;
}
diff --git a/modules/audio_coding/codecs/legacy_encoded_audio_frame_unittest.cc b/modules/audio_coding/codecs/legacy_encoded_audio_frame_unittest.cc
index 2ca1d4c..f081a53 100644
--- a/modules/audio_coding/codecs/legacy_encoded_audio_frame_unittest.cc
+++ b/modules/audio_coding/codecs/legacy_encoded_audio_frame_unittest.cc
@@ -88,7 +88,7 @@
samples_per_ms_ = 8;
break;
default:
- assert(false);
+ RTC_NOTREACHED();
break;
}
}
diff --git a/modules/audio_coding/codecs/tools/audio_codec_speed_test.cc b/modules/audio_coding/codecs/tools/audio_codec_speed_test.cc
index 3d5ba0b..f61aacc 100644
--- a/modules/audio_coding/codecs/tools/audio_codec_speed_test.cc
+++ b/modules/audio_coding/codecs/tools/audio_codec_speed_test.cc
@@ -10,6 +10,7 @@
#include "modules/audio_coding/codecs/tools/audio_codec_speed_test.h"
+#include "rtc_base/checks.h"
#include "rtc_base/format_macros.h"
#include "test/gtest.h"
#include "test/testsupport/file_utils.h"
@@ -43,7 +44,7 @@
save_out_data_ = get<4>(GetParam());
FILE* fp = fopen(in_filename_.c_str(), "rb");
- assert(fp != NULL);
+ RTC_DCHECK(fp);
// Obtain file size.
fseek(fp, 0, SEEK_END);
@@ -83,7 +84,7 @@
out_filename = test::OutputPath() + out_filename + ".pcm";
out_file_ = fopen(out_filename.c_str(), "wb");
- assert(out_file_ != NULL);
+ RTC_DCHECK(out_file_);
printf("Output to be saved in %s.\n", out_filename.c_str());
}
diff --git a/modules/audio_coding/neteq/accelerate.cc b/modules/audio_coding/neteq/accelerate.cc
index 6161a8f..e97191d 100644
--- a/modules/audio_coding/neteq/accelerate.cc
+++ b/modules/audio_coding/neteq/accelerate.cc
@@ -69,7 +69,7 @@
peak_index = (fs_mult_120 / peak_index) * peak_index;
}
- assert(fs_mult_120 >= peak_index); // Should be handled in Process().
+ RTC_DCHECK_GE(fs_mult_120, peak_index); // Should be handled in Process().
// Copy first part; 0 to 15 ms.
output->PushBackInterleaved(
rtc::ArrayView<const int16_t>(input, fs_mult_120 * num_channels_));
diff --git a/modules/audio_coding/neteq/audio_decoder_unittest.cc b/modules/audio_coding/neteq/audio_decoder_unittest.cc
index 79e989e..2277872 100644
--- a/modules/audio_coding/neteq/audio_decoder_unittest.cc
+++ b/modules/audio_coding/neteq/audio_decoder_unittest.cc
@@ -77,9 +77,9 @@
size_t num_samples,
size_t channels,
int delay) {
- assert(delay < static_cast<int>(num_samples));
- assert(num_samples <= input.size());
- assert(num_samples * channels <= output.size());
+ RTC_DCHECK_LT(delay, static_cast<int>(num_samples));
+ RTC_DCHECK_LE(num_samples, input.size());
+ RTC_DCHECK_LE(num_samples * channels, output.size());
if (num_samples == 0)
return 0.0;
double squared_sum = 0.0;
@@ -303,7 +303,7 @@
frame_size_ = 20 * codec_input_rate_hz_ / 1000;
data_length_ = 10 * frame_size_;
decoder_ = new AudioDecoderPcm16B(codec_input_rate_hz_, 1);
- assert(decoder_);
+ RTC_DCHECK(decoder_);
AudioEncoderPcm16B::Config config;
config.sample_rate_hz = codec_input_rate_hz_;
config.frame_size_ms =
@@ -320,7 +320,7 @@
frame_size_ = 240;
data_length_ = 10 * frame_size_;
decoder_ = new AudioDecoderIlbcImpl;
- assert(decoder_);
+ RTC_DCHECK(decoder_);
AudioEncoderIlbcConfig config;
config.frame_size_ms = 30;
audio_encoder_.reset(new AudioEncoderIlbcImpl(config, payload_type_));
@@ -414,7 +414,7 @@
frame_size_ = 160;
data_length_ = 10 * frame_size_;
decoder_ = new AudioDecoderG722Impl;
- assert(decoder_);
+ RTC_DCHECK(decoder_);
AudioEncoderG722Config config;
config.frame_size_ms = 10;
config.num_channels = 1;
@@ -430,7 +430,7 @@
frame_size_ = 160;
data_length_ = 10 * frame_size_;
decoder_ = new AudioDecoderG722StereoImpl;
- assert(decoder_);
+ RTC_DCHECK(decoder_);
AudioEncoderG722Config config;
config.frame_size_ms = 10;
config.num_channels = 2;
diff --git a/modules/audio_coding/neteq/audio_multi_vector.cc b/modules/audio_coding/neteq/audio_multi_vector.cc
index 349d75d..290d7ea 100644
--- a/modules/audio_coding/neteq/audio_multi_vector.cc
+++ b/modules/audio_coding/neteq/audio_multi_vector.cc
@@ -19,7 +19,7 @@
namespace webrtc {
AudioMultiVector::AudioMultiVector(size_t N) {
- assert(N > 0);
+ RTC_DCHECK_GT(N, 0);
if (N < 1)
N = 1;
for (size_t n = 0; n < N; ++n) {
@@ -29,7 +29,7 @@
}
AudioMultiVector::AudioMultiVector(size_t N, size_t initial_size) {
- assert(N > 0);
+ RTC_DCHECK_GT(N, 0);
if (N < 1)
N = 1;
for (size_t n = 0; n < N; ++n) {
@@ -91,7 +91,7 @@
}
void AudioMultiVector::PushBack(const AudioMultiVector& append_this) {
- assert(num_channels_ == append_this.num_channels_);
+ RTC_DCHECK_EQ(num_channels_, append_this.num_channels_);
if (num_channels_ == append_this.num_channels_) {
for (size_t i = 0; i < num_channels_; ++i) {
channels_[i]->PushBack(append_this[i]);
@@ -101,10 +101,10 @@
void AudioMultiVector::PushBackFromIndex(const AudioMultiVector& append_this,
size_t index) {
- assert(index < append_this.Size());
+ RTC_DCHECK_LT(index, append_this.Size());
index = std::min(index, append_this.Size() - 1);
size_t length = append_this.Size() - index;
- assert(num_channels_ == append_this.num_channels_);
+ RTC_DCHECK_EQ(num_channels_, append_this.num_channels_);
if (num_channels_ == append_this.num_channels_) {
for (size_t i = 0; i < num_channels_; ++i) {
channels_[i]->PushBack(append_this[i], length, index);
@@ -162,9 +162,9 @@
void AudioMultiVector::OverwriteAt(const AudioMultiVector& insert_this,
size_t length,
size_t position) {
- assert(num_channels_ == insert_this.num_channels_);
+ RTC_DCHECK_EQ(num_channels_, insert_this.num_channels_);
// Cap |length| at the length of |insert_this|.
- assert(length <= insert_this.Size());
+ RTC_DCHECK_LE(length, insert_this.Size());
length = std::min(length, insert_this.Size());
if (num_channels_ == insert_this.num_channels_) {
for (size_t i = 0; i < num_channels_; ++i) {
@@ -175,7 +175,7 @@
void AudioMultiVector::CrossFade(const AudioMultiVector& append_this,
size_t fade_length) {
- assert(num_channels_ == append_this.num_channels_);
+ RTC_DCHECK_EQ(num_channels_, append_this.num_channels_);
if (num_channels_ == append_this.num_channels_) {
for (size_t i = 0; i < num_channels_; ++i) {
channels_[i]->CrossFade(append_this[i], fade_length);
@@ -188,7 +188,7 @@
}
size_t AudioMultiVector::Size() const {
- assert(channels_[0]);
+ RTC_DCHECK(channels_[0]);
return channels_[0]->Size();
}
@@ -202,13 +202,13 @@
}
bool AudioMultiVector::Empty() const {
- assert(channels_[0]);
+ RTC_DCHECK(channels_[0]);
return channels_[0]->Empty();
}
void AudioMultiVector::CopyChannel(size_t from_channel, size_t to_channel) {
- assert(from_channel < num_channels_);
- assert(to_channel < num_channels_);
+ RTC_DCHECK_LT(from_channel, num_channels_);
+ RTC_DCHECK_LT(to_channel, num_channels_);
channels_[from_channel]->CopyTo(channels_[to_channel]);
}
diff --git a/modules/audio_coding/neteq/audio_vector.cc b/modules/audio_coding/neteq/audio_vector.cc
index b3ad48f..5e435e9 100644
--- a/modules/audio_coding/neteq/audio_vector.cc
+++ b/modules/audio_coding/neteq/audio_vector.cc
@@ -247,8 +247,8 @@
void AudioVector::CrossFade(const AudioVector& append_this,
size_t fade_length) {
// Fade length cannot be longer than the current vector or |append_this|.
- assert(fade_length <= Size());
- assert(fade_length <= append_this.Size());
+ RTC_DCHECK_LE(fade_length, Size());
+ RTC_DCHECK_LE(fade_length, append_this.Size());
fade_length = std::min(fade_length, Size());
fade_length = std::min(fade_length, append_this.Size());
size_t position = Size() - fade_length + begin_index_;
@@ -265,7 +265,7 @@
(16384 - alpha) * append_this[i] + 8192) >>
14;
}
- assert(alpha >= 0); // Verify that the slope was correct.
+ RTC_DCHECK_GE(alpha, 0); // Verify that the slope was correct.
// Append what is left of |append_this|.
size_t samples_to_push_back = append_this.Size() - fade_length;
if (samples_to_push_back > 0)
diff --git a/modules/audio_coding/neteq/background_noise.cc b/modules/audio_coding/neteq/background_noise.cc
index c0dcc5e..ae4645c 100644
--- a/modules/audio_coding/neteq/background_noise.cc
+++ b/modules/audio_coding/neteq/background_noise.cc
@@ -136,7 +136,7 @@
int16_t* buffer) {
constexpr size_t kNoiseLpcOrder = kMaxLpcOrder;
int16_t scaled_random_vector[kMaxSampleRate / 8000 * 125];
- assert(num_noise_samples <= (kMaxSampleRate / 8000 * 125));
+ RTC_DCHECK_LE(num_noise_samples, (kMaxSampleRate / 8000 * 125));
RTC_DCHECK_GE(random_vector.size(), num_noise_samples);
int16_t* noise_samples = &buffer[kNoiseLpcOrder];
if (initialized()) {
@@ -178,44 +178,44 @@
}
int32_t BackgroundNoise::Energy(size_t channel) const {
- assert(channel < num_channels_);
+ RTC_DCHECK_LT(channel, num_channels_);
return channel_parameters_[channel].energy;
}
void BackgroundNoise::SetMuteFactor(size_t channel, int16_t value) {
- assert(channel < num_channels_);
+ RTC_DCHECK_LT(channel, num_channels_);
channel_parameters_[channel].mute_factor = value;
}
int16_t BackgroundNoise::MuteFactor(size_t channel) const {
- assert(channel < num_channels_);
+ RTC_DCHECK_LT(channel, num_channels_);
return channel_parameters_[channel].mute_factor;
}
const int16_t* BackgroundNoise::Filter(size_t channel) const {
- assert(channel < num_channels_);
+ RTC_DCHECK_LT(channel, num_channels_);
return channel_parameters_[channel].filter;
}
const int16_t* BackgroundNoise::FilterState(size_t channel) const {
- assert(channel < num_channels_);
+ RTC_DCHECK_LT(channel, num_channels_);
return channel_parameters_[channel].filter_state;
}
void BackgroundNoise::SetFilterState(size_t channel,
rtc::ArrayView<const int16_t> input) {
- assert(channel < num_channels_);
+ RTC_DCHECK_LT(channel, num_channels_);
size_t length = std::min(input.size(), kMaxLpcOrder);
memcpy(channel_parameters_[channel].filter_state, input.data(),
length * sizeof(int16_t));
}
int16_t BackgroundNoise::Scale(size_t channel) const {
- assert(channel < num_channels_);
+ RTC_DCHECK_LT(channel, num_channels_);
return channel_parameters_[channel].scale;
}
int16_t BackgroundNoise::ScaleShift(size_t channel) const {
- assert(channel < num_channels_);
+ RTC_DCHECK_LT(channel, num_channels_);
return channel_parameters_[channel].scale_shift;
}
@@ -240,7 +240,7 @@
// to the limited-width operations, it is not exactly the same. The
// difference should be inaudible, but bit-exactness would not be
// maintained.
- assert(channel < num_channels_);
+ RTC_DCHECK_LT(channel, num_channels_);
ChannelParameters& parameters = channel_parameters_[channel];
int32_t temp_energy =
(kThresholdIncrement * parameters.low_energy_update_threshold) >> 16;
@@ -278,7 +278,7 @@
const int16_t* filter_state,
int32_t sample_energy,
int32_t residual_energy) {
- assert(channel < num_channels_);
+ RTC_DCHECK_LT(channel, num_channels_);
ChannelParameters& parameters = channel_parameters_[channel];
memcpy(parameters.filter, lpc_coefficients,
(kMaxLpcOrder + 1) * sizeof(int16_t));
diff --git a/modules/audio_coding/neteq/comfort_noise.cc b/modules/audio_coding/neteq/comfort_noise.cc
index a21cdda..b02e3d7 100644
--- a/modules/audio_coding/neteq/comfort_noise.cc
+++ b/modules/audio_coding/neteq/comfort_noise.cc
@@ -45,8 +45,8 @@
int ComfortNoise::Generate(size_t requested_length, AudioMultiVector* output) {
// TODO(hlundin): Change to an enumerator and skip assert.
- assert(fs_hz_ == 8000 || fs_hz_ == 16000 || fs_hz_ == 32000 ||
- fs_hz_ == 48000);
+ RTC_DCHECK(fs_hz_ == 8000 || fs_hz_ == 16000 || fs_hz_ == 32000 ||
+ fs_hz_ == 48000);
// Not adapted for multi-channel yet.
if (output->Channels() != 1) {
RTC_LOG(LS_ERROR) << "No multi-channel support";
diff --git a/modules/audio_coding/neteq/decision_logic.cc b/modules/audio_coding/neteq/decision_logic.cc
index cb6daf0..d702729 100644
--- a/modules/audio_coding/neteq/decision_logic.cc
+++ b/modules/audio_coding/neteq/decision_logic.cc
@@ -96,7 +96,8 @@
void DecisionLogic::SetSampleRate(int fs_hz, size_t output_size_samples) {
// TODO(hlundin): Change to an enumerator and skip assert.
- assert(fs_hz == 8000 || fs_hz == 16000 || fs_hz == 32000 || fs_hz == 48000);
+ RTC_DCHECK(fs_hz == 8000 || fs_hz == 16000 || fs_hz == 32000 ||
+ fs_hz == 48000);
sample_rate_ = fs_hz;
output_size_samples_ = output_size_samples;
}
diff --git a/modules/audio_coding/neteq/dsp_helper.cc b/modules/audio_coding/neteq/dsp_helper.cc
index 05b0f70..91979f2 100644
--- a/modules/audio_coding/neteq/dsp_helper.cc
+++ b/modules/audio_coding/neteq/dsp_helper.cc
@@ -89,7 +89,7 @@
size_t length,
int factor,
int increment) {
- assert(start_index + length <= signal->Size());
+ RTC_DCHECK_LE(start_index + length, signal->Size());
if (start_index + length > signal->Size()) {
// Wrong parameters. Do nothing and return the scale factor unaltered.
return factor;
@@ -355,7 +355,7 @@
break;
}
default: {
- assert(false);
+ RTC_NOTREACHED();
return -1;
}
}
diff --git a/modules/audio_coding/neteq/expand.cc b/modules/audio_coding/neteq/expand.cc
index 8df2c7a..ffaa4c7 100644
--- a/modules/audio_coding/neteq/expand.cc
+++ b/modules/audio_coding/neteq/expand.cc
@@ -48,9 +48,10 @@
stop_muting_(false),
expand_duration_samples_(0),
channel_parameters_(new ChannelParameters[num_channels_]) {
- assert(fs == 8000 || fs == 16000 || fs == 32000 || fs == 48000);
- assert(fs <= static_cast<int>(kMaxSampleRate)); // Should not be possible.
- assert(num_channels_ > 0);
+ RTC_DCHECK(fs == 8000 || fs == 16000 || fs == 32000 || fs == 48000);
+ RTC_DCHECK_LE(fs,
+ static_cast<int>(kMaxSampleRate)); // Should not be possible.
+ RTC_DCHECK_GT(num_channels_, 0);
memset(expand_lags_, 0, sizeof(expand_lags_));
Reset();
}
@@ -91,7 +92,7 @@
// Extract a noise segment.
size_t rand_length = max_lag_;
// This only applies to SWB where length could be larger than 256.
- assert(rand_length <= kMaxSampleRate / 8000 * 120 + 30);
+ RTC_DCHECK_LE(rand_length, kMaxSampleRate / 8000 * 120 + 30);
GenerateRandomVector(2, rand_length, random_vector);
}
@@ -110,8 +111,8 @@
ChannelParameters& parameters = channel_parameters_[channel_ix];
if (current_lag_index_ == 0) {
// Use only expand_vector0.
- assert(expansion_vector_position + temp_length <=
- parameters.expand_vector0.Size());
+ RTC_DCHECK_LE(expansion_vector_position + temp_length,
+ parameters.expand_vector0.Size());
parameters.expand_vector0.CopyTo(temp_length, expansion_vector_position,
voiced_vector_storage);
} else if (current_lag_index_ == 1) {
@@ -126,10 +127,10 @@
voiced_vector_storage, temp_length);
} else if (current_lag_index_ == 2) {
// Mix 1/2 of expand_vector0 with 1/2 of expand_vector1.
- assert(expansion_vector_position + temp_length <=
- parameters.expand_vector0.Size());
- assert(expansion_vector_position + temp_length <=
- parameters.expand_vector1.Size());
+ RTC_DCHECK_LE(expansion_vector_position + temp_length,
+ parameters.expand_vector0.Size());
+ RTC_DCHECK_LE(expansion_vector_position + temp_length,
+ parameters.expand_vector1.Size());
std::unique_ptr<int16_t[]> temp_0(new int16_t[temp_length]);
parameters.expand_vector0.CopyTo(temp_length, expansion_vector_position,
@@ -303,7 +304,7 @@
if (channel_ix == 0) {
output->AssertSize(current_lag);
} else {
- assert(output->Size() == current_lag);
+ RTC_DCHECK_EQ(output->Size(), current_lag);
}
(*output)[channel_ix].OverwriteAt(temp_data, current_lag, 0);
}
@@ -465,7 +466,7 @@
size_t start_index = std::min(distortion_lag, correlation_lag);
size_t correlation_lags = static_cast<size_t>(
WEBRTC_SPL_ABS_W16((distortion_lag - correlation_lag)) + 1);
- assert(correlation_lags <= static_cast<size_t>(99 * fs_mult + 1));
+ RTC_DCHECK_LE(correlation_lags, static_cast<size_t>(99 * fs_mult + 1));
for (size_t channel_ix = 0; channel_ix < num_channels_; ++channel_ix) {
ChannelParameters& parameters = channel_parameters_[channel_ix];
@@ -659,7 +660,7 @@
// |kRandomTableSize|.
memcpy(random_vector, RandomVector::kRandomTable,
sizeof(int16_t) * RandomVector::kRandomTableSize);
- assert(noise_length <= kMaxSampleRate / 8000 * 120 + 30);
+ RTC_DCHECK_LE(noise_length, kMaxSampleRate / 8000 * 120 + 30);
random_vector_->IncreaseSeedIncrement(2);
random_vector_->Generate(
noise_length - RandomVector::kRandomTableSize,
diff --git a/modules/audio_coding/neteq/expand.h b/modules/audio_coding/neteq/expand.h
index 45d78d0..3b0cea3 100644
--- a/modules/audio_coding/neteq/expand.h
+++ b/modules/audio_coding/neteq/expand.h
@@ -59,7 +59,7 @@
// Returns the mute factor for |channel|.
int16_t MuteFactor(size_t channel) const {
- assert(channel < num_channels_);
+ RTC_DCHECK_LT(channel, num_channels_);
return channel_parameters_[channel].mute_factor;
}
diff --git a/modules/audio_coding/neteq/merge.cc b/modules/audio_coding/neteq/merge.cc
index 5bf239b..770e2e3 100644
--- a/modules/audio_coding/neteq/merge.cc
+++ b/modules/audio_coding/neteq/merge.cc
@@ -38,7 +38,7 @@
expand_(expand),
sync_buffer_(sync_buffer),
expanded_(num_channels_) {
- assert(num_channels_ > 0);
+ RTC_DCHECK_GT(num_channels_, 0);
}
Merge::~Merge() = default;
@@ -47,9 +47,9 @@
size_t input_length,
AudioMultiVector* output) {
// TODO(hlundin): Change to an enumerator and skip assert.
- assert(fs_hz_ == 8000 || fs_hz_ == 16000 || fs_hz_ == 32000 ||
- fs_hz_ == 48000);
- assert(fs_hz_ <= kMaxSampleRate); // Should not be possible.
+ RTC_DCHECK(fs_hz_ == 8000 || fs_hz_ == 16000 || fs_hz_ == 32000 ||
+ fs_hz_ == 48000);
+ RTC_DCHECK_LE(fs_hz_, kMaxSampleRate); // Should not be possible.
if (input_length == 0) {
return 0;
}
@@ -64,7 +64,7 @@
input_vector.PushBackInterleaved(
rtc::ArrayView<const int16_t>(input, input_length));
size_t input_length_per_channel = input_vector.Size();
- assert(input_length_per_channel == input_length / num_channels_);
+ RTC_DCHECK_EQ(input_length_per_channel, input_length / num_channels_);
size_t best_correlation_index = 0;
size_t output_length = 0;
@@ -142,10 +142,10 @@
output_length = best_correlation_index + input_length_per_channel;
if (channel == 0) {
- assert(output->Empty()); // Output should be empty at this point.
+ RTC_DCHECK(output->Empty()); // Output should be empty at this point.
output->AssertSize(output_length);
} else {
- assert(output->Size() == output_length);
+ RTC_DCHECK_EQ(output->Size(), output_length);
}
(*output)[channel].OverwriteAt(temp_data_.data(), output_length, 0);
}
@@ -165,7 +165,7 @@
// Check how much data that is left since earlier.
*old_length = sync_buffer_->FutureLength();
// Should never be less than overlap_length.
- assert(*old_length >= expand_->overlap_length());
+ RTC_DCHECK_GE(*old_length, expand_->overlap_length());
// Generate data to merge the overlap with using expand.
expand_->SetParametersForMergeAfterExpand();
@@ -182,7 +182,7 @@
// This is the truncated length.
}
// This assert should always be true thanks to the if statement above.
- assert(210 * kMaxSampleRate / 8000 >= *old_length);
+ RTC_DCHECK_GE(210 * kMaxSampleRate / 8000, *old_length);
AudioMultiVector expanded_temp(num_channels_);
expand_->Process(&expanded_temp);
@@ -191,8 +191,8 @@
expanded_.Clear();
// Copy what is left since earlier into the expanded vector.
expanded_.PushBackFromIndex(*sync_buffer_, sync_buffer_->next_index());
- assert(expanded_.Size() == *old_length);
- assert(expanded_temp.Size() > 0);
+ RTC_DCHECK_EQ(expanded_.Size(), *old_length);
+ RTC_DCHECK_GT(expanded_temp.Size(), 0);
// Do "ugly" copy and paste from the expanded in order to generate more data
// to correlate (but not interpolate) with.
const size_t required_length = static_cast<size_t>((120 + 80 + 2) * fs_mult_);
@@ -204,7 +204,7 @@
// Trim the length to exactly |required_length|.
expanded_.PopBack(expanded_.Size() - required_length);
}
- assert(expanded_.Size() >= required_length);
+ RTC_DCHECK_GE(expanded_.Size(), required_length);
return required_length;
}
@@ -373,7 +373,7 @@
while (((best_correlation_index + input_length) <
(timestamps_per_call_ + expand_->overlap_length())) ||
((best_correlation_index + input_length) < start_position)) {
- assert(false); // Should never happen.
+ RTC_NOTREACHED(); // Should never happen.
best_correlation_index += expand_period; // Jump one lag ahead.
}
return best_correlation_index;
diff --git a/modules/audio_coding/neteq/nack_tracker.cc b/modules/audio_coding/neteq/nack_tracker.cc
index 8358769..9a873ee 100644
--- a/modules/audio_coding/neteq/nack_tracker.cc
+++ b/modules/audio_coding/neteq/nack_tracker.cc
@@ -44,7 +44,7 @@
}
void NackTracker::UpdateSampleRate(int sample_rate_hz) {
- assert(sample_rate_hz > 0);
+ RTC_DCHECK_GT(sample_rate_hz, 0);
sample_rate_khz_ = sample_rate_hz / 1000;
}
@@ -120,9 +120,9 @@
}
void NackTracker::AddToList(uint16_t sequence_number_current_received_rtp) {
- assert(!any_rtp_decoded_ ||
- IsNewerSequenceNumber(sequence_number_current_received_rtp,
- sequence_num_last_decoded_rtp_));
+ RTC_DCHECK(!any_rtp_decoded_ ||
+ IsNewerSequenceNumber(sequence_number_current_received_rtp,
+ sequence_num_last_decoded_rtp_));
// Packets with sequence numbers older than |upper_bound_missing| are
// considered missing, and the rest are considered late.
@@ -164,7 +164,7 @@
++it)
it->second.time_to_play_ms = TimeToPlay(it->second.estimated_timestamp);
} else {
- assert(sequence_number == sequence_num_last_decoded_rtp_);
+ RTC_DCHECK_EQ(sequence_number, sequence_num_last_decoded_rtp_);
// Same sequence number as before. 10 ms is elapsed, update estimations for
// time-to-play.
diff --git a/modules/audio_coding/neteq/neteq_impl.cc b/modules/audio_coding/neteq/neteq_impl.cc
index fed037b..8b07d7e 100644
--- a/modules/audio_coding/neteq/neteq_impl.cc
+++ b/modules/audio_coding/neteq/neteq_impl.cc
@@ -343,7 +343,7 @@
bool NetEqImpl::SetMinimumDelay(int delay_ms) {
MutexLock lock(&mutex_);
if (delay_ms >= 0 && delay_ms <= 10000) {
- assert(controller_.get());
+ RTC_DCHECK(controller_.get());
return controller_->SetMinimumDelay(
std::max(delay_ms - output_delay_chain_ms_, 0));
}
@@ -353,7 +353,7 @@
bool NetEqImpl::SetMaximumDelay(int delay_ms) {
MutexLock lock(&mutex_);
if (delay_ms >= 0 && delay_ms <= 10000) {
- assert(controller_.get());
+ RTC_DCHECK(controller_.get());
return controller_->SetMaximumDelay(
std::max(delay_ms - output_delay_chain_ms_, 0));
}
@@ -392,7 +392,7 @@
int NetEqImpl::NetworkStatistics(NetEqNetworkStatistics* stats) {
MutexLock lock(&mutex_);
- assert(decoder_database_.get());
+ RTC_DCHECK(decoder_database_.get());
*stats = CurrentNetworkStatisticsInternal();
stats_->GetNetworkStatistics(decoder_frame_length_, stats);
// Compensate for output delay chain.
@@ -409,13 +409,13 @@
}
NetEqNetworkStatistics NetEqImpl::CurrentNetworkStatisticsInternal() const {
- assert(decoder_database_.get());
+ RTC_DCHECK(decoder_database_.get());
NetEqNetworkStatistics stats;
const size_t total_samples_in_buffers =
packet_buffer_->NumSamplesInBuffer(decoder_frame_length_) +
sync_buffer_->FutureLength();
- assert(controller_.get());
+ RTC_DCHECK(controller_.get());
stats.preferred_buffer_size_ms = controller_->TargetLevelMs();
stats.jitter_peaks_found = controller_->PeakFound();
RTC_DCHECK_GT(fs_hz_, 0);
@@ -449,13 +449,13 @@
void NetEqImpl::EnableVad() {
MutexLock lock(&mutex_);
- assert(vad_.get());
+ RTC_DCHECK(vad_.get());
vad_->Enable();
}
void NetEqImpl::DisableVad() {
MutexLock lock(&mutex_);
- assert(vad_.get());
+ RTC_DCHECK(vad_.get());
vad_->Disable();
}
@@ -506,8 +506,8 @@
MutexLock lock(&mutex_);
RTC_LOG(LS_VERBOSE) << "FlushBuffers";
packet_buffer_->Flush(stats_.get());
- assert(sync_buffer_.get());
- assert(expand_.get());
+ RTC_DCHECK(sync_buffer_.get());
+ RTC_DCHECK(expand_.get());
sync_buffer_->Flush();
sync_buffer_->set_next_index(sync_buffer_->next_index() -
expand_->overlap_length());
@@ -797,12 +797,12 @@
size_t channels = 1;
if (!decoder_database_->IsComfortNoise(payload_type)) {
AudioDecoder* decoder = decoder_database_->GetDecoder(payload_type);
- assert(decoder); // Payloads are already checked to be valid.
+ RTC_DCHECK(decoder); // Payloads are already checked to be valid.
channels = decoder->Channels();
}
const DecoderDatabase::DecoderInfo* decoder_info =
decoder_database_->GetDecoderInfo(payload_type);
- assert(decoder_info);
+ RTC_DCHECK(decoder_info);
if (decoder_info->SampleRateHz() != fs_hz_ ||
channels != algorithm_buffer_->Channels()) {
SetSampleRateAndChannels(decoder_info->SampleRateHz(), channels);
@@ -816,7 +816,7 @@
const DecoderDatabase::DecoderInfo* dec_info =
decoder_database_->GetDecoderInfo(main_payload_type);
- assert(dec_info); // Already checked that the payload type is known.
+ RTC_DCHECK(dec_info); // Already checked that the payload type is known.
NetEqController::PacketArrivedInfo info;
info.is_cng_or_dtmf = dec_info->IsComfortNoise() || dec_info->IsDtmf();
@@ -894,7 +894,7 @@
int decode_return_value =
Decode(&packet_list, &operation, &length, &speech_type);
- assert(vad_.get());
+ RTC_DCHECK(vad_.get());
bool sid_frame_available =
(operation == Operation::kRfc3389Cng && !packet_list.empty());
vad_->Update(decoded_buffer_.get(), static_cast<size_t>(length), speech_type,
@@ -965,7 +965,7 @@
}
case Operation::kUndefined: {
RTC_LOG(LS_ERROR) << "Invalid operation kUndefined.";
- assert(false); // This should not happen.
+ RTC_NOTREACHED(); // This should not happen.
last_mode_ = Mode::kError;
return kInvalidOperation;
}
@@ -1101,7 +1101,7 @@
*play_dtmf = false;
*operation = Operation::kUndefined;
- assert(sync_buffer_.get());
+ RTC_DCHECK(sync_buffer_.get());
uint32_t end_timestamp = sync_buffer_->end_timestamp();
if (!new_codec_) {
const uint32_t five_seconds_samples = 5 * fs_hz_;
@@ -1128,7 +1128,7 @@
// Don't use this packet, discard it.
if (packet_buffer_->DiscardNextPacket(stats_.get()) !=
PacketBuffer::kOK) {
- assert(false); // Must be ok by design.
+ RTC_NOTREACHED(); // Must be ok by design.
}
// Check buffer again.
if (!new_codec_) {
@@ -1139,7 +1139,7 @@
}
}
- assert(expand_.get());
+ RTC_DCHECK(expand_.get());
const int samples_left = static_cast<int>(sync_buffer_->FutureLength() -
expand_->overlap_length());
if (last_mode_ == Mode::kAccelerateSuccess ||
@@ -1159,8 +1159,8 @@
}
// Get instruction.
- assert(sync_buffer_.get());
- assert(expand_.get());
+ RTC_DCHECK(sync_buffer_.get());
+ RTC_DCHECK(expand_.get());
generated_noise_samples =
generated_noise_stopwatch_
? generated_noise_stopwatch_->ElapsedTicks() * output_size_samples_ +
@@ -1228,7 +1228,7 @@
// Check conditions for reset.
if (new_codec_ || *operation == Operation::kUndefined) {
// The only valid reason to get kUndefined is that new_codec_ is set.
- assert(new_codec_);
+ RTC_DCHECK(new_codec_);
if (*play_dtmf && !packet) {
timestamp_ = dtmf_event->timestamp;
} else {
@@ -1400,7 +1400,7 @@
uint8_t payload_type = packet.payload_type;
if (!decoder_database_->IsComfortNoise(payload_type)) {
decoder = decoder_database_->GetDecoder(payload_type);
- assert(decoder);
+ RTC_DCHECK(decoder);
if (!decoder) {
RTC_LOG(LS_WARNING)
<< "Unknown payload type " << static_cast<int>(payload_type);
@@ -1413,7 +1413,7 @@
// We have a new decoder. Re-init some values.
const DecoderDatabase::DecoderInfo* decoder_info =
decoder_database_->GetDecoderInfo(payload_type);
- assert(decoder_info);
+ RTC_DCHECK(decoder_info);
if (!decoder_info) {
RTC_LOG(LS_WARNING)
<< "Unknown payload type " << static_cast<int>(payload_type);
@@ -1485,8 +1485,8 @@
// Don't increment timestamp if codec returned CNG speech type
// since in this case, the we will increment the CNGplayedTS counter.
// Increase with number of samples per channel.
- assert(*decoded_length == 0 ||
- (decoder && decoder->Channels() == sync_buffer_->Channels()));
+ RTC_DCHECK(*decoded_length == 0 ||
+ (decoder && decoder->Channels() == sync_buffer_->Channels()));
sync_buffer_->IncreaseEndTimestamp(
*decoded_length / static_cast<int>(sync_buffer_->Channels()));
}
@@ -1535,16 +1535,16 @@
// Do decoding.
while (!packet_list->empty() && !decoder_database_->IsComfortNoise(
packet_list->front().payload_type)) {
- assert(decoder); // At this point, we must have a decoder object.
+ RTC_DCHECK(decoder); // At this point, we must have a decoder object.
// The number of channels in the |sync_buffer_| should be the same as the
// number decoder channels.
- assert(sync_buffer_->Channels() == decoder->Channels());
- assert(decoded_buffer_length_ >= kMaxFrameSize * decoder->Channels());
- assert(operation == Operation::kNormal ||
- operation == Operation::kAccelerate ||
- operation == Operation::kFastAccelerate ||
- operation == Operation::kMerge ||
- operation == Operation::kPreemptiveExpand);
+ RTC_DCHECK_EQ(sync_buffer_->Channels(), decoder->Channels());
+ RTC_DCHECK_GE(decoded_buffer_length_, kMaxFrameSize * decoder->Channels());
+ RTC_DCHECK(operation == Operation::kNormal ||
+ operation == Operation::kAccelerate ||
+ operation == Operation::kFastAccelerate ||
+ operation == Operation::kMerge ||
+ operation == Operation::kPreemptiveExpand);
auto opt_result = packet_list->front().frame->Decode(
rtc::ArrayView<int16_t>(&decoded_buffer_[*decoded_length],
@@ -1581,9 +1581,10 @@
// If the list is not empty at this point, either a decoding error terminated
// the while-loop, or list must hold exactly one CNG packet.
- assert(packet_list->empty() || *decoded_length < 0 ||
- (packet_list->size() == 1 && decoder_database_->IsComfortNoise(
- packet_list->front().payload_type)));
+ RTC_DCHECK(
+ packet_list->empty() || *decoded_length < 0 ||
+ (packet_list->size() == 1 &&
+ decoder_database_->IsComfortNoise(packet_list->front().payload_type)));
return 0;
}
@@ -1591,7 +1592,7 @@
size_t decoded_length,
AudioDecoder::SpeechType speech_type,
bool play_dtmf) {
- assert(normal_.get());
+ RTC_DCHECK(normal_.get());
normal_->Process(decoded_buffer, decoded_length, last_mode_,
algorithm_buffer_.get());
if (decoded_length != 0) {
@@ -1614,7 +1615,7 @@
size_t decoded_length,
AudioDecoder::SpeechType speech_type,
bool play_dtmf) {
- assert(merge_.get());
+ RTC_DCHECK(merge_.get());
size_t new_length =
merge_->Process(decoded_buffer, decoded_length, algorithm_buffer_.get());
// Correction can be negative.
@@ -1775,7 +1776,7 @@
sync_buffer_->Size() - borrowed_samples_per_channel);
sync_buffer_->PushFrontZeros(borrowed_samples_per_channel - length);
algorithm_buffer_->PopFront(length);
- assert(algorithm_buffer_->Empty());
+ RTC_DCHECK(algorithm_buffer_->Empty());
} else {
sync_buffer_->ReplaceAtIndex(
*algorithm_buffer_, borrowed_samples_per_channel,
@@ -1864,7 +1865,7 @@
int NetEqImpl::DoRfc3389Cng(PacketList* packet_list, bool play_dtmf) {
if (!packet_list->empty()) {
// Must have exactly one SID frame at this point.
- assert(packet_list->size() == 1);
+ RTC_DCHECK_EQ(packet_list->size(), 1);
const Packet& packet = packet_list->front();
if (!decoder_database_->IsComfortNoise(packet.payload_type)) {
RTC_LOG(LS_ERROR) << "Trying to decode non-CNG payload as CNG.";
@@ -1947,14 +1948,14 @@
// // it must be copied to the speech buffer.
// // TODO(hlundin): This code seems incorrect. (Legacy.) Write test and
// // verify correct operation.
- // assert(false);
+ // RTC_NOTREACHED();
// // Must generate enough data to replace all of the |sync_buffer_|
// // "future".
// int required_length = sync_buffer_->FutureLength();
- // assert(dtmf_tone_generator_->initialized());
+ // RTC_DCHECK(dtmf_tone_generator_->initialized());
// dtmf_return_value = dtmf_tone_generator_->Generate(required_length,
// algorithm_buffer_);
- // assert((size_t) required_length == algorithm_buffer_->Size());
+ // RTC_DCHECK((size_t) required_length == algorithm_buffer_->Size());
// if (dtmf_return_value < 0) {
// algorithm_buffer_->Zeros(output_size_samples_);
// return dtmf_return_value;
@@ -1964,7 +1965,7 @@
// // data.
// // TODO(hlundin): It seems that this overwriting has gone lost.
// // Not adapted for multi-channel yet.
- // assert(algorithm_buffer_->Channels() == 1);
+ // RTC_DCHECK(algorithm_buffer_->Channels() == 1);
// if (algorithm_buffer_->Channels() != 1) {
// RTC_LOG(LS_WARNING) << "DTMF not supported for more than one channel";
// return kStereoNotSupported;
@@ -2006,7 +2007,7 @@
if (dtmf_return_value == 0) {
dtmf_return_value =
dtmf_tone_generator_->Generate(overdub_length, &dtmf_output);
- assert(overdub_length == dtmf_output.Size());
+ RTC_DCHECK_EQ(overdub_length, dtmf_output.Size());
}
dtmf_output.ReadInterleaved(overdub_length, &output[out_index]);
return dtmf_return_value < 0 ? dtmf_return_value : 0;
@@ -2037,7 +2038,7 @@
next_packet = nullptr;
if (!packet) {
RTC_LOG(LS_ERROR) << "Should always be able to extract a packet here";
- assert(false); // Should always be able to extract a packet here.
+ RTC_NOTREACHED(); // Should always be able to extract a packet here.
return -1;
}
const uint64_t waiting_time_ms = packet->waiting_time->ElapsedMs();
@@ -2130,8 +2131,9 @@
RTC_LOG(LS_VERBOSE) << "SetSampleRateAndChannels " << fs_hz << " "
<< channels;
// TODO(hlundin): Change to an enumerator and skip assert.
- assert(fs_hz == 8000 || fs_hz == 16000 || fs_hz == 32000 || fs_hz == 48000);
- assert(channels > 0);
+ RTC_DCHECK(fs_hz == 8000 || fs_hz == 16000 || fs_hz == 32000 ||
+ fs_hz == 48000);
+ RTC_DCHECK_GT(channels, 0);
// Before changing the sample rate, end and report any ongoing expand event.
stats_->EndExpandEvent(fs_hz_);
@@ -2147,7 +2149,7 @@
cng_decoder->Reset();
// Reinit post-decode VAD with new sample rate.
- assert(vad_.get()); // Cannot be NULL here.
+ RTC_DCHECK(vad_.get()); // Cannot be NULL here.
vad_->Init();
// Delete algorithm buffer and create a new one.
@@ -2190,8 +2192,8 @@
}
NetEqImpl::OutputType NetEqImpl::LastOutputType() {
- assert(vad_.get());
- assert(expand_.get());
+ RTC_DCHECK(vad_.get());
+ RTC_DCHECK(expand_.get());
if (last_mode_ == Mode::kCodecInternalCng ||
last_mode_ == Mode::kRfc3389Cng) {
return OutputType::kCNG;
diff --git a/modules/audio_coding/neteq/red_payload_splitter.cc b/modules/audio_coding/neteq/red_payload_splitter.cc
index f5cd9c2..2f21a5f 100644
--- a/modules/audio_coding/neteq/red_payload_splitter.cc
+++ b/modules/audio_coding/neteq/red_payload_splitter.cc
@@ -41,7 +41,7 @@
PacketList::iterator it = packet_list->begin();
while (it != packet_list->end()) {
const Packet& red_packet = *it;
- assert(!red_packet.payload.empty());
+ RTC_DCHECK(!red_packet.payload.empty());
const uint8_t* payload_ptr = red_packet.payload.data();
size_t payload_length = red_packet.payload.size();
diff --git a/modules/audio_coding/neteq/red_payload_splitter_unittest.cc b/modules/audio_coding/neteq/red_payload_splitter_unittest.cc
index 1cf6167..7275232 100644
--- a/modules/audio_coding/neteq/red_payload_splitter_unittest.cc
+++ b/modules/audio_coding/neteq/red_payload_splitter_unittest.cc
@@ -103,7 +103,7 @@
rtc::checked_cast<int>((num_payloads - i - 1) * timestamp_offset);
*payload_ptr = this_offset >> 6;
++payload_ptr;
- assert(kPayloadLength <= 1023); // Max length described by 10 bits.
+ RTC_DCHECK_LE(kPayloadLength, 1023); // Max length described by 10 bits.
*payload_ptr = ((this_offset & 0x3F) << 2) | (kPayloadLength >> 8);
++payload_ptr;
*payload_ptr = kPayloadLength & 0xFF;
diff --git a/modules/audio_coding/neteq/statistics_calculator.cc b/modules/audio_coding/neteq/statistics_calculator.cc
index 708780a..12a0e3c 100644
--- a/modules/audio_coding/neteq/statistics_calculator.cc
+++ b/modules/audio_coding/neteq/statistics_calculator.cc
@@ -375,7 +375,7 @@
return 0;
} else if (numerator < denominator) {
// Ratio must be smaller than 1 in Q14.
- assert((numerator << 14) / denominator < (1 << 14));
+ RTC_DCHECK_LT((numerator << 14) / denominator, (1 << 14));
return static_cast<uint16_t>((numerator << 14) / denominator);
} else {
// Will not produce a ratio larger than 1, since this is probably an error.
diff --git a/modules/audio_coding/neteq/sync_buffer.cc b/modules/audio_coding/neteq/sync_buffer.cc
index 4949bb2..73e0628 100644
--- a/modules/audio_coding/neteq/sync_buffer.cc
+++ b/modules/audio_coding/neteq/sync_buffer.cc
@@ -28,7 +28,7 @@
next_index_ -= samples_added;
} else {
// This means that we are pushing out future data that was never used.
- // assert(false);
+ // RTC_NOTREACHED();
// TODO(hlundin): This assert must be disabled to support 60 ms frames.
// This should not happen even for 60 ms frames, but it does. Investigate
// why.
diff --git a/modules/audio_coding/neteq/time_stretch.cc b/modules/audio_coding/neteq/time_stretch.cc
index ba24e0b..b768029 100644
--- a/modules/audio_coding/neteq/time_stretch.cc
+++ b/modules/audio_coding/neteq/time_stretch.cc
@@ -66,7 +66,7 @@
DspHelper::PeakDetection(auto_correlation_, kCorrelationLen, kNumPeaks,
fs_mult_, &peak_index, &peak_value);
// Assert that |peak_index| stays within boundaries.
- assert(peak_index <= (2 * kCorrelationLen - 1) * fs_mult_);
+ RTC_DCHECK_LE(peak_index, (2 * kCorrelationLen - 1) * fs_mult_);
// Compensate peak_index for displaced starting position. The displacement
// happens in AutoCorrelation(). Here, |kMinLag| is in the down-sampled 4 kHz
@@ -74,8 +74,9 @@
// multiplication by fs_mult_ * 2.
peak_index += kMinLag * fs_mult_ * 2;
// Assert that |peak_index| stays within boundaries.
- assert(peak_index >= static_cast<size_t>(20 * fs_mult_));
- assert(peak_index <= 20 * fs_mult_ + (2 * kCorrelationLen - 1) * fs_mult_);
+ RTC_DCHECK_GE(peak_index, static_cast<size_t>(20 * fs_mult_));
+ RTC_DCHECK_LE(peak_index,
+ 20 * fs_mult_ + (2 * kCorrelationLen - 1) * fs_mult_);
// Calculate scaling to ensure that |peak_index| samples can be square-summed
// without overflowing.
diff --git a/modules/audio_coding/neteq/time_stretch.h b/modules/audio_coding/neteq/time_stretch.h
index aede9ca..26d295f 100644
--- a/modules/audio_coding/neteq/time_stretch.h
+++ b/modules/audio_coding/neteq/time_stretch.h
@@ -42,9 +42,9 @@
num_channels_(num_channels),
background_noise_(background_noise),
max_input_value_(0) {
- assert(sample_rate_hz_ == 8000 || sample_rate_hz_ == 16000 ||
- sample_rate_hz_ == 32000 || sample_rate_hz_ == 48000);
- assert(num_channels_ > 0);
+ RTC_DCHECK(sample_rate_hz_ == 8000 || sample_rate_hz_ == 16000 ||
+ sample_rate_hz_ == 32000 || sample_rate_hz_ == 48000);
+ RTC_DCHECK_GT(num_channels_, 0);
memset(auto_correlation_, 0, sizeof(auto_correlation_));
}
diff --git a/modules/audio_coding/neteq/tools/output_audio_file.h b/modules/audio_coding/neteq/tools/output_audio_file.h
index d729c9c..7220a36 100644
--- a/modules/audio_coding/neteq/tools/output_audio_file.h
+++ b/modules/audio_coding/neteq/tools/output_audio_file.h
@@ -36,7 +36,7 @@
}
bool WriteArray(const int16_t* audio, size_t num_samples) override {
- assert(out_file_);
+ RTC_DCHECK(out_file_);
return fwrite(audio, sizeof(*audio), num_samples, out_file_) == num_samples;
}
diff --git a/modules/audio_coding/neteq/tools/rtp_analyze.cc b/modules/audio_coding/neteq/tools/rtp_analyze.cc
index dad3750..46fc2d7 100644
--- a/modules/audio_coding/neteq/tools/rtp_analyze.cc
+++ b/modules/audio_coding/neteq/tools/rtp_analyze.cc
@@ -56,7 +56,7 @@
printf("Input file: %s\n", args[1]);
std::unique_ptr<webrtc::test::RtpFileSource> file_source(
webrtc::test::RtpFileSource::Create(args[1]));
- assert(file_source.get());
+ RTC_DCHECK(file_source.get());
// Set RTP extension IDs.
bool print_audio_level = false;
if (absl::GetFlag(FLAGS_audio_level) != -1) {
@@ -151,7 +151,7 @@
packet->ExtractRedHeaders(&red_headers);
while (!red_headers.empty()) {
webrtc::RTPHeader* red = red_headers.front();
- assert(red);
+ RTC_DCHECK(red);
fprintf(out_file, "* %5u %10u %10u %5i\n", red->sequenceNumber,
red->timestamp, static_cast<unsigned int>(packet->time_ms()),
red->payloadType);
diff --git a/modules/audio_coding/neteq/tools/rtp_generator.cc b/modules/audio_coding/neteq/tools/rtp_generator.cc
index accd163..a37edef 100644
--- a/modules/audio_coding/neteq/tools/rtp_generator.cc
+++ b/modules/audio_coding/neteq/tools/rtp_generator.cc
@@ -18,7 +18,7 @@
uint32_t RtpGenerator::GetRtpHeader(uint8_t payload_type,
size_t payload_length_samples,
RTPHeader* rtp_header) {
- assert(rtp_header);
+ RTC_DCHECK(rtp_header);
if (!rtp_header) {
return 0;
}
@@ -31,7 +31,7 @@
rtp_header->numCSRCs = 0;
uint32_t this_send_time = next_send_time_ms_;
- assert(samples_per_ms_ > 0);
+ RTC_DCHECK_GT(samples_per_ms_, 0);
next_send_time_ms_ +=
((1.0 + drift_factor_) * payload_length_samples) / samples_per_ms_;
return this_send_time;
diff --git a/modules/audio_coding/test/Channel.cc b/modules/audio_coding/test/Channel.cc
index 9456145..d7bd6a9 100644
--- a/modules/audio_coding/test/Channel.cc
+++ b/modules/audio_coding/test/Channel.cc
@@ -125,7 +125,7 @@
(uint32_t)((uint32_t)rtp_header.timestamp -
(uint32_t)currentPayloadStr->lastTimestamp);
}
- assert(_lastFrameSizeSample > 0);
+ RTC_DCHECK_GT(_lastFrameSizeSample, 0);
int k = 0;
for (; k < MAX_NUM_FRAMESIZES; ++k) {
if ((currentPayloadStr->frameSizeStats[k].frameSizeSample ==
diff --git a/modules/audio_device/linux/audio_device_alsa_linux.cc b/modules/audio_device/linux/audio_device_alsa_linux.cc
index 9e6bd16..60e01e1 100644
--- a/modules/audio_device/linux/audio_device_alsa_linux.cc
+++ b/modules/audio_device/linux/audio_device_alsa_linux.cc
@@ -1490,7 +1490,7 @@
Lock();
_playoutFramesLeft = _ptrAudioBuffer->GetPlayoutData(_playoutBuffer);
- assert(_playoutFramesLeft == _playoutFramesIn10MS);
+ RTC_DCHECK_EQ(_playoutFramesLeft, _playoutFramesIn10MS);
}
if (static_cast<uint32_t>(avail_frames) > _playoutFramesLeft)
@@ -1509,7 +1509,7 @@
UnLock();
return true;
} else {
- assert(frames == avail_frames);
+ RTC_DCHECK_EQ(frames, avail_frames);
_playoutFramesLeft -= frames;
}
@@ -1559,7 +1559,7 @@
UnLock();
return true;
} else if (frames > 0) {
- assert(frames == avail_frames);
+ RTC_DCHECK_EQ(frames, avail_frames);
int left_size =
LATE(snd_pcm_frames_to_bytes)(_handleRecord, _recordingFramesLeft);
diff --git a/modules/audio_device/linux/latebindingsymboltable_linux.h b/modules/audio_device/linux/latebindingsymboltable_linux.h
index edb62ae..6cfb659 100644
--- a/modules/audio_device/linux/latebindingsymboltable_linux.h
+++ b/modules/audio_device/linux/latebindingsymboltable_linux.h
@@ -11,10 +11,10 @@
#ifndef AUDIO_DEVICE_LATEBINDINGSYMBOLTABLE_LINUX_H_
#define AUDIO_DEVICE_LATEBINDINGSYMBOLTABLE_LINUX_H_
-#include <assert.h>
#include <stddef.h> // for NULL
#include <string.h>
+#include "rtc_base/checks.h"
#include "rtc_base/constructor_magic.h"
// This file provides macros for creating "symbol table" classes to simplify the
@@ -59,7 +59,7 @@
// We do not use this, but we offer it for theoretical convenience.
static const char* GetSymbolName(int index) {
- assert(index < NumSymbols());
+ RTC_DCHECK_LT(index, NumSymbols());
return kSymbolNames[index];
}
@@ -100,8 +100,8 @@
// Retrieves the given symbol. NOTE: Recommended to use LATESYM_GET below
// instead of this.
void* GetSymbol(int index) const {
- assert(IsLoaded());
- assert(index < NumSymbols());
+ RTC_DCHECK(IsLoaded());
+ RTC_DCHECK_LT(index, NumSymbols());
return symbols_[index];
}
diff --git a/modules/audio_device/mac/audio_mixer_manager_mac.cc b/modules/audio_device/mac/audio_mixer_manager_mac.cc
index fe96374..942e7db 100644
--- a/modules/audio_device/mac/audio_mixer_manager_mac.cc
+++ b/modules/audio_device/mac/audio_mixer_manager_mac.cc
@@ -225,7 +225,7 @@
// volume range is 0.0 - 1.0, convert from 0 -255
const Float32 vol = (Float32)(volume / 255.0);
- assert(vol <= 1.0 && vol >= 0.0);
+ RTC_DCHECK(vol <= 1.0 && vol >= 0.0);
// Does the capture device have a master volume control?
// If so, use it exclusively.
@@ -311,7 +311,7 @@
return -1;
}
- assert(channels > 0);
+ RTC_DCHECK_GT(channels, 0);
// vol 0.0 to 1.0 -> convert to 0 - 255
volume = static_cast<uint32_t>(255 * vol / channels + 0.5);
}
@@ -522,7 +522,7 @@
return -1;
}
- assert(channels > 0);
+ RTC_DCHECK_GT(channels, 0);
// 1 means muted
enabled = static_cast<bool>(muted);
}
@@ -690,7 +690,7 @@
return -1;
}
- assert(channels > 0);
+ RTC_DCHECK_GT(channels, 0);
// 1 means muted
enabled = static_cast<bool>(muted);
}
@@ -757,7 +757,7 @@
// volume range is 0.0 - 1.0, convert from 0 - 255
const Float32 vol = (Float32)(volume / 255.0);
- assert(vol <= 1.0 && vol >= 0.0);
+ RTC_DCHECK(vol <= 1.0 && vol >= 0.0);
// Does the capture device have a master volume control?
// If so, use it exclusively.
@@ -843,7 +843,7 @@
return -1;
}
- assert(channels > 0);
+ RTC_DCHECK_GT(channels, 0);
// vol 0.0 to 1.0 -> convert to 0 - 255
volume = static_cast<uint32_t>(255 * volFloat32 / channels + 0.5);
}
diff --git a/modules/audio_device/win/audio_device_core_win.cc b/modules/audio_device/win/audio_device_core_win.cc
index 328fefa..a3723ed 100644
--- a/modules/audio_device/win/audio_device_core_win.cc
+++ b/modules/audio_device/win/audio_device_core_win.cc
@@ -281,7 +281,7 @@
DWORD messageLength = ::FormatMessageW(dwFlags, 0, hr, dwLangID, errorText,
MAXERRORLENGTH, NULL);
- assert(messageLength <= MAXERRORLENGTH);
+ RTC_DCHECK_LE(messageLength, MAXERRORLENGTH);
// Trims tailing white space (FormatMessage() leaves a trailing cr-lf.).
for (; messageLength && ::isspace(errorText[messageLength - 1]);
@@ -469,7 +469,7 @@
CoCreateInstance(__uuidof(MMDeviceEnumerator), NULL, CLSCTX_ALL,
__uuidof(IMMDeviceEnumerator),
reinterpret_cast<void**>(&_ptrEnumerator));
- assert(NULL != _ptrEnumerator);
+ RTC_DCHECK(_ptrEnumerator);
// DMO initialization for built-in WASAPI AEC.
{
@@ -1411,7 +1411,7 @@
HRESULT hr(S_OK);
- assert(_ptrRenderCollection != NULL);
+ RTC_DCHECK(_ptrRenderCollection);
// Select an endpoint rendering device given the specified index
SAFE_RELEASE(_ptrDeviceOut);
@@ -1461,7 +1461,7 @@
HRESULT hr(S_OK);
- assert(_ptrEnumerator != NULL);
+ RTC_DCHECK(_ptrEnumerator);
// Select an endpoint rendering device given the specified role
SAFE_RELEASE(_ptrDeviceOut);
@@ -1677,7 +1677,7 @@
HRESULT hr(S_OK);
- assert(_ptrCaptureCollection != NULL);
+ RTC_DCHECK(_ptrCaptureCollection);
// Select an endpoint capture device given the specified index
SAFE_RELEASE(_ptrDeviceIn);
@@ -1727,7 +1727,7 @@
HRESULT hr(S_OK);
- assert(_ptrEnumerator != NULL);
+ RTC_DCHECK(_ptrEnumerator);
// Select an endpoint capture device given the specified role
SAFE_RELEASE(_ptrDeviceIn);
@@ -2036,8 +2036,8 @@
// handles device initialization itself.
// Reference: http://msdn.microsoft.com/en-us/library/ff819492(v=vs.85).aspx
int32_t AudioDeviceWindowsCore::InitRecordingDMO() {
- assert(_builtInAecEnabled);
- assert(_dmo != NULL);
+ RTC_DCHECK(_builtInAecEnabled);
+ RTC_DCHECK(_dmo);
if (SetDMOProperties() == -1) {
return -1;
@@ -2356,7 +2356,7 @@
}
}
- assert(_hRecThread == NULL);
+ RTC_DCHECK(_hRecThread);
_hRecThread = CreateThread(NULL, 0, lpStartAddress, this, 0, NULL);
if (_hRecThread == NULL) {
RTC_LOG(LS_ERROR) << "failed to create the recording thread";
@@ -2421,8 +2421,8 @@
ResetEvent(_hShutdownCaptureEvent); // Must be manually reset.
// Ensure that the thread has released these interfaces properly.
- assert(err == -1 || _ptrClientIn == NULL);
- assert(err == -1 || _ptrCaptureClient == NULL);
+ RTC_DCHECK(err == -1 || _ptrClientIn == NULL);
+ RTC_DCHECK(err == -1 || _ptrCaptureClient == NULL);
_recIsInitialized = false;
_recording = false;
@@ -2433,7 +2433,7 @@
_hRecThread = NULL;
if (_builtInAecEnabled) {
- assert(_dmo != NULL);
+ RTC_DCHECK(_dmo);
// This is necessary. Otherwise the DMO can generate garbage render
// audio even after rendering has stopped.
HRESULT hr = _dmo->FreeStreamingResources();
@@ -2493,7 +2493,7 @@
MutexLock lockScoped(&mutex_);
// Create thread which will drive the rendering.
- assert(_hPlayThread == NULL);
+ RTC_DCHECK(_hPlayThread);
_hPlayThread = CreateThread(NULL, 0, WSAPIRenderThread, this, 0, NULL);
if (_hPlayThread == NULL) {
RTC_LOG(LS_ERROR) << "failed to create the playout thread";
@@ -2954,7 +2954,7 @@
}
DWORD AudioDeviceWindowsCore::DoCaptureThreadPollDMO() {
- assert(_mediaBuffer != NULL);
+ RTC_DCHECK(_mediaBuffer);
bool keepRecording = true;
// Initialize COM as MTA in this thread.
@@ -3010,7 +3010,7 @@
if (FAILED(hr)) {
_TraceCOMError(hr);
keepRecording = false;
- assert(false);
+ RTC_NOTREACHED();
break;
}
@@ -3022,7 +3022,7 @@
if (FAILED(hr)) {
_TraceCOMError(hr);
keepRecording = false;
- assert(false);
+ RTC_NOTREACHED();
break;
}
@@ -3031,8 +3031,8 @@
// TODO(andrew): verify that this is always satisfied. It might
// be that ProcessOutput will try to return more than 10 ms if
// we fail to call it frequently enough.
- assert(kSamplesProduced == static_cast<int>(_recBlockSize));
- assert(sizeof(BYTE) == sizeof(int8_t));
+ RTC_DCHECK_EQ(kSamplesProduced, static_cast<int>(_recBlockSize));
+ RTC_DCHECK_EQ(sizeof(BYTE), sizeof(int8_t));
_ptrAudioBuffer->SetRecordedBuffer(reinterpret_cast<int8_t*>(data),
kSamplesProduced);
_ptrAudioBuffer->SetVQEData(0, 0);
@@ -3047,7 +3047,7 @@
if (FAILED(hr)) {
_TraceCOMError(hr);
keepRecording = false;
- assert(false);
+ RTC_NOTREACHED();
break;
}
@@ -3228,7 +3228,7 @@
pData = NULL;
}
- assert(framesAvailable != 0);
+ RTC_DCHECK_NE(framesAvailable, 0);
if (pData) {
CopyMemory(&syncBuffer[syncBufIndex * _recAudioFrameSize], pData,
@@ -3237,8 +3237,8 @@
ZeroMemory(&syncBuffer[syncBufIndex * _recAudioFrameSize],
framesAvailable * _recAudioFrameSize);
}
- assert(syncBufferSize >= (syncBufIndex * _recAudioFrameSize) +
- framesAvailable * _recAudioFrameSize);
+ RTC_DCHECK_GE(syncBufferSize, (syncBufIndex * _recAudioFrameSize) +
+ framesAvailable * _recAudioFrameSize);
// Release the capture buffer
//
@@ -3377,7 +3377,7 @@
int AudioDeviceWindowsCore::SetDMOProperties() {
HRESULT hr = S_OK;
- assert(_dmo != NULL);
+ RTC_DCHECK(_dmo);
rtc::scoped_refptr<IPropertyStore> ps;
{
@@ -3517,8 +3517,8 @@
HRESULT hr = S_OK;
IMMDeviceCollection* pCollection = NULL;
- assert(dir == eRender || dir == eCapture);
- assert(_ptrEnumerator != NULL);
+ RTC_DCHECK(dir == eRender || dir == eCapture);
+ RTC_DCHECK(_ptrEnumerator);
// Create a fresh list of devices using the specified direction
hr = _ptrEnumerator->EnumAudioEndpoints(dir, DEVICE_STATE_ACTIVE,
@@ -3553,7 +3553,7 @@
HRESULT hr = S_OK;
UINT count = 0;
- assert(eRender == dir || eCapture == dir);
+ RTC_DCHECK(eRender == dir || eCapture == dir);
if (eRender == dir && NULL != _ptrRenderCollection) {
hr = _ptrRenderCollection->GetCount(&count);
@@ -3589,7 +3589,7 @@
HRESULT hr = S_OK;
IMMDevice* pDevice = NULL;
- assert(dir == eRender || dir == eCapture);
+ RTC_DCHECK(dir == eRender || dir == eCapture);
if (eRender == dir && NULL != _ptrRenderCollection) {
hr = _ptrRenderCollection->Item(index, &pDevice);
@@ -3626,9 +3626,9 @@
HRESULT hr = S_OK;
IMMDevice* pDevice = NULL;
- assert(dir == eRender || dir == eCapture);
- assert(role == eConsole || role == eCommunications);
- assert(_ptrEnumerator != NULL);
+ RTC_DCHECK(dir == eRender || dir == eCapture);
+ RTC_DCHECK(role == eConsole || role == eCommunications);
+ RTC_DCHECK(_ptrEnumerator);
hr = _ptrEnumerator->GetDefaultAudioEndpoint(dir, role, &pDevice);
@@ -3663,7 +3663,7 @@
HRESULT hr = S_OK;
IMMDevice* pDevice = NULL;
- assert(dir == eRender || dir == eCapture);
+ RTC_DCHECK(dir == eRender || dir == eCapture);
if (eRender == dir && NULL != _ptrRenderCollection) {
hr = _ptrRenderCollection->Item(index, &pDevice);
@@ -3700,9 +3700,9 @@
HRESULT hr = S_OK;
IMMDevice* pDevice = NULL;
- assert(dir == eRender || dir == eCapture);
- assert(role == eConsole || role == eCommunications);
- assert(_ptrEnumerator != NULL);
+ RTC_DCHECK(dir == eRender || dir == eCapture);
+ RTC_DCHECK(role == eConsole || role == eCommunications);
+ RTC_DCHECK(_ptrEnumerator);
hr = _ptrEnumerator->GetDefaultAudioEndpoint(dir, role, &pDevice);
@@ -3727,8 +3727,8 @@
WCHAR szDeviceID[MAX_PATH] = {0};
const size_t kDeviceIDLength = sizeof(szDeviceID) / sizeof(szDeviceID[0]);
- assert(kDeviceIDLength ==
- sizeof(szDefaultDeviceID) / sizeof(szDefaultDeviceID[0]));
+ RTC_DCHECK_EQ(kDeviceIDLength,
+ sizeof(szDefaultDeviceID) / sizeof(szDefaultDeviceID[0]));
if (_GetDefaultDeviceID(dir, role, szDefaultDeviceID, kDeviceIDLength) ==
-1) {
@@ -3801,8 +3801,8 @@
IPropertyStore* pProps = NULL;
PROPVARIANT varName;
- assert(pszBuffer != NULL);
- assert(bufferLen > 0);
+ RTC_DCHECK(pszBuffer);
+ RTC_DCHECK_GT(bufferLen, 0);
if (pDevice != NULL) {
hr = pDevice->OpenPropertyStore(STGM_READ, &pProps);
@@ -3867,8 +3867,8 @@
HRESULT hr = E_FAIL;
LPWSTR pwszID = NULL;
- assert(pszBuffer != NULL);
- assert(bufferLen > 0);
+ RTC_DCHECK(pszBuffer);
+ RTC_DCHECK_GT(bufferLen, 0);
if (pDevice != NULL) {
hr = pDevice->GetId(&pwszID);
@@ -3897,7 +3897,7 @@
HRESULT hr(S_OK);
- assert(_ptrEnumerator != NULL);
+ RTC_DCHECK(_ptrEnumerator);
hr = _ptrEnumerator->GetDefaultAudioEndpoint(dir, role, ppDevice);
if (FAILED(hr)) {
@@ -3917,7 +3917,7 @@
IMMDevice** ppDevice) {
HRESULT hr(S_OK);
- assert(_ptrEnumerator != NULL);
+ RTC_DCHECK(_ptrEnumerator);
IMMDeviceCollection* pCollection = NULL;
@@ -3951,7 +3951,7 @@
EDataFlow dataFlow) const {
RTC_DLOG(LS_VERBOSE) << __FUNCTION__;
- assert(_ptrEnumerator != NULL);
+ RTC_DCHECK(_ptrEnumerator);
HRESULT hr = S_OK;
IMMDeviceCollection* pCollection = NULL;
@@ -4143,7 +4143,7 @@
DWORD messageLength = ::FormatMessageW(dwFlags, 0, hr, dwLangID, errorText,
MAXERRORLENGTH, NULL);
- assert(messageLength <= MAXERRORLENGTH);
+ RTC_DCHECK_LE(messageLength, MAXERRORLENGTH);
// Trims tailing white space (FormatMessage() leaves a trailing cr-lf.).
for (; messageLength && ::isspace(errorText[messageLength - 1]);
diff --git a/modules/congestion_controller/goog_cc/loss_based_bandwidth_estimation.cc b/modules/congestion_controller/goog_cc/loss_based_bandwidth_estimation.cc
index 505e930..c7f53c6 100644
--- a/modules/congestion_controller/goog_cc/loss_based_bandwidth_estimation.cc
+++ b/modules/congestion_controller/goog_cc/loss_based_bandwidth_estimation.cc
@@ -36,7 +36,7 @@
}
auto rtt_range = config.increase_high_rtt.Get() - config.increase_low_rtt;
if (rtt_range <= TimeDelta::Zero()) {
- RTC_DCHECK(false); // Only on misconfiguration.
+ RTC_NOTREACHED(); // Only on misconfiguration.
return config.min_increase_factor;
}
auto rtt_offset = rtt - config.increase_low_rtt;
@@ -57,7 +57,7 @@
DataRate loss_bandwidth_balance,
double exponent) {
if (exponent <= 0) {
- RTC_DCHECK(false);
+ RTC_NOTREACHED();
return DataRate::Infinity();
}
if (loss < 1e-5)
@@ -69,7 +69,7 @@
// Use the convention that exponential window length (which is really
// infinite) is the time it takes to dampen to 1/e.
if (window <= TimeDelta::Zero()) {
- RTC_DCHECK(false);
+ RTC_NOTREACHED();
return 1.0f;
}
return 1.0f - exp(interval / window * -1.0);
@@ -134,7 +134,7 @@
const std::vector<PacketResult>& packet_results,
Timestamp at_time) {
if (packet_results.empty()) {
- RTC_DCHECK(false);
+ RTC_NOTREACHED();
return;
}
int loss_count = 0;
diff --git a/modules/desktop_capture/cropping_window_capturer_win.cc b/modules/desktop_capture/cropping_window_capturer_win.cc
index c52ca13..31ddbe1 100644
--- a/modules/desktop_capture/cropping_window_capturer_win.cc
+++ b/modules/desktop_capture/cropping_window_capturer_win.cc
@@ -118,7 +118,7 @@
// firing an assert when enabled, report that the selected window isn't
// topmost to avoid inadvertent capture of other windows.
RTC_LOG(LS_ERROR) << "Failed to enumerate windows: " << lastError;
- RTC_DCHECK(false);
+ RTC_NOTREACHED();
return false;
}
}
diff --git a/modules/desktop_capture/desktop_region.cc b/modules/desktop_capture/desktop_region.cc
index befbcc6..96f142d 100644
--- a/modules/desktop_capture/desktop_region.cc
+++ b/modules/desktop_capture/desktop_region.cc
@@ -10,11 +10,11 @@
#include "modules/desktop_capture/desktop_region.h"
-#include <assert.h>
-
#include <algorithm>
#include <utility>
+#include "rtc_base/checks.h"
+
namespace webrtc {
DesktopRegion::RowSpan::RowSpan(int32_t left, int32_t right)
@@ -109,7 +109,7 @@
// If the |top| falls in the middle of the |row| then split |row| into
// two, at |top|, and leave |row| referring to the lower of the two,
// ready to insert a new span into.
- assert(top <= row->second->bottom);
+ RTC_DCHECK_LE(top, row->second->bottom);
Rows::iterator new_row = rows_.insert(
row, Rows::value_type(top, new Row(row->second->top, top)));
row->second->top = top;
@@ -148,7 +148,7 @@
}
void DesktopRegion::MergeWithPrecedingRow(Rows::iterator row) {
- assert(row != rows_.end());
+ RTC_DCHECK(row != rows_.end());
if (row != rows_.begin()) {
Rows::iterator previous_row = row;
@@ -230,7 +230,7 @@
RowSpanSet::const_iterator end1 = set1.end();
RowSpanSet::const_iterator it2 = set2.begin();
RowSpanSet::const_iterator end2 = set2.end();
- assert(it1 != end1 && it2 != end2);
+ RTC_DCHECK(it1 != end1 && it2 != end2);
do {
// Arrange for |it1| to always be the left-most of the spans.
@@ -247,7 +247,7 @@
int32_t left = it2->left;
int32_t right = std::min(it1->right, it2->right);
- assert(left < right);
+ RTC_DCHECK_LT(left, right);
output->push_back(RowSpan(left, right));
@@ -302,7 +302,7 @@
// If |top| falls in the middle of |row_a| then split |row_a| into two, at
// |top|, and leave |row_a| referring to the lower of the two, ready to
// subtract spans from.
- assert(top <= row_a->second->bottom);
+ RTC_DCHECK_LE(top, row_a->second->bottom);
Rows::iterator new_row = rows_.insert(
row_a, Rows::value_type(top, new Row(row_a->second->top, top)));
row_a->second->top = top;
@@ -420,7 +420,7 @@
// Find the first span that ends at or after |left|.
RowSpanSet::iterator start = std::lower_bound(
row->spans.begin(), row->spans.end(), left, CompareSpanRight);
- assert(start < row->spans.end());
+ RTC_DCHECK(start < row->spans.end());
// Find the first span that starts after |right|.
RowSpanSet::iterator end =
@@ -467,7 +467,7 @@
void DesktopRegion::SubtractRows(const RowSpanSet& set_a,
const RowSpanSet& set_b,
RowSpanSet* output) {
- assert(!set_a.empty() && !set_b.empty());
+ RTC_DCHECK(!set_a.empty() && !set_b.empty());
RowSpanSet::const_iterator it_b = set_b.begin();
@@ -503,7 +503,7 @@
row_(region.rows_.begin()),
previous_row_(region.rows_.end()) {
if (!IsAtEnd()) {
- assert(row_->second->spans.size() > 0);
+ RTC_DCHECK_GT(row_->second->spans.size(), 0);
row_span_ = row_->second->spans.begin();
UpdateCurrentRect();
}
@@ -516,7 +516,7 @@
}
void DesktopRegion::Iterator::Advance() {
- assert(!IsAtEnd());
+ RTC_DCHECK(!IsAtEnd());
while (true) {
++row_span_;
@@ -524,7 +524,7 @@
previous_row_ = row_;
++row_;
if (row_ != region_.rows_.end()) {
- assert(row_->second->spans.size() > 0);
+ RTC_DCHECK_GT(row_->second->spans.size(), 0);
row_span_ = row_->second->spans.begin();
}
}
@@ -544,7 +544,7 @@
break;
}
- assert(!IsAtEnd());
+ RTC_DCHECK(!IsAtEnd());
UpdateCurrentRect();
}
diff --git a/modules/desktop_capture/linux/x_error_trap.cc b/modules/desktop_capture/linux/x_error_trap.cc
index 903aa86..13233d8 100644
--- a/modules/desktop_capture/linux/x_error_trap.cc
+++ b/modules/desktop_capture/linux/x_error_trap.cc
@@ -10,9 +10,10 @@
#include "modules/desktop_capture/linux/x_error_trap.h"
-#include <assert.h>
#include <stddef.h>
+#include "rtc_base/checks.h"
+
namespace webrtc {
namespace {
@@ -22,7 +23,7 @@
static int g_last_xserver_error_code = 0;
int XServerErrorHandler(Display* display, XErrorEvent* error_event) {
- assert(g_xserver_error_trap_enabled);
+ RTC_DCHECK(g_xserver_error_trap_enabled);
g_last_xserver_error_code = error_event->error_code;
return 0;
}
@@ -31,7 +32,7 @@
XErrorTrap::XErrorTrap(Display* display)
: original_error_handler_(NULL), enabled_(true) {
- assert(!g_xserver_error_trap_enabled);
+ RTC_DCHECK(!g_xserver_error_trap_enabled);
original_error_handler_ = XSetErrorHandler(&XServerErrorHandler);
g_xserver_error_trap_enabled = true;
g_last_xserver_error_code = 0;
@@ -39,7 +40,7 @@
int XErrorTrap::GetLastErrorAndDisable() {
enabled_ = false;
- assert(g_xserver_error_trap_enabled);
+ RTC_DCHECK(g_xserver_error_trap_enabled);
XSetErrorHandler(original_error_handler_);
g_xserver_error_trap_enabled = false;
return g_last_xserver_error_code;
diff --git a/modules/desktop_capture/mouse_cursor.cc b/modules/desktop_capture/mouse_cursor.cc
index 3b61e10..e826552 100644
--- a/modules/desktop_capture/mouse_cursor.cc
+++ b/modules/desktop_capture/mouse_cursor.cc
@@ -10,9 +10,8 @@
#include "modules/desktop_capture/mouse_cursor.h"
-#include <assert.h>
-
#include "modules/desktop_capture/desktop_frame.h"
+#include "rtc_base/checks.h"
namespace webrtc {
@@ -20,8 +19,8 @@
MouseCursor::MouseCursor(DesktopFrame* image, const DesktopVector& hotspot)
: image_(image), hotspot_(hotspot) {
- assert(0 <= hotspot_.x() && hotspot_.x() <= image_->size().width());
- assert(0 <= hotspot_.y() && hotspot_.y() <= image_->size().height());
+ RTC_DCHECK(0 <= hotspot_.x() && hotspot_.x() <= image_->size().width());
+ RTC_DCHECK(0 <= hotspot_.y() && hotspot_.y() <= image_->size().height());
}
MouseCursor::~MouseCursor() {}
diff --git a/modules/desktop_capture/mouse_cursor_monitor_unittest.cc b/modules/desktop_capture/mouse_cursor_monitor_unittest.cc
index ee2dff3..268e5e3 100644
--- a/modules/desktop_capture/mouse_cursor_monitor_unittest.cc
+++ b/modules/desktop_capture/mouse_cursor_monitor_unittest.cc
@@ -65,7 +65,7 @@
MouseCursorMonitor::CreateForScreen(
DesktopCaptureOptions::CreateDefault(),
webrtc::kFullDesktopScreenId));
- assert(capturer.get());
+ RTC_DCHECK(capturer.get());
capturer->Init(this, MouseCursorMonitor::SHAPE_AND_POSITION);
capturer->Capture();
@@ -102,7 +102,7 @@
std::unique_ptr<MouseCursorMonitor> capturer(
MouseCursorMonitor::CreateForWindow(
DesktopCaptureOptions::CreateDefault(), sources[i].id));
- assert(capturer.get());
+ RTC_DCHECK(capturer.get());
capturer->Init(this, MouseCursorMonitor::SHAPE_AND_POSITION);
capturer->Capture();
@@ -118,7 +118,7 @@
MouseCursorMonitor::CreateForScreen(
DesktopCaptureOptions::CreateDefault(),
webrtc::kFullDesktopScreenId));
- assert(capturer.get());
+ RTC_DCHECK(capturer.get());
capturer->Init(this, MouseCursorMonitor::SHAPE_ONLY);
capturer->Capture();
diff --git a/modules/desktop_capture/mouse_cursor_monitor_win.cc b/modules/desktop_capture/mouse_cursor_monitor_win.cc
index bf0d853..5a10ee1 100644
--- a/modules/desktop_capture/mouse_cursor_monitor_win.cc
+++ b/modules/desktop_capture/mouse_cursor_monitor_win.cc
@@ -77,7 +77,7 @@
callback_(NULL),
mode_(SHAPE_AND_POSITION),
desktop_dc_(NULL) {
- assert(screen >= kFullDesktopScreenId);
+ RTC_DCHECK_GE(screen, kFullDesktopScreenId);
memset(&last_cursor_, 0, sizeof(CURSORINFO));
}
@@ -87,8 +87,8 @@
}
void MouseCursorMonitorWin::Init(Callback* callback, Mode mode) {
- assert(!callback_);
- assert(callback);
+ RTC_DCHECK(!callback_);
+ RTC_DCHECK(callback);
callback_ = callback;
mode_ = mode;
@@ -97,7 +97,7 @@
}
void MouseCursorMonitorWin::Capture() {
- assert(callback_);
+ RTC_DCHECK(callback_);
CURSORINFO cursor_info;
cursor_info.cbSize = sizeof(CURSORINFO);
@@ -158,7 +158,7 @@
position = position.subtract(cropped_rect.top_left());
}
} else {
- assert(screen_ != kInvalidScreenId);
+ RTC_DCHECK_NE(screen_, kInvalidScreenId);
DesktopRect rect = GetScreenRect();
if (inside)
inside = rect.Contains(position);
@@ -169,7 +169,7 @@
}
DesktopRect MouseCursorMonitorWin::GetScreenRect() {
- assert(screen_ != kInvalidScreenId);
+ RTC_DCHECK_NE(screen_, kInvalidScreenId);
if (screen_ == kFullDesktopScreenId) {
return DesktopRect::MakeXYWH(GetSystemMetrics(SM_XVIRTUALSCREEN),
GetSystemMetrics(SM_YVIRTUALSCREEN),
diff --git a/modules/desktop_capture/screen_capturer_helper.cc b/modules/desktop_capture/screen_capturer_helper.cc
index 535b653..e8bd3fc 100644
--- a/modules/desktop_capture/screen_capturer_helper.cc
+++ b/modules/desktop_capture/screen_capturer_helper.cc
@@ -74,7 +74,7 @@
void ScreenCapturerHelper::ExpandToGrid(const DesktopRegion& region,
int log_grid_size,
DesktopRegion* result) {
- assert(log_grid_size >= 1);
+ RTC_DCHECK_GE(log_grid_size, 1);
int grid_size = 1 << log_grid_size;
int grid_size_mask = ~(grid_size - 1);
diff --git a/modules/desktop_capture/window_capturer_null.cc b/modules/desktop_capture/window_capturer_null.cc
index 66e76a5..e7c7b0a 100644
--- a/modules/desktop_capture/window_capturer_null.cc
+++ b/modules/desktop_capture/window_capturer_null.cc
@@ -8,10 +8,9 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#include <assert.h>
-
#include "modules/desktop_capture/desktop_capturer.h"
#include "modules/desktop_capture/desktop_frame.h"
+#include "rtc_base/checks.h"
#include "rtc_base/constructor_magic.h"
namespace webrtc {
@@ -49,8 +48,8 @@
}
void WindowCapturerNull::Start(Callback* callback) {
- assert(!callback_);
- assert(callback);
+ RTC_DCHECK(!callback_);
+ RTC_DCHECK(callback);
callback_ = callback;
}
diff --git a/modules/remote_bitrate_estimator/aimd_rate_control.cc b/modules/remote_bitrate_estimator/aimd_rate_control.cc
index 2ca298b..bf7119c 100644
--- a/modules/remote_bitrate_estimator/aimd_rate_control.cc
+++ b/modules/remote_bitrate_estimator/aimd_rate_control.cc
@@ -362,7 +362,7 @@
break;
}
default:
- assert(false);
+ RTC_NOTREACHED();
}
current_bitrate_ = ClampBitrate(new_bitrate.value_or(current_bitrate_));
@@ -417,7 +417,7 @@
rate_control_state_ = RateControlState::kRcHold;
break;
default:
- assert(false);
+ RTC_NOTREACHED();
}
}
diff --git a/modules/remote_bitrate_estimator/inter_arrival.cc b/modules/remote_bitrate_estimator/inter_arrival.cc
index b8e683b..a8cf47f 100644
--- a/modules/remote_bitrate_estimator/inter_arrival.cc
+++ b/modules/remote_bitrate_estimator/inter_arrival.cc
@@ -37,9 +37,9 @@
uint32_t* timestamp_delta,
int64_t* arrival_time_delta_ms,
int* packet_size_delta) {
- assert(timestamp_delta != NULL);
- assert(arrival_time_delta_ms != NULL);
- assert(packet_size_delta != NULL);
+ RTC_DCHECK(timestamp_delta);
+ RTC_DCHECK(arrival_time_delta_ms);
+ RTC_DCHECK(packet_size_delta);
bool calculated_deltas = false;
if (current_timestamp_group_.IsFirstPacket()) {
// We don't have enough data to update the filter, so we store it until we
@@ -85,7 +85,7 @@
} else {
num_consecutive_reordered_packets_ = 0;
}
- assert(*arrival_time_delta_ms >= 0);
+ RTC_DCHECK_GE(*arrival_time_delta_ms, 0);
*packet_size_delta = static_cast<int>(current_timestamp_group_.size) -
static_cast<int>(prev_timestamp_group_.size);
calculated_deltas = true;
@@ -141,7 +141,7 @@
if (!burst_grouping_) {
return false;
}
- assert(current_timestamp_group_.complete_time_ms >= 0);
+ RTC_DCHECK_GE(current_timestamp_group_.complete_time_ms, 0);
int64_t arrival_time_delta_ms =
arrival_time_ms - current_timestamp_group_.complete_time_ms;
uint32_t timestamp_diff = timestamp - current_timestamp_group_.timestamp;
diff --git a/modules/remote_bitrate_estimator/overuse_estimator.cc b/modules/remote_bitrate_estimator/overuse_estimator.cc
index 74449be..3427d58 100644
--- a/modules/remote_bitrate_estimator/overuse_estimator.cc
+++ b/modules/remote_bitrate_estimator/overuse_estimator.cc
@@ -110,7 +110,7 @@
bool positive_semi_definite =
E_[0][0] + E_[1][1] >= 0 &&
E_[0][0] * E_[1][1] - E_[0][1] * E_[1][0] >= 0 && E_[0][0] >= 0;
- assert(positive_semi_definite);
+ RTC_DCHECK(positive_semi_definite);
if (!positive_semi_definite) {
RTC_LOG(LS_ERROR)
<< "The over-use estimator's covariance matrix is no longer "
diff --git a/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.cc b/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.cc
index 46d8fbc..ddaa1de 100644
--- a/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.cc
+++ b/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.cc
@@ -234,7 +234,7 @@
std::vector<uint32_t>* ssrcs,
uint32_t* bitrate_bps) const {
MutexLock lock(&mutex_);
- assert(bitrate_bps);
+ RTC_DCHECK(bitrate_bps);
if (!remote_rate_->ValidEstimate()) {
return false;
}
@@ -248,7 +248,7 @@
void RemoteBitrateEstimatorSingleStream::GetSsrcs(
std::vector<uint32_t>* ssrcs) const {
- assert(ssrcs);
+ RTC_DCHECK(ssrcs);
ssrcs->resize(overuse_detectors_.size());
int i = 0;
for (SsrcOveruseEstimatorMap::const_iterator it = overuse_detectors_.begin();
diff --git a/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.cc b/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.cc
index 5e11794..66f8ca0 100644
--- a/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.cc
+++ b/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.cc
@@ -46,7 +46,7 @@
next_rtcp_time_(rtcp_receive_time),
rtp_timestamp_offset_(timestamp_offset),
kNtpFracPerMs(4.294967296E6) {
- assert(fps_ > 0);
+ RTC_DCHECK_GT(fps_, 0);
}
void RtpStream::set_rtp_timestamp_offset(uint32_t offset) {
@@ -60,7 +60,7 @@
if (time_now_us < next_rtp_time_) {
return next_rtp_time_;
}
- assert(packets != NULL);
+ RTC_DCHECK(packets);
size_t bits_per_frame = (bitrate_bps_ + fps_ / 2) / fps_;
size_t n_packets =
std::max<size_t>((bits_per_frame + 4 * kMtu) / (8 * kMtu), 1u);
@@ -173,9 +173,9 @@
// it possible to simulate different types of channels.
int64_t StreamGenerator::GenerateFrame(RtpStream::PacketList* packets,
int64_t time_now_us) {
- assert(packets != NULL);
- assert(packets->empty());
- assert(capacity_ > 0);
+ RTC_DCHECK(packets);
+ RTC_DCHECK(packets->empty());
+ RTC_DCHECK_GT(capacity_, 0);
StreamMap::iterator it =
std::min_element(streams_.begin(), streams_.end(), RtpStream::Compare);
(*it).second->GenerateFrame(time_now_us, packets);
diff --git a/modules/rtp_rtcp/source/rtp_utility.cc b/modules/rtp_rtcp/source/rtp_utility.cc
index d7df183..9b68f0d 100644
--- a/modules/rtp_rtcp/source/rtp_utility.cc
+++ b/modules/rtp_rtcp/source/rtp_utility.cc
@@ -131,7 +131,7 @@
}
bool RtpHeaderParser::ParseRtcp(RTPHeader* header) const {
- assert(header != NULL);
+ RTC_DCHECK(header);
const ptrdiff_t length = _ptrRTPDataEnd - _ptrRTPDataBegin;
if (length < kRtcpMinParseLength) {
diff --git a/modules/rtp_rtcp/test/testFec/test_packet_masks_metrics.cc b/modules/rtp_rtcp/test/testFec/test_packet_masks_metrics.cc
index 44597b85..dffdf2e 100644
--- a/modules/rtp_rtcp/test/testFec/test_packet_masks_metrics.cc
+++ b/modules/rtp_rtcp/test/testFec/test_packet_masks_metrics.cc
@@ -225,7 +225,7 @@
}
}
// Check that we can only recover 1 packet.
- assert(check_num_recovered == 1);
+ RTC_DCHECK_EQ(check_num_recovered, 1);
// Update the state with the newly recovered media packet.
state_tmp[jsel] = 0;
}
@@ -260,7 +260,7 @@
}
}
} else { // Gilbert-Elliot model for burst model.
- assert(loss_model_[k].loss_type == kBurstyLossModel);
+ RTC_DCHECK_EQ(loss_model_[k].loss_type, kBurstyLossModel);
// Transition probabilities: from previous to current state.
// Prob. of previous = lost --> current = received.
double prob10 = 1.0 / burst_length;
@@ -425,8 +425,8 @@
}
}
} // Done with loop over total number of packets.
- assert(num_media_packets_lost <= num_media_packets);
- assert(num_packets_lost <= tot_num_packets && num_packets_lost > 0);
+ RTC_DCHECK_LE(num_media_packets_lost, num_media_packets);
+ RTC_DCHECK_LE(num_packets_lost, tot_num_packets && num_packets_lost > 0);
double residual_loss = 0.0;
// Only need to compute residual loss (number of recovered packets) for
// configurations that have at least one media packet lost.
@@ -445,7 +445,7 @@
num_recovered_packets = num_media_packets_lost;
}
}
- assert(num_recovered_packets <= num_media_packets);
+ RTC_DCHECK_LE(num_recovered_packets, num_media_packets);
// Compute the residual loss. We only care about recovering media/source
// packets, so residual loss is based on lost/recovered media packets.
residual_loss =
@@ -464,9 +464,9 @@
// Update the distribution statistics.
// Compute the gap of the loss (the "consecutiveness" of the loss).
int gap_loss = GapLoss(tot_num_packets, state.get());
- assert(gap_loss < kMaxGapSize);
+ RTC_DCHECK_LT(gap_loss, kMaxGapSize);
int index = gap_loss * (2 * kMaxMediaPacketsTest) + num_packets_lost;
- assert(index < kNumStatesDistribution);
+ RTC_DCHECK_LT(index, kNumStatesDistribution);
metrics_code.residual_loss_per_loss_gap[index] += residual_loss;
if (code_type == xor_random_code) {
// The configuration density is only a function of the code length and
@@ -492,8 +492,8 @@
metrics_code.variance_residual_loss[k] -
(metrics_code.average_residual_loss[k] *
metrics_code.average_residual_loss[k]);
- assert(metrics_code.variance_residual_loss[k] >= 0.0);
- assert(metrics_code.average_residual_loss[k] > 0.0);
+ RTC_DCHECK_GE(metrics_code.variance_residual_loss[k], 0.0);
+ RTC_DCHECK_GT(metrics_code.average_residual_loss[k], 0.0);
metrics_code.variance_residual_loss[k] =
std::sqrt(metrics_code.variance_residual_loss[k]) /
metrics_code.average_residual_loss[k];
@@ -509,7 +509,7 @@
} else if (code_type == xor_bursty_code) {
CopyMetrics(&kMetricsXorBursty[code_index], metrics_code);
} else {
- assert(false);
+ RTC_NOTREACHED();
}
}
@@ -588,7 +588,7 @@
num_loss_models++;
}
}
- assert(num_loss_models == kNumLossModels);
+ RTC_DCHECK_EQ(num_loss_models, kNumLossModels);
}
void SetCodeParams() {
@@ -738,7 +738,7 @@
code_index++;
}
}
- assert(code_index == kNumberCodes);
+ RTC_DCHECK_EQ(code_index, kNumberCodes);
return 0;
}
diff --git a/modules/video_capture/device_info_impl.cc b/modules/video_capture/device_info_impl.cc
index 846977e..d5abb29 100644
--- a/modules/video_capture/device_info_impl.cc
+++ b/modules/video_capture/device_info_impl.cc
@@ -52,7 +52,7 @@
int32_t DeviceInfoImpl::GetCapability(const char* deviceUniqueIdUTF8,
const uint32_t deviceCapabilityNumber,
VideoCaptureCapability& capability) {
- assert(deviceUniqueIdUTF8 != NULL);
+ RTC_DCHECK(deviceUniqueIdUTF8);
MutexLock lock(&_apiLock);
diff --git a/modules/video_capture/test/video_capture_unittest.cc b/modules/video_capture/test/video_capture_unittest.cc
index 1a0cf2d..e74a456 100644
--- a/modules/video_capture/test/video_capture_unittest.cc
+++ b/modules/video_capture/test/video_capture_unittest.cc
@@ -152,7 +152,7 @@
void SetUp() override {
device_info_.reset(VideoCaptureFactory::CreateDeviceInfo());
- assert(device_info_.get());
+ RTC_DCHECK(device_info_.get());
number_of_devices_ = device_info_->NumberOfDevices();
ASSERT_GT(number_of_devices_, 0u);
}
diff --git a/modules/video_capture/windows/device_info_ds.cc b/modules/video_capture/windows/device_info_ds.cc
index e3833bc..3731dce 100644
--- a/modules/video_capture/windows/device_info_ds.cc
+++ b/modules/video_capture/windows/device_info_ds.cc
@@ -380,7 +380,7 @@
supportFORMAT_VideoInfo2 = true;
VIDEOINFOHEADER2* h =
reinterpret_cast<VIDEOINFOHEADER2*>(pmt->pbFormat);
- assert(h);
+ RTC_DCHECK(h);
foundInterlacedFormat |=
h->dwInterlaceFlags &
(AMINTERLACE_IsInterlaced | AMINTERLACE_DisplayModeBobOnly);
@@ -418,7 +418,7 @@
if (pmt->formattype == FORMAT_VideoInfo) {
VIDEOINFOHEADER* h = reinterpret_cast<VIDEOINFOHEADER*>(pmt->pbFormat);
- assert(h);
+ RTC_DCHECK(h);
capability.directShowCapabilityIndex = tmp;
capability.width = h->bmiHeader.biWidth;
capability.height = h->bmiHeader.biHeight;
@@ -427,7 +427,7 @@
if (pmt->formattype == FORMAT_VideoInfo2) {
VIDEOINFOHEADER2* h =
reinterpret_cast<VIDEOINFOHEADER2*>(pmt->pbFormat);
- assert(h);
+ RTC_DCHECK(h);
capability.directShowCapabilityIndex = tmp;
capability.width = h->bmiHeader.biWidth;
capability.height = h->bmiHeader.biHeight;
diff --git a/modules/video_capture/windows/sink_filter_ds.cc b/modules/video_capture/windows/sink_filter_ds.cc
index 9019b12..e4be7aa 100644
--- a/modules/video_capture/windows/sink_filter_ds.cc
+++ b/modules/video_capture/windows/sink_filter_ds.cc
@@ -58,7 +58,7 @@
}
STDMETHOD(Clone)(IEnumPins** pins) {
- RTC_DCHECK(false);
+ RTC_NOTREACHED();
return E_NOTIMPL;
}
@@ -83,7 +83,7 @@
}
STDMETHOD(Skip)(ULONG count) {
- RTC_DCHECK(false);
+ RTC_NOTREACHED();
return E_NOTIMPL;
}
@@ -274,7 +274,7 @@
// IEnumMediaTypes
STDMETHOD(Clone)(IEnumMediaTypes** pins) {
- RTC_DCHECK(false);
+ RTC_NOTREACHED();
return E_NOTIMPL;
}
@@ -364,7 +364,7 @@
}
STDMETHOD(Skip)(ULONG count) {
- RTC_DCHECK(false);
+ RTC_NOTREACHED();
return E_NOTIMPL;
}
@@ -538,7 +538,7 @@
return VFW_E_NOT_STOPPED;
if (receive_pin_) {
- RTC_DCHECK(false);
+ RTC_NOTREACHED();
return VFW_E_ALREADY_CONNECTED;
}
@@ -564,7 +564,7 @@
RTC_DCHECK(Filter()->IsStopped());
if (receive_pin_) {
- RTC_DCHECK(false);
+ RTC_NOTREACHED();
return VFW_E_ALREADY_CONNECTED;
}
diff --git a/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc b/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc
index e2849db..a994193 100644
--- a/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc
+++ b/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc
@@ -1037,7 +1037,7 @@
// would like to use the duration of the previous frame. Unfortunately the
// rate control seems to be off with that setup. Using the average input
// frame rate to calculate an average duration for now.
- assert(codec_.maxFramerate > 0);
+ RTC_DCHECK_GT(codec_.maxFramerate, 0);
uint32_t duration = kRtpTicksPerSecond / codec_.maxFramerate;
int error = WEBRTC_VIDEO_CODEC_OK;
@@ -1074,7 +1074,7 @@
int stream_idx,
int encoder_idx,
uint32_t timestamp) {
- assert(codec_specific != NULL);
+ RTC_DCHECK(codec_specific);
codec_specific->codecType = kVideoCodecVP8;
codec_specific->codecSpecific.VP8.keyIdx =
kNoKeyIdx; // TODO(hlundin) populate this
diff --git a/modules/video_coding/codecs/vp9/include/vp9_globals.h b/modules/video_coding/codecs/vp9/include/vp9_globals.h
index 6f9d099..34aa0bc 100644
--- a/modules/video_coding/codecs/vp9/include/vp9_globals.h
+++ b/modules/video_coding/codecs/vp9/include/vp9_globals.h
@@ -18,6 +18,7 @@
#include <stdint.h>
#include "modules/video_coding/codecs/interface/common_constants.h"
+#include "rtc_base/checks.h"
namespace webrtc {
@@ -131,7 +132,7 @@
pid_diff[7][1] = 2;
break;
default:
- assert(false);
+ RTC_NOTREACHED();
}
}
diff --git a/modules/video_coding/decoding_state.cc b/modules/video_coding/decoding_state.cc
index a951358..5e405cb 100644
--- a/modules/video_coding/decoding_state.cc
+++ b/modules/video_coding/decoding_state.cc
@@ -55,21 +55,22 @@
}
bool VCMDecodingState::IsOldFrame(const VCMFrameBuffer* frame) const {
- assert(frame != NULL);
+ RTC_DCHECK(frame);
if (in_initial_state_)
return false;
return !IsNewerTimestamp(frame->Timestamp(), time_stamp_);
}
bool VCMDecodingState::IsOldPacket(const VCMPacket* packet) const {
- assert(packet != NULL);
+ RTC_DCHECK(packet);
if (in_initial_state_)
return false;
return !IsNewerTimestamp(packet->timestamp, time_stamp_);
}
void VCMDecodingState::SetState(const VCMFrameBuffer* frame) {
- assert(frame != NULL && frame->GetHighSeqNum() >= 0);
+ RTC_DCHECK(frame);
+ RTC_CHECK_GE(frame->GetHighSeqNum(), 0);
if (!UsingFlexibleMode(frame))
UpdateSyncState(frame);
sequence_num_ = static_cast<uint16_t>(frame->GetHighSeqNum());
@@ -150,7 +151,7 @@
}
void VCMDecodingState::UpdateOldPacket(const VCMPacket* packet) {
- assert(packet != NULL);
+ RTC_DCHECK(packet);
if (packet->timestamp == time_stamp_) {
// Late packet belonging to the last decoded frame - make sure we update the
// last decoded sequence number.
@@ -204,7 +205,7 @@
// - Sequence numbers.
// Return true when in initial state.
// Note that when a method is not applicable it will return false.
- assert(frame != NULL);
+ RTC_DCHECK(frame);
// A key frame is always considered continuous as it doesn't refer to any
// frames and therefore won't introduce any errors even if prior frames are
// missing.
diff --git a/modules/video_coding/frame_buffer.cc b/modules/video_coding/frame_buffer.cc
index 0f64ab1..8f73e73 100644
--- a/modules/video_coding/frame_buffer.cc
+++ b/modules/video_coding/frame_buffer.cc
@@ -75,7 +75,7 @@
int64_t timeInMs,
const FrameData& frame_data) {
TRACE_EVENT0("webrtc", "VCMFrameBuffer::InsertPacket");
- assert(!(NULL == packet.dataPtr && packet.sizeBytes > 0));
+ RTC_DCHECK(!(NULL == packet.dataPtr && packet.sizeBytes > 0));
if (packet.dataPtr != NULL) {
_payloadType = packet.payloadType;
}
@@ -230,19 +230,19 @@
switch (state) {
case kStateIncomplete:
// we can go to this state from state kStateEmpty
- assert(_state == kStateEmpty);
+ RTC_DCHECK_EQ(_state, kStateEmpty);
// Do nothing, we received a packet
break;
case kStateComplete:
- assert(_state == kStateEmpty || _state == kStateIncomplete);
+ RTC_DCHECK(_state == kStateEmpty || _state == kStateIncomplete);
break;
case kStateEmpty:
// Should only be set to empty through Reset().
- assert(false);
+ RTC_NOTREACHED();
break;
}
_state = state;
diff --git a/modules/video_coding/jitter_buffer.cc b/modules/video_coding/jitter_buffer.cc
index 772098a..75142e9 100644
--- a/modules/video_coding/jitter_buffer.cc
+++ b/modules/video_coding/jitter_buffer.cc
@@ -347,7 +347,7 @@
int64_t VCMJitterBuffer::LastPacketTime(const VCMEncodedFrame* frame,
bool* retransmitted) const {
- assert(retransmitted);
+ RTC_DCHECK(retransmitted);
MutexLock lock(&mutex_);
const VCMFrameBuffer* frame_buffer =
static_cast<const VCMFrameBuffer*>(frame);
@@ -498,7 +498,7 @@
RecycleFrameBuffer(frame);
return kFlushIndicator;
default:
- assert(false);
+ RTC_NOTREACHED();
}
return buffer_state;
}
@@ -580,8 +580,8 @@
int max_packet_age_to_nack,
int max_incomplete_time_ms) {
MutexLock lock(&mutex_);
- assert(max_packet_age_to_nack >= 0);
- assert(max_incomplete_time_ms_ >= 0);
+ RTC_DCHECK_GE(max_packet_age_to_nack, 0);
+ RTC_DCHECK_GE(max_incomplete_time_ms_, 0);
max_nack_list_size_ = max_nack_list_size;
max_packet_age_to_nack_ = max_packet_age_to_nack;
max_incomplete_time_ms_ = max_incomplete_time_ms;
@@ -600,7 +600,7 @@
uint16_t VCMJitterBuffer::EstimatedLowSequenceNumber(
const VCMFrameBuffer& frame) const {
- assert(frame.GetLowSeqNum() >= 0);
+ RTC_DCHECK_GE(frame.GetLowSeqNum(), 0);
if (frame.HaveFirstPacket())
return frame.GetLowSeqNum();
diff --git a/modules/video_coding/jitter_estimator.cc b/modules/video_coding/jitter_estimator.cc
index 44e2a98..92a298c 100644
--- a/modules/video_coding/jitter_estimator.cc
+++ b/modules/video_coding/jitter_estimator.cc
@@ -247,7 +247,7 @@
hMh_sigma = deltaFSBytes * Mh[0] + Mh[1] + sigma;
if ((hMh_sigma < 1e-9 && hMh_sigma >= 0) ||
(hMh_sigma > -1e-9 && hMh_sigma <= 0)) {
- assert(false);
+ RTC_NOTREACHED();
return;
}
kalmanGain[0] = Mh[0] / hMh_sigma;
@@ -276,11 +276,11 @@
kalmanGain[1] * deltaFSBytes * t01;
// Covariance matrix, must be positive semi-definite.
- assert(_thetaCov[0][0] + _thetaCov[1][1] >= 0 &&
- _thetaCov[0][0] * _thetaCov[1][1] -
- _thetaCov[0][1] * _thetaCov[1][0] >=
- 0 &&
- _thetaCov[0][0] >= 0);
+ RTC_DCHECK(_thetaCov[0][0] + _thetaCov[1][1] >= 0 &&
+ _thetaCov[0][0] * _thetaCov[1][1] -
+ _thetaCov[0][1] * _thetaCov[1][0] >=
+ 0 &&
+ _thetaCov[0][0] >= 0);
}
// Calculate difference in delay between a sample and the expected delay
@@ -302,7 +302,7 @@
_lastUpdateT = now;
if (_alphaCount == 0) {
- assert(false);
+ RTC_NOTREACHED();
return;
}
double alpha =
@@ -428,7 +428,7 @@
double fps = 1000000.0 / fps_counter_.ComputeMean();
// Sanity check.
- assert(fps >= 0.0);
+ RTC_DCHECK_GE(fps, 0.0);
if (fps > kMaxFramerateEstimate) {
fps = kMaxFramerateEstimate;
}
diff --git a/modules/video_coding/media_opt_util.cc b/modules/video_coding/media_opt_util.cc
index b47eeb5..0136ae8 100644
--- a/modules/video_coding/media_opt_util.cc
+++ b/modules/video_coding/media_opt_util.cc
@@ -87,10 +87,10 @@
_lowRttNackMs(lowRttNackThresholdMs),
_highRttNackMs(highRttNackThresholdMs),
_maxFramesFec(1) {
- assert(lowRttNackThresholdMs >= -1 && highRttNackThresholdMs >= -1);
- assert(highRttNackThresholdMs == -1 ||
- lowRttNackThresholdMs <= highRttNackThresholdMs);
- assert(lowRttNackThresholdMs > -1 || highRttNackThresholdMs == -1);
+ RTC_DCHECK(lowRttNackThresholdMs >= -1 && highRttNackThresholdMs >= -1);
+ RTC_DCHECK(highRttNackThresholdMs == -1 ||
+ lowRttNackThresholdMs <= highRttNackThresholdMs);
+ RTC_DCHECK(lowRttNackThresholdMs > -1 || highRttNackThresholdMs == -1);
_type = kNackFec;
}
@@ -384,7 +384,7 @@
indexTableKey = VCM_MIN(indexTableKey, kFecRateTableSize);
// Check on table index
- assert(indexTableKey < kFecRateTableSize);
+ RTC_DCHECK_LT(indexTableKey, kFecRateTableSize);
// Protection factor for I frame
codeRateKey = kFecRateTable[indexTableKey];
diff --git a/modules/video_coding/session_info.cc b/modules/video_coding/session_info.cc
index 07b9a9d..477bbbe 100644
--- a/modules/video_coding/session_info.cc
+++ b/modules/video_coding/session_info.cc
@@ -49,7 +49,7 @@
const uint8_t* new_base_ptr) {
for (PacketIterator it = packets_.begin(); it != packets_.end(); ++it)
if ((*it).dataPtr != NULL) {
- assert(old_base_ptr != NULL && new_base_ptr != NULL);
+ RTC_DCHECK(old_base_ptr != NULL && new_base_ptr != NULL);
(*it).dataPtr = new_base_ptr + ((*it).dataPtr - old_base_ptr);
}
}
@@ -348,7 +348,7 @@
VCMSessionInfo::PacketIterator VCMSessionInfo::FindPartitionEnd(
PacketIterator it) const {
- assert((*it).codec() == kVideoCodecVP8);
+ RTC_DCHECK_EQ((*it).codec(), kVideoCodecVP8);
PacketIterator prev_it = it;
const int partition_id =
absl::get<RTPVideoHeaderVP8>((*it).video_header.video_type_header)
diff --git a/modules/video_coding/timing.cc b/modules/video_coding/timing.cc
index 7ad5edff..e811925 100644
--- a/modules/video_coding/timing.cc
+++ b/modules/video_coding/timing.cc
@@ -157,7 +157,7 @@
void VCMTiming::StopDecodeTimer(int32_t decode_time_ms, int64_t now_ms) {
MutexLock lock(&mutex_);
codec_timer_->AddTiming(decode_time_ms, now_ms);
- assert(decode_time_ms >= 0);
+ RTC_DCHECK_GE(decode_time_ms, 0);
++num_decoded_frames_;
}
@@ -199,7 +199,7 @@
int VCMTiming::RequiredDecodeTimeMs() const {
const int decode_time_ms = codec_timer_->RequiredDecodeTimeMs();
- assert(decode_time_ms >= 0);
+ RTC_DCHECK_GE(decode_time_ms, 0);
return decode_time_ms;
}
diff --git a/modules/video_coding/utility/simulcast_test_fixture_impl.cc b/modules/video_coding/utility/simulcast_test_fixture_impl.cc
index a9af643..8a27582 100644
--- a/modules/video_coding/utility/simulcast_test_fixture_impl.cc
+++ b/modules/video_coding/utility/simulcast_test_fixture_impl.cc
@@ -190,7 +190,7 @@
float max_framerate,
SpatialLayer* stream,
int num_temporal_layers) {
- assert(stream);
+ RTC_DCHECK(stream);
stream->width = width;
stream->height = height;
stream->maxBitrate = max_bitrate;
diff --git a/net/dcsctp/packet/sctp_packet.cc b/net/dcsctp/packet/sctp_packet.cc
index da06ccf..3e419c5 100644
--- a/net/dcsctp/packet/sctp_packet.cc
+++ b/net/dcsctp/packet/sctp_packet.cc
@@ -82,8 +82,8 @@
// The packet header (CommonHeader) hasn't been written yet:
return max_packet_size_ - kHeaderSize;
} else if (out_.size() > max_packet_size_) {
- RTC_DCHECK(false) << "Exceeded max size, data=" << out_.size()
- << ", max_size=" << max_packet_size_;
+ RTC_NOTREACHED() << "Exceeded max size, data=" << out_.size()
+ << ", max_size=" << max_packet_size_;
return 0;
}
return max_packet_size_ - out_.size();
diff --git a/rtc_base/system/unused.h b/rtc_base/system/unused.h
index 084c526..a5732a7 100644
--- a/rtc_base/system/unused.h
+++ b/rtc_base/system/unused.h
@@ -13,7 +13,7 @@
// Prevent the compiler from warning about an unused variable. For example:
// int result = DoSomething();
-// assert(result == 17);
+// RTC_DCHECK(result == 17);
// RTC_UNUSED(result);
// Note: In most cases it is better to remove the unused variable rather than
// suppressing the compiler warning.
diff --git a/rtc_base/third_party/base64/BUILD.gn b/rtc_base/third_party/base64/BUILD.gn
index db03e02..969c7c0 100644
--- a/rtc_base/third_party/base64/BUILD.gn
+++ b/rtc_base/third_party/base64/BUILD.gn
@@ -14,5 +14,8 @@
"base64.cc",
"base64.h",
]
- deps = [ "../../system:rtc_export" ]
+ deps = [
+ "../..:checks",
+ "../../system:rtc_export",
+ ]
}
diff --git a/rtc_base/third_party/base64/base64.cc b/rtc_base/third_party/base64/base64.cc
index 53ff6b9..b9acf9a 100644
--- a/rtc_base/third_party/base64/base64.cc
+++ b/rtc_base/third_party/base64/base64.cc
@@ -19,6 +19,8 @@
#include <assert.h>
#include <string.h>
+#include "rtc_base/checks.h"
+
using std::vector;
namespace rtc {
@@ -95,7 +97,7 @@
void Base64::EncodeFromArray(const void* data,
size_t len,
std::string* result) {
- assert(nullptr != result);
+ RTC_DCHECK(result);
result->clear();
result->resize(((len + 2) / 3) * 4);
const unsigned char* byte_data = static_cast<const unsigned char*>(data);
@@ -223,15 +225,15 @@
DecodeFlags flags,
T* result,
size_t* data_used) {
- assert(nullptr != result);
- assert(flags <= (DO_PARSE_MASK | DO_PAD_MASK | DO_TERM_MASK));
+ RTC_DCHECK(result);
+ RTC_DCHECK_LE(flags, (DO_PARSE_MASK | DO_PAD_MASK | DO_TERM_MASK));
const DecodeFlags parse_flags = flags & DO_PARSE_MASK;
const DecodeFlags pad_flags = flags & DO_PAD_MASK;
const DecodeFlags term_flags = flags & DO_TERM_MASK;
- assert(0 != parse_flags);
- assert(0 != pad_flags);
- assert(0 != term_flags);
+ RTC_DCHECK_NE(0, parse_flags);
+ RTC_DCHECK_NE(0, pad_flags);
+ RTC_DCHECK_NE(0, term_flags);
result->clear();
result->reserve(len);
diff --git a/rtc_tools/video_replay.cc b/rtc_tools/video_replay.cc
index dc98e4e..62981b6 100644
--- a/rtc_tools/video_replay.cc
+++ b/rtc_tools/video_replay.cc
@@ -280,7 +280,7 @@
video_codec_type_ = VideoCodecType::kVideoCodecH264;
} else {
RTC_LOG(LS_ERROR) << "Unsupported video codec " << codec;
- RTC_DCHECK(false);
+ RTC_NOTREACHED();
}
}
~DecoderIvfFileWriter() override { file_writer_->Close(); }
diff --git a/system_wrappers/source/field_trial.cc b/system_wrappers/source/field_trial.cc
index f1dccc9..d10b5cf 100644
--- a/system_wrappers/source/field_trial.cc
+++ b/system_wrappers/source/field_trial.cc
@@ -85,7 +85,7 @@
(*fieldtrial_map)[tokens[idx]] = tokens[idx + 1];
}
} else {
- RTC_DCHECK(false) << "Invalid field trials string:" << trials_string;
+ RTC_NOTREACHED() << "Invalid field trials string:" << trials_string;
}
}
diff --git a/test/frame_generator_unittest.cc b/test/frame_generator_unittest.cc
index 12d5111..8e5cde8 100644
--- a/test/frame_generator_unittest.cc
+++ b/test/frame_generator_unittest.cc
@@ -54,7 +54,7 @@
protected:
void WriteYuvFile(FILE* file, uint8_t y, uint8_t u, uint8_t v) {
- assert(file);
+ RTC_DCHECK(file);
std::unique_ptr<uint8_t[]> plane_buffer(new uint8_t[y_size]);
memset(plane_buffer.get(), y, y_size);
fwrite(plane_buffer.get(), 1, y_size, file);
diff --git a/test/linux/glx_renderer.cc b/test/linux/glx_renderer.cc
index 50f2a06..04d482c 100644
--- a/test/linux/glx_renderer.cc
+++ b/test/linux/glx_renderer.cc
@@ -20,8 +20,8 @@
GlxRenderer::GlxRenderer(size_t width, size_t height)
: width_(width), height_(height), display_(NULL), context_(NULL) {
- assert(width > 0);
- assert(height > 0);
+ RTC_DCHECK_GT(width, 0);
+ RTC_DCHECK_GT(height, 0);
}
GlxRenderer::~GlxRenderer() {
diff --git a/test/rtp_file_reader.cc b/test/rtp_file_reader.cc
index 1e268cf6..a09d5a6 100644
--- a/test/rtp_file_reader.cc
+++ b/test/rtp_file_reader.cc
@@ -83,7 +83,7 @@
}
bool NextPacket(RtpPacket* packet) override {
- assert(file_ != nullptr);
+ RTC_DCHECK(file_);
packet->length = RtpPacket::kMaxPacketBufferSize;
uint32_t len = 0;
TRY(ReadUint32(&len, file_));
@@ -276,7 +276,7 @@
if (result == kResultFail) {
break;
} else if (result == kResultSuccess && packets_.size() == 1) {
- assert(stream_start_ms == 0);
+ RTC_DCHECK_EQ(stream_start_ms, 0);
PacketIterator it = packets_.begin();
stream_start_ms = it->time_offset_ms;
it->time_offset_ms = 0;
@@ -330,9 +330,9 @@
}
virtual int NextPcap(uint8_t* data, uint32_t* length, uint32_t* time_ms) {
- assert(data);
- assert(length);
- assert(time_ms);
+ RTC_DCHECK(data);
+ RTC_DCHECK(length);
+ RTC_DCHECK(time_ms);
if (next_packet_it_ == packets_.end()) {
return -1;
@@ -409,7 +409,7 @@
uint32_t stream_start_ms,
uint32_t number,
const std::set<uint32_t>& ssrc_filter) {
- assert(next_packet_pos);
+ RTC_DCHECK(next_packet_pos);
uint32_t ts_sec; // Timestamp seconds.
uint32_t ts_usec; // Timestamp microseconds.
@@ -504,7 +504,7 @@
}
int ReadXxpIpHeader(RtpPacketMarker* marker) {
- assert(marker);
+ RTC_DCHECK(marker);
uint16_t version;
uint16_t length;
@@ -534,7 +534,7 @@
// Skip remaining fields of IP header.
uint16_t header_length = (version & 0x0f00) >> (8 - 2);
- assert(header_length >= kMinIpHeaderLength);
+ RTC_DCHECK_GE(header_length, kMinIpHeaderLength);
TRY_PCAP(Skip(header_length - kMinIpHeaderLength));
protocol = protocol & 0x00ff;
diff --git a/test/testsupport/file_utils.cc b/test/testsupport/file_utils.cc
index 0b4ffa4..1f829d3 100644
--- a/test/testsupport/file_utils.cc
+++ b/test/testsupport/file_utils.cc
@@ -107,7 +107,7 @@
if (::GetTempFileNameW(rtc::ToUtf16(dir).c_str(),
rtc::ToUtf16(prefix).c_str(), 0, filename) != 0)
return rtc::ToUtf8(filename);
- assert(false);
+ RTC_NOTREACHED();
return "";
#else
int len = dir.size() + prefix.size() + 2 + 6;
@@ -116,7 +116,7 @@
snprintf(tempname.get(), len, "%s/%sXXXXXX", dir.c_str(), prefix.c_str());
int fd = ::mkstemp(tempname.get());
if (fd == -1) {
- assert(false);
+ RTC_NOTREACHED();
return "";
} else {
::close(fd);
diff --git a/video/end_to_end_tests/stats_tests.cc b/video/end_to_end_tests/stats_tests.cc
index 605f40e..54e7bcf 100644
--- a/video/end_to_end_tests/stats_tests.cc
+++ b/video/end_to_end_tests/stats_tests.cc
@@ -142,8 +142,8 @@
stats.rtcp_packet_type_counts.nack_requests != 0 ||
stats.rtcp_packet_type_counts.unique_nack_requests != 0;
- assert(stats.current_payload_type == -1 ||
- stats.current_payload_type == kFakeVideoSendPayloadType);
+ RTC_DCHECK(stats.current_payload_type == -1 ||
+ stats.current_payload_type == kFakeVideoSendPayloadType);
receive_stats_filled_["IncomingPayloadType"] |=
stats.current_payload_type == kFakeVideoSendPayloadType;
}
diff --git a/video/video_analyzer.cc b/video/video_analyzer.cc
index 9655333..b90ba29 100644
--- a/video/video_analyzer.cc
+++ b/video/video_analyzer.cc
@@ -601,7 +601,7 @@
bool VideoAnalyzer::FrameProcessed() {
MutexLock lock(&comparison_lock_);
++frames_processed_;
- assert(frames_processed_ <= frames_to_process_);
+ RTC_DCHECK_LE(frames_processed_, frames_to_process_);
return frames_processed_ == frames_to_process_ ||
(clock_->CurrentTime() > test_end_ && comparisons_.empty());
}