audio_device_factory.h (2240B)
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 #ifndef MODULES_AUDIO_DEVICE_INCLUDE_AUDIO_DEVICE_FACTORY_H_ 12 #define MODULES_AUDIO_DEVICE_INCLUDE_AUDIO_DEVICE_FACTORY_H_ 13 14 #include "api/audio/audio_device.h" 15 #include "api/environment/environment.h" 16 #include "api/scoped_refptr.h" 17 18 namespace webrtc { 19 20 // Creates an AudioDeviceModule (ADM) for Windows based on the Core Audio API. 21 // The creating thread must be a COM thread; otherwise nullptr will be returned. 22 // By default `automatic_restart` is set to true and it results in support for 23 // automatic restart of audio if e.g. the existing device is removed. If set to 24 // false, no attempt to restart audio is performed under these conditions. 25 // 26 // Example (assuming webrtc namespace): 27 // 28 // public: 29 // scoped_refptr<AudioDeviceModule> CreateAudioDevice() { 30 // Environment env = CreateEnvironment(); 31 // // Tell COM that this thread shall live in the MTA. 32 // com_initializer_ = std::make_unique<ScopedCOMInitializer>( 33 // ScopedCOMInitializer::kMTA); 34 // if (!com_initializer_->Succeeded()) { 35 // return nullptr; 36 // } 37 // // Create the ADM with support for automatic restart if devices are 38 // // unplugged. 39 // return CreateWindowsCoreAudioAudioDeviceModule(env); 40 // } 41 // 42 // private: 43 // std::unique_ptr<ScopedCOMInitializer> com_initializer_; 44 // std::unique_ptr<TaskQueueFactory> task_queue_factory_; 45 // 46 webrtc::scoped_refptr<AudioDeviceModule> 47 CreateWindowsCoreAudioAudioDeviceModule(const Environment& env, 48 bool automatic_restart = true); 49 50 webrtc::scoped_refptr<AudioDeviceModuleForTest> 51 CreateWindowsCoreAudioAudioDeviceModuleForTest(const Environment& env, 52 bool automatic_restart = true); 53 54 } // namespace webrtc 55 56 #endif // MODULES_AUDIO_DEVICE_INCLUDE_AUDIO_DEVICE_FACTORY_H_