blob: 91d6208fe1fd1e8e85470a68ef52e9590a642198 [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
Peter Boström4adbbcf2016-05-03 15:51:26 -040071rtc::scoped_refptr<AudioDeviceModule> AudioDeviceModule::Create(
Peter Boström4adbbcf2016-05-03 15:51:26 -040072 const AudioLayer audio_layer) {
Mirko Bonadei675513b2017-11-09 11:09:25 +010073 RTC_LOG(INFO) << __FUNCTION__;
henrika5b6afc02018-09-05 14:34:40 +020074 return AudioDeviceModule::CreateForTest(audio_layer);
75}
76
77// static
78rtc::scoped_refptr<AudioDeviceModuleForTest> AudioDeviceModule::CreateForTest(
79 const AudioLayer audio_layer) {
80 RTC_LOG(INFO) << __FUNCTION__;
henrikaec9c7452018-06-08 16:10:03 +020081
82 // The "AudioDeviceModule::kWindowsCoreAudio2" audio layer has its own
83 // dedicated factory method which should be used instead.
84 if (audio_layer == AudioDeviceModule::kWindowsCoreAudio2) {
85 RTC_LOG(LS_ERROR) << "Use the CreateWindowsCoreAudioAudioDeviceModule() "
86 "factory method instead for this option.";
87 return nullptr;
88 }
89
henrika4af73662017-10-11 13:16:17 +020090 // Create the generic reference counted (platform independent) implementation.
Max Morin787eeed2016-06-23 10:42:07 +020091 rtc::scoped_refptr<AudioDeviceModuleImpl> audioDevice(
henrika5ff64832017-10-11 15:14:51 +020092 new rtc::RefCountedObject<AudioDeviceModuleImpl>(audio_layer));
niklase@google.com470e71d2011-07-07 08:21:25 +000093
Max Morin787eeed2016-06-23 10:42:07 +020094 // Ensure that the current platform is supported.
95 if (audioDevice->CheckPlatform() == -1) {
96 return nullptr;
97 }
niklase@google.com470e71d2011-07-07 08:21:25 +000098
Max Morin787eeed2016-06-23 10:42:07 +020099 // Create the platform-dependent implementation.
100 if (audioDevice->CreatePlatformSpecificObjects() == -1) {
101 return nullptr;
102 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000103
henrika4af73662017-10-11 13:16:17 +0200104 // Ensure that the generic audio buffer can communicate with the platform
105 // specific parts.
Max Morin787eeed2016-06-23 10:42:07 +0200106 if (audioDevice->AttachAudioBuffer() == -1) {
107 return nullptr;
108 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000109
Max Morin787eeed2016-06-23 10:42:07 +0200110 return audioDevice;
niklase@google.com470e71d2011-07-07 08:21:25 +0000111}
112
henrika616e3132017-11-13 12:47:59 +0100113// TODO(bugs.webrtc.org/7306): deprecated.
114rtc::scoped_refptr<AudioDeviceModule> AudioDeviceModule::Create(
115 const int32_t id,
116 const AudioLayer audio_layer) {
117 RTC_LOG(INFO) << __FUNCTION__;
118 return AudioDeviceModule::Create(audio_layer);
119}
120
henrika5ff64832017-10-11 15:14:51 +0200121AudioDeviceModuleImpl::AudioDeviceModuleImpl(const AudioLayer audioLayer)
122 : audio_layer_(audioLayer) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100123 RTC_LOG(INFO) << __FUNCTION__;
niklase@google.com470e71d2011-07-07 08:21:25 +0000124}
125
Max Morin787eeed2016-06-23 10:42:07 +0200126int32_t AudioDeviceModuleImpl::CheckPlatform() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100127 RTC_LOG(INFO) << __FUNCTION__;
Max Morin787eeed2016-06-23 10:42:07 +0200128 // Ensure that the current platform is supported
Max Morin787eeed2016-06-23 10:42:07 +0200129 PlatformType platform(kPlatformNotSupported);
niklase@google.com470e71d2011-07-07 08:21:25 +0000130#if defined(_WIN32)
Max Morin787eeed2016-06-23 10:42:07 +0200131 platform = kPlatformWin32;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100132 RTC_LOG(INFO) << "current platform is Win32";
leozwang@google.com522f42b2011-09-19 17:39:05 +0000133#elif defined(WEBRTC_ANDROID)
Max Morin787eeed2016-06-23 10:42:07 +0200134 platform = kPlatformAndroid;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100135 RTC_LOG(INFO) << "current platform is Android";
niklase@google.com470e71d2011-07-07 08:21:25 +0000136#elif defined(WEBRTC_LINUX)
Max Morin787eeed2016-06-23 10:42:07 +0200137 platform = kPlatformLinux;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100138 RTC_LOG(INFO) << "current platform is Linux";
sjlee@webrtc.org414fa7f2012-09-11 17:25:46 +0000139#elif defined(WEBRTC_IOS)
Max Morin787eeed2016-06-23 10:42:07 +0200140 platform = kPlatformIOS;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100141 RTC_LOG(INFO) << "current platform is IOS";
andrew@webrtc.orgf3b65db2012-09-06 18:17:00 +0000142#elif defined(WEBRTC_MAC)
Max Morin787eeed2016-06-23 10:42:07 +0200143 platform = kPlatformMac;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100144 RTC_LOG(INFO) << "current platform is Mac";
niklase@google.com470e71d2011-07-07 08:21:25 +0000145#endif
Max Morin787eeed2016-06-23 10:42:07 +0200146 if (platform == kPlatformNotSupported) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100147 RTC_LOG(LERROR)
148 << "current platform is not supported => this module will self "
149 "destruct!";
Max Morin787eeed2016-06-23 10:42:07 +0200150 return -1;
151 }
henrika4af73662017-10-11 13:16:17 +0200152 platform_type_ = platform;
Max Morin787eeed2016-06-23 10:42:07 +0200153 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000154}
155
Max Morin787eeed2016-06-23 10:42:07 +0200156int32_t AudioDeviceModuleImpl::CreatePlatformSpecificObjects() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100157 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200158// Dummy ADM implementations if build flags are set.
xians@google.combf5d2ba2011-08-16 07:44:19 +0000159#if defined(WEBRTC_DUMMY_AUDIO_BUILD)
henrika5ff64832017-10-11 15:14:51 +0200160 audio_device_.reset(new AudioDeviceDummy());
Mirko Bonadei675513b2017-11-09 11:09:25 +0100161 RTC_LOG(INFO) << "Dummy Audio APIs will be utilized";
phoglund@webrtc.org8454ad12014-06-11 14:12:04 +0000162#elif defined(WEBRTC_DUMMY_FILE_DEVICES)
henrika5ff64832017-10-11 15:14:51 +0200163 audio_device_.reset(FileAudioDeviceFactory::CreateFileAudioDevice());
henrika4af73662017-10-11 13:16:17 +0200164 if (audio_device_) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100165 RTC_LOG(INFO) << "Will use file-playing dummy device.";
noahric6a355902016-08-17 15:19:50 -0700166 } else {
167 // Create a dummy device instead.
henrika5ff64832017-10-11 15:14:51 +0200168 audio_device_.reset(new AudioDeviceDummy());
Mirko Bonadei675513b2017-11-09 11:09:25 +0100169 RTC_LOG(INFO) << "Dummy Audio APIs will be utilized";
noahric6a355902016-08-17 15:19:50 -0700170 }
henrika4af73662017-10-11 13:16:17 +0200171
172// Real (non-dummy) ADM implementations.
xians@google.combf5d2ba2011-08-16 07:44:19 +0000173#else
henrika4af73662017-10-11 13:16:17 +0200174 AudioLayer audio_layer(PlatformAudioLayer());
175// Windows ADM implementation.
niklase@google.com470e71d2011-07-07 08:21:25 +0000176#if defined(WEBRTC_WINDOWS_CORE_AUDIO_BUILD)
henrika4af73662017-10-11 13:16:17 +0200177 if ((audio_layer == kWindowsCoreAudio) ||
178 (audio_layer == kPlatformDefaultAudio)) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100179 RTC_LOG(INFO) << "Attempting to use the Windows Core Audio APIs...";
Max Morin787eeed2016-06-23 10:42:07 +0200180 if (AudioDeviceWindowsCore::CoreAudioIsSupported()) {
henrika4af73662017-10-11 13:16:17 +0200181 audio_device_.reset(new AudioDeviceWindowsCore());
Mirko Bonadei675513b2017-11-09 11:09:25 +0100182 RTC_LOG(INFO) << "Windows Core Audio APIs will be utilized";
niklase@google.com470e71d2011-07-07 08:21:25 +0000183 }
Max Morin787eeed2016-06-23 10:42:07 +0200184 }
185#endif // defined(WEBRTC_WINDOWS_CORE_AUDIO_BUILD)
niklase@google.com470e71d2011-07-07 08:21:25 +0000186
henrike@webrtc.org9ee75e92013-12-11 21:42:44 +0000187#if defined(WEBRTC_ANDROID)
Max Morin787eeed2016-06-23 10:42:07 +0200188 // Create an Android audio manager.
henrika4af73662017-10-11 13:16:17 +0200189 audio_manager_android_.reset(new AudioManager());
Max Morin787eeed2016-06-23 10:42:07 +0200190 // Select best possible combination of audio layers.
henrika4af73662017-10-11 13:16:17 +0200191 if (audio_layer == kPlatformDefaultAudio) {
henrika883d00f2018-03-16 10:09:49 +0100192 if (audio_manager_android_->IsAAudioSupported()) {
193 // Use of AAudio for both playout and recording has highest priority.
194 audio_layer = kAndroidAAudioAudio;
195 } else if (audio_manager_android_->IsLowLatencyPlayoutSupported() &&
196 audio_manager_android_->IsLowLatencyRecordSupported()) {
henrika918b5542016-09-19 15:44:09 +0200197 // Use OpenSL ES for both playout and recording.
henrika4af73662017-10-11 13:16:17 +0200198 audio_layer = kAndroidOpenSLESAudio;
199 } else if (audio_manager_android_->IsLowLatencyPlayoutSupported() &&
200 !audio_manager_android_->IsLowLatencyRecordSupported()) {
henrika918b5542016-09-19 15:44:09 +0200201 // Use OpenSL ES for output on devices that only supports the
Max Morin787eeed2016-06-23 10:42:07 +0200202 // low-latency output audio path.
henrika4af73662017-10-11 13:16:17 +0200203 audio_layer = kAndroidJavaInputAndOpenSLESOutputAudio;
henrikab2619892015-05-18 16:49:16 +0200204 } else {
henrika918b5542016-09-19 15:44:09 +0200205 // Use Java-based audio in both directions when low-latency output is
206 // not supported.
henrika4af73662017-10-11 13:16:17 +0200207 audio_layer = kAndroidJavaAudio;
niklase@google.com470e71d2011-07-07 08:21:25 +0000208 }
Max Morin787eeed2016-06-23 10:42:07 +0200209 }
henrika4af73662017-10-11 13:16:17 +0200210 AudioManager* audio_manager = audio_manager_android_.get();
211 if (audio_layer == kAndroidJavaAudio) {
Max Morin787eeed2016-06-23 10:42:07 +0200212 // Java audio for both input and output audio.
henrika4af73662017-10-11 13:16:17 +0200213 audio_device_.reset(new AudioDeviceTemplate<AudioRecordJni, AudioTrackJni>(
214 audio_layer, audio_manager));
215 } else if (audio_layer == kAndroidOpenSLESAudio) {
henrika918b5542016-09-19 15:44:09 +0200216 // OpenSL ES based audio for both input and output audio.
henrika4af73662017-10-11 13:16:17 +0200217 audio_device_.reset(
218 new AudioDeviceTemplate<OpenSLESRecorder, OpenSLESPlayer>(
219 audio_layer, audio_manager));
220 } else if (audio_layer == kAndroidJavaInputAndOpenSLESOutputAudio) {
Max Morin787eeed2016-06-23 10:42:07 +0200221 // Java audio for input and OpenSL ES for output audio (i.e. mixed APIs).
222 // This combination provides low-latency output audio and at the same
223 // time support for HW AEC using the AudioRecord Java API.
henrika4af73662017-10-11 13:16:17 +0200224 audio_device_.reset(new AudioDeviceTemplate<AudioRecordJni, OpenSLESPlayer>(
225 audio_layer, audio_manager));
henrika883d00f2018-03-16 10:09:49 +0100226 } else if (audio_layer == kAndroidAAudioAudio) {
227#if defined(AUDIO_DEVICE_INCLUDE_ANDROID_AAUDIO)
228 // AAudio based audio for both input and output.
229 audio_device_.reset(new AudioDeviceTemplate<AAudioRecorder, AAudioPlayer>(
230 audio_layer, audio_manager));
231#endif
232 } else if (audio_layer == kAndroidJavaInputAndAAudioOutputAudio) {
233#if defined(AUDIO_DEVICE_INCLUDE_ANDROID_AAUDIO)
234 // Java audio for input and AAudio for output audio (i.e. mixed APIs).
235 audio_device_.reset(new AudioDeviceTemplate<AudioRecordJni, AAudioPlayer>(
236 audio_layer, audio_manager));
237#endif
Max Morin787eeed2016-06-23 10:42:07 +0200238 } else {
henrika883d00f2018-03-16 10:09:49 +0100239 RTC_LOG(LS_ERROR) << "The requested audio layer is not supported";
henrika4af73662017-10-11 13:16:17 +0200240 audio_device_.reset(nullptr);
Max Morin787eeed2016-06-23 10:42:07 +0200241 }
242// END #if defined(WEBRTC_ANDROID)
niklase@google.com470e71d2011-07-07 08:21:25 +0000243
henrika4af73662017-10-11 13:16:17 +0200244// Linux ADM implementation.
henrika68435f52018-04-09 13:31:45 +0200245// Note that, LINUX_ALSA is always defined by default when WEBRTC_LINUX is
246// defined. LINUX_PULSE depends on the 'rtc_include_pulse_audio' build flag.
247// TODO(bugs.webrtc.org/9127): improve support and make it more clear that
248// PulseAudio is the default selection.
niklase@google.com470e71d2011-07-07 08:21:25 +0000249#elif defined(WEBRTC_LINUX)
henrika68435f52018-04-09 13:31:45 +0200250#if !defined(LINUX_PULSE)
251 // Build flag 'rtc_include_pulse_audio' is set to false. In this mode:
252 // - kPlatformDefaultAudio => ALSA, and
253 // - kLinuxAlsaAudio => ALSA, and
254 // - kLinuxPulseAudio => Invalid selection.
255 RTC_LOG(WARNING) << "PulseAudio is disabled using build flag.";
256 if ((audio_layer == kLinuxAlsaAudio) ||
henrika4af73662017-10-11 13:16:17 +0200257 (audio_layer == kPlatformDefaultAudio)) {
henrika4af73662017-10-11 13:16:17 +0200258 audio_device_.reset(new AudioDeviceLinuxALSA());
Mirko Bonadei675513b2017-11-09 11:09:25 +0100259 RTC_LOG(INFO) << "Linux ALSA APIs will be utilized.";
Max Morin787eeed2016-06-23 10:42:07 +0200260 }
henrika68435f52018-04-09 13:31:45 +0200261#else
262 // Build flag 'rtc_include_pulse_audio' is set to true (default). In this
263 // mode:
264 // - kPlatformDefaultAudio => PulseAudio, and
265 // - kLinuxPulseAudio => PulseAudio, and
266 // - kLinuxAlsaAudio => ALSA (supported but not default).
267 RTC_LOG(INFO) << "PulseAudio support is enabled.";
268 if ((audio_layer == kLinuxPulseAudio) ||
269 (audio_layer == kPlatformDefaultAudio)) {
270 // Linux PulseAudio implementation is default.
271 audio_device_.reset(new AudioDeviceLinuxPulse());
272 RTC_LOG(INFO) << "Linux PulseAudio APIs will be utilized";
273 } else if (audio_layer == kLinuxAlsaAudio) {
274 audio_device_.reset(new AudioDeviceLinuxALSA());
275 RTC_LOG(WARNING) << "Linux ALSA APIs will be utilized.";
276 }
277#endif // #if !defined(LINUX_PULSE)
niklase@google.com470e71d2011-07-07 08:21:25 +0000278#endif // #if defined(WEBRTC_LINUX)
279
henrika4af73662017-10-11 13:16:17 +0200280// iOS ADM implementation.
sjlee@webrtc.org414fa7f2012-09-11 17:25:46 +0000281#if defined(WEBRTC_IOS)
henrika4af73662017-10-11 13:16:17 +0200282 if (audio_layer == kPlatformDefaultAudio) {
283 audio_device_.reset(new AudioDeviceIOS());
Mirko Bonadei675513b2017-11-09 11:09:25 +0100284 RTC_LOG(INFO) << "iPhone Audio APIs will be utilized.";
Max Morin787eeed2016-06-23 10:42:07 +0200285 }
286// END #if defined(WEBRTC_IOS)
niklase@google.com470e71d2011-07-07 08:21:25 +0000287
henrika4af73662017-10-11 13:16:17 +0200288// Mac OS X ADM implementation.
andrew@webrtc.orgf3b65db2012-09-06 18:17:00 +0000289#elif defined(WEBRTC_MAC)
henrika4af73662017-10-11 13:16:17 +0200290 if (audio_layer == kPlatformDefaultAudio) {
291 audio_device_.reset(new AudioDeviceMac());
Mirko Bonadei675513b2017-11-09 11:09:25 +0100292 RTC_LOG(INFO) << "Mac OS X Audio APIs will be utilized.";
Max Morin787eeed2016-06-23 10:42:07 +0200293 }
andrew@webrtc.orgf3b65db2012-09-06 18:17:00 +0000294#endif // WEBRTC_MAC
niklase@google.com470e71d2011-07-07 08:21:25 +0000295
henrika4af73662017-10-11 13:16:17 +0200296 // Dummy ADM implementation.
297 if (audio_layer == kDummyAudio) {
henrika5ff64832017-10-11 15:14:51 +0200298 audio_device_.reset(new AudioDeviceDummy());
Mirko Bonadei675513b2017-11-09 11:09:25 +0100299 RTC_LOG(INFO) << "Dummy Audio APIs will be utilized.";
Max Morin787eeed2016-06-23 10:42:07 +0200300 }
xians@google.combf5d2ba2011-08-16 07:44:19 +0000301#endif // if defined(WEBRTC_DUMMY_AUDIO_BUILD)
niklase@google.com470e71d2011-07-07 08:21:25 +0000302
henrika4af73662017-10-11 13:16:17 +0200303 if (!audio_device_) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100304 RTC_LOG(LS_ERROR)
henrika4af73662017-10-11 13:16:17 +0200305 << "Failed to create the platform specific ADM implementation.";
Max Morin787eeed2016-06-23 10:42:07 +0200306 return -1;
307 }
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 +0200311int32_t AudioDeviceModuleImpl::AttachAudioBuffer() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100312 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200313 audio_device_->AttachAudioBuffer(&audio_device_buffer_);
Max Morin787eeed2016-06-23 10:42:07 +0200314 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000315}
316
Max Morin787eeed2016-06-23 10:42:07 +0200317AudioDeviceModuleImpl::~AudioDeviceModuleImpl() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100318 RTC_LOG(INFO) << __FUNCTION__;
niklase@google.com470e71d2011-07-07 08:21:25 +0000319}
320
henrikab2619892015-05-18 16:49:16 +0200321int32_t AudioDeviceModuleImpl::ActiveAudioLayer(AudioLayer* audioLayer) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100322 RTC_LOG(INFO) << __FUNCTION__;
henrikab2619892015-05-18 16:49:16 +0200323 AudioLayer activeAudio;
henrika4af73662017-10-11 13:16:17 +0200324 if (audio_device_->ActiveAudioLayer(activeAudio) == -1) {
henrikab2619892015-05-18 16:49:16 +0200325 return -1;
326 }
327 *audioLayer = activeAudio;
328 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000329}
330
Max Morin787eeed2016-06-23 10:42:07 +0200331int32_t AudioDeviceModuleImpl::Init() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100332 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200333 if (initialized_)
niklase@google.com470e71d2011-07-07 08:21:25 +0000334 return 0;
henrika4af73662017-10-11 13:16:17 +0200335 RTC_CHECK(audio_device_);
336 AudioDeviceGeneric::InitStatus status = audio_device_->Init();
Max Morin84cab202016-07-01 13:35:19 +0200337 RTC_HISTOGRAM_ENUMERATION(
338 "WebRTC.Audio.InitializationResult", static_cast<int>(status),
339 static_cast<int>(AudioDeviceGeneric::InitStatus::NUM_STATUSES));
340 if (status != AudioDeviceGeneric::InitStatus::OK) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100341 RTC_LOG(LS_ERROR) << "Audio device initialization failed.";
Max Morin787eeed2016-06-23 10:42:07 +0200342 return -1;
343 }
henrika4af73662017-10-11 13:16:17 +0200344 initialized_ = true;
Max Morin787eeed2016-06-23 10:42:07 +0200345 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000346}
347
Max Morin787eeed2016-06-23 10:42:07 +0200348int32_t AudioDeviceModuleImpl::Terminate() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100349 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200350 if (!initialized_)
niklase@google.com470e71d2011-07-07 08:21:25 +0000351 return 0;
henrika4af73662017-10-11 13:16:17 +0200352 if (audio_device_->Terminate() == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200353 return -1;
354 }
henrika4af73662017-10-11 13:16:17 +0200355 initialized_ = false;
Max Morin787eeed2016-06-23 10:42:07 +0200356 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000357}
358
Max Morin787eeed2016-06-23 10:42:07 +0200359bool AudioDeviceModuleImpl::Initialized() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100360 RTC_LOG(INFO) << __FUNCTION__ << ": " << initialized_;
henrika4af73662017-10-11 13:16:17 +0200361 return initialized_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000362}
363
Max Morin787eeed2016-06-23 10:42:07 +0200364int32_t AudioDeviceModuleImpl::InitSpeaker() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100365 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200366 CHECKinitialized_();
367 return audio_device_->InitSpeaker();
niklase@google.com470e71d2011-07-07 08:21:25 +0000368}
369
Max Morin787eeed2016-06-23 10:42:07 +0200370int32_t AudioDeviceModuleImpl::InitMicrophone() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100371 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200372 CHECKinitialized_();
373 return audio_device_->InitMicrophone();
niklase@google.com470e71d2011-07-07 08:21:25 +0000374}
375
Max Morin787eeed2016-06-23 10:42:07 +0200376int32_t AudioDeviceModuleImpl::SpeakerVolumeIsAvailable(bool* available) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100377 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200378 CHECKinitialized_();
379 bool isAvailable = false;
380 if (audio_device_->SpeakerVolumeIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200381 return -1;
382 }
Max Morin787eeed2016-06-23 10:42:07 +0200383 *available = isAvailable;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100384 RTC_LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200385 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000386}
387
Max Morin787eeed2016-06-23 10:42:07 +0200388int32_t AudioDeviceModuleImpl::SetSpeakerVolume(uint32_t volume) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100389 RTC_LOG(INFO) << __FUNCTION__ << "(" << volume << ")";
henrika4af73662017-10-11 13:16:17 +0200390 CHECKinitialized_();
391 return audio_device_->SetSpeakerVolume(volume);
niklase@google.com470e71d2011-07-07 08:21:25 +0000392}
393
Max Morin787eeed2016-06-23 10:42:07 +0200394int32_t AudioDeviceModuleImpl::SpeakerVolume(uint32_t* volume) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100395 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200396 CHECKinitialized_();
397 uint32_t level = 0;
398 if (audio_device_->SpeakerVolume(level) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200399 return -1;
400 }
Max Morin787eeed2016-06-23 10:42:07 +0200401 *volume = level;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100402 RTC_LOG(INFO) << "output: " << *volume;
henrika4af73662017-10-11 13:16:17 +0200403 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000404}
405
Max Morin787eeed2016-06-23 10:42:07 +0200406bool AudioDeviceModuleImpl::SpeakerIsInitialized() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100407 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200408 CHECKinitialized__BOOL();
409 bool isInitialized = audio_device_->SpeakerIsInitialized();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100410 RTC_LOG(INFO) << "output: " << isInitialized;
henrika4af73662017-10-11 13:16:17 +0200411 return isInitialized;
niklase@google.com470e71d2011-07-07 08:21:25 +0000412}
413
Max Morin787eeed2016-06-23 10:42:07 +0200414bool AudioDeviceModuleImpl::MicrophoneIsInitialized() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100415 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200416 CHECKinitialized__BOOL();
417 bool isInitialized = audio_device_->MicrophoneIsInitialized();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100418 RTC_LOG(INFO) << "output: " << isInitialized;
henrika4af73662017-10-11 13:16:17 +0200419 return isInitialized;
niklase@google.com470e71d2011-07-07 08:21:25 +0000420}
421
Max Morin787eeed2016-06-23 10:42:07 +0200422int32_t AudioDeviceModuleImpl::MaxSpeakerVolume(uint32_t* maxVolume) const {
henrika4af73662017-10-11 13:16:17 +0200423 CHECKinitialized_();
424 uint32_t maxVol = 0;
425 if (audio_device_->MaxSpeakerVolume(maxVol) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200426 return -1;
427 }
Max Morin787eeed2016-06-23 10:42:07 +0200428 *maxVolume = maxVol;
henrika4af73662017-10-11 13:16:17 +0200429 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000430}
431
Max Morin787eeed2016-06-23 10:42:07 +0200432int32_t AudioDeviceModuleImpl::MinSpeakerVolume(uint32_t* minVolume) const {
henrika4af73662017-10-11 13:16:17 +0200433 CHECKinitialized_();
434 uint32_t minVol = 0;
435 if (audio_device_->MinSpeakerVolume(minVol) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200436 return -1;
437 }
Max Morin787eeed2016-06-23 10:42:07 +0200438 *minVolume = minVol;
henrika4af73662017-10-11 13:16:17 +0200439 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000440}
441
Max Morin787eeed2016-06-23 10:42:07 +0200442int32_t AudioDeviceModuleImpl::SpeakerMuteIsAvailable(bool* available) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100443 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200444 CHECKinitialized_();
Mirko Bonadei72c42502017-11-09 09:33:23 +0100445 bool isAvailable = false;
henrika4af73662017-10-11 13:16:17 +0200446 if (audio_device_->SpeakerMuteIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200447 return -1;
448 }
Max Morin787eeed2016-06-23 10:42:07 +0200449 *available = isAvailable;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100450 RTC_LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200451 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000452}
453
Max Morin787eeed2016-06-23 10:42:07 +0200454int32_t AudioDeviceModuleImpl::SetSpeakerMute(bool enable) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100455 RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200456 CHECKinitialized_();
457 return audio_device_->SetSpeakerMute(enable);
niklase@google.com470e71d2011-07-07 08:21:25 +0000458}
459
Max Morin787eeed2016-06-23 10:42:07 +0200460int32_t AudioDeviceModuleImpl::SpeakerMute(bool* enabled) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100461 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200462 CHECKinitialized_();
463 bool muted = false;
464 if (audio_device_->SpeakerMute(muted) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200465 return -1;
466 }
Max Morin787eeed2016-06-23 10:42:07 +0200467 *enabled = muted;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100468 RTC_LOG(INFO) << "output: " << muted;
henrika4af73662017-10-11 13:16:17 +0200469 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000470}
471
Max Morin787eeed2016-06-23 10:42:07 +0200472int32_t AudioDeviceModuleImpl::MicrophoneMuteIsAvailable(bool* available) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100473 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200474 CHECKinitialized_();
475 bool isAvailable = false;
476 if (audio_device_->MicrophoneMuteIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200477 return -1;
478 }
Max Morin787eeed2016-06-23 10:42:07 +0200479 *available = isAvailable;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100480 RTC_LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200481 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000482}
483
Max Morin787eeed2016-06-23 10:42:07 +0200484int32_t AudioDeviceModuleImpl::SetMicrophoneMute(bool enable) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100485 RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200486 CHECKinitialized_();
487 return (audio_device_->SetMicrophoneMute(enable));
niklase@google.com470e71d2011-07-07 08:21:25 +0000488}
489
Max Morin787eeed2016-06-23 10:42:07 +0200490int32_t AudioDeviceModuleImpl::MicrophoneMute(bool* enabled) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100491 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200492 CHECKinitialized_();
493 bool muted = false;
494 if (audio_device_->MicrophoneMute(muted) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200495 return -1;
496 }
Max Morin787eeed2016-06-23 10:42:07 +0200497 *enabled = muted;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100498 RTC_LOG(INFO) << "output: " << muted;
henrika4af73662017-10-11 13:16:17 +0200499 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000500}
501
Max Morin787eeed2016-06-23 10:42:07 +0200502int32_t AudioDeviceModuleImpl::MicrophoneVolumeIsAvailable(bool* available) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100503 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200504 CHECKinitialized_();
505 bool isAvailable = false;
506 if (audio_device_->MicrophoneVolumeIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200507 return -1;
508 }
Max Morin787eeed2016-06-23 10:42:07 +0200509 *available = isAvailable;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100510 RTC_LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200511 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000512}
513
Max Morin787eeed2016-06-23 10:42:07 +0200514int32_t AudioDeviceModuleImpl::SetMicrophoneVolume(uint32_t volume) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100515 RTC_LOG(INFO) << __FUNCTION__ << "(" << volume << ")";
henrika4af73662017-10-11 13:16:17 +0200516 CHECKinitialized_();
517 return (audio_device_->SetMicrophoneVolume(volume));
niklase@google.com470e71d2011-07-07 08:21:25 +0000518}
519
Max Morin787eeed2016-06-23 10:42:07 +0200520int32_t AudioDeviceModuleImpl::MicrophoneVolume(uint32_t* volume) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100521 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200522 CHECKinitialized_();
523 uint32_t level = 0;
524 if (audio_device_->MicrophoneVolume(level) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200525 return -1;
526 }
Max Morin787eeed2016-06-23 10:42:07 +0200527 *volume = level;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100528 RTC_LOG(INFO) << "output: " << *volume;
henrika4af73662017-10-11 13:16:17 +0200529 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000530}
531
Max Morin787eeed2016-06-23 10:42:07 +0200532int32_t AudioDeviceModuleImpl::StereoRecordingIsAvailable(
533 bool* available) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100534 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200535 CHECKinitialized_();
536 bool isAvailable = false;
537 if (audio_device_->StereoRecordingIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200538 return -1;
539 }
Max Morin787eeed2016-06-23 10:42:07 +0200540 *available = isAvailable;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100541 RTC_LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200542 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000543}
544
Max Morin787eeed2016-06-23 10:42:07 +0200545int32_t AudioDeviceModuleImpl::SetStereoRecording(bool enable) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100546 RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200547 CHECKinitialized_();
548 if (audio_device_->RecordingIsInitialized()) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100549 RTC_LOG(WARNING) << "recording in stereo is not supported";
Max Morin787eeed2016-06-23 10:42:07 +0200550 return -1;
551 }
henrika4af73662017-10-11 13:16:17 +0200552 if (audio_device_->SetStereoRecording(enable) == -1) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100553 RTC_LOG(WARNING) << "failed to change stereo recording";
Max Morin787eeed2016-06-23 10:42:07 +0200554 return -1;
555 }
Max Morin787eeed2016-06-23 10:42:07 +0200556 int8_t nChannels(1);
557 if (enable) {
558 nChannels = 2;
559 }
henrika4af73662017-10-11 13:16:17 +0200560 audio_device_buffer_.SetRecordingChannels(nChannels);
Max Morin787eeed2016-06-23 10:42:07 +0200561 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000562}
563
Max Morin787eeed2016-06-23 10:42:07 +0200564int32_t AudioDeviceModuleImpl::StereoRecording(bool* enabled) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100565 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200566 CHECKinitialized_();
567 bool stereo = false;
568 if (audio_device_->StereoRecording(stereo) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200569 return -1;
570 }
Max Morin787eeed2016-06-23 10:42:07 +0200571 *enabled = stereo;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100572 RTC_LOG(INFO) << "output: " << stereo;
henrika4af73662017-10-11 13:16:17 +0200573 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000574}
575
Max Morin787eeed2016-06-23 10:42:07 +0200576int32_t AudioDeviceModuleImpl::StereoPlayoutIsAvailable(bool* available) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100577 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200578 CHECKinitialized_();
579 bool isAvailable = false;
580 if (audio_device_->StereoPlayoutIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200581 return -1;
582 }
Max Morin787eeed2016-06-23 10:42:07 +0200583 *available = isAvailable;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100584 RTC_LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200585 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000586}
587
Max Morin787eeed2016-06-23 10:42:07 +0200588int32_t AudioDeviceModuleImpl::SetStereoPlayout(bool enable) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100589 RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200590 CHECKinitialized_();
591 if (audio_device_->PlayoutIsInitialized()) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100592 RTC_LOG(LERROR)
Max Morin098e6c52016-06-28 09:36:25 +0200593 << "unable to set stereo mode while playing side is initialized";
Max Morin787eeed2016-06-23 10:42:07 +0200594 return -1;
595 }
henrika4af73662017-10-11 13:16:17 +0200596 if (audio_device_->SetStereoPlayout(enable)) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100597 RTC_LOG(WARNING) << "stereo playout is not supported";
Max Morin787eeed2016-06-23 10:42:07 +0200598 return -1;
599 }
Max Morin787eeed2016-06-23 10:42:07 +0200600 int8_t nChannels(1);
601 if (enable) {
602 nChannels = 2;
603 }
henrika4af73662017-10-11 13:16:17 +0200604 audio_device_buffer_.SetPlayoutChannels(nChannels);
Max Morin787eeed2016-06-23 10:42:07 +0200605 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000606}
607
Max Morin787eeed2016-06-23 10:42:07 +0200608int32_t AudioDeviceModuleImpl::StereoPlayout(bool* enabled) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100609 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200610 CHECKinitialized_();
611 bool stereo = false;
612 if (audio_device_->StereoPlayout(stereo) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200613 return -1;
614 }
Max Morin787eeed2016-06-23 10:42:07 +0200615 *enabled = stereo;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100616 RTC_LOG(INFO) << "output: " << stereo;
henrika4af73662017-10-11 13:16:17 +0200617 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000618}
619
Max Morin787eeed2016-06-23 10:42:07 +0200620int32_t AudioDeviceModuleImpl::PlayoutIsAvailable(bool* available) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100621 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200622 CHECKinitialized_();
623 bool isAvailable = false;
624 if (audio_device_->PlayoutIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200625 return -1;
626 }
Max Morin787eeed2016-06-23 10:42:07 +0200627 *available = isAvailable;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100628 RTC_LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200629 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000630}
631
Max Morin787eeed2016-06-23 10:42:07 +0200632int32_t AudioDeviceModuleImpl::RecordingIsAvailable(bool* available) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100633 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200634 CHECKinitialized_();
635 bool isAvailable = false;
636 if (audio_device_->RecordingIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200637 return -1;
638 }
Max Morin787eeed2016-06-23 10:42:07 +0200639 *available = isAvailable;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100640 RTC_LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200641 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000642}
643
Max Morin787eeed2016-06-23 10:42:07 +0200644int32_t AudioDeviceModuleImpl::MaxMicrophoneVolume(uint32_t* maxVolume) const {
henrika4af73662017-10-11 13:16:17 +0200645 CHECKinitialized_();
Max Morin787eeed2016-06-23 10:42:07 +0200646 uint32_t maxVol(0);
henrika4af73662017-10-11 13:16:17 +0200647 if (audio_device_->MaxMicrophoneVolume(maxVol) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200648 return -1;
649 }
Max Morin787eeed2016-06-23 10:42:07 +0200650 *maxVolume = maxVol;
henrika4af73662017-10-11 13:16:17 +0200651 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000652}
653
Max Morin787eeed2016-06-23 10:42:07 +0200654int32_t AudioDeviceModuleImpl::MinMicrophoneVolume(uint32_t* minVolume) const {
henrika4af73662017-10-11 13:16:17 +0200655 CHECKinitialized_();
Max Morin787eeed2016-06-23 10:42:07 +0200656 uint32_t minVol(0);
henrika4af73662017-10-11 13:16:17 +0200657 if (audio_device_->MinMicrophoneVolume(minVol) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200658 return -1;
659 }
Max Morin787eeed2016-06-23 10:42:07 +0200660 *minVolume = minVol;
henrika4af73662017-10-11 13:16:17 +0200661 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000662}
663
Max Morin787eeed2016-06-23 10:42:07 +0200664int16_t AudioDeviceModuleImpl::PlayoutDevices() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100665 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200666 CHECKinitialized_();
667 uint16_t nPlayoutDevices = audio_device_->PlayoutDevices();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100668 RTC_LOG(INFO) << "output: " << nPlayoutDevices;
henrika4af73662017-10-11 13:16:17 +0200669 return (int16_t)(nPlayoutDevices);
niklase@google.com470e71d2011-07-07 08:21:25 +0000670}
671
Max Morin787eeed2016-06-23 10:42:07 +0200672int32_t AudioDeviceModuleImpl::SetPlayoutDevice(uint16_t index) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100673 RTC_LOG(INFO) << __FUNCTION__ << "(" << index << ")";
henrika4af73662017-10-11 13:16:17 +0200674 CHECKinitialized_();
675 return audio_device_->SetPlayoutDevice(index);
niklase@google.com470e71d2011-07-07 08:21:25 +0000676}
677
Max Morin787eeed2016-06-23 10:42:07 +0200678int32_t AudioDeviceModuleImpl::SetPlayoutDevice(WindowsDeviceType device) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100679 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200680 CHECKinitialized_();
681 return audio_device_->SetPlayoutDevice(device);
niklase@google.com470e71d2011-07-07 08:21:25 +0000682}
683
pbos@webrtc.org25509882013-04-09 10:30:35 +0000684int32_t AudioDeviceModuleImpl::PlayoutDeviceName(
685 uint16_t index,
leozwang@webrtc.org28f39132012-03-01 18:01:48 +0000686 char name[kAdmMaxDeviceNameSize],
Max Morin787eeed2016-06-23 10:42:07 +0200687 char guid[kAdmMaxGuidSize]) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100688 RTC_LOG(INFO) << __FUNCTION__ << "(" << index << ", ...)";
henrika4af73662017-10-11 13:16:17 +0200689 CHECKinitialized_();
Max Morin787eeed2016-06-23 10:42:07 +0200690 if (name == NULL) {
Max Morin787eeed2016-06-23 10:42:07 +0200691 return -1;
692 }
henrika4af73662017-10-11 13:16:17 +0200693 if (audio_device_->PlayoutDeviceName(index, name, guid) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200694 return -1;
695 }
Max Morin787eeed2016-06-23 10:42:07 +0200696 if (name != NULL) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100697 RTC_LOG(INFO) << "output: name = " << name;
Max Morin787eeed2016-06-23 10:42:07 +0200698 }
699 if (guid != NULL) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100700 RTC_LOG(INFO) << "output: guid = " << guid;
Max Morin787eeed2016-06-23 10:42:07 +0200701 }
henrika4af73662017-10-11 13:16:17 +0200702 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000703}
704
pbos@webrtc.org25509882013-04-09 10:30:35 +0000705int32_t AudioDeviceModuleImpl::RecordingDeviceName(
706 uint16_t index,
leozwang@webrtc.org28f39132012-03-01 18:01:48 +0000707 char name[kAdmMaxDeviceNameSize],
Max Morin787eeed2016-06-23 10:42:07 +0200708 char guid[kAdmMaxGuidSize]) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100709 RTC_LOG(INFO) << __FUNCTION__ << "(" << index << ", ...)";
henrika4af73662017-10-11 13:16:17 +0200710 CHECKinitialized_();
Max Morin787eeed2016-06-23 10:42:07 +0200711 if (name == NULL) {
Max Morin787eeed2016-06-23 10:42:07 +0200712 return -1;
713 }
henrika4af73662017-10-11 13:16:17 +0200714 if (audio_device_->RecordingDeviceName(index, name, guid) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200715 return -1;
716 }
Max Morin787eeed2016-06-23 10:42:07 +0200717 if (name != NULL) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100718 RTC_LOG(INFO) << "output: name = " << name;
Max Morin787eeed2016-06-23 10:42:07 +0200719 }
720 if (guid != NULL) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100721 RTC_LOG(INFO) << "output: guid = " << guid;
Max Morin787eeed2016-06-23 10:42:07 +0200722 }
henrika4af73662017-10-11 13:16:17 +0200723 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000724}
725
Max Morin787eeed2016-06-23 10:42:07 +0200726int16_t AudioDeviceModuleImpl::RecordingDevices() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100727 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200728 CHECKinitialized_();
729 uint16_t nRecordingDevices = audio_device_->RecordingDevices();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100730 RTC_LOG(INFO) << "output: " << nRecordingDevices;
henrika4af73662017-10-11 13:16:17 +0200731 return (int16_t)nRecordingDevices;
niklase@google.com470e71d2011-07-07 08:21:25 +0000732}
733
Max Morin787eeed2016-06-23 10:42:07 +0200734int32_t AudioDeviceModuleImpl::SetRecordingDevice(uint16_t index) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100735 RTC_LOG(INFO) << __FUNCTION__ << "(" << index << ")";
henrika4af73662017-10-11 13:16:17 +0200736 CHECKinitialized_();
737 return audio_device_->SetRecordingDevice(index);
niklase@google.com470e71d2011-07-07 08:21:25 +0000738}
739
Max Morin787eeed2016-06-23 10:42:07 +0200740int32_t AudioDeviceModuleImpl::SetRecordingDevice(WindowsDeviceType device) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100741 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200742 CHECKinitialized_();
743 return audio_device_->SetRecordingDevice(device);
niklase@google.com470e71d2011-07-07 08:21:25 +0000744}
745
Max Morin787eeed2016-06-23 10:42:07 +0200746int32_t AudioDeviceModuleImpl::InitPlayout() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100747 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200748 CHECKinitialized_();
maxmorin8c695b42016-07-25 02:46:44 -0700749 if (PlayoutIsInitialized()) {
750 return 0;
751 }
henrika4af73662017-10-11 13:16:17 +0200752 int32_t result = audio_device_->InitPlayout();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100753 RTC_LOG(INFO) << "output: " << result;
Max Morin84cab202016-07-01 13:35:19 +0200754 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.InitPlayoutSuccess",
755 static_cast<int>(result == 0));
756 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000757}
758
Max Morin787eeed2016-06-23 10:42:07 +0200759int32_t AudioDeviceModuleImpl::InitRecording() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100760 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200761 CHECKinitialized_();
maxmorin8c695b42016-07-25 02:46:44 -0700762 if (RecordingIsInitialized()) {
763 return 0;
764 }
henrika4af73662017-10-11 13:16:17 +0200765 int32_t result = audio_device_->InitRecording();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100766 RTC_LOG(INFO) << "output: " << result;
Max Morin84cab202016-07-01 13:35:19 +0200767 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.InitRecordingSuccess",
768 static_cast<int>(result == 0));
769 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000770}
771
Max Morin787eeed2016-06-23 10:42:07 +0200772bool AudioDeviceModuleImpl::PlayoutIsInitialized() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100773 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200774 CHECKinitialized__BOOL();
775 return audio_device_->PlayoutIsInitialized();
niklase@google.com470e71d2011-07-07 08:21:25 +0000776}
777
Max Morin787eeed2016-06-23 10:42:07 +0200778bool AudioDeviceModuleImpl::RecordingIsInitialized() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100779 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200780 CHECKinitialized__BOOL();
781 return audio_device_->RecordingIsInitialized();
niklase@google.com470e71d2011-07-07 08:21:25 +0000782}
783
Max Morin787eeed2016-06-23 10:42:07 +0200784int32_t AudioDeviceModuleImpl::StartPlayout() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100785 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200786 CHECKinitialized_();
maxmorin8c695b42016-07-25 02:46:44 -0700787 if (Playing()) {
788 return 0;
789 }
henrika4af73662017-10-11 13:16:17 +0200790 audio_device_buffer_.StartPlayout();
791 int32_t result = audio_device_->StartPlayout();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100792 RTC_LOG(INFO) << "output: " << result;
Max Morin84cab202016-07-01 13:35:19 +0200793 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StartPlayoutSuccess",
794 static_cast<int>(result == 0));
795 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000796}
797
Max Morin787eeed2016-06-23 10:42:07 +0200798int32_t AudioDeviceModuleImpl::StopPlayout() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100799 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200800 CHECKinitialized_();
801 int32_t result = audio_device_->StopPlayout();
802 audio_device_buffer_.StopPlayout();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100803 RTC_LOG(INFO) << "output: " << result;
Max Morin84cab202016-07-01 13:35:19 +0200804 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StopPlayoutSuccess",
805 static_cast<int>(result == 0));
806 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000807}
808
Max Morin787eeed2016-06-23 10:42:07 +0200809bool AudioDeviceModuleImpl::Playing() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100810 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200811 CHECKinitialized__BOOL();
812 return audio_device_->Playing();
niklase@google.com470e71d2011-07-07 08:21:25 +0000813}
814
Max Morin787eeed2016-06-23 10:42:07 +0200815int32_t AudioDeviceModuleImpl::StartRecording() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100816 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200817 CHECKinitialized_();
maxmorin8c695b42016-07-25 02:46:44 -0700818 if (Recording()) {
819 return 0;
820 }
henrika4af73662017-10-11 13:16:17 +0200821 audio_device_buffer_.StartRecording();
822 int32_t result = audio_device_->StartRecording();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100823 RTC_LOG(INFO) << "output: " << result;
Max Morin84cab202016-07-01 13:35:19 +0200824 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StartRecordingSuccess",
825 static_cast<int>(result == 0));
826 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000827}
niklase@google.com470e71d2011-07-07 08:21:25 +0000828
Max Morin787eeed2016-06-23 10:42:07 +0200829int32_t AudioDeviceModuleImpl::StopRecording() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100830 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200831 CHECKinitialized_();
832 int32_t result = audio_device_->StopRecording();
833 audio_device_buffer_.StopRecording();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100834 RTC_LOG(INFO) << "output: " << result;
Max Morin84cab202016-07-01 13:35:19 +0200835 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StopRecordingSuccess",
836 static_cast<int>(result == 0));
837 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000838}
839
Max Morin787eeed2016-06-23 10:42:07 +0200840bool AudioDeviceModuleImpl::Recording() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100841 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200842 CHECKinitialized__BOOL();
843 return audio_device_->Recording();
niklase@google.com470e71d2011-07-07 08:21:25 +0000844}
845
Max Morin787eeed2016-06-23 10:42:07 +0200846int32_t AudioDeviceModuleImpl::RegisterAudioCallback(
847 AudioTransport* audioCallback) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100848 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200849 return audio_device_buffer_.RegisterAudioCallback(audioCallback);
niklase@google.com470e71d2011-07-07 08:21:25 +0000850}
851
Max Morin787eeed2016-06-23 10:42:07 +0200852int32_t AudioDeviceModuleImpl::PlayoutDelay(uint16_t* delayMS) const {
henrika4af73662017-10-11 13:16:17 +0200853 CHECKinitialized_();
854 uint16_t delay = 0;
855 if (audio_device_->PlayoutDelay(delay) == -1) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100856 RTC_LOG(LERROR) << "failed to retrieve the playout delay";
Max Morin787eeed2016-06-23 10:42:07 +0200857 return -1;
858 }
Max Morin787eeed2016-06-23 10:42:07 +0200859 *delayMS = delay;
henrika4af73662017-10-11 13:16:17 +0200860 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000861}
862
henrika@webrtc.orga954c072014-12-09 16:22:09 +0000863bool AudioDeviceModuleImpl::BuiltInAECIsAvailable() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100864 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200865 CHECKinitialized__BOOL();
866 bool isAvailable = audio_device_->BuiltInAECIsAvailable();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100867 RTC_LOG(INFO) << "output: " << isAvailable;
Max Morin098e6c52016-06-28 09:36:25 +0200868 return isAvailable;
henrika@webrtc.orga954c072014-12-09 16:22:09 +0000869}
870
henrikac14f5ff2015-09-23 14:08:33 +0200871int32_t AudioDeviceModuleImpl::EnableBuiltInAEC(bool enable) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100872 RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200873 CHECKinitialized_();
874 int32_t ok = audio_device_->EnableBuiltInAEC(enable);
Mirko Bonadei675513b2017-11-09 11:09:25 +0100875 RTC_LOG(INFO) << "output: " << ok;
Max Morin098e6c52016-06-28 09:36:25 +0200876 return ok;
henrikac14f5ff2015-09-23 14:08:33 +0200877}
878
879bool AudioDeviceModuleImpl::BuiltInAGCIsAvailable() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100880 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200881 CHECKinitialized__BOOL();
882 bool isAvailable = audio_device_->BuiltInAGCIsAvailable();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100883 RTC_LOG(INFO) << "output: " << isAvailable;
Max Morin098e6c52016-06-28 09:36:25 +0200884 return isAvailable;
henrikac14f5ff2015-09-23 14:08:33 +0200885}
886
887int32_t AudioDeviceModuleImpl::EnableBuiltInAGC(bool enable) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100888 RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200889 CHECKinitialized_();
890 int32_t ok = audio_device_->EnableBuiltInAGC(enable);
Mirko Bonadei675513b2017-11-09 11:09:25 +0100891 RTC_LOG(INFO) << "output: " << ok;
Max Morin098e6c52016-06-28 09:36:25 +0200892 return ok;
henrikac14f5ff2015-09-23 14:08:33 +0200893}
894
895bool AudioDeviceModuleImpl::BuiltInNSIsAvailable() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100896 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200897 CHECKinitialized__BOOL();
898 bool isAvailable = audio_device_->BuiltInNSIsAvailable();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100899 RTC_LOG(INFO) << "output: " << isAvailable;
Max Morin098e6c52016-06-28 09:36:25 +0200900 return isAvailable;
henrikac14f5ff2015-09-23 14:08:33 +0200901}
902
903int32_t AudioDeviceModuleImpl::EnableBuiltInNS(bool enable) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100904 RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200905 CHECKinitialized_();
906 int32_t ok = audio_device_->EnableBuiltInNS(enable);
Mirko Bonadei675513b2017-11-09 11:09:25 +0100907 RTC_LOG(INFO) << "output: " << ok;
Max Morin098e6c52016-06-28 09:36:25 +0200908 return ok;
henrikac14f5ff2015-09-23 14:08:33 +0200909}
910
maxmorin88e31a32016-08-16 00:56:09 -0700911#if defined(WEBRTC_IOS)
henrikaba35d052015-07-14 17:04:08 +0200912int AudioDeviceModuleImpl::GetPlayoutAudioParameters(
913 AudioParameters* params) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100914 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200915 int r = audio_device_->GetPlayoutAudioParameters(params);
Mirko Bonadei675513b2017-11-09 11:09:25 +0100916 RTC_LOG(INFO) << "output: " << r;
Max Morin098e6c52016-06-28 09:36:25 +0200917 return r;
henrikaba35d052015-07-14 17:04:08 +0200918}
919
920int AudioDeviceModuleImpl::GetRecordAudioParameters(
921 AudioParameters* params) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100922 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200923 int r = audio_device_->GetRecordAudioParameters(params);
Mirko Bonadei675513b2017-11-09 11:09:25 +0100924 RTC_LOG(INFO) << "output: " << r;
Max Morin098e6c52016-06-28 09:36:25 +0200925 return r;
henrikaba35d052015-07-14 17:04:08 +0200926}
maxmorin88e31a32016-08-16 00:56:09 -0700927#endif // WEBRTC_IOS
henrikaba35d052015-07-14 17:04:08 +0200928
Max Morin787eeed2016-06-23 10:42:07 +0200929AudioDeviceModuleImpl::PlatformType AudioDeviceModuleImpl::Platform() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100930 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200931 return platform_type_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000932}
933
Max Morin787eeed2016-06-23 10:42:07 +0200934AudioDeviceModule::AudioLayer AudioDeviceModuleImpl::PlatformAudioLayer()
935 const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100936 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200937 return audio_layer_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000938}
939
940} // namespace webrtc