diff --git a/webrtc/common_audio/fir_filter.cc b/webrtc/common_audio/fir_filter.cc index ed1f1bbfb8..d0a2d2f3ee 100644 --- a/webrtc/common_audio/fir_filter.cc +++ b/webrtc/common_audio/fir_filter.cc @@ -10,11 +10,11 @@ #include "webrtc/common_audio/fir_filter.h" -#include #include #include +#include "webrtc/base/checks.h" #include "webrtc/common_audio/fir_filter_neon.h" #include "webrtc/common_audio/fir_filter_sse.h" #include "webrtc/system_wrappers/include/cpu_features_wrapper.h" @@ -39,7 +39,7 @@ FIRFilter* FIRFilter::Create(const float* coefficients, size_t coefficients_length, size_t max_input_length) { if (!coefficients || coefficients_length <= 0 || max_input_length <= 0) { - assert(false); + RTC_NOTREACHED(); return NULL; } @@ -80,7 +80,7 @@ FIRFilterC::FIRFilterC(const float* coefficients, size_t coefficients_length) } void FIRFilterC::Filter(const float* in, size_t length, float* out) { - assert(length > 0); + RTC_DCHECK_GT(length, 0); // Convolves the input signal |in| with the filter kernel |coefficients_| // taking into account the previous state. diff --git a/webrtc/common_audio/fir_filter_neon.cc b/webrtc/common_audio/fir_filter_neon.cc index a81562655b..54e58d0d7a 100644 --- a/webrtc/common_audio/fir_filter_neon.cc +++ b/webrtc/common_audio/fir_filter_neon.cc @@ -11,9 +11,9 @@ #include "webrtc/common_audio/fir_filter_neon.h" #include -#include #include +#include "webrtc/base/checks.h" #include "webrtc/system_wrappers/include/aligned_malloc.h" namespace webrtc { @@ -43,7 +43,7 @@ FIRFilterNEON::FIRFilterNEON(const float* coefficients, } void FIRFilterNEON::Filter(const float* in, size_t length, float* out) { - assert(length > 0); + RTC_DCHECK_GT(length, 0); memcpy(&state_[state_length_], in, length * sizeof(*in)); diff --git a/webrtc/common_audio/fir_filter_sse.cc b/webrtc/common_audio/fir_filter_sse.cc index 89abb00ba4..308eeb676f 100644 --- a/webrtc/common_audio/fir_filter_sse.cc +++ b/webrtc/common_audio/fir_filter_sse.cc @@ -10,11 +10,11 @@ #include "webrtc/common_audio/fir_filter_sse.h" -#include #include #include #include +#include "webrtc/base/checks.h" #include "webrtc/system_wrappers/include/aligned_malloc.h" namespace webrtc { @@ -44,7 +44,7 @@ FIRFilterSSE2::FIRFilterSSE2(const float* coefficients, } void FIRFilterSSE2::Filter(const float* in, size_t length, float* out) { - assert(length > 0); + RTC_DCHECK_GT(length, 0); memcpy(&state_[state_length_], in, length * sizeof(*in)); diff --git a/webrtc/common_audio/resampler/sinc_resampler.cc b/webrtc/common_audio/resampler/sinc_resampler.cc index c8bc15a362..651bbf6954 100644 --- a/webrtc/common_audio/resampler/sinc_resampler.cc +++ b/webrtc/common_audio/resampler/sinc_resampler.cc @@ -87,12 +87,12 @@ #include "webrtc/common_audio/resampler/sinc_resampler.h" -#include #include #include #include +#include "webrtc/base/checks.h" #include "webrtc/system_wrappers/include/cpu_features_wrapper.h" #include "webrtc/typedefs.h" @@ -118,6 +118,8 @@ double SincScaleFactor(double io_ratio) { } // namespace +const size_t SincResampler::kKernelSize; + // If we know the minimum architecture at compile time, avoid CPU detection. #if defined(WEBRTC_ARCH_X86_FAMILY) #if defined(__SSE2__) @@ -165,11 +167,11 @@ SincResampler::SincResampler(double io_sample_rate_ratio, r2_(input_buffer_.get() + kKernelSize / 2) { #if defined(WEBRTC_CPU_DETECTION) InitializeCPUSpecificFeatures(); - assert(convolve_proc_); + RTC_DCHECK(convolve_proc_); #endif - assert(request_frames_ > 0); + RTC_DCHECK_GT(request_frames_, 0); Flush(); - assert(block_size_ > kKernelSize); + RTC_DCHECK_GT(block_size_, kKernelSize); memset(kernel_storage_.get(), 0, sizeof(*kernel_storage_.get()) * kKernelStorageSize); @@ -192,11 +194,11 @@ void SincResampler::UpdateRegions(bool second_load) { block_size_ = r4_ - r2_; // r1_ at the beginning of the buffer. - assert(r1_ == input_buffer_.get()); + RTC_DCHECK_EQ(r1_, input_buffer_.get()); // r1_ left of r2_, r4_ left of r3_ and size correct. - assert(r2_ - r1_ == r4_ - r3_); + RTC_DCHECK_EQ(r2_ - r1_, r4_ - r3_); // r2_ left of r3. - assert(r2_ < r3_); + RTC_DCHECK_LT(r2_, r3_); } void SincResampler::InitializeKernel() { @@ -283,7 +285,7 @@ void SincResampler::Resample(size_t frames, float* destination) { for (int i = static_cast( ceil((block_size_ - virtual_source_idx_) / current_io_ratio)); i > 0; --i) { - assert(virtual_source_idx_ < block_size_); + RTC_DCHECK_LT(virtual_source_idx_, block_size_); // |virtual_source_idx_| lies in between two kernel offsets so figure out // what they are. @@ -301,8 +303,8 @@ void SincResampler::Resample(size_t frames, float* destination) { // Ensure |k1|, |k2| are 16-byte aligned for SIMD usage. Should always be // true so long as kKernelSize is a multiple of 16. - assert(0u == (reinterpret_cast(k1) & 0x0F)); - assert(0u == (reinterpret_cast(k2) & 0x0F)); + RTC_DCHECK_EQ(0, reinterpret_cast(k1) % 16); + RTC_DCHECK_EQ(0, reinterpret_cast(k2) % 16); // Initialize input pointer based on quantized |virtual_source_idx_|. const float* const input_ptr = r1_ + source_idx; diff --git a/webrtc/common_types.h b/webrtc/common_types.h index 3a0d6d8cc5..2988bf9f41 100644 --- a/webrtc/common_types.h +++ b/webrtc/common_types.h @@ -11,13 +11,13 @@ #ifndef WEBRTC_COMMON_TYPES_H_ #define WEBRTC_COMMON_TYPES_H_ -#include #include #include #include #include +#include "webrtc/base/checks.h" #include "webrtc/base/optional.h" #include "webrtc/common_video/rotation.h" #include "webrtc/typedefs.h" @@ -805,13 +805,13 @@ struct RtpPacketCounter { } void Subtract(const RtpPacketCounter& other) { - assert(header_bytes >= other.header_bytes); + RTC_DCHECK_GE(header_bytes, other.header_bytes); header_bytes -= other.header_bytes; - assert(payload_bytes >= other.payload_bytes); + RTC_DCHECK_GE(payload_bytes, other.payload_bytes); payload_bytes -= other.payload_bytes; - assert(padding_bytes >= other.padding_bytes); + RTC_DCHECK_GE(padding_bytes, other.padding_bytes); padding_bytes -= other.padding_bytes; - assert(packets >= other.packets); + RTC_DCHECK_GE(packets, other.packets); packets -= other.packets; } diff --git a/webrtc/common_video/libyuv/webrtc_libyuv.cc b/webrtc/common_video/libyuv/webrtc_libyuv.cc index dd5863dac6..6bfb1799ee 100644 --- a/webrtc/common_video/libyuv/webrtc_libyuv.cc +++ b/webrtc/common_video/libyuv/webrtc_libyuv.cc @@ -10,9 +10,10 @@ #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" -#include #include +#include "webrtc/base/checks.h" + // NOTE(ajm): Path provided by gyp. #include "libyuv.h" // NOLINT @@ -49,14 +50,14 @@ VideoType RawVideoTypeToCommonVideoVideoType(RawVideoType type) { case kVideoMJPEG: return kMJPG; default: - assert(false); + RTC_NOTREACHED(); } return kUnknown; } size_t CalcBufferSize(VideoType type, int width, int height) { - assert(width >= 0); - assert(height >= 0); + RTC_DCHECK_GE(width, 0); + RTC_DCHECK_GE(height, 0); size_t buffer_size = 0; switch (type) { case kI420: @@ -84,7 +85,7 @@ size_t CalcBufferSize(VideoType type, int width, int height) { buffer_size = width * height * 4; break; default: - assert(false); + RTC_NOTREACHED(); break; } return buffer_size; @@ -135,7 +136,7 @@ int PrintVideoFrame(const VideoFrame& frame, FILE* file) { int ExtractBuffer(const rtc::scoped_refptr& input_frame, size_t size, uint8_t* buffer) { - assert(buffer); + RTC_DCHECK(buffer); if (!input_frame) return -1; int width = input_frame->width(); @@ -200,7 +201,7 @@ libyuv::RotationMode ConvertRotationMode(VideoRotation rotation) { case kVideoRotation_270: return libyuv::kRotate270; } - assert(false); + RTC_NOTREACHED(); return libyuv::kRotate0; } @@ -238,7 +239,7 @@ int ConvertVideoType(VideoType video_type) { case kARGB1555: return libyuv::FOURCC_RGBO; } - assert(false); + RTC_NOTREACHED(); return libyuv::FOURCC_ANY; } diff --git a/webrtc/common_video/video_render_frames.cc b/webrtc/common_video/video_render_frames.cc index 5cec386bb2..c6b109c2e9 100644 --- a/webrtc/common_video/video_render_frames.cc +++ b/webrtc/common_video/video_render_frames.cc @@ -10,8 +10,6 @@ #include "webrtc/common_video/video_render_frames.h" -#include - #include "webrtc/base/logging.h" #include "webrtc/base/timeutils.h" #include "webrtc/modules/include/module_common_types.h" diff --git a/webrtc/modules/audio_device/dummy/file_audio_device.cc b/webrtc/modules/audio_device/dummy/file_audio_device.cc index c1ac98f6d4..3dcb1384e7 100644 --- a/webrtc/modules/audio_device/dummy/file_audio_device.cc +++ b/webrtc/modules/audio_device/dummy/file_audio_device.cc @@ -7,6 +7,8 @@ * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ + +#include "webrtc/base/checks.h" #include "webrtc/base/logging.h" #include "webrtc/base/platform_thread.h" #include "webrtc/modules/audio_device/dummy/file_audio_device.h" @@ -492,7 +494,7 @@ bool FileAudioDevice::PlayThreadProcess() _critSect.Enter(); _playoutFramesLeft = _ptrAudioBuffer->GetPlayoutData(_playoutBuffer); - assert(_playoutFramesLeft == _playoutFramesIn10MS); + RTC_DCHECK_EQ(_playoutFramesIn10MS, _playoutFramesLeft); if (_outputFile.is_open()) { _outputFile.Write(_playoutBuffer, kPlayoutBufferSize); } diff --git a/webrtc/modules/desktop_capture/mouse_cursor_monitor_x11.cc b/webrtc/modules/desktop_capture/mouse_cursor_monitor_x11.cc index e58e7c196f..64ae44d9d3 100644 --- a/webrtc/modules/desktop_capture/mouse_cursor_monitor_x11.cc +++ b/webrtc/modules/desktop_capture/mouse_cursor_monitor_x11.cc @@ -131,8 +131,8 @@ MouseCursorMonitorX11::~MouseCursorMonitorX11() { void MouseCursorMonitorX11::Init(Callback* callback, Mode mode) { // Init can be called only once per instance of MouseCursorMonitor. - assert(!callback_); - assert(callback); + RTC_DCHECK(!callback_); + RTC_DCHECK(callback); callback_ = callback; mode_ = mode; @@ -152,7 +152,7 @@ void MouseCursorMonitorX11::Init(Callback* callback, Mode mode) { } void MouseCursorMonitorX11::Capture() { - assert(callback_); + RTC_DCHECK(callback_); // Process X11 events in case XFixes has sent cursor notification. x_display_->ProcessPendingXEvents(); @@ -204,7 +204,7 @@ bool MouseCursorMonitorX11::HandleXEvent(const XEvent& event) { } void MouseCursorMonitorX11::CaptureCursor() { - assert(have_xfixes_); + RTC_DCHECK(have_xfixes_); XFixesCursorImage* img; { diff --git a/webrtc/modules/desktop_capture/screen_capturer_x11.cc b/webrtc/modules/desktop_capture/screen_capturer_x11.cc index da58e647a4..a6f4f91838 100644 --- a/webrtc/modules/desktop_capture/screen_capturer_x11.cc +++ b/webrtc/modules/desktop_capture/screen_capturer_x11.cc @@ -292,7 +292,7 @@ bool ScreenCapturerLinux::HandleXEvent(const XEvent& event) { std::unique_ptr ScreenCapturerLinux::CaptureScreen() { std::unique_ptr frame = queue_.current_frame()->Share(); - assert(x_server_pixel_buffer_.window_size().equals(frame->size())); + RTC_DCHECK(x_server_pixel_buffer_.window_size().equals(frame->size())); // Pass the screen size to the helper, so it can clip the invalid region if it // expands that region to a grid. diff --git a/webrtc/test/frame_generator.cc b/webrtc/test/frame_generator.cc index b6307f94c1..94abcd1242 100644 --- a/webrtc/test/frame_generator.cc +++ b/webrtc/test/frame_generator.cc @@ -89,9 +89,9 @@ class YuvFileGenerator : public FrameGenerator { frame_buffer_(new uint8_t[frame_size_]), frame_display_count_(frame_repeat_count), current_display_count_(0) { - assert(width > 0); - assert(height > 0); - assert(frame_repeat_count > 0); + RTC_DCHECK_GT(width, 0); + RTC_DCHECK_GT(height, 0); + RTC_DCHECK_GT(frame_repeat_count, 0); } virtual ~YuvFileGenerator() { @@ -287,7 +287,7 @@ FrameGenerator* FrameGenerator::CreateFromYuvFile( size_t width, size_t height, int frame_repeat_count) { - assert(!filenames.empty()); + RTC_DCHECK(!filenames.empty()); std::vector files; for (const std::string& filename : filenames) { FILE* file = fopen(filename.c_str(), "rb"); @@ -307,7 +307,7 @@ FrameGenerator* FrameGenerator::CreateScrollingInputFromYuvFiles( size_t target_height, int64_t scroll_time_ms, int64_t pause_time_ms) { - assert(!filenames.empty()); + RTC_DCHECK(!filenames.empty()); std::vector files; for (const std::string& filename : filenames) { FILE* file = fopen(filename.c_str(), "rb"); diff --git a/webrtc/test/gl/gl_renderer.cc b/webrtc/test/gl/gl_renderer.cc index 8ce373b1c1..964a6884a0 100644 --- a/webrtc/test/gl/gl_renderer.cc +++ b/webrtc/test/gl/gl_renderer.cc @@ -12,6 +12,7 @@ #include +#include "webrtc/base/checks.h" #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" namespace webrtc { @@ -21,7 +22,7 @@ GlRenderer::GlRenderer() : is_init_(false), buffer_(NULL), width_(0), height_(0) {} void GlRenderer::Init() { - assert(!is_init_); + RTC_DCHECK(!is_init_); is_init_ = true; glGenTextures(1, &texture_); @@ -52,7 +53,7 @@ void GlRenderer::ResizeViewport(size_t width, size_t height) { } void GlRenderer::ResizeVideo(size_t width, size_t height) { - assert(is_init_); + RTC_DCHECK(is_init_); width_ = width; height_ = height; @@ -60,7 +61,7 @@ void GlRenderer::ResizeVideo(size_t width, size_t height) { delete[] buffer_; buffer_ = new uint8_t[buffer_size_]; - assert(buffer_ != NULL); + RTC_DCHECK(buffer_); memset(buffer_, 0, buffer_size_); glBindTexture(GL_TEXTURE_2D, texture_); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); @@ -70,7 +71,7 @@ void GlRenderer::ResizeVideo(size_t width, size_t height) { } void GlRenderer::OnFrame(const webrtc::VideoFrame& frame) { - assert(is_init_); + RTC_DCHECK(is_init_); if (static_cast(frame.width()) != width_ || static_cast(frame.height()) != height_) { diff --git a/webrtc/test/win/d3d_renderer.cc b/webrtc/test/win/d3d_renderer.cc index e09b32d28e..7c344ba0b3 100644 --- a/webrtc/test/win/d3d_renderer.cc +++ b/webrtc/test/win/d3d_renderer.cc @@ -9,6 +9,7 @@ */ #include "webrtc/test/win/d3d_renderer.h" +#include "webrtc/base/checks.h" #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" namespace webrtc { @@ -37,8 +38,8 @@ D3dRenderer::D3dRenderer(size_t width, size_t height) d3d_device_(NULL), texture_(NULL), vertex_buffer_(NULL) { - assert(width > 0); - assert(height > 0); + RTC_DCHECK_GT(width, 0); + RTC_DCHECK_GT(height, 0); } D3dRenderer::~D3dRenderer() { Destroy(); } @@ -61,7 +62,7 @@ void D3dRenderer::Destroy() { if (hwnd_ != NULL) { DestroyWindow(hwnd_); - assert(!IsWindow(hwnd_)); + RTC_DCHECK(!IsWindow(hwnd_)); hwnd_ = NULL; } }