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}
This commit is contained in:
Mirko Bonadei 2021-07-08 20:08:20 +02:00 committed by WebRTC LUCI CQ
parent 9b5d570ae0
commit 25ab3228f3
82 changed files with 407 additions and 392 deletions

View File

@ -162,7 +162,7 @@ AudioDecoder::SpeechType AudioDecoder::ConvertSpeechType(int16_t type) {
case 2: case 2:
return kComfortNoise; return kComfortNoise;
default: default:
assert(false); RTC_NOTREACHED();
return kSpeech; return kSpeech;
} }
} }

View File

@ -760,6 +760,7 @@ if (is_linux || is_chromeos || is_win) {
"peerconnection/server/utils.h", "peerconnection/server/utils.h",
] ]
deps = [ deps = [
"../rtc_base:checks",
"../rtc_base:rtc_base_approved", "../rtc_base:rtc_base_approved",
"../system_wrappers:field_trial", "../system_wrappers:field_trial",
"../test:field_trial", "../test:field_trial",

View File

@ -10,7 +10,6 @@
#include "examples/peerconnection/server/data_socket.h" #include "examples/peerconnection/server/data_socket.h"
#include <assert.h>
#include <ctype.h> #include <ctype.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -20,6 +19,7 @@
#endif #endif
#include "examples/peerconnection/server/utils.h" #include "examples/peerconnection/server/utils.h"
#include "rtc_base/checks.h"
static const char kHeaderTerminator[] = "\r\n\r\n"; static const char kHeaderTerminator[] = "\r\n\r\n";
static const int kHeaderTerminatorLength = sizeof(kHeaderTerminator) - 1; static const int kHeaderTerminatorLength = sizeof(kHeaderTerminator) - 1;
@ -53,7 +53,7 @@ WinsockInitializer WinsockInitializer::singleton;
// //
bool SocketBase::Create() { bool SocketBase::Create() {
assert(!valid()); RTC_DCHECK(!valid());
socket_ = ::socket(AF_INET, SOCK_STREAM, 0); socket_ = ::socket(AF_INET, SOCK_STREAM, 0);
return valid(); return valid();
} }
@ -77,7 +77,7 @@ std::string DataSocket::request_arguments() const {
} }
bool DataSocket::PathEquals(const char* path) const { bool DataSocket::PathEquals(const char* path) const {
assert(path); RTC_DCHECK(path);
size_t args = request_path_.find('?'); size_t args = request_path_.find('?');
if (args != std::string::npos) if (args != std::string::npos)
return request_path_.substr(0, args).compare(path) == 0; return request_path_.substr(0, args).compare(path) == 0;
@ -85,7 +85,7 @@ bool DataSocket::PathEquals(const char* path) const {
} }
bool DataSocket::OnDataAvailable(bool* close_socket) { bool DataSocket::OnDataAvailable(bool* close_socket) {
assert(valid()); RTC_DCHECK(valid());
char buffer[0xfff] = {0}; char buffer[0xfff] = {0};
int bytes = recv(socket_, buffer, sizeof(buffer), 0); int bytes = recv(socket_, buffer, sizeof(buffer), 0);
if (bytes == SOCKET_ERROR || bytes == 0) { if (bytes == SOCKET_ERROR || bytes == 0) {
@ -125,8 +125,8 @@ bool DataSocket::Send(const std::string& status,
const std::string& content_type, const std::string& content_type,
const std::string& extra_headers, const std::string& extra_headers,
const std::string& data) const { const std::string& data) const {
assert(valid()); RTC_DCHECK(valid());
assert(!status.empty()); RTC_DCHECK(!status.empty());
std::string buffer("HTTP/1.1 " + status + "\r\n"); std::string buffer("HTTP/1.1 " + status + "\r\n");
buffer += buffer +=
@ -165,8 +165,8 @@ void DataSocket::Clear() {
} }
bool DataSocket::ParseHeaders() { bool DataSocket::ParseHeaders() {
assert(!request_headers_.empty()); RTC_DCHECK(!request_headers_.empty());
assert(method_ == INVALID); RTC_DCHECK_EQ(method_, INVALID);
size_t i = request_headers_.find("\r\n"); size_t i = request_headers_.find("\r\n");
if (i == std::string::npos) if (i == std::string::npos)
return false; return false;
@ -174,8 +174,8 @@ bool DataSocket::ParseHeaders() {
if (!ParseMethodAndPath(request_headers_.data(), i)) if (!ParseMethodAndPath(request_headers_.data(), i))
return false; return false;
assert(method_ != INVALID); RTC_DCHECK_NE(method_, INVALID);
assert(!request_path_.empty()); RTC_DCHECK(!request_path_.empty());
if (method_ == POST) { if (method_ == POST) {
const char* headers = request_headers_.data() + i + 2; const char* headers = request_headers_.data() + i + 2;
@ -225,8 +225,8 @@ bool DataSocket::ParseMethodAndPath(const char* begin, size_t len) {
} }
bool DataSocket::ParseContentLengthAndType(const char* headers, size_t length) { bool DataSocket::ParseContentLengthAndType(const char* headers, size_t length) {
assert(content_length_ == 0); RTC_DCHECK_EQ(content_length_, 0);
assert(content_type_.empty()); RTC_DCHECK(content_type_.empty());
const char* end = headers + length; const char* end = headers + length;
while (headers && headers < end) { while (headers && headers < end) {
@ -267,7 +267,7 @@ bool DataSocket::ParseContentLengthAndType(const char* headers, size_t length) {
// //
bool ListeningSocket::Listen(unsigned short port) { bool ListeningSocket::Listen(unsigned short port) {
assert(valid()); RTC_DCHECK(valid());
int enabled = 1; int enabled = 1;
setsockopt(socket_, SOL_SOCKET, SO_REUSEADDR, setsockopt(socket_, SOL_SOCKET, SO_REUSEADDR,
reinterpret_cast<const char*>(&enabled), sizeof(enabled)); reinterpret_cast<const char*>(&enabled), sizeof(enabled));
@ -284,7 +284,7 @@ bool ListeningSocket::Listen(unsigned short port) {
} }
DataSocket* ListeningSocket::Accept() const { DataSocket* ListeningSocket::Accept() const {
assert(valid()); RTC_DCHECK(valid());
struct sockaddr_in addr = {0}; struct sockaddr_in addr = {0};
socklen_t size = sizeof(addr); socklen_t size = sizeof(addr);
NativeSocket client = NativeSocket client =

View File

@ -8,7 +8,6 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include <assert.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#if defined(WEBRTC_POSIX) #if defined(WEBRTC_POSIX)
@ -24,6 +23,7 @@
#include "absl/flags/usage.h" #include "absl/flags/usage.h"
#include "examples/peerconnection/server/data_socket.h" #include "examples/peerconnection/server/data_socket.h"
#include "examples/peerconnection/server/peer_channel.h" #include "examples/peerconnection/server/peer_channel.h"
#include "rtc_base/checks.h"
#include "system_wrappers/include/field_trial.h" #include "system_wrappers/include/field_trial.h"
#include "test/field_trial.h" #include "test/field_trial.h"
@ -41,8 +41,8 @@ ABSL_FLAG(int, port, 8888, "default: 8888");
static const size_t kMaxConnections = (FD_SETSIZE - 2); static const size_t kMaxConnections = (FD_SETSIZE - 2);
void HandleBrowserRequest(DataSocket* ds, bool* quit) { void HandleBrowserRequest(DataSocket* ds, bool* quit) {
assert(ds && ds->valid()); RTC_DCHECK(ds && ds->valid());
assert(quit); RTC_DCHECK(quit);
const std::string& path = ds->request_path(); const std::string& path = ds->request_path();
@ -162,7 +162,7 @@ int main(int argc, char* argv[]) {
if (socket_done) { if (socket_done) {
printf("Disconnecting socket\n"); printf("Disconnecting socket\n");
clients.OnClosing(s); 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); FD_CLR(s->socket(), &socket_set);
delete (*i); delete (*i);
i = sockets.erase(i); i = sockets.erase(i);

View File

@ -10,7 +10,6 @@
#include "examples/peerconnection/server/peer_channel.h" #include "examples/peerconnection/server/peer_channel.h"
#include <assert.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -18,6 +17,7 @@
#include "examples/peerconnection/server/data_socket.h" #include "examples/peerconnection/server/data_socket.h"
#include "examples/peerconnection/server/utils.h" #include "examples/peerconnection/server/utils.h"
#include "rtc_base/checks.h"
// Set to the peer id of the originator when messages are being // Set to the peer id of the originator when messages are being
// exchanged between peers, but set to the id of the receiving peer // exchanged between peers, but set to the id of the receiving peer
@ -57,9 +57,9 @@ ChannelMember::ChannelMember(DataSocket* socket)
id_(++s_member_id_), id_(++s_member_id_),
connected_(true), connected_(true),
timestamp_(time(NULL)) { timestamp_(time(NULL)) {
assert(socket); RTC_DCHECK(socket);
assert(socket->method() == DataSocket::GET); RTC_DCHECK_EQ(socket->method(), DataSocket::GET);
assert(socket->PathEquals("/sign_in")); RTC_DCHECK(socket->PathEquals("/sign_in"));
name_ = socket->request_arguments(); name_ = socket->request_arguments();
if (name_.empty()) if (name_.empty())
name_ = "peer_" + int2str(id_); name_ = "peer_" + int2str(id_);
@ -85,14 +85,14 @@ std::string ChannelMember::GetPeerIdHeader() const {
} }
bool ChannelMember::NotifyOfOtherMember(const ChannelMember& other) { bool ChannelMember::NotifyOfOtherMember(const ChannelMember& other) {
assert(&other != this); RTC_DCHECK_NE(&other, this);
QueueResponse("200 OK", "text/plain", GetPeerIdHeader(), other.GetEntry()); QueueResponse("200 OK", "text/plain", GetPeerIdHeader(), other.GetEntry());
return true; return true;
} }
// Returns a string in the form "name,id,connected\n". // Returns a string in the form "name,id,connected\n".
std::string ChannelMember::GetEntry() const { std::string ChannelMember::GetEntry() const {
assert(name_.length() <= kMaxNameLength); RTC_DCHECK(name_.length() <= kMaxNameLength);
// name, 11-digit int, 1-digit bool, newline, null // name, 11-digit int, 1-digit bool, newline, null
char entry[kMaxNameLength + 15]; char entry[kMaxNameLength + 15];
@ -102,8 +102,8 @@ std::string ChannelMember::GetEntry() const {
} }
void ChannelMember::ForwardRequestToPeer(DataSocket* ds, ChannelMember* peer) { void ChannelMember::ForwardRequestToPeer(DataSocket* ds, ChannelMember* peer) {
assert(peer); RTC_DCHECK(peer);
assert(ds); RTC_DCHECK(ds);
std::string extra_headers(GetPeerIdHeader()); std::string extra_headers(GetPeerIdHeader());
@ -129,8 +129,8 @@ void ChannelMember::QueueResponse(const std::string& status,
const std::string& extra_headers, const std::string& extra_headers,
const std::string& data) { const std::string& data) {
if (waiting_socket_) { if (waiting_socket_) {
assert(queue_.empty()); RTC_DCHECK(queue_.empty());
assert(waiting_socket_->method() == DataSocket::GET); RTC_DCHECK_EQ(waiting_socket_->method(), DataSocket::GET);
bool ok = bool ok =
waiting_socket_->Send(status, true, content_type, extra_headers, data); waiting_socket_->Send(status, true, content_type, extra_headers, data);
if (!ok) { if (!ok) {
@ -149,9 +149,9 @@ void ChannelMember::QueueResponse(const std::string& status,
} }
void ChannelMember::SetWaitingSocket(DataSocket* ds) { void ChannelMember::SetWaitingSocket(DataSocket* ds) {
assert(ds->method() == DataSocket::GET); RTC_DCHECK_EQ(ds->method(), DataSocket::GET);
if (ds && !queue_.empty()) { if (ds && !queue_.empty()) {
assert(waiting_socket_ == NULL); RTC_DCHECK(!waiting_socket_);
const QueuedResponse& response = queue_.front(); const QueuedResponse& response = queue_.front();
ds->Send(response.status, true, response.content_type, ds->Send(response.status, true, response.content_type,
response.extra_headers, response.data); response.extra_headers, response.data);
@ -167,13 +167,13 @@ void ChannelMember::SetWaitingSocket(DataSocket* ds) {
// static // static
bool PeerChannel::IsPeerConnection(const DataSocket* ds) { bool PeerChannel::IsPeerConnection(const DataSocket* ds) {
assert(ds); RTC_DCHECK(ds);
return (ds->method() == DataSocket::POST && ds->content_length() > 0) || return (ds->method() == DataSocket::POST && ds->content_length() > 0) ||
(ds->method() == DataSocket::GET && ds->PathEquals("/sign_in")); (ds->method() == DataSocket::GET && ds->PathEquals("/sign_in"));
} }
ChannelMember* PeerChannel::Lookup(DataSocket* ds) const { ChannelMember* PeerChannel::Lookup(DataSocket* ds) const {
assert(ds); RTC_DCHECK(ds);
if (ds->method() != DataSocket::GET && ds->method() != DataSocket::POST) if (ds->method() != DataSocket::GET && ds->method() != DataSocket::POST)
return NULL; return NULL;
@ -209,7 +209,7 @@ ChannelMember* PeerChannel::Lookup(DataSocket* ds) const {
} }
ChannelMember* PeerChannel::IsTargetedRequest(const DataSocket* ds) const { ChannelMember* PeerChannel::IsTargetedRequest(const DataSocket* ds) const {
assert(ds); RTC_DCHECK(ds);
// Regardless of GET or POST, we look for the peer_id parameter // Regardless of GET or POST, we look for the peer_id parameter
// only in the request_path. // only in the request_path.
const std::string& path = ds->request_path(); const std::string& path = ds->request_path();
@ -239,7 +239,7 @@ ChannelMember* PeerChannel::IsTargetedRequest(const DataSocket* ds) const {
} }
bool PeerChannel::AddMember(DataSocket* ds) { bool PeerChannel::AddMember(DataSocket* ds) {
assert(IsPeerConnection(ds)); RTC_DCHECK(IsPeerConnection(ds));
ChannelMember* new_guy = new ChannelMember(ds); ChannelMember* new_guy = new ChannelMember(ds);
Members failures; Members failures;
BroadcastChangedState(*new_guy, &failures); BroadcastChangedState(*new_guy, &failures);
@ -308,7 +308,7 @@ void PeerChannel::DeleteAll() {
void PeerChannel::BroadcastChangedState(const ChannelMember& member, void PeerChannel::BroadcastChangedState(const ChannelMember& member,
Members* delivery_failures) { Members* delivery_failures) {
// This function should be called prior to DataSocket::Close(). // This function should be called prior to DataSocket::Close().
assert(delivery_failures); RTC_DCHECK(delivery_failures);
if (!member.connected()) { if (!member.connected()) {
printf("Member disconnected: %s\n", member.name().c_str()); printf("Member disconnected: %s\n", member.name().c_str());
@ -329,12 +329,12 @@ void PeerChannel::BroadcastChangedState(const ChannelMember& member,
} }
void PeerChannel::HandleDeliveryFailures(Members* failures) { void PeerChannel::HandleDeliveryFailures(Members* failures) {
assert(failures); RTC_DCHECK(failures);
while (!failures->empty()) { while (!failures->empty()) {
Members::iterator i = failures->begin(); Members::iterator i = failures->begin();
ChannelMember* member = *i; ChannelMember* member = *i;
assert(!member->connected()); RTC_DCHECK(!member->connected());
failures->erase(i); failures->erase(i);
BroadcastChangedState(*member, failures); BroadcastChangedState(*member, failures);
delete member; delete member;
@ -344,14 +344,14 @@ void PeerChannel::HandleDeliveryFailures(Members* failures) {
// Builds a simple list of "name,id\n" entries for each member. // Builds a simple list of "name,id\n" entries for each member.
std::string PeerChannel::BuildResponseForNewMember(const ChannelMember& member, std::string PeerChannel::BuildResponseForNewMember(const ChannelMember& member,
std::string* content_type) { std::string* content_type) {
assert(content_type); RTC_DCHECK(content_type);
*content_type = "text/plain"; *content_type = "text/plain";
// The peer itself will always be the first entry. // The peer itself will always be the first entry.
std::string response(member.GetEntry()); std::string response(member.GetEntry());
for (Members::iterator i = members_.begin(); i != members_.end(); ++i) { for (Members::iterator i = members_.begin(); i != members_.end(); ++i) {
if (member.id() != (*i)->id()) { if (member.id() != (*i)->id()) {
assert((*i)->connected()); RTC_DCHECK((*i)->connected());
response += (*i)->GetEntry(); response += (*i)->GetEntry();
} }
} }

View File

@ -1606,6 +1606,7 @@ if (rtc_include_tests) {
deps += [ deps += [
":isac_fix", ":isac_fix",
":webrtc_opus", ":webrtc_opus",
"../../rtc_base:checks",
"../../rtc_base:rtc_base_approved", "../../rtc_base:rtc_base_approved",
"../../test:test_main", "../../test:test_main",
"../../test:test_support", "../../test:test_support",

View File

@ -119,7 +119,7 @@ class AcmReceiverTestOldApi : public AudioPacketizationCallback,
rtp_header_, rtp_header_,
rtc::ArrayView<const uint8_t>(payload_data, payload_len_bytes)); rtc::ArrayView<const uint8_t>(payload_data, payload_len_bytes));
if (ret_val < 0) { if (ret_val < 0) {
assert(false); RTC_NOTREACHED();
return -1; return -1;
} }
rtp_header_.sequenceNumber++; rtp_header_.sequenceNumber++;

View File

@ -31,7 +31,7 @@ int ACMResampler::Resample10Msec(const int16_t* in_audio,
size_t in_length = in_freq_hz * num_audio_channels / 100; size_t in_length = in_freq_hz * num_audio_channels / 100;
if (in_freq_hz == out_freq_hz) { if (in_freq_hz == out_freq_hz) {
if (out_capacity_samples < in_length) { if (out_capacity_samples < in_length) {
assert(false); RTC_NOTREACHED();
return -1; return -1;
} }
memcpy(out_audio, in_audio, in_length * sizeof(int16_t)); memcpy(out_audio, in_audio, in_length * sizeof(int16_t));

View File

@ -51,8 +51,8 @@ AcmSendTestOldApi::AcmSendTestOldApi(InputAudioFile* audio_source,
input_frame_.sample_rate_hz_ = source_rate_hz_; input_frame_.sample_rate_hz_ = source_rate_hz_;
input_frame_.num_channels_ = 1; input_frame_.num_channels_ = 1;
input_frame_.samples_per_channel_ = input_block_size_samples_; input_frame_.samples_per_channel_ = input_block_size_samples_;
assert(input_block_size_samples_ * input_frame_.num_channels_ <= RTC_DCHECK_LE(input_block_size_samples_ * input_frame_.num_channels_,
AudioFrame::kMaxDataSizeSamples); AudioFrame::kMaxDataSizeSamples);
acm_->RegisterTransportCallback(this); acm_->RegisterTransportCallback(this);
} }
@ -81,8 +81,8 @@ bool AcmSendTestOldApi::RegisterCodec(const char* payload_name,
factory->MakeAudioEncoder(payload_type, format, absl::nullopt)); factory->MakeAudioEncoder(payload_type, format, absl::nullopt));
codec_registered_ = true; codec_registered_ = true;
input_frame_.num_channels_ = num_channels; input_frame_.num_channels_ = num_channels;
assert(input_block_size_samples_ * input_frame_.num_channels_ <= RTC_DCHECK_LE(input_block_size_samples_ * input_frame_.num_channels_,
AudioFrame::kMaxDataSizeSamples); AudioFrame::kMaxDataSizeSamples);
return codec_registered_; return codec_registered_;
} }
@ -90,13 +90,13 @@ void AcmSendTestOldApi::RegisterExternalCodec(
std::unique_ptr<AudioEncoder> external_speech_encoder) { std::unique_ptr<AudioEncoder> external_speech_encoder) {
input_frame_.num_channels_ = external_speech_encoder->NumChannels(); input_frame_.num_channels_ = external_speech_encoder->NumChannels();
acm_->SetEncoder(std::move(external_speech_encoder)); acm_->SetEncoder(std::move(external_speech_encoder));
assert(input_block_size_samples_ * input_frame_.num_channels_ <= RTC_DCHECK_LE(input_block_size_samples_ * input_frame_.num_channels_,
AudioFrame::kMaxDataSizeSamples); AudioFrame::kMaxDataSizeSamples);
codec_registered_ = true; codec_registered_ = true;
} }
std::unique_ptr<Packet> AcmSendTestOldApi::NextPacket() { std::unique_ptr<Packet> AcmSendTestOldApi::NextPacket() {
assert(codec_registered_); RTC_DCHECK(codec_registered_);
if (filter_.test(static_cast<size_t>(payload_type_))) { if (filter_.test(static_cast<size_t>(payload_type_))) {
// This payload type should be filtered out. Since the payload type is the // 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. // same throughout the whole test run, no packet at all will be delivered.
@ -133,7 +133,7 @@ int32_t AcmSendTestOldApi::SendData(AudioFrameType frame_type,
payload_type_ = payload_type; payload_type_ = payload_type;
timestamp_ = timestamp; timestamp_ = timestamp;
last_payload_vec_.assign(payload_data, payload_data + payload_len_bytes); 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; data_to_send_ = true;
return 0; return 0;
} }

View File

@ -343,13 +343,13 @@ int AudioCodingModuleImpl::Add10MsData(const AudioFrame& audio_frame) {
int AudioCodingModuleImpl::Add10MsDataInternal(const AudioFrame& audio_frame, int AudioCodingModuleImpl::Add10MsDataInternal(const AudioFrame& audio_frame,
InputData* input_data) { InputData* input_data) {
if (audio_frame.samples_per_channel_ == 0) { if (audio_frame.samples_per_channel_ == 0) {
assert(false); RTC_NOTREACHED();
RTC_LOG(LS_ERROR) << "Cannot Add 10 ms audio, payload length is zero"; RTC_LOG(LS_ERROR) << "Cannot Add 10 ms audio, payload length is zero";
return -1; return -1;
} }
if (audio_frame.sample_rate_hz_ > kMaxInputSampleRateHz) { if (audio_frame.sample_rate_hz_ > kMaxInputSampleRateHz) {
assert(false); RTC_NOTREACHED();
RTC_LOG(LS_ERROR) << "Cannot Add 10 ms audio, input frequency not valid"; RTC_LOG(LS_ERROR) << "Cannot Add 10 ms audio, input frequency not valid";
return -1; return -1;
} }

View File

@ -11,6 +11,7 @@
#include "modules/audio_coding/codecs/isac/fix/include/isacfix.h" #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/isac/fix/source/settings.h"
#include "modules/audio_coding/codecs/tools/audio_codec_speed_test.h" #include "modules/audio_coding/codecs/tools/audio_codec_speed_test.h"
#include "rtc_base/checks.h"
using std::string; using std::string;
@ -83,7 +84,7 @@ float IsacSpeedTest::EncodeABlock(int16_t* in_data,
} }
clocks = clock() - clocks; clocks = clock() - clocks;
*encoded_bytes = static_cast<size_t>(value); *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; return 1000.0 * clocks / CLOCKS_PER_SEC;
} }

View File

@ -88,7 +88,7 @@ class SplitBySamplesTest : public ::testing::TestWithParam<NetEqDecoder> {
samples_per_ms_ = 8; samples_per_ms_ = 8;
break; break;
default: default:
assert(false); RTC_NOTREACHED();
break; break;
} }
} }

View File

@ -10,6 +10,7 @@
#include "modules/audio_coding/codecs/tools/audio_codec_speed_test.h" #include "modules/audio_coding/codecs/tools/audio_codec_speed_test.h"
#include "rtc_base/checks.h"
#include "rtc_base/format_macros.h" #include "rtc_base/format_macros.h"
#include "test/gtest.h" #include "test/gtest.h"
#include "test/testsupport/file_utils.h" #include "test/testsupport/file_utils.h"
@ -43,7 +44,7 @@ void AudioCodecSpeedTest::SetUp() {
save_out_data_ = get<4>(GetParam()); save_out_data_ = get<4>(GetParam());
FILE* fp = fopen(in_filename_.c_str(), "rb"); FILE* fp = fopen(in_filename_.c_str(), "rb");
assert(fp != NULL); RTC_DCHECK(fp);
// Obtain file size. // Obtain file size.
fseek(fp, 0, SEEK_END); fseek(fp, 0, SEEK_END);
@ -83,7 +84,7 @@ void AudioCodecSpeedTest::SetUp() {
out_filename = test::OutputPath() + out_filename + ".pcm"; out_filename = test::OutputPath() + out_filename + ".pcm";
out_file_ = fopen(out_filename.c_str(), "wb"); 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()); printf("Output to be saved in %s.\n", out_filename.c_str());
} }

View File

@ -69,7 +69,7 @@ Accelerate::ReturnCodes Accelerate::CheckCriteriaAndStretch(
peak_index = (fs_mult_120 / peak_index) * peak_index; 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. // Copy first part; 0 to 15 ms.
output->PushBackInterleaved( output->PushBackInterleaved(
rtc::ArrayView<const int16_t>(input, fs_mult_120 * num_channels_)); rtc::ArrayView<const int16_t>(input, fs_mult_120 * num_channels_));

View File

@ -77,9 +77,9 @@ double MseInputOutput(const std::vector<int16_t>& input,
size_t num_samples, size_t num_samples,
size_t channels, size_t channels,
int delay) { int delay) {
assert(delay < static_cast<int>(num_samples)); RTC_DCHECK_LT(delay, static_cast<int>(num_samples));
assert(num_samples <= input.size()); RTC_DCHECK_LE(num_samples, input.size());
assert(num_samples * channels <= output.size()); RTC_DCHECK_LE(num_samples * channels, output.size());
if (num_samples == 0) if (num_samples == 0)
return 0.0; return 0.0;
double squared_sum = 0.0; double squared_sum = 0.0;
@ -303,7 +303,7 @@ class AudioDecoderPcm16BTest : public AudioDecoderTest {
frame_size_ = 20 * codec_input_rate_hz_ / 1000; frame_size_ = 20 * codec_input_rate_hz_ / 1000;
data_length_ = 10 * frame_size_; data_length_ = 10 * frame_size_;
decoder_ = new AudioDecoderPcm16B(codec_input_rate_hz_, 1); decoder_ = new AudioDecoderPcm16B(codec_input_rate_hz_, 1);
assert(decoder_); RTC_DCHECK(decoder_);
AudioEncoderPcm16B::Config config; AudioEncoderPcm16B::Config config;
config.sample_rate_hz = codec_input_rate_hz_; config.sample_rate_hz = codec_input_rate_hz_;
config.frame_size_ms = config.frame_size_ms =
@ -320,7 +320,7 @@ class AudioDecoderIlbcTest : public AudioDecoderTest {
frame_size_ = 240; frame_size_ = 240;
data_length_ = 10 * frame_size_; data_length_ = 10 * frame_size_;
decoder_ = new AudioDecoderIlbcImpl; decoder_ = new AudioDecoderIlbcImpl;
assert(decoder_); RTC_DCHECK(decoder_);
AudioEncoderIlbcConfig config; AudioEncoderIlbcConfig config;
config.frame_size_ms = 30; config.frame_size_ms = 30;
audio_encoder_.reset(new AudioEncoderIlbcImpl(config, payload_type_)); audio_encoder_.reset(new AudioEncoderIlbcImpl(config, payload_type_));
@ -414,7 +414,7 @@ class AudioDecoderG722Test : public AudioDecoderTest {
frame_size_ = 160; frame_size_ = 160;
data_length_ = 10 * frame_size_; data_length_ = 10 * frame_size_;
decoder_ = new AudioDecoderG722Impl; decoder_ = new AudioDecoderG722Impl;
assert(decoder_); RTC_DCHECK(decoder_);
AudioEncoderG722Config config; AudioEncoderG722Config config;
config.frame_size_ms = 10; config.frame_size_ms = 10;
config.num_channels = 1; config.num_channels = 1;
@ -430,7 +430,7 @@ class AudioDecoderG722StereoTest : public AudioDecoderTest {
frame_size_ = 160; frame_size_ = 160;
data_length_ = 10 * frame_size_; data_length_ = 10 * frame_size_;
decoder_ = new AudioDecoderG722StereoImpl; decoder_ = new AudioDecoderG722StereoImpl;
assert(decoder_); RTC_DCHECK(decoder_);
AudioEncoderG722Config config; AudioEncoderG722Config config;
config.frame_size_ms = 10; config.frame_size_ms = 10;
config.num_channels = 2; config.num_channels = 2;

View File

@ -19,7 +19,7 @@
namespace webrtc { namespace webrtc {
AudioMultiVector::AudioMultiVector(size_t N) { AudioMultiVector::AudioMultiVector(size_t N) {
assert(N > 0); RTC_DCHECK_GT(N, 0);
if (N < 1) if (N < 1)
N = 1; N = 1;
for (size_t n = 0; n < N; ++n) { for (size_t n = 0; n < N; ++n) {
@ -29,7 +29,7 @@ AudioMultiVector::AudioMultiVector(size_t N) {
} }
AudioMultiVector::AudioMultiVector(size_t N, size_t initial_size) { AudioMultiVector::AudioMultiVector(size_t N, size_t initial_size) {
assert(N > 0); RTC_DCHECK_GT(N, 0);
if (N < 1) if (N < 1)
N = 1; N = 1;
for (size_t n = 0; n < N; ++n) { for (size_t n = 0; n < N; ++n) {
@ -91,7 +91,7 @@ void AudioMultiVector::PushBackInterleaved(
} }
void AudioMultiVector::PushBack(const AudioMultiVector& append_this) { 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_) { if (num_channels_ == append_this.num_channels_) {
for (size_t i = 0; i < num_channels_; ++i) { for (size_t i = 0; i < num_channels_; ++i) {
channels_[i]->PushBack(append_this[i]); channels_[i]->PushBack(append_this[i]);
@ -101,10 +101,10 @@ void AudioMultiVector::PushBack(const AudioMultiVector& append_this) {
void AudioMultiVector::PushBackFromIndex(const AudioMultiVector& append_this, void AudioMultiVector::PushBackFromIndex(const AudioMultiVector& append_this,
size_t index) { size_t index) {
assert(index < append_this.Size()); RTC_DCHECK_LT(index, append_this.Size());
index = std::min(index, append_this.Size() - 1); index = std::min(index, append_this.Size() - 1);
size_t length = append_this.Size() - index; 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_) { if (num_channels_ == append_this.num_channels_) {
for (size_t i = 0; i < num_channels_; ++i) { for (size_t i = 0; i < num_channels_; ++i) {
channels_[i]->PushBack(append_this[i], length, index); channels_[i]->PushBack(append_this[i], length, index);
@ -162,9 +162,9 @@ size_t AudioMultiVector::ReadInterleavedFromEnd(size_t length,
void AudioMultiVector::OverwriteAt(const AudioMultiVector& insert_this, void AudioMultiVector::OverwriteAt(const AudioMultiVector& insert_this,
size_t length, size_t length,
size_t position) { 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|. // 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()); length = std::min(length, insert_this.Size());
if (num_channels_ == insert_this.num_channels_) { if (num_channels_ == insert_this.num_channels_) {
for (size_t i = 0; i < num_channels_; ++i) { for (size_t i = 0; i < num_channels_; ++i) {
@ -175,7 +175,7 @@ void AudioMultiVector::OverwriteAt(const AudioMultiVector& insert_this,
void AudioMultiVector::CrossFade(const AudioMultiVector& append_this, void AudioMultiVector::CrossFade(const AudioMultiVector& append_this,
size_t fade_length) { 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_) { if (num_channels_ == append_this.num_channels_) {
for (size_t i = 0; i < num_channels_; ++i) { for (size_t i = 0; i < num_channels_; ++i) {
channels_[i]->CrossFade(append_this[i], fade_length); channels_[i]->CrossFade(append_this[i], fade_length);
@ -188,7 +188,7 @@ size_t AudioMultiVector::Channels() const {
} }
size_t AudioMultiVector::Size() const { size_t AudioMultiVector::Size() const {
assert(channels_[0]); RTC_DCHECK(channels_[0]);
return channels_[0]->Size(); return channels_[0]->Size();
} }
@ -202,13 +202,13 @@ void AudioMultiVector::AssertSize(size_t required_size) {
} }
bool AudioMultiVector::Empty() const { bool AudioMultiVector::Empty() const {
assert(channels_[0]); RTC_DCHECK(channels_[0]);
return channels_[0]->Empty(); return channels_[0]->Empty();
} }
void AudioMultiVector::CopyChannel(size_t from_channel, size_t to_channel) { void AudioMultiVector::CopyChannel(size_t from_channel, size_t to_channel) {
assert(from_channel < num_channels_); RTC_DCHECK_LT(from_channel, num_channels_);
assert(to_channel < num_channels_); RTC_DCHECK_LT(to_channel, num_channels_);
channels_[from_channel]->CopyTo(channels_[to_channel]); channels_[from_channel]->CopyTo(channels_[to_channel]);
} }

View File

@ -247,8 +247,8 @@ void AudioVector::OverwriteAt(const int16_t* insert_this,
void AudioVector::CrossFade(const AudioVector& append_this, void AudioVector::CrossFade(const AudioVector& append_this,
size_t fade_length) { size_t fade_length) {
// Fade length cannot be longer than the current vector or |append_this|. // Fade length cannot be longer than the current vector or |append_this|.
assert(fade_length <= Size()); RTC_DCHECK_LE(fade_length, Size());
assert(fade_length <= append_this.Size()); RTC_DCHECK_LE(fade_length, append_this.Size());
fade_length = std::min(fade_length, Size()); fade_length = std::min(fade_length, Size());
fade_length = std::min(fade_length, append_this.Size()); fade_length = std::min(fade_length, append_this.Size());
size_t position = Size() - fade_length + begin_index_; size_t position = Size() - fade_length + begin_index_;
@ -265,7 +265,7 @@ void AudioVector::CrossFade(const AudioVector& append_this,
(16384 - alpha) * append_this[i] + 8192) >> (16384 - alpha) * append_this[i] + 8192) >>
14; 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|. // Append what is left of |append_this|.
size_t samples_to_push_back = append_this.Size() - fade_length; size_t samples_to_push_back = append_this.Size() - fade_length;
if (samples_to_push_back > 0) if (samples_to_push_back > 0)

View File

@ -136,7 +136,7 @@ void BackgroundNoise::GenerateBackgroundNoise(
int16_t* buffer) { int16_t* buffer) {
constexpr size_t kNoiseLpcOrder = kMaxLpcOrder; constexpr size_t kNoiseLpcOrder = kMaxLpcOrder;
int16_t scaled_random_vector[kMaxSampleRate / 8000 * 125]; 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); RTC_DCHECK_GE(random_vector.size(), num_noise_samples);
int16_t* noise_samples = &buffer[kNoiseLpcOrder]; int16_t* noise_samples = &buffer[kNoiseLpcOrder];
if (initialized()) { if (initialized()) {
@ -178,44 +178,44 @@ void BackgroundNoise::GenerateBackgroundNoise(
} }
int32_t BackgroundNoise::Energy(size_t channel) const { int32_t BackgroundNoise::Energy(size_t channel) const {
assert(channel < num_channels_); RTC_DCHECK_LT(channel, num_channels_);
return channel_parameters_[channel].energy; return channel_parameters_[channel].energy;
} }
void BackgroundNoise::SetMuteFactor(size_t channel, int16_t value) { 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; channel_parameters_[channel].mute_factor = value;
} }
int16_t BackgroundNoise::MuteFactor(size_t channel) const { int16_t BackgroundNoise::MuteFactor(size_t channel) const {
assert(channel < num_channels_); RTC_DCHECK_LT(channel, num_channels_);
return channel_parameters_[channel].mute_factor; return channel_parameters_[channel].mute_factor;
} }
const int16_t* BackgroundNoise::Filter(size_t channel) const { const int16_t* BackgroundNoise::Filter(size_t channel) const {
assert(channel < num_channels_); RTC_DCHECK_LT(channel, num_channels_);
return channel_parameters_[channel].filter; return channel_parameters_[channel].filter;
} }
const int16_t* BackgroundNoise::FilterState(size_t channel) const { 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; return channel_parameters_[channel].filter_state;
} }
void BackgroundNoise::SetFilterState(size_t channel, void BackgroundNoise::SetFilterState(size_t channel,
rtc::ArrayView<const int16_t> input) { rtc::ArrayView<const int16_t> input) {
assert(channel < num_channels_); RTC_DCHECK_LT(channel, num_channels_);
size_t length = std::min(input.size(), kMaxLpcOrder); size_t length = std::min(input.size(), kMaxLpcOrder);
memcpy(channel_parameters_[channel].filter_state, input.data(), memcpy(channel_parameters_[channel].filter_state, input.data(),
length * sizeof(int16_t)); length * sizeof(int16_t));
} }
int16_t BackgroundNoise::Scale(size_t channel) const { int16_t BackgroundNoise::Scale(size_t channel) const {
assert(channel < num_channels_); RTC_DCHECK_LT(channel, num_channels_);
return channel_parameters_[channel].scale; return channel_parameters_[channel].scale;
} }
int16_t BackgroundNoise::ScaleShift(size_t channel) const { int16_t BackgroundNoise::ScaleShift(size_t channel) const {
assert(channel < num_channels_); RTC_DCHECK_LT(channel, num_channels_);
return channel_parameters_[channel].scale_shift; return channel_parameters_[channel].scale_shift;
} }
@ -240,7 +240,7 @@ void BackgroundNoise::IncrementEnergyThreshold(size_t channel,
// to the limited-width operations, it is not exactly the same. The // to the limited-width operations, it is not exactly the same. The
// difference should be inaudible, but bit-exactness would not be // difference should be inaudible, but bit-exactness would not be
// maintained. // maintained.
assert(channel < num_channels_); RTC_DCHECK_LT(channel, num_channels_);
ChannelParameters& parameters = channel_parameters_[channel]; ChannelParameters& parameters = channel_parameters_[channel];
int32_t temp_energy = int32_t temp_energy =
(kThresholdIncrement * parameters.low_energy_update_threshold) >> 16; (kThresholdIncrement * parameters.low_energy_update_threshold) >> 16;
@ -278,7 +278,7 @@ void BackgroundNoise::SaveParameters(size_t channel,
const int16_t* filter_state, const int16_t* filter_state,
int32_t sample_energy, int32_t sample_energy,
int32_t residual_energy) { int32_t residual_energy) {
assert(channel < num_channels_); RTC_DCHECK_LT(channel, num_channels_);
ChannelParameters& parameters = channel_parameters_[channel]; ChannelParameters& parameters = channel_parameters_[channel];
memcpy(parameters.filter, lpc_coefficients, memcpy(parameters.filter, lpc_coefficients,
(kMaxLpcOrder + 1) * sizeof(int16_t)); (kMaxLpcOrder + 1) * sizeof(int16_t));

View File

@ -45,8 +45,8 @@ int ComfortNoise::UpdateParameters(const Packet& packet) {
int ComfortNoise::Generate(size_t requested_length, AudioMultiVector* output) { int ComfortNoise::Generate(size_t requested_length, AudioMultiVector* output) {
// TODO(hlundin): Change to an enumerator and skip assert. // TODO(hlundin): Change to an enumerator and skip assert.
assert(fs_hz_ == 8000 || fs_hz_ == 16000 || fs_hz_ == 32000 || RTC_DCHECK(fs_hz_ == 8000 || fs_hz_ == 16000 || fs_hz_ == 32000 ||
fs_hz_ == 48000); fs_hz_ == 48000);
// Not adapted for multi-channel yet. // Not adapted for multi-channel yet.
if (output->Channels() != 1) { if (output->Channels() != 1) {
RTC_LOG(LS_ERROR) << "No multi-channel support"; RTC_LOG(LS_ERROR) << "No multi-channel support";

View File

@ -96,7 +96,8 @@ void DecisionLogic::SoftReset() {
void DecisionLogic::SetSampleRate(int fs_hz, size_t output_size_samples) { void DecisionLogic::SetSampleRate(int fs_hz, size_t output_size_samples) {
// TODO(hlundin): Change to an enumerator and skip assert. // 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; sample_rate_ = fs_hz;
output_size_samples_ = output_size_samples; output_size_samples_ = output_size_samples;
} }

View File

@ -89,7 +89,7 @@ int DspHelper::RampSignal(AudioMultiVector* signal,
size_t length, size_t length,
int factor, int factor,
int increment) { int increment) {
assert(start_index + length <= signal->Size()); RTC_DCHECK_LE(start_index + length, signal->Size());
if (start_index + length > signal->Size()) { if (start_index + length > signal->Size()) {
// Wrong parameters. Do nothing and return the scale factor unaltered. // Wrong parameters. Do nothing and return the scale factor unaltered.
return factor; return factor;
@ -355,7 +355,7 @@ int DspHelper::DownsampleTo4kHz(const int16_t* input,
break; break;
} }
default: { default: {
assert(false); RTC_NOTREACHED();
return -1; return -1;
} }
} }

View File

@ -48,9 +48,10 @@ Expand::Expand(BackgroundNoise* background_noise,
stop_muting_(false), stop_muting_(false),
expand_duration_samples_(0), expand_duration_samples_(0),
channel_parameters_(new ChannelParameters[num_channels_]) { channel_parameters_(new ChannelParameters[num_channels_]) {
assert(fs == 8000 || fs == 16000 || fs == 32000 || fs == 48000); RTC_DCHECK(fs == 8000 || fs == 16000 || fs == 32000 || fs == 48000);
assert(fs <= static_cast<int>(kMaxSampleRate)); // Should not be possible. RTC_DCHECK_LE(fs,
assert(num_channels_ > 0); static_cast<int>(kMaxSampleRate)); // Should not be possible.
RTC_DCHECK_GT(num_channels_, 0);
memset(expand_lags_, 0, sizeof(expand_lags_)); memset(expand_lags_, 0, sizeof(expand_lags_));
Reset(); Reset();
} }
@ -91,7 +92,7 @@ int Expand::Process(AudioMultiVector* output) {
// Extract a noise segment. // Extract a noise segment.
size_t rand_length = max_lag_; size_t rand_length = max_lag_;
// This only applies to SWB where length could be larger than 256. // 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); GenerateRandomVector(2, rand_length, random_vector);
} }
@ -110,8 +111,8 @@ int Expand::Process(AudioMultiVector* output) {
ChannelParameters& parameters = channel_parameters_[channel_ix]; ChannelParameters& parameters = channel_parameters_[channel_ix];
if (current_lag_index_ == 0) { if (current_lag_index_ == 0) {
// Use only expand_vector0. // Use only expand_vector0.
assert(expansion_vector_position + temp_length <= RTC_DCHECK_LE(expansion_vector_position + temp_length,
parameters.expand_vector0.Size()); parameters.expand_vector0.Size());
parameters.expand_vector0.CopyTo(temp_length, expansion_vector_position, parameters.expand_vector0.CopyTo(temp_length, expansion_vector_position,
voiced_vector_storage); voiced_vector_storage);
} else if (current_lag_index_ == 1) { } else if (current_lag_index_ == 1) {
@ -126,10 +127,10 @@ int Expand::Process(AudioMultiVector* output) {
voiced_vector_storage, temp_length); voiced_vector_storage, temp_length);
} else if (current_lag_index_ == 2) { } else if (current_lag_index_ == 2) {
// Mix 1/2 of expand_vector0 with 1/2 of expand_vector1. // Mix 1/2 of expand_vector0 with 1/2 of expand_vector1.
assert(expansion_vector_position + temp_length <= RTC_DCHECK_LE(expansion_vector_position + temp_length,
parameters.expand_vector0.Size()); parameters.expand_vector0.Size());
assert(expansion_vector_position + temp_length <= RTC_DCHECK_LE(expansion_vector_position + temp_length,
parameters.expand_vector1.Size()); parameters.expand_vector1.Size());
std::unique_ptr<int16_t[]> temp_0(new int16_t[temp_length]); std::unique_ptr<int16_t[]> temp_0(new int16_t[temp_length]);
parameters.expand_vector0.CopyTo(temp_length, expansion_vector_position, parameters.expand_vector0.CopyTo(temp_length, expansion_vector_position,
@ -303,7 +304,7 @@ int Expand::Process(AudioMultiVector* output) {
if (channel_ix == 0) { if (channel_ix == 0) {
output->AssertSize(current_lag); output->AssertSize(current_lag);
} else { } else {
assert(output->Size() == current_lag); RTC_DCHECK_EQ(output->Size(), current_lag);
} }
(*output)[channel_ix].OverwriteAt(temp_data, current_lag, 0); (*output)[channel_ix].OverwriteAt(temp_data, current_lag, 0);
} }
@ -465,7 +466,7 @@ void Expand::AnalyzeSignal(int16_t* random_vector) {
size_t start_index = std::min(distortion_lag, correlation_lag); size_t start_index = std::min(distortion_lag, correlation_lag);
size_t correlation_lags = static_cast<size_t>( size_t correlation_lags = static_cast<size_t>(
WEBRTC_SPL_ABS_W16((distortion_lag - correlation_lag)) + 1); 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) { for (size_t channel_ix = 0; channel_ix < num_channels_; ++channel_ix) {
ChannelParameters& parameters = channel_parameters_[channel_ix]; ChannelParameters& parameters = channel_parameters_[channel_ix];
@ -659,7 +660,7 @@ void Expand::AnalyzeSignal(int16_t* random_vector) {
// |kRandomTableSize|. // |kRandomTableSize|.
memcpy(random_vector, RandomVector::kRandomTable, memcpy(random_vector, RandomVector::kRandomTable,
sizeof(int16_t) * RandomVector::kRandomTableSize); 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_->IncreaseSeedIncrement(2);
random_vector_->Generate( random_vector_->Generate(
noise_length - RandomVector::kRandomTableSize, noise_length - RandomVector::kRandomTableSize,

View File

@ -59,7 +59,7 @@ class Expand {
// Returns the mute factor for |channel|. // Returns the mute factor for |channel|.
int16_t MuteFactor(size_t channel) const { int16_t MuteFactor(size_t channel) const {
assert(channel < num_channels_); RTC_DCHECK_LT(channel, num_channels_);
return channel_parameters_[channel].mute_factor; return channel_parameters_[channel].mute_factor;
} }

View File

@ -38,7 +38,7 @@ Merge::Merge(int fs_hz,
expand_(expand), expand_(expand),
sync_buffer_(sync_buffer), sync_buffer_(sync_buffer),
expanded_(num_channels_) { expanded_(num_channels_) {
assert(num_channels_ > 0); RTC_DCHECK_GT(num_channels_, 0);
} }
Merge::~Merge() = default; Merge::~Merge() = default;
@ -47,9 +47,9 @@ size_t Merge::Process(int16_t* input,
size_t input_length, size_t input_length,
AudioMultiVector* output) { AudioMultiVector* output) {
// TODO(hlundin): Change to an enumerator and skip assert. // TODO(hlundin): Change to an enumerator and skip assert.
assert(fs_hz_ == 8000 || fs_hz_ == 16000 || fs_hz_ == 32000 || RTC_DCHECK(fs_hz_ == 8000 || fs_hz_ == 16000 || fs_hz_ == 32000 ||
fs_hz_ == 48000); fs_hz_ == 48000);
assert(fs_hz_ <= kMaxSampleRate); // Should not be possible. RTC_DCHECK_LE(fs_hz_, kMaxSampleRate); // Should not be possible.
if (input_length == 0) { if (input_length == 0) {
return 0; return 0;
} }
@ -64,7 +64,7 @@ size_t Merge::Process(int16_t* input,
input_vector.PushBackInterleaved( input_vector.PushBackInterleaved(
rtc::ArrayView<const int16_t>(input, input_length)); rtc::ArrayView<const int16_t>(input, input_length));
size_t input_length_per_channel = input_vector.Size(); 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 best_correlation_index = 0;
size_t output_length = 0; size_t output_length = 0;
@ -142,10 +142,10 @@ size_t Merge::Process(int16_t* input,
output_length = best_correlation_index + input_length_per_channel; output_length = best_correlation_index + input_length_per_channel;
if (channel == 0) { 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); output->AssertSize(output_length);
} else { } else {
assert(output->Size() == output_length); RTC_DCHECK_EQ(output->Size(), output_length);
} }
(*output)[channel].OverwriteAt(temp_data_.data(), output_length, 0); (*output)[channel].OverwriteAt(temp_data_.data(), output_length, 0);
} }
@ -165,7 +165,7 @@ size_t Merge::GetExpandedSignal(size_t* old_length, size_t* expand_period) {
// Check how much data that is left since earlier. // Check how much data that is left since earlier.
*old_length = sync_buffer_->FutureLength(); *old_length = sync_buffer_->FutureLength();
// Should never be less than overlap_length. // 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. // Generate data to merge the overlap with using expand.
expand_->SetParametersForMergeAfterExpand(); expand_->SetParametersForMergeAfterExpand();
@ -182,7 +182,7 @@ size_t Merge::GetExpandedSignal(size_t* old_length, size_t* expand_period) {
// This is the truncated length. // This is the truncated length.
} }
// This assert should always be true thanks to the if statement above. // 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_); AudioMultiVector expanded_temp(num_channels_);
expand_->Process(&expanded_temp); expand_->Process(&expanded_temp);
@ -191,8 +191,8 @@ size_t Merge::GetExpandedSignal(size_t* old_length, size_t* expand_period) {
expanded_.Clear(); expanded_.Clear();
// Copy what is left since earlier into the expanded vector. // Copy what is left since earlier into the expanded vector.
expanded_.PushBackFromIndex(*sync_buffer_, sync_buffer_->next_index()); expanded_.PushBackFromIndex(*sync_buffer_, sync_buffer_->next_index());
assert(expanded_.Size() == *old_length); RTC_DCHECK_EQ(expanded_.Size(), *old_length);
assert(expanded_temp.Size() > 0); RTC_DCHECK_GT(expanded_temp.Size(), 0);
// Do "ugly" copy and paste from the expanded in order to generate more data // Do "ugly" copy and paste from the expanded in order to generate more data
// to correlate (but not interpolate) with. // to correlate (but not interpolate) with.
const size_t required_length = static_cast<size_t>((120 + 80 + 2) * fs_mult_); const size_t required_length = static_cast<size_t>((120 + 80 + 2) * fs_mult_);
@ -204,7 +204,7 @@ size_t Merge::GetExpandedSignal(size_t* old_length, size_t* expand_period) {
// Trim the length to exactly |required_length|. // Trim the length to exactly |required_length|.
expanded_.PopBack(expanded_.Size() - required_length); expanded_.PopBack(expanded_.Size() - required_length);
} }
assert(expanded_.Size() >= required_length); RTC_DCHECK_GE(expanded_.Size(), required_length);
return required_length; return required_length;
} }
@ -373,7 +373,7 @@ size_t Merge::CorrelateAndPeakSearch(size_t start_position,
while (((best_correlation_index + input_length) < while (((best_correlation_index + input_length) <
(timestamps_per_call_ + expand_->overlap_length())) || (timestamps_per_call_ + expand_->overlap_length())) ||
((best_correlation_index + input_length) < start_position)) { ((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. best_correlation_index += expand_period; // Jump one lag ahead.
} }
return best_correlation_index; return best_correlation_index;

View File

@ -44,7 +44,7 @@ NackTracker* NackTracker::Create(int nack_threshold_packets) {
} }
void NackTracker::UpdateSampleRate(int sample_rate_hz) { 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; sample_rate_khz_ = sample_rate_hz / 1000;
} }
@ -120,9 +120,9 @@ uint32_t NackTracker::EstimateTimestamp(uint16_t sequence_num) {
} }
void NackTracker::AddToList(uint16_t sequence_number_current_received_rtp) { void NackTracker::AddToList(uint16_t sequence_number_current_received_rtp) {
assert(!any_rtp_decoded_ || RTC_DCHECK(!any_rtp_decoded_ ||
IsNewerSequenceNumber(sequence_number_current_received_rtp, IsNewerSequenceNumber(sequence_number_current_received_rtp,
sequence_num_last_decoded_rtp_)); sequence_num_last_decoded_rtp_));
// Packets with sequence numbers older than |upper_bound_missing| are // Packets with sequence numbers older than |upper_bound_missing| are
// considered missing, and the rest are considered late. // considered missing, and the rest are considered late.
@ -164,7 +164,7 @@ void NackTracker::UpdateLastDecodedPacket(uint16_t sequence_number,
++it) ++it)
it->second.time_to_play_ms = TimeToPlay(it->second.estimated_timestamp); it->second.time_to_play_ms = TimeToPlay(it->second.estimated_timestamp);
} else { } 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 // Same sequence number as before. 10 ms is elapsed, update estimations for
// time-to-play. // time-to-play.

View File

@ -343,7 +343,7 @@ void NetEqImpl::RemoveAllPayloadTypes() {
bool NetEqImpl::SetMinimumDelay(int delay_ms) { bool NetEqImpl::SetMinimumDelay(int delay_ms) {
MutexLock lock(&mutex_); MutexLock lock(&mutex_);
if (delay_ms >= 0 && delay_ms <= 10000) { if (delay_ms >= 0 && delay_ms <= 10000) {
assert(controller_.get()); RTC_DCHECK(controller_.get());
return controller_->SetMinimumDelay( return controller_->SetMinimumDelay(
std::max(delay_ms - output_delay_chain_ms_, 0)); std::max(delay_ms - output_delay_chain_ms_, 0));
} }
@ -353,7 +353,7 @@ bool NetEqImpl::SetMinimumDelay(int delay_ms) {
bool NetEqImpl::SetMaximumDelay(int delay_ms) { bool NetEqImpl::SetMaximumDelay(int delay_ms) {
MutexLock lock(&mutex_); MutexLock lock(&mutex_);
if (delay_ms >= 0 && delay_ms <= 10000) { if (delay_ms >= 0 && delay_ms <= 10000) {
assert(controller_.get()); RTC_DCHECK(controller_.get());
return controller_->SetMaximumDelay( return controller_->SetMaximumDelay(
std::max(delay_ms - output_delay_chain_ms_, 0)); std::max(delay_ms - output_delay_chain_ms_, 0));
} }
@ -392,7 +392,7 @@ int NetEqImpl::FilteredCurrentDelayMs() const {
int NetEqImpl::NetworkStatistics(NetEqNetworkStatistics* stats) { int NetEqImpl::NetworkStatistics(NetEqNetworkStatistics* stats) {
MutexLock lock(&mutex_); MutexLock lock(&mutex_);
assert(decoder_database_.get()); RTC_DCHECK(decoder_database_.get());
*stats = CurrentNetworkStatisticsInternal(); *stats = CurrentNetworkStatisticsInternal();
stats_->GetNetworkStatistics(decoder_frame_length_, stats); stats_->GetNetworkStatistics(decoder_frame_length_, stats);
// Compensate for output delay chain. // Compensate for output delay chain.
@ -409,13 +409,13 @@ NetEqNetworkStatistics NetEqImpl::CurrentNetworkStatistics() const {
} }
NetEqNetworkStatistics NetEqImpl::CurrentNetworkStatisticsInternal() const { NetEqNetworkStatistics NetEqImpl::CurrentNetworkStatisticsInternal() const {
assert(decoder_database_.get()); RTC_DCHECK(decoder_database_.get());
NetEqNetworkStatistics stats; NetEqNetworkStatistics stats;
const size_t total_samples_in_buffers = const size_t total_samples_in_buffers =
packet_buffer_->NumSamplesInBuffer(decoder_frame_length_) + packet_buffer_->NumSamplesInBuffer(decoder_frame_length_) +
sync_buffer_->FutureLength(); sync_buffer_->FutureLength();
assert(controller_.get()); RTC_DCHECK(controller_.get());
stats.preferred_buffer_size_ms = controller_->TargetLevelMs(); stats.preferred_buffer_size_ms = controller_->TargetLevelMs();
stats.jitter_peaks_found = controller_->PeakFound(); stats.jitter_peaks_found = controller_->PeakFound();
RTC_DCHECK_GT(fs_hz_, 0); RTC_DCHECK_GT(fs_hz_, 0);
@ -449,13 +449,13 @@ NetEqOperationsAndState NetEqImpl::GetOperationsAndState() const {
void NetEqImpl::EnableVad() { void NetEqImpl::EnableVad() {
MutexLock lock(&mutex_); MutexLock lock(&mutex_);
assert(vad_.get()); RTC_DCHECK(vad_.get());
vad_->Enable(); vad_->Enable();
} }
void NetEqImpl::DisableVad() { void NetEqImpl::DisableVad() {
MutexLock lock(&mutex_); MutexLock lock(&mutex_);
assert(vad_.get()); RTC_DCHECK(vad_.get());
vad_->Disable(); vad_->Disable();
} }
@ -506,8 +506,8 @@ void NetEqImpl::FlushBuffers() {
MutexLock lock(&mutex_); MutexLock lock(&mutex_);
RTC_LOG(LS_VERBOSE) << "FlushBuffers"; RTC_LOG(LS_VERBOSE) << "FlushBuffers";
packet_buffer_->Flush(stats_.get()); packet_buffer_->Flush(stats_.get());
assert(sync_buffer_.get()); RTC_DCHECK(sync_buffer_.get());
assert(expand_.get()); RTC_DCHECK(expand_.get());
sync_buffer_->Flush(); sync_buffer_->Flush();
sync_buffer_->set_next_index(sync_buffer_->next_index() - sync_buffer_->set_next_index(sync_buffer_->next_index() -
expand_->overlap_length()); expand_->overlap_length());
@ -797,12 +797,12 @@ int NetEqImpl::InsertPacketInternal(const RTPHeader& rtp_header,
size_t channels = 1; size_t channels = 1;
if (!decoder_database_->IsComfortNoise(payload_type)) { if (!decoder_database_->IsComfortNoise(payload_type)) {
AudioDecoder* decoder = decoder_database_->GetDecoder(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(); channels = decoder->Channels();
} }
const DecoderDatabase::DecoderInfo* decoder_info = const DecoderDatabase::DecoderInfo* decoder_info =
decoder_database_->GetDecoderInfo(payload_type); decoder_database_->GetDecoderInfo(payload_type);
assert(decoder_info); RTC_DCHECK(decoder_info);
if (decoder_info->SampleRateHz() != fs_hz_ || if (decoder_info->SampleRateHz() != fs_hz_ ||
channels != algorithm_buffer_->Channels()) { channels != algorithm_buffer_->Channels()) {
SetSampleRateAndChannels(decoder_info->SampleRateHz(), channels); SetSampleRateAndChannels(decoder_info->SampleRateHz(), channels);
@ -816,7 +816,7 @@ int NetEqImpl::InsertPacketInternal(const RTPHeader& rtp_header,
const DecoderDatabase::DecoderInfo* dec_info = const DecoderDatabase::DecoderInfo* dec_info =
decoder_database_->GetDecoderInfo(main_payload_type); 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; NetEqController::PacketArrivedInfo info;
info.is_cng_or_dtmf = dec_info->IsComfortNoise() || dec_info->IsDtmf(); info.is_cng_or_dtmf = dec_info->IsComfortNoise() || dec_info->IsDtmf();
@ -894,7 +894,7 @@ int NetEqImpl::GetAudioInternal(AudioFrame* audio_frame,
int decode_return_value = int decode_return_value =
Decode(&packet_list, &operation, &length, &speech_type); Decode(&packet_list, &operation, &length, &speech_type);
assert(vad_.get()); RTC_DCHECK(vad_.get());
bool sid_frame_available = bool sid_frame_available =
(operation == Operation::kRfc3389Cng && !packet_list.empty()); (operation == Operation::kRfc3389Cng && !packet_list.empty());
vad_->Update(decoded_buffer_.get(), static_cast<size_t>(length), speech_type, vad_->Update(decoded_buffer_.get(), static_cast<size_t>(length), speech_type,
@ -965,7 +965,7 @@ int NetEqImpl::GetAudioInternal(AudioFrame* audio_frame,
} }
case Operation::kUndefined: { case Operation::kUndefined: {
RTC_LOG(LS_ERROR) << "Invalid 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; last_mode_ = Mode::kError;
return kInvalidOperation; return kInvalidOperation;
} }
@ -1101,7 +1101,7 @@ int NetEqImpl::GetDecision(Operation* operation,
*play_dtmf = false; *play_dtmf = false;
*operation = Operation::kUndefined; *operation = Operation::kUndefined;
assert(sync_buffer_.get()); RTC_DCHECK(sync_buffer_.get());
uint32_t end_timestamp = sync_buffer_->end_timestamp(); uint32_t end_timestamp = sync_buffer_->end_timestamp();
if (!new_codec_) { if (!new_codec_) {
const uint32_t five_seconds_samples = 5 * fs_hz_; const uint32_t five_seconds_samples = 5 * fs_hz_;
@ -1128,7 +1128,7 @@ int NetEqImpl::GetDecision(Operation* operation,
// Don't use this packet, discard it. // Don't use this packet, discard it.
if (packet_buffer_->DiscardNextPacket(stats_.get()) != if (packet_buffer_->DiscardNextPacket(stats_.get()) !=
PacketBuffer::kOK) { PacketBuffer::kOK) {
assert(false); // Must be ok by design. RTC_NOTREACHED(); // Must be ok by design.
} }
// Check buffer again. // Check buffer again.
if (!new_codec_) { if (!new_codec_) {
@ -1139,7 +1139,7 @@ int NetEqImpl::GetDecision(Operation* operation,
} }
} }
assert(expand_.get()); RTC_DCHECK(expand_.get());
const int samples_left = static_cast<int>(sync_buffer_->FutureLength() - const int samples_left = static_cast<int>(sync_buffer_->FutureLength() -
expand_->overlap_length()); expand_->overlap_length());
if (last_mode_ == Mode::kAccelerateSuccess || if (last_mode_ == Mode::kAccelerateSuccess ||
@ -1159,8 +1159,8 @@ int NetEqImpl::GetDecision(Operation* operation,
} }
// Get instruction. // Get instruction.
assert(sync_buffer_.get()); RTC_DCHECK(sync_buffer_.get());
assert(expand_.get()); RTC_DCHECK(expand_.get());
generated_noise_samples = generated_noise_samples =
generated_noise_stopwatch_ generated_noise_stopwatch_
? generated_noise_stopwatch_->ElapsedTicks() * output_size_samples_ + ? generated_noise_stopwatch_->ElapsedTicks() * output_size_samples_ +
@ -1228,7 +1228,7 @@ int NetEqImpl::GetDecision(Operation* operation,
// Check conditions for reset. // Check conditions for reset.
if (new_codec_ || *operation == Operation::kUndefined) { if (new_codec_ || *operation == Operation::kUndefined) {
// The only valid reason to get kUndefined is that new_codec_ is set. // The only valid reason to get kUndefined is that new_codec_ is set.
assert(new_codec_); RTC_DCHECK(new_codec_);
if (*play_dtmf && !packet) { if (*play_dtmf && !packet) {
timestamp_ = dtmf_event->timestamp; timestamp_ = dtmf_event->timestamp;
} else { } else {
@ -1400,7 +1400,7 @@ int NetEqImpl::Decode(PacketList* packet_list,
uint8_t payload_type = packet.payload_type; uint8_t payload_type = packet.payload_type;
if (!decoder_database_->IsComfortNoise(payload_type)) { if (!decoder_database_->IsComfortNoise(payload_type)) {
decoder = decoder_database_->GetDecoder(payload_type); decoder = decoder_database_->GetDecoder(payload_type);
assert(decoder); RTC_DCHECK(decoder);
if (!decoder) { if (!decoder) {
RTC_LOG(LS_WARNING) RTC_LOG(LS_WARNING)
<< "Unknown payload type " << static_cast<int>(payload_type); << "Unknown payload type " << static_cast<int>(payload_type);
@ -1413,7 +1413,7 @@ int NetEqImpl::Decode(PacketList* packet_list,
// We have a new decoder. Re-init some values. // We have a new decoder. Re-init some values.
const DecoderDatabase::DecoderInfo* decoder_info = const DecoderDatabase::DecoderInfo* decoder_info =
decoder_database_->GetDecoderInfo(payload_type); decoder_database_->GetDecoderInfo(payload_type);
assert(decoder_info); RTC_DCHECK(decoder_info);
if (!decoder_info) { if (!decoder_info) {
RTC_LOG(LS_WARNING) RTC_LOG(LS_WARNING)
<< "Unknown payload type " << static_cast<int>(payload_type); << "Unknown payload type " << static_cast<int>(payload_type);
@ -1485,8 +1485,8 @@ int NetEqImpl::Decode(PacketList* packet_list,
// Don't increment timestamp if codec returned CNG speech type // Don't increment timestamp if codec returned CNG speech type
// since in this case, the we will increment the CNGplayedTS counter. // since in this case, the we will increment the CNGplayedTS counter.
// Increase with number of samples per channel. // Increase with number of samples per channel.
assert(*decoded_length == 0 || RTC_DCHECK(*decoded_length == 0 ||
(decoder && decoder->Channels() == sync_buffer_->Channels())); (decoder && decoder->Channels() == sync_buffer_->Channels()));
sync_buffer_->IncreaseEndTimestamp( sync_buffer_->IncreaseEndTimestamp(
*decoded_length / static_cast<int>(sync_buffer_->Channels())); *decoded_length / static_cast<int>(sync_buffer_->Channels()));
} }
@ -1535,16 +1535,16 @@ int NetEqImpl::DecodeLoop(PacketList* packet_list,
// Do decoding. // Do decoding.
while (!packet_list->empty() && !decoder_database_->IsComfortNoise( while (!packet_list->empty() && !decoder_database_->IsComfortNoise(
packet_list->front().payload_type)) { 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 // The number of channels in the |sync_buffer_| should be the same as the
// number decoder channels. // number decoder channels.
assert(sync_buffer_->Channels() == decoder->Channels()); RTC_DCHECK_EQ(sync_buffer_->Channels(), decoder->Channels());
assert(decoded_buffer_length_ >= kMaxFrameSize * decoder->Channels()); RTC_DCHECK_GE(decoded_buffer_length_, kMaxFrameSize * decoder->Channels());
assert(operation == Operation::kNormal || RTC_DCHECK(operation == Operation::kNormal ||
operation == Operation::kAccelerate || operation == Operation::kAccelerate ||
operation == Operation::kFastAccelerate || operation == Operation::kFastAccelerate ||
operation == Operation::kMerge || operation == Operation::kMerge ||
operation == Operation::kPreemptiveExpand); operation == Operation::kPreemptiveExpand);
auto opt_result = packet_list->front().frame->Decode( auto opt_result = packet_list->front().frame->Decode(
rtc::ArrayView<int16_t>(&decoded_buffer_[*decoded_length], rtc::ArrayView<int16_t>(&decoded_buffer_[*decoded_length],
@ -1581,9 +1581,10 @@ int NetEqImpl::DecodeLoop(PacketList* packet_list,
// If the list is not empty at this point, either a decoding error terminated // 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. // the while-loop, or list must hold exactly one CNG packet.
assert(packet_list->empty() || *decoded_length < 0 || RTC_DCHECK(
(packet_list->size() == 1 && decoder_database_->IsComfortNoise( packet_list->empty() || *decoded_length < 0 ||
packet_list->front().payload_type))); (packet_list->size() == 1 &&
decoder_database_->IsComfortNoise(packet_list->front().payload_type)));
return 0; return 0;
} }
@ -1591,7 +1592,7 @@ void NetEqImpl::DoNormal(const int16_t* decoded_buffer,
size_t decoded_length, size_t decoded_length,
AudioDecoder::SpeechType speech_type, AudioDecoder::SpeechType speech_type,
bool play_dtmf) { bool play_dtmf) {
assert(normal_.get()); RTC_DCHECK(normal_.get());
normal_->Process(decoded_buffer, decoded_length, last_mode_, normal_->Process(decoded_buffer, decoded_length, last_mode_,
algorithm_buffer_.get()); algorithm_buffer_.get());
if (decoded_length != 0) { if (decoded_length != 0) {
@ -1614,7 +1615,7 @@ void NetEqImpl::DoMerge(int16_t* decoded_buffer,
size_t decoded_length, size_t decoded_length,
AudioDecoder::SpeechType speech_type, AudioDecoder::SpeechType speech_type,
bool play_dtmf) { bool play_dtmf) {
assert(merge_.get()); RTC_DCHECK(merge_.get());
size_t new_length = size_t new_length =
merge_->Process(decoded_buffer, decoded_length, algorithm_buffer_.get()); merge_->Process(decoded_buffer, decoded_length, algorithm_buffer_.get());
// Correction can be negative. // Correction can be negative.
@ -1775,7 +1776,7 @@ int NetEqImpl::DoAccelerate(int16_t* decoded_buffer,
sync_buffer_->Size() - borrowed_samples_per_channel); sync_buffer_->Size() - borrowed_samples_per_channel);
sync_buffer_->PushFrontZeros(borrowed_samples_per_channel - length); sync_buffer_->PushFrontZeros(borrowed_samples_per_channel - length);
algorithm_buffer_->PopFront(length); algorithm_buffer_->PopFront(length);
assert(algorithm_buffer_->Empty()); RTC_DCHECK(algorithm_buffer_->Empty());
} else { } else {
sync_buffer_->ReplaceAtIndex( sync_buffer_->ReplaceAtIndex(
*algorithm_buffer_, borrowed_samples_per_channel, *algorithm_buffer_, borrowed_samples_per_channel,
@ -1864,7 +1865,7 @@ int NetEqImpl::DoPreemptiveExpand(int16_t* decoded_buffer,
int NetEqImpl::DoRfc3389Cng(PacketList* packet_list, bool play_dtmf) { int NetEqImpl::DoRfc3389Cng(PacketList* packet_list, bool play_dtmf) {
if (!packet_list->empty()) { if (!packet_list->empty()) {
// Must have exactly one SID frame at this point. // 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(); const Packet& packet = packet_list->front();
if (!decoder_database_->IsComfortNoise(packet.payload_type)) { if (!decoder_database_->IsComfortNoise(packet.payload_type)) {
RTC_LOG(LS_ERROR) << "Trying to decode non-CNG payload as CNG."; RTC_LOG(LS_ERROR) << "Trying to decode non-CNG payload as CNG.";
@ -1947,14 +1948,14 @@ int NetEqImpl::DoDtmf(const DtmfEvent& dtmf_event, bool* play_dtmf) {
// // it must be copied to the speech buffer. // // it must be copied to the speech buffer.
// // TODO(hlundin): This code seems incorrect. (Legacy.) Write test and // // TODO(hlundin): This code seems incorrect. (Legacy.) Write test and
// // verify correct operation. // // verify correct operation.
// assert(false); // RTC_NOTREACHED();
// // Must generate enough data to replace all of the |sync_buffer_| // // Must generate enough data to replace all of the |sync_buffer_|
// // "future". // // "future".
// int required_length = sync_buffer_->FutureLength(); // 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, // dtmf_return_value = dtmf_tone_generator_->Generate(required_length,
// algorithm_buffer_); // algorithm_buffer_);
// assert((size_t) required_length == algorithm_buffer_->Size()); // RTC_DCHECK((size_t) required_length == algorithm_buffer_->Size());
// if (dtmf_return_value < 0) { // if (dtmf_return_value < 0) {
// algorithm_buffer_->Zeros(output_size_samples_); // algorithm_buffer_->Zeros(output_size_samples_);
// return dtmf_return_value; // return dtmf_return_value;
@ -1964,7 +1965,7 @@ int NetEqImpl::DoDtmf(const DtmfEvent& dtmf_event, bool* play_dtmf) {
// // data. // // data.
// // TODO(hlundin): It seems that this overwriting has gone lost. // // TODO(hlundin): It seems that this overwriting has gone lost.
// // Not adapted for multi-channel yet. // // Not adapted for multi-channel yet.
// assert(algorithm_buffer_->Channels() == 1); // RTC_DCHECK(algorithm_buffer_->Channels() == 1);
// if (algorithm_buffer_->Channels() != 1) { // if (algorithm_buffer_->Channels() != 1) {
// RTC_LOG(LS_WARNING) << "DTMF not supported for more than one channel"; // RTC_LOG(LS_WARNING) << "DTMF not supported for more than one channel";
// return kStereoNotSupported; // return kStereoNotSupported;
@ -2006,7 +2007,7 @@ int NetEqImpl::DtmfOverdub(const DtmfEvent& dtmf_event,
if (dtmf_return_value == 0) { if (dtmf_return_value == 0) {
dtmf_return_value = dtmf_return_value =
dtmf_tone_generator_->Generate(overdub_length, &dtmf_output); 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]); dtmf_output.ReadInterleaved(overdub_length, &output[out_index]);
return dtmf_return_value < 0 ? dtmf_return_value : 0; return dtmf_return_value < 0 ? dtmf_return_value : 0;
@ -2037,7 +2038,7 @@ int NetEqImpl::ExtractPackets(size_t required_samples,
next_packet = nullptr; next_packet = nullptr;
if (!packet) { if (!packet) {
RTC_LOG(LS_ERROR) << "Should always be able to extract a packet here"; 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; return -1;
} }
const uint64_t waiting_time_ms = packet->waiting_time->ElapsedMs(); const uint64_t waiting_time_ms = packet->waiting_time->ElapsedMs();
@ -2130,8 +2131,9 @@ void NetEqImpl::SetSampleRateAndChannels(int fs_hz, size_t channels) {
RTC_LOG(LS_VERBOSE) << "SetSampleRateAndChannels " << fs_hz << " " RTC_LOG(LS_VERBOSE) << "SetSampleRateAndChannels " << fs_hz << " "
<< channels; << channels;
// TODO(hlundin): Change to an enumerator and skip assert. // 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 ||
assert(channels > 0); fs_hz == 48000);
RTC_DCHECK_GT(channels, 0);
// Before changing the sample rate, end and report any ongoing expand event. // Before changing the sample rate, end and report any ongoing expand event.
stats_->EndExpandEvent(fs_hz_); stats_->EndExpandEvent(fs_hz_);
@ -2147,7 +2149,7 @@ void NetEqImpl::SetSampleRateAndChannels(int fs_hz, size_t channels) {
cng_decoder->Reset(); cng_decoder->Reset();
// Reinit post-decode VAD with new sample rate. // 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(); vad_->Init();
// Delete algorithm buffer and create a new one. // Delete algorithm buffer and create a new one.
@ -2190,8 +2192,8 @@ void NetEqImpl::SetSampleRateAndChannels(int fs_hz, size_t channels) {
} }
NetEqImpl::OutputType NetEqImpl::LastOutputType() { NetEqImpl::OutputType NetEqImpl::LastOutputType() {
assert(vad_.get()); RTC_DCHECK(vad_.get());
assert(expand_.get()); RTC_DCHECK(expand_.get());
if (last_mode_ == Mode::kCodecInternalCng || if (last_mode_ == Mode::kCodecInternalCng ||
last_mode_ == Mode::kRfc3389Cng) { last_mode_ == Mode::kRfc3389Cng) {
return OutputType::kCNG; return OutputType::kCNG;

View File

@ -41,7 +41,7 @@ bool RedPayloadSplitter::SplitRed(PacketList* packet_list) {
PacketList::iterator it = packet_list->begin(); PacketList::iterator it = packet_list->begin();
while (it != packet_list->end()) { while (it != packet_list->end()) {
const Packet& red_packet = *it; 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(); const uint8_t* payload_ptr = red_packet.payload.data();
size_t payload_length = red_packet.payload.size(); size_t payload_length = red_packet.payload.size();

View File

@ -103,7 +103,7 @@ Packet CreateRedPayload(size_t num_payloads,
rtc::checked_cast<int>((num_payloads - i - 1) * timestamp_offset); rtc::checked_cast<int>((num_payloads - i - 1) * timestamp_offset);
*payload_ptr = this_offset >> 6; *payload_ptr = this_offset >> 6;
++payload_ptr; ++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 = ((this_offset & 0x3F) << 2) | (kPayloadLength >> 8);
++payload_ptr; ++payload_ptr;
*payload_ptr = kPayloadLength & 0xFF; *payload_ptr = kPayloadLength & 0xFF;

View File

@ -375,7 +375,7 @@ uint16_t StatisticsCalculator::CalculateQ14Ratio(size_t numerator,
return 0; return 0;
} else if (numerator < denominator) { } else if (numerator < denominator) {
// Ratio must be smaller than 1 in Q14. // 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); return static_cast<uint16_t>((numerator << 14) / denominator);
} else { } else {
// Will not produce a ratio larger than 1, since this is probably an error. // Will not produce a ratio larger than 1, since this is probably an error.

View File

@ -28,7 +28,7 @@ void SyncBuffer::PushBack(const AudioMultiVector& append_this) {
next_index_ -= samples_added; next_index_ -= samples_added;
} else { } else {
// This means that we are pushing out future data that was never used. // 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. // 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 // This should not happen even for 60 ms frames, but it does. Investigate
// why. // why.

View File

@ -66,7 +66,7 @@ TimeStretch::ReturnCodes TimeStretch::Process(const int16_t* input,
DspHelper::PeakDetection(auto_correlation_, kCorrelationLen, kNumPeaks, DspHelper::PeakDetection(auto_correlation_, kCorrelationLen, kNumPeaks,
fs_mult_, &peak_index, &peak_value); fs_mult_, &peak_index, &peak_value);
// Assert that |peak_index| stays within boundaries. // 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 // Compensate peak_index for displaced starting position. The displacement
// happens in AutoCorrelation(). Here, |kMinLag| is in the down-sampled 4 kHz // happens in AutoCorrelation(). Here, |kMinLag| is in the down-sampled 4 kHz
@ -74,8 +74,9 @@ TimeStretch::ReturnCodes TimeStretch::Process(const int16_t* input,
// multiplication by fs_mult_ * 2. // multiplication by fs_mult_ * 2.
peak_index += kMinLag * fs_mult_ * 2; peak_index += kMinLag * fs_mult_ * 2;
// Assert that |peak_index| stays within boundaries. // Assert that |peak_index| stays within boundaries.
assert(peak_index >= static_cast<size_t>(20 * fs_mult_)); RTC_DCHECK_GE(peak_index, static_cast<size_t>(20 * fs_mult_));
assert(peak_index <= 20 * fs_mult_ + (2 * kCorrelationLen - 1) * 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 // Calculate scaling to ensure that |peak_index| samples can be square-summed
// without overflowing. // without overflowing.

View File

@ -42,9 +42,9 @@ class TimeStretch {
num_channels_(num_channels), num_channels_(num_channels),
background_noise_(background_noise), background_noise_(background_noise),
max_input_value_(0) { max_input_value_(0) {
assert(sample_rate_hz_ == 8000 || sample_rate_hz_ == 16000 || RTC_DCHECK(sample_rate_hz_ == 8000 || sample_rate_hz_ == 16000 ||
sample_rate_hz_ == 32000 || sample_rate_hz_ == 48000); sample_rate_hz_ == 32000 || sample_rate_hz_ == 48000);
assert(num_channels_ > 0); RTC_DCHECK_GT(num_channels_, 0);
memset(auto_correlation_, 0, sizeof(auto_correlation_)); memset(auto_correlation_, 0, sizeof(auto_correlation_));
} }

View File

@ -36,7 +36,7 @@ class OutputAudioFile : public AudioSink {
} }
bool WriteArray(const int16_t* audio, size_t num_samples) override { 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; return fwrite(audio, sizeof(*audio), num_samples, out_file_) == num_samples;
} }

View File

@ -56,7 +56,7 @@ int main(int argc, char* argv[]) {
printf("Input file: %s\n", args[1]); printf("Input file: %s\n", args[1]);
std::unique_ptr<webrtc::test::RtpFileSource> file_source( std::unique_ptr<webrtc::test::RtpFileSource> file_source(
webrtc::test::RtpFileSource::Create(args[1])); webrtc::test::RtpFileSource::Create(args[1]));
assert(file_source.get()); RTC_DCHECK(file_source.get());
// Set RTP extension IDs. // Set RTP extension IDs.
bool print_audio_level = false; bool print_audio_level = false;
if (absl::GetFlag(FLAGS_audio_level) != -1) { if (absl::GetFlag(FLAGS_audio_level) != -1) {
@ -151,7 +151,7 @@ int main(int argc, char* argv[]) {
packet->ExtractRedHeaders(&red_headers); packet->ExtractRedHeaders(&red_headers);
while (!red_headers.empty()) { while (!red_headers.empty()) {
webrtc::RTPHeader* red = red_headers.front(); webrtc::RTPHeader* red = red_headers.front();
assert(red); RTC_DCHECK(red);
fprintf(out_file, "* %5u %10u %10u %5i\n", red->sequenceNumber, fprintf(out_file, "* %5u %10u %10u %5i\n", red->sequenceNumber,
red->timestamp, static_cast<unsigned int>(packet->time_ms()), red->timestamp, static_cast<unsigned int>(packet->time_ms()),
red->payloadType); red->payloadType);

View File

@ -18,7 +18,7 @@ namespace test {
uint32_t RtpGenerator::GetRtpHeader(uint8_t payload_type, uint32_t RtpGenerator::GetRtpHeader(uint8_t payload_type,
size_t payload_length_samples, size_t payload_length_samples,
RTPHeader* rtp_header) { RTPHeader* rtp_header) {
assert(rtp_header); RTC_DCHECK(rtp_header);
if (!rtp_header) { if (!rtp_header) {
return 0; return 0;
} }
@ -31,7 +31,7 @@ uint32_t RtpGenerator::GetRtpHeader(uint8_t payload_type,
rtp_header->numCSRCs = 0; rtp_header->numCSRCs = 0;
uint32_t this_send_time = next_send_time_ms_; 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_ += next_send_time_ms_ +=
((1.0 + drift_factor_) * payload_length_samples) / samples_per_ms_; ((1.0 + drift_factor_) * payload_length_samples) / samples_per_ms_;
return this_send_time; return this_send_time;

View File

@ -125,7 +125,7 @@ void Channel::CalcStatistics(const RTPHeader& rtp_header, size_t payloadSize) {
(uint32_t)((uint32_t)rtp_header.timestamp - (uint32_t)((uint32_t)rtp_header.timestamp -
(uint32_t)currentPayloadStr->lastTimestamp); (uint32_t)currentPayloadStr->lastTimestamp);
} }
assert(_lastFrameSizeSample > 0); RTC_DCHECK_GT(_lastFrameSizeSample, 0);
int k = 0; int k = 0;
for (; k < MAX_NUM_FRAMESIZES; ++k) { for (; k < MAX_NUM_FRAMESIZES; ++k) {
if ((currentPayloadStr->frameSizeStats[k].frameSizeSample == if ((currentPayloadStr->frameSizeStats[k].frameSizeSample ==

View File

@ -1490,7 +1490,7 @@ bool AudioDeviceLinuxALSA::PlayThreadProcess() {
Lock(); Lock();
_playoutFramesLeft = _ptrAudioBuffer->GetPlayoutData(_playoutBuffer); _playoutFramesLeft = _ptrAudioBuffer->GetPlayoutData(_playoutBuffer);
assert(_playoutFramesLeft == _playoutFramesIn10MS); RTC_DCHECK_EQ(_playoutFramesLeft, _playoutFramesIn10MS);
} }
if (static_cast<uint32_t>(avail_frames) > _playoutFramesLeft) if (static_cast<uint32_t>(avail_frames) > _playoutFramesLeft)
@ -1509,7 +1509,7 @@ bool AudioDeviceLinuxALSA::PlayThreadProcess() {
UnLock(); UnLock();
return true; return true;
} else { } else {
assert(frames == avail_frames); RTC_DCHECK_EQ(frames, avail_frames);
_playoutFramesLeft -= frames; _playoutFramesLeft -= frames;
} }
@ -1559,7 +1559,7 @@ bool AudioDeviceLinuxALSA::RecThreadProcess() {
UnLock(); UnLock();
return true; return true;
} else if (frames > 0) { } else if (frames > 0) {
assert(frames == avail_frames); RTC_DCHECK_EQ(frames, avail_frames);
int left_size = int left_size =
LATE(snd_pcm_frames_to_bytes)(_handleRecord, _recordingFramesLeft); LATE(snd_pcm_frames_to_bytes)(_handleRecord, _recordingFramesLeft);

View File

@ -11,10 +11,10 @@
#ifndef AUDIO_DEVICE_LATEBINDINGSYMBOLTABLE_LINUX_H_ #ifndef AUDIO_DEVICE_LATEBINDINGSYMBOLTABLE_LINUX_H_
#define AUDIO_DEVICE_LATEBINDINGSYMBOLTABLE_LINUX_H_ #define AUDIO_DEVICE_LATEBINDINGSYMBOLTABLE_LINUX_H_
#include <assert.h>
#include <stddef.h> // for NULL #include <stddef.h> // for NULL
#include <string.h> #include <string.h>
#include "rtc_base/checks.h"
#include "rtc_base/constructor_magic.h" #include "rtc_base/constructor_magic.h"
// This file provides macros for creating "symbol table" classes to simplify the // This file provides macros for creating "symbol table" classes to simplify the
@ -59,7 +59,7 @@ class LateBindingSymbolTable {
// We do not use this, but we offer it for theoretical convenience. // We do not use this, but we offer it for theoretical convenience.
static const char* GetSymbolName(int index) { static const char* GetSymbolName(int index) {
assert(index < NumSymbols()); RTC_DCHECK_LT(index, NumSymbols());
return kSymbolNames[index]; return kSymbolNames[index];
} }
@ -100,8 +100,8 @@ class LateBindingSymbolTable {
// Retrieves the given symbol. NOTE: Recommended to use LATESYM_GET below // Retrieves the given symbol. NOTE: Recommended to use LATESYM_GET below
// instead of this. // instead of this.
void* GetSymbol(int index) const { void* GetSymbol(int index) const {
assert(IsLoaded()); RTC_DCHECK(IsLoaded());
assert(index < NumSymbols()); RTC_DCHECK_LT(index, NumSymbols());
return symbols_[index]; return symbols_[index];
} }

View File

@ -225,7 +225,7 @@ int32_t AudioMixerManagerMac::SetSpeakerVolume(uint32_t volume) {
// volume range is 0.0 - 1.0, convert from 0 -255 // volume range is 0.0 - 1.0, convert from 0 -255
const Float32 vol = (Float32)(volume / 255.0); 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? // Does the capture device have a master volume control?
// If so, use it exclusively. // If so, use it exclusively.
@ -311,7 +311,7 @@ int32_t AudioMixerManagerMac::SpeakerVolume(uint32_t& volume) const {
return -1; return -1;
} }
assert(channels > 0); RTC_DCHECK_GT(channels, 0);
// vol 0.0 to 1.0 -> convert to 0 - 255 // vol 0.0 to 1.0 -> convert to 0 - 255
volume = static_cast<uint32_t>(255 * vol / channels + 0.5); volume = static_cast<uint32_t>(255 * vol / channels + 0.5);
} }
@ -522,7 +522,7 @@ int32_t AudioMixerManagerMac::SpeakerMute(bool& enabled) const {
return -1; return -1;
} }
assert(channels > 0); RTC_DCHECK_GT(channels, 0);
// 1 means muted // 1 means muted
enabled = static_cast<bool>(muted); enabled = static_cast<bool>(muted);
} }
@ -690,7 +690,7 @@ int32_t AudioMixerManagerMac::MicrophoneMute(bool& enabled) const {
return -1; return -1;
} }
assert(channels > 0); RTC_DCHECK_GT(channels, 0);
// 1 means muted // 1 means muted
enabled = static_cast<bool>(muted); enabled = static_cast<bool>(muted);
} }
@ -757,7 +757,7 @@ int32_t AudioMixerManagerMac::SetMicrophoneVolume(uint32_t volume) {
// volume range is 0.0 - 1.0, convert from 0 - 255 // volume range is 0.0 - 1.0, convert from 0 - 255
const Float32 vol = (Float32)(volume / 255.0); 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? // Does the capture device have a master volume control?
// If so, use it exclusively. // If so, use it exclusively.
@ -843,7 +843,7 @@ int32_t AudioMixerManagerMac::MicrophoneVolume(uint32_t& volume) const {
return -1; return -1;
} }
assert(channels > 0); RTC_DCHECK_GT(channels, 0);
// vol 0.0 to 1.0 -> convert to 0 - 255 // vol 0.0 to 1.0 -> convert to 0 - 255
volume = static_cast<uint32_t>(255 * volFloat32 / channels + 0.5); volume = static_cast<uint32_t>(255 * volFloat32 / channels + 0.5);
} }

View File

@ -281,7 +281,7 @@ bool AudioDeviceWindowsCore::CoreAudioIsSupported() {
DWORD messageLength = ::FormatMessageW(dwFlags, 0, hr, dwLangID, errorText, DWORD messageLength = ::FormatMessageW(dwFlags, 0, hr, dwLangID, errorText,
MAXERRORLENGTH, NULL); MAXERRORLENGTH, NULL);
assert(messageLength <= MAXERRORLENGTH); RTC_DCHECK_LE(messageLength, MAXERRORLENGTH);
// Trims tailing white space (FormatMessage() leaves a trailing cr-lf.). // Trims tailing white space (FormatMessage() leaves a trailing cr-lf.).
for (; messageLength && ::isspace(errorText[messageLength - 1]); for (; messageLength && ::isspace(errorText[messageLength - 1]);
@ -469,7 +469,7 @@ AudioDeviceWindowsCore::AudioDeviceWindowsCore()
CoCreateInstance(__uuidof(MMDeviceEnumerator), NULL, CLSCTX_ALL, CoCreateInstance(__uuidof(MMDeviceEnumerator), NULL, CLSCTX_ALL,
__uuidof(IMMDeviceEnumerator), __uuidof(IMMDeviceEnumerator),
reinterpret_cast<void**>(&_ptrEnumerator)); reinterpret_cast<void**>(&_ptrEnumerator));
assert(NULL != _ptrEnumerator); RTC_DCHECK(_ptrEnumerator);
// DMO initialization for built-in WASAPI AEC. // DMO initialization for built-in WASAPI AEC.
{ {
@ -1411,7 +1411,7 @@ int32_t AudioDeviceWindowsCore::SetPlayoutDevice(uint16_t index) {
HRESULT hr(S_OK); HRESULT hr(S_OK);
assert(_ptrRenderCollection != NULL); RTC_DCHECK(_ptrRenderCollection);
// Select an endpoint rendering device given the specified index // Select an endpoint rendering device given the specified index
SAFE_RELEASE(_ptrDeviceOut); SAFE_RELEASE(_ptrDeviceOut);
@ -1461,7 +1461,7 @@ int32_t AudioDeviceWindowsCore::SetPlayoutDevice(
HRESULT hr(S_OK); HRESULT hr(S_OK);
assert(_ptrEnumerator != NULL); RTC_DCHECK(_ptrEnumerator);
// Select an endpoint rendering device given the specified role // Select an endpoint rendering device given the specified role
SAFE_RELEASE(_ptrDeviceOut); SAFE_RELEASE(_ptrDeviceOut);
@ -1677,7 +1677,7 @@ int32_t AudioDeviceWindowsCore::SetRecordingDevice(uint16_t index) {
HRESULT hr(S_OK); HRESULT hr(S_OK);
assert(_ptrCaptureCollection != NULL); RTC_DCHECK(_ptrCaptureCollection);
// Select an endpoint capture device given the specified index // Select an endpoint capture device given the specified index
SAFE_RELEASE(_ptrDeviceIn); SAFE_RELEASE(_ptrDeviceIn);
@ -1727,7 +1727,7 @@ int32_t AudioDeviceWindowsCore::SetRecordingDevice(
HRESULT hr(S_OK); HRESULT hr(S_OK);
assert(_ptrEnumerator != NULL); RTC_DCHECK(_ptrEnumerator);
// Select an endpoint capture device given the specified role // Select an endpoint capture device given the specified role
SAFE_RELEASE(_ptrDeviceIn); SAFE_RELEASE(_ptrDeviceIn);
@ -2036,8 +2036,8 @@ Exit:
// handles device initialization itself. // handles device initialization itself.
// Reference: http://msdn.microsoft.com/en-us/library/ff819492(v=vs.85).aspx // Reference: http://msdn.microsoft.com/en-us/library/ff819492(v=vs.85).aspx
int32_t AudioDeviceWindowsCore::InitRecordingDMO() { int32_t AudioDeviceWindowsCore::InitRecordingDMO() {
assert(_builtInAecEnabled); RTC_DCHECK(_builtInAecEnabled);
assert(_dmo != NULL); RTC_DCHECK(_dmo);
if (SetDMOProperties() == -1) { if (SetDMOProperties() == -1) {
return -1; return -1;
@ -2356,7 +2356,7 @@ int32_t AudioDeviceWindowsCore::StartRecording() {
} }
} }
assert(_hRecThread == NULL); RTC_DCHECK(_hRecThread);
_hRecThread = CreateThread(NULL, 0, lpStartAddress, this, 0, NULL); _hRecThread = CreateThread(NULL, 0, lpStartAddress, this, 0, NULL);
if (_hRecThread == NULL) { if (_hRecThread == NULL) {
RTC_LOG(LS_ERROR) << "failed to create the recording thread"; RTC_LOG(LS_ERROR) << "failed to create the recording thread";
@ -2421,8 +2421,8 @@ int32_t AudioDeviceWindowsCore::StopRecording() {
ResetEvent(_hShutdownCaptureEvent); // Must be manually reset. ResetEvent(_hShutdownCaptureEvent); // Must be manually reset.
// Ensure that the thread has released these interfaces properly. // Ensure that the thread has released these interfaces properly.
assert(err == -1 || _ptrClientIn == NULL); RTC_DCHECK(err == -1 || _ptrClientIn == NULL);
assert(err == -1 || _ptrCaptureClient == NULL); RTC_DCHECK(err == -1 || _ptrCaptureClient == NULL);
_recIsInitialized = false; _recIsInitialized = false;
_recording = false; _recording = false;
@ -2433,7 +2433,7 @@ int32_t AudioDeviceWindowsCore::StopRecording() {
_hRecThread = NULL; _hRecThread = NULL;
if (_builtInAecEnabled) { if (_builtInAecEnabled) {
assert(_dmo != NULL); RTC_DCHECK(_dmo);
// This is necessary. Otherwise the DMO can generate garbage render // This is necessary. Otherwise the DMO can generate garbage render
// audio even after rendering has stopped. // audio even after rendering has stopped.
HRESULT hr = _dmo->FreeStreamingResources(); HRESULT hr = _dmo->FreeStreamingResources();
@ -2493,7 +2493,7 @@ int32_t AudioDeviceWindowsCore::StartPlayout() {
MutexLock lockScoped(&mutex_); MutexLock lockScoped(&mutex_);
// Create thread which will drive the rendering. // Create thread which will drive the rendering.
assert(_hPlayThread == NULL); RTC_DCHECK(_hPlayThread);
_hPlayThread = CreateThread(NULL, 0, WSAPIRenderThread, this, 0, NULL); _hPlayThread = CreateThread(NULL, 0, WSAPIRenderThread, this, 0, NULL);
if (_hPlayThread == NULL) { if (_hPlayThread == NULL) {
RTC_LOG(LS_ERROR) << "failed to create the playout thread"; RTC_LOG(LS_ERROR) << "failed to create the playout thread";
@ -2954,7 +2954,7 @@ void AudioDeviceWindowsCore::RevertCaptureThreadPriority() {
} }
DWORD AudioDeviceWindowsCore::DoCaptureThreadPollDMO() { DWORD AudioDeviceWindowsCore::DoCaptureThreadPollDMO() {
assert(_mediaBuffer != NULL); RTC_DCHECK(_mediaBuffer);
bool keepRecording = true; bool keepRecording = true;
// Initialize COM as MTA in this thread. // Initialize COM as MTA in this thread.
@ -3010,7 +3010,7 @@ DWORD AudioDeviceWindowsCore::DoCaptureThreadPollDMO() {
if (FAILED(hr)) { if (FAILED(hr)) {
_TraceCOMError(hr); _TraceCOMError(hr);
keepRecording = false; keepRecording = false;
assert(false); RTC_NOTREACHED();
break; break;
} }
@ -3022,7 +3022,7 @@ DWORD AudioDeviceWindowsCore::DoCaptureThreadPollDMO() {
if (FAILED(hr)) { if (FAILED(hr)) {
_TraceCOMError(hr); _TraceCOMError(hr);
keepRecording = false; keepRecording = false;
assert(false); RTC_NOTREACHED();
break; break;
} }
@ -3031,8 +3031,8 @@ DWORD AudioDeviceWindowsCore::DoCaptureThreadPollDMO() {
// TODO(andrew): verify that this is always satisfied. It might // TODO(andrew): verify that this is always satisfied. It might
// be that ProcessOutput will try to return more than 10 ms if // be that ProcessOutput will try to return more than 10 ms if
// we fail to call it frequently enough. // we fail to call it frequently enough.
assert(kSamplesProduced == static_cast<int>(_recBlockSize)); RTC_DCHECK_EQ(kSamplesProduced, static_cast<int>(_recBlockSize));
assert(sizeof(BYTE) == sizeof(int8_t)); RTC_DCHECK_EQ(sizeof(BYTE), sizeof(int8_t));
_ptrAudioBuffer->SetRecordedBuffer(reinterpret_cast<int8_t*>(data), _ptrAudioBuffer->SetRecordedBuffer(reinterpret_cast<int8_t*>(data),
kSamplesProduced); kSamplesProduced);
_ptrAudioBuffer->SetVQEData(0, 0); _ptrAudioBuffer->SetVQEData(0, 0);
@ -3047,7 +3047,7 @@ DWORD AudioDeviceWindowsCore::DoCaptureThreadPollDMO() {
if (FAILED(hr)) { if (FAILED(hr)) {
_TraceCOMError(hr); _TraceCOMError(hr);
keepRecording = false; keepRecording = false;
assert(false); RTC_NOTREACHED();
break; break;
} }
@ -3228,7 +3228,7 @@ DWORD AudioDeviceWindowsCore::DoCaptureThread() {
pData = NULL; pData = NULL;
} }
assert(framesAvailable != 0); RTC_DCHECK_NE(framesAvailable, 0);
if (pData) { if (pData) {
CopyMemory(&syncBuffer[syncBufIndex * _recAudioFrameSize], pData, CopyMemory(&syncBuffer[syncBufIndex * _recAudioFrameSize], pData,
@ -3237,8 +3237,8 @@ DWORD AudioDeviceWindowsCore::DoCaptureThread() {
ZeroMemory(&syncBuffer[syncBufIndex * _recAudioFrameSize], ZeroMemory(&syncBuffer[syncBufIndex * _recAudioFrameSize],
framesAvailable * _recAudioFrameSize); framesAvailable * _recAudioFrameSize);
} }
assert(syncBufferSize >= (syncBufIndex * _recAudioFrameSize) + RTC_DCHECK_GE(syncBufferSize, (syncBufIndex * _recAudioFrameSize) +
framesAvailable * _recAudioFrameSize); framesAvailable * _recAudioFrameSize);
// Release the capture buffer // Release the capture buffer
// //
@ -3377,7 +3377,7 @@ void AudioDeviceWindowsCore::_UnLock() RTC_NO_THREAD_SAFETY_ANALYSIS {
int AudioDeviceWindowsCore::SetDMOProperties() { int AudioDeviceWindowsCore::SetDMOProperties() {
HRESULT hr = S_OK; HRESULT hr = S_OK;
assert(_dmo != NULL); RTC_DCHECK(_dmo);
rtc::scoped_refptr<IPropertyStore> ps; rtc::scoped_refptr<IPropertyStore> ps;
{ {
@ -3517,8 +3517,8 @@ int32_t AudioDeviceWindowsCore::_RefreshDeviceList(EDataFlow dir) {
HRESULT hr = S_OK; HRESULT hr = S_OK;
IMMDeviceCollection* pCollection = NULL; IMMDeviceCollection* pCollection = NULL;
assert(dir == eRender || dir == eCapture); RTC_DCHECK(dir == eRender || dir == eCapture);
assert(_ptrEnumerator != NULL); RTC_DCHECK(_ptrEnumerator);
// Create a fresh list of devices using the specified direction // Create a fresh list of devices using the specified direction
hr = _ptrEnumerator->EnumAudioEndpoints(dir, DEVICE_STATE_ACTIVE, hr = _ptrEnumerator->EnumAudioEndpoints(dir, DEVICE_STATE_ACTIVE,
@ -3553,7 +3553,7 @@ int16_t AudioDeviceWindowsCore::_DeviceListCount(EDataFlow dir) {
HRESULT hr = S_OK; HRESULT hr = S_OK;
UINT count = 0; UINT count = 0;
assert(eRender == dir || eCapture == dir); RTC_DCHECK(eRender == dir || eCapture == dir);
if (eRender == dir && NULL != _ptrRenderCollection) { if (eRender == dir && NULL != _ptrRenderCollection) {
hr = _ptrRenderCollection->GetCount(&count); hr = _ptrRenderCollection->GetCount(&count);
@ -3589,7 +3589,7 @@ int32_t AudioDeviceWindowsCore::_GetListDeviceName(EDataFlow dir,
HRESULT hr = S_OK; HRESULT hr = S_OK;
IMMDevice* pDevice = NULL; IMMDevice* pDevice = NULL;
assert(dir == eRender || dir == eCapture); RTC_DCHECK(dir == eRender || dir == eCapture);
if (eRender == dir && NULL != _ptrRenderCollection) { if (eRender == dir && NULL != _ptrRenderCollection) {
hr = _ptrRenderCollection->Item(index, &pDevice); hr = _ptrRenderCollection->Item(index, &pDevice);
@ -3626,9 +3626,9 @@ int32_t AudioDeviceWindowsCore::_GetDefaultDeviceName(EDataFlow dir,
HRESULT hr = S_OK; HRESULT hr = S_OK;
IMMDevice* pDevice = NULL; IMMDevice* pDevice = NULL;
assert(dir == eRender || dir == eCapture); RTC_DCHECK(dir == eRender || dir == eCapture);
assert(role == eConsole || role == eCommunications); RTC_DCHECK(role == eConsole || role == eCommunications);
assert(_ptrEnumerator != NULL); RTC_DCHECK(_ptrEnumerator);
hr = _ptrEnumerator->GetDefaultAudioEndpoint(dir, role, &pDevice); hr = _ptrEnumerator->GetDefaultAudioEndpoint(dir, role, &pDevice);
@ -3663,7 +3663,7 @@ int32_t AudioDeviceWindowsCore::_GetListDeviceID(EDataFlow dir,
HRESULT hr = S_OK; HRESULT hr = S_OK;
IMMDevice* pDevice = NULL; IMMDevice* pDevice = NULL;
assert(dir == eRender || dir == eCapture); RTC_DCHECK(dir == eRender || dir == eCapture);
if (eRender == dir && NULL != _ptrRenderCollection) { if (eRender == dir && NULL != _ptrRenderCollection) {
hr = _ptrRenderCollection->Item(index, &pDevice); hr = _ptrRenderCollection->Item(index, &pDevice);
@ -3700,9 +3700,9 @@ int32_t AudioDeviceWindowsCore::_GetDefaultDeviceID(EDataFlow dir,
HRESULT hr = S_OK; HRESULT hr = S_OK;
IMMDevice* pDevice = NULL; IMMDevice* pDevice = NULL;
assert(dir == eRender || dir == eCapture); RTC_DCHECK(dir == eRender || dir == eCapture);
assert(role == eConsole || role == eCommunications); RTC_DCHECK(role == eConsole || role == eCommunications);
assert(_ptrEnumerator != NULL); RTC_DCHECK(_ptrEnumerator);
hr = _ptrEnumerator->GetDefaultAudioEndpoint(dir, role, &pDevice); hr = _ptrEnumerator->GetDefaultAudioEndpoint(dir, role, &pDevice);
@ -3727,8 +3727,8 @@ int32_t AudioDeviceWindowsCore::_GetDefaultDeviceIndex(EDataFlow dir,
WCHAR szDeviceID[MAX_PATH] = {0}; WCHAR szDeviceID[MAX_PATH] = {0};
const size_t kDeviceIDLength = sizeof(szDeviceID) / sizeof(szDeviceID[0]); const size_t kDeviceIDLength = sizeof(szDeviceID) / sizeof(szDeviceID[0]);
assert(kDeviceIDLength == RTC_DCHECK_EQ(kDeviceIDLength,
sizeof(szDefaultDeviceID) / sizeof(szDefaultDeviceID[0])); sizeof(szDefaultDeviceID) / sizeof(szDefaultDeviceID[0]));
if (_GetDefaultDeviceID(dir, role, szDefaultDeviceID, kDeviceIDLength) == if (_GetDefaultDeviceID(dir, role, szDefaultDeviceID, kDeviceIDLength) ==
-1) { -1) {
@ -3801,8 +3801,8 @@ int32_t AudioDeviceWindowsCore::_GetDeviceName(IMMDevice* pDevice,
IPropertyStore* pProps = NULL; IPropertyStore* pProps = NULL;
PROPVARIANT varName; PROPVARIANT varName;
assert(pszBuffer != NULL); RTC_DCHECK(pszBuffer);
assert(bufferLen > 0); RTC_DCHECK_GT(bufferLen, 0);
if (pDevice != NULL) { if (pDevice != NULL) {
hr = pDevice->OpenPropertyStore(STGM_READ, &pProps); hr = pDevice->OpenPropertyStore(STGM_READ, &pProps);
@ -3867,8 +3867,8 @@ int32_t AudioDeviceWindowsCore::_GetDeviceID(IMMDevice* pDevice,
HRESULT hr = E_FAIL; HRESULT hr = E_FAIL;
LPWSTR pwszID = NULL; LPWSTR pwszID = NULL;
assert(pszBuffer != NULL); RTC_DCHECK(pszBuffer);
assert(bufferLen > 0); RTC_DCHECK_GT(bufferLen, 0);
if (pDevice != NULL) { if (pDevice != NULL) {
hr = pDevice->GetId(&pwszID); hr = pDevice->GetId(&pwszID);
@ -3897,7 +3897,7 @@ int32_t AudioDeviceWindowsCore::_GetDefaultDevice(EDataFlow dir,
HRESULT hr(S_OK); HRESULT hr(S_OK);
assert(_ptrEnumerator != NULL); RTC_DCHECK(_ptrEnumerator);
hr = _ptrEnumerator->GetDefaultAudioEndpoint(dir, role, ppDevice); hr = _ptrEnumerator->GetDefaultAudioEndpoint(dir, role, ppDevice);
if (FAILED(hr)) { if (FAILED(hr)) {
@ -3917,7 +3917,7 @@ int32_t AudioDeviceWindowsCore::_GetListDevice(EDataFlow dir,
IMMDevice** ppDevice) { IMMDevice** ppDevice) {
HRESULT hr(S_OK); HRESULT hr(S_OK);
assert(_ptrEnumerator != NULL); RTC_DCHECK(_ptrEnumerator);
IMMDeviceCollection* pCollection = NULL; IMMDeviceCollection* pCollection = NULL;
@ -3951,7 +3951,7 @@ int32_t AudioDeviceWindowsCore::_EnumerateEndpointDevicesAll(
EDataFlow dataFlow) const { EDataFlow dataFlow) const {
RTC_DLOG(LS_VERBOSE) << __FUNCTION__; RTC_DLOG(LS_VERBOSE) << __FUNCTION__;
assert(_ptrEnumerator != NULL); RTC_DCHECK(_ptrEnumerator);
HRESULT hr = S_OK; HRESULT hr = S_OK;
IMMDeviceCollection* pCollection = NULL; IMMDeviceCollection* pCollection = NULL;
@ -4143,7 +4143,7 @@ void AudioDeviceWindowsCore::_TraceCOMError(HRESULT hr) const {
DWORD messageLength = ::FormatMessageW(dwFlags, 0, hr, dwLangID, errorText, DWORD messageLength = ::FormatMessageW(dwFlags, 0, hr, dwLangID, errorText,
MAXERRORLENGTH, NULL); MAXERRORLENGTH, NULL);
assert(messageLength <= MAXERRORLENGTH); RTC_DCHECK_LE(messageLength, MAXERRORLENGTH);
// Trims tailing white space (FormatMessage() leaves a trailing cr-lf.). // Trims tailing white space (FormatMessage() leaves a trailing cr-lf.).
for (; messageLength && ::isspace(errorText[messageLength - 1]); for (; messageLength && ::isspace(errorText[messageLength - 1]);

View File

@ -36,7 +36,7 @@ double GetIncreaseFactor(const LossBasedControlConfig& config, TimeDelta rtt) {
} }
auto rtt_range = config.increase_high_rtt.Get() - config.increase_low_rtt; auto rtt_range = config.increase_high_rtt.Get() - config.increase_low_rtt;
if (rtt_range <= TimeDelta::Zero()) { if (rtt_range <= TimeDelta::Zero()) {
RTC_DCHECK(false); // Only on misconfiguration. RTC_NOTREACHED(); // Only on misconfiguration.
return config.min_increase_factor; return config.min_increase_factor;
} }
auto rtt_offset = rtt - config.increase_low_rtt; auto rtt_offset = rtt - config.increase_low_rtt;
@ -57,7 +57,7 @@ DataRate BitrateFromLoss(double loss,
DataRate loss_bandwidth_balance, DataRate loss_bandwidth_balance,
double exponent) { double exponent) {
if (exponent <= 0) { if (exponent <= 0) {
RTC_DCHECK(false); RTC_NOTREACHED();
return DataRate::Infinity(); return DataRate::Infinity();
} }
if (loss < 1e-5) if (loss < 1e-5)
@ -69,7 +69,7 @@ double ExponentialUpdate(TimeDelta window, TimeDelta interval) {
// Use the convention that exponential window length (which is really // Use the convention that exponential window length (which is really
// infinite) is the time it takes to dampen to 1/e. // infinite) is the time it takes to dampen to 1/e.
if (window <= TimeDelta::Zero()) { if (window <= TimeDelta::Zero()) {
RTC_DCHECK(false); RTC_NOTREACHED();
return 1.0f; return 1.0f;
} }
return 1.0f - exp(interval / window * -1.0); return 1.0f - exp(interval / window * -1.0);
@ -134,7 +134,7 @@ void LossBasedBandwidthEstimation::UpdateLossStatistics(
const std::vector<PacketResult>& packet_results, const std::vector<PacketResult>& packet_results,
Timestamp at_time) { Timestamp at_time) {
if (packet_results.empty()) { if (packet_results.empty()) {
RTC_DCHECK(false); RTC_NOTREACHED();
return; return;
} }
int loss_count = 0; int loss_count = 0;

View File

@ -118,7 +118,7 @@ struct TopWindowVerifierContext : public SelectedWindowContext {
// firing an assert when enabled, report that the selected window isn't // firing an assert when enabled, report that the selected window isn't
// topmost to avoid inadvertent capture of other windows. // topmost to avoid inadvertent capture of other windows.
RTC_LOG(LS_ERROR) << "Failed to enumerate windows: " << lastError; RTC_LOG(LS_ERROR) << "Failed to enumerate windows: " << lastError;
RTC_DCHECK(false); RTC_NOTREACHED();
return false; return false;
} }
} }

View File

@ -10,11 +10,11 @@
#include "modules/desktop_capture/desktop_region.h" #include "modules/desktop_capture/desktop_region.h"
#include <assert.h>
#include <algorithm> #include <algorithm>
#include <utility> #include <utility>
#include "rtc_base/checks.h"
namespace webrtc { namespace webrtc {
DesktopRegion::RowSpan::RowSpan(int32_t left, int32_t right) DesktopRegion::RowSpan::RowSpan(int32_t left, int32_t right)
@ -109,7 +109,7 @@ void DesktopRegion::AddRect(const DesktopRect& rect) {
// If the |top| falls in the middle of the |row| then split |row| into // 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, // two, at |top|, and leave |row| referring to the lower of the two,
// ready to insert a new span into. // 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( Rows::iterator new_row = rows_.insert(
row, Rows::value_type(top, new Row(row->second->top, top))); row, Rows::value_type(top, new Row(row->second->top, top)));
row->second->top = top; row->second->top = top;
@ -148,7 +148,7 @@ void DesktopRegion::AddRects(const DesktopRect* rects, int count) {
} }
void DesktopRegion::MergeWithPrecedingRow(Rows::iterator row) { void DesktopRegion::MergeWithPrecedingRow(Rows::iterator row) {
assert(row != rows_.end()); RTC_DCHECK(row != rows_.end());
if (row != rows_.begin()) { if (row != rows_.begin()) {
Rows::iterator previous_row = row; Rows::iterator previous_row = row;
@ -230,7 +230,7 @@ void DesktopRegion::IntersectRows(const RowSpanSet& set1,
RowSpanSet::const_iterator end1 = set1.end(); RowSpanSet::const_iterator end1 = set1.end();
RowSpanSet::const_iterator it2 = set2.begin(); RowSpanSet::const_iterator it2 = set2.begin();
RowSpanSet::const_iterator end2 = set2.end(); RowSpanSet::const_iterator end2 = set2.end();
assert(it1 != end1 && it2 != end2); RTC_DCHECK(it1 != end1 && it2 != end2);
do { do {
// Arrange for |it1| to always be the left-most of the spans. // Arrange for |it1| to always be the left-most of the spans.
@ -247,7 +247,7 @@ void DesktopRegion::IntersectRows(const RowSpanSet& set1,
int32_t left = it2->left; int32_t left = it2->left;
int32_t right = std::min(it1->right, it2->right); int32_t right = std::min(it1->right, it2->right);
assert(left < right); RTC_DCHECK_LT(left, right);
output->push_back(RowSpan(left, right)); output->push_back(RowSpan(left, right));
@ -302,7 +302,7 @@ void DesktopRegion::Subtract(const DesktopRegion& region) {
// If |top| falls in the middle of |row_a| then split |row_a| into two, at // 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 // |top|, and leave |row_a| referring to the lower of the two, ready to
// subtract spans from. // subtract spans from.
assert(top <= row_a->second->bottom); RTC_DCHECK_LE(top, row_a->second->bottom);
Rows::iterator new_row = rows_.insert( Rows::iterator new_row = rows_.insert(
row_a, Rows::value_type(top, new Row(row_a->second->top, top))); row_a, Rows::value_type(top, new Row(row_a->second->top, top)));
row_a->second->top = top; row_a->second->top = top;
@ -420,7 +420,7 @@ void DesktopRegion::AddSpanToRow(Row* row, int left, int right) {
// Find the first span that ends at or after |left|. // Find the first span that ends at or after |left|.
RowSpanSet::iterator start = std::lower_bound( RowSpanSet::iterator start = std::lower_bound(
row->spans.begin(), row->spans.end(), left, CompareSpanRight); 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|. // Find the first span that starts after |right|.
RowSpanSet::iterator end = RowSpanSet::iterator end =
@ -467,7 +467,7 @@ bool DesktopRegion::IsSpanInRow(const Row& row, const RowSpan& span) {
void DesktopRegion::SubtractRows(const RowSpanSet& set_a, void DesktopRegion::SubtractRows(const RowSpanSet& set_a,
const RowSpanSet& set_b, const RowSpanSet& set_b,
RowSpanSet* output) { 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(); RowSpanSet::const_iterator it_b = set_b.begin();
@ -503,7 +503,7 @@ DesktopRegion::Iterator::Iterator(const DesktopRegion& region)
row_(region.rows_.begin()), row_(region.rows_.begin()),
previous_row_(region.rows_.end()) { previous_row_(region.rows_.end()) {
if (!IsAtEnd()) { if (!IsAtEnd()) {
assert(row_->second->spans.size() > 0); RTC_DCHECK_GT(row_->second->spans.size(), 0);
row_span_ = row_->second->spans.begin(); row_span_ = row_->second->spans.begin();
UpdateCurrentRect(); UpdateCurrentRect();
} }
@ -516,7 +516,7 @@ bool DesktopRegion::Iterator::IsAtEnd() const {
} }
void DesktopRegion::Iterator::Advance() { void DesktopRegion::Iterator::Advance() {
assert(!IsAtEnd()); RTC_DCHECK(!IsAtEnd());
while (true) { while (true) {
++row_span_; ++row_span_;
@ -524,7 +524,7 @@ void DesktopRegion::Iterator::Advance() {
previous_row_ = row_; previous_row_ = row_;
++row_; ++row_;
if (row_ != region_.rows_.end()) { 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(); row_span_ = row_->second->spans.begin();
} }
} }
@ -544,7 +544,7 @@ void DesktopRegion::Iterator::Advance() {
break; break;
} }
assert(!IsAtEnd()); RTC_DCHECK(!IsAtEnd());
UpdateCurrentRect(); UpdateCurrentRect();
} }

View File

@ -10,9 +10,10 @@
#include "modules/desktop_capture/linux/x_error_trap.h" #include "modules/desktop_capture/linux/x_error_trap.h"
#include <assert.h>
#include <stddef.h> #include <stddef.h>
#include "rtc_base/checks.h"
namespace webrtc { namespace webrtc {
namespace { namespace {
@ -22,7 +23,7 @@ static bool g_xserver_error_trap_enabled = false;
static int g_last_xserver_error_code = 0; static int g_last_xserver_error_code = 0;
int XServerErrorHandler(Display* display, XErrorEvent* error_event) { 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; g_last_xserver_error_code = error_event->error_code;
return 0; return 0;
} }
@ -31,7 +32,7 @@ int XServerErrorHandler(Display* display, XErrorEvent* error_event) {
XErrorTrap::XErrorTrap(Display* display) XErrorTrap::XErrorTrap(Display* display)
: original_error_handler_(NULL), enabled_(true) { : original_error_handler_(NULL), enabled_(true) {
assert(!g_xserver_error_trap_enabled); RTC_DCHECK(!g_xserver_error_trap_enabled);
original_error_handler_ = XSetErrorHandler(&XServerErrorHandler); original_error_handler_ = XSetErrorHandler(&XServerErrorHandler);
g_xserver_error_trap_enabled = true; g_xserver_error_trap_enabled = true;
g_last_xserver_error_code = 0; g_last_xserver_error_code = 0;
@ -39,7 +40,7 @@ XErrorTrap::XErrorTrap(Display* display)
int XErrorTrap::GetLastErrorAndDisable() { int XErrorTrap::GetLastErrorAndDisable() {
enabled_ = false; enabled_ = false;
assert(g_xserver_error_trap_enabled); RTC_DCHECK(g_xserver_error_trap_enabled);
XSetErrorHandler(original_error_handler_); XSetErrorHandler(original_error_handler_);
g_xserver_error_trap_enabled = false; g_xserver_error_trap_enabled = false;
return g_last_xserver_error_code; return g_last_xserver_error_code;

View File

@ -10,9 +10,8 @@
#include "modules/desktop_capture/mouse_cursor.h" #include "modules/desktop_capture/mouse_cursor.h"
#include <assert.h>
#include "modules/desktop_capture/desktop_frame.h" #include "modules/desktop_capture/desktop_frame.h"
#include "rtc_base/checks.h"
namespace webrtc { namespace webrtc {
@ -20,8 +19,8 @@ MouseCursor::MouseCursor() {}
MouseCursor::MouseCursor(DesktopFrame* image, const DesktopVector& hotspot) MouseCursor::MouseCursor(DesktopFrame* image, const DesktopVector& hotspot)
: image_(image), hotspot_(hotspot) { : image_(image), hotspot_(hotspot) {
assert(0 <= hotspot_.x() && hotspot_.x() <= image_->size().width()); RTC_DCHECK(0 <= hotspot_.x() && hotspot_.x() <= image_->size().width());
assert(0 <= hotspot_.y() && hotspot_.y() <= image_->size().height()); RTC_DCHECK(0 <= hotspot_.y() && hotspot_.y() <= image_->size().height());
} }
MouseCursor::~MouseCursor() {} MouseCursor::~MouseCursor() {}

View File

@ -65,7 +65,7 @@ TEST_F(MouseCursorMonitorTest, MAYBE(FromScreen)) {
MouseCursorMonitor::CreateForScreen( MouseCursorMonitor::CreateForScreen(
DesktopCaptureOptions::CreateDefault(), DesktopCaptureOptions::CreateDefault(),
webrtc::kFullDesktopScreenId)); webrtc::kFullDesktopScreenId));
assert(capturer.get()); RTC_DCHECK(capturer.get());
capturer->Init(this, MouseCursorMonitor::SHAPE_AND_POSITION); capturer->Init(this, MouseCursorMonitor::SHAPE_AND_POSITION);
capturer->Capture(); capturer->Capture();
@ -102,7 +102,7 @@ TEST_F(MouseCursorMonitorTest, MAYBE(FromWindow)) {
std::unique_ptr<MouseCursorMonitor> capturer( std::unique_ptr<MouseCursorMonitor> capturer(
MouseCursorMonitor::CreateForWindow( MouseCursorMonitor::CreateForWindow(
DesktopCaptureOptions::CreateDefault(), sources[i].id)); DesktopCaptureOptions::CreateDefault(), sources[i].id));
assert(capturer.get()); RTC_DCHECK(capturer.get());
capturer->Init(this, MouseCursorMonitor::SHAPE_AND_POSITION); capturer->Init(this, MouseCursorMonitor::SHAPE_AND_POSITION);
capturer->Capture(); capturer->Capture();
@ -118,7 +118,7 @@ TEST_F(MouseCursorMonitorTest, MAYBE(ShapeOnly)) {
MouseCursorMonitor::CreateForScreen( MouseCursorMonitor::CreateForScreen(
DesktopCaptureOptions::CreateDefault(), DesktopCaptureOptions::CreateDefault(),
webrtc::kFullDesktopScreenId)); webrtc::kFullDesktopScreenId));
assert(capturer.get()); RTC_DCHECK(capturer.get());
capturer->Init(this, MouseCursorMonitor::SHAPE_ONLY); capturer->Init(this, MouseCursorMonitor::SHAPE_ONLY);
capturer->Capture(); capturer->Capture();

View File

@ -77,7 +77,7 @@ MouseCursorMonitorWin::MouseCursorMonitorWin(ScreenId screen)
callback_(NULL), callback_(NULL),
mode_(SHAPE_AND_POSITION), mode_(SHAPE_AND_POSITION),
desktop_dc_(NULL) { desktop_dc_(NULL) {
assert(screen >= kFullDesktopScreenId); RTC_DCHECK_GE(screen, kFullDesktopScreenId);
memset(&last_cursor_, 0, sizeof(CURSORINFO)); memset(&last_cursor_, 0, sizeof(CURSORINFO));
} }
@ -87,8 +87,8 @@ MouseCursorMonitorWin::~MouseCursorMonitorWin() {
} }
void MouseCursorMonitorWin::Init(Callback* callback, Mode mode) { void MouseCursorMonitorWin::Init(Callback* callback, Mode mode) {
assert(!callback_); RTC_DCHECK(!callback_);
assert(callback); RTC_DCHECK(callback);
callback_ = callback; callback_ = callback;
mode_ = mode; mode_ = mode;
@ -97,7 +97,7 @@ void MouseCursorMonitorWin::Init(Callback* callback, Mode mode) {
} }
void MouseCursorMonitorWin::Capture() { void MouseCursorMonitorWin::Capture() {
assert(callback_); RTC_DCHECK(callback_);
CURSORINFO cursor_info; CURSORINFO cursor_info;
cursor_info.cbSize = sizeof(CURSORINFO); cursor_info.cbSize = sizeof(CURSORINFO);
@ -158,7 +158,7 @@ void MouseCursorMonitorWin::Capture() {
position = position.subtract(cropped_rect.top_left()); position = position.subtract(cropped_rect.top_left());
} }
} else { } else {
assert(screen_ != kInvalidScreenId); RTC_DCHECK_NE(screen_, kInvalidScreenId);
DesktopRect rect = GetScreenRect(); DesktopRect rect = GetScreenRect();
if (inside) if (inside)
inside = rect.Contains(position); inside = rect.Contains(position);
@ -169,7 +169,7 @@ void MouseCursorMonitorWin::Capture() {
} }
DesktopRect MouseCursorMonitorWin::GetScreenRect() { DesktopRect MouseCursorMonitorWin::GetScreenRect() {
assert(screen_ != kInvalidScreenId); RTC_DCHECK_NE(screen_, kInvalidScreenId);
if (screen_ == kFullDesktopScreenId) { if (screen_ == kFullDesktopScreenId) {
return DesktopRect::MakeXYWH(GetSystemMetrics(SM_XVIRTUALSCREEN), return DesktopRect::MakeXYWH(GetSystemMetrics(SM_XVIRTUALSCREEN),
GetSystemMetrics(SM_YVIRTUALSCREEN), GetSystemMetrics(SM_YVIRTUALSCREEN),

View File

@ -74,7 +74,7 @@ static int UpToMultiple(int x, int n, int nMask) {
void ScreenCapturerHelper::ExpandToGrid(const DesktopRegion& region, void ScreenCapturerHelper::ExpandToGrid(const DesktopRegion& region,
int log_grid_size, int log_grid_size,
DesktopRegion* result) { DesktopRegion* result) {
assert(log_grid_size >= 1); RTC_DCHECK_GE(log_grid_size, 1);
int grid_size = 1 << log_grid_size; int grid_size = 1 << log_grid_size;
int grid_size_mask = ~(grid_size - 1); int grid_size_mask = ~(grid_size - 1);

View File

@ -8,10 +8,9 @@
* be found in the AUTHORS file in the root of the source tree. * 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_capturer.h"
#include "modules/desktop_capture/desktop_frame.h" #include "modules/desktop_capture/desktop_frame.h"
#include "rtc_base/checks.h"
#include "rtc_base/constructor_magic.h" #include "rtc_base/constructor_magic.h"
namespace webrtc { namespace webrtc {
@ -49,8 +48,8 @@ bool WindowCapturerNull::SelectSource(SourceId id) {
} }
void WindowCapturerNull::Start(Callback* callback) { void WindowCapturerNull::Start(Callback* callback) {
assert(!callback_); RTC_DCHECK(!callback_);
assert(callback); RTC_DCHECK(callback);
callback_ = callback; callback_ = callback;
} }

View File

@ -362,7 +362,7 @@ void AimdRateControl::ChangeBitrate(const RateControlInput& input,
break; break;
} }
default: default:
assert(false); RTC_NOTREACHED();
} }
current_bitrate_ = ClampBitrate(new_bitrate.value_or(current_bitrate_)); current_bitrate_ = ClampBitrate(new_bitrate.value_or(current_bitrate_));
@ -417,7 +417,7 @@ void AimdRateControl::ChangeState(const RateControlInput& input,
rate_control_state_ = RateControlState::kRcHold; rate_control_state_ = RateControlState::kRcHold;
break; break;
default: default:
assert(false); RTC_NOTREACHED();
} }
} }

View File

@ -37,9 +37,9 @@ bool InterArrival::ComputeDeltas(uint32_t timestamp,
uint32_t* timestamp_delta, uint32_t* timestamp_delta,
int64_t* arrival_time_delta_ms, int64_t* arrival_time_delta_ms,
int* packet_size_delta) { int* packet_size_delta) {
assert(timestamp_delta != NULL); RTC_DCHECK(timestamp_delta);
assert(arrival_time_delta_ms != NULL); RTC_DCHECK(arrival_time_delta_ms);
assert(packet_size_delta != NULL); RTC_DCHECK(packet_size_delta);
bool calculated_deltas = false; bool calculated_deltas = false;
if (current_timestamp_group_.IsFirstPacket()) { if (current_timestamp_group_.IsFirstPacket()) {
// We don't have enough data to update the filter, so we store it until we // We don't have enough data to update the filter, so we store it until we
@ -85,7 +85,7 @@ bool InterArrival::ComputeDeltas(uint32_t timestamp,
} else { } else {
num_consecutive_reordered_packets_ = 0; 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) - *packet_size_delta = static_cast<int>(current_timestamp_group_.size) -
static_cast<int>(prev_timestamp_group_.size); static_cast<int>(prev_timestamp_group_.size);
calculated_deltas = true; calculated_deltas = true;
@ -141,7 +141,7 @@ bool InterArrival::BelongsToBurst(int64_t arrival_time_ms,
if (!burst_grouping_) { if (!burst_grouping_) {
return false; 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 = int64_t arrival_time_delta_ms =
arrival_time_ms - current_timestamp_group_.complete_time_ms; arrival_time_ms - current_timestamp_group_.complete_time_ms;
uint32_t timestamp_diff = timestamp - current_timestamp_group_.timestamp; uint32_t timestamp_diff = timestamp - current_timestamp_group_.timestamp;

View File

@ -110,7 +110,7 @@ void OveruseEstimator::Update(int64_t t_delta,
bool positive_semi_definite = bool positive_semi_definite =
E_[0][0] + E_[1][1] >= 0 && E_[0][0] + E_[1][1] >= 0 &&
E_[0][0] * E_[1][1] - E_[0][1] * E_[1][0] >= 0 && E_[0][0] >= 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) { if (!positive_semi_definite) {
RTC_LOG(LS_ERROR) RTC_LOG(LS_ERROR)
<< "The over-use estimator's covariance matrix is no longer " << "The over-use estimator's covariance matrix is no longer "

View File

@ -234,7 +234,7 @@ bool RemoteBitrateEstimatorSingleStream::LatestEstimate(
std::vector<uint32_t>* ssrcs, std::vector<uint32_t>* ssrcs,
uint32_t* bitrate_bps) const { uint32_t* bitrate_bps) const {
MutexLock lock(&mutex_); MutexLock lock(&mutex_);
assert(bitrate_bps); RTC_DCHECK(bitrate_bps);
if (!remote_rate_->ValidEstimate()) { if (!remote_rate_->ValidEstimate()) {
return false; return false;
} }
@ -248,7 +248,7 @@ bool RemoteBitrateEstimatorSingleStream::LatestEstimate(
void RemoteBitrateEstimatorSingleStream::GetSsrcs( void RemoteBitrateEstimatorSingleStream::GetSsrcs(
std::vector<uint32_t>* ssrcs) const { std::vector<uint32_t>* ssrcs) const {
assert(ssrcs); RTC_DCHECK(ssrcs);
ssrcs->resize(overuse_detectors_.size()); ssrcs->resize(overuse_detectors_.size());
int i = 0; int i = 0;
for (SsrcOveruseEstimatorMap::const_iterator it = overuse_detectors_.begin(); for (SsrcOveruseEstimatorMap::const_iterator it = overuse_detectors_.begin();

View File

@ -46,7 +46,7 @@ RtpStream::RtpStream(int fps,
next_rtcp_time_(rtcp_receive_time), next_rtcp_time_(rtcp_receive_time),
rtp_timestamp_offset_(timestamp_offset), rtp_timestamp_offset_(timestamp_offset),
kNtpFracPerMs(4.294967296E6) { kNtpFracPerMs(4.294967296E6) {
assert(fps_ > 0); RTC_DCHECK_GT(fps_, 0);
} }
void RtpStream::set_rtp_timestamp_offset(uint32_t offset) { void RtpStream::set_rtp_timestamp_offset(uint32_t offset) {
@ -60,7 +60,7 @@ int64_t RtpStream::GenerateFrame(int64_t time_now_us, PacketList* packets) {
if (time_now_us < next_rtp_time_) { if (time_now_us < next_rtp_time_) {
return 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 bits_per_frame = (bitrate_bps_ + fps_ / 2) / fps_;
size_t n_packets = size_t n_packets =
std::max<size_t>((bits_per_frame + 4 * kMtu) / (8 * kMtu), 1u); std::max<size_t>((bits_per_frame + 4 * kMtu) / (8 * kMtu), 1u);
@ -173,9 +173,9 @@ void StreamGenerator::set_rtp_timestamp_offset(uint32_t ssrc, uint32_t offset) {
// it possible to simulate different types of channels. // it possible to simulate different types of channels.
int64_t StreamGenerator::GenerateFrame(RtpStream::PacketList* packets, int64_t StreamGenerator::GenerateFrame(RtpStream::PacketList* packets,
int64_t time_now_us) { int64_t time_now_us) {
assert(packets != NULL); RTC_DCHECK(packets);
assert(packets->empty()); RTC_DCHECK(packets->empty());
assert(capacity_ > 0); RTC_DCHECK_GT(capacity_, 0);
StreamMap::iterator it = StreamMap::iterator it =
std::min_element(streams_.begin(), streams_.end(), RtpStream::Compare); std::min_element(streams_.begin(), streams_.end(), RtpStream::Compare);
(*it).second->GenerateFrame(time_now_us, packets); (*it).second->GenerateFrame(time_now_us, packets);

View File

@ -131,7 +131,7 @@ bool RtpHeaderParser::RTCP() const {
} }
bool RtpHeaderParser::ParseRtcp(RTPHeader* header) const { bool RtpHeaderParser::ParseRtcp(RTPHeader* header) const {
assert(header != NULL); RTC_DCHECK(header);
const ptrdiff_t length = _ptrRTPDataEnd - _ptrRTPDataBegin; const ptrdiff_t length = _ptrRTPDataEnd - _ptrRTPDataBegin;
if (length < kRtcpMinParseLength) { if (length < kRtcpMinParseLength) {

View File

@ -225,7 +225,7 @@ class FecPacketMaskMetricsTest : public ::testing::Test {
} }
} }
// Check that we can only recover 1 packet. // 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. // Update the state with the newly recovered media packet.
state_tmp[jsel] = 0; state_tmp[jsel] = 0;
} }
@ -260,7 +260,7 @@ class FecPacketMaskMetricsTest : public ::testing::Test {
} }
} }
} else { // Gilbert-Elliot model for burst model. } 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. // Transition probabilities: from previous to current state.
// Prob. of previous = lost --> current = received. // Prob. of previous = lost --> current = received.
double prob10 = 1.0 / burst_length; double prob10 = 1.0 / burst_length;
@ -425,8 +425,8 @@ class FecPacketMaskMetricsTest : public ::testing::Test {
} }
} }
} // Done with loop over total number of packets. } // Done with loop over total number of packets.
assert(num_media_packets_lost <= num_media_packets); RTC_DCHECK_LE(num_media_packets_lost, num_media_packets);
assert(num_packets_lost <= tot_num_packets && num_packets_lost > 0); RTC_DCHECK_LE(num_packets_lost, tot_num_packets && num_packets_lost > 0);
double residual_loss = 0.0; double residual_loss = 0.0;
// Only need to compute residual loss (number of recovered packets) for // Only need to compute residual loss (number of recovered packets) for
// configurations that have at least one media packet lost. // configurations that have at least one media packet lost.
@ -445,7 +445,7 @@ class FecPacketMaskMetricsTest : public ::testing::Test {
num_recovered_packets = num_media_packets_lost; 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 // Compute the residual loss. We only care about recovering media/source
// packets, so residual loss is based on lost/recovered media packets. // packets, so residual loss is based on lost/recovered media packets.
residual_loss = residual_loss =
@ -464,9 +464,9 @@ class FecPacketMaskMetricsTest : public ::testing::Test {
// Update the distribution statistics. // Update the distribution statistics.
// Compute the gap of the loss (the "consecutiveness" of the loss). // Compute the gap of the loss (the "consecutiveness" of the loss).
int gap_loss = GapLoss(tot_num_packets, state.get()); 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; 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; metrics_code.residual_loss_per_loss_gap[index] += residual_loss;
if (code_type == xor_random_code) { if (code_type == xor_random_code) {
// The configuration density is only a function of the code length and // The configuration density is only a function of the code length and
@ -492,8 +492,8 @@ class FecPacketMaskMetricsTest : public ::testing::Test {
metrics_code.variance_residual_loss[k] - metrics_code.variance_residual_loss[k] -
(metrics_code.average_residual_loss[k] * (metrics_code.average_residual_loss[k] *
metrics_code.average_residual_loss[k]); metrics_code.average_residual_loss[k]);
assert(metrics_code.variance_residual_loss[k] >= 0.0); RTC_DCHECK_GE(metrics_code.variance_residual_loss[k], 0.0);
assert(metrics_code.average_residual_loss[k] > 0.0); RTC_DCHECK_GT(metrics_code.average_residual_loss[k], 0.0);
metrics_code.variance_residual_loss[k] = metrics_code.variance_residual_loss[k] =
std::sqrt(metrics_code.variance_residual_loss[k]) / std::sqrt(metrics_code.variance_residual_loss[k]) /
metrics_code.average_residual_loss[k]; metrics_code.average_residual_loss[k];
@ -509,7 +509,7 @@ class FecPacketMaskMetricsTest : public ::testing::Test {
} else if (code_type == xor_bursty_code) { } else if (code_type == xor_bursty_code) {
CopyMetrics(&kMetricsXorBursty[code_index], metrics_code); CopyMetrics(&kMetricsXorBursty[code_index], metrics_code);
} else { } else {
assert(false); RTC_NOTREACHED();
} }
} }
@ -588,7 +588,7 @@ class FecPacketMaskMetricsTest : public ::testing::Test {
num_loss_models++; num_loss_models++;
} }
} }
assert(num_loss_models == kNumLossModels); RTC_DCHECK_EQ(num_loss_models, kNumLossModels);
} }
void SetCodeParams() { void SetCodeParams() {
@ -738,7 +738,7 @@ class FecPacketMaskMetricsTest : public ::testing::Test {
code_index++; code_index++;
} }
} }
assert(code_index == kNumberCodes); RTC_DCHECK_EQ(code_index, kNumberCodes);
return 0; return 0;
} }

View File

@ -52,7 +52,7 @@ int32_t DeviceInfoImpl::NumberOfCapabilities(const char* deviceUniqueIdUTF8) {
int32_t DeviceInfoImpl::GetCapability(const char* deviceUniqueIdUTF8, int32_t DeviceInfoImpl::GetCapability(const char* deviceUniqueIdUTF8,
const uint32_t deviceCapabilityNumber, const uint32_t deviceCapabilityNumber,
VideoCaptureCapability& capability) { VideoCaptureCapability& capability) {
assert(deviceUniqueIdUTF8 != NULL); RTC_DCHECK(deviceUniqueIdUTF8);
MutexLock lock(&_apiLock); MutexLock lock(&_apiLock);

View File

@ -152,7 +152,7 @@ class VideoCaptureTest : public ::testing::Test {
void SetUp() override { void SetUp() override {
device_info_.reset(VideoCaptureFactory::CreateDeviceInfo()); device_info_.reset(VideoCaptureFactory::CreateDeviceInfo());
assert(device_info_.get()); RTC_DCHECK(device_info_.get());
number_of_devices_ = device_info_->NumberOfDevices(); number_of_devices_ = device_info_->NumberOfDevices();
ASSERT_GT(number_of_devices_, 0u); ASSERT_GT(number_of_devices_, 0u);
} }

View File

@ -380,7 +380,7 @@ int32_t DeviceInfoDS::CreateCapabilityMap(const char* deviceUniqueIdUTF8)
supportFORMAT_VideoInfo2 = true; supportFORMAT_VideoInfo2 = true;
VIDEOINFOHEADER2* h = VIDEOINFOHEADER2* h =
reinterpret_cast<VIDEOINFOHEADER2*>(pmt->pbFormat); reinterpret_cast<VIDEOINFOHEADER2*>(pmt->pbFormat);
assert(h); RTC_DCHECK(h);
foundInterlacedFormat |= foundInterlacedFormat |=
h->dwInterlaceFlags & h->dwInterlaceFlags &
(AMINTERLACE_IsInterlaced | AMINTERLACE_DisplayModeBobOnly); (AMINTERLACE_IsInterlaced | AMINTERLACE_DisplayModeBobOnly);
@ -418,7 +418,7 @@ int32_t DeviceInfoDS::CreateCapabilityMap(const char* deviceUniqueIdUTF8)
if (pmt->formattype == FORMAT_VideoInfo) { if (pmt->formattype == FORMAT_VideoInfo) {
VIDEOINFOHEADER* h = reinterpret_cast<VIDEOINFOHEADER*>(pmt->pbFormat); VIDEOINFOHEADER* h = reinterpret_cast<VIDEOINFOHEADER*>(pmt->pbFormat);
assert(h); RTC_DCHECK(h);
capability.directShowCapabilityIndex = tmp; capability.directShowCapabilityIndex = tmp;
capability.width = h->bmiHeader.biWidth; capability.width = h->bmiHeader.biWidth;
capability.height = h->bmiHeader.biHeight; capability.height = h->bmiHeader.biHeight;
@ -427,7 +427,7 @@ int32_t DeviceInfoDS::CreateCapabilityMap(const char* deviceUniqueIdUTF8)
if (pmt->formattype == FORMAT_VideoInfo2) { if (pmt->formattype == FORMAT_VideoInfo2) {
VIDEOINFOHEADER2* h = VIDEOINFOHEADER2* h =
reinterpret_cast<VIDEOINFOHEADER2*>(pmt->pbFormat); reinterpret_cast<VIDEOINFOHEADER2*>(pmt->pbFormat);
assert(h); RTC_DCHECK(h);
capability.directShowCapabilityIndex = tmp; capability.directShowCapabilityIndex = tmp;
capability.width = h->bmiHeader.biWidth; capability.width = h->bmiHeader.biWidth;
capability.height = h->bmiHeader.biHeight; capability.height = h->bmiHeader.biHeight;

View File

@ -58,7 +58,7 @@ class EnumPins : public IEnumPins {
} }
STDMETHOD(Clone)(IEnumPins** pins) { STDMETHOD(Clone)(IEnumPins** pins) {
RTC_DCHECK(false); RTC_NOTREACHED();
return E_NOTIMPL; return E_NOTIMPL;
} }
@ -83,7 +83,7 @@ class EnumPins : public IEnumPins {
} }
STDMETHOD(Skip)(ULONG count) { STDMETHOD(Skip)(ULONG count) {
RTC_DCHECK(false); RTC_NOTREACHED();
return E_NOTIMPL; return E_NOTIMPL;
} }
@ -274,7 +274,7 @@ class MediaTypesEnum : public IEnumMediaTypes {
// IEnumMediaTypes // IEnumMediaTypes
STDMETHOD(Clone)(IEnumMediaTypes** pins) { STDMETHOD(Clone)(IEnumMediaTypes** pins) {
RTC_DCHECK(false); RTC_NOTREACHED();
return E_NOTIMPL; return E_NOTIMPL;
} }
@ -364,7 +364,7 @@ class MediaTypesEnum : public IEnumMediaTypes {
} }
STDMETHOD(Skip)(ULONG count) { STDMETHOD(Skip)(ULONG count) {
RTC_DCHECK(false); RTC_NOTREACHED();
return E_NOTIMPL; return E_NOTIMPL;
} }
@ -538,7 +538,7 @@ STDMETHODIMP CaptureInputPin::Connect(IPin* receive_pin,
return VFW_E_NOT_STOPPED; return VFW_E_NOT_STOPPED;
if (receive_pin_) { if (receive_pin_) {
RTC_DCHECK(false); RTC_NOTREACHED();
return VFW_E_ALREADY_CONNECTED; return VFW_E_ALREADY_CONNECTED;
} }
@ -564,7 +564,7 @@ STDMETHODIMP CaptureInputPin::ReceiveConnection(
RTC_DCHECK(Filter()->IsStopped()); RTC_DCHECK(Filter()->IsStopped());
if (receive_pin_) { if (receive_pin_) {
RTC_DCHECK(false); RTC_NOTREACHED();
return VFW_E_ALREADY_CONNECTED; return VFW_E_ALREADY_CONNECTED;
} }

View File

@ -1037,7 +1037,7 @@ int LibvpxVp8Encoder::Encode(const VideoFrame& frame,
// would like to use the duration of the previous frame. Unfortunately the // 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 // rate control seems to be off with that setup. Using the average input
// frame rate to calculate an average duration for now. // 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; uint32_t duration = kRtpTicksPerSecond / codec_.maxFramerate;
int error = WEBRTC_VIDEO_CODEC_OK; int error = WEBRTC_VIDEO_CODEC_OK;
@ -1074,7 +1074,7 @@ void LibvpxVp8Encoder::PopulateCodecSpecific(CodecSpecificInfo* codec_specific,
int stream_idx, int stream_idx,
int encoder_idx, int encoder_idx,
uint32_t timestamp) { uint32_t timestamp) {
assert(codec_specific != NULL); RTC_DCHECK(codec_specific);
codec_specific->codecType = kVideoCodecVP8; codec_specific->codecType = kVideoCodecVP8;
codec_specific->codecSpecific.VP8.keyIdx = codec_specific->codecSpecific.VP8.keyIdx =
kNoKeyIdx; // TODO(hlundin) populate this kNoKeyIdx; // TODO(hlundin) populate this

View File

@ -18,6 +18,7 @@
#include <stdint.h> #include <stdint.h>
#include "modules/video_coding/codecs/interface/common_constants.h" #include "modules/video_coding/codecs/interface/common_constants.h"
#include "rtc_base/checks.h"
namespace webrtc { namespace webrtc {
@ -131,7 +132,7 @@ struct GofInfoVP9 {
pid_diff[7][1] = 2; pid_diff[7][1] = 2;
break; break;
default: default:
assert(false); RTC_NOTREACHED();
} }
} }

View File

@ -55,21 +55,22 @@ uint16_t VCMDecodingState::sequence_num() const {
} }
bool VCMDecodingState::IsOldFrame(const VCMFrameBuffer* frame) const { bool VCMDecodingState::IsOldFrame(const VCMFrameBuffer* frame) const {
assert(frame != NULL); RTC_DCHECK(frame);
if (in_initial_state_) if (in_initial_state_)
return false; return false;
return !IsNewerTimestamp(frame->Timestamp(), time_stamp_); return !IsNewerTimestamp(frame->Timestamp(), time_stamp_);
} }
bool VCMDecodingState::IsOldPacket(const VCMPacket* packet) const { bool VCMDecodingState::IsOldPacket(const VCMPacket* packet) const {
assert(packet != NULL); RTC_DCHECK(packet);
if (in_initial_state_) if (in_initial_state_)
return false; return false;
return !IsNewerTimestamp(packet->timestamp, time_stamp_); return !IsNewerTimestamp(packet->timestamp, time_stamp_);
} }
void VCMDecodingState::SetState(const VCMFrameBuffer* frame) { void VCMDecodingState::SetState(const VCMFrameBuffer* frame) {
assert(frame != NULL && frame->GetHighSeqNum() >= 0); RTC_DCHECK(frame);
RTC_CHECK_GE(frame->GetHighSeqNum(), 0);
if (!UsingFlexibleMode(frame)) if (!UsingFlexibleMode(frame))
UpdateSyncState(frame); UpdateSyncState(frame);
sequence_num_ = static_cast<uint16_t>(frame->GetHighSeqNum()); sequence_num_ = static_cast<uint16_t>(frame->GetHighSeqNum());
@ -150,7 +151,7 @@ bool VCMDecodingState::UpdateEmptyFrame(const VCMFrameBuffer* frame) {
} }
void VCMDecodingState::UpdateOldPacket(const VCMPacket* packet) { void VCMDecodingState::UpdateOldPacket(const VCMPacket* packet) {
assert(packet != NULL); RTC_DCHECK(packet);
if (packet->timestamp == time_stamp_) { if (packet->timestamp == time_stamp_) {
// Late packet belonging to the last decoded frame - make sure we update the // Late packet belonging to the last decoded frame - make sure we update the
// last decoded sequence number. // last decoded sequence number.
@ -204,7 +205,7 @@ bool VCMDecodingState::ContinuousFrame(const VCMFrameBuffer* frame) const {
// - Sequence numbers. // - Sequence numbers.
// Return true when in initial state. // Return true when in initial state.
// Note that when a method is not applicable it will return false. // 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 // 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 // frames and therefore won't introduce any errors even if prior frames are
// missing. // missing.

View File

@ -75,7 +75,7 @@ VCMFrameBufferEnum VCMFrameBuffer::InsertPacket(const VCMPacket& packet,
int64_t timeInMs, int64_t timeInMs,
const FrameData& frame_data) { const FrameData& frame_data) {
TRACE_EVENT0("webrtc", "VCMFrameBuffer::InsertPacket"); TRACE_EVENT0("webrtc", "VCMFrameBuffer::InsertPacket");
assert(!(NULL == packet.dataPtr && packet.sizeBytes > 0)); RTC_DCHECK(!(NULL == packet.dataPtr && packet.sizeBytes > 0));
if (packet.dataPtr != NULL) { if (packet.dataPtr != NULL) {
_payloadType = packet.payloadType; _payloadType = packet.payloadType;
} }
@ -230,19 +230,19 @@ void VCMFrameBuffer::SetState(VCMFrameBufferStateEnum state) {
switch (state) { switch (state) {
case kStateIncomplete: case kStateIncomplete:
// we can go to this state from state kStateEmpty // we can go to this state from state kStateEmpty
assert(_state == kStateEmpty); RTC_DCHECK_EQ(_state, kStateEmpty);
// Do nothing, we received a packet // Do nothing, we received a packet
break; break;
case kStateComplete: case kStateComplete:
assert(_state == kStateEmpty || _state == kStateIncomplete); RTC_DCHECK(_state == kStateEmpty || _state == kStateIncomplete);
break; break;
case kStateEmpty: case kStateEmpty:
// Should only be set to empty through Reset(). // Should only be set to empty through Reset().
assert(false); RTC_NOTREACHED();
break; break;
} }
_state = state; _state = state;

View File

@ -347,7 +347,7 @@ VCMFrameBufferEnum VCMJitterBuffer::GetFrame(const VCMPacket& packet,
int64_t VCMJitterBuffer::LastPacketTime(const VCMEncodedFrame* frame, int64_t VCMJitterBuffer::LastPacketTime(const VCMEncodedFrame* frame,
bool* retransmitted) const { bool* retransmitted) const {
assert(retransmitted); RTC_DCHECK(retransmitted);
MutexLock lock(&mutex_); MutexLock lock(&mutex_);
const VCMFrameBuffer* frame_buffer = const VCMFrameBuffer* frame_buffer =
static_cast<const VCMFrameBuffer*>(frame); static_cast<const VCMFrameBuffer*>(frame);
@ -498,7 +498,7 @@ VCMFrameBufferEnum VCMJitterBuffer::InsertPacket(const VCMPacket& packet,
RecycleFrameBuffer(frame); RecycleFrameBuffer(frame);
return kFlushIndicator; return kFlushIndicator;
default: default:
assert(false); RTC_NOTREACHED();
} }
return buffer_state; return buffer_state;
} }
@ -580,8 +580,8 @@ void VCMJitterBuffer::SetNackSettings(size_t max_nack_list_size,
int max_packet_age_to_nack, int max_packet_age_to_nack,
int max_incomplete_time_ms) { int max_incomplete_time_ms) {
MutexLock lock(&mutex_); MutexLock lock(&mutex_);
assert(max_packet_age_to_nack >= 0); RTC_DCHECK_GE(max_packet_age_to_nack, 0);
assert(max_incomplete_time_ms_ >= 0); RTC_DCHECK_GE(max_incomplete_time_ms_, 0);
max_nack_list_size_ = max_nack_list_size; max_nack_list_size_ = max_nack_list_size;
max_packet_age_to_nack_ = max_packet_age_to_nack; max_packet_age_to_nack_ = max_packet_age_to_nack;
max_incomplete_time_ms_ = max_incomplete_time_ms; max_incomplete_time_ms_ = max_incomplete_time_ms;
@ -600,7 +600,7 @@ int VCMJitterBuffer::NonContinuousOrIncompleteDuration() {
uint16_t VCMJitterBuffer::EstimatedLowSequenceNumber( uint16_t VCMJitterBuffer::EstimatedLowSequenceNumber(
const VCMFrameBuffer& frame) const { const VCMFrameBuffer& frame) const {
assert(frame.GetLowSeqNum() >= 0); RTC_DCHECK_GE(frame.GetLowSeqNum(), 0);
if (frame.HaveFirstPacket()) if (frame.HaveFirstPacket())
return frame.GetLowSeqNum(); return frame.GetLowSeqNum();

View File

@ -247,7 +247,7 @@ void VCMJitterEstimator::KalmanEstimateChannel(int64_t frameDelayMS,
hMh_sigma = deltaFSBytes * Mh[0] + Mh[1] + sigma; hMh_sigma = deltaFSBytes * Mh[0] + Mh[1] + sigma;
if ((hMh_sigma < 1e-9 && hMh_sigma >= 0) || if ((hMh_sigma < 1e-9 && hMh_sigma >= 0) ||
(hMh_sigma > -1e-9 && hMh_sigma <= 0)) { (hMh_sigma > -1e-9 && hMh_sigma <= 0)) {
assert(false); RTC_NOTREACHED();
return; return;
} }
kalmanGain[0] = Mh[0] / hMh_sigma; kalmanGain[0] = Mh[0] / hMh_sigma;
@ -276,11 +276,11 @@ void VCMJitterEstimator::KalmanEstimateChannel(int64_t frameDelayMS,
kalmanGain[1] * deltaFSBytes * t01; kalmanGain[1] * deltaFSBytes * t01;
// Covariance matrix, must be positive semi-definite. // Covariance matrix, must be positive semi-definite.
assert(_thetaCov[0][0] + _thetaCov[1][1] >= 0 && RTC_DCHECK(_thetaCov[0][0] + _thetaCov[1][1] >= 0 &&
_thetaCov[0][0] * _thetaCov[1][1] - _thetaCov[0][0] * _thetaCov[1][1] -
_thetaCov[0][1] * _thetaCov[1][0] >= _thetaCov[0][1] * _thetaCov[1][0] >=
0 && 0 &&
_thetaCov[0][0] >= 0); _thetaCov[0][0] >= 0);
} }
// Calculate difference in delay between a sample and the expected delay // Calculate difference in delay between a sample and the expected delay
@ -302,7 +302,7 @@ void VCMJitterEstimator::EstimateRandomJitter(double d_dT,
_lastUpdateT = now; _lastUpdateT = now;
if (_alphaCount == 0) { if (_alphaCount == 0) {
assert(false); RTC_NOTREACHED();
return; return;
} }
double alpha = double alpha =
@ -428,7 +428,7 @@ double VCMJitterEstimator::GetFrameRate() const {
double fps = 1000000.0 / fps_counter_.ComputeMean(); double fps = 1000000.0 / fps_counter_.ComputeMean();
// Sanity check. // Sanity check.
assert(fps >= 0.0); RTC_DCHECK_GE(fps, 0.0);
if (fps > kMaxFramerateEstimate) { if (fps > kMaxFramerateEstimate) {
fps = kMaxFramerateEstimate; fps = kMaxFramerateEstimate;
} }

View File

@ -87,10 +87,10 @@ VCMNackFecMethod::VCMNackFecMethod(int64_t lowRttNackThresholdMs,
_lowRttNackMs(lowRttNackThresholdMs), _lowRttNackMs(lowRttNackThresholdMs),
_highRttNackMs(highRttNackThresholdMs), _highRttNackMs(highRttNackThresholdMs),
_maxFramesFec(1) { _maxFramesFec(1) {
assert(lowRttNackThresholdMs >= -1 && highRttNackThresholdMs >= -1); RTC_DCHECK(lowRttNackThresholdMs >= -1 && highRttNackThresholdMs >= -1);
assert(highRttNackThresholdMs == -1 || RTC_DCHECK(highRttNackThresholdMs == -1 ||
lowRttNackThresholdMs <= highRttNackThresholdMs); lowRttNackThresholdMs <= highRttNackThresholdMs);
assert(lowRttNackThresholdMs > -1 || highRttNackThresholdMs == -1); RTC_DCHECK(lowRttNackThresholdMs > -1 || highRttNackThresholdMs == -1);
_type = kNackFec; _type = kNackFec;
} }
@ -384,7 +384,7 @@ bool VCMFecMethod::ProtectionFactor(const VCMProtectionParameters* parameters) {
indexTableKey = VCM_MIN(indexTableKey, kFecRateTableSize); indexTableKey = VCM_MIN(indexTableKey, kFecRateTableSize);
// Check on table index // Check on table index
assert(indexTableKey < kFecRateTableSize); RTC_DCHECK_LT(indexTableKey, kFecRateTableSize);
// Protection factor for I frame // Protection factor for I frame
codeRateKey = kFecRateTable[indexTableKey]; codeRateKey = kFecRateTable[indexTableKey];

View File

@ -49,7 +49,7 @@ void VCMSessionInfo::UpdateDataPointers(const uint8_t* old_base_ptr,
const uint8_t* new_base_ptr) { const uint8_t* new_base_ptr) {
for (PacketIterator it = packets_.begin(); it != packets_.end(); ++it) for (PacketIterator it = packets_.begin(); it != packets_.end(); ++it)
if ((*it).dataPtr != NULL) { 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); (*it).dataPtr = new_base_ptr + ((*it).dataPtr - old_base_ptr);
} }
} }
@ -348,7 +348,7 @@ VCMSessionInfo::PacketIterator VCMSessionInfo::FindNextPartitionBeginning(
VCMSessionInfo::PacketIterator VCMSessionInfo::FindPartitionEnd( VCMSessionInfo::PacketIterator VCMSessionInfo::FindPartitionEnd(
PacketIterator it) const { PacketIterator it) const {
assert((*it).codec() == kVideoCodecVP8); RTC_DCHECK_EQ((*it).codec(), kVideoCodecVP8);
PacketIterator prev_it = it; PacketIterator prev_it = it;
const int partition_id = const int partition_id =
absl::get<RTPVideoHeaderVP8>((*it).video_header.video_type_header) absl::get<RTPVideoHeaderVP8>((*it).video_header.video_type_header)

View File

@ -157,7 +157,7 @@ void VCMTiming::StopDecodeTimer(uint32_t /*time_stamp*/,
void VCMTiming::StopDecodeTimer(int32_t decode_time_ms, int64_t now_ms) { void VCMTiming::StopDecodeTimer(int32_t decode_time_ms, int64_t now_ms) {
MutexLock lock(&mutex_); MutexLock lock(&mutex_);
codec_timer_->AddTiming(decode_time_ms, now_ms); codec_timer_->AddTiming(decode_time_ms, now_ms);
assert(decode_time_ms >= 0); RTC_DCHECK_GE(decode_time_ms, 0);
++num_decoded_frames_; ++num_decoded_frames_;
} }
@ -199,7 +199,7 @@ int64_t VCMTiming::RenderTimeMsInternal(uint32_t frame_timestamp,
int VCMTiming::RequiredDecodeTimeMs() const { int VCMTiming::RequiredDecodeTimeMs() const {
const int decode_time_ms = codec_timer_->RequiredDecodeTimeMs(); const int decode_time_ms = codec_timer_->RequiredDecodeTimeMs();
assert(decode_time_ms >= 0); RTC_DCHECK_GE(decode_time_ms, 0);
return decode_time_ms; return decode_time_ms;
} }

View File

@ -190,7 +190,7 @@ void ConfigureStream(int width,
float max_framerate, float max_framerate,
SpatialLayer* stream, SpatialLayer* stream,
int num_temporal_layers) { int num_temporal_layers) {
assert(stream); RTC_DCHECK(stream);
stream->width = width; stream->width = width;
stream->height = height; stream->height = height;
stream->maxBitrate = max_bitrate; stream->maxBitrate = max_bitrate;

View File

@ -82,8 +82,8 @@ size_t SctpPacket::Builder::bytes_remaining() const {
// The packet header (CommonHeader) hasn't been written yet: // The packet header (CommonHeader) hasn't been written yet:
return max_packet_size_ - kHeaderSize; return max_packet_size_ - kHeaderSize;
} else if (out_.size() > max_packet_size_) { } else if (out_.size() > max_packet_size_) {
RTC_DCHECK(false) << "Exceeded max size, data=" << out_.size() RTC_NOTREACHED() << "Exceeded max size, data=" << out_.size()
<< ", max_size=" << max_packet_size_; << ", max_size=" << max_packet_size_;
return 0; return 0;
} }
return max_packet_size_ - out_.size(); return max_packet_size_ - out_.size();

View File

@ -13,7 +13,7 @@
// Prevent the compiler from warning about an unused variable. For example: // Prevent the compiler from warning about an unused variable. For example:
// int result = DoSomething(); // int result = DoSomething();
// assert(result == 17); // RTC_DCHECK(result == 17);
// RTC_UNUSED(result); // RTC_UNUSED(result);
// Note: In most cases it is better to remove the unused variable rather than // Note: In most cases it is better to remove the unused variable rather than
// suppressing the compiler warning. // suppressing the compiler warning.

View File

@ -14,5 +14,8 @@ rtc_library("base64") {
"base64.cc", "base64.cc",
"base64.h", "base64.h",
] ]
deps = [ "../../system:rtc_export" ] deps = [
"../..:checks",
"../../system:rtc_export",
]
} }

View File

@ -19,6 +19,8 @@
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
#include "rtc_base/checks.h"
using std::vector; using std::vector;
namespace rtc { namespace rtc {
@ -95,7 +97,7 @@ bool Base64::IsBase64Encoded(const std::string& str) {
void Base64::EncodeFromArray(const void* data, void Base64::EncodeFromArray(const void* data,
size_t len, size_t len,
std::string* result) { std::string* result) {
assert(nullptr != result); RTC_DCHECK(result);
result->clear(); result->clear();
result->resize(((len + 2) / 3) * 4); result->resize(((len + 2) / 3) * 4);
const unsigned char* byte_data = static_cast<const unsigned char*>(data); const unsigned char* byte_data = static_cast<const unsigned char*>(data);
@ -223,15 +225,15 @@ bool Base64::DecodeFromArrayTemplate(const char* data,
DecodeFlags flags, DecodeFlags flags,
T* result, T* result,
size_t* data_used) { size_t* data_used) {
assert(nullptr != result); RTC_DCHECK(result);
assert(flags <= (DO_PARSE_MASK | DO_PAD_MASK | DO_TERM_MASK)); RTC_DCHECK_LE(flags, (DO_PARSE_MASK | DO_PAD_MASK | DO_TERM_MASK));
const DecodeFlags parse_flags = flags & DO_PARSE_MASK; const DecodeFlags parse_flags = flags & DO_PARSE_MASK;
const DecodeFlags pad_flags = flags & DO_PAD_MASK; const DecodeFlags pad_flags = flags & DO_PAD_MASK;
const DecodeFlags term_flags = flags & DO_TERM_MASK; const DecodeFlags term_flags = flags & DO_TERM_MASK;
assert(0 != parse_flags); RTC_DCHECK_NE(0, parse_flags);
assert(0 != pad_flags); RTC_DCHECK_NE(0, pad_flags);
assert(0 != term_flags); RTC_DCHECK_NE(0, term_flags);
result->clear(); result->clear();
result->reserve(len); result->reserve(len);

View File

@ -280,7 +280,7 @@ class DecoderIvfFileWriter : public test::FakeDecoder {
video_codec_type_ = VideoCodecType::kVideoCodecH264; video_codec_type_ = VideoCodecType::kVideoCodecH264;
} else { } else {
RTC_LOG(LS_ERROR) << "Unsupported video codec " << codec; RTC_LOG(LS_ERROR) << "Unsupported video codec " << codec;
RTC_DCHECK(false); RTC_NOTREACHED();
} }
} }
~DecoderIvfFileWriter() override { file_writer_->Close(); } ~DecoderIvfFileWriter() override { file_writer_->Close(); }

View File

@ -85,7 +85,7 @@ void InsertOrReplaceFieldTrialStringsInMap(
(*fieldtrial_map)[tokens[idx]] = tokens[idx + 1]; (*fieldtrial_map)[tokens[idx]] = tokens[idx + 1];
} }
} else { } else {
RTC_DCHECK(false) << "Invalid field trials string:" << trials_string; RTC_NOTREACHED() << "Invalid field trials string:" << trials_string;
} }
} }

View File

@ -54,7 +54,7 @@ class FrameGeneratorTest : public ::testing::Test {
protected: protected:
void WriteYuvFile(FILE* file, uint8_t y, uint8_t u, uint8_t v) { 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]); std::unique_ptr<uint8_t[]> plane_buffer(new uint8_t[y_size]);
memset(plane_buffer.get(), y, y_size); memset(plane_buffer.get(), y, y_size);
fwrite(plane_buffer.get(), 1, y_size, file); fwrite(plane_buffer.get(), 1, y_size, file);

View File

@ -20,8 +20,8 @@ namespace test {
GlxRenderer::GlxRenderer(size_t width, size_t height) GlxRenderer::GlxRenderer(size_t width, size_t height)
: width_(width), height_(height), display_(NULL), context_(NULL) { : width_(width), height_(height), display_(NULL), context_(NULL) {
assert(width > 0); RTC_DCHECK_GT(width, 0);
assert(height > 0); RTC_DCHECK_GT(height, 0);
} }
GlxRenderer::~GlxRenderer() { GlxRenderer::~GlxRenderer() {

View File

@ -83,7 +83,7 @@ class InterleavedRtpFileReader : public RtpFileReaderImpl {
} }
bool NextPacket(RtpPacket* packet) override { bool NextPacket(RtpPacket* packet) override {
assert(file_ != nullptr); RTC_DCHECK(file_);
packet->length = RtpPacket::kMaxPacketBufferSize; packet->length = RtpPacket::kMaxPacketBufferSize;
uint32_t len = 0; uint32_t len = 0;
TRY(ReadUint32(&len, file_)); TRY(ReadUint32(&len, file_));
@ -276,7 +276,7 @@ class PcapReader : public RtpFileReaderImpl {
if (result == kResultFail) { if (result == kResultFail) {
break; break;
} else if (result == kResultSuccess && packets_.size() == 1) { } else if (result == kResultSuccess && packets_.size() == 1) {
assert(stream_start_ms == 0); RTC_DCHECK_EQ(stream_start_ms, 0);
PacketIterator it = packets_.begin(); PacketIterator it = packets_.begin();
stream_start_ms = it->time_offset_ms; stream_start_ms = it->time_offset_ms;
it->time_offset_ms = 0; it->time_offset_ms = 0;
@ -330,9 +330,9 @@ class PcapReader : public RtpFileReaderImpl {
} }
virtual int NextPcap(uint8_t* data, uint32_t* length, uint32_t* time_ms) { virtual int NextPcap(uint8_t* data, uint32_t* length, uint32_t* time_ms) {
assert(data); RTC_DCHECK(data);
assert(length); RTC_DCHECK(length);
assert(time_ms); RTC_DCHECK(time_ms);
if (next_packet_it_ == packets_.end()) { if (next_packet_it_ == packets_.end()) {
return -1; return -1;
@ -409,7 +409,7 @@ class PcapReader : public RtpFileReaderImpl {
uint32_t stream_start_ms, uint32_t stream_start_ms,
uint32_t number, uint32_t number,
const std::set<uint32_t>& ssrc_filter) { 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_sec; // Timestamp seconds.
uint32_t ts_usec; // Timestamp microseconds. uint32_t ts_usec; // Timestamp microseconds.
@ -504,7 +504,7 @@ class PcapReader : public RtpFileReaderImpl {
} }
int ReadXxpIpHeader(RtpPacketMarker* marker) { int ReadXxpIpHeader(RtpPacketMarker* marker) {
assert(marker); RTC_DCHECK(marker);
uint16_t version; uint16_t version;
uint16_t length; uint16_t length;
@ -534,7 +534,7 @@ class PcapReader : public RtpFileReaderImpl {
// Skip remaining fields of IP header. // Skip remaining fields of IP header.
uint16_t header_length = (version & 0x0f00) >> (8 - 2); uint16_t header_length = (version & 0x0f00) >> (8 - 2);
assert(header_length >= kMinIpHeaderLength); RTC_DCHECK_GE(header_length, kMinIpHeaderLength);
TRY_PCAP(Skip(header_length - kMinIpHeaderLength)); TRY_PCAP(Skip(header_length - kMinIpHeaderLength));
protocol = protocol & 0x00ff; protocol = protocol & 0x00ff;

View File

@ -107,7 +107,7 @@ std::string TempFilename(const std::string& dir, const std::string& prefix) {
if (::GetTempFileNameW(rtc::ToUtf16(dir).c_str(), if (::GetTempFileNameW(rtc::ToUtf16(dir).c_str(),
rtc::ToUtf16(prefix).c_str(), 0, filename) != 0) rtc::ToUtf16(prefix).c_str(), 0, filename) != 0)
return rtc::ToUtf8(filename); return rtc::ToUtf8(filename);
assert(false); RTC_NOTREACHED();
return ""; return "";
#else #else
int len = dir.size() + prefix.size() + 2 + 6; int len = dir.size() + prefix.size() + 2 + 6;
@ -116,7 +116,7 @@ std::string TempFilename(const std::string& dir, const std::string& prefix) {
snprintf(tempname.get(), len, "%s/%sXXXXXX", dir.c_str(), prefix.c_str()); snprintf(tempname.get(), len, "%s/%sXXXXXX", dir.c_str(), prefix.c_str());
int fd = ::mkstemp(tempname.get()); int fd = ::mkstemp(tempname.get());
if (fd == -1) { if (fd == -1) {
assert(false); RTC_NOTREACHED();
return ""; return "";
} else { } else {
::close(fd); ::close(fd);

View File

@ -142,8 +142,8 @@ TEST_F(StatsEndToEndTest, GetStats) {
stats.rtcp_packet_type_counts.nack_requests != 0 || stats.rtcp_packet_type_counts.nack_requests != 0 ||
stats.rtcp_packet_type_counts.unique_nack_requests != 0; stats.rtcp_packet_type_counts.unique_nack_requests != 0;
assert(stats.current_payload_type == -1 || RTC_DCHECK(stats.current_payload_type == -1 ||
stats.current_payload_type == kFakeVideoSendPayloadType); stats.current_payload_type == kFakeVideoSendPayloadType);
receive_stats_filled_["IncomingPayloadType"] |= receive_stats_filled_["IncomingPayloadType"] |=
stats.current_payload_type == kFakeVideoSendPayloadType; stats.current_payload_type == kFakeVideoSendPayloadType;
} }

View File

@ -601,7 +601,7 @@ bool VideoAnalyzer::AllFramesRecordedLocked() {
bool VideoAnalyzer::FrameProcessed() { bool VideoAnalyzer::FrameProcessed() {
MutexLock lock(&comparison_lock_); MutexLock lock(&comparison_lock_);
++frames_processed_; ++frames_processed_;
assert(frames_processed_ <= frames_to_process_); RTC_DCHECK_LE(frames_processed_, frames_to_process_);
return frames_processed_ == frames_to_process_ || return frames_processed_ == frames_to_process_ ||
(clock_->CurrentTime() > test_end_ && comparisons_.empty()); (clock_->CurrentTime() > test_end_ && comparisons_.empty());
} }