blob: c5f4332e5e9f0c78cc4f078b1635ea7118eddd4a [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()) {
Gustavo Garciaff98f4b2018-12-19 10:37:16 +0100551 RTC_LOG(LERROR)
552 << "unable to set stereo mode after recording is initialized";
Max Morin787eeed2016-06-23 10:42:07 +0200553 return -1;
554 }
henrika4af73662017-10-11 13:16:17 +0200555 if (audio_device_->SetStereoRecording(enable) == -1) {
Gustavo Garciaff98f4b2018-12-19 10:37:16 +0100556 if (enable) {
557 RTC_LOG(WARNING) << "failed to enable stereo recording";
558 }
Max Morin787eeed2016-06-23 10:42:07 +0200559 return -1;
560 }
Max Morin787eeed2016-06-23 10:42:07 +0200561 int8_t nChannels(1);
562 if (enable) {
563 nChannels = 2;
564 }
henrika4af73662017-10-11 13:16:17 +0200565 audio_device_buffer_.SetRecordingChannels(nChannels);
Max Morin787eeed2016-06-23 10:42:07 +0200566 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000567}
568
Max Morin787eeed2016-06-23 10:42:07 +0200569int32_t AudioDeviceModuleImpl::StereoRecording(bool* enabled) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100570 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200571 CHECKinitialized_();
572 bool stereo = false;
573 if (audio_device_->StereoRecording(stereo) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200574 return -1;
575 }
Max Morin787eeed2016-06-23 10:42:07 +0200576 *enabled = stereo;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100577 RTC_LOG(INFO) << "output: " << stereo;
henrika4af73662017-10-11 13:16:17 +0200578 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000579}
580
Max Morin787eeed2016-06-23 10:42:07 +0200581int32_t AudioDeviceModuleImpl::StereoPlayoutIsAvailable(bool* available) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100582 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200583 CHECKinitialized_();
584 bool isAvailable = false;
585 if (audio_device_->StereoPlayoutIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200586 return -1;
587 }
Max Morin787eeed2016-06-23 10:42:07 +0200588 *available = isAvailable;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100589 RTC_LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200590 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000591}
592
Max Morin787eeed2016-06-23 10:42:07 +0200593int32_t AudioDeviceModuleImpl::SetStereoPlayout(bool enable) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100594 RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200595 CHECKinitialized_();
596 if (audio_device_->PlayoutIsInitialized()) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100597 RTC_LOG(LERROR)
Max Morin098e6c52016-06-28 09:36:25 +0200598 << "unable to set stereo mode while playing side is initialized";
Max Morin787eeed2016-06-23 10:42:07 +0200599 return -1;
600 }
henrika4af73662017-10-11 13:16:17 +0200601 if (audio_device_->SetStereoPlayout(enable)) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100602 RTC_LOG(WARNING) << "stereo playout is not supported";
Max Morin787eeed2016-06-23 10:42:07 +0200603 return -1;
604 }
Max Morin787eeed2016-06-23 10:42:07 +0200605 int8_t nChannels(1);
606 if (enable) {
607 nChannels = 2;
608 }
henrika4af73662017-10-11 13:16:17 +0200609 audio_device_buffer_.SetPlayoutChannels(nChannels);
Max Morin787eeed2016-06-23 10:42:07 +0200610 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000611}
612
Max Morin787eeed2016-06-23 10:42:07 +0200613int32_t AudioDeviceModuleImpl::StereoPlayout(bool* enabled) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100614 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200615 CHECKinitialized_();
616 bool stereo = false;
617 if (audio_device_->StereoPlayout(stereo) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200618 return -1;
619 }
Max Morin787eeed2016-06-23 10:42:07 +0200620 *enabled = stereo;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100621 RTC_LOG(INFO) << "output: " << stereo;
henrika4af73662017-10-11 13:16:17 +0200622 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000623}
624
Max Morin787eeed2016-06-23 10:42:07 +0200625int32_t AudioDeviceModuleImpl::PlayoutIsAvailable(bool* available) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100626 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200627 CHECKinitialized_();
628 bool isAvailable = false;
629 if (audio_device_->PlayoutIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200630 return -1;
631 }
Max Morin787eeed2016-06-23 10:42:07 +0200632 *available = isAvailable;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100633 RTC_LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200634 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000635}
636
Max Morin787eeed2016-06-23 10:42:07 +0200637int32_t AudioDeviceModuleImpl::RecordingIsAvailable(bool* available) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100638 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200639 CHECKinitialized_();
640 bool isAvailable = false;
641 if (audio_device_->RecordingIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200642 return -1;
643 }
Max Morin787eeed2016-06-23 10:42:07 +0200644 *available = isAvailable;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100645 RTC_LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200646 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000647}
648
Max Morin787eeed2016-06-23 10:42:07 +0200649int32_t AudioDeviceModuleImpl::MaxMicrophoneVolume(uint32_t* maxVolume) const {
henrika4af73662017-10-11 13:16:17 +0200650 CHECKinitialized_();
Max Morin787eeed2016-06-23 10:42:07 +0200651 uint32_t maxVol(0);
henrika4af73662017-10-11 13:16:17 +0200652 if (audio_device_->MaxMicrophoneVolume(maxVol) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200653 return -1;
654 }
Max Morin787eeed2016-06-23 10:42:07 +0200655 *maxVolume = maxVol;
henrika4af73662017-10-11 13:16:17 +0200656 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000657}
658
Max Morin787eeed2016-06-23 10:42:07 +0200659int32_t AudioDeviceModuleImpl::MinMicrophoneVolume(uint32_t* minVolume) const {
henrika4af73662017-10-11 13:16:17 +0200660 CHECKinitialized_();
Max Morin787eeed2016-06-23 10:42:07 +0200661 uint32_t minVol(0);
henrika4af73662017-10-11 13:16:17 +0200662 if (audio_device_->MinMicrophoneVolume(minVol) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200663 return -1;
664 }
Max Morin787eeed2016-06-23 10:42:07 +0200665 *minVolume = minVol;
henrika4af73662017-10-11 13:16:17 +0200666 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000667}
668
Max Morin787eeed2016-06-23 10:42:07 +0200669int16_t AudioDeviceModuleImpl::PlayoutDevices() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100670 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200671 CHECKinitialized_();
672 uint16_t nPlayoutDevices = audio_device_->PlayoutDevices();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100673 RTC_LOG(INFO) << "output: " << nPlayoutDevices;
henrika4af73662017-10-11 13:16:17 +0200674 return (int16_t)(nPlayoutDevices);
niklase@google.com470e71d2011-07-07 08:21:25 +0000675}
676
Max Morin787eeed2016-06-23 10:42:07 +0200677int32_t AudioDeviceModuleImpl::SetPlayoutDevice(uint16_t index) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100678 RTC_LOG(INFO) << __FUNCTION__ << "(" << index << ")";
henrika4af73662017-10-11 13:16:17 +0200679 CHECKinitialized_();
680 return audio_device_->SetPlayoutDevice(index);
niklase@google.com470e71d2011-07-07 08:21:25 +0000681}
682
Max Morin787eeed2016-06-23 10:42:07 +0200683int32_t AudioDeviceModuleImpl::SetPlayoutDevice(WindowsDeviceType device) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100684 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200685 CHECKinitialized_();
686 return audio_device_->SetPlayoutDevice(device);
niklase@google.com470e71d2011-07-07 08:21:25 +0000687}
688
pbos@webrtc.org25509882013-04-09 10:30:35 +0000689int32_t AudioDeviceModuleImpl::PlayoutDeviceName(
690 uint16_t index,
leozwang@webrtc.org28f39132012-03-01 18:01:48 +0000691 char name[kAdmMaxDeviceNameSize],
Max Morin787eeed2016-06-23 10:42:07 +0200692 char guid[kAdmMaxGuidSize]) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100693 RTC_LOG(INFO) << __FUNCTION__ << "(" << index << ", ...)";
henrika4af73662017-10-11 13:16:17 +0200694 CHECKinitialized_();
Max Morin787eeed2016-06-23 10:42:07 +0200695 if (name == NULL) {
Max Morin787eeed2016-06-23 10:42:07 +0200696 return -1;
697 }
henrika4af73662017-10-11 13:16:17 +0200698 if (audio_device_->PlayoutDeviceName(index, name, guid) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200699 return -1;
700 }
Max Morin787eeed2016-06-23 10:42:07 +0200701 if (name != NULL) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100702 RTC_LOG(INFO) << "output: name = " << name;
Max Morin787eeed2016-06-23 10:42:07 +0200703 }
704 if (guid != NULL) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100705 RTC_LOG(INFO) << "output: guid = " << guid;
Max Morin787eeed2016-06-23 10:42:07 +0200706 }
henrika4af73662017-10-11 13:16:17 +0200707 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000708}
709
pbos@webrtc.org25509882013-04-09 10:30:35 +0000710int32_t AudioDeviceModuleImpl::RecordingDeviceName(
711 uint16_t index,
leozwang@webrtc.org28f39132012-03-01 18:01:48 +0000712 char name[kAdmMaxDeviceNameSize],
Max Morin787eeed2016-06-23 10:42:07 +0200713 char guid[kAdmMaxGuidSize]) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100714 RTC_LOG(INFO) << __FUNCTION__ << "(" << index << ", ...)";
henrika4af73662017-10-11 13:16:17 +0200715 CHECKinitialized_();
Max Morin787eeed2016-06-23 10:42:07 +0200716 if (name == NULL) {
Max Morin787eeed2016-06-23 10:42:07 +0200717 return -1;
718 }
henrika4af73662017-10-11 13:16:17 +0200719 if (audio_device_->RecordingDeviceName(index, name, guid) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200720 return -1;
721 }
Max Morin787eeed2016-06-23 10:42:07 +0200722 if (name != NULL) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100723 RTC_LOG(INFO) << "output: name = " << name;
Max Morin787eeed2016-06-23 10:42:07 +0200724 }
725 if (guid != NULL) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100726 RTC_LOG(INFO) << "output: guid = " << guid;
Max Morin787eeed2016-06-23 10:42:07 +0200727 }
henrika4af73662017-10-11 13:16:17 +0200728 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000729}
730
Max Morin787eeed2016-06-23 10:42:07 +0200731int16_t AudioDeviceModuleImpl::RecordingDevices() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100732 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200733 CHECKinitialized_();
734 uint16_t nRecordingDevices = audio_device_->RecordingDevices();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100735 RTC_LOG(INFO) << "output: " << nRecordingDevices;
henrika4af73662017-10-11 13:16:17 +0200736 return (int16_t)nRecordingDevices;
niklase@google.com470e71d2011-07-07 08:21:25 +0000737}
738
Max Morin787eeed2016-06-23 10:42:07 +0200739int32_t AudioDeviceModuleImpl::SetRecordingDevice(uint16_t index) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100740 RTC_LOG(INFO) << __FUNCTION__ << "(" << index << ")";
henrika4af73662017-10-11 13:16:17 +0200741 CHECKinitialized_();
742 return audio_device_->SetRecordingDevice(index);
niklase@google.com470e71d2011-07-07 08:21:25 +0000743}
744
Max Morin787eeed2016-06-23 10:42:07 +0200745int32_t AudioDeviceModuleImpl::SetRecordingDevice(WindowsDeviceType device) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100746 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200747 CHECKinitialized_();
748 return audio_device_->SetRecordingDevice(device);
niklase@google.com470e71d2011-07-07 08:21:25 +0000749}
750
Max Morin787eeed2016-06-23 10:42:07 +0200751int32_t AudioDeviceModuleImpl::InitPlayout() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100752 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200753 CHECKinitialized_();
maxmorin8c695b42016-07-25 02:46:44 -0700754 if (PlayoutIsInitialized()) {
755 return 0;
756 }
henrika4af73662017-10-11 13:16:17 +0200757 int32_t result = audio_device_->InitPlayout();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100758 RTC_LOG(INFO) << "output: " << result;
Max Morin84cab202016-07-01 13:35:19 +0200759 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.InitPlayoutSuccess",
760 static_cast<int>(result == 0));
761 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000762}
763
Max Morin787eeed2016-06-23 10:42:07 +0200764int32_t AudioDeviceModuleImpl::InitRecording() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100765 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200766 CHECKinitialized_();
maxmorin8c695b42016-07-25 02:46:44 -0700767 if (RecordingIsInitialized()) {
768 return 0;
769 }
henrika4af73662017-10-11 13:16:17 +0200770 int32_t result = audio_device_->InitRecording();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100771 RTC_LOG(INFO) << "output: " << result;
Max Morin84cab202016-07-01 13:35:19 +0200772 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.InitRecordingSuccess",
773 static_cast<int>(result == 0));
774 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000775}
776
Max Morin787eeed2016-06-23 10:42:07 +0200777bool AudioDeviceModuleImpl::PlayoutIsInitialized() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100778 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200779 CHECKinitialized__BOOL();
780 return audio_device_->PlayoutIsInitialized();
niklase@google.com470e71d2011-07-07 08:21:25 +0000781}
782
Max Morin787eeed2016-06-23 10:42:07 +0200783bool AudioDeviceModuleImpl::RecordingIsInitialized() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100784 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200785 CHECKinitialized__BOOL();
786 return audio_device_->RecordingIsInitialized();
niklase@google.com470e71d2011-07-07 08:21:25 +0000787}
788
Max Morin787eeed2016-06-23 10:42:07 +0200789int32_t AudioDeviceModuleImpl::StartPlayout() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100790 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200791 CHECKinitialized_();
maxmorin8c695b42016-07-25 02:46:44 -0700792 if (Playing()) {
793 return 0;
794 }
henrika4af73662017-10-11 13:16:17 +0200795 audio_device_buffer_.StartPlayout();
796 int32_t result = audio_device_->StartPlayout();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100797 RTC_LOG(INFO) << "output: " << result;
Max Morin84cab202016-07-01 13:35:19 +0200798 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StartPlayoutSuccess",
799 static_cast<int>(result == 0));
800 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000801}
802
Max Morin787eeed2016-06-23 10:42:07 +0200803int32_t AudioDeviceModuleImpl::StopPlayout() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100804 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200805 CHECKinitialized_();
806 int32_t result = audio_device_->StopPlayout();
807 audio_device_buffer_.StopPlayout();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100808 RTC_LOG(INFO) << "output: " << result;
Max Morin84cab202016-07-01 13:35:19 +0200809 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StopPlayoutSuccess",
810 static_cast<int>(result == 0));
811 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000812}
813
Max Morin787eeed2016-06-23 10:42:07 +0200814bool AudioDeviceModuleImpl::Playing() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100815 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200816 CHECKinitialized__BOOL();
817 return audio_device_->Playing();
niklase@google.com470e71d2011-07-07 08:21:25 +0000818}
819
Max Morin787eeed2016-06-23 10:42:07 +0200820int32_t AudioDeviceModuleImpl::StartRecording() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100821 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200822 CHECKinitialized_();
maxmorin8c695b42016-07-25 02:46:44 -0700823 if (Recording()) {
824 return 0;
825 }
henrika4af73662017-10-11 13:16:17 +0200826 audio_device_buffer_.StartRecording();
827 int32_t result = audio_device_->StartRecording();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100828 RTC_LOG(INFO) << "output: " << result;
Max Morin84cab202016-07-01 13:35:19 +0200829 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StartRecordingSuccess",
830 static_cast<int>(result == 0));
831 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000832}
niklase@google.com470e71d2011-07-07 08:21:25 +0000833
Max Morin787eeed2016-06-23 10:42:07 +0200834int32_t AudioDeviceModuleImpl::StopRecording() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100835 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200836 CHECKinitialized_();
837 int32_t result = audio_device_->StopRecording();
838 audio_device_buffer_.StopRecording();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100839 RTC_LOG(INFO) << "output: " << result;
Max Morin84cab202016-07-01 13:35:19 +0200840 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StopRecordingSuccess",
841 static_cast<int>(result == 0));
842 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000843}
844
Max Morin787eeed2016-06-23 10:42:07 +0200845bool AudioDeviceModuleImpl::Recording() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100846 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200847 CHECKinitialized__BOOL();
848 return audio_device_->Recording();
niklase@google.com470e71d2011-07-07 08:21:25 +0000849}
850
Max Morin787eeed2016-06-23 10:42:07 +0200851int32_t AudioDeviceModuleImpl::RegisterAudioCallback(
852 AudioTransport* audioCallback) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100853 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200854 return audio_device_buffer_.RegisterAudioCallback(audioCallback);
niklase@google.com470e71d2011-07-07 08:21:25 +0000855}
856
Max Morin787eeed2016-06-23 10:42:07 +0200857int32_t AudioDeviceModuleImpl::PlayoutDelay(uint16_t* delayMS) const {
henrika4af73662017-10-11 13:16:17 +0200858 CHECKinitialized_();
859 uint16_t delay = 0;
860 if (audio_device_->PlayoutDelay(delay) == -1) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100861 RTC_LOG(LERROR) << "failed to retrieve the playout delay";
Max Morin787eeed2016-06-23 10:42:07 +0200862 return -1;
863 }
Max Morin787eeed2016-06-23 10:42:07 +0200864 *delayMS = delay;
henrika4af73662017-10-11 13:16:17 +0200865 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000866}
867
henrika@webrtc.orga954c072014-12-09 16:22:09 +0000868bool AudioDeviceModuleImpl::BuiltInAECIsAvailable() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100869 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200870 CHECKinitialized__BOOL();
871 bool isAvailable = audio_device_->BuiltInAECIsAvailable();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100872 RTC_LOG(INFO) << "output: " << isAvailable;
Max Morin098e6c52016-06-28 09:36:25 +0200873 return isAvailable;
henrika@webrtc.orga954c072014-12-09 16:22:09 +0000874}
875
henrikac14f5ff2015-09-23 14:08:33 +0200876int32_t AudioDeviceModuleImpl::EnableBuiltInAEC(bool enable) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100877 RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200878 CHECKinitialized_();
879 int32_t ok = audio_device_->EnableBuiltInAEC(enable);
Mirko Bonadei675513b2017-11-09 11:09:25 +0100880 RTC_LOG(INFO) << "output: " << ok;
Max Morin098e6c52016-06-28 09:36:25 +0200881 return ok;
henrikac14f5ff2015-09-23 14:08:33 +0200882}
883
884bool AudioDeviceModuleImpl::BuiltInAGCIsAvailable() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100885 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200886 CHECKinitialized__BOOL();
887 bool isAvailable = audio_device_->BuiltInAGCIsAvailable();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100888 RTC_LOG(INFO) << "output: " << isAvailable;
Max Morin098e6c52016-06-28 09:36:25 +0200889 return isAvailable;
henrikac14f5ff2015-09-23 14:08:33 +0200890}
891
892int32_t AudioDeviceModuleImpl::EnableBuiltInAGC(bool enable) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100893 RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200894 CHECKinitialized_();
895 int32_t ok = audio_device_->EnableBuiltInAGC(enable);
Mirko Bonadei675513b2017-11-09 11:09:25 +0100896 RTC_LOG(INFO) << "output: " << ok;
Max Morin098e6c52016-06-28 09:36:25 +0200897 return ok;
henrikac14f5ff2015-09-23 14:08:33 +0200898}
899
900bool AudioDeviceModuleImpl::BuiltInNSIsAvailable() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100901 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200902 CHECKinitialized__BOOL();
903 bool isAvailable = audio_device_->BuiltInNSIsAvailable();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100904 RTC_LOG(INFO) << "output: " << isAvailable;
Max Morin098e6c52016-06-28 09:36:25 +0200905 return isAvailable;
henrikac14f5ff2015-09-23 14:08:33 +0200906}
907
908int32_t AudioDeviceModuleImpl::EnableBuiltInNS(bool enable) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100909 RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200910 CHECKinitialized_();
911 int32_t ok = audio_device_->EnableBuiltInNS(enable);
Mirko Bonadei675513b2017-11-09 11:09:25 +0100912 RTC_LOG(INFO) << "output: " << ok;
Max Morin098e6c52016-06-28 09:36:25 +0200913 return ok;
henrikac14f5ff2015-09-23 14:08:33 +0200914}
915
maxmorin88e31a32016-08-16 00:56:09 -0700916#if defined(WEBRTC_IOS)
henrikaba35d052015-07-14 17:04:08 +0200917int AudioDeviceModuleImpl::GetPlayoutAudioParameters(
918 AudioParameters* params) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100919 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200920 int r = audio_device_->GetPlayoutAudioParameters(params);
Mirko Bonadei675513b2017-11-09 11:09:25 +0100921 RTC_LOG(INFO) << "output: " << r;
Max Morin098e6c52016-06-28 09:36:25 +0200922 return r;
henrikaba35d052015-07-14 17:04:08 +0200923}
924
925int AudioDeviceModuleImpl::GetRecordAudioParameters(
926 AudioParameters* params) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100927 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200928 int r = audio_device_->GetRecordAudioParameters(params);
Mirko Bonadei675513b2017-11-09 11:09:25 +0100929 RTC_LOG(INFO) << "output: " << r;
Max Morin098e6c52016-06-28 09:36:25 +0200930 return r;
henrikaba35d052015-07-14 17:04:08 +0200931}
maxmorin88e31a32016-08-16 00:56:09 -0700932#endif // WEBRTC_IOS
henrikaba35d052015-07-14 17:04:08 +0200933
Max Morin787eeed2016-06-23 10:42:07 +0200934AudioDeviceModuleImpl::PlatformType AudioDeviceModuleImpl::Platform() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100935 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200936 return platform_type_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000937}
938
Max Morin787eeed2016-06-23 10:42:07 +0200939AudioDeviceModule::AudioLayer AudioDeviceModuleImpl::PlatformAudioLayer()
940 const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100941 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200942 return audio_layer_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000943}
944
945} // namespace webrtc