1 /* 2 * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #include "modules/audio_device/include/audio_device_factory.h" 12 13 #include <memory> 14 15 #if defined(WEBRTC_WIN) 16 #include "modules/audio_device/win/audio_device_module_win.h" 17 #include "modules/audio_device/win/core_audio_input_win.h" 18 #include "modules/audio_device/win/core_audio_output_win.h" 19 #include "modules/audio_device/win/core_audio_utility_win.h" 20 #endif 21 22 #include "api/task_queue/task_queue_factory.h" 23 #include "rtc_base/logging.h" 24 25 namespace webrtc { 26 CreateWindowsCoreAudioAudioDeviceModule(TaskQueueFactory * task_queue_factory,bool automatic_restart)27rtc::scoped_refptr<AudioDeviceModule> CreateWindowsCoreAudioAudioDeviceModule( 28 TaskQueueFactory* task_queue_factory, 29 bool automatic_restart) { 30 RTC_DLOG(INFO) << __FUNCTION__; 31 return CreateWindowsCoreAudioAudioDeviceModuleForTest(task_queue_factory, 32 automatic_restart); 33 } 34 35 rtc::scoped_refptr<AudioDeviceModuleForTest> CreateWindowsCoreAudioAudioDeviceModuleForTest(TaskQueueFactory * task_queue_factory,bool automatic_restart)36CreateWindowsCoreAudioAudioDeviceModuleForTest( 37 TaskQueueFactory* task_queue_factory, 38 bool automatic_restart) { 39 RTC_DLOG(INFO) << __FUNCTION__; 40 // Returns NULL if Core Audio is not supported or if COM has not been 41 // initialized correctly using webrtc_win::ScopedCOMInitializer. 42 if (!webrtc_win::core_audio_utility::IsSupported()) { 43 RTC_LOG(LS_ERROR) 44 << "Unable to create ADM since Core Audio is not supported"; 45 return nullptr; 46 } 47 return CreateWindowsCoreAudioAudioDeviceModuleFromInputAndOutput( 48 std::make_unique<webrtc_win::CoreAudioInput>(automatic_restart), 49 std::make_unique<webrtc_win::CoreAudioOutput>(automatic_restart), 50 task_queue_factory); 51 } 52 53 } // namespace webrtc 54