Skip to content

Commit

Permalink
Prepare to rename RTC_NOTREACHED to RTC_DCHECK_NOTREACHED
Browse files Browse the repository at this point in the history
Add implementation of RTC_DCHECK_NOTREACHED equal to the RTC_NOTREACHED.
The new macros will replace the old one when old one's usage will be
removed. The idea of the renaming to provide a clear signal that this
is debug build only macros and will be stripped in the production build.

Bug: webrtc:9065
Change-Id: I4c35d8b03e74a4b3fd1ae75dba2f9c05643101db
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/237802
Reviewed-by: Harald Alvestrand <[email protected]>
Commit-Queue: Artem Titov <[email protected]>
Cr-Commit-Position: refs/heads/main@{#35348}
  • Loading branch information
Artem Titov authored and WebRTC LUCI CQ committed Nov 15, 2021
1 parent f5ea3b9 commit d325196
Show file tree
Hide file tree
Showing 263 changed files with 604 additions and 583 deletions.
2 changes: 1 addition & 1 deletion api/audio/channel_layout.cc
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ const char* ChannelLayoutToString(ChannelLayout layout) {
case CHANNEL_LAYOUT_BITSTREAM:
return "BITSTREAM";
}
RTC_NOTREACHED() << "Invalid channel layout provided: " << layout;
RTC_DCHECK_NOTREACHED() << "Invalid channel layout provided: " << layout;
return "";
}

Expand Down
2 changes: 1 addition & 1 deletion api/audio_codecs/audio_decoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ AudioDecoder::SpeechType AudioDecoder::ConvertSpeechType(int16_t type) {
case 2:
return kComfortNoise;
default:
RTC_NOTREACHED();
RTC_DCHECK_NOTREACHED();
return kSpeech;
}
}
Expand Down
2 changes: 1 addition & 1 deletion api/audio_codecs/audio_encoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void AudioEncoder::OnReceivedUplinkPacketLossFraction(

void AudioEncoder::OnReceivedUplinkRecoverablePacketLossFraction(
float uplink_recoverable_packet_loss_fraction) {
RTC_NOTREACHED();
RTC_DCHECK_NOTREACHED();
}

void AudioEncoder::OnReceivedTargetAudioBitrate(int target_audio_bitrate_bps) {
Expand Down
2 changes: 1 addition & 1 deletion api/media_stream_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ class AudioTrackSinkInterface {
int sample_rate,
size_t number_of_channels,
size_t number_of_frames) {
RTC_NOTREACHED() << "This method must be overridden, or not used.";
RTC_DCHECK_NOTREACHED() << "This method must be overridden, or not used.";
}

// In this method, `absolute_capture_timestamp_ms`, when available, is
Expand Down
2 changes: 1 addition & 1 deletion api/media_types.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ std::string MediaTypeToString(MediaType type) {
return kMediaTypeData;
case MEDIA_TYPE_UNSUPPORTED:
// Unsupported media stores the m=<mediatype> differently.
RTC_NOTREACHED();
RTC_DCHECK_NOTREACHED();
return "";
}
RTC_CHECK_NOTREACHED();
Expand Down
2 changes: 1 addition & 1 deletion api/packet_socket_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class RTC_EXPORT PacketSocketFactory {
virtual AsyncResolverInterface* CreateAsyncResolver() {
// Default implementation, so that downstream users can remove this
// immediately after changing to CreateAsyncDnsResolver
RTC_NOTREACHED();
RTC_DCHECK_NOTREACHED();
return nullptr;
}

Expand Down
10 changes: 6 additions & 4 deletions api/rtp_transceiver_interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,19 @@ void RtpTransceiverInterface::Stop() {
}

RTCError RtpTransceiverInterface::StopStandard() {
RTC_NOTREACHED() << "DEBUG: RtpTransceiverInterface::StopStandard called";
RTC_DCHECK_NOTREACHED()
<< "DEBUG: RtpTransceiverInterface::StopStandard called";
return RTCError::OK();
}

void RtpTransceiverInterface::StopInternal() {
RTC_NOTREACHED() << "DEBUG: RtpTransceiverInterface::StopInternal called";
RTC_DCHECK_NOTREACHED()
<< "DEBUG: RtpTransceiverInterface::StopInternal called";
}

RTCError RtpTransceiverInterface::SetCodecPreferences(
rtc::ArrayView<RtpCodecCapability>) {
RTC_NOTREACHED() << "Not implemented";
RTC_DCHECK_NOTREACHED() << "Not implemented";
return {};
}

Expand Down Expand Up @@ -78,7 +80,7 @@ void RtpTransceiverInterface::SetDirection(

RTCError RtpTransceiverInterface::SetDirectionWithError(
RtpTransceiverDirection new_direction) {
RTC_NOTREACHED() << "Default implementation called";
RTC_DCHECK_NOTREACHED() << "Default implementation called";
return RTCError::OK();
}

Expand Down
6 changes: 3 additions & 3 deletions api/stats_types.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const char* InternalTypeToString(StatsReport::StatsType type) {
case StatsReport::kStatsReportTypeDataChannel:
return "datachannel";
}
RTC_NOTREACHED();
RTC_DCHECK_NOTREACHED();
return nullptr;
}

Expand Down Expand Up @@ -291,7 +291,7 @@ bool StatsReport::Value::Equals(const Value& other) const {
case kId:
return (*value_.id_)->Equals(*other.value_.id_);
}
RTC_NOTREACHED();
RTC_DCHECK_NOTREACHED();
return false;
}

Expand Down Expand Up @@ -676,7 +676,7 @@ std::string StatsReport::Value::ToString() const {
case kId:
return (*value_.id_)->ToString();
}
RTC_NOTREACHED();
RTC_DCHECK_NOTREACHED();
return std::string();
}

Expand Down
2 changes: 1 addition & 1 deletion api/test/frame_generator_interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const char* FrameGeneratorInterface::OutputTypeToString(
case OutputType::kNV12:
return "NV12";
default:
RTC_NOTREACHED();
RTC_DCHECK_NOTREACHED();
}
}

Expand Down
2 changes: 1 addition & 1 deletion api/test/video/function_video_encoder_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class FunctionVideoEncoderFactory final : public VideoEncoderFactory {

// Unused by tests.
std::vector<SdpVideoFormat> GetSupportedFormats() const override {
RTC_NOTREACHED();
RTC_DCHECK_NOTREACHED();
return {};
}

Expand Down
2 changes: 1 addition & 1 deletion api/transport/rtp/dependency_descriptor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ absl::InlinedVector<DecodeTargetIndication, 10> StringToDecodeTargetIndications(
indication = DecodeTargetIndication::kSwitch;
break;
default:
RTC_NOTREACHED();
RTC_DCHECK_NOTREACHED();
}
dtis.push_back(indication);
}
Expand Down
2 changes: 1 addition & 1 deletion api/transport/stun.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ bool LengthValid(int type, int length) {
// Return an arbitrary restriction for all other types.
return length <= kTheoreticalMaximumAttributeLength;
}
RTC_NOTREACHED();
RTC_DCHECK_NOTREACHED();
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion api/video/i010_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ rtc::scoped_refptr<I010Buffer> I010Buffer::Rotate(
switch (rotation) {
// This case is covered by the early return.
case webrtc::kVideoRotation_0:
RTC_NOTREACHED();
RTC_DCHECK_NOTREACHED();
break;
case webrtc::kVideoRotation_90:
dest_x = src.height() - y - 1;
Expand Down
2 changes: 1 addition & 1 deletion api/video/rtp_video_frame_assembler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ std::unique_ptr<VideoRtpDepacketizer> CreateDepacketizer(
case RtpVideoFrameAssembler::kGeneric:
return std::make_unique<VideoRtpDepacketizerGeneric>();
}
RTC_NOTREACHED();
RTC_DCHECK_NOTREACHED();
return nullptr;
}
} // namespace
Expand Down
2 changes: 1 addition & 1 deletion api/video/rtp_video_frame_assembler_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class PacketBuilder {
return kVideoCodecGeneric;
}
}
RTC_NOTREACHED();
RTC_DCHECK_NOTREACHED();
return absl::nullopt;
}

Expand Down
2 changes: 1 addition & 1 deletion api/video/video_frame_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const char* VideoFrameBufferTypeToString(VideoFrameBuffer::Type type) {
case VideoFrameBuffer::Type::kNV12:
return "kNV12";
default:
RTC_NOTREACHED();
RTC_DCHECK_NOTREACHED();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,13 @@ TEST_F(VideoDecoderSoftwareFallbackWrapperTest,
int32_t Decoded(VideoFrame& decodedImage) override { return 0; }
int32_t Decoded(webrtc::VideoFrame& decodedImage,
int64_t decode_time_ms) override {
RTC_NOTREACHED();
RTC_DCHECK_NOTREACHED();
return -1;
}
void Decoded(webrtc::VideoFrame& decodedImage,
absl::optional<int32_t> decode_time_ms,
absl::optional<uint8_t> qp) override {
RTC_NOTREACHED();
RTC_DCHECK_NOTREACHED();
}
} callback;

Expand Down
4 changes: 2 additions & 2 deletions api/video_codecs/video_decoder_software_fallback_wrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ int32_t VideoDecoderSoftwareFallbackWrapper::Decode(
return fallback_decoder_->Decode(input_image, missing_frames,
render_time_ms);
default:
RTC_NOTREACHED();
RTC_DCHECK_NOTREACHED();
return WEBRTC_VIDEO_CODEC_ERROR;
}
}
Expand All @@ -240,7 +240,7 @@ int32_t VideoDecoderSoftwareFallbackWrapper::Release() {
status = WEBRTC_VIDEO_CODEC_OK;
break;
default:
RTC_NOTREACHED();
RTC_DCHECK_NOTREACHED();
status = WEBRTC_VIDEO_CODEC_ERROR;
}

Expand Down
9 changes: 5 additions & 4 deletions api/video_codecs/video_encoder_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,23 +97,24 @@ void VideoEncoderConfig::EncoderSpecificSettings::FillEncoderSpecificSettings(
} else if (codec->codecType == kVideoCodecVP9) {
FillVideoCodecVp9(codec->VP9());
} else {
RTC_NOTREACHED() << "Encoder specifics set/used for unknown codec type.";
RTC_DCHECK_NOTREACHED()
<< "Encoder specifics set/used for unknown codec type.";
}
}

void VideoEncoderConfig::EncoderSpecificSettings::FillVideoCodecH264(
VideoCodecH264* h264_settings) const {
RTC_NOTREACHED();
RTC_DCHECK_NOTREACHED();
}

void VideoEncoderConfig::EncoderSpecificSettings::FillVideoCodecVp8(
VideoCodecVP8* vp8_settings) const {
RTC_NOTREACHED();
RTC_DCHECK_NOTREACHED();
}

void VideoEncoderConfig::EncoderSpecificSettings::FillVideoCodecVp9(
VideoCodecVP9* vp9_settings) const {
RTC_NOTREACHED();
RTC_DCHECK_NOTREACHED();
}

VideoEncoderConfig::H264EncoderSpecificSettings::H264EncoderSpecificSettings(
Expand Down
4 changes: 2 additions & 2 deletions api/video_codecs/vp8_frame_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ bool Vp8FrameConfig::References(Buffer buffer) const {
case Buffer::kCount:
break;
}
RTC_NOTREACHED();
RTC_DCHECK_NOTREACHED();
return false;
}

Expand All @@ -71,7 +71,7 @@ bool Vp8FrameConfig::Updates(Buffer buffer) const {
case Buffer::kCount:
break;
}
RTC_NOTREACHED();
RTC_DCHECK_NOTREACHED();
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion audio/channel_receive.cc
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@ void ChannelReceive::SetDepacketizerToDecoderFrameTransformer(
// Depending on when the channel is created, the transformer might be set
// twice. Don't replace the delegate if it was already initialized.
if (!frame_transformer || frame_transformer_delegate_) {
RTC_NOTREACHED() << "Not setting the transformer?";
RTC_DCHECK_NOTREACHED() << "Not setting the transformer?";
return;
}

Expand Down
8 changes: 4 additions & 4 deletions audio/utility/audio_frame_operations.cc
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ void AudioFrameOperations::DownmixChannels(const int16_t* src_audio,
return;
}

RTC_NOTREACHED() << "src_channels: " << src_channels
<< ", dst_channels: " << dst_channels;
RTC_DCHECK_NOTREACHED() << "src_channels: " << src_channels
<< ", dst_channels: " << dst_channels;
}

void AudioFrameOperations::DownmixChannels(size_t dst_channels,
Expand All @@ -149,8 +149,8 @@ void AudioFrameOperations::DownmixChannels(size_t dst_channels,
int err = QuadToStereo(frame);
RTC_DCHECK_EQ(err, 0);
} else {
RTC_NOTREACHED() << "src_channels: " << frame->num_channels_
<< ", dst_channels: " << dst_channels;
RTC_DCHECK_NOTREACHED() << "src_channels: " << frame->num_channels_
<< ", dst_channels: " << dst_channels;
}
}

Expand Down
4 changes: 2 additions & 2 deletions call/adaptation/video_stream_adapter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ VideoStreamAdapter::RestrictionsOrState VideoStreamAdapter::DecreaseFramerate(
max_frame_rate = balanced_settings_.MinFps(input_state.video_codec_type(),
frame_size_pixels);
} else {
RTC_NOTREACHED();
RTC_DCHECK_NOTREACHED();
max_frame_rate = GetLowerFrameRateThan(input_state.frames_per_second());
}
if (!CanDecreaseFrameRateTo(max_frame_rate,
Expand Down Expand Up @@ -584,7 +584,7 @@ VideoStreamAdapter::RestrictionsOrState VideoStreamAdapter::IncreaseFramerate(
return Adaptation::Status::kLimitReached;
}
} else {
RTC_NOTREACHED();
RTC_DCHECK_NOTREACHED();
max_frame_rate = GetHigherFrameRateThan(input_state.frames_per_second());
}
if (current_restrictions.counters.fps_adaptations == 1) {
Expand Down
2 changes: 1 addition & 1 deletion call/rtp_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ uint32_t FindAssociatedSsrc(uint32_t ssrc,
if (ssrcs[i] == ssrc)
return associated_ssrcs[i];
}
RTC_NOTREACHED();
RTC_DCHECK_NOTREACHED();
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion call/rtp_payload_params.cc
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ void RtpPayloadParams::SetGeneric(const CodecSpecificInfo* codec_specific_info,
case VideoCodecType::kVideoCodecMultiplex:
return;
}
RTC_NOTREACHED() << "Unsupported codec.";
RTC_DCHECK_NOTREACHED() << "Unsupported codec.";
}

void RtpPayloadParams::GenericToGeneric(int64_t shared_frame_id,
Expand Down
2 changes: 1 addition & 1 deletion common_audio/fir_filter_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ FIRFilter* CreateFirFilter(const float* coefficients,
size_t coefficients_length,
size_t max_input_length) {
if (!coefficients || coefficients_length <= 0 || max_input_length <= 0) {
RTC_NOTREACHED();
RTC_DCHECK_NOTREACHED();
return nullptr;
}

Expand Down
2 changes: 1 addition & 1 deletion common_audio/vad/vad.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class VadImpl final : public Vad {
case 1:
return kActive;
default:
RTC_NOTREACHED() << "WebRtcVad_Process returned an error.";
RTC_DCHECK_NOTREACHED() << "WebRtcVad_Process returned an error.";
return kError;
}
}
Expand Down
2 changes: 1 addition & 1 deletion common_video/h264/pps_parser_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void WritePps(const PpsParser::PpsState& pps,
break;
}
default:
RTC_NOTREACHED();
RTC_DCHECK_NOTREACHED();
}
}

Expand Down
4 changes: 2 additions & 2 deletions common_video/libyuv/webrtc_libyuv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ size_t CalcBufferSize(VideoType type, int width, int height) {
buffer_size = width * height * 4;
break;
default:
RTC_NOTREACHED();
RTC_DCHECK_NOTREACHED();
break;
}
return buffer_size;
Expand Down Expand Up @@ -106,7 +106,7 @@ int ConvertVideoType(VideoType video_type) {
case VideoType::kBGRA:
return libyuv::FOURCC_BGRA;
}
RTC_NOTREACHED();
RTC_DCHECK_NOTREACHED();
return libyuv::FOURCC_ANY;
}

Expand Down
2 changes: 1 addition & 1 deletion common_video/video_frame_buffer_pool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ bool HasOneRef(const rtc::scoped_refptr<VideoFrameBuffer>& buffer) {
->HasOneRef();
}
default:
RTC_NOTREACHED();
RTC_DCHECK_NOTREACHED();
}
return false;
}
Expand Down
Loading

0 comments on commit d325196

Please sign in to comment.