blob: 834f4aa91760d965549c70845cd55c9368e910f1 [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__;
henrikaec9c7452018-06-08 16:10:03 +020075
76 // The "AudioDeviceModule::kWindowsCoreAudio2" audio layer has its own
77 // dedicated factory method which should be used instead.
78 if (audio_layer == AudioDeviceModule::kWindowsCoreAudio2) {
79 RTC_LOG(LS_ERROR) << "Use the CreateWindowsCoreAudioAudioDeviceModule() "
80 "factory method instead for this option.";
81 return nullptr;
82 }
83
henrika4af73662017-10-11 13:16:17 +020084 // Create the generic reference counted (platform independent) implementation.
Max Morin787eeed2016-06-23 10:42:07 +020085 rtc::scoped_refptr<AudioDeviceModuleImpl> audioDevice(
henrika5ff64832017-10-11 15:14:51 +020086 new rtc::RefCountedObject<AudioDeviceModuleImpl>(audio_layer));
niklase@google.com470e71d2011-07-07 08:21:25 +000087
Max Morin787eeed2016-06-23 10:42:07 +020088 // Ensure that the current platform is supported.
89 if (audioDevice->CheckPlatform() == -1) {
90 return nullptr;
91 }
niklase@google.com470e71d2011-07-07 08:21:25 +000092
Max Morin787eeed2016-06-23 10:42:07 +020093 // Create the platform-dependent implementation.
94 if (audioDevice->CreatePlatformSpecificObjects() == -1) {
95 return nullptr;
96 }
niklase@google.com470e71d2011-07-07 08:21:25 +000097
henrika4af73662017-10-11 13:16:17 +020098 // Ensure that the generic audio buffer can communicate with the platform
99 // specific parts.
Max Morin787eeed2016-06-23 10:42:07 +0200100 if (audioDevice->AttachAudioBuffer() == -1) {
101 return nullptr;
102 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000103
Max Morin787eeed2016-06-23 10:42:07 +0200104 return audioDevice;
niklase@google.com470e71d2011-07-07 08:21:25 +0000105}
106
henrika616e3132017-11-13 12:47:59 +0100107// TODO(bugs.webrtc.org/7306): deprecated.
108rtc::scoped_refptr<AudioDeviceModule> AudioDeviceModule::Create(
109 const int32_t id,
110 const AudioLayer audio_layer) {
111 RTC_LOG(INFO) << __FUNCTION__;
112 return AudioDeviceModule::Create(audio_layer);
113}
114
henrika5ff64832017-10-11 15:14:51 +0200115AudioDeviceModuleImpl::AudioDeviceModuleImpl(const AudioLayer audioLayer)
116 : audio_layer_(audioLayer) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100117 RTC_LOG(INFO) << __FUNCTION__;
niklase@google.com470e71d2011-07-07 08:21:25 +0000118}
119
Max Morin787eeed2016-06-23 10:42:07 +0200120int32_t AudioDeviceModuleImpl::CheckPlatform() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100121 RTC_LOG(INFO) << __FUNCTION__;
Max Morin787eeed2016-06-23 10:42:07 +0200122 // Ensure that the current platform is supported
Max Morin787eeed2016-06-23 10:42:07 +0200123 PlatformType platform(kPlatformNotSupported);
niklase@google.com470e71d2011-07-07 08:21:25 +0000124#if defined(_WIN32)
Max Morin787eeed2016-06-23 10:42:07 +0200125 platform = kPlatformWin32;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100126 RTC_LOG(INFO) << "current platform is Win32";
leozwang@google.com522f42b2011-09-19 17:39:05 +0000127#elif defined(WEBRTC_ANDROID)
Max Morin787eeed2016-06-23 10:42:07 +0200128 platform = kPlatformAndroid;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100129 RTC_LOG(INFO) << "current platform is Android";
niklase@google.com470e71d2011-07-07 08:21:25 +0000130#elif defined(WEBRTC_LINUX)
Max Morin787eeed2016-06-23 10:42:07 +0200131 platform = kPlatformLinux;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100132 RTC_LOG(INFO) << "current platform is Linux";
sjlee@webrtc.org414fa7f2012-09-11 17:25:46 +0000133#elif defined(WEBRTC_IOS)
Max Morin787eeed2016-06-23 10:42:07 +0200134 platform = kPlatformIOS;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100135 RTC_LOG(INFO) << "current platform is IOS";
andrew@webrtc.orgf3b65db2012-09-06 18:17:00 +0000136#elif defined(WEBRTC_MAC)
Max Morin787eeed2016-06-23 10:42:07 +0200137 platform = kPlatformMac;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100138 RTC_LOG(INFO) << "current platform is Mac";
niklase@google.com470e71d2011-07-07 08:21:25 +0000139#endif
Max Morin787eeed2016-06-23 10:42:07 +0200140 if (platform == kPlatformNotSupported) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100141 RTC_LOG(LERROR)
142 << "current platform is not supported => this module will self "
143 "destruct!";
Max Morin787eeed2016-06-23 10:42:07 +0200144 return -1;
145 }
henrika4af73662017-10-11 13:16:17 +0200146 platform_type_ = platform;
Max Morin787eeed2016-06-23 10:42:07 +0200147 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000148}
149
Max Morin787eeed2016-06-23 10:42:07 +0200150int32_t AudioDeviceModuleImpl::CreatePlatformSpecificObjects() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100151 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200152// Dummy ADM implementations if build flags are set.
xians@google.combf5d2ba2011-08-16 07:44:19 +0000153#if defined(WEBRTC_DUMMY_AUDIO_BUILD)
henrika5ff64832017-10-11 15:14:51 +0200154 audio_device_.reset(new AudioDeviceDummy());
Mirko Bonadei675513b2017-11-09 11:09:25 +0100155 RTC_LOG(INFO) << "Dummy Audio APIs will be utilized";
phoglund@webrtc.org8454ad12014-06-11 14:12:04 +0000156#elif defined(WEBRTC_DUMMY_FILE_DEVICES)
henrika5ff64832017-10-11 15:14:51 +0200157 audio_device_.reset(FileAudioDeviceFactory::CreateFileAudioDevice());
henrika4af73662017-10-11 13:16:17 +0200158 if (audio_device_) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100159 RTC_LOG(INFO) << "Will use file-playing dummy device.";
noahric6a355902016-08-17 15:19:50 -0700160 } else {
161 // Create a dummy device instead.
henrika5ff64832017-10-11 15:14:51 +0200162 audio_device_.reset(new AudioDeviceDummy());
Mirko Bonadei675513b2017-11-09 11:09:25 +0100163 RTC_LOG(INFO) << "Dummy Audio APIs will be utilized";
noahric6a355902016-08-17 15:19:50 -0700164 }
henrika4af73662017-10-11 13:16:17 +0200165
166// Real (non-dummy) ADM implementations.
xians@google.combf5d2ba2011-08-16 07:44:19 +0000167#else
henrika4af73662017-10-11 13:16:17 +0200168 AudioLayer audio_layer(PlatformAudioLayer());
169// Windows ADM implementation.
niklase@google.com470e71d2011-07-07 08:21:25 +0000170#if defined(WEBRTC_WINDOWS_CORE_AUDIO_BUILD)
henrika4af73662017-10-11 13:16:17 +0200171 if ((audio_layer == kWindowsCoreAudio) ||
172 (audio_layer == kPlatformDefaultAudio)) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100173 RTC_LOG(INFO) << "Attempting to use the Windows Core Audio APIs...";
Max Morin787eeed2016-06-23 10:42:07 +0200174 if (AudioDeviceWindowsCore::CoreAudioIsSupported()) {
henrika4af73662017-10-11 13:16:17 +0200175 audio_device_.reset(new AudioDeviceWindowsCore());
Mirko Bonadei675513b2017-11-09 11:09:25 +0100176 RTC_LOG(INFO) << "Windows Core Audio APIs will be utilized";
niklase@google.com470e71d2011-07-07 08:21:25 +0000177 }
Max Morin787eeed2016-06-23 10:42:07 +0200178 }
179#endif // defined(WEBRTC_WINDOWS_CORE_AUDIO_BUILD)
niklase@google.com470e71d2011-07-07 08:21:25 +0000180
henrike@webrtc.org9ee75e92013-12-11 21:42:44 +0000181#if defined(WEBRTC_ANDROID)
Max Morin787eeed2016-06-23 10:42:07 +0200182 // Create an Android audio manager.
henrika4af73662017-10-11 13:16:17 +0200183 audio_manager_android_.reset(new AudioManager());
Max Morin787eeed2016-06-23 10:42:07 +0200184 // Select best possible combination of audio layers.
henrika4af73662017-10-11 13:16:17 +0200185 if (audio_layer == kPlatformDefaultAudio) {
henrika883d00f2018-03-16 10:09:49 +0100186 if (audio_manager_android_->IsAAudioSupported()) {
187 // Use of AAudio for both playout and recording has highest priority.
188 audio_layer = kAndroidAAudioAudio;
189 } else if (audio_manager_android_->IsLowLatencyPlayoutSupported() &&
190 audio_manager_android_->IsLowLatencyRecordSupported()) {
henrika918b5542016-09-19 15:44:09 +0200191 // Use OpenSL ES for both playout and recording.
henrika4af73662017-10-11 13:16:17 +0200192 audio_layer = kAndroidOpenSLESAudio;
193 } else if (audio_manager_android_->IsLowLatencyPlayoutSupported() &&
194 !audio_manager_android_->IsLowLatencyRecordSupported()) {
henrika918b5542016-09-19 15:44:09 +0200195 // Use OpenSL ES for output on devices that only supports the
Max Morin787eeed2016-06-23 10:42:07 +0200196 // low-latency output audio path.
henrika4af73662017-10-11 13:16:17 +0200197 audio_layer = kAndroidJavaInputAndOpenSLESOutputAudio;
henrikab2619892015-05-18 16:49:16 +0200198 } else {
henrika918b5542016-09-19 15:44:09 +0200199 // Use Java-based audio in both directions when low-latency output is
200 // not supported.
henrika4af73662017-10-11 13:16:17 +0200201 audio_layer = kAndroidJavaAudio;
niklase@google.com470e71d2011-07-07 08:21:25 +0000202 }
Max Morin787eeed2016-06-23 10:42:07 +0200203 }
henrika4af73662017-10-11 13:16:17 +0200204 AudioManager* audio_manager = audio_manager_android_.get();
205 if (audio_layer == kAndroidJavaAudio) {
Max Morin787eeed2016-06-23 10:42:07 +0200206 // Java audio for both input and output audio.
henrika4af73662017-10-11 13:16:17 +0200207 audio_device_.reset(new AudioDeviceTemplate<AudioRecordJni, AudioTrackJni>(
208 audio_layer, audio_manager));
209 } else if (audio_layer == kAndroidOpenSLESAudio) {
henrika918b5542016-09-19 15:44:09 +0200210 // OpenSL ES based audio for both input and output audio.
henrika4af73662017-10-11 13:16:17 +0200211 audio_device_.reset(
212 new AudioDeviceTemplate<OpenSLESRecorder, OpenSLESPlayer>(
213 audio_layer, audio_manager));
214 } else if (audio_layer == kAndroidJavaInputAndOpenSLESOutputAudio) {
Max Morin787eeed2016-06-23 10:42:07 +0200215 // Java audio for input and OpenSL ES for output audio (i.e. mixed APIs).
216 // This combination provides low-latency output audio and at the same
217 // time support for HW AEC using the AudioRecord Java API.
henrika4af73662017-10-11 13:16:17 +0200218 audio_device_.reset(new AudioDeviceTemplate<AudioRecordJni, OpenSLESPlayer>(
219 audio_layer, audio_manager));
henrika883d00f2018-03-16 10:09:49 +0100220 } else if (audio_layer == kAndroidAAudioAudio) {
221#if defined(AUDIO_DEVICE_INCLUDE_ANDROID_AAUDIO)
222 // AAudio based audio for both input and output.
223 audio_device_.reset(new AudioDeviceTemplate<AAudioRecorder, AAudioPlayer>(
224 audio_layer, audio_manager));
225#endif
226 } else if (audio_layer == kAndroidJavaInputAndAAudioOutputAudio) {
227#if defined(AUDIO_DEVICE_INCLUDE_ANDROID_AAUDIO)
228 // Java audio for input and AAudio for output audio (i.e. mixed APIs).
229 audio_device_.reset(new AudioDeviceTemplate<AudioRecordJni, AAudioPlayer>(
230 audio_layer, audio_manager));
231#endif
Max Morin787eeed2016-06-23 10:42:07 +0200232 } else {
henrika883d00f2018-03-16 10:09:49 +0100233 RTC_LOG(LS_ERROR) << "The requested audio layer is not supported";
henrika4af73662017-10-11 13:16:17 +0200234 audio_device_.reset(nullptr);
Max Morin787eeed2016-06-23 10:42:07 +0200235 }
236// END #if defined(WEBRTC_ANDROID)
niklase@google.com470e71d2011-07-07 08:21:25 +0000237
henrika4af73662017-10-11 13:16:17 +0200238// Linux ADM implementation.
henrika68435f52018-04-09 13:31:45 +0200239// Note that, LINUX_ALSA is always defined by default when WEBRTC_LINUX is
240// defined. LINUX_PULSE depends on the 'rtc_include_pulse_audio' build flag.
241// TODO(bugs.webrtc.org/9127): improve support and make it more clear that
242// PulseAudio is the default selection.
niklase@google.com470e71d2011-07-07 08:21:25 +0000243#elif defined(WEBRTC_LINUX)
henrika68435f52018-04-09 13:31:45 +0200244#if !defined(LINUX_PULSE)
245 // Build flag 'rtc_include_pulse_audio' is set to false. In this mode:
246 // - kPlatformDefaultAudio => ALSA, and
247 // - kLinuxAlsaAudio => ALSA, and
248 // - kLinuxPulseAudio => Invalid selection.
249 RTC_LOG(WARNING) << "PulseAudio is disabled using build flag.";
250 if ((audio_layer == kLinuxAlsaAudio) ||
henrika4af73662017-10-11 13:16:17 +0200251 (audio_layer == kPlatformDefaultAudio)) {
henrika4af73662017-10-11 13:16:17 +0200252 audio_device_.reset(new AudioDeviceLinuxALSA());
Mirko Bonadei675513b2017-11-09 11:09:25 +0100253 RTC_LOG(INFO) << "Linux ALSA APIs will be utilized.";
Max Morin787eeed2016-06-23 10:42:07 +0200254 }
henrika68435f52018-04-09 13:31:45 +0200255#else
256 // Build flag 'rtc_include_pulse_audio' is set to true (default). In this
257 // mode:
258 // - kPlatformDefaultAudio => PulseAudio, and
259 // - kLinuxPulseAudio => PulseAudio, and
260 // - kLinuxAlsaAudio => ALSA (supported but not default).
261 RTC_LOG(INFO) << "PulseAudio support is enabled.";
262 if ((audio_layer == kLinuxPulseAudio) ||
263 (audio_layer == kPlatformDefaultAudio)) {
264 // Linux PulseAudio implementation is default.
265 audio_device_.reset(new AudioDeviceLinuxPulse());
266 RTC_LOG(INFO) << "Linux PulseAudio APIs will be utilized";
267 } else if (audio_layer == kLinuxAlsaAudio) {
268 audio_device_.reset(new AudioDeviceLinuxALSA());
269 RTC_LOG(WARNING) << "Linux ALSA APIs will be utilized.";
270 }
271#endif // #if !defined(LINUX_PULSE)
niklase@google.com470e71d2011-07-07 08:21:25 +0000272#endif // #if defined(WEBRTC_LINUX)
273
henrika4af73662017-10-11 13:16:17 +0200274// iOS ADM implementation.
sjlee@webrtc.org414fa7f2012-09-11 17:25:46 +0000275#if defined(WEBRTC_IOS)
henrika4af73662017-10-11 13:16:17 +0200276 if (audio_layer == kPlatformDefaultAudio) {
277 audio_device_.reset(new AudioDeviceIOS());
Mirko Bonadei675513b2017-11-09 11:09:25 +0100278 RTC_LOG(INFO) << "iPhone Audio APIs will be utilized.";
Max Morin787eeed2016-06-23 10:42:07 +0200279 }
280// END #if defined(WEBRTC_IOS)
niklase@google.com470e71d2011-07-07 08:21:25 +0000281
henrika4af73662017-10-11 13:16:17 +0200282// Mac OS X ADM implementation.
andrew@webrtc.orgf3b65db2012-09-06 18:17:00 +0000283#elif defined(WEBRTC_MAC)
henrika4af73662017-10-11 13:16:17 +0200284 if (audio_layer == kPlatformDefaultAudio) {
285 audio_device_.reset(new AudioDeviceMac());
Mirko Bonadei675513b2017-11-09 11:09:25 +0100286 RTC_LOG(INFO) << "Mac OS X Audio APIs will be utilized.";
Max Morin787eeed2016-06-23 10:42:07 +0200287 }
andrew@webrtc.orgf3b65db2012-09-06 18:17:00 +0000288#endif // WEBRTC_MAC
niklase@google.com470e71d2011-07-07 08:21:25 +0000289
henrika4af73662017-10-11 13:16:17 +0200290 // Dummy ADM implementation.
291 if (audio_layer == kDummyAudio) {
henrika5ff64832017-10-11 15:14:51 +0200292 audio_device_.reset(new AudioDeviceDummy());
Mirko Bonadei675513b2017-11-09 11:09:25 +0100293 RTC_LOG(INFO) << "Dummy Audio APIs will be utilized.";
Max Morin787eeed2016-06-23 10:42:07 +0200294 }
xians@google.combf5d2ba2011-08-16 07:44:19 +0000295#endif // if defined(WEBRTC_DUMMY_AUDIO_BUILD)
niklase@google.com470e71d2011-07-07 08:21:25 +0000296
henrika4af73662017-10-11 13:16:17 +0200297 if (!audio_device_) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100298 RTC_LOG(LS_ERROR)
henrika4af73662017-10-11 13:16:17 +0200299 << "Failed to create the platform specific ADM implementation.";
Max Morin787eeed2016-06-23 10:42:07 +0200300 return -1;
301 }
Max Morin787eeed2016-06-23 10:42:07 +0200302 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000303}
304
Max Morin787eeed2016-06-23 10:42:07 +0200305int32_t AudioDeviceModuleImpl::AttachAudioBuffer() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100306 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200307 audio_device_->AttachAudioBuffer(&audio_device_buffer_);
Max Morin787eeed2016-06-23 10:42:07 +0200308 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000309}
310
Max Morin787eeed2016-06-23 10:42:07 +0200311AudioDeviceModuleImpl::~AudioDeviceModuleImpl() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100312 RTC_LOG(INFO) << __FUNCTION__;
niklase@google.com470e71d2011-07-07 08:21:25 +0000313}
314
henrikab2619892015-05-18 16:49:16 +0200315int32_t AudioDeviceModuleImpl::ActiveAudioLayer(AudioLayer* audioLayer) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100316 RTC_LOG(INFO) << __FUNCTION__;
henrikab2619892015-05-18 16:49:16 +0200317 AudioLayer activeAudio;
henrika4af73662017-10-11 13:16:17 +0200318 if (audio_device_->ActiveAudioLayer(activeAudio) == -1) {
henrikab2619892015-05-18 16:49:16 +0200319 return -1;
320 }
321 *audioLayer = activeAudio;
322 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000323}
324
Max Morin787eeed2016-06-23 10:42:07 +0200325int32_t AudioDeviceModuleImpl::Init() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100326 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200327 if (initialized_)
niklase@google.com470e71d2011-07-07 08:21:25 +0000328 return 0;
henrika4af73662017-10-11 13:16:17 +0200329 RTC_CHECK(audio_device_);
330 AudioDeviceGeneric::InitStatus status = audio_device_->Init();
Max Morin84cab202016-07-01 13:35:19 +0200331 RTC_HISTOGRAM_ENUMERATION(
332 "WebRTC.Audio.InitializationResult", static_cast<int>(status),
333 static_cast<int>(AudioDeviceGeneric::InitStatus::NUM_STATUSES));
334 if (status != AudioDeviceGeneric::InitStatus::OK) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100335 RTC_LOG(LS_ERROR) << "Audio device initialization failed.";
Max Morin787eeed2016-06-23 10:42:07 +0200336 return -1;
337 }
henrika4af73662017-10-11 13:16:17 +0200338 initialized_ = true;
Max Morin787eeed2016-06-23 10:42:07 +0200339 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000340}
341
Max Morin787eeed2016-06-23 10:42:07 +0200342int32_t AudioDeviceModuleImpl::Terminate() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100343 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200344 if (!initialized_)
niklase@google.com470e71d2011-07-07 08:21:25 +0000345 return 0;
henrika4af73662017-10-11 13:16:17 +0200346 if (audio_device_->Terminate() == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200347 return -1;
348 }
henrika4af73662017-10-11 13:16:17 +0200349 initialized_ = false;
Max Morin787eeed2016-06-23 10:42:07 +0200350 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000351}
352
Max Morin787eeed2016-06-23 10:42:07 +0200353bool AudioDeviceModuleImpl::Initialized() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100354 RTC_LOG(INFO) << __FUNCTION__ << ": " << initialized_;
henrika4af73662017-10-11 13:16:17 +0200355 return initialized_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000356}
357
Max Morin787eeed2016-06-23 10:42:07 +0200358int32_t AudioDeviceModuleImpl::InitSpeaker() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100359 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200360 CHECKinitialized_();
361 return audio_device_->InitSpeaker();
niklase@google.com470e71d2011-07-07 08:21:25 +0000362}
363
Max Morin787eeed2016-06-23 10:42:07 +0200364int32_t AudioDeviceModuleImpl::InitMicrophone() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100365 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200366 CHECKinitialized_();
367 return audio_device_->InitMicrophone();
niklase@google.com470e71d2011-07-07 08:21:25 +0000368}
369
Max Morin787eeed2016-06-23 10:42:07 +0200370int32_t AudioDeviceModuleImpl::SpeakerVolumeIsAvailable(bool* available) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100371 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200372 CHECKinitialized_();
373 bool isAvailable = false;
374 if (audio_device_->SpeakerVolumeIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200375 return -1;
376 }
Max Morin787eeed2016-06-23 10:42:07 +0200377 *available = isAvailable;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100378 RTC_LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200379 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000380}
381
Max Morin787eeed2016-06-23 10:42:07 +0200382int32_t AudioDeviceModuleImpl::SetSpeakerVolume(uint32_t volume) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100383 RTC_LOG(INFO) << __FUNCTION__ << "(" << volume << ")";
henrika4af73662017-10-11 13:16:17 +0200384 CHECKinitialized_();
385 return audio_device_->SetSpeakerVolume(volume);
niklase@google.com470e71d2011-07-07 08:21:25 +0000386}
387
Max Morin787eeed2016-06-23 10:42:07 +0200388int32_t AudioDeviceModuleImpl::SpeakerVolume(uint32_t* volume) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100389 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200390 CHECKinitialized_();
391 uint32_t level = 0;
392 if (audio_device_->SpeakerVolume(level) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200393 return -1;
394 }
Max Morin787eeed2016-06-23 10:42:07 +0200395 *volume = level;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100396 RTC_LOG(INFO) << "output: " << *volume;
henrika4af73662017-10-11 13:16:17 +0200397 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000398}
399
Max Morin787eeed2016-06-23 10:42:07 +0200400bool AudioDeviceModuleImpl::SpeakerIsInitialized() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100401 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200402 CHECKinitialized__BOOL();
403 bool isInitialized = audio_device_->SpeakerIsInitialized();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100404 RTC_LOG(INFO) << "output: " << isInitialized;
henrika4af73662017-10-11 13:16:17 +0200405 return isInitialized;
niklase@google.com470e71d2011-07-07 08:21:25 +0000406}
407
Max Morin787eeed2016-06-23 10:42:07 +0200408bool AudioDeviceModuleImpl::MicrophoneIsInitialized() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100409 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200410 CHECKinitialized__BOOL();
411 bool isInitialized = audio_device_->MicrophoneIsInitialized();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100412 RTC_LOG(INFO) << "output: " << isInitialized;
henrika4af73662017-10-11 13:16:17 +0200413 return isInitialized;
niklase@google.com470e71d2011-07-07 08:21:25 +0000414}
415
Max Morin787eeed2016-06-23 10:42:07 +0200416int32_t AudioDeviceModuleImpl::MaxSpeakerVolume(uint32_t* maxVolume) const {
henrika4af73662017-10-11 13:16:17 +0200417 CHECKinitialized_();
418 uint32_t maxVol = 0;
419 if (audio_device_->MaxSpeakerVolume(maxVol) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200420 return -1;
421 }
Max Morin787eeed2016-06-23 10:42:07 +0200422 *maxVolume = maxVol;
henrika4af73662017-10-11 13:16:17 +0200423 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000424}
425
Max Morin787eeed2016-06-23 10:42:07 +0200426int32_t AudioDeviceModuleImpl::MinSpeakerVolume(uint32_t* minVolume) const {
henrika4af73662017-10-11 13:16:17 +0200427 CHECKinitialized_();
428 uint32_t minVol = 0;
429 if (audio_device_->MinSpeakerVolume(minVol) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200430 return -1;
431 }
Max Morin787eeed2016-06-23 10:42:07 +0200432 *minVolume = minVol;
henrika4af73662017-10-11 13:16:17 +0200433 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000434}
435
Max Morin787eeed2016-06-23 10:42:07 +0200436int32_t AudioDeviceModuleImpl::SpeakerMuteIsAvailable(bool* available) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100437 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200438 CHECKinitialized_();
Mirko Bonadei72c42502017-11-09 09:33:23 +0100439 bool isAvailable = false;
henrika4af73662017-10-11 13:16:17 +0200440 if (audio_device_->SpeakerMuteIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200441 return -1;
442 }
Max Morin787eeed2016-06-23 10:42:07 +0200443 *available = isAvailable;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100444 RTC_LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200445 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000446}
447
Max Morin787eeed2016-06-23 10:42:07 +0200448int32_t AudioDeviceModuleImpl::SetSpeakerMute(bool enable) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100449 RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200450 CHECKinitialized_();
451 return audio_device_->SetSpeakerMute(enable);
niklase@google.com470e71d2011-07-07 08:21:25 +0000452}
453
Max Morin787eeed2016-06-23 10:42:07 +0200454int32_t AudioDeviceModuleImpl::SpeakerMute(bool* enabled) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100455 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200456 CHECKinitialized_();
457 bool muted = false;
458 if (audio_device_->SpeakerMute(muted) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200459 return -1;
460 }
Max Morin787eeed2016-06-23 10:42:07 +0200461 *enabled = muted;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100462 RTC_LOG(INFO) << "output: " << muted;
henrika4af73662017-10-11 13:16:17 +0200463 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000464}
465
Max Morin787eeed2016-06-23 10:42:07 +0200466int32_t AudioDeviceModuleImpl::MicrophoneMuteIsAvailable(bool* available) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100467 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200468 CHECKinitialized_();
469 bool isAvailable = false;
470 if (audio_device_->MicrophoneMuteIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200471 return -1;
472 }
Max Morin787eeed2016-06-23 10:42:07 +0200473 *available = isAvailable;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100474 RTC_LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200475 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000476}
477
Max Morin787eeed2016-06-23 10:42:07 +0200478int32_t AudioDeviceModuleImpl::SetMicrophoneMute(bool enable) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100479 RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200480 CHECKinitialized_();
481 return (audio_device_->SetMicrophoneMute(enable));
niklase@google.com470e71d2011-07-07 08:21:25 +0000482}
483
Max Morin787eeed2016-06-23 10:42:07 +0200484int32_t AudioDeviceModuleImpl::MicrophoneMute(bool* enabled) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100485 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200486 CHECKinitialized_();
487 bool muted = false;
488 if (audio_device_->MicrophoneMute(muted) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200489 return -1;
490 }
Max Morin787eeed2016-06-23 10:42:07 +0200491 *enabled = muted;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100492 RTC_LOG(INFO) << "output: " << muted;
henrika4af73662017-10-11 13:16:17 +0200493 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000494}
495
Max Morin787eeed2016-06-23 10:42:07 +0200496int32_t AudioDeviceModuleImpl::MicrophoneVolumeIsAvailable(bool* available) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100497 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200498 CHECKinitialized_();
499 bool isAvailable = false;
500 if (audio_device_->MicrophoneVolumeIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200501 return -1;
502 }
Max Morin787eeed2016-06-23 10:42:07 +0200503 *available = isAvailable;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100504 RTC_LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200505 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000506}
507
Max Morin787eeed2016-06-23 10:42:07 +0200508int32_t AudioDeviceModuleImpl::SetMicrophoneVolume(uint32_t volume) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100509 RTC_LOG(INFO) << __FUNCTION__ << "(" << volume << ")";
henrika4af73662017-10-11 13:16:17 +0200510 CHECKinitialized_();
511 return (audio_device_->SetMicrophoneVolume(volume));
niklase@google.com470e71d2011-07-07 08:21:25 +0000512}
513
Max Morin787eeed2016-06-23 10:42:07 +0200514int32_t AudioDeviceModuleImpl::MicrophoneVolume(uint32_t* volume) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100515 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200516 CHECKinitialized_();
517 uint32_t level = 0;
518 if (audio_device_->MicrophoneVolume(level) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200519 return -1;
520 }
Max Morin787eeed2016-06-23 10:42:07 +0200521 *volume = level;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100522 RTC_LOG(INFO) << "output: " << *volume;
henrika4af73662017-10-11 13:16:17 +0200523 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000524}
525
Max Morin787eeed2016-06-23 10:42:07 +0200526int32_t AudioDeviceModuleImpl::StereoRecordingIsAvailable(
527 bool* available) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100528 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200529 CHECKinitialized_();
530 bool isAvailable = false;
531 if (audio_device_->StereoRecordingIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200532 return -1;
533 }
Max Morin787eeed2016-06-23 10:42:07 +0200534 *available = isAvailable;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100535 RTC_LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200536 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000537}
538
Max Morin787eeed2016-06-23 10:42:07 +0200539int32_t AudioDeviceModuleImpl::SetStereoRecording(bool enable) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100540 RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200541 CHECKinitialized_();
542 if (audio_device_->RecordingIsInitialized()) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100543 RTC_LOG(WARNING) << "recording in stereo is not supported";
Max Morin787eeed2016-06-23 10:42:07 +0200544 return -1;
545 }
henrika4af73662017-10-11 13:16:17 +0200546 if (audio_device_->SetStereoRecording(enable) == -1) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100547 RTC_LOG(WARNING) << "failed to change stereo recording";
Max Morin787eeed2016-06-23 10:42:07 +0200548 return -1;
549 }
Max Morin787eeed2016-06-23 10:42:07 +0200550 int8_t nChannels(1);
551 if (enable) {
552 nChannels = 2;
553 }
henrika4af73662017-10-11 13:16:17 +0200554 audio_device_buffer_.SetRecordingChannels(nChannels);
Max Morin787eeed2016-06-23 10:42:07 +0200555 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000556}
557
Max Morin787eeed2016-06-23 10:42:07 +0200558int32_t AudioDeviceModuleImpl::StereoRecording(bool* enabled) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100559 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200560 CHECKinitialized_();
561 bool stereo = false;
562 if (audio_device_->StereoRecording(stereo) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200563 return -1;
564 }
Max Morin787eeed2016-06-23 10:42:07 +0200565 *enabled = stereo;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100566 RTC_LOG(INFO) << "output: " << stereo;
henrika4af73662017-10-11 13:16:17 +0200567 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000568}
569
Max Morin787eeed2016-06-23 10:42:07 +0200570int32_t AudioDeviceModuleImpl::StereoPlayoutIsAvailable(bool* available) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100571 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200572 CHECKinitialized_();
573 bool isAvailable = false;
574 if (audio_device_->StereoPlayoutIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200575 return -1;
576 }
Max Morin787eeed2016-06-23 10:42:07 +0200577 *available = isAvailable;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100578 RTC_LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200579 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000580}
581
Max Morin787eeed2016-06-23 10:42:07 +0200582int32_t AudioDeviceModuleImpl::SetStereoPlayout(bool enable) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100583 RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200584 CHECKinitialized_();
585 if (audio_device_->PlayoutIsInitialized()) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100586 RTC_LOG(LERROR)
Max Morin098e6c52016-06-28 09:36:25 +0200587 << "unable to set stereo mode while playing side is initialized";
Max Morin787eeed2016-06-23 10:42:07 +0200588 return -1;
589 }
henrika4af73662017-10-11 13:16:17 +0200590 if (audio_device_->SetStereoPlayout(enable)) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100591 RTC_LOG(WARNING) << "stereo playout is not supported";
Max Morin787eeed2016-06-23 10:42:07 +0200592 return -1;
593 }
Max Morin787eeed2016-06-23 10:42:07 +0200594 int8_t nChannels(1);
595 if (enable) {
596 nChannels = 2;
597 }
henrika4af73662017-10-11 13:16:17 +0200598 audio_device_buffer_.SetPlayoutChannels(nChannels);
Max Morin787eeed2016-06-23 10:42:07 +0200599 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000600}
601
Max Morin787eeed2016-06-23 10:42:07 +0200602int32_t AudioDeviceModuleImpl::StereoPlayout(bool* enabled) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100603 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200604 CHECKinitialized_();
605 bool stereo = false;
606 if (audio_device_->StereoPlayout(stereo) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200607 return -1;
608 }
Max Morin787eeed2016-06-23 10:42:07 +0200609 *enabled = stereo;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100610 RTC_LOG(INFO) << "output: " << stereo;
henrika4af73662017-10-11 13:16:17 +0200611 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000612}
613
Max Morin787eeed2016-06-23 10:42:07 +0200614int32_t AudioDeviceModuleImpl::PlayoutIsAvailable(bool* available) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100615 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200616 CHECKinitialized_();
617 bool isAvailable = false;
618 if (audio_device_->PlayoutIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200619 return -1;
620 }
Max Morin787eeed2016-06-23 10:42:07 +0200621 *available = isAvailable;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100622 RTC_LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200623 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000624}
625
Max Morin787eeed2016-06-23 10:42:07 +0200626int32_t AudioDeviceModuleImpl::RecordingIsAvailable(bool* available) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100627 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200628 CHECKinitialized_();
629 bool isAvailable = false;
630 if (audio_device_->RecordingIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200631 return -1;
632 }
Max Morin787eeed2016-06-23 10:42:07 +0200633 *available = isAvailable;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100634 RTC_LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200635 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000636}
637
Max Morin787eeed2016-06-23 10:42:07 +0200638int32_t AudioDeviceModuleImpl::MaxMicrophoneVolume(uint32_t* maxVolume) const {
henrika4af73662017-10-11 13:16:17 +0200639 CHECKinitialized_();
Max Morin787eeed2016-06-23 10:42:07 +0200640 uint32_t maxVol(0);
henrika4af73662017-10-11 13:16:17 +0200641 if (audio_device_->MaxMicrophoneVolume(maxVol) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200642 return -1;
643 }
Max Morin787eeed2016-06-23 10:42:07 +0200644 *maxVolume = maxVol;
henrika4af73662017-10-11 13:16:17 +0200645 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000646}
647
Max Morin787eeed2016-06-23 10:42:07 +0200648int32_t AudioDeviceModuleImpl::MinMicrophoneVolume(uint32_t* minVolume) const {
henrika4af73662017-10-11 13:16:17 +0200649 CHECKinitialized_();
Max Morin787eeed2016-06-23 10:42:07 +0200650 uint32_t minVol(0);
henrika4af73662017-10-11 13:16:17 +0200651 if (audio_device_->MinMicrophoneVolume(minVol) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200652 return -1;
653 }
Max Morin787eeed2016-06-23 10:42:07 +0200654 *minVolume = minVol;
henrika4af73662017-10-11 13:16:17 +0200655 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000656}
657
Max Morin787eeed2016-06-23 10:42:07 +0200658int16_t AudioDeviceModuleImpl::PlayoutDevices() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100659 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200660 CHECKinitialized_();
661 uint16_t nPlayoutDevices = audio_device_->PlayoutDevices();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100662 RTC_LOG(INFO) << "output: " << nPlayoutDevices;
henrika4af73662017-10-11 13:16:17 +0200663 return (int16_t)(nPlayoutDevices);
niklase@google.com470e71d2011-07-07 08:21:25 +0000664}
665
Max Morin787eeed2016-06-23 10:42:07 +0200666int32_t AudioDeviceModuleImpl::SetPlayoutDevice(uint16_t index) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100667 RTC_LOG(INFO) << __FUNCTION__ << "(" << index << ")";
henrika4af73662017-10-11 13:16:17 +0200668 CHECKinitialized_();
669 return audio_device_->SetPlayoutDevice(index);
niklase@google.com470e71d2011-07-07 08:21:25 +0000670}
671
Max Morin787eeed2016-06-23 10:42:07 +0200672int32_t AudioDeviceModuleImpl::SetPlayoutDevice(WindowsDeviceType device) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100673 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200674 CHECKinitialized_();
675 return audio_device_->SetPlayoutDevice(device);
niklase@google.com470e71d2011-07-07 08:21:25 +0000676}
677
pbos@webrtc.org25509882013-04-09 10:30:35 +0000678int32_t AudioDeviceModuleImpl::PlayoutDeviceName(
679 uint16_t index,
leozwang@webrtc.org28f39132012-03-01 18:01:48 +0000680 char name[kAdmMaxDeviceNameSize],
Max Morin787eeed2016-06-23 10:42:07 +0200681 char guid[kAdmMaxGuidSize]) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100682 RTC_LOG(INFO) << __FUNCTION__ << "(" << index << ", ...)";
henrika4af73662017-10-11 13:16:17 +0200683 CHECKinitialized_();
Max Morin787eeed2016-06-23 10:42:07 +0200684 if (name == NULL) {
Max Morin787eeed2016-06-23 10:42:07 +0200685 return -1;
686 }
henrika4af73662017-10-11 13:16:17 +0200687 if (audio_device_->PlayoutDeviceName(index, name, guid) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200688 return -1;
689 }
Max Morin787eeed2016-06-23 10:42:07 +0200690 if (name != NULL) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100691 RTC_LOG(INFO) << "output: name = " << name;
Max Morin787eeed2016-06-23 10:42:07 +0200692 }
693 if (guid != NULL) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100694 RTC_LOG(INFO) << "output: guid = " << guid;
Max Morin787eeed2016-06-23 10:42:07 +0200695 }
henrika4af73662017-10-11 13:16:17 +0200696 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000697}
698
pbos@webrtc.org25509882013-04-09 10:30:35 +0000699int32_t AudioDeviceModuleImpl::RecordingDeviceName(
700 uint16_t index,
leozwang@webrtc.org28f39132012-03-01 18:01:48 +0000701 char name[kAdmMaxDeviceNameSize],
Max Morin787eeed2016-06-23 10:42:07 +0200702 char guid[kAdmMaxGuidSize]) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100703 RTC_LOG(INFO) << __FUNCTION__ << "(" << index << ", ...)";
henrika4af73662017-10-11 13:16:17 +0200704 CHECKinitialized_();
Max Morin787eeed2016-06-23 10:42:07 +0200705 if (name == NULL) {
Max Morin787eeed2016-06-23 10:42:07 +0200706 return -1;
707 }
henrika4af73662017-10-11 13:16:17 +0200708 if (audio_device_->RecordingDeviceName(index, name, guid) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200709 return -1;
710 }
Max Morin787eeed2016-06-23 10:42:07 +0200711 if (name != NULL) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100712 RTC_LOG(INFO) << "output: name = " << name;
Max Morin787eeed2016-06-23 10:42:07 +0200713 }
714 if (guid != NULL) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100715 RTC_LOG(INFO) << "output: guid = " << guid;
Max Morin787eeed2016-06-23 10:42:07 +0200716 }
henrika4af73662017-10-11 13:16:17 +0200717 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000718}
719
Max Morin787eeed2016-06-23 10:42:07 +0200720int16_t AudioDeviceModuleImpl::RecordingDevices() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100721 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200722 CHECKinitialized_();
723 uint16_t nRecordingDevices = audio_device_->RecordingDevices();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100724 RTC_LOG(INFO) << "output: " << nRecordingDevices;
henrika4af73662017-10-11 13:16:17 +0200725 return (int16_t)nRecordingDevices;
niklase@google.com470e71d2011-07-07 08:21:25 +0000726}
727
Max Morin787eeed2016-06-23 10:42:07 +0200728int32_t AudioDeviceModuleImpl::SetRecordingDevice(uint16_t index) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100729 RTC_LOG(INFO) << __FUNCTION__ << "(" << index << ")";
henrika4af73662017-10-11 13:16:17 +0200730 CHECKinitialized_();
731 return audio_device_->SetRecordingDevice(index);
niklase@google.com470e71d2011-07-07 08:21:25 +0000732}
733
Max Morin787eeed2016-06-23 10:42:07 +0200734int32_t AudioDeviceModuleImpl::SetRecordingDevice(WindowsDeviceType device) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100735 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200736 CHECKinitialized_();
737 return audio_device_->SetRecordingDevice(device);
niklase@google.com470e71d2011-07-07 08:21:25 +0000738}
739
Max Morin787eeed2016-06-23 10:42:07 +0200740int32_t AudioDeviceModuleImpl::InitPlayout() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100741 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200742 CHECKinitialized_();
maxmorin8c695b42016-07-25 02:46:44 -0700743 if (PlayoutIsInitialized()) {
744 return 0;
745 }
henrika4af73662017-10-11 13:16:17 +0200746 int32_t result = audio_device_->InitPlayout();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100747 RTC_LOG(INFO) << "output: " << result;
Max Morin84cab202016-07-01 13:35:19 +0200748 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.InitPlayoutSuccess",
749 static_cast<int>(result == 0));
750 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000751}
752
Max Morin787eeed2016-06-23 10:42:07 +0200753int32_t AudioDeviceModuleImpl::InitRecording() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100754 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200755 CHECKinitialized_();
maxmorin8c695b42016-07-25 02:46:44 -0700756 if (RecordingIsInitialized()) {
757 return 0;
758 }
henrika4af73662017-10-11 13:16:17 +0200759 int32_t result = audio_device_->InitRecording();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100760 RTC_LOG(INFO) << "output: " << result;
Max Morin84cab202016-07-01 13:35:19 +0200761 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.InitRecordingSuccess",
762 static_cast<int>(result == 0));
763 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000764}
765
Max Morin787eeed2016-06-23 10:42:07 +0200766bool AudioDeviceModuleImpl::PlayoutIsInitialized() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100767 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200768 CHECKinitialized__BOOL();
769 return audio_device_->PlayoutIsInitialized();
niklase@google.com470e71d2011-07-07 08:21:25 +0000770}
771
Max Morin787eeed2016-06-23 10:42:07 +0200772bool AudioDeviceModuleImpl::RecordingIsInitialized() 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_->RecordingIsInitialized();
niklase@google.com470e71d2011-07-07 08:21:25 +0000776}
777
Max Morin787eeed2016-06-23 10:42:07 +0200778int32_t AudioDeviceModuleImpl::StartPlayout() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100779 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200780 CHECKinitialized_();
maxmorin8c695b42016-07-25 02:46:44 -0700781 if (Playing()) {
782 return 0;
783 }
henrika4af73662017-10-11 13:16:17 +0200784 audio_device_buffer_.StartPlayout();
785 int32_t result = audio_device_->StartPlayout();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100786 RTC_LOG(INFO) << "output: " << result;
Max Morin84cab202016-07-01 13:35:19 +0200787 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StartPlayoutSuccess",
788 static_cast<int>(result == 0));
789 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000790}
791
Max Morin787eeed2016-06-23 10:42:07 +0200792int32_t AudioDeviceModuleImpl::StopPlayout() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100793 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200794 CHECKinitialized_();
795 int32_t result = audio_device_->StopPlayout();
796 audio_device_buffer_.StopPlayout();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100797 RTC_LOG(INFO) << "output: " << result;
Max Morin84cab202016-07-01 13:35:19 +0200798 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StopPlayoutSuccess",
799 static_cast<int>(result == 0));
800 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000801}
802
Max Morin787eeed2016-06-23 10:42:07 +0200803bool AudioDeviceModuleImpl::Playing() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100804 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200805 CHECKinitialized__BOOL();
806 return audio_device_->Playing();
niklase@google.com470e71d2011-07-07 08:21:25 +0000807}
808
Max Morin787eeed2016-06-23 10:42:07 +0200809int32_t AudioDeviceModuleImpl::StartRecording() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100810 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200811 CHECKinitialized_();
maxmorin8c695b42016-07-25 02:46:44 -0700812 if (Recording()) {
813 return 0;
814 }
henrika4af73662017-10-11 13:16:17 +0200815 audio_device_buffer_.StartRecording();
816 int32_t result = audio_device_->StartRecording();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100817 RTC_LOG(INFO) << "output: " << result;
Max Morin84cab202016-07-01 13:35:19 +0200818 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StartRecordingSuccess",
819 static_cast<int>(result == 0));
820 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000821}
niklase@google.com470e71d2011-07-07 08:21:25 +0000822
Max Morin787eeed2016-06-23 10:42:07 +0200823int32_t AudioDeviceModuleImpl::StopRecording() {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100824 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200825 CHECKinitialized_();
826 int32_t result = audio_device_->StopRecording();
827 audio_device_buffer_.StopRecording();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100828 RTC_LOG(INFO) << "output: " << result;
Max Morin84cab202016-07-01 13:35:19 +0200829 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StopRecordingSuccess",
830 static_cast<int>(result == 0));
831 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000832}
833
Max Morin787eeed2016-06-23 10:42:07 +0200834bool AudioDeviceModuleImpl::Recording() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100835 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200836 CHECKinitialized__BOOL();
837 return audio_device_->Recording();
niklase@google.com470e71d2011-07-07 08:21:25 +0000838}
839
Max Morin787eeed2016-06-23 10:42:07 +0200840int32_t AudioDeviceModuleImpl::RegisterAudioCallback(
841 AudioTransport* audioCallback) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100842 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200843 return audio_device_buffer_.RegisterAudioCallback(audioCallback);
niklase@google.com470e71d2011-07-07 08:21:25 +0000844}
845
Max Morin787eeed2016-06-23 10:42:07 +0200846int32_t AudioDeviceModuleImpl::PlayoutDelay(uint16_t* delayMS) const {
henrika4af73662017-10-11 13:16:17 +0200847 CHECKinitialized_();
848 uint16_t delay = 0;
849 if (audio_device_->PlayoutDelay(delay) == -1) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100850 RTC_LOG(LERROR) << "failed to retrieve the playout delay";
Max Morin787eeed2016-06-23 10:42:07 +0200851 return -1;
852 }
Max Morin787eeed2016-06-23 10:42:07 +0200853 *delayMS = delay;
henrika4af73662017-10-11 13:16:17 +0200854 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000855}
856
henrika@webrtc.orga954c072014-12-09 16:22:09 +0000857bool AudioDeviceModuleImpl::BuiltInAECIsAvailable() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100858 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200859 CHECKinitialized__BOOL();
860 bool isAvailable = audio_device_->BuiltInAECIsAvailable();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100861 RTC_LOG(INFO) << "output: " << isAvailable;
Max Morin098e6c52016-06-28 09:36:25 +0200862 return isAvailable;
henrika@webrtc.orga954c072014-12-09 16:22:09 +0000863}
864
henrikac14f5ff2015-09-23 14:08:33 +0200865int32_t AudioDeviceModuleImpl::EnableBuiltInAEC(bool enable) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100866 RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200867 CHECKinitialized_();
868 int32_t ok = audio_device_->EnableBuiltInAEC(enable);
Mirko Bonadei675513b2017-11-09 11:09:25 +0100869 RTC_LOG(INFO) << "output: " << ok;
Max Morin098e6c52016-06-28 09:36:25 +0200870 return ok;
henrikac14f5ff2015-09-23 14:08:33 +0200871}
872
873bool AudioDeviceModuleImpl::BuiltInAGCIsAvailable() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100874 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200875 CHECKinitialized__BOOL();
876 bool isAvailable = audio_device_->BuiltInAGCIsAvailable();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100877 RTC_LOG(INFO) << "output: " << isAvailable;
Max Morin098e6c52016-06-28 09:36:25 +0200878 return isAvailable;
henrikac14f5ff2015-09-23 14:08:33 +0200879}
880
881int32_t AudioDeviceModuleImpl::EnableBuiltInAGC(bool enable) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100882 RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200883 CHECKinitialized_();
884 int32_t ok = audio_device_->EnableBuiltInAGC(enable);
Mirko Bonadei675513b2017-11-09 11:09:25 +0100885 RTC_LOG(INFO) << "output: " << ok;
Max Morin098e6c52016-06-28 09:36:25 +0200886 return ok;
henrikac14f5ff2015-09-23 14:08:33 +0200887}
888
889bool AudioDeviceModuleImpl::BuiltInNSIsAvailable() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100890 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200891 CHECKinitialized__BOOL();
892 bool isAvailable = audio_device_->BuiltInNSIsAvailable();
Mirko Bonadei675513b2017-11-09 11:09:25 +0100893 RTC_LOG(INFO) << "output: " << isAvailable;
Max Morin098e6c52016-06-28 09:36:25 +0200894 return isAvailable;
henrikac14f5ff2015-09-23 14:08:33 +0200895}
896
897int32_t AudioDeviceModuleImpl::EnableBuiltInNS(bool enable) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100898 RTC_LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200899 CHECKinitialized_();
900 int32_t ok = audio_device_->EnableBuiltInNS(enable);
Mirko Bonadei675513b2017-11-09 11:09:25 +0100901 RTC_LOG(INFO) << "output: " << ok;
Max Morin098e6c52016-06-28 09:36:25 +0200902 return ok;
henrikac14f5ff2015-09-23 14:08:33 +0200903}
904
maxmorin88e31a32016-08-16 00:56:09 -0700905#if defined(WEBRTC_IOS)
henrikaba35d052015-07-14 17:04:08 +0200906int AudioDeviceModuleImpl::GetPlayoutAudioParameters(
907 AudioParameters* params) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100908 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200909 int r = audio_device_->GetPlayoutAudioParameters(params);
Mirko Bonadei675513b2017-11-09 11:09:25 +0100910 RTC_LOG(INFO) << "output: " << r;
Max Morin098e6c52016-06-28 09:36:25 +0200911 return r;
henrikaba35d052015-07-14 17:04:08 +0200912}
913
914int AudioDeviceModuleImpl::GetRecordAudioParameters(
915 AudioParameters* params) const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100916 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200917 int r = audio_device_->GetRecordAudioParameters(params);
Mirko Bonadei675513b2017-11-09 11:09:25 +0100918 RTC_LOG(INFO) << "output: " << r;
Max Morin098e6c52016-06-28 09:36:25 +0200919 return r;
henrikaba35d052015-07-14 17:04:08 +0200920}
maxmorin88e31a32016-08-16 00:56:09 -0700921#endif // WEBRTC_IOS
henrikaba35d052015-07-14 17:04:08 +0200922
Max Morin787eeed2016-06-23 10:42:07 +0200923AudioDeviceModuleImpl::PlatformType AudioDeviceModuleImpl::Platform() const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100924 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200925 return platform_type_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000926}
927
Max Morin787eeed2016-06-23 10:42:07 +0200928AudioDeviceModule::AudioLayer AudioDeviceModuleImpl::PlatformAudioLayer()
929 const {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100930 RTC_LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200931 return audio_layer_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000932}
933
934} // namespace webrtc