From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Reilly Brogan Date: Tue, 19 Aug 2025 14:47:03 -0500 Subject: [PATCH] Fix build with abseil-cpp 202508 --- webrtc/api/audio/audio_processing.h | 12 +++++++++ webrtc/api/make_ref_counted.h | 13 ++++++++++ webrtc/api/scoped_refptr.h | 15 +++++++++++ .../aec_dump/aec_dump_factory.h | 15 +++++++++++ .../aec_dump/null_aec_dump_factory.cc | 25 +++++++++++++++++++ .../audio_processing/audio_processing_impl.cc | 9 +++++++ .../audio_processing/audio_processing_impl.h | 9 +++++++ 7 files changed, 98 insertions(+) diff --git a/webrtc/api/audio/audio_processing.h b/webrtc/api/audio/audio_processing.h index dca75f2174dd..4580ba9fd9af 100644 --- a/webrtc/api/audio/audio_processing.h +++ b/webrtc/api/audio/audio_processing.h @@ -28,6 +28,7 @@ #include #include +#include "absl/base/config.h" #include "absl/base/nullability.h" #include "absl/strings/string_view.h" #include "api/array_view.h" @@ -632,14 +633,25 @@ class RTC_EXPORT AudioProcessing : public RefCountInterface { // return value of true indicates that the file has been // sucessfully opened, while a value of false indicates that // opening the file failed. +#if defined(ABSL_LTS_RELEASE_VERSION) && ABSL_LTS_RELEASE_VERSION < 20250512 virtual bool CreateAndAttachAecDump( absl::string_view file_name, int64_t max_log_size_bytes, absl::Nonnull worker_queue) = 0; virtual bool CreateAndAttachAecDump( absl::Nonnull handle, int64_t max_log_size_bytes, absl::Nonnull worker_queue) = 0; +#else + virtual bool CreateAndAttachAecDump(absl::string_view file_name, + int64_t max_log_size_bytes, + TaskQueueBase* absl_nonnull + worker_queue) = 0; + virtual bool CreateAndAttachAecDump(FILE* absl_nonnull handle, + int64_t max_log_size_bytes, + TaskQueueBase* absl_nonnull + worker_queue) = 0; +#endif // TODO(webrtc:5298) Deprecated variant. // Attaches provided webrtc::AecDump for recording debugging diff --git a/webrtc/api/make_ref_counted.h b/webrtc/api/make_ref_counted.h index b5f4e99c8530..080023a83ff9 100644 --- a/webrtc/api/make_ref_counted.h +++ b/webrtc/api/make_ref_counted.h @@ -13,6 +13,7 @@ #include #include +#include "absl/base/config.h" #include "absl/base/nullability.h" #include "api/ref_count.h" #include "api/scoped_refptr.h" @@ -86,34 +87,46 @@ template < typename std::enable_if && std::is_abstract_v, T>::type* = nullptr> +#if defined(ABSL_LTS_RELEASE_VERSION) && ABSL_LTS_RELEASE_VERSION < 20250512 absl::Nonnull> make_ref_counted(Args&&... args) { +#else +absl_nonnull scoped_refptr make_ref_counted(Args&&... args) { +#endif return scoped_refptr(new RefCountedObject(std::forward(args)...)); } // `make_ref_counted` for complete classes that are not convertible to // RefCountInterface and already carry a ref count. template < typename T, typename... Args, typename std::enable_if< !std::is_convertible_v && webrtc_make_ref_counted_internal::HasAddRefAndRelease::value, T>::type* = nullptr> +#if defined(ABSL_LTS_RELEASE_VERSION) && ABSL_LTS_RELEASE_VERSION < 20250512 absl::Nonnull> make_ref_counted(Args&&... args) { +#else +absl_nonnull scoped_refptr make_ref_counted(Args&&... args) { +#endif return scoped_refptr(new T(std::forward(args)...)); } // `make_ref_counted` for complete classes that are not convertible to // RefCountInterface and have no ref count of their own. template < typename T, typename... Args, typename std::enable_if< !std::is_convertible_v && !webrtc_make_ref_counted_internal::HasAddRefAndRelease::value, T>::type* = nullptr> +#if defined(ABSL_LTS_RELEASE_VERSION) && ABSL_LTS_RELEASE_VERSION < 20250512 absl::Nonnull>> make_ref_counted( +#else +absl_nonnull scoped_refptr> make_ref_counted( +#endif Args&&... args) { return scoped_refptr>( new FinalRefCountedObject(std::forward(args)...)); diff --git a/webrtc/api/scoped_refptr.h b/webrtc/api/scoped_refptr.h index c6fb5605ca2e..8c441ff07adf 100644 --- a/webrtc/api/scoped_refptr.h +++ b/webrtc/api/scoped_refptr.h @@ -66,20 +66,27 @@ #include #include +#include "absl/base/config.h" #include "absl/base/nullability.h" namespace webrtc { template class ABSL_NULLABILITY_COMPATIBLE scoped_refptr { public: +#if defined(ABSL_LTS_RELEASE_VERSION) && ABSL_LTS_RELEASE_VERSION < 20250512 using absl_nullability_compatible = void; +#endif using element_type = T; scoped_refptr() : ptr_(nullptr) {} scoped_refptr(std::nullptr_t) : ptr_(nullptr) {} // NOLINT(runtime/explicit) +#if defined(ABSL_LTS_RELEASE_VERSION) && ABSL_LTS_RELEASE_VERSION < 20250512 explicit scoped_refptr(absl::Nullable p) : ptr_(p) { +#else + explicit scoped_refptr(T* absl_nullable p) : ptr_(p) { +#endif if (ptr_) ptr_->AddRef(); } @@ -122,7 +129,11 @@ class ABSL_NULLABILITY_COMPATIBLE scoped_refptr { return retVal; } +#if defined(ABSL_LTS_RELEASE_VERSION) && ABSL_LTS_RELEASE_VERSION < 20250512 scoped_refptr& operator=(absl::Nullable p) { +#else + scoped_refptr& operator=(T* absl_nullable p) { +#endif // AddRef first so that self assignment should work if (p) p->AddRef(); @@ -152,7 +163,11 @@ class ABSL_NULLABILITY_COMPATIBLE scoped_refptr { return *this; } +#if defined(ABSL_LTS_RELEASE_VERSION) && ABSL_LTS_RELEASE_VERSION < 20250512 void swap(absl::Nonnull pp) noexcept { +#else + void swap(T** absl_nonnull pp) noexcept { +#endif T* p = ptr_; ptr_ = *pp; *pp = p; diff --git a/webrtc/modules/audio_processing/aec_dump/aec_dump_factory.h b/webrtc/modules/audio_processing/aec_dump/aec_dump_factory.h index 0d258a9ebc09..14d8b39a346a 100644 --- a/webrtc/modules/audio_processing/aec_dump/aec_dump_factory.h +++ b/webrtc/modules/audio_processing/aec_dump/aec_dump_factory.h @@ -29,18 +29,33 @@ class RTC_EXPORT AecDumpFactory { // The AecDump takes responsibility for `handle` and closes it in the // destructor. A non-null return value indicates that the file has been // sucessfully opened. +#if defined(ABSL_LTS_RELEASE_VERSION) && ABSL_LTS_RELEASE_VERSION < 20250512 static absl::Nullable> Create( FileWrapper file, int64_t max_log_size_bytes, absl::Nonnull worker_queue); static absl::Nullable> Create( absl::string_view file_name, int64_t max_log_size_bytes, absl::Nonnull worker_queue); static absl::Nullable> Create( absl::Nonnull handle, int64_t max_log_size_bytes, absl::Nonnull worker_queue); +#else + static absl_nullable std::unique_ptr Create( + FileWrapper file, + int64_t max_log_size_bytes, + TaskQueueBase* absl_nonnull worker_queue); + static absl_nullable std::unique_ptr Create( + absl::string_view file_name, + int64_t max_log_size_bytes, + TaskQueueBase* absl_nonnull worker_queue); + static absl_nullable std::unique_ptr Create( + FILE* absl_nonnull handle, + int64_t max_log_size_bytes, + TaskQueueBase* absl_nonnull worker_queue); +#endif }; } // namespace webrtc diff --git a/webrtc/modules/audio_processing/aec_dump/null_aec_dump_factory.cc b/webrtc/modules/audio_processing/aec_dump/null_aec_dump_factory.cc index 63929afac419..658bcee7f484 100644 --- a/webrtc/modules/audio_processing/aec_dump/null_aec_dump_factory.cc +++ b/webrtc/modules/audio_processing/aec_dump/null_aec_dump_factory.cc @@ -16,24 +16,49 @@ namespace webrtc { +#if defined(ABSL_LTS_RELEASE_VERSION) && ABSL_LTS_RELEASE_VERSION < 20250512 absl::Nullable> AecDumpFactory::Create( FileWrapper file, int64_t max_log_size_bytes, absl::Nonnull worker_queue) { return nullptr; } absl::Nullable> AecDumpFactory::Create( absl::string_view file_name, int64_t max_log_size_bytes, absl::Nonnull worker_queue) { return nullptr; } absl::Nullable> AecDumpFactory::Create( absl::Nonnull handle, int64_t max_log_size_bytes, absl::Nonnull worker_queue) { return nullptr; } } // namespace webrtc +#else +absl_nullable std::unique_ptr AecDumpFactory::Create( + FileWrapper file, + int64_t max_log_size_bytes, + TaskQueueBase* absl_nonnull worker_queue) { + return nullptr; +} + +absl_nullable std::unique_ptr AecDumpFactory::Create( + absl::string_view file_name, + int64_t max_log_size_bytes, + TaskQueueBase* absl_nonnull worker_queue) { + return nullptr; +} + +absl_nullable std::unique_ptr AecDumpFactory::Create( + FILE* absl_nonnull handle, + int64_t max_log_size_bytes, + TaskQueueBase* absl_nonnull worker_queue) { + return nullptr; +} +} // namespace webrtc + +#endif diff --git a/webrtc/modules/audio_processing/audio_processing_impl.cc b/webrtc/modules/audio_processing/audio_processing_impl.cc index a1cba51a1158..1dfe26d4a83f 100644 --- a/webrtc/modules/audio_processing/audio_processing_impl.cc +++ b/webrtc/modules/audio_processing/audio_processing_impl.cc @@ -19,6 +19,7 @@ #include #include +#include "absl/base/config.h" #include "absl/base/nullability.h" #include "absl/strings/match.h" #include "absl/strings/string_view.h" @@ -1787,21 +1788,29 @@ void AudioProcessingImpl::UpdateRecommendedInputVolumeLocked() { bool AudioProcessingImpl::CreateAndAttachAecDump( absl::string_view file_name, int64_t max_log_size_bytes, +#if defined(ABSL_LTS_RELEASE_VERSION) && ABSL_LTS_RELEASE_VERSION < 20250512 absl::Nonnull worker_queue) { +#else + TaskQueueBase* absl_nonnull worker_queue) { +#endif std::unique_ptr aec_dump = AecDumpFactory::Create(file_name, max_log_size_bytes, worker_queue); if (!aec_dump) { return false; } AttachAecDump(std::move(aec_dump)); return true; } bool AudioProcessingImpl::CreateAndAttachAecDump( FILE* handle, int64_t max_log_size_bytes, +#if defined(ABSL_LTS_RELEASE_VERSION) && ABSL_LTS_RELEASE_VERSION < 20250512 absl::Nonnull worker_queue) { +#else + TaskQueueBase* absl_nonnull worker_queue) { +#endif std::unique_ptr aec_dump = AecDumpFactory::Create(handle, max_log_size_bytes, worker_queue); if (!aec_dump) { diff --git a/webrtc/modules/audio_processing/audio_processing_impl.h b/webrtc/modules/audio_processing/audio_processing_impl.h index ecdc055768bd..51a2bfbfaa81 100644 --- a/webrtc/modules/audio_processing/audio_processing_impl.h +++ b/webrtc/modules/audio_processing/audio_processing_impl.h @@ -20,6 +20,7 @@ #include #include +#include "absl/base/config.h" #include "absl/base/nullability.h" #include "absl/strings/string_view.h" #include "api/array_view.h" @@ -74,11 +75,19 @@ class AudioProcessingImpl : public AudioProcessing { bool CreateAndAttachAecDump( absl::string_view file_name, int64_t max_log_size_bytes, +#if defined(ABSL_LTS_RELEASE_VERSION) && ABSL_LTS_RELEASE_VERSION < 20250512 absl::Nonnull worker_queue) override; +#else + TaskQueueBase* absl_nonnull worker_queue) override; +#endif bool CreateAndAttachAecDump( FILE* handle, int64_t max_log_size_bytes, +#if defined(ABSL_LTS_RELEASE_VERSION) && ABSL_LTS_RELEASE_VERSION < 20250512 absl::Nonnull worker_queue) override; +#else + TaskQueueBase* absl_nonnull worker_queue) override; +#endif // TODO(webrtc:5298) Deprecated variant. void AttachAecDump(std::unique_ptr aec_dump) override; void DetachAecDump() override;