Revert "Delete TestAudioDeviceModule factory which uses GlobalTaskQueueFactory"
This reverts commit fc961357a721cd87dcd45ed409c66cb8cda6f4a2.
Reason for revert: Breaks downstream importer.
Original change's description:
> Delete TestAudioDeviceModule factory which uses GlobalTaskQueueFactory
>
> Bug: webrtc:10284
> Change-Id: Ic92f6ff31b40c48a3362745a0a81179af0595fe0
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/141409
> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
> Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#28227}
TBR=danilchap@webrtc.org,kwiberg@webrtc.org
Change-Id: Id6d7571f48771646ddce0f05139a7ea0107759fb
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:10284
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/141414
Reviewed-by: Philip Eliasson <philipel@webrtc.org>
Commit-Queue: Philip Eliasson <philipel@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28228}
diff --git a/audio/test/media_transport_test.cc b/audio/test/media_transport_test.cc
index b06d46d..5b2c554 100644
--- a/audio/test/media_transport_test.cc
+++ b/audio/test/media_transport_test.cc
@@ -72,8 +72,6 @@
TEST(AudioWithMediaTransport, DeliversAudio) {
std::unique_ptr<rtc::Thread> transport_thread = rtc::Thread::Create();
transport_thread->Start();
- std::unique_ptr<TaskQueueFactory> task_queue_factory =
- CreateDefaultTaskQueueFactory();
MediaTransportPair transport_pair(transport_thread.get());
NiceMock<MockTransport> rtcp_send_transport;
NiceMock<MockTransport> send_transport;
@@ -81,8 +79,7 @@
NiceMock<MockBitrateAllocator> bitrate_allocator;
rtc::scoped_refptr<TestAudioDeviceModule> audio_device =
- TestAudioDeviceModule::Create(
- task_queue_factory.get(),
+ TestAudioDeviceModule::CreateTestAudioDeviceModule(
TestAudioDeviceModule::CreatePulsedNoiseCapturer(
/* max_amplitude= */ 10000, kSamplingFrequency, kNumChannels),
absl::make_unique<TestRenderer>(kSamplingFrequency, kNumChannels,
@@ -128,6 +125,8 @@
send_config.encoder_factory = CreateAudioEncoderFactory<AudioEncoderOpus>();
std::unique_ptr<ProcessThread> send_process_thread =
ProcessThread::Create("audio send thread");
+ std::unique_ptr<TaskQueueFactory> task_queue_factory =
+ CreateDefaultTaskQueueFactory();
RtpTransportControllerSend rtp_transport(
Clock::GetRealTimeClock(), &null_event_log, nullptr, nullptr,
BitrateConstraints(), ProcessThread::Create("Pacer"),
diff --git a/call/call_perf_tests.cc b/call/call_perf_tests.cc
index 2f8f8fd..0bbf034 100644
--- a/call/call_perf_tests.cc
+++ b/call/call_perf_tests.cc
@@ -185,8 +185,7 @@
task_queue_.SendTask([&]() {
metrics::Reset();
rtc::scoped_refptr<TestAudioDeviceModule> fake_audio_device =
- TestAudioDeviceModule::Create(
- task_queue_factory_.get(),
+ TestAudioDeviceModule::CreateTestAudioDeviceModule(
TestAudioDeviceModule::CreatePulsedNoiseCapturer(256, 48000),
TestAudioDeviceModule::CreateDiscardRenderer(48000),
audio_rtp_speed);
diff --git a/modules/audio_device/BUILD.gn b/modules/audio_device/BUILD.gn
index 943b0ed..c42f862 100644
--- a/modules/audio_device/BUILD.gn
+++ b/modules/audio_device/BUILD.gn
@@ -167,6 +167,7 @@
"../../api:refcountedbase",
"../../api:scoped_refptr",
"../../api/task_queue",
+ "../../api/task_queue:global_task_queue_factory",
"../../common_audio",
"../../common_audio:common_audio_c",
"../../rtc_base",
diff --git a/modules/audio_device/include/test_audio_device.cc b/modules/audio_device/include/test_audio_device.cc
index 08ce8ad..5ff5387 100644
--- a/modules/audio_device/include/test_audio_device.cc
+++ b/modules/audio_device/include/test_audio_device.cc
@@ -18,6 +18,7 @@
#include "absl/memory/memory.h"
#include "api/array_view.h"
+#include "api/task_queue/global_task_queue_factory.h"
#include "common_audio/wav_file.h"
#include "modules/audio_device/include/audio_device_default.h"
#include "modules/audio_device/include/test_audio_device.h"
@@ -473,6 +474,15 @@
return rtc::CheckedDivExact(sampling_frequency_in_hz, kFramesPerSecond);
}
+rtc::scoped_refptr<TestAudioDeviceModule>
+TestAudioDeviceModule::CreateTestAudioDeviceModule(
+ std::unique_ptr<Capturer> capturer,
+ std::unique_ptr<Renderer> renderer,
+ float speed) {
+ return Create(&GlobalTaskQueueFactory(), std::move(capturer),
+ std::move(renderer), speed);
+}
+
rtc::scoped_refptr<TestAudioDeviceModule> TestAudioDeviceModule::Create(
TaskQueueFactory* task_queue_factory,
std::unique_ptr<TestAudioDeviceModule::Capturer> capturer,
diff --git a/modules/audio_device/include/test_audio_device.h b/modules/audio_device/include/test_audio_device.h
index a3b1b3a..586996e 100644
--- a/modules/audio_device/include/test_audio_device.h
+++ b/modules/audio_device/include/test_audio_device.h
@@ -79,6 +79,10 @@
// |renderer| is an object that receives audio data that would have been
// played out. Can be nullptr if this device is never used for playing.
// Use one of the Create... functions to get these instances.
+ static rtc::scoped_refptr<TestAudioDeviceModule> CreateTestAudioDeviceModule(
+ std::unique_ptr<Capturer> capturer,
+ std::unique_ptr<Renderer> renderer,
+ float speed = 1);
static rtc::scoped_refptr<TestAudioDeviceModule> Create(
TaskQueueFactory* task_queue_factory,
std::unique_ptr<Capturer> capturer,
diff --git a/test/call_test.cc b/test/call_test.cc
index 5d551a5..1dd4c80 100644
--- a/test/call_test.cc
+++ b/test/call_test.cc
@@ -492,10 +492,10 @@
void CallTest::CreateFakeAudioDevices(
std::unique_ptr<TestAudioDeviceModule::Capturer> capturer,
std::unique_ptr<TestAudioDeviceModule::Renderer> renderer) {
- fake_send_audio_device_ = TestAudioDeviceModule::Create(
- task_queue_factory_.get(), std::move(capturer), nullptr, 1.f);
- fake_recv_audio_device_ = TestAudioDeviceModule::Create(
- task_queue_factory_.get(), nullptr, std::move(renderer), 1.f);
+ fake_send_audio_device_ = TestAudioDeviceModule::CreateTestAudioDeviceModule(
+ std::move(capturer), nullptr, 1.f);
+ fake_recv_audio_device_ = TestAudioDeviceModule::CreateTestAudioDeviceModule(
+ nullptr, std::move(renderer), 1.f);
}
void CallTest::CreateVideoStreams() {
diff --git a/video/video_quality_test.cc b/video/video_quality_test.cc
index e2ca10d..cc30c79 100644
--- a/video/video_quality_test.cc
+++ b/video/video_quality_test.cc
@@ -1354,8 +1354,7 @@
audio_device = CreateAudioDevice();
} else {
// By default, create a test ADM which fakes audio.
- audio_device = TestAudioDeviceModule::Create(
- task_queue_factory_.get(),
+ audio_device = TestAudioDeviceModule::CreateTestAudioDeviceModule(
TestAudioDeviceModule::CreatePulsedNoiseCapturer(32000, 48000),
TestAudioDeviceModule::CreateDiscardRenderer(48000), 1.f);
}