Propagate TaskQueueFactory to AudioDeviceBuffer
keep using GlobalTaskQueueFactory in android/ios bindings. Switch to DefaultTaskQueueFactory in tests. Bug: webrtc:10284 Change-Id: I034c70542be5eeb830be86527830d51204fb2855 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/130223 Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Cr-Commit-Position: refs/heads/master@{#27380}
This commit is contained in:
parent
105a10aef0
commit
1c41be6e05
@ -240,7 +240,7 @@ void WebRtcVoiceEngine::Init() {
|
||||
// No ADM supplied? Create a default one.
|
||||
if (!adm_) {
|
||||
adm_ = webrtc::AudioDeviceModule::Create(
|
||||
webrtc::AudioDeviceModule::kPlatformDefaultAudio);
|
||||
webrtc::AudioDeviceModule::kPlatformDefaultAudio, task_queue_factory_);
|
||||
}
|
||||
#endif // WEBRTC_INCLUDE_INTERNAL_AUDIO_DEVICE
|
||||
RTC_CHECK(adm());
|
||||
|
||||
@ -94,6 +94,7 @@ rtc_source_set("audio_device_api") {
|
||||
]
|
||||
deps = [
|
||||
"../../api:scoped_refptr",
|
||||
"../../api/task_queue",
|
||||
"../../rtc_base:checks",
|
||||
"../../rtc_base:deprecation",
|
||||
"../../rtc_base:rtc_base_approved",
|
||||
@ -112,6 +113,7 @@ rtc_source_set("audio_device_buffer") {
|
||||
deps = [
|
||||
":audio_device_api",
|
||||
"../../api:array_view",
|
||||
"../../api/task_queue",
|
||||
"../../common_audio:common_audio_c",
|
||||
"../../rtc_base:checks",
|
||||
"../../rtc_base:rtc_base_approved",
|
||||
@ -183,6 +185,7 @@ rtc_source_set("audio_device_module_from_input_and_output") {
|
||||
":audio_device_buffer",
|
||||
":windows_core_audio_utility",
|
||||
"../../api:scoped_refptr",
|
||||
"../../api/task_queue",
|
||||
"../../rtc_base:checks",
|
||||
"../../rtc_base:rtc_base_approved",
|
||||
"//third_party/abseil-cpp/absl/memory",
|
||||
@ -434,6 +437,8 @@ if (rtc_include_tests) {
|
||||
":mock_audio_device",
|
||||
"../../api:array_view",
|
||||
"../../api:scoped_refptr",
|
||||
"../../api/task_queue",
|
||||
"../../api/task_queue:default_task_queue_factory",
|
||||
"../../common_audio",
|
||||
"../../rtc_base:checks",
|
||||
"../../rtc_base:rtc_base_approved",
|
||||
|
||||
@ -17,6 +17,8 @@
|
||||
#include <vector>
|
||||
|
||||
#include "api/scoped_refptr.h"
|
||||
#include "api/task_queue/default_task_queue_factory.h"
|
||||
#include "api/task_queue/task_queue_factory.h"
|
||||
#include "modules/audio_device/android/audio_common.h"
|
||||
#include "modules/audio_device/android/audio_manager.h"
|
||||
#include "modules/audio_device/android/build_info.h"
|
||||
@ -460,7 +462,7 @@ class MockAudioTransportAndroid : public test::MockAudioTransport {
|
||||
// AudioDeviceTest test fixture.
|
||||
class AudioDeviceTest : public ::testing::Test {
|
||||
protected:
|
||||
AudioDeviceTest() {
|
||||
AudioDeviceTest() : task_queue_factory_(CreateDefaultTaskQueueFactory()) {
|
||||
// One-time initialization of JVM and application context. Ensures that we
|
||||
// can do calls between C++ and Java. Initializes both Java and OpenSL ES
|
||||
// implementations.
|
||||
@ -514,7 +516,7 @@ class AudioDeviceTest : public ::testing::Test {
|
||||
rtc::scoped_refptr<AudioDeviceModule> CreateAudioDevice(
|
||||
AudioDeviceModule::AudioLayer audio_layer) {
|
||||
rtc::scoped_refptr<AudioDeviceModule> module(
|
||||
AudioDeviceModule::Create(audio_layer));
|
||||
AudioDeviceModule::Create(audio_layer, task_queue_factory_.get()));
|
||||
return module;
|
||||
}
|
||||
|
||||
@ -639,6 +641,7 @@ class AudioDeviceTest : public ::testing::Test {
|
||||
}
|
||||
|
||||
rtc::Event test_is_done_;
|
||||
std::unique_ptr<TaskQueueFactory> task_queue_factory_;
|
||||
rtc::scoped_refptr<AudioDeviceModule> audio_device_;
|
||||
AudioParameters playout_parameters_;
|
||||
AudioParameters record_parameters_;
|
||||
|
||||
@ -39,8 +39,10 @@ static const size_t kMinValidCallTimeTimeInMilliseconds =
|
||||
static const double k2Pi = 6.28318530717959;
|
||||
#endif
|
||||
|
||||
AudioDeviceBuffer::AudioDeviceBuffer()
|
||||
: task_queue_(kTimerQueueName),
|
||||
AudioDeviceBuffer::AudioDeviceBuffer(TaskQueueFactory* task_queue_factory)
|
||||
: task_queue_(task_queue_factory->CreateTaskQueue(
|
||||
kTimerQueueName,
|
||||
TaskQueueFactory::Priority::NORMAL)),
|
||||
audio_transport_cb_(nullptr),
|
||||
rec_sample_rate_(0),
|
||||
play_sample_rate_(0),
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
#include <stdint.h>
|
||||
#include <atomic>
|
||||
|
||||
#include "api/task_queue/task_queue_factory.h"
|
||||
#include "modules/audio_device/include/audio_device_defines.h"
|
||||
#include "rtc_base/buffer.h"
|
||||
#include "rtc_base/critical_section.h"
|
||||
@ -75,7 +76,7 @@ class AudioDeviceBuffer {
|
||||
int16_t max_play_level = 0;
|
||||
};
|
||||
|
||||
AudioDeviceBuffer();
|
||||
explicit AudioDeviceBuffer(TaskQueueFactory* task_queue_factory);
|
||||
virtual ~AudioDeviceBuffer();
|
||||
|
||||
int32_t RegisterAudioCallback(AudioTransport* audio_callback);
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
|
||||
#include "modules/audio_device/include/audio_device_data_observer.h"
|
||||
|
||||
#include "api/task_queue/global_task_queue_factory.h"
|
||||
#include "modules/audio_device/include/audio_device_defines.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/ref_counted_object.h"
|
||||
@ -22,8 +23,11 @@ namespace {
|
||||
// callback and redirects the PCM data to AudioDeviceDataObserver callback.
|
||||
class ADMWrapper : public AudioDeviceModule, public AudioTransport {
|
||||
public:
|
||||
ADMWrapper(const AudioLayer audio_layer, AudioDeviceDataObserver* observer)
|
||||
: impl_(AudioDeviceModule::Create(audio_layer)), observer_(observer) {
|
||||
ADMWrapper(AudioLayer audio_layer,
|
||||
TaskQueueFactory* task_queue_factory,
|
||||
AudioDeviceDataObserver* observer)
|
||||
: impl_(AudioDeviceModule::Create(audio_layer, task_queue_factory)),
|
||||
observer_(observer) {
|
||||
// Register self as the audio transport callback for underlying ADM impl.
|
||||
auto res = impl_->RegisterAudioCallback(this);
|
||||
is_valid_ = (impl_.get() != nullptr) && (res == 0);
|
||||
@ -280,8 +284,17 @@ class ADMWrapper : public AudioDeviceModule, public AudioTransport {
|
||||
rtc::scoped_refptr<AudioDeviceModule> CreateAudioDeviceWithDataObserver(
|
||||
const AudioDeviceModule::AudioLayer audio_layer,
|
||||
AudioDeviceDataObserver* observer) {
|
||||
return CreateAudioDeviceWithDataObserver(audio_layer,
|
||||
&GlobalTaskQueueFactory(), observer);
|
||||
}
|
||||
|
||||
rtc::scoped_refptr<AudioDeviceModule> CreateAudioDeviceWithDataObserver(
|
||||
AudioDeviceModule::AudioLayer audio_layer,
|
||||
TaskQueueFactory* task_queue_factory,
|
||||
AudioDeviceDataObserver* observer) {
|
||||
rtc::scoped_refptr<ADMWrapper> audio_device(
|
||||
new rtc::RefCountedObject<ADMWrapper>(audio_layer, observer));
|
||||
new rtc::RefCountedObject<ADMWrapper>(audio_layer, task_queue_factory,
|
||||
observer));
|
||||
|
||||
if (!audio_device->IsValid()) {
|
||||
return nullptr;
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
#include <stddef.h>
|
||||
|
||||
#include "api/scoped_refptr.h"
|
||||
#include "api/task_queue/global_task_queue_factory.h"
|
||||
#include "modules/audio_device/audio_device_config.h" // IWYU pragma: keep
|
||||
#include "modules/audio_device/audio_device_generic.h"
|
||||
#include "rtc_base/checks.h"
|
||||
@ -71,14 +72,23 @@
|
||||
namespace webrtc {
|
||||
|
||||
rtc::scoped_refptr<AudioDeviceModule> AudioDeviceModule::Create(
|
||||
const AudioLayer audio_layer) {
|
||||
AudioLayer audio_layer) {
|
||||
RTC_LOG(INFO) << __FUNCTION__;
|
||||
return AudioDeviceModule::CreateForTest(audio_layer);
|
||||
return AudioDeviceModule::CreateForTest(audio_layer,
|
||||
&GlobalTaskQueueFactory());
|
||||
}
|
||||
|
||||
rtc::scoped_refptr<AudioDeviceModule> AudioDeviceModule::Create(
|
||||
AudioLayer audio_layer,
|
||||
TaskQueueFactory* task_queue_factory) {
|
||||
RTC_LOG(INFO) << __FUNCTION__;
|
||||
return AudioDeviceModule::CreateForTest(audio_layer, task_queue_factory);
|
||||
}
|
||||
|
||||
// static
|
||||
rtc::scoped_refptr<AudioDeviceModuleForTest> AudioDeviceModule::CreateForTest(
|
||||
const AudioLayer audio_layer) {
|
||||
AudioLayer audio_layer,
|
||||
TaskQueueFactory* task_queue_factory) {
|
||||
RTC_LOG(INFO) << __FUNCTION__;
|
||||
|
||||
// The "AudioDeviceModule::kWindowsCoreAudio2" audio layer has its own
|
||||
@ -91,7 +101,8 @@ rtc::scoped_refptr<AudioDeviceModuleForTest> AudioDeviceModule::CreateForTest(
|
||||
|
||||
// Create the generic reference counted (platform independent) implementation.
|
||||
rtc::scoped_refptr<AudioDeviceModuleImpl> audioDevice(
|
||||
new rtc::RefCountedObject<AudioDeviceModuleImpl>(audio_layer));
|
||||
new rtc::RefCountedObject<AudioDeviceModuleImpl>(audio_layer,
|
||||
task_queue_factory));
|
||||
|
||||
// Ensure that the current platform is supported.
|
||||
if (audioDevice->CheckPlatform() == -1) {
|
||||
@ -112,8 +123,10 @@ rtc::scoped_refptr<AudioDeviceModuleForTest> AudioDeviceModule::CreateForTest(
|
||||
return audioDevice;
|
||||
}
|
||||
|
||||
AudioDeviceModuleImpl::AudioDeviceModuleImpl(const AudioLayer audioLayer)
|
||||
: audio_layer_(audioLayer) {
|
||||
AudioDeviceModuleImpl::AudioDeviceModuleImpl(
|
||||
AudioLayer audio_layer,
|
||||
TaskQueueFactory* task_queue_factory)
|
||||
: audio_layer_(audio_layer), audio_device_buffer_(task_queue_factory) {
|
||||
RTC_LOG(INFO) << __FUNCTION__;
|
||||
}
|
||||
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
#include <stdint.h>
|
||||
#include <memory>
|
||||
|
||||
#include "api/task_queue/task_queue_factory.h"
|
||||
#include "modules/audio_device/audio_device_buffer.h"
|
||||
#include "modules/audio_device/include/audio_device.h"
|
||||
|
||||
@ -40,7 +41,8 @@ class AudioDeviceModuleImpl : public AudioDeviceModuleForTest {
|
||||
int32_t CreatePlatformSpecificObjects();
|
||||
int32_t AttachAudioBuffer();
|
||||
|
||||
AudioDeviceModuleImpl(const AudioLayer audioLayer);
|
||||
AudioDeviceModuleImpl(AudioLayer audio_layer,
|
||||
TaskQueueFactory* task_queue_factory);
|
||||
~AudioDeviceModuleImpl() override;
|
||||
|
||||
// Retrieve the currently utilized audio layer
|
||||
|
||||
@ -17,6 +17,8 @@
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/array_view.h"
|
||||
#include "api/scoped_refptr.h"
|
||||
#include "api/task_queue/default_task_queue_factory.h"
|
||||
#include "api/task_queue/task_queue_factory.h"
|
||||
#include "modules/audio_device/audio_device_impl.h"
|
||||
#include "modules/audio_device/include/audio_device.h"
|
||||
#include "modules/audio_device/include/mock_audio_transport.h"
|
||||
@ -510,7 +512,9 @@ class MockAudioTransport : public test::MockAudioTransport {
|
||||
class AudioDeviceTest
|
||||
: public ::testing::TestWithParam<webrtc::AudioDeviceModule::AudioLayer> {
|
||||
protected:
|
||||
AudioDeviceTest() : audio_layer_(GetParam()) {
|
||||
AudioDeviceTest()
|
||||
: audio_layer_(GetParam()),
|
||||
task_queue_factory_(CreateDefaultTaskQueueFactory()) {
|
||||
// TODO(webrtc:9778): Re-enable on THREAD_SANITIZER?
|
||||
#if !defined(ADDRESS_SANITIZER) && !defined(MEMORY_SANITIZER) && \
|
||||
!defined(WEBRTC_DUMMY_AUDIO_BUILD) && !defined(THREAD_SANITIZER)
|
||||
@ -579,7 +583,8 @@ class AudioDeviceTest
|
||||
// The value of |audio_layer_| is set at construction by GetParam() and two
|
||||
// different layers are tested on Windows only.
|
||||
if (audio_layer_ == AudioDeviceModule::kPlatformDefaultAudio) {
|
||||
return AudioDeviceModule::CreateForTest(audio_layer_);
|
||||
return AudioDeviceModule::CreateForTest(audio_layer_,
|
||||
task_queue_factory_.get());
|
||||
} else if (audio_layer_ == AudioDeviceModule::kWindowsCoreAudio2) {
|
||||
#ifdef WEBRTC_WIN
|
||||
// We must initialize the COM library on a thread before we calling any of
|
||||
@ -590,7 +595,8 @@ class AudioDeviceTest
|
||||
EXPECT_TRUE(com_initializer_->Succeeded());
|
||||
EXPECT_TRUE(webrtc_win::core_audio_utility::IsSupported());
|
||||
EXPECT_TRUE(webrtc_win::core_audio_utility::IsMMCSSSupported());
|
||||
return CreateWindowsCoreAudioAudioDeviceModuleForTest();
|
||||
return CreateWindowsCoreAudioAudioDeviceModuleForTest(
|
||||
task_queue_factory_.get());
|
||||
#else
|
||||
return nullptr;
|
||||
#endif
|
||||
@ -647,6 +653,7 @@ class AudioDeviceTest
|
||||
std::unique_ptr<webrtc_win::ScopedCOMInitializer> com_initializer_;
|
||||
#endif
|
||||
AudioDeviceModule::AudioLayer audio_layer_;
|
||||
std::unique_ptr<TaskQueueFactory> task_queue_factory_;
|
||||
bool requirements_satisfied_ = true;
|
||||
rtc::Event event_;
|
||||
rtc::scoped_refptr<AudioDeviceModuleForTest> audio_device_;
|
||||
@ -656,11 +663,13 @@ class AudioDeviceTest
|
||||
// Instead of using the test fixture, verify that the different factory methods
|
||||
// work as intended.
|
||||
TEST(AudioDeviceTestWin, ConstructDestructWithFactory) {
|
||||
std::unique_ptr<TaskQueueFactory> task_queue_factory =
|
||||
CreateDefaultTaskQueueFactory();
|
||||
rtc::scoped_refptr<AudioDeviceModule> audio_device;
|
||||
// The default factory should work for all platforms when a default ADM is
|
||||
// requested.
|
||||
audio_device =
|
||||
AudioDeviceModule::Create(AudioDeviceModule::kPlatformDefaultAudio);
|
||||
audio_device = AudioDeviceModule::Create(
|
||||
AudioDeviceModule::kPlatformDefaultAudio, task_queue_factory.get());
|
||||
EXPECT_TRUE(audio_device);
|
||||
audio_device = nullptr;
|
||||
#ifdef WEBRTC_WIN
|
||||
@ -668,8 +677,8 @@ TEST(AudioDeviceTestWin, ConstructDestructWithFactory) {
|
||||
// specific parts are implemented by an AudioDeviceGeneric object. Verify
|
||||
// that the old factory can't be used in combination with the latest audio
|
||||
// layer AudioDeviceModule::kWindowsCoreAudio2.
|
||||
audio_device =
|
||||
AudioDeviceModule::Create(AudioDeviceModule::kWindowsCoreAudio2);
|
||||
audio_device = AudioDeviceModule::Create(
|
||||
AudioDeviceModule::kWindowsCoreAudio2, task_queue_factory.get());
|
||||
EXPECT_FALSE(audio_device);
|
||||
audio_device = nullptr;
|
||||
// Instead, ensure that the new dedicated factory method called
|
||||
@ -679,7 +688,8 @@ TEST(AudioDeviceTestWin, ConstructDestructWithFactory) {
|
||||
webrtc_win::ScopedCOMInitializer com_initializer(
|
||||
webrtc_win::ScopedCOMInitializer::kMTA);
|
||||
EXPECT_TRUE(com_initializer.Succeeded());
|
||||
audio_device = CreateWindowsCoreAudioAudioDeviceModule();
|
||||
audio_device =
|
||||
CreateWindowsCoreAudioAudioDeviceModule(task_queue_factory.get());
|
||||
EXPECT_TRUE(audio_device);
|
||||
AudioDeviceModule::AudioLayer audio_layer;
|
||||
EXPECT_EQ(0, audio_device->ActiveAudioLayer(&audio_layer));
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
#include <memory>
|
||||
|
||||
#include "api/array_view.h"
|
||||
#include "api/task_queue/default_task_queue_factory.h"
|
||||
#include "modules/audio_device/mock_audio_device_buffer.h"
|
||||
#include "test/gmock.h"
|
||||
#include "test/gtest.h"
|
||||
@ -91,7 +92,8 @@ void RunFineBufferTest(int frame_size_in_samples) {
|
||||
const int kNumberOfUpdateBufferCalls =
|
||||
1 + ((kNumberOfFrames * frame_size_in_samples - 1) / kSamplesPer10Ms);
|
||||
|
||||
MockAudioDeviceBuffer audio_device_buffer;
|
||||
auto task_queue_factory = CreateDefaultTaskQueueFactory();
|
||||
MockAudioDeviceBuffer audio_device_buffer(task_queue_factory.get());
|
||||
audio_device_buffer.SetPlayoutSampleRate(kSampleRate);
|
||||
audio_device_buffer.SetPlayoutChannels(kChannels);
|
||||
audio_device_buffer.SetRecordingSampleRate(kSampleRate);
|
||||
|
||||
@ -12,6 +12,7 @@
|
||||
#define MODULES_AUDIO_DEVICE_INCLUDE_AUDIO_DEVICE_H_
|
||||
|
||||
#include "api/scoped_refptr.h"
|
||||
#include "api/task_queue/task_queue_factory.h"
|
||||
#include "modules/audio_device/include/audio_device_defines.h"
|
||||
#include "rtc_base/ref_count.h"
|
||||
|
||||
@ -41,13 +42,18 @@ class AudioDeviceModule : public rtc::RefCountInterface {
|
||||
};
|
||||
|
||||
public:
|
||||
// TODO(bugs.webrtc.org/10284): Remove when unused.
|
||||
RTC_DEPRECATED
|
||||
static rtc::scoped_refptr<AudioDeviceModule> Create(AudioLayer audio_layer);
|
||||
// Creates a default ADM for usage in production code.
|
||||
static rtc::scoped_refptr<AudioDeviceModule> Create(
|
||||
const AudioLayer audio_layer);
|
||||
AudioLayer audio_layer,
|
||||
TaskQueueFactory* task_queue_factory);
|
||||
// Creates an ADM with support for extra test methods. Don't use this factory
|
||||
// in production code.
|
||||
static rtc::scoped_refptr<AudioDeviceModuleForTest> CreateForTest(
|
||||
const AudioLayer audio_layer);
|
||||
AudioLayer audio_layer,
|
||||
TaskQueueFactory* task_queue_factory);
|
||||
|
||||
// Retrieve the currently utilized audio layer
|
||||
virtual int32_t ActiveAudioLayer(AudioLayer* audioLayer) const = 0;
|
||||
|
||||
@ -15,7 +15,9 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include "api/scoped_refptr.h"
|
||||
#include "api/task_queue/task_queue_factory.h"
|
||||
#include "modules/audio_device/include/audio_device.h"
|
||||
#include "rtc_base/deprecation.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -39,9 +41,16 @@ class AudioDeviceDataObserver {
|
||||
virtual ~AudioDeviceDataObserver() = default;
|
||||
};
|
||||
|
||||
// TODO(bugs.webrtc.org/10284): Remove when unused.
|
||||
RTC_DEPRECATED
|
||||
rtc::scoped_refptr<AudioDeviceModule> CreateAudioDeviceWithDataObserver(
|
||||
const AudioDeviceModule::AudioLayer audio_layer,
|
||||
AudioDeviceDataObserver* observer);
|
||||
|
||||
// Creates an ADM instance with AudioDeviceDataObserver registered.
|
||||
rtc::scoped_refptr<AudioDeviceModule> CreateAudioDeviceWithDataObserver(
|
||||
const AudioDeviceModule::AudioLayer audio_layer,
|
||||
TaskQueueFactory* task_queue_factory,
|
||||
AudioDeviceDataObserver* observer);
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
@ -18,18 +18,20 @@
|
||||
#endif
|
||||
|
||||
#include "absl/memory/memory.h"
|
||||
#include "api/task_queue/task_queue_factory.h"
|
||||
#include "rtc_base/logging.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
rtc::scoped_refptr<AudioDeviceModule>
|
||||
CreateWindowsCoreAudioAudioDeviceModule() {
|
||||
rtc::scoped_refptr<AudioDeviceModule> CreateWindowsCoreAudioAudioDeviceModule(
|
||||
TaskQueueFactory* task_queue_factory) {
|
||||
RTC_DLOG(INFO) << __FUNCTION__;
|
||||
return CreateWindowsCoreAudioAudioDeviceModuleForTest();
|
||||
return CreateWindowsCoreAudioAudioDeviceModuleForTest(task_queue_factory);
|
||||
}
|
||||
|
||||
rtc::scoped_refptr<AudioDeviceModuleForTest>
|
||||
CreateWindowsCoreAudioAudioDeviceModuleForTest() {
|
||||
CreateWindowsCoreAudioAudioDeviceModuleForTest(
|
||||
TaskQueueFactory* task_queue_factory) {
|
||||
RTC_DLOG(INFO) << __FUNCTION__;
|
||||
// Returns NULL if Core Audio is not supported or if COM has not been
|
||||
// initialized correctly using webrtc_win::ScopedCOMInitializer.
|
||||
@ -40,7 +42,7 @@ CreateWindowsCoreAudioAudioDeviceModuleForTest() {
|
||||
}
|
||||
return CreateWindowsCoreAudioAudioDeviceModuleFromInputAndOutput(
|
||||
absl::make_unique<webrtc_win::CoreAudioInput>(),
|
||||
absl::make_unique<webrtc_win::CoreAudioOutput>());
|
||||
absl::make_unique<webrtc_win::CoreAudioOutput>(), task_queue_factory);
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
@ -12,6 +12,7 @@
|
||||
#define MODULES_AUDIO_DEVICE_INCLUDE_AUDIO_DEVICE_FACTORY_H_
|
||||
|
||||
#include "absl/memory/memory.h"
|
||||
#include "api/task_queue/task_queue_factory.h"
|
||||
#include "modules/audio_device/include/audio_device.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -34,10 +35,12 @@ namespace webrtc {
|
||||
// private:
|
||||
// std::unique_ptr<webrtc_win::ScopedCOMInitializer> com_initializer_;
|
||||
//
|
||||
rtc::scoped_refptr<AudioDeviceModule> CreateWindowsCoreAudioAudioDeviceModule();
|
||||
rtc::scoped_refptr<AudioDeviceModule> CreateWindowsCoreAudioAudioDeviceModule(
|
||||
TaskQueueFactory* task_queue_factory);
|
||||
|
||||
rtc::scoped_refptr<AudioDeviceModuleForTest>
|
||||
CreateWindowsCoreAudioAudioDeviceModuleForTest();
|
||||
CreateWindowsCoreAudioAudioDeviceModuleForTest(
|
||||
TaskQueueFactory* task_queue_factory);
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@ namespace webrtc {
|
||||
|
||||
class MockAudioDeviceBuffer : public AudioDeviceBuffer {
|
||||
public:
|
||||
MockAudioDeviceBuffer() {}
|
||||
using AudioDeviceBuffer::AudioDeviceBuffer;
|
||||
virtual ~MockAudioDeviceBuffer() {}
|
||||
MOCK_METHOD1(RequestPlayoutData, int32_t(size_t nSamples));
|
||||
MOCK_METHOD1(GetPlayoutData, int32_t(void* audioBuffer));
|
||||
|
||||
@ -60,8 +60,11 @@ class WindowsAudioDeviceModule : public AudioDeviceModuleForTest {
|
||||
};
|
||||
|
||||
WindowsAudioDeviceModule(std::unique_ptr<AudioInput> audio_input,
|
||||
std::unique_ptr<AudioOutput> audio_output)
|
||||
: input_(std::move(audio_input)), output_(std::move(audio_output)) {
|
||||
std::unique_ptr<AudioOutput> audio_output,
|
||||
TaskQueueFactory* task_queue_factory)
|
||||
: input_(std::move(audio_input)),
|
||||
output_(std::move(audio_output)),
|
||||
task_queue_factory_(task_queue_factory) {
|
||||
RTC_CHECK(input_);
|
||||
RTC_CHECK(output_);
|
||||
RTC_LOG(INFO) << __FUNCTION__;
|
||||
@ -101,7 +104,8 @@ class WindowsAudioDeviceModule : public AudioDeviceModuleForTest {
|
||||
if (initialized_) {
|
||||
return 0;
|
||||
}
|
||||
audio_device_buffer_ = absl::make_unique<AudioDeviceBuffer>();
|
||||
audio_device_buffer_ =
|
||||
absl::make_unique<AudioDeviceBuffer>(task_queue_factory_);
|
||||
AttachAudioBuffer();
|
||||
InitStatus status;
|
||||
if (output_->Init() != 0) {
|
||||
@ -459,6 +463,7 @@ class WindowsAudioDeviceModule : public AudioDeviceModuleForTest {
|
||||
// Implements the AudioOutput interface and deals with audio rendering parts.
|
||||
const std::unique_ptr<AudioOutput> output_;
|
||||
|
||||
TaskQueueFactory* const task_queue_factory_;
|
||||
// The AudioDeviceBuffer (ADB) instance is needed for sending/receiving audio
|
||||
// to/from the WebRTC layer. Created and owned by this object. Used by
|
||||
// both |input_| and |output_| but they use orthogonal parts of the ADB.
|
||||
@ -473,10 +478,11 @@ class WindowsAudioDeviceModule : public AudioDeviceModuleForTest {
|
||||
rtc::scoped_refptr<AudioDeviceModuleForTest>
|
||||
CreateWindowsCoreAudioAudioDeviceModuleFromInputAndOutput(
|
||||
std::unique_ptr<AudioInput> audio_input,
|
||||
std::unique_ptr<AudioOutput> audio_output) {
|
||||
std::unique_ptr<AudioOutput> audio_output,
|
||||
TaskQueueFactory* task_queue_factory) {
|
||||
RTC_LOG(INFO) << __FUNCTION__;
|
||||
return new rtc::RefCountedObject<WindowsAudioDeviceModule>(
|
||||
std::move(audio_input), std::move(audio_output));
|
||||
std::move(audio_input), std::move(audio_output), task_queue_factory);
|
||||
}
|
||||
|
||||
} // namespace webrtc_win
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "api/scoped_refptr.h"
|
||||
#include "api/task_queue/task_queue_factory.h"
|
||||
#include "modules/audio_device/include/audio_device.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -76,7 +77,8 @@ class AudioOutput {
|
||||
rtc::scoped_refptr<AudioDeviceModuleForTest>
|
||||
CreateWindowsCoreAudioAudioDeviceModuleFromInputAndOutput(
|
||||
std::unique_ptr<AudioInput> audio_input,
|
||||
std::unique_ptr<AudioOutput> audio_output);
|
||||
std::unique_ptr<AudioOutput> audio_output,
|
||||
TaskQueueFactory* task_queue_factory);
|
||||
|
||||
} // namespace webrtc_win
|
||||
|
||||
|
||||
@ -232,6 +232,7 @@ if (is_ios || is_mac) {
|
||||
|
||||
deps = [
|
||||
":audio_device",
|
||||
"../api/task_queue:global_task_queue_factory",
|
||||
"../modules/audio_device:audio_device_api",
|
||||
"../modules/audio_device:audio_device_generic",
|
||||
"../rtc_base:checks",
|
||||
@ -271,6 +272,7 @@ if (is_ios || is_mac) {
|
||||
":audio_session_observer",
|
||||
":base_objc",
|
||||
"../api:array_view",
|
||||
"../api/task_queue:global_task_queue_factory",
|
||||
"../modules/audio_device:audio_device_api",
|
||||
"../modules/audio_device:audio_device_buffer",
|
||||
"../modules/audio_device:audio_device_generic",
|
||||
|
||||
@ -1124,6 +1124,7 @@ if (is_android) {
|
||||
":base_jni",
|
||||
":generated_audio_device_module_base_jni",
|
||||
":native_api_jni",
|
||||
"../../api/task_queue:global_task_queue_factory",
|
||||
"../../modules/audio_device:audio_device_api",
|
||||
"../../modules/audio_device:audio_device_buffer",
|
||||
"../../rtc_base:checks",
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
#include <utility>
|
||||
|
||||
#include "absl/memory/memory.h"
|
||||
#include "api/task_queue/global_task_queue_factory.h"
|
||||
#include "modules/audio_device/audio_device_buffer.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/logging.h"
|
||||
@ -88,7 +89,8 @@ class AndroidAudioDeviceModule : public AudioDeviceModule {
|
||||
int32_t Init() override {
|
||||
RTC_LOG(INFO) << __FUNCTION__;
|
||||
RTC_DCHECK(thread_checker_.CalledOnValidThread());
|
||||
audio_device_buffer_ = absl::make_unique<AudioDeviceBuffer>();
|
||||
audio_device_buffer_ =
|
||||
absl::make_unique<AudioDeviceBuffer>(&GlobalTaskQueueFactory());
|
||||
AttachAudioBuffer();
|
||||
if (initialized_) {
|
||||
return 0;
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
|
||||
#include "audio_device_module_ios.h"
|
||||
|
||||
#include "api/task_queue/global_task_queue_factory.h"
|
||||
#include "modules/audio_device/audio_device_config.h"
|
||||
#include "modules/audio_device/audio_device_generic.h"
|
||||
#include "rtc_base/checks.h"
|
||||
@ -69,7 +70,7 @@ namespace ios_adm {
|
||||
if (initialized_)
|
||||
return 0;
|
||||
|
||||
audio_device_buffer_.reset(new webrtc::AudioDeviceBuffer());
|
||||
audio_device_buffer_.reset(new webrtc::AudioDeviceBuffer(&GlobalTaskQueueFactory()));
|
||||
audio_device_.reset(new ios_adm::AudioDeviceIOS());
|
||||
RTC_CHECK(audio_device_);
|
||||
|
||||
|
||||
@ -247,6 +247,8 @@ if (rtc_include_tests) {
|
||||
"../api:fec_controller_api",
|
||||
"../api:test_dependency_factory",
|
||||
"../api:video_quality_test_fixture_api",
|
||||
"../api/task_queue",
|
||||
"../api/task_queue:default_task_queue_factory",
|
||||
"../api/video:builtin_video_bitrate_allocator_factory",
|
||||
"../api/video:video_bitrate_allocator_factory",
|
||||
"../api/video:video_frame",
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "absl/memory/memory.h"
|
||||
#include "api/task_queue/default_task_queue_factory.h"
|
||||
#include "api/video/builtin_video_bitrate_allocator_factory.h"
|
||||
#include "call/fake_network_pipe.h"
|
||||
#include "call/simulated_network.h"
|
||||
@ -323,6 +324,7 @@ std::unique_ptr<VideoEncoder> VideoQualityTest::CreateVideoEncoder(
|
||||
VideoQualityTest::VideoQualityTest(
|
||||
std::unique_ptr<InjectionComponents> injection_components)
|
||||
: clock_(Clock::GetRealTimeClock()),
|
||||
task_queue_factory_(CreateDefaultTaskQueueFactory()),
|
||||
video_decoder_factory_([this](const SdpVideoFormat& format) {
|
||||
return this->CreateVideoDecoder(format);
|
||||
}),
|
||||
@ -1307,10 +1309,11 @@ rtc::scoped_refptr<AudioDeviceModule> VideoQualityTest::CreateAudioDevice() {
|
||||
RTC_CHECK(com_initializer_->Succeeded());
|
||||
RTC_CHECK(webrtc_win::core_audio_utility::IsSupported());
|
||||
RTC_CHECK(webrtc_win::core_audio_utility::IsMMCSSSupported());
|
||||
return CreateWindowsCoreAudioAudioDeviceModule();
|
||||
return CreateWindowsCoreAudioAudioDeviceModule(task_queue_factory_.get());
|
||||
#else
|
||||
// Use legacy factory method on all platforms except Windows.
|
||||
return AudioDeviceModule::Create(AudioDeviceModule::kPlatformDefaultAudio);
|
||||
return AudioDeviceModule::Create(AudioDeviceModule::kPlatformDefaultAudio,
|
||||
task_queue_factory_.get());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "api/fec_controller.h"
|
||||
#include "api/task_queue/task_queue_factory.h"
|
||||
#include "api/test/video_quality_test_fixture.h"
|
||||
#include "api/video/video_bitrate_allocator_factory.h"
|
||||
#include "call/fake_network_pipe.h"
|
||||
@ -100,6 +101,7 @@ class VideoQualityTest :
|
||||
std::vector<std::unique_ptr<rtc::VideoSourceInterface<VideoFrame>>>
|
||||
thumbnail_capturers_;
|
||||
Clock* const clock_;
|
||||
const std::unique_ptr<TaskQueueFactory> task_queue_factory_;
|
||||
|
||||
test::FunctionVideoDecoderFactory video_decoder_factory_;
|
||||
InternalDecoderFactory internal_decoder_factory_;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user