niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
xians@webrtc.org | 20aabbb | 2012-02-20 09:17:41 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #include "modules/audio_device/audio_device_impl.h" |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 12 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 13 | #include "modules/audio_device/audio_device_config.h" |
| 14 | #include "modules/audio_device/audio_device_generic.h" |
| 15 | #include "rtc_base/checks.h" |
| 16 | #include "rtc_base/logging.h" |
| 17 | #include "rtc_base/refcount.h" |
Niels Möller | 84255bb | 2017-10-06 13:43:23 +0200 | [diff] [blame] | 18 | #include "rtc_base/refcountedobject.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 19 | #include "system_wrappers/include/metrics.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 20 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 21 | #if defined(_WIN32) |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 22 | #if defined(WEBRTC_WINDOWS_CORE_AUDIO_BUILD) |
| 23 | #include "audio_device_core_win.h" |
| 24 | #endif |
leozwang@google.com | 39f2051 | 2011-07-15 16:29:40 +0000 | [diff] [blame] | 25 | #elif defined(WEBRTC_ANDROID) |
henrika | b261989 | 2015-05-18 16:49:16 +0200 | [diff] [blame] | 26 | #include <stdlib.h> |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 27 | #include "modules/audio_device/android/audio_device_template.h" |
| 28 | #include "modules/audio_device/android/audio_manager.h" |
| 29 | #include "modules/audio_device/android/audio_record_jni.h" |
| 30 | #include "modules/audio_device/android/audio_track_jni.h" |
| 31 | #include "modules/audio_device/android/opensles_player.h" |
| 32 | #include "modules/audio_device/android/opensles_recorder.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 33 | #elif defined(WEBRTC_LINUX) |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 34 | #if defined(LINUX_ALSA) |
| 35 | #include "audio_device_alsa_linux.h" |
| 36 | #endif |
Tommi | 68898a2 | 2015-05-19 17:28:07 +0200 | [diff] [blame] | 37 | #if defined(LINUX_PULSE) |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 38 | #include "audio_device_pulse_linux.h" |
Tommi | 68898a2 | 2015-05-19 17:28:07 +0200 | [diff] [blame] | 39 | #endif |
sjlee@webrtc.org | 414fa7f | 2012-09-11 17:25:46 +0000 | [diff] [blame] | 40 | #elif defined(WEBRTC_IOS) |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 41 | #include "audio_device_ios.h" |
andrew@webrtc.org | f3b65db | 2012-09-06 18:17:00 +0000 | [diff] [blame] | 42 | #elif defined(WEBRTC_MAC) |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 43 | #include "audio_device_mac.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 44 | #endif |
phoglund@webrtc.org | 8454ad1 | 2014-06-11 14:12:04 +0000 | [diff] [blame] | 45 | #if defined(WEBRTC_DUMMY_FILE_DEVICES) |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 46 | #include "modules/audio_device/dummy/file_audio_device_factory.h" |
phoglund@webrtc.org | 8454ad1 | 2014-06-11 14:12:04 +0000 | [diff] [blame] | 47 | #endif |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 48 | #include "modules/audio_device/dummy/audio_device_dummy.h" |
| 49 | #include "modules/audio_device/dummy/file_audio_device.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 50 | |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 51 | #define CHECKinitialized_() \ |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 52 | { \ |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 53 | if (!initialized_) { \ |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 54 | return -1; \ |
| 55 | }; \ |
| 56 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 57 | |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 58 | #define CHECKinitialized__BOOL() \ |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 59 | { \ |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 60 | if (!initialized_) { \ |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 61 | return false; \ |
| 62 | }; \ |
| 63 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 64 | |
Peter Boström | 1d19441 | 2016-03-21 16:44:31 +0100 | [diff] [blame] | 65 | namespace webrtc { |
henrike@webrtc.org | 70efc32 | 2012-02-23 17:45:33 +0000 | [diff] [blame] | 66 | |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 67 | // static |
Peter Boström | 4adbbcf | 2016-05-03 15:51:26 -0400 | [diff] [blame] | 68 | rtc::scoped_refptr<AudioDeviceModule> AudioDeviceModule::Create( |
Peter Boström | 4adbbcf | 2016-05-03 15:51:26 -0400 | [diff] [blame] | 69 | const AudioLayer audio_layer) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 70 | RTC_LOG(INFO) << __FUNCTION__; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 71 | // Create the generic reference counted (platform independent) implementation. |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 72 | rtc::scoped_refptr<AudioDeviceModuleImpl> audioDevice( |
henrika | 5ff6483 | 2017-10-11 15:14:51 +0200 | [diff] [blame] | 73 | new rtc::RefCountedObject<AudioDeviceModuleImpl>(audio_layer)); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 74 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 75 | // Ensure that the current platform is supported. |
| 76 | if (audioDevice->CheckPlatform() == -1) { |
| 77 | return nullptr; |
| 78 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 79 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 80 | // Create the platform-dependent implementation. |
| 81 | if (audioDevice->CreatePlatformSpecificObjects() == -1) { |
| 82 | return nullptr; |
| 83 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 84 | |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 85 | // Ensure that the generic audio buffer can communicate with the platform |
| 86 | // specific parts. |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 87 | if (audioDevice->AttachAudioBuffer() == -1) { |
| 88 | return nullptr; |
| 89 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 90 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 91 | return audioDevice; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 92 | } |
| 93 | |
henrika | 616e313 | 2017-11-13 12:47:59 +0100 | [diff] [blame] | 94 | // TODO(bugs.webrtc.org/7306): deprecated. |
| 95 | rtc::scoped_refptr<AudioDeviceModule> AudioDeviceModule::Create( |
| 96 | const int32_t id, |
| 97 | const AudioLayer audio_layer) { |
| 98 | RTC_LOG(INFO) << __FUNCTION__; |
| 99 | return AudioDeviceModule::Create(audio_layer); |
| 100 | } |
| 101 | |
henrika | 5ff6483 | 2017-10-11 15:14:51 +0200 | [diff] [blame] | 102 | AudioDeviceModuleImpl::AudioDeviceModuleImpl(const AudioLayer audioLayer) |
| 103 | : audio_layer_(audioLayer) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 104 | RTC_LOG(INFO) << __FUNCTION__; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 105 | } |
| 106 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 107 | int32_t AudioDeviceModuleImpl::CheckPlatform() { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 108 | RTC_LOG(INFO) << __FUNCTION__; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 109 | // Ensure that the current platform is supported |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 110 | PlatformType platform(kPlatformNotSupported); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 111 | #if defined(_WIN32) |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 112 | platform = kPlatformWin32; |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 113 | RTC_LOG(INFO) << "current platform is Win32"; |
leozwang@google.com | 522f42b | 2011-09-19 17:39:05 +0000 | [diff] [blame] | 114 | #elif defined(WEBRTC_ANDROID) |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 115 | platform = kPlatformAndroid; |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 116 | RTC_LOG(INFO) << "current platform is Android"; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 117 | #elif defined(WEBRTC_LINUX) |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 118 | platform = kPlatformLinux; |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 119 | RTC_LOG(INFO) << "current platform is Linux"; |
sjlee@webrtc.org | 414fa7f | 2012-09-11 17:25:46 +0000 | [diff] [blame] | 120 | #elif defined(WEBRTC_IOS) |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 121 | platform = kPlatformIOS; |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 122 | RTC_LOG(INFO) << "current platform is IOS"; |
andrew@webrtc.org | f3b65db | 2012-09-06 18:17:00 +0000 | [diff] [blame] | 123 | #elif defined(WEBRTC_MAC) |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 124 | platform = kPlatformMac; |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 125 | RTC_LOG(INFO) << "current platform is Mac"; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 126 | #endif |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 127 | if (platform == kPlatformNotSupported) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 128 | RTC_LOG(LERROR) |
| 129 | << "current platform is not supported => this module will self " |
| 130 | "destruct!"; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 131 | return -1; |
| 132 | } |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 133 | platform_type_ = platform; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 134 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 135 | } |
| 136 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 137 | int32_t AudioDeviceModuleImpl::CreatePlatformSpecificObjects() { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 138 | RTC_LOG(INFO) << __FUNCTION__; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 139 | // Dummy ADM implementations if build flags are set. |
xians@google.com | bf5d2ba | 2011-08-16 07:44:19 +0000 | [diff] [blame] | 140 | #if defined(WEBRTC_DUMMY_AUDIO_BUILD) |
henrika | 5ff6483 | 2017-10-11 15:14:51 +0200 | [diff] [blame] | 141 | audio_device_.reset(new AudioDeviceDummy()); |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 142 | RTC_LOG(INFO) << "Dummy Audio APIs will be utilized"; |
phoglund@webrtc.org | 8454ad1 | 2014-06-11 14:12:04 +0000 | [diff] [blame] | 143 | #elif defined(WEBRTC_DUMMY_FILE_DEVICES) |
henrika | 5ff6483 | 2017-10-11 15:14:51 +0200 | [diff] [blame] | 144 | audio_device_.reset(FileAudioDeviceFactory::CreateFileAudioDevice()); |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 145 | if (audio_device_) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 146 | RTC_LOG(INFO) << "Will use file-playing dummy device."; |
noahric | 6a35590 | 2016-08-17 15:19:50 -0700 | [diff] [blame] | 147 | } else { |
| 148 | // Create a dummy device instead. |
henrika | 5ff6483 | 2017-10-11 15:14:51 +0200 | [diff] [blame] | 149 | audio_device_.reset(new AudioDeviceDummy()); |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 150 | RTC_LOG(INFO) << "Dummy Audio APIs will be utilized"; |
noahric | 6a35590 | 2016-08-17 15:19:50 -0700 | [diff] [blame] | 151 | } |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 152 | |
| 153 | // Real (non-dummy) ADM implementations. |
xians@google.com | bf5d2ba | 2011-08-16 07:44:19 +0000 | [diff] [blame] | 154 | #else |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 155 | AudioLayer audio_layer(PlatformAudioLayer()); |
| 156 | // Windows ADM implementation. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 157 | #if defined(WEBRTC_WINDOWS_CORE_AUDIO_BUILD) |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 158 | if ((audio_layer == kWindowsCoreAudio) || |
| 159 | (audio_layer == kPlatformDefaultAudio)) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 160 | RTC_LOG(INFO) << "Attempting to use the Windows Core Audio APIs..."; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 161 | if (AudioDeviceWindowsCore::CoreAudioIsSupported()) { |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 162 | audio_device_.reset(new AudioDeviceWindowsCore()); |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 163 | RTC_LOG(INFO) << "Windows Core Audio APIs will be utilized"; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 164 | } |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 165 | } |
| 166 | #endif // defined(WEBRTC_WINDOWS_CORE_AUDIO_BUILD) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 167 | |
henrike@webrtc.org | 9ee75e9 | 2013-12-11 21:42:44 +0000 | [diff] [blame] | 168 | #if defined(WEBRTC_ANDROID) |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 169 | // Create an Android audio manager. |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 170 | audio_manager_android_.reset(new AudioManager()); |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 171 | // Select best possible combination of audio layers. |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 172 | if (audio_layer == kPlatformDefaultAudio) { |
| 173 | if (audio_manager_android_->IsLowLatencyPlayoutSupported() && |
| 174 | audio_manager_android_->IsLowLatencyRecordSupported()) { |
henrika | 918b554 | 2016-09-19 15:44:09 +0200 | [diff] [blame] | 175 | // Use OpenSL ES for both playout and recording. |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 176 | audio_layer = kAndroidOpenSLESAudio; |
| 177 | } else if (audio_manager_android_->IsLowLatencyPlayoutSupported() && |
| 178 | !audio_manager_android_->IsLowLatencyRecordSupported()) { |
henrika | 918b554 | 2016-09-19 15:44:09 +0200 | [diff] [blame] | 179 | // Use OpenSL ES for output on devices that only supports the |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 180 | // low-latency output audio path. |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 181 | audio_layer = kAndroidJavaInputAndOpenSLESOutputAudio; |
henrika | b261989 | 2015-05-18 16:49:16 +0200 | [diff] [blame] | 182 | } else { |
henrika | 918b554 | 2016-09-19 15:44:09 +0200 | [diff] [blame] | 183 | // Use Java-based audio in both directions when low-latency output is |
| 184 | // not supported. |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 185 | audio_layer = kAndroidJavaAudio; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 186 | } |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 187 | } |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 188 | AudioManager* audio_manager = audio_manager_android_.get(); |
| 189 | if (audio_layer == kAndroidJavaAudio) { |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 190 | // Java audio for both input and output audio. |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 191 | audio_device_.reset(new AudioDeviceTemplate<AudioRecordJni, AudioTrackJni>( |
| 192 | audio_layer, audio_manager)); |
| 193 | } else if (audio_layer == kAndroidOpenSLESAudio) { |
henrika | 918b554 | 2016-09-19 15:44:09 +0200 | [diff] [blame] | 194 | // OpenSL ES based audio for both input and output audio. |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 195 | audio_device_.reset( |
| 196 | new AudioDeviceTemplate<OpenSLESRecorder, OpenSLESPlayer>( |
| 197 | audio_layer, audio_manager)); |
| 198 | } else if (audio_layer == kAndroidJavaInputAndOpenSLESOutputAudio) { |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 199 | // Java audio for input and OpenSL ES for output audio (i.e. mixed APIs). |
| 200 | // This combination provides low-latency output audio and at the same |
| 201 | // time support for HW AEC using the AudioRecord Java API. |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 202 | audio_device_.reset(new AudioDeviceTemplate<AudioRecordJni, OpenSLESPlayer>( |
| 203 | audio_layer, audio_manager)); |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 204 | } else { |
| 205 | // Invalid audio layer. |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 206 | audio_device_.reset(nullptr); |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 207 | } |
| 208 | // END #if defined(WEBRTC_ANDROID) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 209 | |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 210 | // Linux ADM implementation. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 211 | #elif defined(WEBRTC_LINUX) |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 212 | if ((audio_layer == kLinuxPulseAudio) || |
| 213 | (audio_layer == kPlatformDefaultAudio)) { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 214 | #if defined(LINUX_PULSE) |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 215 | RTC_LOG(INFO) << "Attempting to use Linux PulseAudio APIs..."; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 216 | // Linux PulseAudio implementation. |
| 217 | audio_device_.reset(new AudioDeviceLinuxPulse()); |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 218 | RTC_LOG(INFO) << "Linux PulseAudio APIs will be utilized"; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 219 | #endif |
| 220 | #if defined(LINUX_PULSE) |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 221 | #endif |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 222 | } else if (audio_layer == kLinuxAlsaAudio) { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 223 | #if defined(LINUX_ALSA) |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 224 | // Linux ALSA implementation. |
| 225 | audio_device_.reset(new AudioDeviceLinuxALSA()); |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 226 | RTC_LOG(INFO) << "Linux ALSA APIs will be utilized."; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 227 | #endif |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 228 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 229 | #endif // #if defined(WEBRTC_LINUX) |
| 230 | |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 231 | // iOS ADM implementation. |
sjlee@webrtc.org | 414fa7f | 2012-09-11 17:25:46 +0000 | [diff] [blame] | 232 | #if defined(WEBRTC_IOS) |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 233 | if (audio_layer == kPlatformDefaultAudio) { |
| 234 | audio_device_.reset(new AudioDeviceIOS()); |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 235 | RTC_LOG(INFO) << "iPhone Audio APIs will be utilized."; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 236 | } |
| 237 | // END #if defined(WEBRTC_IOS) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 238 | |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 239 | // Mac OS X ADM implementation. |
andrew@webrtc.org | f3b65db | 2012-09-06 18:17:00 +0000 | [diff] [blame] | 240 | #elif defined(WEBRTC_MAC) |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 241 | if (audio_layer == kPlatformDefaultAudio) { |
| 242 | audio_device_.reset(new AudioDeviceMac()); |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 243 | RTC_LOG(INFO) << "Mac OS X Audio APIs will be utilized."; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 244 | } |
andrew@webrtc.org | f3b65db | 2012-09-06 18:17:00 +0000 | [diff] [blame] | 245 | #endif // WEBRTC_MAC |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 246 | |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 247 | // Dummy ADM implementation. |
| 248 | if (audio_layer == kDummyAudio) { |
henrika | 5ff6483 | 2017-10-11 15:14:51 +0200 | [diff] [blame] | 249 | audio_device_.reset(new AudioDeviceDummy()); |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 250 | RTC_LOG(INFO) << "Dummy Audio APIs will be utilized."; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 251 | } |
xians@google.com | bf5d2ba | 2011-08-16 07:44:19 +0000 | [diff] [blame] | 252 | #endif // if defined(WEBRTC_DUMMY_AUDIO_BUILD) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 253 | |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 254 | if (!audio_device_) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 255 | RTC_LOG(LS_ERROR) |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 256 | << "Failed to create the platform specific ADM implementation."; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 257 | return -1; |
| 258 | } |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 259 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 260 | } |
| 261 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 262 | int32_t AudioDeviceModuleImpl::AttachAudioBuffer() { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 263 | RTC_LOG(INFO) << __FUNCTION__; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 264 | audio_device_->AttachAudioBuffer(&audio_device_buffer_); |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 265 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 266 | } |
| 267 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 268 | AudioDeviceModuleImpl::~AudioDeviceModuleImpl() { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 269 | RTC_LOG(INFO) << __FUNCTION__; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 270 | } |
| 271 | |
henrika | b261989 | 2015-05-18 16:49:16 +0200 | [diff] [blame] | 272 | int32_t AudioDeviceModuleImpl::ActiveAudioLayer(AudioLayer* audioLayer) const { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 273 | RTC_LOG(INFO) << __FUNCTION__; |
henrika | b261989 | 2015-05-18 16:49:16 +0200 | [diff] [blame] | 274 | AudioLayer activeAudio; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 275 | if (audio_device_->ActiveAudioLayer(activeAudio) == -1) { |
henrika | b261989 | 2015-05-18 16:49:16 +0200 | [diff] [blame] | 276 | return -1; |
| 277 | } |
| 278 | *audioLayer = activeAudio; |
| 279 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 280 | } |
| 281 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 282 | int32_t AudioDeviceModuleImpl::Init() { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 283 | RTC_LOG(INFO) << __FUNCTION__; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 284 | if (initialized_) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 285 | return 0; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 286 | RTC_CHECK(audio_device_); |
| 287 | AudioDeviceGeneric::InitStatus status = audio_device_->Init(); |
Max Morin | 84cab20 | 2016-07-01 13:35:19 +0200 | [diff] [blame] | 288 | RTC_HISTOGRAM_ENUMERATION( |
| 289 | "WebRTC.Audio.InitializationResult", static_cast<int>(status), |
| 290 | static_cast<int>(AudioDeviceGeneric::InitStatus::NUM_STATUSES)); |
| 291 | if (status != AudioDeviceGeneric::InitStatus::OK) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 292 | RTC_LOG(LS_ERROR) << "Audio device initialization failed."; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 293 | return -1; |
| 294 | } |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 295 | initialized_ = true; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 296 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 297 | } |
| 298 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 299 | int32_t AudioDeviceModuleImpl::Terminate() { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 300 | RTC_LOG(INFO) << __FUNCTION__; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 301 | if (!initialized_) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 302 | return 0; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 303 | if (audio_device_->Terminate() == -1) { |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 304 | return -1; |
| 305 | } |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 306 | initialized_ = false; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 307 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 308 | } |
| 309 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 310 | bool AudioDeviceModuleImpl::Initialized() const { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 311 | RTC_LOG(INFO) << __FUNCTION__ << ": " << initialized_; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 312 | return initialized_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 313 | } |
| 314 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 315 | int32_t AudioDeviceModuleImpl::InitSpeaker() { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 316 | RTC_LOG(INFO) << __FUNCTION__; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 317 | CHECKinitialized_(); |
| 318 | return audio_device_->InitSpeaker(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 319 | } |
| 320 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 321 | int32_t AudioDeviceModuleImpl::InitMicrophone() { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 322 | RTC_LOG(INFO) << __FUNCTION__; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 323 | CHECKinitialized_(); |
| 324 | return audio_device_->InitMicrophone(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 325 | } |
| 326 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 327 | int32_t AudioDeviceModuleImpl::SpeakerVolumeIsAvailable(bool* available) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 328 | RTC_LOG(INFO) << __FUNCTION__; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 329 | CHECKinitialized_(); |
| 330 | bool isAvailable = false; |
| 331 | if (audio_device_->SpeakerVolumeIsAvailable(isAvailable) == -1) { |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 332 | return -1; |
| 333 | } |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 334 | *available = isAvailable; |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 335 | RTC_LOG(INFO) << "output: " << isAvailable; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 336 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 337 | } |
| 338 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 339 | int32_t AudioDeviceModuleImpl::SetSpeakerVolume(uint32_t volume) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 340 | RTC_LOG(INFO) << __FUNCTION__ << "(" << volume << ")"; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 341 | CHECKinitialized_(); |
| 342 | return audio_device_->SetSpeakerVolume(volume); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 343 | } |
| 344 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 345 | int32_t AudioDeviceModuleImpl::SpeakerVolume(uint32_t* volume) const { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 346 | RTC_LOG(INFO) << __FUNCTION__; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 347 | CHECKinitialized_(); |
| 348 | uint32_t level = 0; |
| 349 | if (audio_device_->SpeakerVolume(level) == -1) { |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 350 | return -1; |
| 351 | } |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 352 | *volume = level; |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 353 | RTC_LOG(INFO) << "output: " << *volume; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 354 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 355 | } |
| 356 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 357 | bool AudioDeviceModuleImpl::SpeakerIsInitialized() const { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 358 | RTC_LOG(INFO) << __FUNCTION__; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 359 | CHECKinitialized__BOOL(); |
| 360 | bool isInitialized = audio_device_->SpeakerIsInitialized(); |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 361 | RTC_LOG(INFO) << "output: " << isInitialized; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 362 | return isInitialized; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 363 | } |
| 364 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 365 | bool AudioDeviceModuleImpl::MicrophoneIsInitialized() const { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 366 | RTC_LOG(INFO) << __FUNCTION__; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 367 | CHECKinitialized__BOOL(); |
| 368 | bool isInitialized = audio_device_->MicrophoneIsInitialized(); |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 369 | RTC_LOG(INFO) << "output: " << isInitialized; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 370 | return isInitialized; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 371 | } |
| 372 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 373 | int32_t AudioDeviceModuleImpl::MaxSpeakerVolume(uint32_t* maxVolume) const { |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 374 | CHECKinitialized_(); |
| 375 | uint32_t maxVol = 0; |
| 376 | if (audio_device_->MaxSpeakerVolume(maxVol) == -1) { |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 377 | return -1; |
| 378 | } |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 379 | *maxVolume = maxVol; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 380 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 381 | } |
| 382 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 383 | int32_t AudioDeviceModuleImpl::MinSpeakerVolume(uint32_t* minVolume) const { |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 384 | CHECKinitialized_(); |
| 385 | uint32_t minVol = 0; |
| 386 | if (audio_device_->MinSpeakerVolume(minVol) == -1) { |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 387 | return -1; |
| 388 | } |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 389 | *minVolume = minVol; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 390 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 391 | } |
| 392 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 393 | int32_t AudioDeviceModuleImpl::SpeakerMuteIsAvailable(bool* available) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 394 | RTC_LOG(INFO) << __FUNCTION__; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 395 | CHECKinitialized_(); |
Mirko Bonadei | 72c4250 | 2017-11-09 09:33:23 +0100 | [diff] [blame] | 396 | bool isAvailable = false; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 397 | if (audio_device_->SpeakerMuteIsAvailable(isAvailable) == -1) { |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 398 | return -1; |
| 399 | } |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 400 | *available = isAvailable; |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 401 | RTC_LOG(INFO) << "output: " << isAvailable; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 402 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 403 | } |
| 404 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 405 | int32_t AudioDeviceModuleImpl::SetSpeakerMute(bool enable) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 406 | RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")"; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 407 | CHECKinitialized_(); |
| 408 | return audio_device_->SetSpeakerMute(enable); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 409 | } |
| 410 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 411 | int32_t AudioDeviceModuleImpl::SpeakerMute(bool* enabled) const { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 412 | RTC_LOG(INFO) << __FUNCTION__; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 413 | CHECKinitialized_(); |
| 414 | bool muted = false; |
| 415 | if (audio_device_->SpeakerMute(muted) == -1) { |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 416 | return -1; |
| 417 | } |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 418 | *enabled = muted; |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 419 | RTC_LOG(INFO) << "output: " << muted; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 420 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 421 | } |
| 422 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 423 | int32_t AudioDeviceModuleImpl::MicrophoneMuteIsAvailable(bool* available) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 424 | RTC_LOG(INFO) << __FUNCTION__; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 425 | CHECKinitialized_(); |
| 426 | bool isAvailable = false; |
| 427 | if (audio_device_->MicrophoneMuteIsAvailable(isAvailable) == -1) { |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 428 | return -1; |
| 429 | } |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 430 | *available = isAvailable; |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 431 | RTC_LOG(INFO) << "output: " << isAvailable; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 432 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 433 | } |
| 434 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 435 | int32_t AudioDeviceModuleImpl::SetMicrophoneMute(bool enable) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 436 | RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")"; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 437 | CHECKinitialized_(); |
| 438 | return (audio_device_->SetMicrophoneMute(enable)); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 439 | } |
| 440 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 441 | int32_t AudioDeviceModuleImpl::MicrophoneMute(bool* enabled) const { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 442 | RTC_LOG(INFO) << __FUNCTION__; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 443 | CHECKinitialized_(); |
| 444 | bool muted = false; |
| 445 | if (audio_device_->MicrophoneMute(muted) == -1) { |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 446 | return -1; |
| 447 | } |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 448 | *enabled = muted; |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 449 | RTC_LOG(INFO) << "output: " << muted; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 450 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 451 | } |
| 452 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 453 | int32_t AudioDeviceModuleImpl::MicrophoneVolumeIsAvailable(bool* available) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 454 | RTC_LOG(INFO) << __FUNCTION__; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 455 | CHECKinitialized_(); |
| 456 | bool isAvailable = false; |
| 457 | if (audio_device_->MicrophoneVolumeIsAvailable(isAvailable) == -1) { |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 458 | return -1; |
| 459 | } |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 460 | *available = isAvailable; |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 461 | RTC_LOG(INFO) << "output: " << isAvailable; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 462 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 463 | } |
| 464 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 465 | int32_t AudioDeviceModuleImpl::SetMicrophoneVolume(uint32_t volume) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 466 | RTC_LOG(INFO) << __FUNCTION__ << "(" << volume << ")"; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 467 | CHECKinitialized_(); |
| 468 | return (audio_device_->SetMicrophoneVolume(volume)); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 469 | } |
| 470 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 471 | int32_t AudioDeviceModuleImpl::MicrophoneVolume(uint32_t* volume) const { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 472 | RTC_LOG(INFO) << __FUNCTION__; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 473 | CHECKinitialized_(); |
| 474 | uint32_t level = 0; |
| 475 | if (audio_device_->MicrophoneVolume(level) == -1) { |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 476 | return -1; |
| 477 | } |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 478 | *volume = level; |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 479 | RTC_LOG(INFO) << "output: " << *volume; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 480 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 481 | } |
| 482 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 483 | int32_t AudioDeviceModuleImpl::StereoRecordingIsAvailable( |
| 484 | bool* available) const { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 485 | RTC_LOG(INFO) << __FUNCTION__; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 486 | CHECKinitialized_(); |
| 487 | bool isAvailable = false; |
| 488 | if (audio_device_->StereoRecordingIsAvailable(isAvailable) == -1) { |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 489 | return -1; |
| 490 | } |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 491 | *available = isAvailable; |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 492 | RTC_LOG(INFO) << "output: " << isAvailable; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 493 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 494 | } |
| 495 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 496 | int32_t AudioDeviceModuleImpl::SetStereoRecording(bool enable) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 497 | RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")"; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 498 | CHECKinitialized_(); |
| 499 | if (audio_device_->RecordingIsInitialized()) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 500 | RTC_LOG(WARNING) << "recording in stereo is not supported"; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 501 | return -1; |
| 502 | } |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 503 | if (audio_device_->SetStereoRecording(enable) == -1) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 504 | RTC_LOG(WARNING) << "failed to change stereo recording"; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 505 | return -1; |
| 506 | } |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 507 | int8_t nChannels(1); |
| 508 | if (enable) { |
| 509 | nChannels = 2; |
| 510 | } |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 511 | audio_device_buffer_.SetRecordingChannels(nChannels); |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 512 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 513 | } |
| 514 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 515 | int32_t AudioDeviceModuleImpl::StereoRecording(bool* enabled) const { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 516 | RTC_LOG(INFO) << __FUNCTION__; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 517 | CHECKinitialized_(); |
| 518 | bool stereo = false; |
| 519 | if (audio_device_->StereoRecording(stereo) == -1) { |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 520 | return -1; |
| 521 | } |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 522 | *enabled = stereo; |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 523 | RTC_LOG(INFO) << "output: " << stereo; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 524 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 525 | } |
| 526 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 527 | int32_t AudioDeviceModuleImpl::StereoPlayoutIsAvailable(bool* available) const { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 528 | RTC_LOG(INFO) << __FUNCTION__; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 529 | CHECKinitialized_(); |
| 530 | bool isAvailable = false; |
| 531 | if (audio_device_->StereoPlayoutIsAvailable(isAvailable) == -1) { |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 532 | return -1; |
| 533 | } |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 534 | *available = isAvailable; |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 535 | RTC_LOG(INFO) << "output: " << isAvailable; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 536 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 537 | } |
| 538 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 539 | int32_t AudioDeviceModuleImpl::SetStereoPlayout(bool enable) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 540 | RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")"; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 541 | CHECKinitialized_(); |
| 542 | if (audio_device_->PlayoutIsInitialized()) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 543 | RTC_LOG(LERROR) |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 544 | << "unable to set stereo mode while playing side is initialized"; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 545 | return -1; |
| 546 | } |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 547 | if (audio_device_->SetStereoPlayout(enable)) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 548 | RTC_LOG(WARNING) << "stereo playout is not supported"; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 549 | return -1; |
| 550 | } |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 551 | int8_t nChannels(1); |
| 552 | if (enable) { |
| 553 | nChannels = 2; |
| 554 | } |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 555 | audio_device_buffer_.SetPlayoutChannels(nChannels); |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 556 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 557 | } |
| 558 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 559 | int32_t AudioDeviceModuleImpl::StereoPlayout(bool* enabled) const { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 560 | RTC_LOG(INFO) << __FUNCTION__; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 561 | CHECKinitialized_(); |
| 562 | bool stereo = false; |
| 563 | if (audio_device_->StereoPlayout(stereo) == -1) { |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 564 | return -1; |
| 565 | } |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 566 | *enabled = stereo; |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 567 | RTC_LOG(INFO) << "output: " << stereo; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 568 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 569 | } |
| 570 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 571 | int32_t AudioDeviceModuleImpl::SetAGC(bool enable) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 572 | RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")"; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 573 | CHECKinitialized_(); |
| 574 | return (audio_device_->SetAGC(enable)); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 575 | } |
| 576 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 577 | bool AudioDeviceModuleImpl::AGC() const { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 578 | RTC_LOG(INFO) << __FUNCTION__; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 579 | CHECKinitialized__BOOL(); |
| 580 | return audio_device_->AGC(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 581 | } |
| 582 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 583 | int32_t AudioDeviceModuleImpl::PlayoutIsAvailable(bool* available) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 584 | RTC_LOG(INFO) << __FUNCTION__; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 585 | CHECKinitialized_(); |
| 586 | bool isAvailable = false; |
| 587 | if (audio_device_->PlayoutIsAvailable(isAvailable) == -1) { |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 588 | return -1; |
| 589 | } |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 590 | *available = isAvailable; |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 591 | RTC_LOG(INFO) << "output: " << isAvailable; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 592 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 593 | } |
| 594 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 595 | int32_t AudioDeviceModuleImpl::RecordingIsAvailable(bool* available) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 596 | RTC_LOG(INFO) << __FUNCTION__; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 597 | CHECKinitialized_(); |
| 598 | bool isAvailable = false; |
| 599 | if (audio_device_->RecordingIsAvailable(isAvailable) == -1) { |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 600 | return -1; |
| 601 | } |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 602 | *available = isAvailable; |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 603 | RTC_LOG(INFO) << "output: " << isAvailable; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 604 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 605 | } |
| 606 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 607 | int32_t AudioDeviceModuleImpl::MaxMicrophoneVolume(uint32_t* maxVolume) const { |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 608 | CHECKinitialized_(); |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 609 | uint32_t maxVol(0); |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 610 | if (audio_device_->MaxMicrophoneVolume(maxVol) == -1) { |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 611 | return -1; |
| 612 | } |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 613 | *maxVolume = maxVol; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 614 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 615 | } |
| 616 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 617 | int32_t AudioDeviceModuleImpl::MinMicrophoneVolume(uint32_t* minVolume) const { |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 618 | CHECKinitialized_(); |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 619 | uint32_t minVol(0); |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 620 | if (audio_device_->MinMicrophoneVolume(minVol) == -1) { |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 621 | return -1; |
| 622 | } |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 623 | *minVolume = minVol; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 624 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 625 | } |
| 626 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 627 | int16_t AudioDeviceModuleImpl::PlayoutDevices() { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 628 | RTC_LOG(INFO) << __FUNCTION__; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 629 | CHECKinitialized_(); |
| 630 | uint16_t nPlayoutDevices = audio_device_->PlayoutDevices(); |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 631 | RTC_LOG(INFO) << "output: " << nPlayoutDevices; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 632 | return (int16_t)(nPlayoutDevices); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 633 | } |
| 634 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 635 | int32_t AudioDeviceModuleImpl::SetPlayoutDevice(uint16_t index) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 636 | RTC_LOG(INFO) << __FUNCTION__ << "(" << index << ")"; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 637 | CHECKinitialized_(); |
| 638 | return audio_device_->SetPlayoutDevice(index); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 639 | } |
| 640 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 641 | int32_t AudioDeviceModuleImpl::SetPlayoutDevice(WindowsDeviceType device) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 642 | RTC_LOG(INFO) << __FUNCTION__; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 643 | CHECKinitialized_(); |
| 644 | return audio_device_->SetPlayoutDevice(device); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 645 | } |
| 646 | |
pbos@webrtc.org | 2550988 | 2013-04-09 10:30:35 +0000 | [diff] [blame] | 647 | int32_t AudioDeviceModuleImpl::PlayoutDeviceName( |
| 648 | uint16_t index, |
leozwang@webrtc.org | 28f3913 | 2012-03-01 18:01:48 +0000 | [diff] [blame] | 649 | char name[kAdmMaxDeviceNameSize], |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 650 | char guid[kAdmMaxGuidSize]) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 651 | RTC_LOG(INFO) << __FUNCTION__ << "(" << index << ", ...)"; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 652 | CHECKinitialized_(); |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 653 | if (name == NULL) { |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 654 | return -1; |
| 655 | } |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 656 | if (audio_device_->PlayoutDeviceName(index, name, guid) == -1) { |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 657 | return -1; |
| 658 | } |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 659 | if (name != NULL) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 660 | RTC_LOG(INFO) << "output: name = " << name; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 661 | } |
| 662 | if (guid != NULL) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 663 | RTC_LOG(INFO) << "output: guid = " << guid; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 664 | } |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 665 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 666 | } |
| 667 | |
pbos@webrtc.org | 2550988 | 2013-04-09 10:30:35 +0000 | [diff] [blame] | 668 | int32_t AudioDeviceModuleImpl::RecordingDeviceName( |
| 669 | uint16_t index, |
leozwang@webrtc.org | 28f3913 | 2012-03-01 18:01:48 +0000 | [diff] [blame] | 670 | char name[kAdmMaxDeviceNameSize], |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 671 | char guid[kAdmMaxGuidSize]) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 672 | RTC_LOG(INFO) << __FUNCTION__ << "(" << index << ", ...)"; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 673 | CHECKinitialized_(); |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 674 | if (name == NULL) { |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 675 | return -1; |
| 676 | } |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 677 | if (audio_device_->RecordingDeviceName(index, name, guid) == -1) { |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 678 | return -1; |
| 679 | } |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 680 | if (name != NULL) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 681 | RTC_LOG(INFO) << "output: name = " << name; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 682 | } |
| 683 | if (guid != NULL) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 684 | RTC_LOG(INFO) << "output: guid = " << guid; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 685 | } |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 686 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 687 | } |
| 688 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 689 | int16_t AudioDeviceModuleImpl::RecordingDevices() { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 690 | RTC_LOG(INFO) << __FUNCTION__; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 691 | CHECKinitialized_(); |
| 692 | uint16_t nRecordingDevices = audio_device_->RecordingDevices(); |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 693 | RTC_LOG(INFO) << "output: " << nRecordingDevices; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 694 | return (int16_t)nRecordingDevices; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 695 | } |
| 696 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 697 | int32_t AudioDeviceModuleImpl::SetRecordingDevice(uint16_t index) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 698 | RTC_LOG(INFO) << __FUNCTION__ << "(" << index << ")"; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 699 | CHECKinitialized_(); |
| 700 | return audio_device_->SetRecordingDevice(index); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 701 | } |
| 702 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 703 | int32_t AudioDeviceModuleImpl::SetRecordingDevice(WindowsDeviceType device) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 704 | RTC_LOG(INFO) << __FUNCTION__; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 705 | CHECKinitialized_(); |
| 706 | return audio_device_->SetRecordingDevice(device); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 707 | } |
| 708 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 709 | int32_t AudioDeviceModuleImpl::InitPlayout() { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 710 | RTC_LOG(INFO) << __FUNCTION__; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 711 | CHECKinitialized_(); |
maxmorin | 8c695b4 | 2016-07-25 02:46:44 -0700 | [diff] [blame] | 712 | if (PlayoutIsInitialized()) { |
| 713 | return 0; |
| 714 | } |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 715 | int32_t result = audio_device_->InitPlayout(); |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 716 | RTC_LOG(INFO) << "output: " << result; |
Max Morin | 84cab20 | 2016-07-01 13:35:19 +0200 | [diff] [blame] | 717 | RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.InitPlayoutSuccess", |
| 718 | static_cast<int>(result == 0)); |
| 719 | return result; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 720 | } |
| 721 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 722 | int32_t AudioDeviceModuleImpl::InitRecording() { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 723 | RTC_LOG(INFO) << __FUNCTION__; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 724 | CHECKinitialized_(); |
maxmorin | 8c695b4 | 2016-07-25 02:46:44 -0700 | [diff] [blame] | 725 | if (RecordingIsInitialized()) { |
| 726 | return 0; |
| 727 | } |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 728 | int32_t result = audio_device_->InitRecording(); |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 729 | RTC_LOG(INFO) << "output: " << result; |
Max Morin | 84cab20 | 2016-07-01 13:35:19 +0200 | [diff] [blame] | 730 | RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.InitRecordingSuccess", |
| 731 | static_cast<int>(result == 0)); |
| 732 | return result; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 733 | } |
| 734 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 735 | bool AudioDeviceModuleImpl::PlayoutIsInitialized() const { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 736 | RTC_LOG(INFO) << __FUNCTION__; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 737 | CHECKinitialized__BOOL(); |
| 738 | return audio_device_->PlayoutIsInitialized(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 739 | } |
| 740 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 741 | bool AudioDeviceModuleImpl::RecordingIsInitialized() const { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 742 | RTC_LOG(INFO) << __FUNCTION__; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 743 | CHECKinitialized__BOOL(); |
| 744 | return audio_device_->RecordingIsInitialized(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 745 | } |
| 746 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 747 | int32_t AudioDeviceModuleImpl::StartPlayout() { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 748 | RTC_LOG(INFO) << __FUNCTION__; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 749 | CHECKinitialized_(); |
maxmorin | 8c695b4 | 2016-07-25 02:46:44 -0700 | [diff] [blame] | 750 | if (Playing()) { |
| 751 | return 0; |
| 752 | } |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 753 | audio_device_buffer_.StartPlayout(); |
| 754 | int32_t result = audio_device_->StartPlayout(); |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 755 | RTC_LOG(INFO) << "output: " << result; |
Max Morin | 84cab20 | 2016-07-01 13:35:19 +0200 | [diff] [blame] | 756 | RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StartPlayoutSuccess", |
| 757 | static_cast<int>(result == 0)); |
| 758 | return result; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 759 | } |
| 760 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 761 | int32_t AudioDeviceModuleImpl::StopPlayout() { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 762 | RTC_LOG(INFO) << __FUNCTION__; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 763 | CHECKinitialized_(); |
| 764 | int32_t result = audio_device_->StopPlayout(); |
| 765 | audio_device_buffer_.StopPlayout(); |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 766 | RTC_LOG(INFO) << "output: " << result; |
Max Morin | 84cab20 | 2016-07-01 13:35:19 +0200 | [diff] [blame] | 767 | RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StopPlayoutSuccess", |
| 768 | static_cast<int>(result == 0)); |
| 769 | return result; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 770 | } |
| 771 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 772 | bool AudioDeviceModuleImpl::Playing() const { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 773 | RTC_LOG(INFO) << __FUNCTION__; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 774 | CHECKinitialized__BOOL(); |
| 775 | return audio_device_->Playing(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 776 | } |
| 777 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 778 | int32_t AudioDeviceModuleImpl::StartRecording() { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 779 | RTC_LOG(INFO) << __FUNCTION__; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 780 | CHECKinitialized_(); |
maxmorin | 8c695b4 | 2016-07-25 02:46:44 -0700 | [diff] [blame] | 781 | if (Recording()) { |
| 782 | return 0; |
| 783 | } |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 784 | audio_device_buffer_.StartRecording(); |
| 785 | int32_t result = audio_device_->StartRecording(); |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 786 | RTC_LOG(INFO) << "output: " << result; |
Max Morin | 84cab20 | 2016-07-01 13:35:19 +0200 | [diff] [blame] | 787 | RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StartRecordingSuccess", |
| 788 | static_cast<int>(result == 0)); |
| 789 | return result; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 790 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 791 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 792 | int32_t AudioDeviceModuleImpl::StopRecording() { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 793 | RTC_LOG(INFO) << __FUNCTION__; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 794 | CHECKinitialized_(); |
| 795 | int32_t result = audio_device_->StopRecording(); |
| 796 | audio_device_buffer_.StopRecording(); |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 797 | RTC_LOG(INFO) << "output: " << result; |
Max Morin | 84cab20 | 2016-07-01 13:35:19 +0200 | [diff] [blame] | 798 | RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StopRecordingSuccess", |
| 799 | static_cast<int>(result == 0)); |
| 800 | return result; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 801 | } |
| 802 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 803 | bool AudioDeviceModuleImpl::Recording() const { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 804 | RTC_LOG(INFO) << __FUNCTION__; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 805 | CHECKinitialized__BOOL(); |
| 806 | return audio_device_->Recording(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 807 | } |
| 808 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 809 | int32_t AudioDeviceModuleImpl::RegisterAudioCallback( |
| 810 | AudioTransport* audioCallback) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 811 | RTC_LOG(INFO) << __FUNCTION__; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 812 | return audio_device_buffer_.RegisterAudioCallback(audioCallback); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 813 | } |
| 814 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 815 | int32_t AudioDeviceModuleImpl::PlayoutDelay(uint16_t* delayMS) const { |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 816 | CHECKinitialized_(); |
| 817 | uint16_t delay = 0; |
| 818 | if (audio_device_->PlayoutDelay(delay) == -1) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 819 | RTC_LOG(LERROR) << "failed to retrieve the playout delay"; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 820 | return -1; |
| 821 | } |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 822 | *delayMS = delay; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 823 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 824 | } |
| 825 | |
henrika@webrtc.org | a954c07 | 2014-12-09 16:22:09 +0000 | [diff] [blame] | 826 | bool AudioDeviceModuleImpl::BuiltInAECIsAvailable() const { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 827 | RTC_LOG(INFO) << __FUNCTION__; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 828 | CHECKinitialized__BOOL(); |
| 829 | bool isAvailable = audio_device_->BuiltInAECIsAvailable(); |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 830 | RTC_LOG(INFO) << "output: " << isAvailable; |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 831 | return isAvailable; |
henrika@webrtc.org | a954c07 | 2014-12-09 16:22:09 +0000 | [diff] [blame] | 832 | } |
| 833 | |
henrika | c14f5ff | 2015-09-23 14:08:33 +0200 | [diff] [blame] | 834 | int32_t AudioDeviceModuleImpl::EnableBuiltInAEC(bool enable) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 835 | RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")"; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 836 | CHECKinitialized_(); |
| 837 | int32_t ok = audio_device_->EnableBuiltInAEC(enable); |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 838 | RTC_LOG(INFO) << "output: " << ok; |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 839 | return ok; |
henrika | c14f5ff | 2015-09-23 14:08:33 +0200 | [diff] [blame] | 840 | } |
| 841 | |
| 842 | bool AudioDeviceModuleImpl::BuiltInAGCIsAvailable() const { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 843 | RTC_LOG(INFO) << __FUNCTION__; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 844 | CHECKinitialized__BOOL(); |
| 845 | bool isAvailable = audio_device_->BuiltInAGCIsAvailable(); |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 846 | RTC_LOG(INFO) << "output: " << isAvailable; |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 847 | return isAvailable; |
henrika | c14f5ff | 2015-09-23 14:08:33 +0200 | [diff] [blame] | 848 | } |
| 849 | |
| 850 | int32_t AudioDeviceModuleImpl::EnableBuiltInAGC(bool enable) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 851 | RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")"; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 852 | CHECKinitialized_(); |
| 853 | int32_t ok = audio_device_->EnableBuiltInAGC(enable); |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 854 | RTC_LOG(INFO) << "output: " << ok; |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 855 | return ok; |
henrika | c14f5ff | 2015-09-23 14:08:33 +0200 | [diff] [blame] | 856 | } |
| 857 | |
| 858 | bool AudioDeviceModuleImpl::BuiltInNSIsAvailable() const { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 859 | RTC_LOG(INFO) << __FUNCTION__; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 860 | CHECKinitialized__BOOL(); |
| 861 | bool isAvailable = audio_device_->BuiltInNSIsAvailable(); |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 862 | RTC_LOG(INFO) << "output: " << isAvailable; |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 863 | return isAvailable; |
henrika | c14f5ff | 2015-09-23 14:08:33 +0200 | [diff] [blame] | 864 | } |
| 865 | |
| 866 | int32_t AudioDeviceModuleImpl::EnableBuiltInNS(bool enable) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 867 | RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")"; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 868 | CHECKinitialized_(); |
| 869 | int32_t ok = audio_device_->EnableBuiltInNS(enable); |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 870 | RTC_LOG(INFO) << "output: " << ok; |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 871 | return ok; |
henrika | c14f5ff | 2015-09-23 14:08:33 +0200 | [diff] [blame] | 872 | } |
| 873 | |
maxmorin | 88e31a3 | 2016-08-16 00:56:09 -0700 | [diff] [blame] | 874 | #if defined(WEBRTC_IOS) |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 875 | int AudioDeviceModuleImpl::GetPlayoutAudioParameters( |
| 876 | AudioParameters* params) const { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 877 | RTC_LOG(INFO) << __FUNCTION__; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 878 | int r = audio_device_->GetPlayoutAudioParameters(params); |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 879 | RTC_LOG(INFO) << "output: " << r; |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 880 | return r; |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 881 | } |
| 882 | |
| 883 | int AudioDeviceModuleImpl::GetRecordAudioParameters( |
| 884 | AudioParameters* params) const { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 885 | RTC_LOG(INFO) << __FUNCTION__; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 886 | int r = audio_device_->GetRecordAudioParameters(params); |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 887 | RTC_LOG(INFO) << "output: " << r; |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 888 | return r; |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 889 | } |
maxmorin | 88e31a3 | 2016-08-16 00:56:09 -0700 | [diff] [blame] | 890 | #endif // WEBRTC_IOS |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 891 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 892 | AudioDeviceModuleImpl::PlatformType AudioDeviceModuleImpl::Platform() const { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 893 | RTC_LOG(INFO) << __FUNCTION__; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 894 | return platform_type_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 895 | } |
| 896 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 897 | AudioDeviceModule::AudioLayer AudioDeviceModuleImpl::PlatformAudioLayer() |
| 898 | const { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 899 | RTC_LOG(INFO) << __FUNCTION__; |
henrika | 4af7366 | 2017-10-11 13:16:17 +0200 | [diff] [blame] | 900 | return audio_layer_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 901 | } |
| 902 | |
| 903 | } // namespace webrtc |