webrtc/modules/audio_device/include/audio_device_factory.cc
Danil Chapovalov 1c41be6e05 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}
2019-04-01 08:00:49 +00:00

48 lines
1.8 KiB
C++

/*
* Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "modules/audio_device/include/audio_device_factory.h"
#if defined(WEBRTC_WIN)
#include "modules/audio_device/win/audio_device_module_win.h"
#include "modules/audio_device/win/core_audio_input_win.h"
#include "modules/audio_device/win/core_audio_output_win.h"
#include "modules/audio_device/win/core_audio_utility_win.h"
#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(
TaskQueueFactory* task_queue_factory) {
RTC_DLOG(INFO) << __FUNCTION__;
return CreateWindowsCoreAudioAudioDeviceModuleForTest(task_queue_factory);
}
rtc::scoped_refptr<AudioDeviceModuleForTest>
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.
if (!webrtc_win::core_audio_utility::IsSupported()) {
RTC_LOG(LS_ERROR)
<< "Unable to create ADM since Core Audio is not supported";
return nullptr;
}
return CreateWindowsCoreAudioAudioDeviceModuleFromInputAndOutput(
absl::make_unique<webrtc_win::CoreAudioInput>(),
absl::make_unique<webrtc_win::CoreAudioOutput>(), task_queue_factory);
}
} // namespace webrtc