blob: 7b08a5af49675704c8049d77c1ccd3418fd6eaba [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
xians@webrtc.org20aabbb2012-02-20 09:17:41 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
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 Bonadei92ea95e2017-09-15 06:47:31 +020011#include "modules/audio_device/audio_device_impl.h"
henrika4af73662017-10-11 13:16:17 +020012
Yves Gerey988cc082018-10-23 12:03:01 +020013#include <stddef.h>
14
Mirko Bonadeid9708072019-01-25 20:26:48 +010015#include "api/scoped_refptr.h"
Danil Chapovalov1c41be62019-04-01 09:16:12 +020016#include "api/task_queue/global_task_queue_factory.h"
Yves Gerey988cc082018-10-23 12:03:01 +020017#include "modules/audio_device/audio_device_config.h" // IWYU pragma: keep
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020018#include "modules/audio_device/audio_device_generic.h"
19#include "rtc_base/checks.h"
20#include "rtc_base/logging.h"
Steve Anton10542f22019-01-11 09:11:00 -080021#include "rtc_base/ref_counted_object.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020022#include "system_wrappers/include/metrics.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000023
niklase@google.com470e71d2011-07-07 08:21:25 +000024#if defined(_WIN32)
Max Morin787eeed2016-06-23 10:42:07 +020025#if defined(WEBRTC_WINDOWS_CORE_AUDIO_BUILD)
henrika883d00f2018-03-16 10:09:49 +010026#include "modules/audio_device/win/audio_device_core_win.h"
Max Morin787eeed2016-06-23 10:42:07 +020027#endif
leozwang@google.com39f20512011-07-15 16:29:40 +000028#elif defined(WEBRTC_ANDROID)
henrikab2619892015-05-18 16:49:16 +020029#include <stdlib.h>
Mirko Bonadei185e8022019-03-27 21:11:17 +010030#if defined(WEBRTC_AUDIO_DEVICE_INCLUDE_ANDROID_AAUDIO)
henrika883d00f2018-03-16 10:09:49 +010031#include "modules/audio_device/android/aaudio_player.h"
32#include "modules/audio_device/android/aaudio_recorder.h"
33#endif
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020034#include "modules/audio_device/android/audio_device_template.h"
35#include "modules/audio_device/android/audio_manager.h"
36#include "modules/audio_device/android/audio_record_jni.h"
37#include "modules/audio_device/android/audio_track_jni.h"
38#include "modules/audio_device/android/opensles_player.h"
39#include "modules/audio_device/android/opensles_recorder.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000040#elif defined(WEBRTC_LINUX)
Max Morin787eeed2016-06-23 10:42:07 +020041#if defined(LINUX_ALSA)
henrika883d00f2018-03-16 10:09:49 +010042#include "modules/audio_device/linux/audio_device_alsa_linux.h"
Max Morin787eeed2016-06-23 10:42:07 +020043#endif
Tommi68898a22015-05-19 17:28:07 +020044#if defined(LINUX_PULSE)
henrika883d00f2018-03-16 10:09:49 +010045#include "modules/audio_device/linux/audio_device_pulse_linux.h"
Tommi68898a22015-05-19 17:28:07 +020046#endif
sjlee@webrtc.org414fa7f2012-09-11 17:25:46 +000047#elif defined(WEBRTC_IOS)
Jeroen de Borste9d2b4e2019-04-08 15:00:02 +000048#include "modules/audio_device/ios/audio_device_ios.h"
andrew@webrtc.orgf3b65db2012-09-06 18:17:00 +000049#elif defined(WEBRTC_MAC)
henrika883d00f2018-03-16 10:09:49 +010050#include "modules/audio_device/mac/audio_device_mac.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000051#endif
phoglund@webrtc.org8454ad12014-06-11 14:12:04 +000052#if defined(WEBRTC_DUMMY_FILE_DEVICES)
Yves Gerey988cc082018-10-23 12:03:01 +020053#include "modules/audio_device/dummy/file_audio_device.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020054#include "modules/audio_device/dummy/file_audio_device_factory.h"
phoglund@webrtc.org8454ad12014-06-11 14:12:04 +000055#endif
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020056#include "modules/audio_device/dummy/audio_device_dummy.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000057
henrika4af73662017-10-11 13:16:17 +020058#define CHECKinitialized_() \
Max Morin787eeed2016-06-23 10:42:07 +020059 { \
henrika4af73662017-10-11 13:16:17 +020060 if (!initialized_) { \
Max Morin787eeed2016-06-23 10:42:07 +020061 return -1; \
henrika883d00f2018-03-16 10:09:49 +010062 } \
Max Morin787eeed2016-06-23 10:42:07 +020063 }
niklase@google.com470e71d2011-07-07 08:21:25 +000064
henrika4af73662017-10-11 13:16:17 +020065#define CHECKinitialized__BOOL() \
Max Morin787eeed2016-06-23 10:42:07 +020066 { \
henrika4af73662017-10-11 13:16:17 +020067 if (!initialized_) { \
Max Morin787eeed2016-06-23 10:42:07 +020068 return false; \
henrika883d00f2018-03-16 10:09:49 +010069 } \
Max Morin787eeed2016-06-23 10:42:07 +020070 }
niklase@google.com470e71d2011-07-07 08:21:25 +000071
Peter Boström1d194412016-03-21 16:44:31 +010072namespace webrtc {
henrike@webrtc.org70efc322012-02-23 17:45:33 +000073
Peter Boström4adbbcf2016-05-03 15:51:26 -040074rtc::scoped_refptr<AudioDeviceModule> AudioDeviceModule::Create(
Danil Chapovalov1c41be62019-04-01 09:16:12 +020075 AudioLayer audio_layer) {
Mirko Bonadei675513b2017-11-09 11:09:25 +010076 RTC_LOG(INFO) << __FUNCTION__;
Danil Chapovalov1c41be62019-04-01 09:16:12 +020077 return AudioDeviceModule::CreateForTest(audio_layer,
78 &GlobalTaskQueueFactory());
79}
80
81rtc::scoped_refptr<AudioDeviceModule> AudioDeviceModule::Create(
82 AudioLayer audio_layer,
83 TaskQueueFactory* task_queue_factory) {
84 RTC_LOG(INFO) << __FUNCTION__;
85 return AudioDeviceModule::CreateForTest(audio_layer, task_queue_factory);
henrika5b6afc02018-09-05 14:34:40 +020086}
87
88// static
89rtc::scoped_refptr<AudioDeviceModuleForTest> AudioDeviceModule::CreateForTest(
Danil Chapovalov1c41be62019-04-01 09:16:12 +020090 AudioLayer audio_layer,
91 TaskQueueFactory* task_queue_factory) {
henrika5b6afc02018-09-05 14:34:40 +020092 RTC_LOG(INFO) << __FUNCTION__;
henrikaec9c7452018-06-08 16:10:03 +020093
94 // The "AudioDeviceModule::kWindowsCoreAudio2" audio layer has its own
95 // dedicated factory method which should be used instead.
96 if (audio_layer == AudioDeviceModule::kWindowsCoreAudio2) {
97 RTC_LOG(LS_ERROR) << "Use the CreateWindowsCoreAudioAudioDeviceModule() "
98 "factory method instead for this option.";
99 return nullptr;
100 }
101
henrika4af73662017-10-11 13:16:17 +0200102 // Create the generic reference counted (platform independent) implementation.
Max Morin787eeed2016-06-23 10:42:07 +0200103 rtc::scoped_refptr<AudioDeviceModuleImpl> audioDevice(
Danil Chapovalov1c41be62019-04-01 09:16:12 +0200104 new rtc::RefCountedObject<AudioDeviceModuleImpl>(audio_layer,
105 task_queue_factory));
niklase@google.com470e71d2011-07-07 08:21:25 +0000106
Max Morin787eeed2016-06-23 10:42:07 +0200107 // Ensure that the current platform is supported.
108 if (audioDevice->CheckPlatform() == -1) {
109 return nullptr;
110 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000111
Max Morin787eeed2016-06-23 10:42:07 +0200112 // Create the platform-dependent implementation.
113 if (audioDevice->CreatePlatformSpecificObjects() == -1) {
114 return nullptr;
115 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000116
henrika4af73662017-10-11 13:16:17 +0200117 // Ensure that the generic audio buffer can communicate with the platform
118 // specific parts.
Max Morin787eeed2016-06-23 10:42:07 +0200119 if (audioDevice->AttachAudioBuffer() == -1) {
120 return nullptr;
121 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000122
Max Morin787eeed2016-06-23 10:42:07 +0200123 return audioDevice;
niklase@google.com470e71d2011-07-07 08:21:25 +0000124}
125
Danil Chapovalov1c41be62019-04-01 09:16:12 +0200126AudioDeviceModuleImpl::AudioDeviceModuleImpl(
127 AudioLayer audio_layer,
128 TaskQueueFactory* task_queue_factory)
129 : audio_layer_(audio_layer), audio_device_buffer_(task_queue_factory) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100130 RTC_LOG(INFO) << __FUNCTION__;
niklase@google.com470e71d2011-07-07 08:21:25 +0000131}
132
Max Morin787eeed2016-06-23 10:42:07 +0200133int32_t AudioDeviceModuleImpl::CheckPlatform() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100134 RTC_LOG(INFO) << __FUNCTION__;
Max Morin787eeed2016-06-23 10:42:07 +0200135 // Ensure that the current platform is supported
Max Morin787eeed2016-06-23 10:42:07 +0200136 PlatformType platform(kPlatformNotSupported);
niklase@google.com470e71d2011-07-07 08:21:25 +0000137#if defined(_WIN32)
Max Morin787eeed2016-06-23 10:42:07 +0200138 platform = kPlatformWin32;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100139 RTC_LOG(INFO) << "current platform is Win32";
leozwang@google.com522f42b2011-09-19 17:39:05 +0000140#elif defined(WEBRTC_ANDROID)
Max Morin787eeed2016-06-23 10:42:07 +0200141 platform = kPlatformAndroid;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100142 RTC_LOG(INFO) << "current platform is Android";
niklase@google.com470e71d2011-07-07 08:21:25 +0000143#elif defined(WEBRTC_LINUX)
Max Morin787eeed2016-06-23 10:42:07 +0200144 platform = kPlatformLinux;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100145 RTC_LOG(INFO) << "current platform is Linux";
sjlee@webrtc.org414fa7f2012-09-11 17:25:46 +0000146#elif defined(WEBRTC_IOS)
Max Morin787eeed2016-06-23 10:42:07 +0200147 platform = kPlatformIOS;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100148 RTC_LOG(INFO) << "current platform is IOS";
andrew@webrtc.orgf3b65db2012-09-06 18:17:00 +0000149#elif defined(WEBRTC_MAC)
Max Morin787eeed2016-06-23 10:42:07 +0200150 platform = kPlatformMac;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100151 RTC_LOG(INFO) << "current platform is Mac";
niklase@google.com470e71d2011-07-07 08:21:25 +0000152#endif
Max Morin787eeed2016-06-23 10:42:07 +0200153 if (platform == kPlatformNotSupported) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100154 RTC_LOG(LERROR)
155 << "current platform is not supported => this module will self "
156 "destruct!";
Max Morin787eeed2016-06-23 10:42:07 +0200157 return -1;
158 }
henrika4af73662017-10-11 13:16:17 +0200159 platform_type_ = platform;
Max Morin787eeed2016-06-23 10:42:07 +0200160 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000161}
162
Max Morin787eeed2016-06-23 10:42:07 +0200163int32_t AudioDeviceModuleImpl::CreatePlatformSpecificObjects() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100164 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200165// Dummy ADM implementations if build flags are set.
xians@google.combf5d2ba2011-08-16 07:44:19 +0000166#if defined(WEBRTC_DUMMY_AUDIO_BUILD)
henrika5ff64832017-10-11 15:14:51 +0200167 audio_device_.reset(new AudioDeviceDummy());
Mirko Bonadei675513b2017-11-09 11:09:25 +0100168 RTC_LOG(INFO) << "Dummy Audio APIs will be utilized";
phoglund@webrtc.org8454ad12014-06-11 14:12:04 +0000169#elif defined(WEBRTC_DUMMY_FILE_DEVICES)
henrika5ff64832017-10-11 15:14:51 +0200170 audio_device_.reset(FileAudioDeviceFactory::CreateFileAudioDevice());
henrika4af73662017-10-11 13:16:17 +0200171 if (audio_device_) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100172 RTC_LOG(INFO) << "Will use file-playing dummy device.";
noahric6a355902016-08-17 15:19:50 -0700173 } else {
174 // Create a dummy device instead.
henrika5ff64832017-10-11 15:14:51 +0200175 audio_device_.reset(new AudioDeviceDummy());
Mirko Bonadei675513b2017-11-09 11:09:25 +0100176 RTC_LOG(INFO) << "Dummy Audio APIs will be utilized";
noahric6a355902016-08-17 15:19:50 -0700177 }
henrika4af73662017-10-11 13:16:17 +0200178
179// Real (non-dummy) ADM implementations.
xians@google.combf5d2ba2011-08-16 07:44:19 +0000180#else
henrika4af73662017-10-11 13:16:17 +0200181 AudioLayer audio_layer(PlatformAudioLayer());
182// Windows ADM implementation.
niklase@google.com470e71d2011-07-07 08:21:25 +0000183#if defined(WEBRTC_WINDOWS_CORE_AUDIO_BUILD)
henrika4af73662017-10-11 13:16:17 +0200184 if ((audio_layer == kWindowsCoreAudio) ||
185 (audio_layer == kPlatformDefaultAudio)) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100186 RTC_LOG(INFO) << "Attempting to use the Windows Core Audio APIs...";
Max Morin787eeed2016-06-23 10:42:07 +0200187 if (AudioDeviceWindowsCore::CoreAudioIsSupported()) {
henrika4af73662017-10-11 13:16:17 +0200188 audio_device_.reset(new AudioDeviceWindowsCore());
Mirko Bonadei675513b2017-11-09 11:09:25 +0100189 RTC_LOG(INFO) << "Windows Core Audio APIs will be utilized";
niklase@google.com470e71d2011-07-07 08:21:25 +0000190 }
Max Morin787eeed2016-06-23 10:42:07 +0200191 }
192#endif // defined(WEBRTC_WINDOWS_CORE_AUDIO_BUILD)
niklase@google.com470e71d2011-07-07 08:21:25 +0000193
henrike@webrtc.org9ee75e92013-12-11 21:42:44 +0000194#if defined(WEBRTC_ANDROID)
Max Morin787eeed2016-06-23 10:42:07 +0200195 // Create an Android audio manager.
henrika4af73662017-10-11 13:16:17 +0200196 audio_manager_android_.reset(new AudioManager());
Max Morin787eeed2016-06-23 10:42:07 +0200197 // Select best possible combination of audio layers.
henrika4af73662017-10-11 13:16:17 +0200198 if (audio_layer == kPlatformDefaultAudio) {
henrika883d00f2018-03-16 10:09:49 +0100199 if (audio_manager_android_->IsAAudioSupported()) {
200 // Use of AAudio for both playout and recording has highest priority.
201 audio_layer = kAndroidAAudioAudio;
202 } else if (audio_manager_android_->IsLowLatencyPlayoutSupported() &&
203 audio_manager_android_->IsLowLatencyRecordSupported()) {
henrika918b5542016-09-19 15:44:09 +0200204 // Use OpenSL ES for both playout and recording.
henrika4af73662017-10-11 13:16:17 +0200205 audio_layer = kAndroidOpenSLESAudio;
206 } else if (audio_manager_android_->IsLowLatencyPlayoutSupported() &&
207 !audio_manager_android_->IsLowLatencyRecordSupported()) {
henrika918b5542016-09-19 15:44:09 +0200208 // Use OpenSL ES for output on devices that only supports the
Max Morin787eeed2016-06-23 10:42:07 +0200209 // low-latency output audio path.
henrika4af73662017-10-11 13:16:17 +0200210 audio_layer = kAndroidJavaInputAndOpenSLESOutputAudio;
henrikab2619892015-05-18 16:49:16 +0200211 } else {
henrika918b5542016-09-19 15:44:09 +0200212 // Use Java-based audio in both directions when low-latency output is
213 // not supported.
henrika4af73662017-10-11 13:16:17 +0200214 audio_layer = kAndroidJavaAudio;
niklase@google.com470e71d2011-07-07 08:21:25 +0000215 }
Max Morin787eeed2016-06-23 10:42:07 +0200216 }
henrika4af73662017-10-11 13:16:17 +0200217 AudioManager* audio_manager = audio_manager_android_.get();
218 if (audio_layer == kAndroidJavaAudio) {
Max Morin787eeed2016-06-23 10:42:07 +0200219 // Java audio for both input and output audio.
henrika4af73662017-10-11 13:16:17 +0200220 audio_device_.reset(new AudioDeviceTemplate<AudioRecordJni, AudioTrackJni>(
221 audio_layer, audio_manager));
222 } else if (audio_layer == kAndroidOpenSLESAudio) {
henrika918b5542016-09-19 15:44:09 +0200223 // OpenSL ES based audio for both input and output audio.
henrika4af73662017-10-11 13:16:17 +0200224 audio_device_.reset(
225 new AudioDeviceTemplate<OpenSLESRecorder, OpenSLESPlayer>(
226 audio_layer, audio_manager));
227 } else if (audio_layer == kAndroidJavaInputAndOpenSLESOutputAudio) {
Max Morin787eeed2016-06-23 10:42:07 +0200228 // Java audio for input and OpenSL ES for output audio (i.e. mixed APIs).
229 // This combination provides low-latency output audio and at the same
230 // time support for HW AEC using the AudioRecord Java API.
henrika4af73662017-10-11 13:16:17 +0200231 audio_device_.reset(new AudioDeviceTemplate<AudioRecordJni, OpenSLESPlayer>(
232 audio_layer, audio_manager));
henrika883d00f2018-03-16 10:09:49 +0100233 } else if (audio_layer == kAndroidAAudioAudio) {
Mirko Bonadei185e8022019-03-27 21:11:17 +0100234#if defined(WEBRTC_AUDIO_DEVICE_INCLUDE_ANDROID_AAUDIO)
henrika883d00f2018-03-16 10:09:49 +0100235 // AAudio based audio for both input and output.
236 audio_device_.reset(new AudioDeviceTemplate<AAudioRecorder, AAudioPlayer>(
237 audio_layer, audio_manager));
238#endif
239 } else if (audio_layer == kAndroidJavaInputAndAAudioOutputAudio) {
Mirko Bonadei185e8022019-03-27 21:11:17 +0100240#if defined(WEBRTC_AUDIO_DEVICE_INCLUDE_ANDROID_AAUDIO)
henrika883d00f2018-03-16 10:09:49 +0100241 // Java audio for input and AAudio for output audio (i.e. mixed APIs).
242 audio_device_.reset(new AudioDeviceTemplate<AudioRecordJni, AAudioPlayer>(
243 audio_layer, audio_manager));
244#endif
Max Morin787eeed2016-06-23 10:42:07 +0200245 } else {
henrika883d00f2018-03-16 10:09:49 +0100246 RTC_LOG(LS_ERROR) << "The requested audio layer is not supported";
henrika4af73662017-10-11 13:16:17 +0200247 audio_device_.reset(nullptr);
Max Morin787eeed2016-06-23 10:42:07 +0200248 }
249// END #if defined(WEBRTC_ANDROID)
niklase@google.com470e71d2011-07-07 08:21:25 +0000250
henrika4af73662017-10-11 13:16:17 +0200251// Linux ADM implementation.
henrika68435f52018-04-09 13:31:45 +0200252// Note that, LINUX_ALSA is always defined by default when WEBRTC_LINUX is
253// defined. LINUX_PULSE depends on the 'rtc_include_pulse_audio' build flag.
254// TODO(bugs.webrtc.org/9127): improve support and make it more clear that
255// PulseAudio is the default selection.
niklase@google.com470e71d2011-07-07 08:21:25 +0000256#elif defined(WEBRTC_LINUX)
henrika68435f52018-04-09 13:31:45 +0200257#if !defined(LINUX_PULSE)
258 // Build flag 'rtc_include_pulse_audio' is set to false. In this mode:
259 // - kPlatformDefaultAudio => ALSA, and
260 // - kLinuxAlsaAudio => ALSA, and
261 // - kLinuxPulseAudio => Invalid selection.
262 RTC_LOG(WARNING) << "PulseAudio is disabled using build flag.";
263 if ((audio_layer == kLinuxAlsaAudio) ||
henrika4af73662017-10-11 13:16:17 +0200264 (audio_layer == kPlatformDefaultAudio)) {
henrika4af73662017-10-11 13:16:17 +0200265 audio_device_.reset(new AudioDeviceLinuxALSA());
Mirko Bonadei675513b2017-11-09 11:09:25 +0100266 RTC_LOG(INFO) << "Linux ALSA APIs will be utilized.";
Max Morin787eeed2016-06-23 10:42:07 +0200267 }
henrika68435f52018-04-09 13:31:45 +0200268#else
269 // Build flag 'rtc_include_pulse_audio' is set to true (default). In this
270 // mode:
271 // - kPlatformDefaultAudio => PulseAudio, and
272 // - kLinuxPulseAudio => PulseAudio, and
273 // - kLinuxAlsaAudio => ALSA (supported but not default).
274 RTC_LOG(INFO) << "PulseAudio support is enabled.";
275 if ((audio_layer == kLinuxPulseAudio) ||
276 (audio_layer == kPlatformDefaultAudio)) {
277 // Linux PulseAudio implementation is default.
278 audio_device_.reset(new AudioDeviceLinuxPulse());
279 RTC_LOG(INFO) << "Linux PulseAudio APIs will be utilized";
280 } else if (audio_layer == kLinuxAlsaAudio) {
281 audio_device_.reset(new AudioDeviceLinuxALSA());
282 RTC_LOG(WARNING) << "Linux ALSA APIs will be utilized.";
283 }
284#endif // #if !defined(LINUX_PULSE)
niklase@google.com470e71d2011-07-07 08:21:25 +0000285#endif // #if defined(WEBRTC_LINUX)
286
henrika4af73662017-10-11 13:16:17 +0200287// iOS ADM implementation.
sjlee@webrtc.org414fa7f2012-09-11 17:25:46 +0000288#if defined(WEBRTC_IOS)
henrika4af73662017-10-11 13:16:17 +0200289 if (audio_layer == kPlatformDefaultAudio) {
Jeroen de Borste9d2b4e2019-04-08 15:00:02 +0000290 audio_device_.reset(new AudioDeviceIOS());
Mirko Bonadei675513b2017-11-09 11:09:25 +0100291 RTC_LOG(INFO) << "iPhone Audio APIs will be utilized.";
Max Morin787eeed2016-06-23 10:42:07 +0200292 }
293// END #if defined(WEBRTC_IOS)
niklase@google.com470e71d2011-07-07 08:21:25 +0000294
henrika4af73662017-10-11 13:16:17 +0200295// Mac OS X ADM implementation.
andrew@webrtc.orgf3b65db2012-09-06 18:17:00 +0000296#elif defined(WEBRTC_MAC)
henrika4af73662017-10-11 13:16:17 +0200297 if (audio_layer == kPlatformDefaultAudio) {
298 audio_device_.reset(new AudioDeviceMac());
Mirko Bonadei675513b2017-11-09 11:09:25 +0100299 RTC_LOG(INFO) << "Mac OS X Audio APIs will be utilized.";
Max Morin787eeed2016-06-23 10:42:07 +0200300 }
andrew@webrtc.orgf3b65db2012-09-06 18:17:00 +0000301#endif // WEBRTC_MAC
niklase@google.com470e71d2011-07-07 08:21:25 +0000302
henrika4af73662017-10-11 13:16:17 +0200303 // Dummy ADM implementation.
304 if (audio_layer == kDummyAudio) {
henrika5ff64832017-10-11 15:14:51 +0200305 audio_device_.reset(new AudioDeviceDummy());
Mirko Bonadei675513b2017-11-09 11:09:25 +0100306 RTC_LOG(INFO) << "Dummy Audio APIs will be utilized.";
Max Morin787eeed2016-06-23 10:42:07 +0200307 }
xians@google.combf5d2ba2011-08-16 07:44:19 +0000308#endif // if defined(WEBRTC_DUMMY_AUDIO_BUILD)
niklase@google.com470e71d2011-07-07 08:21:25 +0000309
henrika4af73662017-10-11 13:16:17 +0200310 if (!audio_device_) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100311 RTC_LOG(LS_ERROR)
henrika4af73662017-10-11 13:16:17 +0200312 << "Failed to create the platform specific ADM implementation.";
Max Morin787eeed2016-06-23 10:42:07 +0200313 return -1;
314 }
Max Morin787eeed2016-06-23 10:42:07 +0200315 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000316}
317
Max Morin787eeed2016-06-23 10:42:07 +0200318int32_t AudioDeviceModuleImpl::AttachAudioBuffer() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100319 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200320 audio_device_->AttachAudioBuffer(&audio_device_buffer_);
Max Morin787eeed2016-06-23 10:42:07 +0200321 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000322}
323
Max Morin787eeed2016-06-23 10:42:07 +0200324AudioDeviceModuleImpl::~AudioDeviceModuleImpl() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100325 RTC_LOG(INFO) << __FUNCTION__;
niklase@google.com470e71d2011-07-07 08:21:25 +0000326}
327
henrikab2619892015-05-18 16:49:16 +0200328int32_t AudioDeviceModuleImpl::ActiveAudioLayer(AudioLayer* audioLayer) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100329 RTC_LOG(INFO) << __FUNCTION__;
henrikab2619892015-05-18 16:49:16 +0200330 AudioLayer activeAudio;
henrika4af73662017-10-11 13:16:17 +0200331 if (audio_device_->ActiveAudioLayer(activeAudio) == -1) {
henrikab2619892015-05-18 16:49:16 +0200332 return -1;
333 }
334 *audioLayer = activeAudio;
335 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000336}
337
Max Morin787eeed2016-06-23 10:42:07 +0200338int32_t AudioDeviceModuleImpl::Init() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100339 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200340 if (initialized_)
niklase@google.com470e71d2011-07-07 08:21:25 +0000341 return 0;
henrika4af73662017-10-11 13:16:17 +0200342 RTC_CHECK(audio_device_);
343 AudioDeviceGeneric::InitStatus status = audio_device_->Init();
Max Morin84cab202016-07-01 13:35:19 +0200344 RTC_HISTOGRAM_ENUMERATION(
345 "WebRTC.Audio.InitializationResult", static_cast<int>(status),
346 static_cast<int>(AudioDeviceGeneric::InitStatus::NUM_STATUSES));
347 if (status != AudioDeviceGeneric::InitStatus::OK) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100348 RTC_LOG(LS_ERROR) << "Audio device initialization failed.";
Max Morin787eeed2016-06-23 10:42:07 +0200349 return -1;
350 }
henrika4af73662017-10-11 13:16:17 +0200351 initialized_ = true;
Max Morin787eeed2016-06-23 10:42:07 +0200352 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000353}
354
Max Morin787eeed2016-06-23 10:42:07 +0200355int32_t AudioDeviceModuleImpl::Terminate() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100356 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200357 if (!initialized_)
niklase@google.com470e71d2011-07-07 08:21:25 +0000358 return 0;
henrika4af73662017-10-11 13:16:17 +0200359 if (audio_device_->Terminate() == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200360 return -1;
361 }
henrika4af73662017-10-11 13:16:17 +0200362 initialized_ = false;
Max Morin787eeed2016-06-23 10:42:07 +0200363 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000364}
365
Max Morin787eeed2016-06-23 10:42:07 +0200366bool AudioDeviceModuleImpl::Initialized() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100367 RTC_LOG(INFO) << __FUNCTION__ << ": " << initialized_;
henrika4af73662017-10-11 13:16:17 +0200368 return initialized_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000369}
370
Max Morin787eeed2016-06-23 10:42:07 +0200371int32_t AudioDeviceModuleImpl::InitSpeaker() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100372 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200373 CHECKinitialized_();
374 return audio_device_->InitSpeaker();
niklase@google.com470e71d2011-07-07 08:21:25 +0000375}
376
Max Morin787eeed2016-06-23 10:42:07 +0200377int32_t AudioDeviceModuleImpl::InitMicrophone() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100378 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200379 CHECKinitialized_();
380 return audio_device_->InitMicrophone();
niklase@google.com470e71d2011-07-07 08:21:25 +0000381}
382
Max Morin787eeed2016-06-23 10:42:07 +0200383int32_t AudioDeviceModuleImpl::SpeakerVolumeIsAvailable(bool* available) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100384 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200385 CHECKinitialized_();
386 bool isAvailable = false;
387 if (audio_device_->SpeakerVolumeIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200388 return -1;
389 }
Max Morin787eeed2016-06-23 10:42:07 +0200390 *available = isAvailable;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100391 RTC_LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200392 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000393}
394
Max Morin787eeed2016-06-23 10:42:07 +0200395int32_t AudioDeviceModuleImpl::SetSpeakerVolume(uint32_t volume) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100396 RTC_LOG(INFO) << __FUNCTION__ << "(" << volume << ")";
henrika4af73662017-10-11 13:16:17 +0200397 CHECKinitialized_();
398 return audio_device_->SetSpeakerVolume(volume);
niklase@google.com470e71d2011-07-07 08:21:25 +0000399}
400
Max Morin787eeed2016-06-23 10:42:07 +0200401int32_t AudioDeviceModuleImpl::SpeakerVolume(uint32_t* volume) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100402 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200403 CHECKinitialized_();
404 uint32_t level = 0;
405 if (audio_device_->SpeakerVolume(level) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200406 return -1;
407 }
Max Morin787eeed2016-06-23 10:42:07 +0200408 *volume = level;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100409 RTC_LOG(INFO) << "output: " << *volume;
henrika4af73662017-10-11 13:16:17 +0200410 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000411}
412
Max Morin787eeed2016-06-23 10:42:07 +0200413bool AudioDeviceModuleImpl::SpeakerIsInitialized() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100414 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200415 CHECKinitialized__BOOL();
416 bool isInitialized = audio_device_->SpeakerIsInitialized();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100417 RTC_LOG(INFO) << "output: " << isInitialized;
henrika4af73662017-10-11 13:16:17 +0200418 return isInitialized;
niklase@google.com470e71d2011-07-07 08:21:25 +0000419}
420
Max Morin787eeed2016-06-23 10:42:07 +0200421bool AudioDeviceModuleImpl::MicrophoneIsInitialized() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100422 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200423 CHECKinitialized__BOOL();
424 bool isInitialized = audio_device_->MicrophoneIsInitialized();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100425 RTC_LOG(INFO) << "output: " << isInitialized;
henrika4af73662017-10-11 13:16:17 +0200426 return isInitialized;
niklase@google.com470e71d2011-07-07 08:21:25 +0000427}
428
Max Morin787eeed2016-06-23 10:42:07 +0200429int32_t AudioDeviceModuleImpl::MaxSpeakerVolume(uint32_t* maxVolume) const {
henrika4af73662017-10-11 13:16:17 +0200430 CHECKinitialized_();
431 uint32_t maxVol = 0;
432 if (audio_device_->MaxSpeakerVolume(maxVol) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200433 return -1;
434 }
Max Morin787eeed2016-06-23 10:42:07 +0200435 *maxVolume = maxVol;
henrika4af73662017-10-11 13:16:17 +0200436 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000437}
438
Max Morin787eeed2016-06-23 10:42:07 +0200439int32_t AudioDeviceModuleImpl::MinSpeakerVolume(uint32_t* minVolume) const {
henrika4af73662017-10-11 13:16:17 +0200440 CHECKinitialized_();
441 uint32_t minVol = 0;
442 if (audio_device_->MinSpeakerVolume(minVol) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200443 return -1;
444 }
Max Morin787eeed2016-06-23 10:42:07 +0200445 *minVolume = minVol;
henrika4af73662017-10-11 13:16:17 +0200446 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000447}
448
Max Morin787eeed2016-06-23 10:42:07 +0200449int32_t AudioDeviceModuleImpl::SpeakerMuteIsAvailable(bool* available) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100450 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200451 CHECKinitialized_();
Mirko Bonadei72c42502017-11-09 09:33:23 +0100452 bool isAvailable = false;
henrika4af73662017-10-11 13:16:17 +0200453 if (audio_device_->SpeakerMuteIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200454 return -1;
455 }
Max Morin787eeed2016-06-23 10:42:07 +0200456 *available = isAvailable;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100457 RTC_LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200458 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000459}
460
Max Morin787eeed2016-06-23 10:42:07 +0200461int32_t AudioDeviceModuleImpl::SetSpeakerMute(bool enable) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100462 RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200463 CHECKinitialized_();
464 return audio_device_->SetSpeakerMute(enable);
niklase@google.com470e71d2011-07-07 08:21:25 +0000465}
466
Max Morin787eeed2016-06-23 10:42:07 +0200467int32_t AudioDeviceModuleImpl::SpeakerMute(bool* enabled) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100468 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200469 CHECKinitialized_();
470 bool muted = false;
471 if (audio_device_->SpeakerMute(muted) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200472 return -1;
473 }
Max Morin787eeed2016-06-23 10:42:07 +0200474 *enabled = muted;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100475 RTC_LOG(INFO) << "output: " << muted;
henrika4af73662017-10-11 13:16:17 +0200476 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000477}
478
Max Morin787eeed2016-06-23 10:42:07 +0200479int32_t AudioDeviceModuleImpl::MicrophoneMuteIsAvailable(bool* available) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100480 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200481 CHECKinitialized_();
482 bool isAvailable = false;
483 if (audio_device_->MicrophoneMuteIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200484 return -1;
485 }
Max Morin787eeed2016-06-23 10:42:07 +0200486 *available = isAvailable;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100487 RTC_LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200488 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000489}
490
Max Morin787eeed2016-06-23 10:42:07 +0200491int32_t AudioDeviceModuleImpl::SetMicrophoneMute(bool enable) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100492 RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200493 CHECKinitialized_();
494 return (audio_device_->SetMicrophoneMute(enable));
niklase@google.com470e71d2011-07-07 08:21:25 +0000495}
496
Max Morin787eeed2016-06-23 10:42:07 +0200497int32_t AudioDeviceModuleImpl::MicrophoneMute(bool* enabled) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100498 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200499 CHECKinitialized_();
500 bool muted = false;
501 if (audio_device_->MicrophoneMute(muted) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200502 return -1;
503 }
Max Morin787eeed2016-06-23 10:42:07 +0200504 *enabled = muted;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100505 RTC_LOG(INFO) << "output: " << muted;
henrika4af73662017-10-11 13:16:17 +0200506 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000507}
508
Max Morin787eeed2016-06-23 10:42:07 +0200509int32_t AudioDeviceModuleImpl::MicrophoneVolumeIsAvailable(bool* available) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100510 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200511 CHECKinitialized_();
512 bool isAvailable = false;
513 if (audio_device_->MicrophoneVolumeIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200514 return -1;
515 }
Max Morin787eeed2016-06-23 10:42:07 +0200516 *available = isAvailable;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100517 RTC_LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200518 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000519}
520
Max Morin787eeed2016-06-23 10:42:07 +0200521int32_t AudioDeviceModuleImpl::SetMicrophoneVolume(uint32_t volume) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100522 RTC_LOG(INFO) << __FUNCTION__ << "(" << volume << ")";
henrika4af73662017-10-11 13:16:17 +0200523 CHECKinitialized_();
524 return (audio_device_->SetMicrophoneVolume(volume));
niklase@google.com470e71d2011-07-07 08:21:25 +0000525}
526
Max Morin787eeed2016-06-23 10:42:07 +0200527int32_t AudioDeviceModuleImpl::MicrophoneVolume(uint32_t* volume) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100528 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200529 CHECKinitialized_();
530 uint32_t level = 0;
531 if (audio_device_->MicrophoneVolume(level) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200532 return -1;
533 }
Max Morin787eeed2016-06-23 10:42:07 +0200534 *volume = level;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100535 RTC_LOG(INFO) << "output: " << *volume;
henrika4af73662017-10-11 13:16:17 +0200536 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000537}
538
Max Morin787eeed2016-06-23 10:42:07 +0200539int32_t AudioDeviceModuleImpl::StereoRecordingIsAvailable(
540 bool* available) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100541 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200542 CHECKinitialized_();
543 bool isAvailable = false;
544 if (audio_device_->StereoRecordingIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200545 return -1;
546 }
Max Morin787eeed2016-06-23 10:42:07 +0200547 *available = isAvailable;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100548 RTC_LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200549 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000550}
551
Max Morin787eeed2016-06-23 10:42:07 +0200552int32_t AudioDeviceModuleImpl::SetStereoRecording(bool enable) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100553 RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200554 CHECKinitialized_();
555 if (audio_device_->RecordingIsInitialized()) {
Gustavo Garciaff98f4b2018-12-19 10:37:16 +0100556 RTC_LOG(LERROR)
557 << "unable to set stereo mode after recording is initialized";
Max Morin787eeed2016-06-23 10:42:07 +0200558 return -1;
559 }
henrika4af73662017-10-11 13:16:17 +0200560 if (audio_device_->SetStereoRecording(enable) == -1) {
Gustavo Garciaff98f4b2018-12-19 10:37:16 +0100561 if (enable) {
562 RTC_LOG(WARNING) << "failed to enable stereo recording";
563 }
Max Morin787eeed2016-06-23 10:42:07 +0200564 return -1;
565 }
Max Morin787eeed2016-06-23 10:42:07 +0200566 int8_t nChannels(1);
567 if (enable) {
568 nChannels = 2;
569 }
henrika4af73662017-10-11 13:16:17 +0200570 audio_device_buffer_.SetRecordingChannels(nChannels);
Max Morin787eeed2016-06-23 10:42:07 +0200571 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000572}
573
Max Morin787eeed2016-06-23 10:42:07 +0200574int32_t AudioDeviceModuleImpl::StereoRecording(bool* enabled) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100575 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200576 CHECKinitialized_();
577 bool stereo = false;
578 if (audio_device_->StereoRecording(stereo) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200579 return -1;
580 }
Max Morin787eeed2016-06-23 10:42:07 +0200581 *enabled = stereo;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100582 RTC_LOG(INFO) << "output: " << stereo;
henrika4af73662017-10-11 13:16:17 +0200583 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000584}
585
Max Morin787eeed2016-06-23 10:42:07 +0200586int32_t AudioDeviceModuleImpl::StereoPlayoutIsAvailable(bool* available) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100587 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200588 CHECKinitialized_();
589 bool isAvailable = false;
590 if (audio_device_->StereoPlayoutIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200591 return -1;
592 }
Max Morin787eeed2016-06-23 10:42:07 +0200593 *available = isAvailable;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100594 RTC_LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200595 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000596}
597
Max Morin787eeed2016-06-23 10:42:07 +0200598int32_t AudioDeviceModuleImpl::SetStereoPlayout(bool enable) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100599 RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200600 CHECKinitialized_();
601 if (audio_device_->PlayoutIsInitialized()) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100602 RTC_LOG(LERROR)
Max Morin098e6c52016-06-28 09:36:25 +0200603 << "unable to set stereo mode while playing side is initialized";
Max Morin787eeed2016-06-23 10:42:07 +0200604 return -1;
605 }
henrika4af73662017-10-11 13:16:17 +0200606 if (audio_device_->SetStereoPlayout(enable)) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100607 RTC_LOG(WARNING) << "stereo playout is not supported";
Max Morin787eeed2016-06-23 10:42:07 +0200608 return -1;
609 }
Max Morin787eeed2016-06-23 10:42:07 +0200610 int8_t nChannels(1);
611 if (enable) {
612 nChannels = 2;
613 }
henrika4af73662017-10-11 13:16:17 +0200614 audio_device_buffer_.SetPlayoutChannels(nChannels);
Max Morin787eeed2016-06-23 10:42:07 +0200615 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000616}
617
Max Morin787eeed2016-06-23 10:42:07 +0200618int32_t AudioDeviceModuleImpl::StereoPlayout(bool* enabled) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100619 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200620 CHECKinitialized_();
621 bool stereo = false;
622 if (audio_device_->StereoPlayout(stereo) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200623 return -1;
624 }
Max Morin787eeed2016-06-23 10:42:07 +0200625 *enabled = stereo;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100626 RTC_LOG(INFO) << "output: " << stereo;
henrika4af73662017-10-11 13:16:17 +0200627 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000628}
629
Max Morin787eeed2016-06-23 10:42:07 +0200630int32_t AudioDeviceModuleImpl::PlayoutIsAvailable(bool* available) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100631 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200632 CHECKinitialized_();
633 bool isAvailable = false;
634 if (audio_device_->PlayoutIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200635 return -1;
636 }
Max Morin787eeed2016-06-23 10:42:07 +0200637 *available = isAvailable;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100638 RTC_LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200639 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000640}
641
Max Morin787eeed2016-06-23 10:42:07 +0200642int32_t AudioDeviceModuleImpl::RecordingIsAvailable(bool* available) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100643 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200644 CHECKinitialized_();
645 bool isAvailable = false;
646 if (audio_device_->RecordingIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200647 return -1;
648 }
Max Morin787eeed2016-06-23 10:42:07 +0200649 *available = isAvailable;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100650 RTC_LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200651 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000652}
653
Max Morin787eeed2016-06-23 10:42:07 +0200654int32_t AudioDeviceModuleImpl::MaxMicrophoneVolume(uint32_t* maxVolume) const {
henrika4af73662017-10-11 13:16:17 +0200655 CHECKinitialized_();
Max Morin787eeed2016-06-23 10:42:07 +0200656 uint32_t maxVol(0);
henrika4af73662017-10-11 13:16:17 +0200657 if (audio_device_->MaxMicrophoneVolume(maxVol) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200658 return -1;
659 }
Max Morin787eeed2016-06-23 10:42:07 +0200660 *maxVolume = maxVol;
henrika4af73662017-10-11 13:16:17 +0200661 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000662}
663
Max Morin787eeed2016-06-23 10:42:07 +0200664int32_t AudioDeviceModuleImpl::MinMicrophoneVolume(uint32_t* minVolume) const {
henrika4af73662017-10-11 13:16:17 +0200665 CHECKinitialized_();
Max Morin787eeed2016-06-23 10:42:07 +0200666 uint32_t minVol(0);
henrika4af73662017-10-11 13:16:17 +0200667 if (audio_device_->MinMicrophoneVolume(minVol) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200668 return -1;
669 }
Max Morin787eeed2016-06-23 10:42:07 +0200670 *minVolume = minVol;
henrika4af73662017-10-11 13:16:17 +0200671 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000672}
673
Max Morin787eeed2016-06-23 10:42:07 +0200674int16_t AudioDeviceModuleImpl::PlayoutDevices() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100675 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200676 CHECKinitialized_();
677 uint16_t nPlayoutDevices = audio_device_->PlayoutDevices();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100678 RTC_LOG(INFO) << "output: " << nPlayoutDevices;
henrika4af73662017-10-11 13:16:17 +0200679 return (int16_t)(nPlayoutDevices);
niklase@google.com470e71d2011-07-07 08:21:25 +0000680}
681
Max Morin787eeed2016-06-23 10:42:07 +0200682int32_t AudioDeviceModuleImpl::SetPlayoutDevice(uint16_t index) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100683 RTC_LOG(INFO) << __FUNCTION__ << "(" << index << ")";
henrika4af73662017-10-11 13:16:17 +0200684 CHECKinitialized_();
685 return audio_device_->SetPlayoutDevice(index);
niklase@google.com470e71d2011-07-07 08:21:25 +0000686}
687
Max Morin787eeed2016-06-23 10:42:07 +0200688int32_t AudioDeviceModuleImpl::SetPlayoutDevice(WindowsDeviceType device) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100689 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200690 CHECKinitialized_();
691 return audio_device_->SetPlayoutDevice(device);
niklase@google.com470e71d2011-07-07 08:21:25 +0000692}
693
pbos@webrtc.org25509882013-04-09 10:30:35 +0000694int32_t AudioDeviceModuleImpl::PlayoutDeviceName(
695 uint16_t index,
leozwang@webrtc.org28f39132012-03-01 18:01:48 +0000696 char name[kAdmMaxDeviceNameSize],
Max Morin787eeed2016-06-23 10:42:07 +0200697 char guid[kAdmMaxGuidSize]) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100698 RTC_LOG(INFO) << __FUNCTION__ << "(" << index << ", ...)";
henrika4af73662017-10-11 13:16:17 +0200699 CHECKinitialized_();
Max Morin787eeed2016-06-23 10:42:07 +0200700 if (name == NULL) {
Max Morin787eeed2016-06-23 10:42:07 +0200701 return -1;
702 }
henrika4af73662017-10-11 13:16:17 +0200703 if (audio_device_->PlayoutDeviceName(index, name, guid) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200704 return -1;
705 }
Max Morin787eeed2016-06-23 10:42:07 +0200706 if (name != NULL) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100707 RTC_LOG(INFO) << "output: name = " << name;
Max Morin787eeed2016-06-23 10:42:07 +0200708 }
709 if (guid != NULL) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100710 RTC_LOG(INFO) << "output: guid = " << guid;
Max Morin787eeed2016-06-23 10:42:07 +0200711 }
henrika4af73662017-10-11 13:16:17 +0200712 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000713}
714
pbos@webrtc.org25509882013-04-09 10:30:35 +0000715int32_t AudioDeviceModuleImpl::RecordingDeviceName(
716 uint16_t index,
leozwang@webrtc.org28f39132012-03-01 18:01:48 +0000717 char name[kAdmMaxDeviceNameSize],
Max Morin787eeed2016-06-23 10:42:07 +0200718 char guid[kAdmMaxGuidSize]) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100719 RTC_LOG(INFO) << __FUNCTION__ << "(" << index << ", ...)";
henrika4af73662017-10-11 13:16:17 +0200720 CHECKinitialized_();
Max Morin787eeed2016-06-23 10:42:07 +0200721 if (name == NULL) {
Max Morin787eeed2016-06-23 10:42:07 +0200722 return -1;
723 }
henrika4af73662017-10-11 13:16:17 +0200724 if (audio_device_->RecordingDeviceName(index, name, guid) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200725 return -1;
726 }
Max Morin787eeed2016-06-23 10:42:07 +0200727 if (name != NULL) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100728 RTC_LOG(INFO) << "output: name = " << name;
Max Morin787eeed2016-06-23 10:42:07 +0200729 }
730 if (guid != NULL) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100731 RTC_LOG(INFO) << "output: guid = " << guid;
Max Morin787eeed2016-06-23 10:42:07 +0200732 }
henrika4af73662017-10-11 13:16:17 +0200733 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000734}
735
Max Morin787eeed2016-06-23 10:42:07 +0200736int16_t AudioDeviceModuleImpl::RecordingDevices() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100737 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200738 CHECKinitialized_();
739 uint16_t nRecordingDevices = audio_device_->RecordingDevices();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100740 RTC_LOG(INFO) << "output: " << nRecordingDevices;
henrika4af73662017-10-11 13:16:17 +0200741 return (int16_t)nRecordingDevices;
niklase@google.com470e71d2011-07-07 08:21:25 +0000742}
743
Max Morin787eeed2016-06-23 10:42:07 +0200744int32_t AudioDeviceModuleImpl::SetRecordingDevice(uint16_t index) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100745 RTC_LOG(INFO) << __FUNCTION__ << "(" << index << ")";
henrika4af73662017-10-11 13:16:17 +0200746 CHECKinitialized_();
747 return audio_device_->SetRecordingDevice(index);
niklase@google.com470e71d2011-07-07 08:21:25 +0000748}
749
Max Morin787eeed2016-06-23 10:42:07 +0200750int32_t AudioDeviceModuleImpl::SetRecordingDevice(WindowsDeviceType device) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100751 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200752 CHECKinitialized_();
753 return audio_device_->SetRecordingDevice(device);
niklase@google.com470e71d2011-07-07 08:21:25 +0000754}
755
Max Morin787eeed2016-06-23 10:42:07 +0200756int32_t AudioDeviceModuleImpl::InitPlayout() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100757 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200758 CHECKinitialized_();
maxmorin8c695b42016-07-25 02:46:44 -0700759 if (PlayoutIsInitialized()) {
760 return 0;
761 }
henrika4af73662017-10-11 13:16:17 +0200762 int32_t result = audio_device_->InitPlayout();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100763 RTC_LOG(INFO) << "output: " << result;
Max Morin84cab202016-07-01 13:35:19 +0200764 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.InitPlayoutSuccess",
765 static_cast<int>(result == 0));
766 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000767}
768
Max Morin787eeed2016-06-23 10:42:07 +0200769int32_t AudioDeviceModuleImpl::InitRecording() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100770 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200771 CHECKinitialized_();
maxmorin8c695b42016-07-25 02:46:44 -0700772 if (RecordingIsInitialized()) {
773 return 0;
774 }
henrika4af73662017-10-11 13:16:17 +0200775 int32_t result = audio_device_->InitRecording();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100776 RTC_LOG(INFO) << "output: " << result;
Max Morin84cab202016-07-01 13:35:19 +0200777 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.InitRecordingSuccess",
778 static_cast<int>(result == 0));
779 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000780}
781
Max Morin787eeed2016-06-23 10:42:07 +0200782bool AudioDeviceModuleImpl::PlayoutIsInitialized() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100783 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200784 CHECKinitialized__BOOL();
785 return audio_device_->PlayoutIsInitialized();
niklase@google.com470e71d2011-07-07 08:21:25 +0000786}
787
Max Morin787eeed2016-06-23 10:42:07 +0200788bool AudioDeviceModuleImpl::RecordingIsInitialized() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100789 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200790 CHECKinitialized__BOOL();
791 return audio_device_->RecordingIsInitialized();
niklase@google.com470e71d2011-07-07 08:21:25 +0000792}
793
Max Morin787eeed2016-06-23 10:42:07 +0200794int32_t AudioDeviceModuleImpl::StartPlayout() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100795 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200796 CHECKinitialized_();
maxmorin8c695b42016-07-25 02:46:44 -0700797 if (Playing()) {
798 return 0;
799 }
henrika4af73662017-10-11 13:16:17 +0200800 audio_device_buffer_.StartPlayout();
801 int32_t result = audio_device_->StartPlayout();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100802 RTC_LOG(INFO) << "output: " << result;
Max Morin84cab202016-07-01 13:35:19 +0200803 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StartPlayoutSuccess",
804 static_cast<int>(result == 0));
805 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000806}
807
Max Morin787eeed2016-06-23 10:42:07 +0200808int32_t AudioDeviceModuleImpl::StopPlayout() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100809 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200810 CHECKinitialized_();
811 int32_t result = audio_device_->StopPlayout();
812 audio_device_buffer_.StopPlayout();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100813 RTC_LOG(INFO) << "output: " << result;
Max Morin84cab202016-07-01 13:35:19 +0200814 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StopPlayoutSuccess",
815 static_cast<int>(result == 0));
816 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000817}
818
Max Morin787eeed2016-06-23 10:42:07 +0200819bool AudioDeviceModuleImpl::Playing() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100820 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200821 CHECKinitialized__BOOL();
822 return audio_device_->Playing();
niklase@google.com470e71d2011-07-07 08:21:25 +0000823}
824
Max Morin787eeed2016-06-23 10:42:07 +0200825int32_t AudioDeviceModuleImpl::StartRecording() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100826 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200827 CHECKinitialized_();
maxmorin8c695b42016-07-25 02:46:44 -0700828 if (Recording()) {
829 return 0;
830 }
henrika4af73662017-10-11 13:16:17 +0200831 audio_device_buffer_.StartRecording();
832 int32_t result = audio_device_->StartRecording();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100833 RTC_LOG(INFO) << "output: " << result;
Max Morin84cab202016-07-01 13:35:19 +0200834 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StartRecordingSuccess",
835 static_cast<int>(result == 0));
836 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000837}
niklase@google.com470e71d2011-07-07 08:21:25 +0000838
Max Morin787eeed2016-06-23 10:42:07 +0200839int32_t AudioDeviceModuleImpl::StopRecording() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100840 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200841 CHECKinitialized_();
842 int32_t result = audio_device_->StopRecording();
843 audio_device_buffer_.StopRecording();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100844 RTC_LOG(INFO) << "output: " << result;
Max Morin84cab202016-07-01 13:35:19 +0200845 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StopRecordingSuccess",
846 static_cast<int>(result == 0));
847 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000848}
849
Max Morin787eeed2016-06-23 10:42:07 +0200850bool AudioDeviceModuleImpl::Recording() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100851 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200852 CHECKinitialized__BOOL();
853 return audio_device_->Recording();
niklase@google.com470e71d2011-07-07 08:21:25 +0000854}
855
Max Morin787eeed2016-06-23 10:42:07 +0200856int32_t AudioDeviceModuleImpl::RegisterAudioCallback(
857 AudioTransport* audioCallback) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100858 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200859 return audio_device_buffer_.RegisterAudioCallback(audioCallback);
niklase@google.com470e71d2011-07-07 08:21:25 +0000860}
861
Max Morin787eeed2016-06-23 10:42:07 +0200862int32_t AudioDeviceModuleImpl::PlayoutDelay(uint16_t* delayMS) const {
henrika4af73662017-10-11 13:16:17 +0200863 CHECKinitialized_();
864 uint16_t delay = 0;
865 if (audio_device_->PlayoutDelay(delay) == -1) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100866 RTC_LOG(LERROR) << "failed to retrieve the playout delay";
Max Morin787eeed2016-06-23 10:42:07 +0200867 return -1;
868 }
Max Morin787eeed2016-06-23 10:42:07 +0200869 *delayMS = delay;
henrika4af73662017-10-11 13:16:17 +0200870 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000871}
872
henrika@webrtc.orga954c072014-12-09 16:22:09 +0000873bool AudioDeviceModuleImpl::BuiltInAECIsAvailable() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100874 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200875 CHECKinitialized__BOOL();
876 bool isAvailable = audio_device_->BuiltInAECIsAvailable();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100877 RTC_LOG(INFO) << "output: " << isAvailable;
Max Morin098e6c52016-06-28 09:36:25 +0200878 return isAvailable;
henrika@webrtc.orga954c072014-12-09 16:22:09 +0000879}
880
henrikac14f5ff2015-09-23 14:08:33 +0200881int32_t AudioDeviceModuleImpl::EnableBuiltInAEC(bool enable) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100882 RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200883 CHECKinitialized_();
884 int32_t ok = audio_device_->EnableBuiltInAEC(enable);
Mirko Bonadei675513b2017-11-09 11:09:25 +0100885 RTC_LOG(INFO) << "output: " << ok;
Max Morin098e6c52016-06-28 09:36:25 +0200886 return ok;
henrikac14f5ff2015-09-23 14:08:33 +0200887}
888
889bool AudioDeviceModuleImpl::BuiltInAGCIsAvailable() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100890 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200891 CHECKinitialized__BOOL();
892 bool isAvailable = audio_device_->BuiltInAGCIsAvailable();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100893 RTC_LOG(INFO) << "output: " << isAvailable;
Max Morin098e6c52016-06-28 09:36:25 +0200894 return isAvailable;
henrikac14f5ff2015-09-23 14:08:33 +0200895}
896
897int32_t AudioDeviceModuleImpl::EnableBuiltInAGC(bool enable) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100898 RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200899 CHECKinitialized_();
900 int32_t ok = audio_device_->EnableBuiltInAGC(enable);
Mirko Bonadei675513b2017-11-09 11:09:25 +0100901 RTC_LOG(INFO) << "output: " << ok;
Max Morin098e6c52016-06-28 09:36:25 +0200902 return ok;
henrikac14f5ff2015-09-23 14:08:33 +0200903}
904
905bool AudioDeviceModuleImpl::BuiltInNSIsAvailable() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100906 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200907 CHECKinitialized__BOOL();
908 bool isAvailable = audio_device_->BuiltInNSIsAvailable();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100909 RTC_LOG(INFO) << "output: " << isAvailable;
Max Morin098e6c52016-06-28 09:36:25 +0200910 return isAvailable;
henrikac14f5ff2015-09-23 14:08:33 +0200911}
912
913int32_t AudioDeviceModuleImpl::EnableBuiltInNS(bool enable) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100914 RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200915 CHECKinitialized_();
916 int32_t ok = audio_device_->EnableBuiltInNS(enable);
Mirko Bonadei675513b2017-11-09 11:09:25 +0100917 RTC_LOG(INFO) << "output: " << ok;
Max Morin098e6c52016-06-28 09:36:25 +0200918 return ok;
henrikac14f5ff2015-09-23 14:08:33 +0200919}
920
maxmorin88e31a32016-08-16 00:56:09 -0700921#if defined(WEBRTC_IOS)
henrikaba35d052015-07-14 17:04:08 +0200922int AudioDeviceModuleImpl::GetPlayoutAudioParameters(
923 AudioParameters* params) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100924 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200925 int r = audio_device_->GetPlayoutAudioParameters(params);
Mirko Bonadei675513b2017-11-09 11:09:25 +0100926 RTC_LOG(INFO) << "output: " << r;
Max Morin098e6c52016-06-28 09:36:25 +0200927 return r;
henrikaba35d052015-07-14 17:04:08 +0200928}
929
930int AudioDeviceModuleImpl::GetRecordAudioParameters(
931 AudioParameters* params) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100932 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200933 int r = audio_device_->GetRecordAudioParameters(params);
Mirko Bonadei675513b2017-11-09 11:09:25 +0100934 RTC_LOG(INFO) << "output: " << r;
Max Morin098e6c52016-06-28 09:36:25 +0200935 return r;
henrikaba35d052015-07-14 17:04:08 +0200936}
maxmorin88e31a32016-08-16 00:56:09 -0700937#endif // WEBRTC_IOS
henrikaba35d052015-07-14 17:04:08 +0200938
Max Morin787eeed2016-06-23 10:42:07 +0200939AudioDeviceModuleImpl::PlatformType AudioDeviceModuleImpl::Platform() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100940 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200941 return platform_type_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000942}
943
Max Morin787eeed2016-06-23 10:42:07 +0200944AudioDeviceModule::AudioLayer AudioDeviceModuleImpl::PlatformAudioLayer()
945 const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100946 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200947 return audio_layer_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000948}
949
950} // namespace webrtc