Change AudioProcessing interface to allow not to require rtc::TaskQueue
rtc::TaskQueue is a wrapper of TaskQueueBase providing no extra functionality in this case
Bug: webrtc:14169
Change-Id: I5eb27a5dbb16f6097a9c71c2633c807808e50c05
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/333800
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41501}
diff --git a/modules/audio_processing/BUILD.gn b/modules/audio_processing/BUILD.gn
index 3611c1a..35193c1 100644
--- a/modules/audio_processing/BUILD.gn
+++ b/modules/audio_processing/BUILD.gn
@@ -34,8 +34,10 @@
"../../api/audio:aec3_config",
"../../api/audio:audio_frame_api",
"../../api/audio:echo_control",
+ "../../api/task_queue",
"../../rtc_base:macromagic",
"../../rtc_base:refcount",
+ "../../rtc_base:rtc_task_queue",
"../../rtc_base:stringutils",
"../../rtc_base/system:arch",
"../../rtc_base/system:file_wrapper",
@@ -43,6 +45,7 @@
"agc:gain_control_interface",
]
absl_deps = [
+ "//third_party/abseil-cpp/absl/base:nullability",
"//third_party/abseil-cpp/absl/strings",
"//third_party/abseil-cpp/absl/types:optional",
]
@@ -185,6 +188,7 @@
"../../api/audio:aec3_config",
"../../api/audio:audio_frame_api",
"../../api/audio:echo_control",
+ "../../api/task_queue",
"../../audio/utility:audio_frame_operations",
"../../common_audio:common_audio_c",
"../../common_audio/third_party/ooura:fft_size_256",
@@ -193,7 +197,6 @@
"../../rtc_base:gtest_prod",
"../../rtc_base:logging",
"../../rtc_base:macromagic",
- "../../rtc_base:rtc_task_queue",
"../../rtc_base:safe_minmax",
"../../rtc_base:sanitizer",
"../../rtc_base:swap_queue",
@@ -218,6 +221,7 @@
"vad",
]
absl_deps = [
+ "//third_party/abseil-cpp/absl/base:nullability",
"//third_party/abseil-cpp/absl/strings",
"//third_party/abseil-cpp/absl/types:optional",
]
@@ -338,9 +342,13 @@
":audio_buffer",
":audio_processing",
":audio_processing_statistics",
+ "../../api/task_queue",
"../../test:test_support",
]
- absl_deps = [ "//third_party/abseil-cpp/absl/strings" ]
+ absl_deps = [
+ "//third_party/abseil-cpp/absl/base:nullability",
+ "//third_party/abseil-cpp/absl/strings",
+ ]
}
if (!build_with_chromium) {
diff --git a/modules/audio_processing/audio_processing_impl.cc b/modules/audio_processing/audio_processing_impl.cc
index 2e18ef4..0104e0c 100644
--- a/modules/audio_processing/audio_processing_impl.cc
+++ b/modules/audio_processing/audio_processing_impl.cc
@@ -18,11 +18,13 @@
#include <type_traits>
#include <utility>
+#include "absl/base/nullability.h"
#include "absl/strings/match.h"
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
#include "api/array_view.h"
#include "api/audio/audio_frame.h"
+#include "api/task_queue/task_queue_base.h"
#include "common_audio/audio_converter.h"
#include "common_audio/include/audio_util.h"
#include "modules/audio_processing/aec_dump/aec_dump_factory.h"
@@ -33,7 +35,6 @@
#include "rtc_base/checks.h"
#include "rtc_base/experiments/field_trial_parser.h"
#include "rtc_base/logging.h"
-#include "rtc_base/task_queue.h"
#include "rtc_base/time_utils.h"
#include "rtc_base/trace_event.h"
#include "system_wrappers/include/denormal_disabler.h"
@@ -2083,11 +2084,12 @@
capture_.recommended_input_volume = capture_.applied_input_volume;
}
-bool AudioProcessingImpl::CreateAndAttachAecDump(absl::string_view file_name,
- int64_t max_log_size_bytes,
- rtc::TaskQueue* worker_queue) {
- std::unique_ptr<AecDump> aec_dump = AecDumpFactory::Create(
- file_name, max_log_size_bytes, worker_queue->Get());
+bool AudioProcessingImpl::CreateAndAttachAecDump(
+ absl::string_view file_name,
+ int64_t max_log_size_bytes,
+ absl::Nonnull<TaskQueueBase*> worker_queue) {
+ std::unique_ptr<AecDump> aec_dump =
+ AecDumpFactory::Create(file_name, max_log_size_bytes, worker_queue);
if (!aec_dump) {
return false;
}
@@ -2096,11 +2098,12 @@
return true;
}
-bool AudioProcessingImpl::CreateAndAttachAecDump(FILE* handle,
- int64_t max_log_size_bytes,
- rtc::TaskQueue* worker_queue) {
+bool AudioProcessingImpl::CreateAndAttachAecDump(
+ FILE* handle,
+ int64_t max_log_size_bytes,
+ absl::Nonnull<TaskQueueBase*> worker_queue) {
std::unique_ptr<AecDump> aec_dump =
- AecDumpFactory::Create(handle, max_log_size_bytes, worker_queue->Get());
+ AecDumpFactory::Create(handle, max_log_size_bytes, worker_queue);
if (!aec_dump) {
return false;
}
diff --git a/modules/audio_processing/audio_processing_impl.h b/modules/audio_processing/audio_processing_impl.h
index 1e058b5..2c0ab19 100644
--- a/modules/audio_processing/audio_processing_impl.h
+++ b/modules/audio_processing/audio_processing_impl.h
@@ -19,10 +19,12 @@
#include <string>
#include <vector>
+#include "absl/base/nullability.h"
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
#include "api/array_view.h"
#include "api/function_view.h"
+#include "api/task_queue/task_queue_base.h"
#include "modules/audio_processing/aec3/echo_canceller3.h"
#include "modules/audio_processing/agc/agc_manager_direct.h"
#include "modules/audio_processing/agc/gain_control.h"
@@ -71,12 +73,14 @@
int Initialize() override;
int Initialize(const ProcessingConfig& processing_config) override;
void ApplyConfig(const AudioProcessing::Config& config) override;
- bool CreateAndAttachAecDump(absl::string_view file_name,
- int64_t max_log_size_bytes,
- rtc::TaskQueue* worker_queue) override;
- bool CreateAndAttachAecDump(FILE* handle,
- int64_t max_log_size_bytes,
- rtc::TaskQueue* worker_queue) override;
+ bool CreateAndAttachAecDump(
+ absl::string_view file_name,
+ int64_t max_log_size_bytes,
+ absl::Nonnull<TaskQueueBase*> worker_queue) override;
+ bool CreateAndAttachAecDump(
+ FILE* handle,
+ int64_t max_log_size_bytes,
+ absl::Nonnull<TaskQueueBase*> worker_queue) override;
// TODO(webrtc:5298) Deprecated variant.
void AttachAecDump(std::unique_ptr<AecDump> aec_dump) override;
void DetachAecDump() override;
diff --git a/modules/audio_processing/include/audio_processing.cc b/modules/audio_processing/include/audio_processing.cc
index 13ddcc5..48cf461 100644
--- a/modules/audio_processing/include/audio_processing.cc
+++ b/modules/audio_processing/include/audio_processing.cc
@@ -12,6 +12,7 @@
#include "rtc_base/strings/string_builder.h"
#include "rtc_base/system/arch.h"
+#include "rtc_base/task_queue.h"
namespace webrtc {
namespace {
@@ -207,4 +208,36 @@
return builder.str();
}
+bool AudioProcessing::CreateAndAttachAecDump(absl::string_view file_name,
+ int64_t max_log_size_bytes,
+ rtc::TaskQueue* worker_queue) {
+ return CreateAndAttachAecDump(file_name, max_log_size_bytes,
+ worker_queue->Get());
+}
+
+bool AudioProcessing::CreateAndAttachAecDump(FILE* handle,
+ int64_t max_log_size_bytes,
+ rtc::TaskQueue* worker_queue) {
+ return CreateAndAttachAecDump(handle, max_log_size_bytes,
+ worker_queue->Get());
+}
+
+bool AudioProcessing::CreateAndAttachAecDump(
+ absl::string_view file_name,
+ int64_t max_log_size_bytes,
+ absl::Nonnull<TaskQueueBase*> worker_queue) {
+ // Newer code should implement this variant,
+ // Older code shouldn't call this variant.
+ RTC_CHECK_NOTREACHED();
+}
+
+bool AudioProcessing::CreateAndAttachAecDump(
+ FILE* handle,
+ int64_t max_log_size_bytes,
+ absl::Nonnull<TaskQueueBase*> worker_queue) {
+ // New ercode should implement this variant,
+ // Older code shouldn't call this variant.
+ RTC_CHECK_NOTREACHED();
+}
+
} // namespace webrtc
diff --git a/modules/audio_processing/include/audio_processing.h b/modules/audio_processing/include/audio_processing.h
index e322351..a732e92 100644
--- a/modules/audio_processing/include/audio_processing.h
+++ b/modules/audio_processing/include/audio_processing.h
@@ -23,6 +23,7 @@
#include <vector>
+#include "absl/base/nullability.h"
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
#include "api/array_view.h"
@@ -30,6 +31,7 @@
#include "api/audio/echo_control.h"
#include "api/ref_count.h"
#include "api/scoped_refptr.h"
+#include "api/task_queue/task_queue_base.h"
#include "modules/audio_processing/include/audio_processing_statistics.h"
#include "rtc_base/arraysize.h"
#include "rtc_base/system/file_wrapper.h"
@@ -632,12 +634,23 @@
// return value of true indicates that the file has been
// sucessfully opened, while a value of false indicates that
// opening the file failed.
+ // TODO: bugs.webrtc.org/14169 - Delete rtc::TaskQueue variants
virtual bool CreateAndAttachAecDump(absl::string_view file_name,
int64_t max_log_size_bytes,
- rtc::TaskQueue* worker_queue) = 0;
+ rtc::TaskQueue* worker_queue);
virtual bool CreateAndAttachAecDump(FILE* handle,
int64_t max_log_size_bytes,
- rtc::TaskQueue* worker_queue) = 0;
+ rtc::TaskQueue* worker_queue);
+ // TODO: bugs.webrtc.org/14169 - Make TaskQueueBase variants pure virtual when
+ // implemented by derived classes.
+ virtual bool CreateAndAttachAecDump(
+ absl::string_view file_name,
+ int64_t max_log_size_bytes,
+ absl::Nonnull<TaskQueueBase*> worker_queue);
+ virtual bool CreateAndAttachAecDump(
+ absl::Nonnull<FILE*> handle,
+ int64_t max_log_size_bytes,
+ absl::Nonnull<TaskQueueBase*> worker_queue);
// TODO(webrtc:5298) Deprecated variant.
// Attaches provided webrtc::AecDump for recording debugging
diff --git a/modules/audio_processing/include/mock_audio_processing.h b/modules/audio_processing/include/mock_audio_processing.h
index 2ea1a86..dfe7d84 100644
--- a/modules/audio_processing/include/mock_audio_processing.h
+++ b/modules/audio_processing/include/mock_audio_processing.h
@@ -13,7 +13,9 @@
#include <memory>
+#include "absl/base/nullability.h"
#include "absl/strings/string_view.h"
+#include "api/task_queue/task_queue_base.h"
#include "modules/audio_processing/include/aec_dump.h"
#include "modules/audio_processing/include/audio_processing.h"
#include "modules/audio_processing/include/audio_processing_statistics.h"
@@ -155,13 +157,13 @@
CreateAndAttachAecDump,
(absl::string_view file_name,
int64_t max_log_size_bytes,
- rtc::TaskQueue* worker_queue),
+ absl::Nonnull<TaskQueueBase*> worker_queue),
(override));
MOCK_METHOD(bool,
CreateAndAttachAecDump,
(FILE * handle,
int64_t max_log_size_bytes,
- rtc::TaskQueue* worker_queue),
+ absl::Nonnull<TaskQueueBase*> worker_queue),
(override));
MOCK_METHOD(void, AttachAecDump, (std::unique_ptr<AecDump>), (override));
MOCK_METHOD(void, DetachAecDump, (), (override));