diff --git a/BUILD.gn b/BUILD.gn index 698e4cff70..adb78df424 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -265,6 +265,10 @@ config("common_config") { defines += [ "WEBRTC_USE_H264" ] } + if (rtc_use_absl_mutex) { + defines += [ "WEBRTC_ABSL_MUTEX" ] + } + if (rtc_disable_logging) { defines += [ "RTC_DISABLE_LOGGING" ] } diff --git a/rtc_base/synchronization/BUILD.gn b/rtc_base/synchronization/BUILD.gn index b1942e7815..84ed31ff5a 100644 --- a/rtc_base/synchronization/BUILD.gn +++ b/rtc_base/synchronization/BUILD.gn @@ -25,18 +25,23 @@ rtc_library("mutex") { sources = [ "mutex.cc", "mutex.h", - "mutex_abseil.h", "mutex_critical_section.h", "mutex_pthread.h", ] + if (rtc_use_absl_mutex) { + sources += [ "mutex_abseil.h" ] + } + deps = [ ":yield", "..:checks", "..:macromagic", "../system:unused", "//third_party/abseil-cpp/absl/base:core_headers", - "//third_party/abseil-cpp/absl/synchronization", ] + if (rtc_use_absl_mutex) { + deps += [ "//third_party/abseil-cpp/absl/synchronization" ] + } } rtc_library("rw_lock_wrapper") { diff --git a/rtc_base/synchronization/mutex.h b/rtc_base/synchronization/mutex.h index bfcadc2139..7980dae9d7 100644 --- a/rtc_base/synchronization/mutex.h +++ b/rtc_base/synchronization/mutex.h @@ -19,7 +19,7 @@ #include "rtc_base/thread_annotations.h" #if defined(WEBRTC_ABSL_MUTEX) -#include "rtc_base/synchronization/mutex_abseil.h" +#include "rtc_base/synchronization/mutex_abseil.h" // nogncheck #elif defined(WEBRTC_WIN) #include "rtc_base/synchronization/mutex_critical_section.h" #elif defined(WEBRTC_POSIX) diff --git a/webrtc.gni b/webrtc.gni index d222bc7ec9..bf4d0a00b3 100644 --- a/webrtc.gni +++ b/webrtc.gni @@ -155,6 +155,9 @@ declare_args() { rtc_use_h264 = proprietary_codecs && !is_android && !is_ios && !(is_win && !is_clang) + # Enable this flag to make webrtc::Mutex be implemented by absl::Mutex. + rtc_use_absl_mutex = false + # By default, use normal platform audio support or dummy audio, but don't # use file-based audio playout and record. rtc_use_dummy_audio_file_devices = false