blob: 521f766e1df096c0524579f1ae3ca689d1855295 [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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020013#include "modules/audio_device/audio_device_config.h"
14#include "modules/audio_device/audio_device_generic.h"
15#include "rtc_base/checks.h"
16#include "rtc_base/logging.h"
17#include "rtc_base/refcount.h"
Niels Möller84255bb2017-10-06 13:43:23 +020018#include "rtc_base/refcountedobject.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020019#include "system_wrappers/include/metrics.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000020
niklase@google.com470e71d2011-07-07 08:21:25 +000021#if defined(_WIN32)
Max Morin787eeed2016-06-23 10:42:07 +020022#if defined(WEBRTC_WINDOWS_CORE_AUDIO_BUILD)
henrika883d00f2018-03-16 10:09:49 +010023#include "modules/audio_device/win/audio_device_core_win.h"
Max Morin787eeed2016-06-23 10:42:07 +020024#endif
leozwang@google.com39f20512011-07-15 16:29:40 +000025#elif defined(WEBRTC_ANDROID)
henrikab2619892015-05-18 16:49:16 +020026#include <stdlib.h>
henrika883d00f2018-03-16 10:09:49 +010027#if defined(AUDIO_DEVICE_INCLUDE_ANDROID_AAUDIO)
28#include "modules/audio_device/android/aaudio_player.h"
29#include "modules/audio_device/android/aaudio_recorder.h"
30#endif
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020031#include "modules/audio_device/android/audio_device_template.h"
32#include "modules/audio_device/android/audio_manager.h"
33#include "modules/audio_device/android/audio_record_jni.h"
34#include "modules/audio_device/android/audio_track_jni.h"
35#include "modules/audio_device/android/opensles_player.h"
36#include "modules/audio_device/android/opensles_recorder.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000037#elif defined(WEBRTC_LINUX)
Max Morin787eeed2016-06-23 10:42:07 +020038#if defined(LINUX_ALSA)
henrika883d00f2018-03-16 10:09:49 +010039#include "modules/audio_device/linux/audio_device_alsa_linux.h"
Max Morin787eeed2016-06-23 10:42:07 +020040#endif
Tommi68898a22015-05-19 17:28:07 +020041#if defined(LINUX_PULSE)
henrika883d00f2018-03-16 10:09:49 +010042#include "modules/audio_device/linux/audio_device_pulse_linux.h"
Tommi68898a22015-05-19 17:28:07 +020043#endif
sjlee@webrtc.org414fa7f2012-09-11 17:25:46 +000044#elif defined(WEBRTC_IOS)
henrika883d00f2018-03-16 10:09:49 +010045#include "modules/audio_device/ios/audio_device_ios.h"
andrew@webrtc.orgf3b65db2012-09-06 18:17:00 +000046#elif defined(WEBRTC_MAC)
henrika883d00f2018-03-16 10:09:49 +010047#include "modules/audio_device/mac/audio_device_mac.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000048#endif
phoglund@webrtc.org8454ad12014-06-11 14:12:04 +000049#if defined(WEBRTC_DUMMY_FILE_DEVICES)
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020050#include "modules/audio_device/dummy/file_audio_device_factory.h"
phoglund@webrtc.org8454ad12014-06-11 14:12:04 +000051#endif
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020052#include "modules/audio_device/dummy/audio_device_dummy.h"
53#include "modules/audio_device/dummy/file_audio_device.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000054
henrika4af73662017-10-11 13:16:17 +020055#define CHECKinitialized_() \
Max Morin787eeed2016-06-23 10:42:07 +020056 { \
henrika4af73662017-10-11 13:16:17 +020057 if (!initialized_) { \
Max Morin787eeed2016-06-23 10:42:07 +020058 return -1; \
henrika883d00f2018-03-16 10:09:49 +010059 } \
Max Morin787eeed2016-06-23 10:42:07 +020060 }
niklase@google.com470e71d2011-07-07 08:21:25 +000061
henrika4af73662017-10-11 13:16:17 +020062#define CHECKinitialized__BOOL() \
Max Morin787eeed2016-06-23 10:42:07 +020063 { \
henrika4af73662017-10-11 13:16:17 +020064 if (!initialized_) { \
Max Morin787eeed2016-06-23 10:42:07 +020065 return false; \
henrika883d00f2018-03-16 10:09:49 +010066 } \
Max Morin787eeed2016-06-23 10:42:07 +020067 }
niklase@google.com470e71d2011-07-07 08:21:25 +000068
Peter Boström1d194412016-03-21 16:44:31 +010069namespace webrtc {
henrike@webrtc.org70efc322012-02-23 17:45:33 +000070
henrika4af73662017-10-11 13:16:17 +020071// static
Peter Boström4adbbcf2016-05-03 15:51:26 -040072rtc::scoped_refptr<AudioDeviceModule> AudioDeviceModule::Create(
Peter Boström4adbbcf2016-05-03 15:51:26 -040073 const AudioLayer audio_layer) {
Mirko Bonadei675513b2017-11-09 11:09:25 +010074 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +020075 // Create the generic reference counted (platform independent) implementation.
Max Morin787eeed2016-06-23 10:42:07 +020076 rtc::scoped_refptr<AudioDeviceModuleImpl> audioDevice(
henrika5ff64832017-10-11 15:14:51 +020077 new rtc::RefCountedObject<AudioDeviceModuleImpl>(audio_layer));
niklase@google.com470e71d2011-07-07 08:21:25 +000078
Max Morin787eeed2016-06-23 10:42:07 +020079 // Ensure that the current platform is supported.
80 if (audioDevice->CheckPlatform() == -1) {
81 return nullptr;
82 }
niklase@google.com470e71d2011-07-07 08:21:25 +000083
Max Morin787eeed2016-06-23 10:42:07 +020084 // Create the platform-dependent implementation.
85 if (audioDevice->CreatePlatformSpecificObjects() == -1) {
86 return nullptr;
87 }
niklase@google.com470e71d2011-07-07 08:21:25 +000088
henrika4af73662017-10-11 13:16:17 +020089 // Ensure that the generic audio buffer can communicate with the platform
90 // specific parts.
Max Morin787eeed2016-06-23 10:42:07 +020091 if (audioDevice->AttachAudioBuffer() == -1) {
92 return nullptr;
93 }
niklase@google.com470e71d2011-07-07 08:21:25 +000094
Max Morin787eeed2016-06-23 10:42:07 +020095 return audioDevice;
niklase@google.com470e71d2011-07-07 08:21:25 +000096}
97
henrika616e3132017-11-13 12:47:59 +010098// TODO(bugs.webrtc.org/7306): deprecated.
99rtc::scoped_refptr<AudioDeviceModule> AudioDeviceModule::Create(
100 const int32_t id,
101 const AudioLayer audio_layer) {
102 RTC_LOG(INFO) << __FUNCTION__;
103 return AudioDeviceModule::Create(audio_layer);
104}
105
henrika5ff64832017-10-11 15:14:51 +0200106AudioDeviceModuleImpl::AudioDeviceModuleImpl(const AudioLayer audioLayer)
107 : audio_layer_(audioLayer) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100108 RTC_LOG(INFO) << __FUNCTION__;
niklase@google.com470e71d2011-07-07 08:21:25 +0000109}
110
Max Morin787eeed2016-06-23 10:42:07 +0200111int32_t AudioDeviceModuleImpl::CheckPlatform() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100112 RTC_LOG(INFO) << __FUNCTION__;
Max Morin787eeed2016-06-23 10:42:07 +0200113 // Ensure that the current platform is supported
Max Morin787eeed2016-06-23 10:42:07 +0200114 PlatformType platform(kPlatformNotSupported);
niklase@google.com470e71d2011-07-07 08:21:25 +0000115#if defined(_WIN32)
Max Morin787eeed2016-06-23 10:42:07 +0200116 platform = kPlatformWin32;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100117 RTC_LOG(INFO) << "current platform is Win32";
leozwang@google.com522f42b2011-09-19 17:39:05 +0000118#elif defined(WEBRTC_ANDROID)
Max Morin787eeed2016-06-23 10:42:07 +0200119 platform = kPlatformAndroid;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100120 RTC_LOG(INFO) << "current platform is Android";
niklase@google.com470e71d2011-07-07 08:21:25 +0000121#elif defined(WEBRTC_LINUX)
Max Morin787eeed2016-06-23 10:42:07 +0200122 platform = kPlatformLinux;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100123 RTC_LOG(INFO) << "current platform is Linux";
sjlee@webrtc.org414fa7f2012-09-11 17:25:46 +0000124#elif defined(WEBRTC_IOS)
Max Morin787eeed2016-06-23 10:42:07 +0200125 platform = kPlatformIOS;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100126 RTC_LOG(INFO) << "current platform is IOS";
andrew@webrtc.orgf3b65db2012-09-06 18:17:00 +0000127#elif defined(WEBRTC_MAC)
Max Morin787eeed2016-06-23 10:42:07 +0200128 platform = kPlatformMac;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100129 RTC_LOG(INFO) << "current platform is Mac";
niklase@google.com470e71d2011-07-07 08:21:25 +0000130#endif
Max Morin787eeed2016-06-23 10:42:07 +0200131 if (platform == kPlatformNotSupported) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100132 RTC_LOG(LERROR)
133 << "current platform is not supported => this module will self "
134 "destruct!";
Max Morin787eeed2016-06-23 10:42:07 +0200135 return -1;
136 }
henrika4af73662017-10-11 13:16:17 +0200137 platform_type_ = platform;
Max Morin787eeed2016-06-23 10:42:07 +0200138 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000139}
140
Max Morin787eeed2016-06-23 10:42:07 +0200141int32_t AudioDeviceModuleImpl::CreatePlatformSpecificObjects() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100142 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200143// Dummy ADM implementations if build flags are set.
xians@google.combf5d2ba2011-08-16 07:44:19 +0000144#if defined(WEBRTC_DUMMY_AUDIO_BUILD)
henrika5ff64832017-10-11 15:14:51 +0200145 audio_device_.reset(new AudioDeviceDummy());
Mirko Bonadei675513b2017-11-09 11:09:25 +0100146 RTC_LOG(INFO) << "Dummy Audio APIs will be utilized";
phoglund@webrtc.org8454ad12014-06-11 14:12:04 +0000147#elif defined(WEBRTC_DUMMY_FILE_DEVICES)
henrika5ff64832017-10-11 15:14:51 +0200148 audio_device_.reset(FileAudioDeviceFactory::CreateFileAudioDevice());
henrika4af73662017-10-11 13:16:17 +0200149 if (audio_device_) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100150 RTC_LOG(INFO) << "Will use file-playing dummy device.";
noahric6a355902016-08-17 15:19:50 -0700151 } else {
152 // Create a dummy device instead.
henrika5ff64832017-10-11 15:14:51 +0200153 audio_device_.reset(new AudioDeviceDummy());
Mirko Bonadei675513b2017-11-09 11:09:25 +0100154 RTC_LOG(INFO) << "Dummy Audio APIs will be utilized";
noahric6a355902016-08-17 15:19:50 -0700155 }
henrika4af73662017-10-11 13:16:17 +0200156
157// Real (non-dummy) ADM implementations.
xians@google.combf5d2ba2011-08-16 07:44:19 +0000158#else
henrika4af73662017-10-11 13:16:17 +0200159 AudioLayer audio_layer(PlatformAudioLayer());
160// Windows ADM implementation.
niklase@google.com470e71d2011-07-07 08:21:25 +0000161#if defined(WEBRTC_WINDOWS_CORE_AUDIO_BUILD)
henrika4af73662017-10-11 13:16:17 +0200162 if ((audio_layer == kWindowsCoreAudio) ||
163 (audio_layer == kPlatformDefaultAudio)) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100164 RTC_LOG(INFO) << "Attempting to use the Windows Core Audio APIs...";
Max Morin787eeed2016-06-23 10:42:07 +0200165 if (AudioDeviceWindowsCore::CoreAudioIsSupported()) {
henrika4af73662017-10-11 13:16:17 +0200166 audio_device_.reset(new AudioDeviceWindowsCore());
Mirko Bonadei675513b2017-11-09 11:09:25 +0100167 RTC_LOG(INFO) << "Windows Core Audio APIs will be utilized";
niklase@google.com470e71d2011-07-07 08:21:25 +0000168 }
Max Morin787eeed2016-06-23 10:42:07 +0200169 }
170#endif // defined(WEBRTC_WINDOWS_CORE_AUDIO_BUILD)
niklase@google.com470e71d2011-07-07 08:21:25 +0000171
henrike@webrtc.org9ee75e92013-12-11 21:42:44 +0000172#if defined(WEBRTC_ANDROID)
Max Morin787eeed2016-06-23 10:42:07 +0200173 // Create an Android audio manager.
henrika4af73662017-10-11 13:16:17 +0200174 audio_manager_android_.reset(new AudioManager());
Max Morin787eeed2016-06-23 10:42:07 +0200175 // Select best possible combination of audio layers.
henrika4af73662017-10-11 13:16:17 +0200176 if (audio_layer == kPlatformDefaultAudio) {
henrika883d00f2018-03-16 10:09:49 +0100177 if (audio_manager_android_->IsAAudioSupported()) {
178 // Use of AAudio for both playout and recording has highest priority.
179 audio_layer = kAndroidAAudioAudio;
180 } else if (audio_manager_android_->IsLowLatencyPlayoutSupported() &&
181 audio_manager_android_->IsLowLatencyRecordSupported()) {
henrika918b5542016-09-19 15:44:09 +0200182 // Use OpenSL ES for both playout and recording.
henrika4af73662017-10-11 13:16:17 +0200183 audio_layer = kAndroidOpenSLESAudio;
184 } else if (audio_manager_android_->IsLowLatencyPlayoutSupported() &&
185 !audio_manager_android_->IsLowLatencyRecordSupported()) {
henrika918b5542016-09-19 15:44:09 +0200186 // Use OpenSL ES for output on devices that only supports the
Max Morin787eeed2016-06-23 10:42:07 +0200187 // low-latency output audio path.
henrika4af73662017-10-11 13:16:17 +0200188 audio_layer = kAndroidJavaInputAndOpenSLESOutputAudio;
henrikab2619892015-05-18 16:49:16 +0200189 } else {
henrika918b5542016-09-19 15:44:09 +0200190 // Use Java-based audio in both directions when low-latency output is
191 // not supported.
henrika4af73662017-10-11 13:16:17 +0200192 audio_layer = kAndroidJavaAudio;
niklase@google.com470e71d2011-07-07 08:21:25 +0000193 }
Max Morin787eeed2016-06-23 10:42:07 +0200194 }
henrika4af73662017-10-11 13:16:17 +0200195 AudioManager* audio_manager = audio_manager_android_.get();
196 if (audio_layer == kAndroidJavaAudio) {
Max Morin787eeed2016-06-23 10:42:07 +0200197 // Java audio for both input and output audio.
henrika4af73662017-10-11 13:16:17 +0200198 audio_device_.reset(new AudioDeviceTemplate<AudioRecordJni, AudioTrackJni>(
199 audio_layer, audio_manager));
200 } else if (audio_layer == kAndroidOpenSLESAudio) {
henrika918b5542016-09-19 15:44:09 +0200201 // OpenSL ES based audio for both input and output audio.
henrika4af73662017-10-11 13:16:17 +0200202 audio_device_.reset(
203 new AudioDeviceTemplate<OpenSLESRecorder, OpenSLESPlayer>(
204 audio_layer, audio_manager));
205 } else if (audio_layer == kAndroidJavaInputAndOpenSLESOutputAudio) {
Max Morin787eeed2016-06-23 10:42:07 +0200206 // Java audio for input and OpenSL ES for output audio (i.e. mixed APIs).
207 // This combination provides low-latency output audio and at the same
208 // time support for HW AEC using the AudioRecord Java API.
henrika4af73662017-10-11 13:16:17 +0200209 audio_device_.reset(new AudioDeviceTemplate<AudioRecordJni, OpenSLESPlayer>(
210 audio_layer, audio_manager));
henrika883d00f2018-03-16 10:09:49 +0100211 } else if (audio_layer == kAndroidAAudioAudio) {
212#if defined(AUDIO_DEVICE_INCLUDE_ANDROID_AAUDIO)
213 // AAudio based audio for both input and output.
214 audio_device_.reset(new AudioDeviceTemplate<AAudioRecorder, AAudioPlayer>(
215 audio_layer, audio_manager));
216#endif
217 } else if (audio_layer == kAndroidJavaInputAndAAudioOutputAudio) {
218#if defined(AUDIO_DEVICE_INCLUDE_ANDROID_AAUDIO)
219 // Java audio for input and AAudio for output audio (i.e. mixed APIs).
220 audio_device_.reset(new AudioDeviceTemplate<AudioRecordJni, AAudioPlayer>(
221 audio_layer, audio_manager));
222#endif
Max Morin787eeed2016-06-23 10:42:07 +0200223 } else {
henrika883d00f2018-03-16 10:09:49 +0100224 RTC_LOG(LS_ERROR) << "The requested audio layer is not supported";
henrika4af73662017-10-11 13:16:17 +0200225 audio_device_.reset(nullptr);
Max Morin787eeed2016-06-23 10:42:07 +0200226 }
227// END #if defined(WEBRTC_ANDROID)
niklase@google.com470e71d2011-07-07 08:21:25 +0000228
henrika4af73662017-10-11 13:16:17 +0200229// Linux ADM implementation.
henrika68435f52018-04-09 13:31:45 +0200230// Note that, LINUX_ALSA is always defined by default when WEBRTC_LINUX is
231// defined. LINUX_PULSE depends on the 'rtc_include_pulse_audio' build flag.
232// TODO(bugs.webrtc.org/9127): improve support and make it more clear that
233// PulseAudio is the default selection.
niklase@google.com470e71d2011-07-07 08:21:25 +0000234#elif defined(WEBRTC_LINUX)
henrika68435f52018-04-09 13:31:45 +0200235#if !defined(LINUX_PULSE)
236 // Build flag 'rtc_include_pulse_audio' is set to false. In this mode:
237 // - kPlatformDefaultAudio => ALSA, and
238 // - kLinuxAlsaAudio => ALSA, and
239 // - kLinuxPulseAudio => Invalid selection.
240 RTC_LOG(WARNING) << "PulseAudio is disabled using build flag.";
241 if ((audio_layer == kLinuxAlsaAudio) ||
henrika4af73662017-10-11 13:16:17 +0200242 (audio_layer == kPlatformDefaultAudio)) {
henrika4af73662017-10-11 13:16:17 +0200243 audio_device_.reset(new AudioDeviceLinuxALSA());
Mirko Bonadei675513b2017-11-09 11:09:25 +0100244 RTC_LOG(INFO) << "Linux ALSA APIs will be utilized.";
Max Morin787eeed2016-06-23 10:42:07 +0200245 }
henrika68435f52018-04-09 13:31:45 +0200246#else
247 // Build flag 'rtc_include_pulse_audio' is set to true (default). In this
248 // mode:
249 // - kPlatformDefaultAudio => PulseAudio, and
250 // - kLinuxPulseAudio => PulseAudio, and
251 // - kLinuxAlsaAudio => ALSA (supported but not default).
252 RTC_LOG(INFO) << "PulseAudio support is enabled.";
253 if ((audio_layer == kLinuxPulseAudio) ||
254 (audio_layer == kPlatformDefaultAudio)) {
255 // Linux PulseAudio implementation is default.
256 audio_device_.reset(new AudioDeviceLinuxPulse());
257 RTC_LOG(INFO) << "Linux PulseAudio APIs will be utilized";
258 } else if (audio_layer == kLinuxAlsaAudio) {
259 audio_device_.reset(new AudioDeviceLinuxALSA());
260 RTC_LOG(WARNING) << "Linux ALSA APIs will be utilized.";
261 }
262#endif // #if !defined(LINUX_PULSE)
niklase@google.com470e71d2011-07-07 08:21:25 +0000263#endif // #if defined(WEBRTC_LINUX)
264
henrika4af73662017-10-11 13:16:17 +0200265// iOS ADM implementation.
sjlee@webrtc.org414fa7f2012-09-11 17:25:46 +0000266#if defined(WEBRTC_IOS)
henrika4af73662017-10-11 13:16:17 +0200267 if (audio_layer == kPlatformDefaultAudio) {
268 audio_device_.reset(new AudioDeviceIOS());
Mirko Bonadei675513b2017-11-09 11:09:25 +0100269 RTC_LOG(INFO) << "iPhone Audio APIs will be utilized.";
Max Morin787eeed2016-06-23 10:42:07 +0200270 }
271// END #if defined(WEBRTC_IOS)
niklase@google.com470e71d2011-07-07 08:21:25 +0000272
henrika4af73662017-10-11 13:16:17 +0200273// Mac OS X ADM implementation.
andrew@webrtc.orgf3b65db2012-09-06 18:17:00 +0000274#elif defined(WEBRTC_MAC)
henrika4af73662017-10-11 13:16:17 +0200275 if (audio_layer == kPlatformDefaultAudio) {
276 audio_device_.reset(new AudioDeviceMac());
Mirko Bonadei675513b2017-11-09 11:09:25 +0100277 RTC_LOG(INFO) << "Mac OS X Audio APIs will be utilized.";
Max Morin787eeed2016-06-23 10:42:07 +0200278 }
andrew@webrtc.orgf3b65db2012-09-06 18:17:00 +0000279#endif // WEBRTC_MAC
niklase@google.com470e71d2011-07-07 08:21:25 +0000280
henrika4af73662017-10-11 13:16:17 +0200281 // Dummy ADM implementation.
282 if (audio_layer == kDummyAudio) {
henrika5ff64832017-10-11 15:14:51 +0200283 audio_device_.reset(new AudioDeviceDummy());
Mirko Bonadei675513b2017-11-09 11:09:25 +0100284 RTC_LOG(INFO) << "Dummy Audio APIs will be utilized.";
Max Morin787eeed2016-06-23 10:42:07 +0200285 }
xians@google.combf5d2ba2011-08-16 07:44:19 +0000286#endif // if defined(WEBRTC_DUMMY_AUDIO_BUILD)
niklase@google.com470e71d2011-07-07 08:21:25 +0000287
henrika4af73662017-10-11 13:16:17 +0200288 if (!audio_device_) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100289 RTC_LOG(LS_ERROR)
henrika4af73662017-10-11 13:16:17 +0200290 << "Failed to create the platform specific ADM implementation.";
Max Morin787eeed2016-06-23 10:42:07 +0200291 return -1;
292 }
Max Morin787eeed2016-06-23 10:42:07 +0200293 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000294}
295
Max Morin787eeed2016-06-23 10:42:07 +0200296int32_t AudioDeviceModuleImpl::AttachAudioBuffer() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100297 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200298 audio_device_->AttachAudioBuffer(&audio_device_buffer_);
Max Morin787eeed2016-06-23 10:42:07 +0200299 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000300}
301
Max Morin787eeed2016-06-23 10:42:07 +0200302AudioDeviceModuleImpl::~AudioDeviceModuleImpl() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100303 RTC_LOG(INFO) << __FUNCTION__;
niklase@google.com470e71d2011-07-07 08:21:25 +0000304}
305
henrikab2619892015-05-18 16:49:16 +0200306int32_t AudioDeviceModuleImpl::ActiveAudioLayer(AudioLayer* audioLayer) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100307 RTC_LOG(INFO) << __FUNCTION__;
henrikab2619892015-05-18 16:49:16 +0200308 AudioLayer activeAudio;
henrika4af73662017-10-11 13:16:17 +0200309 if (audio_device_->ActiveAudioLayer(activeAudio) == -1) {
henrikab2619892015-05-18 16:49:16 +0200310 return -1;
311 }
312 *audioLayer = activeAudio;
313 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000314}
315
Max Morin787eeed2016-06-23 10:42:07 +0200316int32_t AudioDeviceModuleImpl::Init() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100317 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200318 if (initialized_)
niklase@google.com470e71d2011-07-07 08:21:25 +0000319 return 0;
henrika4af73662017-10-11 13:16:17 +0200320 RTC_CHECK(audio_device_);
321 AudioDeviceGeneric::InitStatus status = audio_device_->Init();
Max Morin84cab202016-07-01 13:35:19 +0200322 RTC_HISTOGRAM_ENUMERATION(
323 "WebRTC.Audio.InitializationResult", static_cast<int>(status),
324 static_cast<int>(AudioDeviceGeneric::InitStatus::NUM_STATUSES));
325 if (status != AudioDeviceGeneric::InitStatus::OK) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100326 RTC_LOG(LS_ERROR) << "Audio device initialization failed.";
Max Morin787eeed2016-06-23 10:42:07 +0200327 return -1;
328 }
henrika4af73662017-10-11 13:16:17 +0200329 initialized_ = true;
Max Morin787eeed2016-06-23 10:42:07 +0200330 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000331}
332
Max Morin787eeed2016-06-23 10:42:07 +0200333int32_t AudioDeviceModuleImpl::Terminate() {
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 if (audio_device_->Terminate() == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200338 return -1;
339 }
henrika4af73662017-10-11 13:16:17 +0200340 initialized_ = false;
Max Morin787eeed2016-06-23 10:42:07 +0200341 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000342}
343
Max Morin787eeed2016-06-23 10:42:07 +0200344bool AudioDeviceModuleImpl::Initialized() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100345 RTC_LOG(INFO) << __FUNCTION__ << ": " << initialized_;
henrika4af73662017-10-11 13:16:17 +0200346 return initialized_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000347}
348
Max Morin787eeed2016-06-23 10:42:07 +0200349int32_t AudioDeviceModuleImpl::InitSpeaker() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100350 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200351 CHECKinitialized_();
352 return audio_device_->InitSpeaker();
niklase@google.com470e71d2011-07-07 08:21:25 +0000353}
354
Max Morin787eeed2016-06-23 10:42:07 +0200355int32_t AudioDeviceModuleImpl::InitMicrophone() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100356 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200357 CHECKinitialized_();
358 return audio_device_->InitMicrophone();
niklase@google.com470e71d2011-07-07 08:21:25 +0000359}
360
Max Morin787eeed2016-06-23 10:42:07 +0200361int32_t AudioDeviceModuleImpl::SpeakerVolumeIsAvailable(bool* available) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100362 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200363 CHECKinitialized_();
364 bool isAvailable = false;
365 if (audio_device_->SpeakerVolumeIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200366 return -1;
367 }
Max Morin787eeed2016-06-23 10:42:07 +0200368 *available = isAvailable;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100369 RTC_LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200370 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000371}
372
Max Morin787eeed2016-06-23 10:42:07 +0200373int32_t AudioDeviceModuleImpl::SetSpeakerVolume(uint32_t volume) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100374 RTC_LOG(INFO) << __FUNCTION__ << "(" << volume << ")";
henrika4af73662017-10-11 13:16:17 +0200375 CHECKinitialized_();
376 return audio_device_->SetSpeakerVolume(volume);
niklase@google.com470e71d2011-07-07 08:21:25 +0000377}
378
Max Morin787eeed2016-06-23 10:42:07 +0200379int32_t AudioDeviceModuleImpl::SpeakerVolume(uint32_t* volume) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100380 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200381 CHECKinitialized_();
382 uint32_t level = 0;
383 if (audio_device_->SpeakerVolume(level) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200384 return -1;
385 }
Max Morin787eeed2016-06-23 10:42:07 +0200386 *volume = level;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100387 RTC_LOG(INFO) << "output: " << *volume;
henrika4af73662017-10-11 13:16:17 +0200388 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000389}
390
Max Morin787eeed2016-06-23 10:42:07 +0200391bool AudioDeviceModuleImpl::SpeakerIsInitialized() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100392 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200393 CHECKinitialized__BOOL();
394 bool isInitialized = audio_device_->SpeakerIsInitialized();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100395 RTC_LOG(INFO) << "output: " << isInitialized;
henrika4af73662017-10-11 13:16:17 +0200396 return isInitialized;
niklase@google.com470e71d2011-07-07 08:21:25 +0000397}
398
Max Morin787eeed2016-06-23 10:42:07 +0200399bool AudioDeviceModuleImpl::MicrophoneIsInitialized() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100400 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200401 CHECKinitialized__BOOL();
402 bool isInitialized = audio_device_->MicrophoneIsInitialized();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100403 RTC_LOG(INFO) << "output: " << isInitialized;
henrika4af73662017-10-11 13:16:17 +0200404 return isInitialized;
niklase@google.com470e71d2011-07-07 08:21:25 +0000405}
406
Max Morin787eeed2016-06-23 10:42:07 +0200407int32_t AudioDeviceModuleImpl::MaxSpeakerVolume(uint32_t* maxVolume) const {
henrika4af73662017-10-11 13:16:17 +0200408 CHECKinitialized_();
409 uint32_t maxVol = 0;
410 if (audio_device_->MaxSpeakerVolume(maxVol) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200411 return -1;
412 }
Max Morin787eeed2016-06-23 10:42:07 +0200413 *maxVolume = maxVol;
henrika4af73662017-10-11 13:16:17 +0200414 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000415}
416
Max Morin787eeed2016-06-23 10:42:07 +0200417int32_t AudioDeviceModuleImpl::MinSpeakerVolume(uint32_t* minVolume) const {
henrika4af73662017-10-11 13:16:17 +0200418 CHECKinitialized_();
419 uint32_t minVol = 0;
420 if (audio_device_->MinSpeakerVolume(minVol) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200421 return -1;
422 }
Max Morin787eeed2016-06-23 10:42:07 +0200423 *minVolume = minVol;
henrika4af73662017-10-11 13:16:17 +0200424 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000425}
426
Max Morin787eeed2016-06-23 10:42:07 +0200427int32_t AudioDeviceModuleImpl::SpeakerMuteIsAvailable(bool* available) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100428 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200429 CHECKinitialized_();
Mirko Bonadei72c42502017-11-09 09:33:23 +0100430 bool isAvailable = false;
henrika4af73662017-10-11 13:16:17 +0200431 if (audio_device_->SpeakerMuteIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200432 return -1;
433 }
Max Morin787eeed2016-06-23 10:42:07 +0200434 *available = isAvailable;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100435 RTC_LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200436 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000437}
438
Max Morin787eeed2016-06-23 10:42:07 +0200439int32_t AudioDeviceModuleImpl::SetSpeakerMute(bool enable) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100440 RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200441 CHECKinitialized_();
442 return audio_device_->SetSpeakerMute(enable);
niklase@google.com470e71d2011-07-07 08:21:25 +0000443}
444
Max Morin787eeed2016-06-23 10:42:07 +0200445int32_t AudioDeviceModuleImpl::SpeakerMute(bool* enabled) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100446 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200447 CHECKinitialized_();
448 bool muted = false;
449 if (audio_device_->SpeakerMute(muted) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200450 return -1;
451 }
Max Morin787eeed2016-06-23 10:42:07 +0200452 *enabled = muted;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100453 RTC_LOG(INFO) << "output: " << muted;
henrika4af73662017-10-11 13:16:17 +0200454 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000455}
456
Max Morin787eeed2016-06-23 10:42:07 +0200457int32_t AudioDeviceModuleImpl::MicrophoneMuteIsAvailable(bool* available) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100458 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200459 CHECKinitialized_();
460 bool isAvailable = false;
461 if (audio_device_->MicrophoneMuteIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200462 return -1;
463 }
Max Morin787eeed2016-06-23 10:42:07 +0200464 *available = isAvailable;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100465 RTC_LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200466 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000467}
468
Max Morin787eeed2016-06-23 10:42:07 +0200469int32_t AudioDeviceModuleImpl::SetMicrophoneMute(bool enable) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100470 RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200471 CHECKinitialized_();
472 return (audio_device_->SetMicrophoneMute(enable));
niklase@google.com470e71d2011-07-07 08:21:25 +0000473}
474
Max Morin787eeed2016-06-23 10:42:07 +0200475int32_t AudioDeviceModuleImpl::MicrophoneMute(bool* enabled) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100476 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200477 CHECKinitialized_();
478 bool muted = false;
479 if (audio_device_->MicrophoneMute(muted) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200480 return -1;
481 }
Max Morin787eeed2016-06-23 10:42:07 +0200482 *enabled = muted;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100483 RTC_LOG(INFO) << "output: " << muted;
henrika4af73662017-10-11 13:16:17 +0200484 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000485}
486
Max Morin787eeed2016-06-23 10:42:07 +0200487int32_t AudioDeviceModuleImpl::MicrophoneVolumeIsAvailable(bool* available) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100488 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200489 CHECKinitialized_();
490 bool isAvailable = false;
491 if (audio_device_->MicrophoneVolumeIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200492 return -1;
493 }
Max Morin787eeed2016-06-23 10:42:07 +0200494 *available = isAvailable;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100495 RTC_LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200496 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000497}
498
Max Morin787eeed2016-06-23 10:42:07 +0200499int32_t AudioDeviceModuleImpl::SetMicrophoneVolume(uint32_t volume) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100500 RTC_LOG(INFO) << __FUNCTION__ << "(" << volume << ")";
henrika4af73662017-10-11 13:16:17 +0200501 CHECKinitialized_();
502 return (audio_device_->SetMicrophoneVolume(volume));
niklase@google.com470e71d2011-07-07 08:21:25 +0000503}
504
Max Morin787eeed2016-06-23 10:42:07 +0200505int32_t AudioDeviceModuleImpl::MicrophoneVolume(uint32_t* volume) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100506 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200507 CHECKinitialized_();
508 uint32_t level = 0;
509 if (audio_device_->MicrophoneVolume(level) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200510 return -1;
511 }
Max Morin787eeed2016-06-23 10:42:07 +0200512 *volume = level;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100513 RTC_LOG(INFO) << "output: " << *volume;
henrika4af73662017-10-11 13:16:17 +0200514 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000515}
516
Max Morin787eeed2016-06-23 10:42:07 +0200517int32_t AudioDeviceModuleImpl::StereoRecordingIsAvailable(
518 bool* available) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100519 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200520 CHECKinitialized_();
521 bool isAvailable = false;
522 if (audio_device_->StereoRecordingIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200523 return -1;
524 }
Max Morin787eeed2016-06-23 10:42:07 +0200525 *available = isAvailable;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100526 RTC_LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200527 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000528}
529
Max Morin787eeed2016-06-23 10:42:07 +0200530int32_t AudioDeviceModuleImpl::SetStereoRecording(bool enable) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100531 RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200532 CHECKinitialized_();
533 if (audio_device_->RecordingIsInitialized()) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100534 RTC_LOG(WARNING) << "recording in stereo is not supported";
Max Morin787eeed2016-06-23 10:42:07 +0200535 return -1;
536 }
henrika4af73662017-10-11 13:16:17 +0200537 if (audio_device_->SetStereoRecording(enable) == -1) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100538 RTC_LOG(WARNING) << "failed to change stereo recording";
Max Morin787eeed2016-06-23 10:42:07 +0200539 return -1;
540 }
Max Morin787eeed2016-06-23 10:42:07 +0200541 int8_t nChannels(1);
542 if (enable) {
543 nChannels = 2;
544 }
henrika4af73662017-10-11 13:16:17 +0200545 audio_device_buffer_.SetRecordingChannels(nChannels);
Max Morin787eeed2016-06-23 10:42:07 +0200546 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000547}
548
Max Morin787eeed2016-06-23 10:42:07 +0200549int32_t AudioDeviceModuleImpl::StereoRecording(bool* enabled) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100550 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200551 CHECKinitialized_();
552 bool stereo = false;
553 if (audio_device_->StereoRecording(stereo) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200554 return -1;
555 }
Max Morin787eeed2016-06-23 10:42:07 +0200556 *enabled = stereo;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100557 RTC_LOG(INFO) << "output: " << stereo;
henrika4af73662017-10-11 13:16:17 +0200558 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000559}
560
Max Morin787eeed2016-06-23 10:42:07 +0200561int32_t AudioDeviceModuleImpl::StereoPlayoutIsAvailable(bool* available) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100562 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200563 CHECKinitialized_();
564 bool isAvailable = false;
565 if (audio_device_->StereoPlayoutIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200566 return -1;
567 }
Max Morin787eeed2016-06-23 10:42:07 +0200568 *available = isAvailable;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100569 RTC_LOG(INFO) << "output: " << isAvailable;
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::SetStereoPlayout(bool enable) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100574 RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200575 CHECKinitialized_();
576 if (audio_device_->PlayoutIsInitialized()) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100577 RTC_LOG(LERROR)
Max Morin098e6c52016-06-28 09:36:25 +0200578 << "unable to set stereo mode while playing side is initialized";
Max Morin787eeed2016-06-23 10:42:07 +0200579 return -1;
580 }
henrika4af73662017-10-11 13:16:17 +0200581 if (audio_device_->SetStereoPlayout(enable)) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100582 RTC_LOG(WARNING) << "stereo playout is not supported";
Max Morin787eeed2016-06-23 10:42:07 +0200583 return -1;
584 }
Max Morin787eeed2016-06-23 10:42:07 +0200585 int8_t nChannels(1);
586 if (enable) {
587 nChannels = 2;
588 }
henrika4af73662017-10-11 13:16:17 +0200589 audio_device_buffer_.SetPlayoutChannels(nChannels);
Max Morin787eeed2016-06-23 10:42:07 +0200590 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000591}
592
Max Morin787eeed2016-06-23 10:42:07 +0200593int32_t AudioDeviceModuleImpl::StereoPlayout(bool* enabled) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100594 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200595 CHECKinitialized_();
596 bool stereo = false;
597 if (audio_device_->StereoPlayout(stereo) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200598 return -1;
599 }
Max Morin787eeed2016-06-23 10:42:07 +0200600 *enabled = stereo;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100601 RTC_LOG(INFO) << "output: " << stereo;
henrika4af73662017-10-11 13:16:17 +0200602 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000603}
604
Max Morin787eeed2016-06-23 10:42:07 +0200605int32_t AudioDeviceModuleImpl::PlayoutIsAvailable(bool* available) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100606 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200607 CHECKinitialized_();
608 bool isAvailable = false;
609 if (audio_device_->PlayoutIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200610 return -1;
611 }
Max Morin787eeed2016-06-23 10:42:07 +0200612 *available = isAvailable;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100613 RTC_LOG(INFO) << "output: " << isAvailable;
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::RecordingIsAvailable(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_->RecordingIsAvailable(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::MaxMicrophoneVolume(uint32_t* maxVolume) const {
henrika4af73662017-10-11 13:16:17 +0200630 CHECKinitialized_();
Max Morin787eeed2016-06-23 10:42:07 +0200631 uint32_t maxVol(0);
henrika4af73662017-10-11 13:16:17 +0200632 if (audio_device_->MaxMicrophoneVolume(maxVol) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200633 return -1;
634 }
Max Morin787eeed2016-06-23 10:42:07 +0200635 *maxVolume = maxVol;
henrika4af73662017-10-11 13:16:17 +0200636 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000637}
638
Max Morin787eeed2016-06-23 10:42:07 +0200639int32_t AudioDeviceModuleImpl::MinMicrophoneVolume(uint32_t* minVolume) const {
henrika4af73662017-10-11 13:16:17 +0200640 CHECKinitialized_();
Max Morin787eeed2016-06-23 10:42:07 +0200641 uint32_t minVol(0);
henrika4af73662017-10-11 13:16:17 +0200642 if (audio_device_->MinMicrophoneVolume(minVol) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200643 return -1;
644 }
Max Morin787eeed2016-06-23 10:42:07 +0200645 *minVolume = minVol;
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 +0200649int16_t AudioDeviceModuleImpl::PlayoutDevices() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100650 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200651 CHECKinitialized_();
652 uint16_t nPlayoutDevices = audio_device_->PlayoutDevices();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100653 RTC_LOG(INFO) << "output: " << nPlayoutDevices;
henrika4af73662017-10-11 13:16:17 +0200654 return (int16_t)(nPlayoutDevices);
niklase@google.com470e71d2011-07-07 08:21:25 +0000655}
656
Max Morin787eeed2016-06-23 10:42:07 +0200657int32_t AudioDeviceModuleImpl::SetPlayoutDevice(uint16_t index) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100658 RTC_LOG(INFO) << __FUNCTION__ << "(" << index << ")";
henrika4af73662017-10-11 13:16:17 +0200659 CHECKinitialized_();
660 return audio_device_->SetPlayoutDevice(index);
niklase@google.com470e71d2011-07-07 08:21:25 +0000661}
662
Max Morin787eeed2016-06-23 10:42:07 +0200663int32_t AudioDeviceModuleImpl::SetPlayoutDevice(WindowsDeviceType device) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100664 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200665 CHECKinitialized_();
666 return audio_device_->SetPlayoutDevice(device);
niklase@google.com470e71d2011-07-07 08:21:25 +0000667}
668
pbos@webrtc.org25509882013-04-09 10:30:35 +0000669int32_t AudioDeviceModuleImpl::PlayoutDeviceName(
670 uint16_t index,
leozwang@webrtc.org28f39132012-03-01 18:01:48 +0000671 char name[kAdmMaxDeviceNameSize],
Max Morin787eeed2016-06-23 10:42:07 +0200672 char guid[kAdmMaxGuidSize]) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100673 RTC_LOG(INFO) << __FUNCTION__ << "(" << index << ", ...)";
henrika4af73662017-10-11 13:16:17 +0200674 CHECKinitialized_();
Max Morin787eeed2016-06-23 10:42:07 +0200675 if (name == NULL) {
Max Morin787eeed2016-06-23 10:42:07 +0200676 return -1;
677 }
henrika4af73662017-10-11 13:16:17 +0200678 if (audio_device_->PlayoutDeviceName(index, name, guid) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200679 return -1;
680 }
Max Morin787eeed2016-06-23 10:42:07 +0200681 if (name != NULL) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100682 RTC_LOG(INFO) << "output: name = " << name;
Max Morin787eeed2016-06-23 10:42:07 +0200683 }
684 if (guid != NULL) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100685 RTC_LOG(INFO) << "output: guid = " << guid;
Max Morin787eeed2016-06-23 10:42:07 +0200686 }
henrika4af73662017-10-11 13:16:17 +0200687 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000688}
689
pbos@webrtc.org25509882013-04-09 10:30:35 +0000690int32_t AudioDeviceModuleImpl::RecordingDeviceName(
691 uint16_t index,
leozwang@webrtc.org28f39132012-03-01 18:01:48 +0000692 char name[kAdmMaxDeviceNameSize],
Max Morin787eeed2016-06-23 10:42:07 +0200693 char guid[kAdmMaxGuidSize]) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100694 RTC_LOG(INFO) << __FUNCTION__ << "(" << index << ", ...)";
henrika4af73662017-10-11 13:16:17 +0200695 CHECKinitialized_();
Max Morin787eeed2016-06-23 10:42:07 +0200696 if (name == NULL) {
Max Morin787eeed2016-06-23 10:42:07 +0200697 return -1;
698 }
henrika4af73662017-10-11 13:16:17 +0200699 if (audio_device_->RecordingDeviceName(index, name, guid) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200700 return -1;
701 }
Max Morin787eeed2016-06-23 10:42:07 +0200702 if (name != NULL) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100703 RTC_LOG(INFO) << "output: name = " << name;
Max Morin787eeed2016-06-23 10:42:07 +0200704 }
705 if (guid != NULL) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100706 RTC_LOG(INFO) << "output: guid = " << guid;
Max Morin787eeed2016-06-23 10:42:07 +0200707 }
henrika4af73662017-10-11 13:16:17 +0200708 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000709}
710
Max Morin787eeed2016-06-23 10:42:07 +0200711int16_t AudioDeviceModuleImpl::RecordingDevices() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100712 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200713 CHECKinitialized_();
714 uint16_t nRecordingDevices = audio_device_->RecordingDevices();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100715 RTC_LOG(INFO) << "output: " << nRecordingDevices;
henrika4af73662017-10-11 13:16:17 +0200716 return (int16_t)nRecordingDevices;
niklase@google.com470e71d2011-07-07 08:21:25 +0000717}
718
Max Morin787eeed2016-06-23 10:42:07 +0200719int32_t AudioDeviceModuleImpl::SetRecordingDevice(uint16_t index) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100720 RTC_LOG(INFO) << __FUNCTION__ << "(" << index << ")";
henrika4af73662017-10-11 13:16:17 +0200721 CHECKinitialized_();
722 return audio_device_->SetRecordingDevice(index);
niklase@google.com470e71d2011-07-07 08:21:25 +0000723}
724
Max Morin787eeed2016-06-23 10:42:07 +0200725int32_t AudioDeviceModuleImpl::SetRecordingDevice(WindowsDeviceType device) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100726 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200727 CHECKinitialized_();
728 return audio_device_->SetRecordingDevice(device);
niklase@google.com470e71d2011-07-07 08:21:25 +0000729}
730
Max Morin787eeed2016-06-23 10:42:07 +0200731int32_t AudioDeviceModuleImpl::InitPlayout() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100732 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200733 CHECKinitialized_();
maxmorin8c695b42016-07-25 02:46:44 -0700734 if (PlayoutIsInitialized()) {
735 return 0;
736 }
henrika4af73662017-10-11 13:16:17 +0200737 int32_t result = audio_device_->InitPlayout();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100738 RTC_LOG(INFO) << "output: " << result;
Max Morin84cab202016-07-01 13:35:19 +0200739 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.InitPlayoutSuccess",
740 static_cast<int>(result == 0));
741 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000742}
743
Max Morin787eeed2016-06-23 10:42:07 +0200744int32_t AudioDeviceModuleImpl::InitRecording() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100745 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200746 CHECKinitialized_();
maxmorin8c695b42016-07-25 02:46:44 -0700747 if (RecordingIsInitialized()) {
748 return 0;
749 }
henrika4af73662017-10-11 13:16:17 +0200750 int32_t result = audio_device_->InitRecording();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100751 RTC_LOG(INFO) << "output: " << result;
Max Morin84cab202016-07-01 13:35:19 +0200752 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.InitRecordingSuccess",
753 static_cast<int>(result == 0));
754 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000755}
756
Max Morin787eeed2016-06-23 10:42:07 +0200757bool AudioDeviceModuleImpl::PlayoutIsInitialized() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100758 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200759 CHECKinitialized__BOOL();
760 return audio_device_->PlayoutIsInitialized();
niklase@google.com470e71d2011-07-07 08:21:25 +0000761}
762
Max Morin787eeed2016-06-23 10:42:07 +0200763bool AudioDeviceModuleImpl::RecordingIsInitialized() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100764 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200765 CHECKinitialized__BOOL();
766 return audio_device_->RecordingIsInitialized();
niklase@google.com470e71d2011-07-07 08:21:25 +0000767}
768
Max Morin787eeed2016-06-23 10:42:07 +0200769int32_t AudioDeviceModuleImpl::StartPlayout() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100770 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200771 CHECKinitialized_();
maxmorin8c695b42016-07-25 02:46:44 -0700772 if (Playing()) {
773 return 0;
774 }
henrika4af73662017-10-11 13:16:17 +0200775 audio_device_buffer_.StartPlayout();
776 int32_t result = audio_device_->StartPlayout();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100777 RTC_LOG(INFO) << "output: " << result;
Max Morin84cab202016-07-01 13:35:19 +0200778 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StartPlayoutSuccess",
779 static_cast<int>(result == 0));
780 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000781}
782
Max Morin787eeed2016-06-23 10:42:07 +0200783int32_t AudioDeviceModuleImpl::StopPlayout() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100784 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200785 CHECKinitialized_();
786 int32_t result = audio_device_->StopPlayout();
787 audio_device_buffer_.StopPlayout();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100788 RTC_LOG(INFO) << "output: " << result;
Max Morin84cab202016-07-01 13:35:19 +0200789 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StopPlayoutSuccess",
790 static_cast<int>(result == 0));
791 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000792}
793
Max Morin787eeed2016-06-23 10:42:07 +0200794bool AudioDeviceModuleImpl::Playing() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100795 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200796 CHECKinitialized__BOOL();
797 return audio_device_->Playing();
niklase@google.com470e71d2011-07-07 08:21:25 +0000798}
799
Max Morin787eeed2016-06-23 10:42:07 +0200800int32_t AudioDeviceModuleImpl::StartRecording() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100801 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200802 CHECKinitialized_();
maxmorin8c695b42016-07-25 02:46:44 -0700803 if (Recording()) {
804 return 0;
805 }
henrika4af73662017-10-11 13:16:17 +0200806 audio_device_buffer_.StartRecording();
807 int32_t result = audio_device_->StartRecording();
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.StartRecordingSuccess",
810 static_cast<int>(result == 0));
811 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000812}
niklase@google.com470e71d2011-07-07 08:21:25 +0000813
Max Morin787eeed2016-06-23 10:42:07 +0200814int32_t AudioDeviceModuleImpl::StopRecording() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100815 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200816 CHECKinitialized_();
817 int32_t result = audio_device_->StopRecording();
818 audio_device_buffer_.StopRecording();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100819 RTC_LOG(INFO) << "output: " << result;
Max Morin84cab202016-07-01 13:35:19 +0200820 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StopRecordingSuccess",
821 static_cast<int>(result == 0));
822 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000823}
824
Max Morin787eeed2016-06-23 10:42:07 +0200825bool AudioDeviceModuleImpl::Recording() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100826 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200827 CHECKinitialized__BOOL();
828 return audio_device_->Recording();
niklase@google.com470e71d2011-07-07 08:21:25 +0000829}
830
Max Morin787eeed2016-06-23 10:42:07 +0200831int32_t AudioDeviceModuleImpl::RegisterAudioCallback(
832 AudioTransport* audioCallback) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100833 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200834 return audio_device_buffer_.RegisterAudioCallback(audioCallback);
niklase@google.com470e71d2011-07-07 08:21:25 +0000835}
836
Max Morin787eeed2016-06-23 10:42:07 +0200837int32_t AudioDeviceModuleImpl::PlayoutDelay(uint16_t* delayMS) const {
henrika4af73662017-10-11 13:16:17 +0200838 CHECKinitialized_();
839 uint16_t delay = 0;
840 if (audio_device_->PlayoutDelay(delay) == -1) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100841 RTC_LOG(LERROR) << "failed to retrieve the playout delay";
Max Morin787eeed2016-06-23 10:42:07 +0200842 return -1;
843 }
Max Morin787eeed2016-06-23 10:42:07 +0200844 *delayMS = delay;
henrika4af73662017-10-11 13:16:17 +0200845 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000846}
847
henrika@webrtc.orga954c072014-12-09 16:22:09 +0000848bool AudioDeviceModuleImpl::BuiltInAECIsAvailable() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100849 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200850 CHECKinitialized__BOOL();
851 bool isAvailable = audio_device_->BuiltInAECIsAvailable();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100852 RTC_LOG(INFO) << "output: " << isAvailable;
Max Morin098e6c52016-06-28 09:36:25 +0200853 return isAvailable;
henrika@webrtc.orga954c072014-12-09 16:22:09 +0000854}
855
henrikac14f5ff2015-09-23 14:08:33 +0200856int32_t AudioDeviceModuleImpl::EnableBuiltInAEC(bool enable) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100857 RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200858 CHECKinitialized_();
859 int32_t ok = audio_device_->EnableBuiltInAEC(enable);
Mirko Bonadei675513b2017-11-09 11:09:25 +0100860 RTC_LOG(INFO) << "output: " << ok;
Max Morin098e6c52016-06-28 09:36:25 +0200861 return ok;
henrikac14f5ff2015-09-23 14:08:33 +0200862}
863
864bool AudioDeviceModuleImpl::BuiltInAGCIsAvailable() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100865 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200866 CHECKinitialized__BOOL();
867 bool isAvailable = audio_device_->BuiltInAGCIsAvailable();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100868 RTC_LOG(INFO) << "output: " << isAvailable;
Max Morin098e6c52016-06-28 09:36:25 +0200869 return isAvailable;
henrikac14f5ff2015-09-23 14:08:33 +0200870}
871
872int32_t AudioDeviceModuleImpl::EnableBuiltInAGC(bool enable) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100873 RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200874 CHECKinitialized_();
875 int32_t ok = audio_device_->EnableBuiltInAGC(enable);
Mirko Bonadei675513b2017-11-09 11:09:25 +0100876 RTC_LOG(INFO) << "output: " << ok;
Max Morin098e6c52016-06-28 09:36:25 +0200877 return ok;
henrikac14f5ff2015-09-23 14:08:33 +0200878}
879
880bool AudioDeviceModuleImpl::BuiltInNSIsAvailable() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100881 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200882 CHECKinitialized__BOOL();
883 bool isAvailable = audio_device_->BuiltInNSIsAvailable();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100884 RTC_LOG(INFO) << "output: " << isAvailable;
Max Morin098e6c52016-06-28 09:36:25 +0200885 return isAvailable;
henrikac14f5ff2015-09-23 14:08:33 +0200886}
887
888int32_t AudioDeviceModuleImpl::EnableBuiltInNS(bool enable) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100889 RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200890 CHECKinitialized_();
891 int32_t ok = audio_device_->EnableBuiltInNS(enable);
Mirko Bonadei675513b2017-11-09 11:09:25 +0100892 RTC_LOG(INFO) << "output: " << ok;
Max Morin098e6c52016-06-28 09:36:25 +0200893 return ok;
henrikac14f5ff2015-09-23 14:08:33 +0200894}
895
maxmorin88e31a32016-08-16 00:56:09 -0700896#if defined(WEBRTC_IOS)
henrikaba35d052015-07-14 17:04:08 +0200897int AudioDeviceModuleImpl::GetPlayoutAudioParameters(
898 AudioParameters* params) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100899 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200900 int r = audio_device_->GetPlayoutAudioParameters(params);
Mirko Bonadei675513b2017-11-09 11:09:25 +0100901 RTC_LOG(INFO) << "output: " << r;
Max Morin098e6c52016-06-28 09:36:25 +0200902 return r;
henrikaba35d052015-07-14 17:04:08 +0200903}
904
905int AudioDeviceModuleImpl::GetRecordAudioParameters(
906 AudioParameters* params) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100907 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200908 int r = audio_device_->GetRecordAudioParameters(params);
Mirko Bonadei675513b2017-11-09 11:09:25 +0100909 RTC_LOG(INFO) << "output: " << r;
Max Morin098e6c52016-06-28 09:36:25 +0200910 return r;
henrikaba35d052015-07-14 17:04:08 +0200911}
maxmorin88e31a32016-08-16 00:56:09 -0700912#endif // WEBRTC_IOS
henrikaba35d052015-07-14 17:04:08 +0200913
Max Morin787eeed2016-06-23 10:42:07 +0200914AudioDeviceModuleImpl::PlatformType AudioDeviceModuleImpl::Platform() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100915 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200916 return platform_type_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000917}
918
Max Morin787eeed2016-06-23 10:42:07 +0200919AudioDeviceModule::AudioLayer AudioDeviceModuleImpl::PlatformAudioLayer()
920 const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100921 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200922 return audio_layer_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000923}
924
925} // namespace webrtc