blob: e44a62db8a8f95749c7792cf8df5c4c2c87d58dc [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"
Steve Anton10542f22019-01-11 09:11:00 -080019#include "rtc_base/ref_counted_object.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
henrika5ff64832017-10-11 15:14:51 +0200115AudioDeviceModuleImpl::AudioDeviceModuleImpl(const AudioLayer audioLayer)
116 : audio_layer_(audioLayer) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100117 RTC_LOG(INFO) << __FUNCTION__;
niklase@google.com470e71d2011-07-07 08:21:25 +0000118}
119
Max Morin787eeed2016-06-23 10:42:07 +0200120int32_t AudioDeviceModuleImpl::CheckPlatform() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100121 RTC_LOG(INFO) << __FUNCTION__;
Max Morin787eeed2016-06-23 10:42:07 +0200122 // Ensure that the current platform is supported
Max Morin787eeed2016-06-23 10:42:07 +0200123 PlatformType platform(kPlatformNotSupported);
niklase@google.com470e71d2011-07-07 08:21:25 +0000124#if defined(_WIN32)
Max Morin787eeed2016-06-23 10:42:07 +0200125 platform = kPlatformWin32;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100126 RTC_LOG(INFO) << "current platform is Win32";
leozwang@google.com522f42b2011-09-19 17:39:05 +0000127#elif defined(WEBRTC_ANDROID)
Max Morin787eeed2016-06-23 10:42:07 +0200128 platform = kPlatformAndroid;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100129 RTC_LOG(INFO) << "current platform is Android";
niklase@google.com470e71d2011-07-07 08:21:25 +0000130#elif defined(WEBRTC_LINUX)
Max Morin787eeed2016-06-23 10:42:07 +0200131 platform = kPlatformLinux;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100132 RTC_LOG(INFO) << "current platform is Linux";
sjlee@webrtc.org414fa7f2012-09-11 17:25:46 +0000133#elif defined(WEBRTC_IOS)
Max Morin787eeed2016-06-23 10:42:07 +0200134 platform = kPlatformIOS;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100135 RTC_LOG(INFO) << "current platform is IOS";
andrew@webrtc.orgf3b65db2012-09-06 18:17:00 +0000136#elif defined(WEBRTC_MAC)
Max Morin787eeed2016-06-23 10:42:07 +0200137 platform = kPlatformMac;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100138 RTC_LOG(INFO) << "current platform is Mac";
niklase@google.com470e71d2011-07-07 08:21:25 +0000139#endif
Max Morin787eeed2016-06-23 10:42:07 +0200140 if (platform == kPlatformNotSupported) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100141 RTC_LOG(LERROR)
142 << "current platform is not supported => this module will self "
143 "destruct!";
Max Morin787eeed2016-06-23 10:42:07 +0200144 return -1;
145 }
henrika4af73662017-10-11 13:16:17 +0200146 platform_type_ = platform;
Max Morin787eeed2016-06-23 10:42:07 +0200147 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000148}
149
Max Morin787eeed2016-06-23 10:42:07 +0200150int32_t AudioDeviceModuleImpl::CreatePlatformSpecificObjects() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100151 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200152// Dummy ADM implementations if build flags are set.
xians@google.combf5d2ba2011-08-16 07:44:19 +0000153#if defined(WEBRTC_DUMMY_AUDIO_BUILD)
henrika5ff64832017-10-11 15:14:51 +0200154 audio_device_.reset(new AudioDeviceDummy());
Mirko Bonadei675513b2017-11-09 11:09:25 +0100155 RTC_LOG(INFO) << "Dummy Audio APIs will be utilized";
phoglund@webrtc.org8454ad12014-06-11 14:12:04 +0000156#elif defined(WEBRTC_DUMMY_FILE_DEVICES)
henrika5ff64832017-10-11 15:14:51 +0200157 audio_device_.reset(FileAudioDeviceFactory::CreateFileAudioDevice());
henrika4af73662017-10-11 13:16:17 +0200158 if (audio_device_) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100159 RTC_LOG(INFO) << "Will use file-playing dummy device.";
noahric6a355902016-08-17 15:19:50 -0700160 } else {
161 // Create a dummy device instead.
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";
noahric6a355902016-08-17 15:19:50 -0700164 }
henrika4af73662017-10-11 13:16:17 +0200165
166// Real (non-dummy) ADM implementations.
xians@google.combf5d2ba2011-08-16 07:44:19 +0000167#else
henrika4af73662017-10-11 13:16:17 +0200168 AudioLayer audio_layer(PlatformAudioLayer());
169// Windows ADM implementation.
niklase@google.com470e71d2011-07-07 08:21:25 +0000170#if defined(WEBRTC_WINDOWS_CORE_AUDIO_BUILD)
henrika4af73662017-10-11 13:16:17 +0200171 if ((audio_layer == kWindowsCoreAudio) ||
172 (audio_layer == kPlatformDefaultAudio)) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100173 RTC_LOG(INFO) << "Attempting to use the Windows Core Audio APIs...";
Max Morin787eeed2016-06-23 10:42:07 +0200174 if (AudioDeviceWindowsCore::CoreAudioIsSupported()) {
henrika4af73662017-10-11 13:16:17 +0200175 audio_device_.reset(new AudioDeviceWindowsCore());
Mirko Bonadei675513b2017-11-09 11:09:25 +0100176 RTC_LOG(INFO) << "Windows Core Audio APIs will be utilized";
niklase@google.com470e71d2011-07-07 08:21:25 +0000177 }
Max Morin787eeed2016-06-23 10:42:07 +0200178 }
179#endif // defined(WEBRTC_WINDOWS_CORE_AUDIO_BUILD)
niklase@google.com470e71d2011-07-07 08:21:25 +0000180
henrike@webrtc.org9ee75e92013-12-11 21:42:44 +0000181#if defined(WEBRTC_ANDROID)
Max Morin787eeed2016-06-23 10:42:07 +0200182 // Create an Android audio manager.
henrika4af73662017-10-11 13:16:17 +0200183 audio_manager_android_.reset(new AudioManager());
Max Morin787eeed2016-06-23 10:42:07 +0200184 // Select best possible combination of audio layers.
henrika4af73662017-10-11 13:16:17 +0200185 if (audio_layer == kPlatformDefaultAudio) {
henrika883d00f2018-03-16 10:09:49 +0100186 if (audio_manager_android_->IsAAudioSupported()) {
187 // Use of AAudio for both playout and recording has highest priority.
188 audio_layer = kAndroidAAudioAudio;
189 } else if (audio_manager_android_->IsLowLatencyPlayoutSupported() &&
190 audio_manager_android_->IsLowLatencyRecordSupported()) {
henrika918b5542016-09-19 15:44:09 +0200191 // Use OpenSL ES for both playout and recording.
henrika4af73662017-10-11 13:16:17 +0200192 audio_layer = kAndroidOpenSLESAudio;
193 } else if (audio_manager_android_->IsLowLatencyPlayoutSupported() &&
194 !audio_manager_android_->IsLowLatencyRecordSupported()) {
henrika918b5542016-09-19 15:44:09 +0200195 // Use OpenSL ES for output on devices that only supports the
Max Morin787eeed2016-06-23 10:42:07 +0200196 // low-latency output audio path.
henrika4af73662017-10-11 13:16:17 +0200197 audio_layer = kAndroidJavaInputAndOpenSLESOutputAudio;
henrikab2619892015-05-18 16:49:16 +0200198 } else {
henrika918b5542016-09-19 15:44:09 +0200199 // Use Java-based audio in both directions when low-latency output is
200 // not supported.
henrika4af73662017-10-11 13:16:17 +0200201 audio_layer = kAndroidJavaAudio;
niklase@google.com470e71d2011-07-07 08:21:25 +0000202 }
Max Morin787eeed2016-06-23 10:42:07 +0200203 }
henrika4af73662017-10-11 13:16:17 +0200204 AudioManager* audio_manager = audio_manager_android_.get();
205 if (audio_layer == kAndroidJavaAudio) {
Max Morin787eeed2016-06-23 10:42:07 +0200206 // Java audio for both input and output audio.
henrika4af73662017-10-11 13:16:17 +0200207 audio_device_.reset(new AudioDeviceTemplate<AudioRecordJni, AudioTrackJni>(
208 audio_layer, audio_manager));
209 } else if (audio_layer == kAndroidOpenSLESAudio) {
henrika918b5542016-09-19 15:44:09 +0200210 // OpenSL ES based audio for both input and output audio.
henrika4af73662017-10-11 13:16:17 +0200211 audio_device_.reset(
212 new AudioDeviceTemplate<OpenSLESRecorder, OpenSLESPlayer>(
213 audio_layer, audio_manager));
214 } else if (audio_layer == kAndroidJavaInputAndOpenSLESOutputAudio) {
Max Morin787eeed2016-06-23 10:42:07 +0200215 // Java audio for input and OpenSL ES for output audio (i.e. mixed APIs).
216 // This combination provides low-latency output audio and at the same
217 // time support for HW AEC using the AudioRecord Java API.
henrika4af73662017-10-11 13:16:17 +0200218 audio_device_.reset(new AudioDeviceTemplate<AudioRecordJni, OpenSLESPlayer>(
219 audio_layer, audio_manager));
henrika883d00f2018-03-16 10:09:49 +0100220 } else if (audio_layer == kAndroidAAudioAudio) {
221#if defined(AUDIO_DEVICE_INCLUDE_ANDROID_AAUDIO)
222 // AAudio based audio for both input and output.
223 audio_device_.reset(new AudioDeviceTemplate<AAudioRecorder, AAudioPlayer>(
224 audio_layer, audio_manager));
225#endif
226 } else if (audio_layer == kAndroidJavaInputAndAAudioOutputAudio) {
227#if defined(AUDIO_DEVICE_INCLUDE_ANDROID_AAUDIO)
228 // Java audio for input and AAudio for output audio (i.e. mixed APIs).
229 audio_device_.reset(new AudioDeviceTemplate<AudioRecordJni, AAudioPlayer>(
230 audio_layer, audio_manager));
231#endif
Max Morin787eeed2016-06-23 10:42:07 +0200232 } else {
henrika883d00f2018-03-16 10:09:49 +0100233 RTC_LOG(LS_ERROR) << "The requested audio layer is not supported";
henrika4af73662017-10-11 13:16:17 +0200234 audio_device_.reset(nullptr);
Max Morin787eeed2016-06-23 10:42:07 +0200235 }
236// END #if defined(WEBRTC_ANDROID)
niklase@google.com470e71d2011-07-07 08:21:25 +0000237
henrika4af73662017-10-11 13:16:17 +0200238// Linux ADM implementation.
henrika68435f52018-04-09 13:31:45 +0200239// Note that, LINUX_ALSA is always defined by default when WEBRTC_LINUX is
240// defined. LINUX_PULSE depends on the 'rtc_include_pulse_audio' build flag.
241// TODO(bugs.webrtc.org/9127): improve support and make it more clear that
242// PulseAudio is the default selection.
niklase@google.com470e71d2011-07-07 08:21:25 +0000243#elif defined(WEBRTC_LINUX)
henrika68435f52018-04-09 13:31:45 +0200244#if !defined(LINUX_PULSE)
245 // Build flag 'rtc_include_pulse_audio' is set to false. In this mode:
246 // - kPlatformDefaultAudio => ALSA, and
247 // - kLinuxAlsaAudio => ALSA, and
248 // - kLinuxPulseAudio => Invalid selection.
249 RTC_LOG(WARNING) << "PulseAudio is disabled using build flag.";
250 if ((audio_layer == kLinuxAlsaAudio) ||
henrika4af73662017-10-11 13:16:17 +0200251 (audio_layer == kPlatformDefaultAudio)) {
henrika4af73662017-10-11 13:16:17 +0200252 audio_device_.reset(new AudioDeviceLinuxALSA());
Mirko Bonadei675513b2017-11-09 11:09:25 +0100253 RTC_LOG(INFO) << "Linux ALSA APIs will be utilized.";
Max Morin787eeed2016-06-23 10:42:07 +0200254 }
henrika68435f52018-04-09 13:31:45 +0200255#else
256 // Build flag 'rtc_include_pulse_audio' is set to true (default). In this
257 // mode:
258 // - kPlatformDefaultAudio => PulseAudio, and
259 // - kLinuxPulseAudio => PulseAudio, and
260 // - kLinuxAlsaAudio => ALSA (supported but not default).
261 RTC_LOG(INFO) << "PulseAudio support is enabled.";
262 if ((audio_layer == kLinuxPulseAudio) ||
263 (audio_layer == kPlatformDefaultAudio)) {
264 // Linux PulseAudio implementation is default.
265 audio_device_.reset(new AudioDeviceLinuxPulse());
266 RTC_LOG(INFO) << "Linux PulseAudio APIs will be utilized";
267 } else if (audio_layer == kLinuxAlsaAudio) {
268 audio_device_.reset(new AudioDeviceLinuxALSA());
269 RTC_LOG(WARNING) << "Linux ALSA APIs will be utilized.";
270 }
271#endif // #if !defined(LINUX_PULSE)
niklase@google.com470e71d2011-07-07 08:21:25 +0000272#endif // #if defined(WEBRTC_LINUX)
273
henrika4af73662017-10-11 13:16:17 +0200274// iOS ADM implementation.
sjlee@webrtc.org414fa7f2012-09-11 17:25:46 +0000275#if defined(WEBRTC_IOS)
henrika4af73662017-10-11 13:16:17 +0200276 if (audio_layer == kPlatformDefaultAudio) {
277 audio_device_.reset(new AudioDeviceIOS());
Mirko Bonadei675513b2017-11-09 11:09:25 +0100278 RTC_LOG(INFO) << "iPhone Audio APIs will be utilized.";
Max Morin787eeed2016-06-23 10:42:07 +0200279 }
280// END #if defined(WEBRTC_IOS)
niklase@google.com470e71d2011-07-07 08:21:25 +0000281
henrika4af73662017-10-11 13:16:17 +0200282// Mac OS X ADM implementation.
andrew@webrtc.orgf3b65db2012-09-06 18:17:00 +0000283#elif defined(WEBRTC_MAC)
henrika4af73662017-10-11 13:16:17 +0200284 if (audio_layer == kPlatformDefaultAudio) {
285 audio_device_.reset(new AudioDeviceMac());
Mirko Bonadei675513b2017-11-09 11:09:25 +0100286 RTC_LOG(INFO) << "Mac OS X Audio APIs will be utilized.";
Max Morin787eeed2016-06-23 10:42:07 +0200287 }
andrew@webrtc.orgf3b65db2012-09-06 18:17:00 +0000288#endif // WEBRTC_MAC
niklase@google.com470e71d2011-07-07 08:21:25 +0000289
henrika4af73662017-10-11 13:16:17 +0200290 // Dummy ADM implementation.
291 if (audio_layer == kDummyAudio) {
henrika5ff64832017-10-11 15:14:51 +0200292 audio_device_.reset(new AudioDeviceDummy());
Mirko Bonadei675513b2017-11-09 11:09:25 +0100293 RTC_LOG(INFO) << "Dummy Audio APIs will be utilized.";
Max Morin787eeed2016-06-23 10:42:07 +0200294 }
xians@google.combf5d2ba2011-08-16 07:44:19 +0000295#endif // if defined(WEBRTC_DUMMY_AUDIO_BUILD)
niklase@google.com470e71d2011-07-07 08:21:25 +0000296
henrika4af73662017-10-11 13:16:17 +0200297 if (!audio_device_) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100298 RTC_LOG(LS_ERROR)
henrika4af73662017-10-11 13:16:17 +0200299 << "Failed to create the platform specific ADM implementation.";
Max Morin787eeed2016-06-23 10:42:07 +0200300 return -1;
301 }
Max Morin787eeed2016-06-23 10:42:07 +0200302 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000303}
304
Max Morin787eeed2016-06-23 10:42:07 +0200305int32_t AudioDeviceModuleImpl::AttachAudioBuffer() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100306 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200307 audio_device_->AttachAudioBuffer(&audio_device_buffer_);
Max Morin787eeed2016-06-23 10:42:07 +0200308 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000309}
310
Max Morin787eeed2016-06-23 10:42:07 +0200311AudioDeviceModuleImpl::~AudioDeviceModuleImpl() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100312 RTC_LOG(INFO) << __FUNCTION__;
niklase@google.com470e71d2011-07-07 08:21:25 +0000313}
314
henrikab2619892015-05-18 16:49:16 +0200315int32_t AudioDeviceModuleImpl::ActiveAudioLayer(AudioLayer* audioLayer) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100316 RTC_LOG(INFO) << __FUNCTION__;
henrikab2619892015-05-18 16:49:16 +0200317 AudioLayer activeAudio;
henrika4af73662017-10-11 13:16:17 +0200318 if (audio_device_->ActiveAudioLayer(activeAudio) == -1) {
henrikab2619892015-05-18 16:49:16 +0200319 return -1;
320 }
321 *audioLayer = activeAudio;
322 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000323}
324
Max Morin787eeed2016-06-23 10:42:07 +0200325int32_t AudioDeviceModuleImpl::Init() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100326 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200327 if (initialized_)
niklase@google.com470e71d2011-07-07 08:21:25 +0000328 return 0;
henrika4af73662017-10-11 13:16:17 +0200329 RTC_CHECK(audio_device_);
330 AudioDeviceGeneric::InitStatus status = audio_device_->Init();
Max Morin84cab202016-07-01 13:35:19 +0200331 RTC_HISTOGRAM_ENUMERATION(
332 "WebRTC.Audio.InitializationResult", static_cast<int>(status),
333 static_cast<int>(AudioDeviceGeneric::InitStatus::NUM_STATUSES));
334 if (status != AudioDeviceGeneric::InitStatus::OK) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100335 RTC_LOG(LS_ERROR) << "Audio device initialization failed.";
Max Morin787eeed2016-06-23 10:42:07 +0200336 return -1;
337 }
henrika4af73662017-10-11 13:16:17 +0200338 initialized_ = true;
Max Morin787eeed2016-06-23 10:42:07 +0200339 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000340}
341
Max Morin787eeed2016-06-23 10:42:07 +0200342int32_t AudioDeviceModuleImpl::Terminate() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100343 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200344 if (!initialized_)
niklase@google.com470e71d2011-07-07 08:21:25 +0000345 return 0;
henrika4af73662017-10-11 13:16:17 +0200346 if (audio_device_->Terminate() == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200347 return -1;
348 }
henrika4af73662017-10-11 13:16:17 +0200349 initialized_ = false;
Max Morin787eeed2016-06-23 10:42:07 +0200350 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000351}
352
Max Morin787eeed2016-06-23 10:42:07 +0200353bool AudioDeviceModuleImpl::Initialized() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100354 RTC_LOG(INFO) << __FUNCTION__ << ": " << initialized_;
henrika4af73662017-10-11 13:16:17 +0200355 return initialized_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000356}
357
Max Morin787eeed2016-06-23 10:42:07 +0200358int32_t AudioDeviceModuleImpl::InitSpeaker() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100359 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200360 CHECKinitialized_();
361 return audio_device_->InitSpeaker();
niklase@google.com470e71d2011-07-07 08:21:25 +0000362}
363
Max Morin787eeed2016-06-23 10:42:07 +0200364int32_t AudioDeviceModuleImpl::InitMicrophone() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100365 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200366 CHECKinitialized_();
367 return audio_device_->InitMicrophone();
niklase@google.com470e71d2011-07-07 08:21:25 +0000368}
369
Max Morin787eeed2016-06-23 10:42:07 +0200370int32_t AudioDeviceModuleImpl::SpeakerVolumeIsAvailable(bool* available) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100371 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200372 CHECKinitialized_();
373 bool isAvailable = false;
374 if (audio_device_->SpeakerVolumeIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200375 return -1;
376 }
Max Morin787eeed2016-06-23 10:42:07 +0200377 *available = isAvailable;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100378 RTC_LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200379 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000380}
381
Max Morin787eeed2016-06-23 10:42:07 +0200382int32_t AudioDeviceModuleImpl::SetSpeakerVolume(uint32_t volume) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100383 RTC_LOG(INFO) << __FUNCTION__ << "(" << volume << ")";
henrika4af73662017-10-11 13:16:17 +0200384 CHECKinitialized_();
385 return audio_device_->SetSpeakerVolume(volume);
niklase@google.com470e71d2011-07-07 08:21:25 +0000386}
387
Max Morin787eeed2016-06-23 10:42:07 +0200388int32_t AudioDeviceModuleImpl::SpeakerVolume(uint32_t* volume) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100389 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200390 CHECKinitialized_();
391 uint32_t level = 0;
392 if (audio_device_->SpeakerVolume(level) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200393 return -1;
394 }
Max Morin787eeed2016-06-23 10:42:07 +0200395 *volume = level;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100396 RTC_LOG(INFO) << "output: " << *volume;
henrika4af73662017-10-11 13:16:17 +0200397 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000398}
399
Max Morin787eeed2016-06-23 10:42:07 +0200400bool AudioDeviceModuleImpl::SpeakerIsInitialized() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100401 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200402 CHECKinitialized__BOOL();
403 bool isInitialized = audio_device_->SpeakerIsInitialized();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100404 RTC_LOG(INFO) << "output: " << isInitialized;
henrika4af73662017-10-11 13:16:17 +0200405 return isInitialized;
niklase@google.com470e71d2011-07-07 08:21:25 +0000406}
407
Max Morin787eeed2016-06-23 10:42:07 +0200408bool AudioDeviceModuleImpl::MicrophoneIsInitialized() 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_->MicrophoneIsInitialized();
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 +0200416int32_t AudioDeviceModuleImpl::MaxSpeakerVolume(uint32_t* maxVolume) const {
henrika4af73662017-10-11 13:16:17 +0200417 CHECKinitialized_();
418 uint32_t maxVol = 0;
419 if (audio_device_->MaxSpeakerVolume(maxVol) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200420 return -1;
421 }
Max Morin787eeed2016-06-23 10:42:07 +0200422 *maxVolume = maxVol;
henrika4af73662017-10-11 13:16:17 +0200423 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000424}
425
Max Morin787eeed2016-06-23 10:42:07 +0200426int32_t AudioDeviceModuleImpl::MinSpeakerVolume(uint32_t* minVolume) const {
henrika4af73662017-10-11 13:16:17 +0200427 CHECKinitialized_();
428 uint32_t minVol = 0;
429 if (audio_device_->MinSpeakerVolume(minVol) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200430 return -1;
431 }
Max Morin787eeed2016-06-23 10:42:07 +0200432 *minVolume = minVol;
henrika4af73662017-10-11 13:16:17 +0200433 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000434}
435
Max Morin787eeed2016-06-23 10:42:07 +0200436int32_t AudioDeviceModuleImpl::SpeakerMuteIsAvailable(bool* available) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100437 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200438 CHECKinitialized_();
Mirko Bonadei72c42502017-11-09 09:33:23 +0100439 bool isAvailable = false;
henrika4af73662017-10-11 13:16:17 +0200440 if (audio_device_->SpeakerMuteIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200441 return -1;
442 }
Max Morin787eeed2016-06-23 10:42:07 +0200443 *available = isAvailable;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100444 RTC_LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200445 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000446}
447
Max Morin787eeed2016-06-23 10:42:07 +0200448int32_t AudioDeviceModuleImpl::SetSpeakerMute(bool enable) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100449 RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200450 CHECKinitialized_();
451 return audio_device_->SetSpeakerMute(enable);
niklase@google.com470e71d2011-07-07 08:21:25 +0000452}
453
Max Morin787eeed2016-06-23 10:42:07 +0200454int32_t AudioDeviceModuleImpl::SpeakerMute(bool* enabled) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100455 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200456 CHECKinitialized_();
457 bool muted = false;
458 if (audio_device_->SpeakerMute(muted) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200459 return -1;
460 }
Max Morin787eeed2016-06-23 10:42:07 +0200461 *enabled = muted;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100462 RTC_LOG(INFO) << "output: " << muted;
henrika4af73662017-10-11 13:16:17 +0200463 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000464}
465
Max Morin787eeed2016-06-23 10:42:07 +0200466int32_t AudioDeviceModuleImpl::MicrophoneMuteIsAvailable(bool* available) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100467 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200468 CHECKinitialized_();
469 bool isAvailable = false;
470 if (audio_device_->MicrophoneMuteIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200471 return -1;
472 }
Max Morin787eeed2016-06-23 10:42:07 +0200473 *available = isAvailable;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100474 RTC_LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200475 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000476}
477
Max Morin787eeed2016-06-23 10:42:07 +0200478int32_t AudioDeviceModuleImpl::SetMicrophoneMute(bool enable) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100479 RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200480 CHECKinitialized_();
481 return (audio_device_->SetMicrophoneMute(enable));
niklase@google.com470e71d2011-07-07 08:21:25 +0000482}
483
Max Morin787eeed2016-06-23 10:42:07 +0200484int32_t AudioDeviceModuleImpl::MicrophoneMute(bool* enabled) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100485 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200486 CHECKinitialized_();
487 bool muted = false;
488 if (audio_device_->MicrophoneMute(muted) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200489 return -1;
490 }
Max Morin787eeed2016-06-23 10:42:07 +0200491 *enabled = muted;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100492 RTC_LOG(INFO) << "output: " << muted;
henrika4af73662017-10-11 13:16:17 +0200493 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000494}
495
Max Morin787eeed2016-06-23 10:42:07 +0200496int32_t AudioDeviceModuleImpl::MicrophoneVolumeIsAvailable(bool* available) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100497 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200498 CHECKinitialized_();
499 bool isAvailable = false;
500 if (audio_device_->MicrophoneVolumeIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200501 return -1;
502 }
Max Morin787eeed2016-06-23 10:42:07 +0200503 *available = isAvailable;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100504 RTC_LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200505 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000506}
507
Max Morin787eeed2016-06-23 10:42:07 +0200508int32_t AudioDeviceModuleImpl::SetMicrophoneVolume(uint32_t volume) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100509 RTC_LOG(INFO) << __FUNCTION__ << "(" << volume << ")";
henrika4af73662017-10-11 13:16:17 +0200510 CHECKinitialized_();
511 return (audio_device_->SetMicrophoneVolume(volume));
niklase@google.com470e71d2011-07-07 08:21:25 +0000512}
513
Max Morin787eeed2016-06-23 10:42:07 +0200514int32_t AudioDeviceModuleImpl::MicrophoneVolume(uint32_t* volume) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100515 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200516 CHECKinitialized_();
517 uint32_t level = 0;
518 if (audio_device_->MicrophoneVolume(level) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200519 return -1;
520 }
Max Morin787eeed2016-06-23 10:42:07 +0200521 *volume = level;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100522 RTC_LOG(INFO) << "output: " << *volume;
henrika4af73662017-10-11 13:16:17 +0200523 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000524}
525
Max Morin787eeed2016-06-23 10:42:07 +0200526int32_t AudioDeviceModuleImpl::StereoRecordingIsAvailable(
527 bool* available) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100528 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200529 CHECKinitialized_();
530 bool isAvailable = false;
531 if (audio_device_->StereoRecordingIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200532 return -1;
533 }
Max Morin787eeed2016-06-23 10:42:07 +0200534 *available = isAvailable;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100535 RTC_LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200536 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000537}
538
Max Morin787eeed2016-06-23 10:42:07 +0200539int32_t AudioDeviceModuleImpl::SetStereoRecording(bool enable) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100540 RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200541 CHECKinitialized_();
542 if (audio_device_->RecordingIsInitialized()) {
Gustavo Garciaff98f4b2018-12-19 10:37:16 +0100543 RTC_LOG(LERROR)
544 << "unable to set stereo mode after recording is initialized";
Max Morin787eeed2016-06-23 10:42:07 +0200545 return -1;
546 }
henrika4af73662017-10-11 13:16:17 +0200547 if (audio_device_->SetStereoRecording(enable) == -1) {
Gustavo Garciaff98f4b2018-12-19 10:37:16 +0100548 if (enable) {
549 RTC_LOG(WARNING) << "failed to enable stereo recording";
550 }
Max Morin787eeed2016-06-23 10:42:07 +0200551 return -1;
552 }
Max Morin787eeed2016-06-23 10:42:07 +0200553 int8_t nChannels(1);
554 if (enable) {
555 nChannels = 2;
556 }
henrika4af73662017-10-11 13:16:17 +0200557 audio_device_buffer_.SetRecordingChannels(nChannels);
Max Morin787eeed2016-06-23 10:42:07 +0200558 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000559}
560
Max Morin787eeed2016-06-23 10:42:07 +0200561int32_t AudioDeviceModuleImpl::StereoRecording(bool* enabled) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100562 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200563 CHECKinitialized_();
564 bool stereo = false;
565 if (audio_device_->StereoRecording(stereo) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200566 return -1;
567 }
Max Morin787eeed2016-06-23 10:42:07 +0200568 *enabled = stereo;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100569 RTC_LOG(INFO) << "output: " << stereo;
henrika4af73662017-10-11 13:16:17 +0200570 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000571}
572
Max Morin787eeed2016-06-23 10:42:07 +0200573int32_t AudioDeviceModuleImpl::StereoPlayoutIsAvailable(bool* available) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100574 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200575 CHECKinitialized_();
576 bool isAvailable = false;
577 if (audio_device_->StereoPlayoutIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200578 return -1;
579 }
Max Morin787eeed2016-06-23 10:42:07 +0200580 *available = isAvailable;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100581 RTC_LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200582 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000583}
584
Max Morin787eeed2016-06-23 10:42:07 +0200585int32_t AudioDeviceModuleImpl::SetStereoPlayout(bool enable) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100586 RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200587 CHECKinitialized_();
588 if (audio_device_->PlayoutIsInitialized()) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100589 RTC_LOG(LERROR)
Max Morin098e6c52016-06-28 09:36:25 +0200590 << "unable to set stereo mode while playing side is initialized";
Max Morin787eeed2016-06-23 10:42:07 +0200591 return -1;
592 }
henrika4af73662017-10-11 13:16:17 +0200593 if (audio_device_->SetStereoPlayout(enable)) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100594 RTC_LOG(WARNING) << "stereo playout is not supported";
Max Morin787eeed2016-06-23 10:42:07 +0200595 return -1;
596 }
Max Morin787eeed2016-06-23 10:42:07 +0200597 int8_t nChannels(1);
598 if (enable) {
599 nChannels = 2;
600 }
henrika4af73662017-10-11 13:16:17 +0200601 audio_device_buffer_.SetPlayoutChannels(nChannels);
Max Morin787eeed2016-06-23 10:42:07 +0200602 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000603}
604
Max Morin787eeed2016-06-23 10:42:07 +0200605int32_t AudioDeviceModuleImpl::StereoPlayout(bool* enabled) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100606 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200607 CHECKinitialized_();
608 bool stereo = false;
609 if (audio_device_->StereoPlayout(stereo) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200610 return -1;
611 }
Max Morin787eeed2016-06-23 10:42:07 +0200612 *enabled = stereo;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100613 RTC_LOG(INFO) << "output: " << stereo;
henrika4af73662017-10-11 13:16:17 +0200614 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000615}
616
Max Morin787eeed2016-06-23 10:42:07 +0200617int32_t AudioDeviceModuleImpl::PlayoutIsAvailable(bool* available) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100618 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200619 CHECKinitialized_();
620 bool isAvailable = false;
621 if (audio_device_->PlayoutIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200622 return -1;
623 }
Max Morin787eeed2016-06-23 10:42:07 +0200624 *available = isAvailable;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100625 RTC_LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200626 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000627}
628
Max Morin787eeed2016-06-23 10:42:07 +0200629int32_t AudioDeviceModuleImpl::RecordingIsAvailable(bool* available) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100630 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200631 CHECKinitialized_();
632 bool isAvailable = false;
633 if (audio_device_->RecordingIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200634 return -1;
635 }
Max Morin787eeed2016-06-23 10:42:07 +0200636 *available = isAvailable;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100637 RTC_LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200638 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000639}
640
Max Morin787eeed2016-06-23 10:42:07 +0200641int32_t AudioDeviceModuleImpl::MaxMicrophoneVolume(uint32_t* maxVolume) const {
henrika4af73662017-10-11 13:16:17 +0200642 CHECKinitialized_();
Max Morin787eeed2016-06-23 10:42:07 +0200643 uint32_t maxVol(0);
henrika4af73662017-10-11 13:16:17 +0200644 if (audio_device_->MaxMicrophoneVolume(maxVol) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200645 return -1;
646 }
Max Morin787eeed2016-06-23 10:42:07 +0200647 *maxVolume = maxVol;
henrika4af73662017-10-11 13:16:17 +0200648 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000649}
650
Max Morin787eeed2016-06-23 10:42:07 +0200651int32_t AudioDeviceModuleImpl::MinMicrophoneVolume(uint32_t* minVolume) const {
henrika4af73662017-10-11 13:16:17 +0200652 CHECKinitialized_();
Max Morin787eeed2016-06-23 10:42:07 +0200653 uint32_t minVol(0);
henrika4af73662017-10-11 13:16:17 +0200654 if (audio_device_->MinMicrophoneVolume(minVol) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200655 return -1;
656 }
Max Morin787eeed2016-06-23 10:42:07 +0200657 *minVolume = minVol;
henrika4af73662017-10-11 13:16:17 +0200658 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000659}
660
Max Morin787eeed2016-06-23 10:42:07 +0200661int16_t AudioDeviceModuleImpl::PlayoutDevices() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100662 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200663 CHECKinitialized_();
664 uint16_t nPlayoutDevices = audio_device_->PlayoutDevices();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100665 RTC_LOG(INFO) << "output: " << nPlayoutDevices;
henrika4af73662017-10-11 13:16:17 +0200666 return (int16_t)(nPlayoutDevices);
niklase@google.com470e71d2011-07-07 08:21:25 +0000667}
668
Max Morin787eeed2016-06-23 10:42:07 +0200669int32_t AudioDeviceModuleImpl::SetPlayoutDevice(uint16_t index) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100670 RTC_LOG(INFO) << __FUNCTION__ << "(" << index << ")";
henrika4af73662017-10-11 13:16:17 +0200671 CHECKinitialized_();
672 return audio_device_->SetPlayoutDevice(index);
niklase@google.com470e71d2011-07-07 08:21:25 +0000673}
674
Max Morin787eeed2016-06-23 10:42:07 +0200675int32_t AudioDeviceModuleImpl::SetPlayoutDevice(WindowsDeviceType device) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100676 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200677 CHECKinitialized_();
678 return audio_device_->SetPlayoutDevice(device);
niklase@google.com470e71d2011-07-07 08:21:25 +0000679}
680
pbos@webrtc.org25509882013-04-09 10:30:35 +0000681int32_t AudioDeviceModuleImpl::PlayoutDeviceName(
682 uint16_t index,
leozwang@webrtc.org28f39132012-03-01 18:01:48 +0000683 char name[kAdmMaxDeviceNameSize],
Max Morin787eeed2016-06-23 10:42:07 +0200684 char guid[kAdmMaxGuidSize]) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100685 RTC_LOG(INFO) << __FUNCTION__ << "(" << index << ", ...)";
henrika4af73662017-10-11 13:16:17 +0200686 CHECKinitialized_();
Max Morin787eeed2016-06-23 10:42:07 +0200687 if (name == NULL) {
Max Morin787eeed2016-06-23 10:42:07 +0200688 return -1;
689 }
henrika4af73662017-10-11 13:16:17 +0200690 if (audio_device_->PlayoutDeviceName(index, name, guid) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200691 return -1;
692 }
Max Morin787eeed2016-06-23 10:42:07 +0200693 if (name != NULL) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100694 RTC_LOG(INFO) << "output: name = " << name;
Max Morin787eeed2016-06-23 10:42:07 +0200695 }
696 if (guid != NULL) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100697 RTC_LOG(INFO) << "output: guid = " << guid;
Max Morin787eeed2016-06-23 10:42:07 +0200698 }
henrika4af73662017-10-11 13:16:17 +0200699 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000700}
701
pbos@webrtc.org25509882013-04-09 10:30:35 +0000702int32_t AudioDeviceModuleImpl::RecordingDeviceName(
703 uint16_t index,
leozwang@webrtc.org28f39132012-03-01 18:01:48 +0000704 char name[kAdmMaxDeviceNameSize],
Max Morin787eeed2016-06-23 10:42:07 +0200705 char guid[kAdmMaxGuidSize]) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100706 RTC_LOG(INFO) << __FUNCTION__ << "(" << index << ", ...)";
henrika4af73662017-10-11 13:16:17 +0200707 CHECKinitialized_();
Max Morin787eeed2016-06-23 10:42:07 +0200708 if (name == NULL) {
Max Morin787eeed2016-06-23 10:42:07 +0200709 return -1;
710 }
henrika4af73662017-10-11 13:16:17 +0200711 if (audio_device_->RecordingDeviceName(index, name, guid) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200712 return -1;
713 }
Max Morin787eeed2016-06-23 10:42:07 +0200714 if (name != NULL) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100715 RTC_LOG(INFO) << "output: name = " << name;
Max Morin787eeed2016-06-23 10:42:07 +0200716 }
717 if (guid != NULL) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100718 RTC_LOG(INFO) << "output: guid = " << guid;
Max Morin787eeed2016-06-23 10:42:07 +0200719 }
henrika4af73662017-10-11 13:16:17 +0200720 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000721}
722
Max Morin787eeed2016-06-23 10:42:07 +0200723int16_t AudioDeviceModuleImpl::RecordingDevices() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100724 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200725 CHECKinitialized_();
726 uint16_t nRecordingDevices = audio_device_->RecordingDevices();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100727 RTC_LOG(INFO) << "output: " << nRecordingDevices;
henrika4af73662017-10-11 13:16:17 +0200728 return (int16_t)nRecordingDevices;
niklase@google.com470e71d2011-07-07 08:21:25 +0000729}
730
Max Morin787eeed2016-06-23 10:42:07 +0200731int32_t AudioDeviceModuleImpl::SetRecordingDevice(uint16_t index) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100732 RTC_LOG(INFO) << __FUNCTION__ << "(" << index << ")";
henrika4af73662017-10-11 13:16:17 +0200733 CHECKinitialized_();
734 return audio_device_->SetRecordingDevice(index);
niklase@google.com470e71d2011-07-07 08:21:25 +0000735}
736
Max Morin787eeed2016-06-23 10:42:07 +0200737int32_t AudioDeviceModuleImpl::SetRecordingDevice(WindowsDeviceType device) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100738 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200739 CHECKinitialized_();
740 return audio_device_->SetRecordingDevice(device);
niklase@google.com470e71d2011-07-07 08:21:25 +0000741}
742
Max Morin787eeed2016-06-23 10:42:07 +0200743int32_t AudioDeviceModuleImpl::InitPlayout() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100744 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200745 CHECKinitialized_();
maxmorin8c695b42016-07-25 02:46:44 -0700746 if (PlayoutIsInitialized()) {
747 return 0;
748 }
henrika4af73662017-10-11 13:16:17 +0200749 int32_t result = audio_device_->InitPlayout();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100750 RTC_LOG(INFO) << "output: " << result;
Max Morin84cab202016-07-01 13:35:19 +0200751 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.InitPlayoutSuccess",
752 static_cast<int>(result == 0));
753 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000754}
755
Max Morin787eeed2016-06-23 10:42:07 +0200756int32_t AudioDeviceModuleImpl::InitRecording() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100757 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200758 CHECKinitialized_();
maxmorin8c695b42016-07-25 02:46:44 -0700759 if (RecordingIsInitialized()) {
760 return 0;
761 }
henrika4af73662017-10-11 13:16:17 +0200762 int32_t result = audio_device_->InitRecording();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100763 RTC_LOG(INFO) << "output: " << result;
Max Morin84cab202016-07-01 13:35:19 +0200764 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.InitRecordingSuccess",
765 static_cast<int>(result == 0));
766 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000767}
768
Max Morin787eeed2016-06-23 10:42:07 +0200769bool AudioDeviceModuleImpl::PlayoutIsInitialized() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100770 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200771 CHECKinitialized__BOOL();
772 return audio_device_->PlayoutIsInitialized();
niklase@google.com470e71d2011-07-07 08:21:25 +0000773}
774
Max Morin787eeed2016-06-23 10:42:07 +0200775bool AudioDeviceModuleImpl::RecordingIsInitialized() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100776 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200777 CHECKinitialized__BOOL();
778 return audio_device_->RecordingIsInitialized();
niklase@google.com470e71d2011-07-07 08:21:25 +0000779}
780
Max Morin787eeed2016-06-23 10:42:07 +0200781int32_t AudioDeviceModuleImpl::StartPlayout() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100782 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200783 CHECKinitialized_();
maxmorin8c695b42016-07-25 02:46:44 -0700784 if (Playing()) {
785 return 0;
786 }
henrika4af73662017-10-11 13:16:17 +0200787 audio_device_buffer_.StartPlayout();
788 int32_t result = audio_device_->StartPlayout();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100789 RTC_LOG(INFO) << "output: " << result;
Max Morin84cab202016-07-01 13:35:19 +0200790 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StartPlayoutSuccess",
791 static_cast<int>(result == 0));
792 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000793}
794
Max Morin787eeed2016-06-23 10:42:07 +0200795int32_t AudioDeviceModuleImpl::StopPlayout() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100796 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200797 CHECKinitialized_();
798 int32_t result = audio_device_->StopPlayout();
799 audio_device_buffer_.StopPlayout();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100800 RTC_LOG(INFO) << "output: " << result;
Max Morin84cab202016-07-01 13:35:19 +0200801 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StopPlayoutSuccess",
802 static_cast<int>(result == 0));
803 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000804}
805
Max Morin787eeed2016-06-23 10:42:07 +0200806bool AudioDeviceModuleImpl::Playing() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100807 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200808 CHECKinitialized__BOOL();
809 return audio_device_->Playing();
niklase@google.com470e71d2011-07-07 08:21:25 +0000810}
811
Max Morin787eeed2016-06-23 10:42:07 +0200812int32_t AudioDeviceModuleImpl::StartRecording() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100813 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200814 CHECKinitialized_();
maxmorin8c695b42016-07-25 02:46:44 -0700815 if (Recording()) {
816 return 0;
817 }
henrika4af73662017-10-11 13:16:17 +0200818 audio_device_buffer_.StartRecording();
819 int32_t result = audio_device_->StartRecording();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100820 RTC_LOG(INFO) << "output: " << result;
Max Morin84cab202016-07-01 13:35:19 +0200821 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StartRecordingSuccess",
822 static_cast<int>(result == 0));
823 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000824}
niklase@google.com470e71d2011-07-07 08:21:25 +0000825
Max Morin787eeed2016-06-23 10:42:07 +0200826int32_t AudioDeviceModuleImpl::StopRecording() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100827 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200828 CHECKinitialized_();
829 int32_t result = audio_device_->StopRecording();
830 audio_device_buffer_.StopRecording();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100831 RTC_LOG(INFO) << "output: " << result;
Max Morin84cab202016-07-01 13:35:19 +0200832 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StopRecordingSuccess",
833 static_cast<int>(result == 0));
834 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000835}
836
Max Morin787eeed2016-06-23 10:42:07 +0200837bool AudioDeviceModuleImpl::Recording() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100838 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200839 CHECKinitialized__BOOL();
840 return audio_device_->Recording();
niklase@google.com470e71d2011-07-07 08:21:25 +0000841}
842
Max Morin787eeed2016-06-23 10:42:07 +0200843int32_t AudioDeviceModuleImpl::RegisterAudioCallback(
844 AudioTransport* audioCallback) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100845 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200846 return audio_device_buffer_.RegisterAudioCallback(audioCallback);
niklase@google.com470e71d2011-07-07 08:21:25 +0000847}
848
Max Morin787eeed2016-06-23 10:42:07 +0200849int32_t AudioDeviceModuleImpl::PlayoutDelay(uint16_t* delayMS) const {
henrika4af73662017-10-11 13:16:17 +0200850 CHECKinitialized_();
851 uint16_t delay = 0;
852 if (audio_device_->PlayoutDelay(delay) == -1) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100853 RTC_LOG(LERROR) << "failed to retrieve the playout delay";
Max Morin787eeed2016-06-23 10:42:07 +0200854 return -1;
855 }
Max Morin787eeed2016-06-23 10:42:07 +0200856 *delayMS = delay;
henrika4af73662017-10-11 13:16:17 +0200857 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000858}
859
henrika@webrtc.orga954c072014-12-09 16:22:09 +0000860bool AudioDeviceModuleImpl::BuiltInAECIsAvailable() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100861 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200862 CHECKinitialized__BOOL();
863 bool isAvailable = audio_device_->BuiltInAECIsAvailable();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100864 RTC_LOG(INFO) << "output: " << isAvailable;
Max Morin098e6c52016-06-28 09:36:25 +0200865 return isAvailable;
henrika@webrtc.orga954c072014-12-09 16:22:09 +0000866}
867
henrikac14f5ff2015-09-23 14:08:33 +0200868int32_t AudioDeviceModuleImpl::EnableBuiltInAEC(bool enable) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100869 RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200870 CHECKinitialized_();
871 int32_t ok = audio_device_->EnableBuiltInAEC(enable);
Mirko Bonadei675513b2017-11-09 11:09:25 +0100872 RTC_LOG(INFO) << "output: " << ok;
Max Morin098e6c52016-06-28 09:36:25 +0200873 return ok;
henrikac14f5ff2015-09-23 14:08:33 +0200874}
875
876bool AudioDeviceModuleImpl::BuiltInAGCIsAvailable() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100877 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200878 CHECKinitialized__BOOL();
879 bool isAvailable = audio_device_->BuiltInAGCIsAvailable();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100880 RTC_LOG(INFO) << "output: " << isAvailable;
Max Morin098e6c52016-06-28 09:36:25 +0200881 return isAvailable;
henrikac14f5ff2015-09-23 14:08:33 +0200882}
883
884int32_t AudioDeviceModuleImpl::EnableBuiltInAGC(bool enable) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100885 RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200886 CHECKinitialized_();
887 int32_t ok = audio_device_->EnableBuiltInAGC(enable);
Mirko Bonadei675513b2017-11-09 11:09:25 +0100888 RTC_LOG(INFO) << "output: " << ok;
Max Morin098e6c52016-06-28 09:36:25 +0200889 return ok;
henrikac14f5ff2015-09-23 14:08:33 +0200890}
891
892bool AudioDeviceModuleImpl::BuiltInNSIsAvailable() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100893 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200894 CHECKinitialized__BOOL();
895 bool isAvailable = audio_device_->BuiltInNSIsAvailable();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100896 RTC_LOG(INFO) << "output: " << isAvailable;
Max Morin098e6c52016-06-28 09:36:25 +0200897 return isAvailable;
henrikac14f5ff2015-09-23 14:08:33 +0200898}
899
900int32_t AudioDeviceModuleImpl::EnableBuiltInNS(bool enable) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100901 RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200902 CHECKinitialized_();
903 int32_t ok = audio_device_->EnableBuiltInNS(enable);
Mirko Bonadei675513b2017-11-09 11:09:25 +0100904 RTC_LOG(INFO) << "output: " << ok;
Max Morin098e6c52016-06-28 09:36:25 +0200905 return ok;
henrikac14f5ff2015-09-23 14:08:33 +0200906}
907
maxmorin88e31a32016-08-16 00:56:09 -0700908#if defined(WEBRTC_IOS)
henrikaba35d052015-07-14 17:04:08 +0200909int AudioDeviceModuleImpl::GetPlayoutAudioParameters(
910 AudioParameters* params) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100911 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200912 int r = audio_device_->GetPlayoutAudioParameters(params);
Mirko Bonadei675513b2017-11-09 11:09:25 +0100913 RTC_LOG(INFO) << "output: " << r;
Max Morin098e6c52016-06-28 09:36:25 +0200914 return r;
henrikaba35d052015-07-14 17:04:08 +0200915}
916
917int AudioDeviceModuleImpl::GetRecordAudioParameters(
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_->GetRecordAudioParameters(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}
maxmorin88e31a32016-08-16 00:56:09 -0700924#endif // WEBRTC_IOS
henrikaba35d052015-07-14 17:04:08 +0200925
Max Morin787eeed2016-06-23 10:42:07 +0200926AudioDeviceModuleImpl::PlatformType AudioDeviceModuleImpl::Platform() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100927 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200928 return platform_type_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000929}
930
Max Morin787eeed2016-06-23 10:42:07 +0200931AudioDeviceModule::AudioLayer AudioDeviceModuleImpl::PlatformAudioLayer()
932 const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100933 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200934 return audio_layer_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000935}
936
937} // namespace webrtc