blob: 31d5b5ecfc51e9a8ca53b2c3aee89865983e06f4 [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
15#include "modules/audio_device/audio_device_config.h" // IWYU pragma: keep
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020016#include "modules/audio_device/audio_device_generic.h"
17#include "rtc_base/checks.h"
18#include "rtc_base/logging.h"
Niels Möller84255bb2017-10-06 13:43:23 +020019#include "rtc_base/refcountedobject.h"
Yves Gerey988cc082018-10-23 12:03:01 +020020#include "rtc_base/scoped_ref_ptr.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020021#include "system_wrappers/include/metrics.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000022
niklase@google.com470e71d2011-07-07 08:21:25 +000023#if defined(_WIN32)
Max Morin787eeed2016-06-23 10:42:07 +020024#if defined(WEBRTC_WINDOWS_CORE_AUDIO_BUILD)
henrika883d00f2018-03-16 10:09:49 +010025#include "modules/audio_device/win/audio_device_core_win.h"
Max Morin787eeed2016-06-23 10:42:07 +020026#endif
leozwang@google.com39f20512011-07-15 16:29:40 +000027#elif defined(WEBRTC_ANDROID)
henrikab2619892015-05-18 16:49:16 +020028#include <stdlib.h>
henrika883d00f2018-03-16 10:09:49 +010029#if defined(AUDIO_DEVICE_INCLUDE_ANDROID_AAUDIO)
30#include "modules/audio_device/android/aaudio_player.h"
31#include "modules/audio_device/android/aaudio_recorder.h"
32#endif
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020033#include "modules/audio_device/android/audio_device_template.h"
34#include "modules/audio_device/android/audio_manager.h"
35#include "modules/audio_device/android/audio_record_jni.h"
36#include "modules/audio_device/android/audio_track_jni.h"
37#include "modules/audio_device/android/opensles_player.h"
38#include "modules/audio_device/android/opensles_recorder.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000039#elif defined(WEBRTC_LINUX)
Max Morin787eeed2016-06-23 10:42:07 +020040#if defined(LINUX_ALSA)
henrika883d00f2018-03-16 10:09:49 +010041#include "modules/audio_device/linux/audio_device_alsa_linux.h"
Max Morin787eeed2016-06-23 10:42:07 +020042#endif
Tommi68898a22015-05-19 17:28:07 +020043#if defined(LINUX_PULSE)
henrika883d00f2018-03-16 10:09:49 +010044#include "modules/audio_device/linux/audio_device_pulse_linux.h"
Tommi68898a22015-05-19 17:28:07 +020045#endif
sjlee@webrtc.org414fa7f2012-09-11 17:25:46 +000046#elif defined(WEBRTC_IOS)
henrika883d00f2018-03-16 10:09:49 +010047#include "modules/audio_device/ios/audio_device_ios.h"
andrew@webrtc.orgf3b65db2012-09-06 18:17:00 +000048#elif defined(WEBRTC_MAC)
henrika883d00f2018-03-16 10:09:49 +010049#include "modules/audio_device/mac/audio_device_mac.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000050#endif
phoglund@webrtc.org8454ad12014-06-11 14:12:04 +000051#if defined(WEBRTC_DUMMY_FILE_DEVICES)
Yves Gerey988cc082018-10-23 12:03:01 +020052#include "modules/audio_device/dummy/file_audio_device.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020053#include "modules/audio_device/dummy/file_audio_device_factory.h"
phoglund@webrtc.org8454ad12014-06-11 14:12:04 +000054#endif
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020055#include "modules/audio_device/dummy/audio_device_dummy.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000056
henrika4af73662017-10-11 13:16:17 +020057#define CHECKinitialized_() \
Max Morin787eeed2016-06-23 10:42:07 +020058 { \
henrika4af73662017-10-11 13:16:17 +020059 if (!initialized_) { \
Max Morin787eeed2016-06-23 10:42:07 +020060 return -1; \
henrika883d00f2018-03-16 10:09:49 +010061 } \
Max Morin787eeed2016-06-23 10:42:07 +020062 }
niklase@google.com470e71d2011-07-07 08:21:25 +000063
henrika4af73662017-10-11 13:16:17 +020064#define CHECKinitialized__BOOL() \
Max Morin787eeed2016-06-23 10:42:07 +020065 { \
henrika4af73662017-10-11 13:16:17 +020066 if (!initialized_) { \
Max Morin787eeed2016-06-23 10:42:07 +020067 return false; \
henrika883d00f2018-03-16 10:09:49 +010068 } \
Max Morin787eeed2016-06-23 10:42:07 +020069 }
niklase@google.com470e71d2011-07-07 08:21:25 +000070
Peter Boström1d194412016-03-21 16:44:31 +010071namespace webrtc {
henrike@webrtc.org70efc322012-02-23 17:45:33 +000072
Peter Boström4adbbcf2016-05-03 15:51:26 -040073rtc::scoped_refptr<AudioDeviceModule> AudioDeviceModule::Create(
Peter Boström4adbbcf2016-05-03 15:51:26 -040074 const AudioLayer audio_layer) {
Mirko Bonadei675513b2017-11-09 11:09:25 +010075 RTC_LOG(INFO) << __FUNCTION__;
henrika5b6afc02018-09-05 14:34:40 +020076 return AudioDeviceModule::CreateForTest(audio_layer);
77}
78
79// static
80rtc::scoped_refptr<AudioDeviceModuleForTest> AudioDeviceModule::CreateForTest(
81 const AudioLayer audio_layer) {
82 RTC_LOG(INFO) << __FUNCTION__;
henrikaec9c7452018-06-08 16:10:03 +020083
84 // The "AudioDeviceModule::kWindowsCoreAudio2" audio layer has its own
85 // dedicated factory method which should be used instead.
86 if (audio_layer == AudioDeviceModule::kWindowsCoreAudio2) {
87 RTC_LOG(LS_ERROR) << "Use the CreateWindowsCoreAudioAudioDeviceModule() "
88 "factory method instead for this option.";
89 return nullptr;
90 }
91
henrika4af73662017-10-11 13:16:17 +020092 // Create the generic reference counted (platform independent) implementation.
Max Morin787eeed2016-06-23 10:42:07 +020093 rtc::scoped_refptr<AudioDeviceModuleImpl> audioDevice(
henrika5ff64832017-10-11 15:14:51 +020094 new rtc::RefCountedObject<AudioDeviceModuleImpl>(audio_layer));
niklase@google.com470e71d2011-07-07 08:21:25 +000095
Max Morin787eeed2016-06-23 10:42:07 +020096 // Ensure that the current platform is supported.
97 if (audioDevice->CheckPlatform() == -1) {
98 return nullptr;
99 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000100
Max Morin787eeed2016-06-23 10:42:07 +0200101 // Create the platform-dependent implementation.
102 if (audioDevice->CreatePlatformSpecificObjects() == -1) {
103 return nullptr;
104 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000105
henrika4af73662017-10-11 13:16:17 +0200106 // Ensure that the generic audio buffer can communicate with the platform
107 // specific parts.
Max Morin787eeed2016-06-23 10:42:07 +0200108 if (audioDevice->AttachAudioBuffer() == -1) {
109 return nullptr;
110 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000111
Max Morin787eeed2016-06-23 10:42:07 +0200112 return audioDevice;
niklase@google.com470e71d2011-07-07 08:21:25 +0000113}
114
henrika616e3132017-11-13 12:47:59 +0100115// TODO(bugs.webrtc.org/7306): deprecated.
116rtc::scoped_refptr<AudioDeviceModule> AudioDeviceModule::Create(
117 const int32_t id,
118 const AudioLayer audio_layer) {
119 RTC_LOG(INFO) << __FUNCTION__;
120 return AudioDeviceModule::Create(audio_layer);
121}
122
henrika5ff64832017-10-11 15:14:51 +0200123AudioDeviceModuleImpl::AudioDeviceModuleImpl(const AudioLayer audioLayer)
124 : audio_layer_(audioLayer) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100125 RTC_LOG(INFO) << __FUNCTION__;
niklase@google.com470e71d2011-07-07 08:21:25 +0000126}
127
Max Morin787eeed2016-06-23 10:42:07 +0200128int32_t AudioDeviceModuleImpl::CheckPlatform() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100129 RTC_LOG(INFO) << __FUNCTION__;
Max Morin787eeed2016-06-23 10:42:07 +0200130 // Ensure that the current platform is supported
Max Morin787eeed2016-06-23 10:42:07 +0200131 PlatformType platform(kPlatformNotSupported);
niklase@google.com470e71d2011-07-07 08:21:25 +0000132#if defined(_WIN32)
Max Morin787eeed2016-06-23 10:42:07 +0200133 platform = kPlatformWin32;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100134 RTC_LOG(INFO) << "current platform is Win32";
leozwang@google.com522f42b2011-09-19 17:39:05 +0000135#elif defined(WEBRTC_ANDROID)
Max Morin787eeed2016-06-23 10:42:07 +0200136 platform = kPlatformAndroid;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100137 RTC_LOG(INFO) << "current platform is Android";
niklase@google.com470e71d2011-07-07 08:21:25 +0000138#elif defined(WEBRTC_LINUX)
Max Morin787eeed2016-06-23 10:42:07 +0200139 platform = kPlatformLinux;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100140 RTC_LOG(INFO) << "current platform is Linux";
sjlee@webrtc.org414fa7f2012-09-11 17:25:46 +0000141#elif defined(WEBRTC_IOS)
Max Morin787eeed2016-06-23 10:42:07 +0200142 platform = kPlatformIOS;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100143 RTC_LOG(INFO) << "current platform is IOS";
andrew@webrtc.orgf3b65db2012-09-06 18:17:00 +0000144#elif defined(WEBRTC_MAC)
Max Morin787eeed2016-06-23 10:42:07 +0200145 platform = kPlatformMac;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100146 RTC_LOG(INFO) << "current platform is Mac";
niklase@google.com470e71d2011-07-07 08:21:25 +0000147#endif
Max Morin787eeed2016-06-23 10:42:07 +0200148 if (platform == kPlatformNotSupported) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100149 RTC_LOG(LERROR)
150 << "current platform is not supported => this module will self "
151 "destruct!";
Max Morin787eeed2016-06-23 10:42:07 +0200152 return -1;
153 }
henrika4af73662017-10-11 13:16:17 +0200154 platform_type_ = platform;
Max Morin787eeed2016-06-23 10:42:07 +0200155 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000156}
157
Max Morin787eeed2016-06-23 10:42:07 +0200158int32_t AudioDeviceModuleImpl::CreatePlatformSpecificObjects() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100159 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200160// Dummy ADM implementations if build flags are set.
xians@google.combf5d2ba2011-08-16 07:44:19 +0000161#if defined(WEBRTC_DUMMY_AUDIO_BUILD)
henrika5ff64832017-10-11 15:14:51 +0200162 audio_device_.reset(new AudioDeviceDummy());
Mirko Bonadei675513b2017-11-09 11:09:25 +0100163 RTC_LOG(INFO) << "Dummy Audio APIs will be utilized";
phoglund@webrtc.org8454ad12014-06-11 14:12:04 +0000164#elif defined(WEBRTC_DUMMY_FILE_DEVICES)
henrika5ff64832017-10-11 15:14:51 +0200165 audio_device_.reset(FileAudioDeviceFactory::CreateFileAudioDevice());
henrika4af73662017-10-11 13:16:17 +0200166 if (audio_device_) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100167 RTC_LOG(INFO) << "Will use file-playing dummy device.";
noahric6a355902016-08-17 15:19:50 -0700168 } else {
169 // Create a dummy device instead.
henrika5ff64832017-10-11 15:14:51 +0200170 audio_device_.reset(new AudioDeviceDummy());
Mirko Bonadei675513b2017-11-09 11:09:25 +0100171 RTC_LOG(INFO) << "Dummy Audio APIs will be utilized";
noahric6a355902016-08-17 15:19:50 -0700172 }
henrika4af73662017-10-11 13:16:17 +0200173
174// Real (non-dummy) ADM implementations.
xians@google.combf5d2ba2011-08-16 07:44:19 +0000175#else
henrika4af73662017-10-11 13:16:17 +0200176 AudioLayer audio_layer(PlatformAudioLayer());
177// Windows ADM implementation.
niklase@google.com470e71d2011-07-07 08:21:25 +0000178#if defined(WEBRTC_WINDOWS_CORE_AUDIO_BUILD)
henrika4af73662017-10-11 13:16:17 +0200179 if ((audio_layer == kWindowsCoreAudio) ||
180 (audio_layer == kPlatformDefaultAudio)) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100181 RTC_LOG(INFO) << "Attempting to use the Windows Core Audio APIs...";
Max Morin787eeed2016-06-23 10:42:07 +0200182 if (AudioDeviceWindowsCore::CoreAudioIsSupported()) {
henrika4af73662017-10-11 13:16:17 +0200183 audio_device_.reset(new AudioDeviceWindowsCore());
Mirko Bonadei675513b2017-11-09 11:09:25 +0100184 RTC_LOG(INFO) << "Windows Core Audio APIs will be utilized";
niklase@google.com470e71d2011-07-07 08:21:25 +0000185 }
Max Morin787eeed2016-06-23 10:42:07 +0200186 }
187#endif // defined(WEBRTC_WINDOWS_CORE_AUDIO_BUILD)
niklase@google.com470e71d2011-07-07 08:21:25 +0000188
henrike@webrtc.org9ee75e92013-12-11 21:42:44 +0000189#if defined(WEBRTC_ANDROID)
Max Morin787eeed2016-06-23 10:42:07 +0200190 // Create an Android audio manager.
henrika4af73662017-10-11 13:16:17 +0200191 audio_manager_android_.reset(new AudioManager());
Max Morin787eeed2016-06-23 10:42:07 +0200192 // Select best possible combination of audio layers.
henrika4af73662017-10-11 13:16:17 +0200193 if (audio_layer == kPlatformDefaultAudio) {
henrika883d00f2018-03-16 10:09:49 +0100194 if (audio_manager_android_->IsAAudioSupported()) {
195 // Use of AAudio for both playout and recording has highest priority.
196 audio_layer = kAndroidAAudioAudio;
197 } else if (audio_manager_android_->IsLowLatencyPlayoutSupported() &&
198 audio_manager_android_->IsLowLatencyRecordSupported()) {
henrika918b5542016-09-19 15:44:09 +0200199 // Use OpenSL ES for both playout and recording.
henrika4af73662017-10-11 13:16:17 +0200200 audio_layer = kAndroidOpenSLESAudio;
201 } else if (audio_manager_android_->IsLowLatencyPlayoutSupported() &&
202 !audio_manager_android_->IsLowLatencyRecordSupported()) {
henrika918b5542016-09-19 15:44:09 +0200203 // Use OpenSL ES for output on devices that only supports the
Max Morin787eeed2016-06-23 10:42:07 +0200204 // low-latency output audio path.
henrika4af73662017-10-11 13:16:17 +0200205 audio_layer = kAndroidJavaInputAndOpenSLESOutputAudio;
henrikab2619892015-05-18 16:49:16 +0200206 } else {
henrika918b5542016-09-19 15:44:09 +0200207 // Use Java-based audio in both directions when low-latency output is
208 // not supported.
henrika4af73662017-10-11 13:16:17 +0200209 audio_layer = kAndroidJavaAudio;
niklase@google.com470e71d2011-07-07 08:21:25 +0000210 }
Max Morin787eeed2016-06-23 10:42:07 +0200211 }
henrika4af73662017-10-11 13:16:17 +0200212 AudioManager* audio_manager = audio_manager_android_.get();
213 if (audio_layer == kAndroidJavaAudio) {
Max Morin787eeed2016-06-23 10:42:07 +0200214 // Java audio for both input and output audio.
henrika4af73662017-10-11 13:16:17 +0200215 audio_device_.reset(new AudioDeviceTemplate<AudioRecordJni, AudioTrackJni>(
216 audio_layer, audio_manager));
217 } else if (audio_layer == kAndroidOpenSLESAudio) {
henrika918b5542016-09-19 15:44:09 +0200218 // OpenSL ES based audio for both input and output audio.
henrika4af73662017-10-11 13:16:17 +0200219 audio_device_.reset(
220 new AudioDeviceTemplate<OpenSLESRecorder, OpenSLESPlayer>(
221 audio_layer, audio_manager));
222 } else if (audio_layer == kAndroidJavaInputAndOpenSLESOutputAudio) {
Max Morin787eeed2016-06-23 10:42:07 +0200223 // Java audio for input and OpenSL ES for output audio (i.e. mixed APIs).
224 // This combination provides low-latency output audio and at the same
225 // time support for HW AEC using the AudioRecord Java API.
henrika4af73662017-10-11 13:16:17 +0200226 audio_device_.reset(new AudioDeviceTemplate<AudioRecordJni, OpenSLESPlayer>(
227 audio_layer, audio_manager));
henrika883d00f2018-03-16 10:09:49 +0100228 } else if (audio_layer == kAndroidAAudioAudio) {
229#if defined(AUDIO_DEVICE_INCLUDE_ANDROID_AAUDIO)
230 // AAudio based audio for both input and output.
231 audio_device_.reset(new AudioDeviceTemplate<AAudioRecorder, AAudioPlayer>(
232 audio_layer, audio_manager));
233#endif
234 } else if (audio_layer == kAndroidJavaInputAndAAudioOutputAudio) {
235#if defined(AUDIO_DEVICE_INCLUDE_ANDROID_AAUDIO)
236 // Java audio for input and AAudio for output audio (i.e. mixed APIs).
237 audio_device_.reset(new AudioDeviceTemplate<AudioRecordJni, AAudioPlayer>(
238 audio_layer, audio_manager));
239#endif
Max Morin787eeed2016-06-23 10:42:07 +0200240 } else {
henrika883d00f2018-03-16 10:09:49 +0100241 RTC_LOG(LS_ERROR) << "The requested audio layer is not supported";
henrika4af73662017-10-11 13:16:17 +0200242 audio_device_.reset(nullptr);
Max Morin787eeed2016-06-23 10:42:07 +0200243 }
244// END #if defined(WEBRTC_ANDROID)
niklase@google.com470e71d2011-07-07 08:21:25 +0000245
henrika4af73662017-10-11 13:16:17 +0200246// Linux ADM implementation.
henrika68435f52018-04-09 13:31:45 +0200247// Note that, LINUX_ALSA is always defined by default when WEBRTC_LINUX is
248// defined. LINUX_PULSE depends on the 'rtc_include_pulse_audio' build flag.
249// TODO(bugs.webrtc.org/9127): improve support and make it more clear that
250// PulseAudio is the default selection.
niklase@google.com470e71d2011-07-07 08:21:25 +0000251#elif defined(WEBRTC_LINUX)
henrika68435f52018-04-09 13:31:45 +0200252#if !defined(LINUX_PULSE)
253 // Build flag 'rtc_include_pulse_audio' is set to false. In this mode:
254 // - kPlatformDefaultAudio => ALSA, and
255 // - kLinuxAlsaAudio => ALSA, and
256 // - kLinuxPulseAudio => Invalid selection.
257 RTC_LOG(WARNING) << "PulseAudio is disabled using build flag.";
258 if ((audio_layer == kLinuxAlsaAudio) ||
henrika4af73662017-10-11 13:16:17 +0200259 (audio_layer == kPlatformDefaultAudio)) {
henrika4af73662017-10-11 13:16:17 +0200260 audio_device_.reset(new AudioDeviceLinuxALSA());
Mirko Bonadei675513b2017-11-09 11:09:25 +0100261 RTC_LOG(INFO) << "Linux ALSA APIs will be utilized.";
Max Morin787eeed2016-06-23 10:42:07 +0200262 }
henrika68435f52018-04-09 13:31:45 +0200263#else
264 // Build flag 'rtc_include_pulse_audio' is set to true (default). In this
265 // mode:
266 // - kPlatformDefaultAudio => PulseAudio, and
267 // - kLinuxPulseAudio => PulseAudio, and
268 // - kLinuxAlsaAudio => ALSA (supported but not default).
269 RTC_LOG(INFO) << "PulseAudio support is enabled.";
270 if ((audio_layer == kLinuxPulseAudio) ||
271 (audio_layer == kPlatformDefaultAudio)) {
272 // Linux PulseAudio implementation is default.
273 audio_device_.reset(new AudioDeviceLinuxPulse());
274 RTC_LOG(INFO) << "Linux PulseAudio APIs will be utilized";
275 } else if (audio_layer == kLinuxAlsaAudio) {
276 audio_device_.reset(new AudioDeviceLinuxALSA());
277 RTC_LOG(WARNING) << "Linux ALSA APIs will be utilized.";
278 }
279#endif // #if !defined(LINUX_PULSE)
niklase@google.com470e71d2011-07-07 08:21:25 +0000280#endif // #if defined(WEBRTC_LINUX)
281
henrika4af73662017-10-11 13:16:17 +0200282// iOS ADM implementation.
sjlee@webrtc.org414fa7f2012-09-11 17:25:46 +0000283#if defined(WEBRTC_IOS)
henrika4af73662017-10-11 13:16:17 +0200284 if (audio_layer == kPlatformDefaultAudio) {
285 audio_device_.reset(new AudioDeviceIOS());
Mirko Bonadei675513b2017-11-09 11:09:25 +0100286 RTC_LOG(INFO) << "iPhone Audio APIs will be utilized.";
Max Morin787eeed2016-06-23 10:42:07 +0200287 }
288// END #if defined(WEBRTC_IOS)
niklase@google.com470e71d2011-07-07 08:21:25 +0000289
henrika4af73662017-10-11 13:16:17 +0200290// Mac OS X ADM implementation.
andrew@webrtc.orgf3b65db2012-09-06 18:17:00 +0000291#elif defined(WEBRTC_MAC)
henrika4af73662017-10-11 13:16:17 +0200292 if (audio_layer == kPlatformDefaultAudio) {
293 audio_device_.reset(new AudioDeviceMac());
Mirko Bonadei675513b2017-11-09 11:09:25 +0100294 RTC_LOG(INFO) << "Mac OS X Audio APIs will be utilized.";
Max Morin787eeed2016-06-23 10:42:07 +0200295 }
andrew@webrtc.orgf3b65db2012-09-06 18:17:00 +0000296#endif // WEBRTC_MAC
niklase@google.com470e71d2011-07-07 08:21:25 +0000297
henrika4af73662017-10-11 13:16:17 +0200298 // Dummy ADM implementation.
299 if (audio_layer == kDummyAudio) {
henrika5ff64832017-10-11 15:14:51 +0200300 audio_device_.reset(new AudioDeviceDummy());
Mirko Bonadei675513b2017-11-09 11:09:25 +0100301 RTC_LOG(INFO) << "Dummy Audio APIs will be utilized.";
Max Morin787eeed2016-06-23 10:42:07 +0200302 }
xians@google.combf5d2ba2011-08-16 07:44:19 +0000303#endif // if defined(WEBRTC_DUMMY_AUDIO_BUILD)
niklase@google.com470e71d2011-07-07 08:21:25 +0000304
henrika4af73662017-10-11 13:16:17 +0200305 if (!audio_device_) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100306 RTC_LOG(LS_ERROR)
henrika4af73662017-10-11 13:16:17 +0200307 << "Failed to create the platform specific ADM implementation.";
Max Morin787eeed2016-06-23 10:42:07 +0200308 return -1;
309 }
Max Morin787eeed2016-06-23 10:42:07 +0200310 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000311}
312
Max Morin787eeed2016-06-23 10:42:07 +0200313int32_t AudioDeviceModuleImpl::AttachAudioBuffer() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100314 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200315 audio_device_->AttachAudioBuffer(&audio_device_buffer_);
Max Morin787eeed2016-06-23 10:42:07 +0200316 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000317}
318
Max Morin787eeed2016-06-23 10:42:07 +0200319AudioDeviceModuleImpl::~AudioDeviceModuleImpl() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100320 RTC_LOG(INFO) << __FUNCTION__;
niklase@google.com470e71d2011-07-07 08:21:25 +0000321}
322
henrikab2619892015-05-18 16:49:16 +0200323int32_t AudioDeviceModuleImpl::ActiveAudioLayer(AudioLayer* audioLayer) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100324 RTC_LOG(INFO) << __FUNCTION__;
henrikab2619892015-05-18 16:49:16 +0200325 AudioLayer activeAudio;
henrika4af73662017-10-11 13:16:17 +0200326 if (audio_device_->ActiveAudioLayer(activeAudio) == -1) {
henrikab2619892015-05-18 16:49:16 +0200327 return -1;
328 }
329 *audioLayer = activeAudio;
330 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000331}
332
Max Morin787eeed2016-06-23 10:42:07 +0200333int32_t AudioDeviceModuleImpl::Init() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100334 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200335 if (initialized_)
niklase@google.com470e71d2011-07-07 08:21:25 +0000336 return 0;
henrika4af73662017-10-11 13:16:17 +0200337 RTC_CHECK(audio_device_);
338 AudioDeviceGeneric::InitStatus status = audio_device_->Init();
Max Morin84cab202016-07-01 13:35:19 +0200339 RTC_HISTOGRAM_ENUMERATION(
340 "WebRTC.Audio.InitializationResult", static_cast<int>(status),
341 static_cast<int>(AudioDeviceGeneric::InitStatus::NUM_STATUSES));
342 if (status != AudioDeviceGeneric::InitStatus::OK) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100343 RTC_LOG(LS_ERROR) << "Audio device initialization failed.";
Max Morin787eeed2016-06-23 10:42:07 +0200344 return -1;
345 }
henrika4af73662017-10-11 13:16:17 +0200346 initialized_ = true;
Max Morin787eeed2016-06-23 10:42:07 +0200347 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000348}
349
Max Morin787eeed2016-06-23 10:42:07 +0200350int32_t AudioDeviceModuleImpl::Terminate() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100351 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200352 if (!initialized_)
niklase@google.com470e71d2011-07-07 08:21:25 +0000353 return 0;
henrika4af73662017-10-11 13:16:17 +0200354 if (audio_device_->Terminate() == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200355 return -1;
356 }
henrika4af73662017-10-11 13:16:17 +0200357 initialized_ = false;
Max Morin787eeed2016-06-23 10:42:07 +0200358 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000359}
360
Max Morin787eeed2016-06-23 10:42:07 +0200361bool AudioDeviceModuleImpl::Initialized() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100362 RTC_LOG(INFO) << __FUNCTION__ << ": " << initialized_;
henrika4af73662017-10-11 13:16:17 +0200363 return initialized_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000364}
365
Max Morin787eeed2016-06-23 10:42:07 +0200366int32_t AudioDeviceModuleImpl::InitSpeaker() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100367 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200368 CHECKinitialized_();
369 return audio_device_->InitSpeaker();
niklase@google.com470e71d2011-07-07 08:21:25 +0000370}
371
Max Morin787eeed2016-06-23 10:42:07 +0200372int32_t AudioDeviceModuleImpl::InitMicrophone() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100373 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200374 CHECKinitialized_();
375 return audio_device_->InitMicrophone();
niklase@google.com470e71d2011-07-07 08:21:25 +0000376}
377
Max Morin787eeed2016-06-23 10:42:07 +0200378int32_t AudioDeviceModuleImpl::SpeakerVolumeIsAvailable(bool* available) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100379 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200380 CHECKinitialized_();
381 bool isAvailable = false;
382 if (audio_device_->SpeakerVolumeIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200383 return -1;
384 }
Max Morin787eeed2016-06-23 10:42:07 +0200385 *available = isAvailable;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100386 RTC_LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200387 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000388}
389
Max Morin787eeed2016-06-23 10:42:07 +0200390int32_t AudioDeviceModuleImpl::SetSpeakerVolume(uint32_t volume) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100391 RTC_LOG(INFO) << __FUNCTION__ << "(" << volume << ")";
henrika4af73662017-10-11 13:16:17 +0200392 CHECKinitialized_();
393 return audio_device_->SetSpeakerVolume(volume);
niklase@google.com470e71d2011-07-07 08:21:25 +0000394}
395
Max Morin787eeed2016-06-23 10:42:07 +0200396int32_t AudioDeviceModuleImpl::SpeakerVolume(uint32_t* volume) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100397 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200398 CHECKinitialized_();
399 uint32_t level = 0;
400 if (audio_device_->SpeakerVolume(level) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200401 return -1;
402 }
Max Morin787eeed2016-06-23 10:42:07 +0200403 *volume = level;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100404 RTC_LOG(INFO) << "output: " << *volume;
henrika4af73662017-10-11 13:16:17 +0200405 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000406}
407
Max Morin787eeed2016-06-23 10:42:07 +0200408bool AudioDeviceModuleImpl::SpeakerIsInitialized() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100409 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200410 CHECKinitialized__BOOL();
411 bool isInitialized = audio_device_->SpeakerIsInitialized();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100412 RTC_LOG(INFO) << "output: " << isInitialized;
henrika4af73662017-10-11 13:16:17 +0200413 return isInitialized;
niklase@google.com470e71d2011-07-07 08:21:25 +0000414}
415
Max Morin787eeed2016-06-23 10:42:07 +0200416bool AudioDeviceModuleImpl::MicrophoneIsInitialized() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100417 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200418 CHECKinitialized__BOOL();
419 bool isInitialized = audio_device_->MicrophoneIsInitialized();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100420 RTC_LOG(INFO) << "output: " << isInitialized;
henrika4af73662017-10-11 13:16:17 +0200421 return isInitialized;
niklase@google.com470e71d2011-07-07 08:21:25 +0000422}
423
Max Morin787eeed2016-06-23 10:42:07 +0200424int32_t AudioDeviceModuleImpl::MaxSpeakerVolume(uint32_t* maxVolume) const {
henrika4af73662017-10-11 13:16:17 +0200425 CHECKinitialized_();
426 uint32_t maxVol = 0;
427 if (audio_device_->MaxSpeakerVolume(maxVol) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200428 return -1;
429 }
Max Morin787eeed2016-06-23 10:42:07 +0200430 *maxVolume = maxVol;
henrika4af73662017-10-11 13:16:17 +0200431 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000432}
433
Max Morin787eeed2016-06-23 10:42:07 +0200434int32_t AudioDeviceModuleImpl::MinSpeakerVolume(uint32_t* minVolume) const {
henrika4af73662017-10-11 13:16:17 +0200435 CHECKinitialized_();
436 uint32_t minVol = 0;
437 if (audio_device_->MinSpeakerVolume(minVol) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200438 return -1;
439 }
Max Morin787eeed2016-06-23 10:42:07 +0200440 *minVolume = minVol;
henrika4af73662017-10-11 13:16:17 +0200441 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000442}
443
Max Morin787eeed2016-06-23 10:42:07 +0200444int32_t AudioDeviceModuleImpl::SpeakerMuteIsAvailable(bool* available) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100445 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200446 CHECKinitialized_();
Mirko Bonadei72c42502017-11-09 09:33:23 +0100447 bool isAvailable = false;
henrika4af73662017-10-11 13:16:17 +0200448 if (audio_device_->SpeakerMuteIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200449 return -1;
450 }
Max Morin787eeed2016-06-23 10:42:07 +0200451 *available = isAvailable;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100452 RTC_LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200453 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000454}
455
Max Morin787eeed2016-06-23 10:42:07 +0200456int32_t AudioDeviceModuleImpl::SetSpeakerMute(bool enable) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100457 RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200458 CHECKinitialized_();
459 return audio_device_->SetSpeakerMute(enable);
niklase@google.com470e71d2011-07-07 08:21:25 +0000460}
461
Max Morin787eeed2016-06-23 10:42:07 +0200462int32_t AudioDeviceModuleImpl::SpeakerMute(bool* enabled) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100463 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200464 CHECKinitialized_();
465 bool muted = false;
466 if (audio_device_->SpeakerMute(muted) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200467 return -1;
468 }
Max Morin787eeed2016-06-23 10:42:07 +0200469 *enabled = muted;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100470 RTC_LOG(INFO) << "output: " << muted;
henrika4af73662017-10-11 13:16:17 +0200471 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000472}
473
Max Morin787eeed2016-06-23 10:42:07 +0200474int32_t AudioDeviceModuleImpl::MicrophoneMuteIsAvailable(bool* available) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100475 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200476 CHECKinitialized_();
477 bool isAvailable = false;
478 if (audio_device_->MicrophoneMuteIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200479 return -1;
480 }
Max Morin787eeed2016-06-23 10:42:07 +0200481 *available = isAvailable;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100482 RTC_LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200483 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000484}
485
Max Morin787eeed2016-06-23 10:42:07 +0200486int32_t AudioDeviceModuleImpl::SetMicrophoneMute(bool enable) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100487 RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200488 CHECKinitialized_();
489 return (audio_device_->SetMicrophoneMute(enable));
niklase@google.com470e71d2011-07-07 08:21:25 +0000490}
491
Max Morin787eeed2016-06-23 10:42:07 +0200492int32_t AudioDeviceModuleImpl::MicrophoneMute(bool* enabled) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100493 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200494 CHECKinitialized_();
495 bool muted = false;
496 if (audio_device_->MicrophoneMute(muted) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200497 return -1;
498 }
Max Morin787eeed2016-06-23 10:42:07 +0200499 *enabled = muted;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100500 RTC_LOG(INFO) << "output: " << muted;
henrika4af73662017-10-11 13:16:17 +0200501 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000502}
503
Max Morin787eeed2016-06-23 10:42:07 +0200504int32_t AudioDeviceModuleImpl::MicrophoneVolumeIsAvailable(bool* available) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100505 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200506 CHECKinitialized_();
507 bool isAvailable = false;
508 if (audio_device_->MicrophoneVolumeIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200509 return -1;
510 }
Max Morin787eeed2016-06-23 10:42:07 +0200511 *available = isAvailable;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100512 RTC_LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200513 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000514}
515
Max Morin787eeed2016-06-23 10:42:07 +0200516int32_t AudioDeviceModuleImpl::SetMicrophoneVolume(uint32_t volume) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100517 RTC_LOG(INFO) << __FUNCTION__ << "(" << volume << ")";
henrika4af73662017-10-11 13:16:17 +0200518 CHECKinitialized_();
519 return (audio_device_->SetMicrophoneVolume(volume));
niklase@google.com470e71d2011-07-07 08:21:25 +0000520}
521
Max Morin787eeed2016-06-23 10:42:07 +0200522int32_t AudioDeviceModuleImpl::MicrophoneVolume(uint32_t* volume) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100523 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200524 CHECKinitialized_();
525 uint32_t level = 0;
526 if (audio_device_->MicrophoneVolume(level) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200527 return -1;
528 }
Max Morin787eeed2016-06-23 10:42:07 +0200529 *volume = level;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100530 RTC_LOG(INFO) << "output: " << *volume;
henrika4af73662017-10-11 13:16:17 +0200531 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000532}
533
Max Morin787eeed2016-06-23 10:42:07 +0200534int32_t AudioDeviceModuleImpl::StereoRecordingIsAvailable(
535 bool* available) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100536 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200537 CHECKinitialized_();
538 bool isAvailable = false;
539 if (audio_device_->StereoRecordingIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200540 return -1;
541 }
Max Morin787eeed2016-06-23 10:42:07 +0200542 *available = isAvailable;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100543 RTC_LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200544 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000545}
546
Max Morin787eeed2016-06-23 10:42:07 +0200547int32_t AudioDeviceModuleImpl::SetStereoRecording(bool enable) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100548 RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200549 CHECKinitialized_();
550 if (audio_device_->RecordingIsInitialized()) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100551 RTC_LOG(WARNING) << "recording in stereo is not supported";
Max Morin787eeed2016-06-23 10:42:07 +0200552 return -1;
553 }
henrika4af73662017-10-11 13:16:17 +0200554 if (audio_device_->SetStereoRecording(enable) == -1) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100555 RTC_LOG(WARNING) << "failed to change stereo recording";
Max Morin787eeed2016-06-23 10:42:07 +0200556 return -1;
557 }
Max Morin787eeed2016-06-23 10:42:07 +0200558 int8_t nChannels(1);
559 if (enable) {
560 nChannels = 2;
561 }
henrika4af73662017-10-11 13:16:17 +0200562 audio_device_buffer_.SetRecordingChannels(nChannels);
Max Morin787eeed2016-06-23 10:42:07 +0200563 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000564}
565
Max Morin787eeed2016-06-23 10:42:07 +0200566int32_t AudioDeviceModuleImpl::StereoRecording(bool* enabled) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100567 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200568 CHECKinitialized_();
569 bool stereo = false;
570 if (audio_device_->StereoRecording(stereo) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200571 return -1;
572 }
Max Morin787eeed2016-06-23 10:42:07 +0200573 *enabled = stereo;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100574 RTC_LOG(INFO) << "output: " << stereo;
henrika4af73662017-10-11 13:16:17 +0200575 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000576}
577
Max Morin787eeed2016-06-23 10:42:07 +0200578int32_t AudioDeviceModuleImpl::StereoPlayoutIsAvailable(bool* available) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100579 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200580 CHECKinitialized_();
581 bool isAvailable = false;
582 if (audio_device_->StereoPlayoutIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200583 return -1;
584 }
Max Morin787eeed2016-06-23 10:42:07 +0200585 *available = isAvailable;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100586 RTC_LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200587 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000588}
589
Max Morin787eeed2016-06-23 10:42:07 +0200590int32_t AudioDeviceModuleImpl::SetStereoPlayout(bool enable) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100591 RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200592 CHECKinitialized_();
593 if (audio_device_->PlayoutIsInitialized()) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100594 RTC_LOG(LERROR)
Max Morin098e6c52016-06-28 09:36:25 +0200595 << "unable to set stereo mode while playing side is initialized";
Max Morin787eeed2016-06-23 10:42:07 +0200596 return -1;
597 }
henrika4af73662017-10-11 13:16:17 +0200598 if (audio_device_->SetStereoPlayout(enable)) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100599 RTC_LOG(WARNING) << "stereo playout is not supported";
Max Morin787eeed2016-06-23 10:42:07 +0200600 return -1;
601 }
Max Morin787eeed2016-06-23 10:42:07 +0200602 int8_t nChannels(1);
603 if (enable) {
604 nChannels = 2;
605 }
henrika4af73662017-10-11 13:16:17 +0200606 audio_device_buffer_.SetPlayoutChannels(nChannels);
Max Morin787eeed2016-06-23 10:42:07 +0200607 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000608}
609
Max Morin787eeed2016-06-23 10:42:07 +0200610int32_t AudioDeviceModuleImpl::StereoPlayout(bool* enabled) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100611 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200612 CHECKinitialized_();
613 bool stereo = false;
614 if (audio_device_->StereoPlayout(stereo) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200615 return -1;
616 }
Max Morin787eeed2016-06-23 10:42:07 +0200617 *enabled = stereo;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100618 RTC_LOG(INFO) << "output: " << stereo;
henrika4af73662017-10-11 13:16:17 +0200619 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000620}
621
Max Morin787eeed2016-06-23 10:42:07 +0200622int32_t AudioDeviceModuleImpl::PlayoutIsAvailable(bool* available) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100623 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200624 CHECKinitialized_();
625 bool isAvailable = false;
626 if (audio_device_->PlayoutIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200627 return -1;
628 }
Max Morin787eeed2016-06-23 10:42:07 +0200629 *available = isAvailable;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100630 RTC_LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200631 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000632}
633
Max Morin787eeed2016-06-23 10:42:07 +0200634int32_t AudioDeviceModuleImpl::RecordingIsAvailable(bool* available) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100635 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200636 CHECKinitialized_();
637 bool isAvailable = false;
638 if (audio_device_->RecordingIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200639 return -1;
640 }
Max Morin787eeed2016-06-23 10:42:07 +0200641 *available = isAvailable;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100642 RTC_LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200643 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000644}
645
Max Morin787eeed2016-06-23 10:42:07 +0200646int32_t AudioDeviceModuleImpl::MaxMicrophoneVolume(uint32_t* maxVolume) const {
henrika4af73662017-10-11 13:16:17 +0200647 CHECKinitialized_();
Max Morin787eeed2016-06-23 10:42:07 +0200648 uint32_t maxVol(0);
henrika4af73662017-10-11 13:16:17 +0200649 if (audio_device_->MaxMicrophoneVolume(maxVol) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200650 return -1;
651 }
Max Morin787eeed2016-06-23 10:42:07 +0200652 *maxVolume = maxVol;
henrika4af73662017-10-11 13:16:17 +0200653 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000654}
655
Max Morin787eeed2016-06-23 10:42:07 +0200656int32_t AudioDeviceModuleImpl::MinMicrophoneVolume(uint32_t* minVolume) const {
henrika4af73662017-10-11 13:16:17 +0200657 CHECKinitialized_();
Max Morin787eeed2016-06-23 10:42:07 +0200658 uint32_t minVol(0);
henrika4af73662017-10-11 13:16:17 +0200659 if (audio_device_->MinMicrophoneVolume(minVol) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200660 return -1;
661 }
Max Morin787eeed2016-06-23 10:42:07 +0200662 *minVolume = minVol;
henrika4af73662017-10-11 13:16:17 +0200663 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000664}
665
Max Morin787eeed2016-06-23 10:42:07 +0200666int16_t AudioDeviceModuleImpl::PlayoutDevices() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100667 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200668 CHECKinitialized_();
669 uint16_t nPlayoutDevices = audio_device_->PlayoutDevices();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100670 RTC_LOG(INFO) << "output: " << nPlayoutDevices;
henrika4af73662017-10-11 13:16:17 +0200671 return (int16_t)(nPlayoutDevices);
niklase@google.com470e71d2011-07-07 08:21:25 +0000672}
673
Max Morin787eeed2016-06-23 10:42:07 +0200674int32_t AudioDeviceModuleImpl::SetPlayoutDevice(uint16_t index) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100675 RTC_LOG(INFO) << __FUNCTION__ << "(" << index << ")";
henrika4af73662017-10-11 13:16:17 +0200676 CHECKinitialized_();
677 return audio_device_->SetPlayoutDevice(index);
niklase@google.com470e71d2011-07-07 08:21:25 +0000678}
679
Max Morin787eeed2016-06-23 10:42:07 +0200680int32_t AudioDeviceModuleImpl::SetPlayoutDevice(WindowsDeviceType device) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100681 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200682 CHECKinitialized_();
683 return audio_device_->SetPlayoutDevice(device);
niklase@google.com470e71d2011-07-07 08:21:25 +0000684}
685
pbos@webrtc.org25509882013-04-09 10:30:35 +0000686int32_t AudioDeviceModuleImpl::PlayoutDeviceName(
687 uint16_t index,
leozwang@webrtc.org28f39132012-03-01 18:01:48 +0000688 char name[kAdmMaxDeviceNameSize],
Max Morin787eeed2016-06-23 10:42:07 +0200689 char guid[kAdmMaxGuidSize]) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100690 RTC_LOG(INFO) << __FUNCTION__ << "(" << index << ", ...)";
henrika4af73662017-10-11 13:16:17 +0200691 CHECKinitialized_();
Max Morin787eeed2016-06-23 10:42:07 +0200692 if (name == NULL) {
Max Morin787eeed2016-06-23 10:42:07 +0200693 return -1;
694 }
henrika4af73662017-10-11 13:16:17 +0200695 if (audio_device_->PlayoutDeviceName(index, name, guid) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200696 return -1;
697 }
Max Morin787eeed2016-06-23 10:42:07 +0200698 if (name != NULL) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100699 RTC_LOG(INFO) << "output: name = " << name;
Max Morin787eeed2016-06-23 10:42:07 +0200700 }
701 if (guid != NULL) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100702 RTC_LOG(INFO) << "output: guid = " << guid;
Max Morin787eeed2016-06-23 10:42:07 +0200703 }
henrika4af73662017-10-11 13:16:17 +0200704 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000705}
706
pbos@webrtc.org25509882013-04-09 10:30:35 +0000707int32_t AudioDeviceModuleImpl::RecordingDeviceName(
708 uint16_t index,
leozwang@webrtc.org28f39132012-03-01 18:01:48 +0000709 char name[kAdmMaxDeviceNameSize],
Max Morin787eeed2016-06-23 10:42:07 +0200710 char guid[kAdmMaxGuidSize]) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100711 RTC_LOG(INFO) << __FUNCTION__ << "(" << index << ", ...)";
henrika4af73662017-10-11 13:16:17 +0200712 CHECKinitialized_();
Max Morin787eeed2016-06-23 10:42:07 +0200713 if (name == NULL) {
Max Morin787eeed2016-06-23 10:42:07 +0200714 return -1;
715 }
henrika4af73662017-10-11 13:16:17 +0200716 if (audio_device_->RecordingDeviceName(index, name, guid) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200717 return -1;
718 }
Max Morin787eeed2016-06-23 10:42:07 +0200719 if (name != NULL) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100720 RTC_LOG(INFO) << "output: name = " << name;
Max Morin787eeed2016-06-23 10:42:07 +0200721 }
722 if (guid != NULL) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100723 RTC_LOG(INFO) << "output: guid = " << guid;
Max Morin787eeed2016-06-23 10:42:07 +0200724 }
henrika4af73662017-10-11 13:16:17 +0200725 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000726}
727
Max Morin787eeed2016-06-23 10:42:07 +0200728int16_t AudioDeviceModuleImpl::RecordingDevices() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100729 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200730 CHECKinitialized_();
731 uint16_t nRecordingDevices = audio_device_->RecordingDevices();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100732 RTC_LOG(INFO) << "output: " << nRecordingDevices;
henrika4af73662017-10-11 13:16:17 +0200733 return (int16_t)nRecordingDevices;
niklase@google.com470e71d2011-07-07 08:21:25 +0000734}
735
Max Morin787eeed2016-06-23 10:42:07 +0200736int32_t AudioDeviceModuleImpl::SetRecordingDevice(uint16_t index) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100737 RTC_LOG(INFO) << __FUNCTION__ << "(" << index << ")";
henrika4af73662017-10-11 13:16:17 +0200738 CHECKinitialized_();
739 return audio_device_->SetRecordingDevice(index);
niklase@google.com470e71d2011-07-07 08:21:25 +0000740}
741
Max Morin787eeed2016-06-23 10:42:07 +0200742int32_t AudioDeviceModuleImpl::SetRecordingDevice(WindowsDeviceType device) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100743 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200744 CHECKinitialized_();
745 return audio_device_->SetRecordingDevice(device);
niklase@google.com470e71d2011-07-07 08:21:25 +0000746}
747
Max Morin787eeed2016-06-23 10:42:07 +0200748int32_t AudioDeviceModuleImpl::InitPlayout() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100749 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200750 CHECKinitialized_();
maxmorin8c695b42016-07-25 02:46:44 -0700751 if (PlayoutIsInitialized()) {
752 return 0;
753 }
henrika4af73662017-10-11 13:16:17 +0200754 int32_t result = audio_device_->InitPlayout();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100755 RTC_LOG(INFO) << "output: " << result;
Max Morin84cab202016-07-01 13:35:19 +0200756 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.InitPlayoutSuccess",
757 static_cast<int>(result == 0));
758 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000759}
760
Max Morin787eeed2016-06-23 10:42:07 +0200761int32_t AudioDeviceModuleImpl::InitRecording() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100762 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200763 CHECKinitialized_();
maxmorin8c695b42016-07-25 02:46:44 -0700764 if (RecordingIsInitialized()) {
765 return 0;
766 }
henrika4af73662017-10-11 13:16:17 +0200767 int32_t result = audio_device_->InitRecording();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100768 RTC_LOG(INFO) << "output: " << result;
Max Morin84cab202016-07-01 13:35:19 +0200769 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.InitRecordingSuccess",
770 static_cast<int>(result == 0));
771 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000772}
773
Max Morin787eeed2016-06-23 10:42:07 +0200774bool AudioDeviceModuleImpl::PlayoutIsInitialized() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100775 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200776 CHECKinitialized__BOOL();
777 return audio_device_->PlayoutIsInitialized();
niklase@google.com470e71d2011-07-07 08:21:25 +0000778}
779
Max Morin787eeed2016-06-23 10:42:07 +0200780bool AudioDeviceModuleImpl::RecordingIsInitialized() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100781 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200782 CHECKinitialized__BOOL();
783 return audio_device_->RecordingIsInitialized();
niklase@google.com470e71d2011-07-07 08:21:25 +0000784}
785
Max Morin787eeed2016-06-23 10:42:07 +0200786int32_t AudioDeviceModuleImpl::StartPlayout() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100787 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200788 CHECKinitialized_();
maxmorin8c695b42016-07-25 02:46:44 -0700789 if (Playing()) {
790 return 0;
791 }
henrika4af73662017-10-11 13:16:17 +0200792 audio_device_buffer_.StartPlayout();
793 int32_t result = audio_device_->StartPlayout();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100794 RTC_LOG(INFO) << "output: " << result;
Max Morin84cab202016-07-01 13:35:19 +0200795 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StartPlayoutSuccess",
796 static_cast<int>(result == 0));
797 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000798}
799
Max Morin787eeed2016-06-23 10:42:07 +0200800int32_t AudioDeviceModuleImpl::StopPlayout() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100801 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200802 CHECKinitialized_();
803 int32_t result = audio_device_->StopPlayout();
804 audio_device_buffer_.StopPlayout();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100805 RTC_LOG(INFO) << "output: " << result;
Max Morin84cab202016-07-01 13:35:19 +0200806 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StopPlayoutSuccess",
807 static_cast<int>(result == 0));
808 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000809}
810
Max Morin787eeed2016-06-23 10:42:07 +0200811bool AudioDeviceModuleImpl::Playing() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100812 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200813 CHECKinitialized__BOOL();
814 return audio_device_->Playing();
niklase@google.com470e71d2011-07-07 08:21:25 +0000815}
816
Max Morin787eeed2016-06-23 10:42:07 +0200817int32_t AudioDeviceModuleImpl::StartRecording() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100818 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200819 CHECKinitialized_();
maxmorin8c695b42016-07-25 02:46:44 -0700820 if (Recording()) {
821 return 0;
822 }
henrika4af73662017-10-11 13:16:17 +0200823 audio_device_buffer_.StartRecording();
824 int32_t result = audio_device_->StartRecording();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100825 RTC_LOG(INFO) << "output: " << result;
Max Morin84cab202016-07-01 13:35:19 +0200826 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StartRecordingSuccess",
827 static_cast<int>(result == 0));
828 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000829}
niklase@google.com470e71d2011-07-07 08:21:25 +0000830
Max Morin787eeed2016-06-23 10:42:07 +0200831int32_t AudioDeviceModuleImpl::StopRecording() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100832 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200833 CHECKinitialized_();
834 int32_t result = audio_device_->StopRecording();
835 audio_device_buffer_.StopRecording();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100836 RTC_LOG(INFO) << "output: " << result;
Max Morin84cab202016-07-01 13:35:19 +0200837 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StopRecordingSuccess",
838 static_cast<int>(result == 0));
839 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000840}
841
Max Morin787eeed2016-06-23 10:42:07 +0200842bool AudioDeviceModuleImpl::Recording() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100843 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200844 CHECKinitialized__BOOL();
845 return audio_device_->Recording();
niklase@google.com470e71d2011-07-07 08:21:25 +0000846}
847
Max Morin787eeed2016-06-23 10:42:07 +0200848int32_t AudioDeviceModuleImpl::RegisterAudioCallback(
849 AudioTransport* audioCallback) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100850 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200851 return audio_device_buffer_.RegisterAudioCallback(audioCallback);
niklase@google.com470e71d2011-07-07 08:21:25 +0000852}
853
Max Morin787eeed2016-06-23 10:42:07 +0200854int32_t AudioDeviceModuleImpl::PlayoutDelay(uint16_t* delayMS) const {
henrika4af73662017-10-11 13:16:17 +0200855 CHECKinitialized_();
856 uint16_t delay = 0;
857 if (audio_device_->PlayoutDelay(delay) == -1) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100858 RTC_LOG(LERROR) << "failed to retrieve the playout delay";
Max Morin787eeed2016-06-23 10:42:07 +0200859 return -1;
860 }
Max Morin787eeed2016-06-23 10:42:07 +0200861 *delayMS = delay;
henrika4af73662017-10-11 13:16:17 +0200862 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000863}
864
henrika@webrtc.orga954c072014-12-09 16:22:09 +0000865bool AudioDeviceModuleImpl::BuiltInAECIsAvailable() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100866 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200867 CHECKinitialized__BOOL();
868 bool isAvailable = audio_device_->BuiltInAECIsAvailable();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100869 RTC_LOG(INFO) << "output: " << isAvailable;
Max Morin098e6c52016-06-28 09:36:25 +0200870 return isAvailable;
henrika@webrtc.orga954c072014-12-09 16:22:09 +0000871}
872
henrikac14f5ff2015-09-23 14:08:33 +0200873int32_t AudioDeviceModuleImpl::EnableBuiltInAEC(bool enable) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100874 RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200875 CHECKinitialized_();
876 int32_t ok = audio_device_->EnableBuiltInAEC(enable);
Mirko Bonadei675513b2017-11-09 11:09:25 +0100877 RTC_LOG(INFO) << "output: " << ok;
Max Morin098e6c52016-06-28 09:36:25 +0200878 return ok;
henrikac14f5ff2015-09-23 14:08:33 +0200879}
880
881bool AudioDeviceModuleImpl::BuiltInAGCIsAvailable() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100882 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200883 CHECKinitialized__BOOL();
884 bool isAvailable = audio_device_->BuiltInAGCIsAvailable();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100885 RTC_LOG(INFO) << "output: " << isAvailable;
Max Morin098e6c52016-06-28 09:36:25 +0200886 return isAvailable;
henrikac14f5ff2015-09-23 14:08:33 +0200887}
888
889int32_t AudioDeviceModuleImpl::EnableBuiltInAGC(bool enable) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100890 RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200891 CHECKinitialized_();
892 int32_t ok = audio_device_->EnableBuiltInAGC(enable);
Mirko Bonadei675513b2017-11-09 11:09:25 +0100893 RTC_LOG(INFO) << "output: " << ok;
Max Morin098e6c52016-06-28 09:36:25 +0200894 return ok;
henrikac14f5ff2015-09-23 14:08:33 +0200895}
896
897bool AudioDeviceModuleImpl::BuiltInNSIsAvailable() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100898 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200899 CHECKinitialized__BOOL();
900 bool isAvailable = audio_device_->BuiltInNSIsAvailable();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100901 RTC_LOG(INFO) << "output: " << isAvailable;
Max Morin098e6c52016-06-28 09:36:25 +0200902 return isAvailable;
henrikac14f5ff2015-09-23 14:08:33 +0200903}
904
905int32_t AudioDeviceModuleImpl::EnableBuiltInNS(bool enable) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100906 RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200907 CHECKinitialized_();
908 int32_t ok = audio_device_->EnableBuiltInNS(enable);
Mirko Bonadei675513b2017-11-09 11:09:25 +0100909 RTC_LOG(INFO) << "output: " << ok;
Max Morin098e6c52016-06-28 09:36:25 +0200910 return ok;
henrikac14f5ff2015-09-23 14:08:33 +0200911}
912
maxmorin88e31a32016-08-16 00:56:09 -0700913#if defined(WEBRTC_IOS)
henrikaba35d052015-07-14 17:04:08 +0200914int AudioDeviceModuleImpl::GetPlayoutAudioParameters(
915 AudioParameters* params) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100916 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200917 int r = audio_device_->GetPlayoutAudioParameters(params);
Mirko Bonadei675513b2017-11-09 11:09:25 +0100918 RTC_LOG(INFO) << "output: " << r;
Max Morin098e6c52016-06-28 09:36:25 +0200919 return r;
henrikaba35d052015-07-14 17:04:08 +0200920}
921
922int AudioDeviceModuleImpl::GetRecordAudioParameters(
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_->GetRecordAudioParameters(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}
maxmorin88e31a32016-08-16 00:56:09 -0700929#endif // WEBRTC_IOS
henrikaba35d052015-07-14 17:04:08 +0200930
Max Morin787eeed2016-06-23 10:42:07 +0200931AudioDeviceModuleImpl::PlatformType AudioDeviceModuleImpl::Platform() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100932 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200933 return platform_type_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000934}
935
Max Morin787eeed2016-06-23 10:42:07 +0200936AudioDeviceModule::AudioLayer AudioDeviceModuleImpl::PlatformAudioLayer()
937 const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100938 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200939 return audio_layer_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000940}
941
942} // namespace webrtc