tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

audio_device_factory.cc (2002B)


      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 #include "api/audio/audio_device.h"
     16 #include "api/environment/environment.h"
     17 #include "api/scoped_refptr.h"
     18 #include "rtc_base/logging.h"
     19 
     20 #if defined(WEBRTC_WIN)
     21 #include "modules/audio_device/win/audio_device_module_win.h"
     22 #include "modules/audio_device/win/core_audio_input_win.h"
     23 #include "modules/audio_device/win/core_audio_output_win.h"
     24 #include "modules/audio_device/win/core_audio_utility_win.h"
     25 #endif
     26 
     27 namespace webrtc {
     28 
     29 webrtc::scoped_refptr<AudioDeviceModule>
     30 CreateWindowsCoreAudioAudioDeviceModule(const Environment& env,
     31                                        bool automatic_restart) {
     32  RTC_DLOG(LS_INFO) << __FUNCTION__;
     33  return CreateWindowsCoreAudioAudioDeviceModuleForTest(env, automatic_restart);
     34 }
     35 
     36 webrtc::scoped_refptr<AudioDeviceModuleForTest>
     37 CreateWindowsCoreAudioAudioDeviceModuleForTest(const Environment& env,
     38                                               bool automatic_restart) {
     39  RTC_DLOG(LS_INFO) << __FUNCTION__;
     40  // Returns NULL if Core Audio is not supported or if COM has not been
     41  // initialized correctly using 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      env, std::make_unique<webrtc_win::CoreAudioInput>(env, automatic_restart),
     49      std::make_unique<webrtc_win::CoreAudioOutput>(env, automatic_restart));
     50 }
     51 
     52 }  // namespace webrtc