blob: 12caa2e3c409befca65772333958dc92dd403708 [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)
23#include "audio_device_core_win.h"
24#endif
leozwang@google.com39f20512011-07-15 16:29:40 +000025#elif defined(WEBRTC_ANDROID)
henrikab2619892015-05-18 16:49:16 +020026#include <stdlib.h>
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020027#include "modules/audio_device/android/audio_device_template.h"
28#include "modules/audio_device/android/audio_manager.h"
29#include "modules/audio_device/android/audio_record_jni.h"
30#include "modules/audio_device/android/audio_track_jni.h"
31#include "modules/audio_device/android/opensles_player.h"
32#include "modules/audio_device/android/opensles_recorder.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000033#elif defined(WEBRTC_LINUX)
Max Morin787eeed2016-06-23 10:42:07 +020034#if defined(LINUX_ALSA)
35#include "audio_device_alsa_linux.h"
36#endif
Tommi68898a22015-05-19 17:28:07 +020037#if defined(LINUX_PULSE)
Max Morin787eeed2016-06-23 10:42:07 +020038#include "audio_device_pulse_linux.h"
Tommi68898a22015-05-19 17:28:07 +020039#endif
sjlee@webrtc.org414fa7f2012-09-11 17:25:46 +000040#elif defined(WEBRTC_IOS)
Max Morin787eeed2016-06-23 10:42:07 +020041#include "audio_device_ios.h"
andrew@webrtc.orgf3b65db2012-09-06 18:17:00 +000042#elif defined(WEBRTC_MAC)
Max Morin787eeed2016-06-23 10:42:07 +020043#include "audio_device_mac.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000044#endif
phoglund@webrtc.org8454ad12014-06-11 14:12:04 +000045#if defined(WEBRTC_DUMMY_FILE_DEVICES)
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020046#include "modules/audio_device/dummy/file_audio_device_factory.h"
phoglund@webrtc.org8454ad12014-06-11 14:12:04 +000047#endif
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020048#include "modules/audio_device/dummy/audio_device_dummy.h"
49#include "modules/audio_device/dummy/file_audio_device.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000050
henrika4af73662017-10-11 13:16:17 +020051#define CHECKinitialized_() \
Max Morin787eeed2016-06-23 10:42:07 +020052 { \
henrika4af73662017-10-11 13:16:17 +020053 if (!initialized_) { \
Max Morin787eeed2016-06-23 10:42:07 +020054 return -1; \
55 }; \
56 }
niklase@google.com470e71d2011-07-07 08:21:25 +000057
henrika4af73662017-10-11 13:16:17 +020058#define CHECKinitialized__BOOL() \
Max Morin787eeed2016-06-23 10:42:07 +020059 { \
henrika4af73662017-10-11 13:16:17 +020060 if (!initialized_) { \
Max Morin787eeed2016-06-23 10:42:07 +020061 return false; \
62 }; \
63 }
niklase@google.com470e71d2011-07-07 08:21:25 +000064
Peter Boström1d194412016-03-21 16:44:31 +010065namespace webrtc {
henrike@webrtc.org70efc322012-02-23 17:45:33 +000066
henrika4af73662017-10-11 13:16:17 +020067// static
henrika5ff64832017-10-11 15:14:51 +020068// TODO(henrika): remove id parameter when all clients are updated.
Peter Boström4adbbcf2016-05-03 15:51:26 -040069rtc::scoped_refptr<AudioDeviceModule> AudioDeviceModule::Create(
Peter Boström1d194412016-03-21 16:44:31 +010070 const int32_t id,
Peter Boström4adbbcf2016-05-03 15:51:26 -040071 const AudioLayer audio_layer) {
Max Morin098e6c52016-06-28 09:36:25 +020072 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +020073 // Create the generic reference counted (platform independent) implementation.
Max Morin787eeed2016-06-23 10:42:07 +020074 rtc::scoped_refptr<AudioDeviceModuleImpl> audioDevice(
henrika5ff64832017-10-11 15:14:51 +020075 new rtc::RefCountedObject<AudioDeviceModuleImpl>(audio_layer));
niklase@google.com470e71d2011-07-07 08:21:25 +000076
Max Morin787eeed2016-06-23 10:42:07 +020077 // Ensure that the current platform is supported.
78 if (audioDevice->CheckPlatform() == -1) {
79 return nullptr;
80 }
niklase@google.com470e71d2011-07-07 08:21:25 +000081
Max Morin787eeed2016-06-23 10:42:07 +020082 // Create the platform-dependent implementation.
83 if (audioDevice->CreatePlatformSpecificObjects() == -1) {
84 return nullptr;
85 }
niklase@google.com470e71d2011-07-07 08:21:25 +000086
henrika4af73662017-10-11 13:16:17 +020087 // Ensure that the generic audio buffer can communicate with the platform
88 // specific parts.
Max Morin787eeed2016-06-23 10:42:07 +020089 if (audioDevice->AttachAudioBuffer() == -1) {
90 return nullptr;
91 }
niklase@google.com470e71d2011-07-07 08:21:25 +000092
Max Morin787eeed2016-06-23 10:42:07 +020093 return audioDevice;
niklase@google.com470e71d2011-07-07 08:21:25 +000094}
95
henrika5ff64832017-10-11 15:14:51 +020096AudioDeviceModuleImpl::AudioDeviceModuleImpl(const AudioLayer audioLayer)
97 : audio_layer_(audioLayer) {
Max Morin098e6c52016-06-28 09:36:25 +020098 LOG(INFO) << __FUNCTION__;
niklase@google.com470e71d2011-07-07 08:21:25 +000099}
100
Max Morin787eeed2016-06-23 10:42:07 +0200101int32_t AudioDeviceModuleImpl::CheckPlatform() {
Max Morin098e6c52016-06-28 09:36:25 +0200102 LOG(INFO) << __FUNCTION__;
Max Morin787eeed2016-06-23 10:42:07 +0200103 // Ensure that the current platform is supported
Max Morin787eeed2016-06-23 10:42:07 +0200104 PlatformType platform(kPlatformNotSupported);
niklase@google.com470e71d2011-07-07 08:21:25 +0000105#if defined(_WIN32)
Max Morin787eeed2016-06-23 10:42:07 +0200106 platform = kPlatformWin32;
Max Morin098e6c52016-06-28 09:36:25 +0200107 LOG(INFO) << "current platform is Win32";
leozwang@google.com522f42b2011-09-19 17:39:05 +0000108#elif defined(WEBRTC_ANDROID)
Max Morin787eeed2016-06-23 10:42:07 +0200109 platform = kPlatformAndroid;
Max Morin098e6c52016-06-28 09:36:25 +0200110 LOG(INFO) << "current platform is Android";
niklase@google.com470e71d2011-07-07 08:21:25 +0000111#elif defined(WEBRTC_LINUX)
Max Morin787eeed2016-06-23 10:42:07 +0200112 platform = kPlatformLinux;
Max Morin098e6c52016-06-28 09:36:25 +0200113 LOG(INFO) << "current platform is Linux";
sjlee@webrtc.org414fa7f2012-09-11 17:25:46 +0000114#elif defined(WEBRTC_IOS)
Max Morin787eeed2016-06-23 10:42:07 +0200115 platform = kPlatformIOS;
Max Morin098e6c52016-06-28 09:36:25 +0200116 LOG(INFO) << "current platform is IOS";
andrew@webrtc.orgf3b65db2012-09-06 18:17:00 +0000117#elif defined(WEBRTC_MAC)
Max Morin787eeed2016-06-23 10:42:07 +0200118 platform = kPlatformMac;
Max Morin098e6c52016-06-28 09:36:25 +0200119 LOG(INFO) << "current platform is Mac";
niklase@google.com470e71d2011-07-07 08:21:25 +0000120#endif
Max Morin787eeed2016-06-23 10:42:07 +0200121 if (platform == kPlatformNotSupported) {
Max Morin098e6c52016-06-28 09:36:25 +0200122 LOG(LERROR) << "current platform is not supported => this module will self "
123 "destruct!";
Max Morin787eeed2016-06-23 10:42:07 +0200124 return -1;
125 }
henrika4af73662017-10-11 13:16:17 +0200126 platform_type_ = platform;
Max Morin787eeed2016-06-23 10:42:07 +0200127 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000128}
129
Max Morin787eeed2016-06-23 10:42:07 +0200130int32_t AudioDeviceModuleImpl::CreatePlatformSpecificObjects() {
Max Morin098e6c52016-06-28 09:36:25 +0200131 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200132// Dummy ADM implementations if build flags are set.
xians@google.combf5d2ba2011-08-16 07:44:19 +0000133#if defined(WEBRTC_DUMMY_AUDIO_BUILD)
henrika5ff64832017-10-11 15:14:51 +0200134 audio_device_.reset(new AudioDeviceDummy());
Max Morin098e6c52016-06-28 09:36:25 +0200135 LOG(INFO) << "Dummy Audio APIs will be utilized";
phoglund@webrtc.org8454ad12014-06-11 14:12:04 +0000136#elif defined(WEBRTC_DUMMY_FILE_DEVICES)
henrika5ff64832017-10-11 15:14:51 +0200137 audio_device_.reset(FileAudioDeviceFactory::CreateFileAudioDevice());
henrika4af73662017-10-11 13:16:17 +0200138 if (audio_device_) {
noahric6a355902016-08-17 15:19:50 -0700139 LOG(INFO) << "Will use file-playing dummy device.";
140 } else {
141 // Create a dummy device instead.
henrika5ff64832017-10-11 15:14:51 +0200142 audio_device_.reset(new AudioDeviceDummy());
noahric6a355902016-08-17 15:19:50 -0700143 LOG(INFO) << "Dummy Audio APIs will be utilized";
144 }
henrika4af73662017-10-11 13:16:17 +0200145
146// Real (non-dummy) ADM implementations.
xians@google.combf5d2ba2011-08-16 07:44:19 +0000147#else
henrika4af73662017-10-11 13:16:17 +0200148 AudioLayer audio_layer(PlatformAudioLayer());
149// Windows ADM implementation.
niklase@google.com470e71d2011-07-07 08:21:25 +0000150#if defined(WEBRTC_WINDOWS_CORE_AUDIO_BUILD)
henrika4af73662017-10-11 13:16:17 +0200151 if ((audio_layer == kWindowsCoreAudio) ||
152 (audio_layer == kPlatformDefaultAudio)) {
153 LOG(INFO) << "Attempting to use the Windows Core Audio APIs...";
Max Morin787eeed2016-06-23 10:42:07 +0200154 if (AudioDeviceWindowsCore::CoreAudioIsSupported()) {
henrika4af73662017-10-11 13:16:17 +0200155 audio_device_.reset(new AudioDeviceWindowsCore());
Max Morin098e6c52016-06-28 09:36:25 +0200156 LOG(INFO) << "Windows Core Audio APIs will be utilized";
niklase@google.com470e71d2011-07-07 08:21:25 +0000157 }
Max Morin787eeed2016-06-23 10:42:07 +0200158 }
159#endif // defined(WEBRTC_WINDOWS_CORE_AUDIO_BUILD)
niklase@google.com470e71d2011-07-07 08:21:25 +0000160
henrike@webrtc.org9ee75e92013-12-11 21:42:44 +0000161#if defined(WEBRTC_ANDROID)
Max Morin787eeed2016-06-23 10:42:07 +0200162 // Create an Android audio manager.
henrika4af73662017-10-11 13:16:17 +0200163 audio_manager_android_.reset(new AudioManager());
Max Morin787eeed2016-06-23 10:42:07 +0200164 // Select best possible combination of audio layers.
henrika4af73662017-10-11 13:16:17 +0200165 if (audio_layer == kPlatformDefaultAudio) {
166 if (audio_manager_android_->IsLowLatencyPlayoutSupported() &&
167 audio_manager_android_->IsLowLatencyRecordSupported()) {
henrika918b5542016-09-19 15:44:09 +0200168 // Use OpenSL ES for both playout and recording.
henrika4af73662017-10-11 13:16:17 +0200169 audio_layer = kAndroidOpenSLESAudio;
170 } else if (audio_manager_android_->IsLowLatencyPlayoutSupported() &&
171 !audio_manager_android_->IsLowLatencyRecordSupported()) {
henrika918b5542016-09-19 15:44:09 +0200172 // Use OpenSL ES for output on devices that only supports the
Max Morin787eeed2016-06-23 10:42:07 +0200173 // low-latency output audio path.
henrika4af73662017-10-11 13:16:17 +0200174 audio_layer = kAndroidJavaInputAndOpenSLESOutputAudio;
henrikab2619892015-05-18 16:49:16 +0200175 } else {
henrika918b5542016-09-19 15:44:09 +0200176 // Use Java-based audio in both directions when low-latency output is
177 // not supported.
henrika4af73662017-10-11 13:16:17 +0200178 audio_layer = kAndroidJavaAudio;
niklase@google.com470e71d2011-07-07 08:21:25 +0000179 }
Max Morin787eeed2016-06-23 10:42:07 +0200180 }
henrika4af73662017-10-11 13:16:17 +0200181 AudioManager* audio_manager = audio_manager_android_.get();
182 if (audio_layer == kAndroidJavaAudio) {
Max Morin787eeed2016-06-23 10:42:07 +0200183 // Java audio for both input and output audio.
henrika4af73662017-10-11 13:16:17 +0200184 audio_device_.reset(new AudioDeviceTemplate<AudioRecordJni, AudioTrackJni>(
185 audio_layer, audio_manager));
186 } else if (audio_layer == kAndroidOpenSLESAudio) {
henrika918b5542016-09-19 15:44:09 +0200187 // OpenSL ES based audio for both input and output audio.
henrika4af73662017-10-11 13:16:17 +0200188 audio_device_.reset(
189 new AudioDeviceTemplate<OpenSLESRecorder, OpenSLESPlayer>(
190 audio_layer, audio_manager));
191 } else if (audio_layer == kAndroidJavaInputAndOpenSLESOutputAudio) {
Max Morin787eeed2016-06-23 10:42:07 +0200192 // Java audio for input and OpenSL ES for output audio (i.e. mixed APIs).
193 // This combination provides low-latency output audio and at the same
194 // time support for HW AEC using the AudioRecord Java API.
henrika4af73662017-10-11 13:16:17 +0200195 audio_device_.reset(new AudioDeviceTemplate<AudioRecordJni, OpenSLESPlayer>(
196 audio_layer, audio_manager));
Max Morin787eeed2016-06-23 10:42:07 +0200197 } else {
198 // Invalid audio layer.
henrika4af73662017-10-11 13:16:17 +0200199 audio_device_.reset(nullptr);
Max Morin787eeed2016-06-23 10:42:07 +0200200 }
201// END #if defined(WEBRTC_ANDROID)
niklase@google.com470e71d2011-07-07 08:21:25 +0000202
henrika4af73662017-10-11 13:16:17 +0200203// Linux ADM implementation.
niklase@google.com470e71d2011-07-07 08:21:25 +0000204#elif defined(WEBRTC_LINUX)
henrika4af73662017-10-11 13:16:17 +0200205 if ((audio_layer == kLinuxPulseAudio) ||
206 (audio_layer == kPlatformDefaultAudio)) {
niklase@google.com470e71d2011-07-07 08:21:25 +0000207#if defined(LINUX_PULSE)
henrika4af73662017-10-11 13:16:17 +0200208 LOG(INFO) << "Attempting to use Linux PulseAudio APIs...";
209 // Linux PulseAudio implementation.
210 audio_device_.reset(new AudioDeviceLinuxPulse());
henrika919dc2e2017-10-12 14:24:55 +0200211 LOG(INFO) << "Linux PulseAudio APIs will be utilized";
niklase@google.com470e71d2011-07-07 08:21:25 +0000212#endif
213#if defined(LINUX_PULSE)
Max Morin787eeed2016-06-23 10:42:07 +0200214#endif
henrika4af73662017-10-11 13:16:17 +0200215 } else if (audio_layer == kLinuxAlsaAudio) {
niklase@google.com470e71d2011-07-07 08:21:25 +0000216#if defined(LINUX_ALSA)
henrika4af73662017-10-11 13:16:17 +0200217 // Linux ALSA implementation.
218 audio_device_.reset(new AudioDeviceLinuxALSA());
219 LOG(INFO) << "Linux ALSA APIs will be utilized.";
niklase@google.com470e71d2011-07-07 08:21:25 +0000220#endif
Max Morin787eeed2016-06-23 10:42:07 +0200221 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000222#endif // #if defined(WEBRTC_LINUX)
223
henrika4af73662017-10-11 13:16:17 +0200224// iOS ADM implementation.
sjlee@webrtc.org414fa7f2012-09-11 17:25:46 +0000225#if defined(WEBRTC_IOS)
henrika4af73662017-10-11 13:16:17 +0200226 if (audio_layer == kPlatformDefaultAudio) {
227 audio_device_.reset(new AudioDeviceIOS());
228 LOG(INFO) << "iPhone Audio APIs will be utilized.";
Max Morin787eeed2016-06-23 10:42:07 +0200229 }
230// END #if defined(WEBRTC_IOS)
niklase@google.com470e71d2011-07-07 08:21:25 +0000231
henrika4af73662017-10-11 13:16:17 +0200232// Mac OS X ADM implementation.
andrew@webrtc.orgf3b65db2012-09-06 18:17:00 +0000233#elif defined(WEBRTC_MAC)
henrika4af73662017-10-11 13:16:17 +0200234 if (audio_layer == kPlatformDefaultAudio) {
235 audio_device_.reset(new AudioDeviceMac());
236 LOG(INFO) << "Mac OS X Audio APIs will be utilized.";
Max Morin787eeed2016-06-23 10:42:07 +0200237 }
andrew@webrtc.orgf3b65db2012-09-06 18:17:00 +0000238#endif // WEBRTC_MAC
niklase@google.com470e71d2011-07-07 08:21:25 +0000239
henrika4af73662017-10-11 13:16:17 +0200240 // Dummy ADM implementation.
241 if (audio_layer == kDummyAudio) {
henrika5ff64832017-10-11 15:14:51 +0200242 audio_device_.reset(new AudioDeviceDummy());
henrika4af73662017-10-11 13:16:17 +0200243 LOG(INFO) << "Dummy Audio APIs will be utilized.";
Max Morin787eeed2016-06-23 10:42:07 +0200244 }
xians@google.combf5d2ba2011-08-16 07:44:19 +0000245#endif // if defined(WEBRTC_DUMMY_AUDIO_BUILD)
niklase@google.com470e71d2011-07-07 08:21:25 +0000246
henrika4af73662017-10-11 13:16:17 +0200247 if (!audio_device_) {
248 LOG(LS_ERROR)
249 << "Failed to create the platform specific ADM implementation.";
Max Morin787eeed2016-06-23 10:42:07 +0200250 return -1;
251 }
Max Morin787eeed2016-06-23 10:42:07 +0200252 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000253}
254
Max Morin787eeed2016-06-23 10:42:07 +0200255int32_t AudioDeviceModuleImpl::AttachAudioBuffer() {
Max Morin098e6c52016-06-28 09:36:25 +0200256 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200257 audio_device_->AttachAudioBuffer(&audio_device_buffer_);
Max Morin787eeed2016-06-23 10:42:07 +0200258 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000259}
260
Max Morin787eeed2016-06-23 10:42:07 +0200261AudioDeviceModuleImpl::~AudioDeviceModuleImpl() {
Max Morin098e6c52016-06-28 09:36:25 +0200262 LOG(INFO) << __FUNCTION__;
niklase@google.com470e71d2011-07-07 08:21:25 +0000263}
264
henrikab2619892015-05-18 16:49:16 +0200265int32_t AudioDeviceModuleImpl::ActiveAudioLayer(AudioLayer* audioLayer) const {
Max Morin098e6c52016-06-28 09:36:25 +0200266 LOG(INFO) << __FUNCTION__;
henrikab2619892015-05-18 16:49:16 +0200267 AudioLayer activeAudio;
henrika4af73662017-10-11 13:16:17 +0200268 if (audio_device_->ActiveAudioLayer(activeAudio) == -1) {
henrikab2619892015-05-18 16:49:16 +0200269 return -1;
270 }
271 *audioLayer = activeAudio;
272 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000273}
274
Max Morin787eeed2016-06-23 10:42:07 +0200275int32_t AudioDeviceModuleImpl::Init() {
Max Morin098e6c52016-06-28 09:36:25 +0200276 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200277 if (initialized_)
niklase@google.com470e71d2011-07-07 08:21:25 +0000278 return 0;
henrika4af73662017-10-11 13:16:17 +0200279 RTC_CHECK(audio_device_);
280 AudioDeviceGeneric::InitStatus status = audio_device_->Init();
Max Morin84cab202016-07-01 13:35:19 +0200281 RTC_HISTOGRAM_ENUMERATION(
282 "WebRTC.Audio.InitializationResult", static_cast<int>(status),
283 static_cast<int>(AudioDeviceGeneric::InitStatus::NUM_STATUSES));
284 if (status != AudioDeviceGeneric::InitStatus::OK) {
285 LOG(LS_ERROR) << "Audio device initialization failed.";
Max Morin787eeed2016-06-23 10:42:07 +0200286 return -1;
287 }
henrika4af73662017-10-11 13:16:17 +0200288 initialized_ = true;
Max Morin787eeed2016-06-23 10:42:07 +0200289 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000290}
291
Max Morin787eeed2016-06-23 10:42:07 +0200292int32_t AudioDeviceModuleImpl::Terminate() {
Max Morin098e6c52016-06-28 09:36:25 +0200293 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200294 if (!initialized_)
niklase@google.com470e71d2011-07-07 08:21:25 +0000295 return 0;
henrika4af73662017-10-11 13:16:17 +0200296 if (audio_device_->Terminate() == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200297 return -1;
298 }
henrika4af73662017-10-11 13:16:17 +0200299 initialized_ = false;
Max Morin787eeed2016-06-23 10:42:07 +0200300 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000301}
302
Max Morin787eeed2016-06-23 10:42:07 +0200303bool AudioDeviceModuleImpl::Initialized() const {
henrika4af73662017-10-11 13:16:17 +0200304 LOG(INFO) << __FUNCTION__ << ": " << initialized_;
305 return initialized_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000306}
307
Max Morin787eeed2016-06-23 10:42:07 +0200308int32_t AudioDeviceModuleImpl::InitSpeaker() {
Max Morin098e6c52016-06-28 09:36:25 +0200309 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200310 CHECKinitialized_();
311 return audio_device_->InitSpeaker();
niklase@google.com470e71d2011-07-07 08:21:25 +0000312}
313
Max Morin787eeed2016-06-23 10:42:07 +0200314int32_t AudioDeviceModuleImpl::InitMicrophone() {
Max Morin098e6c52016-06-28 09:36:25 +0200315 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200316 CHECKinitialized_();
317 return audio_device_->InitMicrophone();
niklase@google.com470e71d2011-07-07 08:21:25 +0000318}
319
Max Morin787eeed2016-06-23 10:42:07 +0200320int32_t AudioDeviceModuleImpl::SpeakerVolumeIsAvailable(bool* available) {
Max Morin098e6c52016-06-28 09:36:25 +0200321 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200322 CHECKinitialized_();
323 bool isAvailable = false;
324 if (audio_device_->SpeakerVolumeIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200325 return -1;
326 }
Max Morin787eeed2016-06-23 10:42:07 +0200327 *available = isAvailable;
Max Morin2c332bb2016-07-04 09:03:42 +0200328 LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200329 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000330}
331
Max Morin787eeed2016-06-23 10:42:07 +0200332int32_t AudioDeviceModuleImpl::SetSpeakerVolume(uint32_t volume) {
Max Morin098e6c52016-06-28 09:36:25 +0200333 LOG(INFO) << __FUNCTION__ << "(" << volume << ")";
henrika4af73662017-10-11 13:16:17 +0200334 CHECKinitialized_();
335 return audio_device_->SetSpeakerVolume(volume);
niklase@google.com470e71d2011-07-07 08:21:25 +0000336}
337
Max Morin787eeed2016-06-23 10:42:07 +0200338int32_t AudioDeviceModuleImpl::SpeakerVolume(uint32_t* volume) const {
Max Morin098e6c52016-06-28 09:36:25 +0200339 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200340 CHECKinitialized_();
341 uint32_t level = 0;
342 if (audio_device_->SpeakerVolume(level) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200343 return -1;
344 }
Max Morin787eeed2016-06-23 10:42:07 +0200345 *volume = level;
Max Morin2c332bb2016-07-04 09:03:42 +0200346 LOG(INFO) << "output: " << *volume;
henrika4af73662017-10-11 13:16:17 +0200347 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000348}
349
Max Morin787eeed2016-06-23 10:42:07 +0200350bool AudioDeviceModuleImpl::SpeakerIsInitialized() const {
Max Morin098e6c52016-06-28 09:36:25 +0200351 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200352 CHECKinitialized__BOOL();
353 bool isInitialized = audio_device_->SpeakerIsInitialized();
Max Morin2c332bb2016-07-04 09:03:42 +0200354 LOG(INFO) << "output: " << isInitialized;
henrika4af73662017-10-11 13:16:17 +0200355 return isInitialized;
niklase@google.com470e71d2011-07-07 08:21:25 +0000356}
357
Max Morin787eeed2016-06-23 10:42:07 +0200358bool AudioDeviceModuleImpl::MicrophoneIsInitialized() const {
Max Morin098e6c52016-06-28 09:36:25 +0200359 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200360 CHECKinitialized__BOOL();
361 bool isInitialized = audio_device_->MicrophoneIsInitialized();
Max Morin2c332bb2016-07-04 09:03:42 +0200362 LOG(INFO) << "output: " << isInitialized;
henrika4af73662017-10-11 13:16:17 +0200363 return isInitialized;
niklase@google.com470e71d2011-07-07 08:21:25 +0000364}
365
Max Morin787eeed2016-06-23 10:42:07 +0200366int32_t AudioDeviceModuleImpl::MaxSpeakerVolume(uint32_t* maxVolume) const {
henrika4af73662017-10-11 13:16:17 +0200367 CHECKinitialized_();
368 uint32_t maxVol = 0;
369 if (audio_device_->MaxSpeakerVolume(maxVol) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200370 return -1;
371 }
Max Morin787eeed2016-06-23 10:42:07 +0200372 *maxVolume = maxVol;
henrika4af73662017-10-11 13:16:17 +0200373 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000374}
375
Max Morin787eeed2016-06-23 10:42:07 +0200376int32_t AudioDeviceModuleImpl::MinSpeakerVolume(uint32_t* minVolume) const {
henrika4af73662017-10-11 13:16:17 +0200377 CHECKinitialized_();
378 uint32_t minVol = 0;
379 if (audio_device_->MinSpeakerVolume(minVol) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200380 return -1;
381 }
Max Morin787eeed2016-06-23 10:42:07 +0200382 *minVolume = minVol;
henrika4af73662017-10-11 13:16:17 +0200383 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000384}
385
Max Morin787eeed2016-06-23 10:42:07 +0200386int32_t AudioDeviceModuleImpl::SpeakerMuteIsAvailable(bool* available) {
Max Morin098e6c52016-06-28 09:36:25 +0200387 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200388 CHECKinitialized_();
389 bool isAvailable = false;
390 if (audio_device_->SpeakerMuteIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200391 return -1;
392 }
Max Morin787eeed2016-06-23 10:42:07 +0200393 *available = isAvailable;
Max Morin2c332bb2016-07-04 09:03:42 +0200394 LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200395 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000396}
397
Max Morin787eeed2016-06-23 10:42:07 +0200398int32_t AudioDeviceModuleImpl::SetSpeakerMute(bool enable) {
Max Morin098e6c52016-06-28 09:36:25 +0200399 LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200400 CHECKinitialized_();
401 return audio_device_->SetSpeakerMute(enable);
niklase@google.com470e71d2011-07-07 08:21:25 +0000402}
403
Max Morin787eeed2016-06-23 10:42:07 +0200404int32_t AudioDeviceModuleImpl::SpeakerMute(bool* enabled) const {
Max Morin098e6c52016-06-28 09:36:25 +0200405 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200406 CHECKinitialized_();
407 bool muted = false;
408 if (audio_device_->SpeakerMute(muted) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200409 return -1;
410 }
Max Morin787eeed2016-06-23 10:42:07 +0200411 *enabled = muted;
Max Morin2c332bb2016-07-04 09:03:42 +0200412 LOG(INFO) << "output: " << muted;
henrika4af73662017-10-11 13:16:17 +0200413 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000414}
415
Max Morin787eeed2016-06-23 10:42:07 +0200416int32_t AudioDeviceModuleImpl::MicrophoneMuteIsAvailable(bool* available) {
Max Morin098e6c52016-06-28 09:36:25 +0200417 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200418 CHECKinitialized_();
419 bool isAvailable = false;
420 if (audio_device_->MicrophoneMuteIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200421 return -1;
422 }
Max Morin787eeed2016-06-23 10:42:07 +0200423 *available = isAvailable;
Max Morin2c332bb2016-07-04 09:03:42 +0200424 LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200425 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000426}
427
Max Morin787eeed2016-06-23 10:42:07 +0200428int32_t AudioDeviceModuleImpl::SetMicrophoneMute(bool enable) {
Max Morin098e6c52016-06-28 09:36:25 +0200429 LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200430 CHECKinitialized_();
431 return (audio_device_->SetMicrophoneMute(enable));
niklase@google.com470e71d2011-07-07 08:21:25 +0000432}
433
Max Morin787eeed2016-06-23 10:42:07 +0200434int32_t AudioDeviceModuleImpl::MicrophoneMute(bool* enabled) const {
Max Morin098e6c52016-06-28 09:36:25 +0200435 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200436 CHECKinitialized_();
437 bool muted = false;
438 if (audio_device_->MicrophoneMute(muted) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200439 return -1;
440 }
Max Morin787eeed2016-06-23 10:42:07 +0200441 *enabled = muted;
Max Morin2c332bb2016-07-04 09:03:42 +0200442 LOG(INFO) << "output: " << muted;
henrika4af73662017-10-11 13:16:17 +0200443 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000444}
445
Max Morin787eeed2016-06-23 10:42:07 +0200446int32_t AudioDeviceModuleImpl::MicrophoneVolumeIsAvailable(bool* available) {
Max Morin098e6c52016-06-28 09:36:25 +0200447 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200448 CHECKinitialized_();
449 bool isAvailable = false;
450 if (audio_device_->MicrophoneVolumeIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200451 return -1;
452 }
Max Morin787eeed2016-06-23 10:42:07 +0200453 *available = isAvailable;
Max Morin2c332bb2016-07-04 09:03:42 +0200454 LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200455 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000456}
457
Max Morin787eeed2016-06-23 10:42:07 +0200458int32_t AudioDeviceModuleImpl::SetMicrophoneVolume(uint32_t volume) {
Max Morin098e6c52016-06-28 09:36:25 +0200459 LOG(INFO) << __FUNCTION__ << "(" << volume << ")";
henrika4af73662017-10-11 13:16:17 +0200460 CHECKinitialized_();
461 return (audio_device_->SetMicrophoneVolume(volume));
niklase@google.com470e71d2011-07-07 08:21:25 +0000462}
463
Max Morin787eeed2016-06-23 10:42:07 +0200464int32_t AudioDeviceModuleImpl::MicrophoneVolume(uint32_t* volume) const {
Max Morin098e6c52016-06-28 09:36:25 +0200465 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200466 CHECKinitialized_();
467 uint32_t level = 0;
468 if (audio_device_->MicrophoneVolume(level) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200469 return -1;
470 }
Max Morin787eeed2016-06-23 10:42:07 +0200471 *volume = level;
Max Morin2c332bb2016-07-04 09:03:42 +0200472 LOG(INFO) << "output: " << *volume;
henrika4af73662017-10-11 13:16:17 +0200473 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000474}
475
Max Morin787eeed2016-06-23 10:42:07 +0200476int32_t AudioDeviceModuleImpl::StereoRecordingIsAvailable(
477 bool* available) const {
Max Morin098e6c52016-06-28 09:36:25 +0200478 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200479 CHECKinitialized_();
480 bool isAvailable = false;
481 if (audio_device_->StereoRecordingIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200482 return -1;
483 }
Max Morin787eeed2016-06-23 10:42:07 +0200484 *available = isAvailable;
Max Morin2c332bb2016-07-04 09:03:42 +0200485 LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200486 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000487}
488
Max Morin787eeed2016-06-23 10:42:07 +0200489int32_t AudioDeviceModuleImpl::SetStereoRecording(bool enable) {
Max Morin098e6c52016-06-28 09:36:25 +0200490 LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200491 CHECKinitialized_();
492 if (audio_device_->RecordingIsInitialized()) {
Max Morin098e6c52016-06-28 09:36:25 +0200493 LOG(WARNING) << "recording in stereo is not supported";
Max Morin787eeed2016-06-23 10:42:07 +0200494 return -1;
495 }
henrika4af73662017-10-11 13:16:17 +0200496 if (audio_device_->SetStereoRecording(enable) == -1) {
Max Morin2c332bb2016-07-04 09:03:42 +0200497 LOG(WARNING) << "failed to change stereo recording";
Max Morin787eeed2016-06-23 10:42:07 +0200498 return -1;
499 }
Max Morin787eeed2016-06-23 10:42:07 +0200500 int8_t nChannels(1);
501 if (enable) {
502 nChannels = 2;
503 }
henrika4af73662017-10-11 13:16:17 +0200504 audio_device_buffer_.SetRecordingChannels(nChannels);
Max Morin787eeed2016-06-23 10:42:07 +0200505 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000506}
507
Max Morin787eeed2016-06-23 10:42:07 +0200508int32_t AudioDeviceModuleImpl::StereoRecording(bool* enabled) const {
Max Morin098e6c52016-06-28 09:36:25 +0200509 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200510 CHECKinitialized_();
511 bool stereo = false;
512 if (audio_device_->StereoRecording(stereo) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200513 return -1;
514 }
Max Morin787eeed2016-06-23 10:42:07 +0200515 *enabled = stereo;
Max Morin2c332bb2016-07-04 09:03:42 +0200516 LOG(INFO) << "output: " << stereo;
henrika4af73662017-10-11 13:16:17 +0200517 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000518}
519
Max Morin787eeed2016-06-23 10:42:07 +0200520int32_t AudioDeviceModuleImpl::SetRecordingChannel(const ChannelType channel) {
521 if (channel == kChannelBoth) {
Max Morin098e6c52016-06-28 09:36:25 +0200522 LOG(INFO) << __FUNCTION__ << "(both)";
Max Morin787eeed2016-06-23 10:42:07 +0200523 } else if (channel == kChannelLeft) {
Max Morin098e6c52016-06-28 09:36:25 +0200524 LOG(INFO) << __FUNCTION__ << "(left)";
Max Morin787eeed2016-06-23 10:42:07 +0200525 } else {
Max Morin098e6c52016-06-28 09:36:25 +0200526 LOG(INFO) << __FUNCTION__ << "(right)";
Max Morin787eeed2016-06-23 10:42:07 +0200527 }
henrika4af73662017-10-11 13:16:17 +0200528 CHECKinitialized_();
529 bool stereo = false;
530 if (audio_device_->StereoRecording(stereo) == -1) {
Max Morin098e6c52016-06-28 09:36:25 +0200531 LOG(WARNING) << "recording in stereo is not supported";
Max Morin787eeed2016-06-23 10:42:07 +0200532 return -1;
533 }
henrika4af73662017-10-11 13:16:17 +0200534 return audio_device_buffer_.SetRecordingChannel(channel);
niklase@google.com470e71d2011-07-07 08:21:25 +0000535}
536
Max Morin787eeed2016-06-23 10:42:07 +0200537int32_t AudioDeviceModuleImpl::RecordingChannel(ChannelType* channel) const {
Max Morin098e6c52016-06-28 09:36:25 +0200538 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200539 CHECKinitialized_();
Max Morin787eeed2016-06-23 10:42:07 +0200540 ChannelType chType;
henrika4af73662017-10-11 13:16:17 +0200541 if (audio_device_buffer_.RecordingChannel(chType) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200542 return -1;
543 }
Max Morin787eeed2016-06-23 10:42:07 +0200544 *channel = chType;
Max Morin787eeed2016-06-23 10:42:07 +0200545 if (*channel == kChannelBoth) {
Max Morin2c332bb2016-07-04 09:03:42 +0200546 LOG(INFO) << "output: both";
Max Morin787eeed2016-06-23 10:42:07 +0200547 } else if (*channel == kChannelLeft) {
Max Morin2c332bb2016-07-04 09:03:42 +0200548 LOG(INFO) << "output: left";
Max Morin787eeed2016-06-23 10:42:07 +0200549 } else {
Max Morin2c332bb2016-07-04 09:03:42 +0200550 LOG(INFO) << "output: right";
Max Morin787eeed2016-06-23 10:42:07 +0200551 }
henrika4af73662017-10-11 13:16:17 +0200552 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000553}
554
Max Morin787eeed2016-06-23 10:42:07 +0200555int32_t AudioDeviceModuleImpl::StereoPlayoutIsAvailable(bool* available) const {
Max Morin098e6c52016-06-28 09:36:25 +0200556 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200557 CHECKinitialized_();
558 bool isAvailable = false;
559 if (audio_device_->StereoPlayoutIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200560 return -1;
561 }
Max Morin787eeed2016-06-23 10:42:07 +0200562 *available = isAvailable;
Max Morin2c332bb2016-07-04 09:03:42 +0200563 LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200564 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000565}
566
Max Morin787eeed2016-06-23 10:42:07 +0200567int32_t AudioDeviceModuleImpl::SetStereoPlayout(bool enable) {
Max Morin098e6c52016-06-28 09:36:25 +0200568 LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200569 CHECKinitialized_();
570 if (audio_device_->PlayoutIsInitialized()) {
Max Morin098e6c52016-06-28 09:36:25 +0200571 LOG(LERROR)
572 << "unable to set stereo mode while playing side is initialized";
Max Morin787eeed2016-06-23 10:42:07 +0200573 return -1;
574 }
henrika4af73662017-10-11 13:16:17 +0200575 if (audio_device_->SetStereoPlayout(enable)) {
Max Morin098e6c52016-06-28 09:36:25 +0200576 LOG(WARNING) << "stereo playout is not supported";
Max Morin787eeed2016-06-23 10:42:07 +0200577 return -1;
578 }
Max Morin787eeed2016-06-23 10:42:07 +0200579 int8_t nChannels(1);
580 if (enable) {
581 nChannels = 2;
582 }
henrika4af73662017-10-11 13:16:17 +0200583 audio_device_buffer_.SetPlayoutChannels(nChannels);
Max Morin787eeed2016-06-23 10:42:07 +0200584 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000585}
586
Max Morin787eeed2016-06-23 10:42:07 +0200587int32_t AudioDeviceModuleImpl::StereoPlayout(bool* enabled) const {
Max Morin098e6c52016-06-28 09:36:25 +0200588 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200589 CHECKinitialized_();
590 bool stereo = false;
591 if (audio_device_->StereoPlayout(stereo) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200592 return -1;
593 }
Max Morin787eeed2016-06-23 10:42:07 +0200594 *enabled = stereo;
Max Morin2c332bb2016-07-04 09:03:42 +0200595 LOG(INFO) << "output: " << stereo;
henrika4af73662017-10-11 13:16:17 +0200596 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000597}
598
Max Morin787eeed2016-06-23 10:42:07 +0200599int32_t AudioDeviceModuleImpl::SetAGC(bool enable) {
Max Morin098e6c52016-06-28 09:36:25 +0200600 LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200601 CHECKinitialized_();
602 return (audio_device_->SetAGC(enable));
niklase@google.com470e71d2011-07-07 08:21:25 +0000603}
604
Max Morin787eeed2016-06-23 10:42:07 +0200605bool AudioDeviceModuleImpl::AGC() const {
Max Morin098e6c52016-06-28 09:36:25 +0200606 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200607 CHECKinitialized__BOOL();
608 return audio_device_->AGC();
niklase@google.com470e71d2011-07-07 08:21:25 +0000609}
610
Max Morin787eeed2016-06-23 10:42:07 +0200611int32_t AudioDeviceModuleImpl::PlayoutIsAvailable(bool* available) {
Max Morin098e6c52016-06-28 09:36:25 +0200612 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200613 CHECKinitialized_();
614 bool isAvailable = false;
615 if (audio_device_->PlayoutIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200616 return -1;
617 }
Max Morin787eeed2016-06-23 10:42:07 +0200618 *available = isAvailable;
Max Morin2c332bb2016-07-04 09:03:42 +0200619 LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200620 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000621}
622
Max Morin787eeed2016-06-23 10:42:07 +0200623int32_t AudioDeviceModuleImpl::RecordingIsAvailable(bool* available) {
Max Morin098e6c52016-06-28 09:36:25 +0200624 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200625 CHECKinitialized_();
626 bool isAvailable = false;
627 if (audio_device_->RecordingIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200628 return -1;
629 }
Max Morin787eeed2016-06-23 10:42:07 +0200630 *available = isAvailable;
Max Morin2c332bb2016-07-04 09:03:42 +0200631 LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200632 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000633}
634
Max Morin787eeed2016-06-23 10:42:07 +0200635int32_t AudioDeviceModuleImpl::MaxMicrophoneVolume(uint32_t* maxVolume) const {
henrika4af73662017-10-11 13:16:17 +0200636 CHECKinitialized_();
Max Morin787eeed2016-06-23 10:42:07 +0200637 uint32_t maxVol(0);
henrika4af73662017-10-11 13:16:17 +0200638 if (audio_device_->MaxMicrophoneVolume(maxVol) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200639 return -1;
640 }
Max Morin787eeed2016-06-23 10:42:07 +0200641 *maxVolume = maxVol;
henrika4af73662017-10-11 13:16:17 +0200642 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000643}
644
Max Morin787eeed2016-06-23 10:42:07 +0200645int32_t AudioDeviceModuleImpl::MinMicrophoneVolume(uint32_t* minVolume) const {
henrika4af73662017-10-11 13:16:17 +0200646 CHECKinitialized_();
Max Morin787eeed2016-06-23 10:42:07 +0200647 uint32_t minVol(0);
henrika4af73662017-10-11 13:16:17 +0200648 if (audio_device_->MinMicrophoneVolume(minVol) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200649 return -1;
650 }
Max Morin787eeed2016-06-23 10:42:07 +0200651 *minVolume = minVol;
henrika4af73662017-10-11 13:16:17 +0200652 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000653}
654
Max Morin787eeed2016-06-23 10:42:07 +0200655int16_t AudioDeviceModuleImpl::PlayoutDevices() {
Max Morin098e6c52016-06-28 09:36:25 +0200656 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200657 CHECKinitialized_();
658 uint16_t nPlayoutDevices = audio_device_->PlayoutDevices();
Max Morin2c332bb2016-07-04 09:03:42 +0200659 LOG(INFO) << "output: " << nPlayoutDevices;
henrika4af73662017-10-11 13:16:17 +0200660 return (int16_t)(nPlayoutDevices);
niklase@google.com470e71d2011-07-07 08:21:25 +0000661}
662
Max Morin787eeed2016-06-23 10:42:07 +0200663int32_t AudioDeviceModuleImpl::SetPlayoutDevice(uint16_t index) {
Max Morin098e6c52016-06-28 09:36:25 +0200664 LOG(INFO) << __FUNCTION__ << "(" << index << ")";
henrika4af73662017-10-11 13:16:17 +0200665 CHECKinitialized_();
666 return audio_device_->SetPlayoutDevice(index);
niklase@google.com470e71d2011-07-07 08:21:25 +0000667}
668
Max Morin787eeed2016-06-23 10:42:07 +0200669int32_t AudioDeviceModuleImpl::SetPlayoutDevice(WindowsDeviceType device) {
Max Morin098e6c52016-06-28 09:36:25 +0200670 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200671 CHECKinitialized_();
672 return audio_device_->SetPlayoutDevice(device);
niklase@google.com470e71d2011-07-07 08:21:25 +0000673}
674
pbos@webrtc.org25509882013-04-09 10:30:35 +0000675int32_t AudioDeviceModuleImpl::PlayoutDeviceName(
676 uint16_t index,
leozwang@webrtc.org28f39132012-03-01 18:01:48 +0000677 char name[kAdmMaxDeviceNameSize],
Max Morin787eeed2016-06-23 10:42:07 +0200678 char guid[kAdmMaxGuidSize]) {
Max Morin098e6c52016-06-28 09:36:25 +0200679 LOG(INFO) << __FUNCTION__ << "(" << index << ", ...)";
henrika4af73662017-10-11 13:16:17 +0200680 CHECKinitialized_();
Max Morin787eeed2016-06-23 10:42:07 +0200681 if (name == NULL) {
Max Morin787eeed2016-06-23 10:42:07 +0200682 return -1;
683 }
henrika4af73662017-10-11 13:16:17 +0200684 if (audio_device_->PlayoutDeviceName(index, name, guid) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200685 return -1;
686 }
Max Morin787eeed2016-06-23 10:42:07 +0200687 if (name != NULL) {
Max Morin2c332bb2016-07-04 09:03:42 +0200688 LOG(INFO) << "output: name = " << name;
Max Morin787eeed2016-06-23 10:42:07 +0200689 }
690 if (guid != NULL) {
Max Morin2c332bb2016-07-04 09:03:42 +0200691 LOG(INFO) << "output: guid = " << guid;
Max Morin787eeed2016-06-23 10:42:07 +0200692 }
henrika4af73662017-10-11 13:16:17 +0200693 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000694}
695
pbos@webrtc.org25509882013-04-09 10:30:35 +0000696int32_t AudioDeviceModuleImpl::RecordingDeviceName(
697 uint16_t index,
leozwang@webrtc.org28f39132012-03-01 18:01:48 +0000698 char name[kAdmMaxDeviceNameSize],
Max Morin787eeed2016-06-23 10:42:07 +0200699 char guid[kAdmMaxGuidSize]) {
Max Morin098e6c52016-06-28 09:36:25 +0200700 LOG(INFO) << __FUNCTION__ << "(" << index << ", ...)";
henrika4af73662017-10-11 13:16:17 +0200701 CHECKinitialized_();
Max Morin787eeed2016-06-23 10:42:07 +0200702 if (name == NULL) {
Max Morin787eeed2016-06-23 10:42:07 +0200703 return -1;
704 }
henrika4af73662017-10-11 13:16:17 +0200705 if (audio_device_->RecordingDeviceName(index, name, guid) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200706 return -1;
707 }
Max Morin787eeed2016-06-23 10:42:07 +0200708 if (name != NULL) {
Max Morin2c332bb2016-07-04 09:03:42 +0200709 LOG(INFO) << "output: name = " << name;
Max Morin787eeed2016-06-23 10:42:07 +0200710 }
711 if (guid != NULL) {
Max Morin2c332bb2016-07-04 09:03:42 +0200712 LOG(INFO) << "output: guid = " << guid;
Max Morin787eeed2016-06-23 10:42:07 +0200713 }
henrika4af73662017-10-11 13:16:17 +0200714 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000715}
716
Max Morin787eeed2016-06-23 10:42:07 +0200717int16_t AudioDeviceModuleImpl::RecordingDevices() {
Max Morin098e6c52016-06-28 09:36:25 +0200718 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200719 CHECKinitialized_();
720 uint16_t nRecordingDevices = audio_device_->RecordingDevices();
Max Morin2c332bb2016-07-04 09:03:42 +0200721 LOG(INFO) << "output: " << nRecordingDevices;
henrika4af73662017-10-11 13:16:17 +0200722 return (int16_t)nRecordingDevices;
niklase@google.com470e71d2011-07-07 08:21:25 +0000723}
724
Max Morin787eeed2016-06-23 10:42:07 +0200725int32_t AudioDeviceModuleImpl::SetRecordingDevice(uint16_t index) {
Max Morin098e6c52016-06-28 09:36:25 +0200726 LOG(INFO) << __FUNCTION__ << "(" << index << ")";
henrika4af73662017-10-11 13:16:17 +0200727 CHECKinitialized_();
728 return audio_device_->SetRecordingDevice(index);
niklase@google.com470e71d2011-07-07 08:21:25 +0000729}
730
Max Morin787eeed2016-06-23 10:42:07 +0200731int32_t AudioDeviceModuleImpl::SetRecordingDevice(WindowsDeviceType device) {
Max Morin098e6c52016-06-28 09:36:25 +0200732 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200733 CHECKinitialized_();
734 return audio_device_->SetRecordingDevice(device);
niklase@google.com470e71d2011-07-07 08:21:25 +0000735}
736
Max Morin787eeed2016-06-23 10:42:07 +0200737int32_t AudioDeviceModuleImpl::InitPlayout() {
Max Morin098e6c52016-06-28 09:36:25 +0200738 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200739 CHECKinitialized_();
maxmorin8c695b42016-07-25 02:46:44 -0700740 if (PlayoutIsInitialized()) {
741 return 0;
742 }
henrika4af73662017-10-11 13:16:17 +0200743 int32_t result = audio_device_->InitPlayout();
Max Morin84cab202016-07-01 13:35:19 +0200744 LOG(INFO) << "output: " << result;
745 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.InitPlayoutSuccess",
746 static_cast<int>(result == 0));
747 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000748}
749
Max Morin787eeed2016-06-23 10:42:07 +0200750int32_t AudioDeviceModuleImpl::InitRecording() {
Max Morin098e6c52016-06-28 09:36:25 +0200751 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200752 CHECKinitialized_();
maxmorin8c695b42016-07-25 02:46:44 -0700753 if (RecordingIsInitialized()) {
754 return 0;
755 }
henrika4af73662017-10-11 13:16:17 +0200756 int32_t result = audio_device_->InitRecording();
Max Morin84cab202016-07-01 13:35:19 +0200757 LOG(INFO) << "output: " << result;
758 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.InitRecordingSuccess",
759 static_cast<int>(result == 0));
760 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000761}
762
Max Morin787eeed2016-06-23 10:42:07 +0200763bool AudioDeviceModuleImpl::PlayoutIsInitialized() const {
Max Morin098e6c52016-06-28 09:36:25 +0200764 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200765 CHECKinitialized__BOOL();
766 return audio_device_->PlayoutIsInitialized();
niklase@google.com470e71d2011-07-07 08:21:25 +0000767}
768
Max Morin787eeed2016-06-23 10:42:07 +0200769bool AudioDeviceModuleImpl::RecordingIsInitialized() const {
Max Morin098e6c52016-06-28 09:36:25 +0200770 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200771 CHECKinitialized__BOOL();
772 return audio_device_->RecordingIsInitialized();
niklase@google.com470e71d2011-07-07 08:21:25 +0000773}
774
Max Morin787eeed2016-06-23 10:42:07 +0200775int32_t AudioDeviceModuleImpl::StartPlayout() {
Max Morin098e6c52016-06-28 09:36:25 +0200776 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200777 CHECKinitialized_();
maxmorin8c695b42016-07-25 02:46:44 -0700778 if (Playing()) {
779 return 0;
780 }
henrika4af73662017-10-11 13:16:17 +0200781 audio_device_buffer_.StartPlayout();
782 int32_t result = audio_device_->StartPlayout();
Max Morin84cab202016-07-01 13:35:19 +0200783 LOG(INFO) << "output: " << result;
784 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StartPlayoutSuccess",
785 static_cast<int>(result == 0));
786 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000787}
788
Max Morin787eeed2016-06-23 10:42:07 +0200789int32_t AudioDeviceModuleImpl::StopPlayout() {
Max Morin098e6c52016-06-28 09:36:25 +0200790 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200791 CHECKinitialized_();
792 int32_t result = audio_device_->StopPlayout();
793 audio_device_buffer_.StopPlayout();
Max Morin84cab202016-07-01 13:35:19 +0200794 LOG(INFO) << "output: " << result;
795 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StopPlayoutSuccess",
796 static_cast<int>(result == 0));
797 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000798}
799
Max Morin787eeed2016-06-23 10:42:07 +0200800bool AudioDeviceModuleImpl::Playing() const {
Max Morin098e6c52016-06-28 09:36:25 +0200801 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200802 CHECKinitialized__BOOL();
803 return audio_device_->Playing();
niklase@google.com470e71d2011-07-07 08:21:25 +0000804}
805
Max Morin787eeed2016-06-23 10:42:07 +0200806int32_t AudioDeviceModuleImpl::StartRecording() {
Max Morin098e6c52016-06-28 09:36:25 +0200807 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200808 CHECKinitialized_();
maxmorin8c695b42016-07-25 02:46:44 -0700809 if (Recording()) {
810 return 0;
811 }
henrika4af73662017-10-11 13:16:17 +0200812 audio_device_buffer_.StartRecording();
813 int32_t result = audio_device_->StartRecording();
Max Morin84cab202016-07-01 13:35:19 +0200814 LOG(INFO) << "output: " << result;
815 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StartRecordingSuccess",
816 static_cast<int>(result == 0));
817 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000818}
niklase@google.com470e71d2011-07-07 08:21:25 +0000819
Max Morin787eeed2016-06-23 10:42:07 +0200820int32_t AudioDeviceModuleImpl::StopRecording() {
Max Morin098e6c52016-06-28 09:36:25 +0200821 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200822 CHECKinitialized_();
823 int32_t result = audio_device_->StopRecording();
824 audio_device_buffer_.StopRecording();
Max Morin84cab202016-07-01 13:35:19 +0200825 LOG(INFO) << "output: " << result;
826 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StopRecordingSuccess",
827 static_cast<int>(result == 0));
828 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000829}
830
Max Morin787eeed2016-06-23 10:42:07 +0200831bool AudioDeviceModuleImpl::Recording() const {
Max Morin098e6c52016-06-28 09:36:25 +0200832 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200833 CHECKinitialized__BOOL();
834 return audio_device_->Recording();
niklase@google.com470e71d2011-07-07 08:21:25 +0000835}
836
Max Morin787eeed2016-06-23 10:42:07 +0200837int32_t AudioDeviceModuleImpl::RegisterAudioCallback(
838 AudioTransport* audioCallback) {
Max Morin098e6c52016-06-28 09:36:25 +0200839 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200840 return audio_device_buffer_.RegisterAudioCallback(audioCallback);
niklase@google.com470e71d2011-07-07 08:21:25 +0000841}
842
Max Morin787eeed2016-06-23 10:42:07 +0200843int32_t AudioDeviceModuleImpl::PlayoutDelay(uint16_t* delayMS) const {
henrika4af73662017-10-11 13:16:17 +0200844 CHECKinitialized_();
845 uint16_t delay = 0;
846 if (audio_device_->PlayoutDelay(delay) == -1) {
Max Morin098e6c52016-06-28 09:36:25 +0200847 LOG(LERROR) << "failed to retrieve the playout delay";
Max Morin787eeed2016-06-23 10:42:07 +0200848 return -1;
849 }
Max Morin787eeed2016-06-23 10:42:07 +0200850 *delayMS = delay;
henrika4af73662017-10-11 13:16:17 +0200851 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000852}
853
Max Morin787eeed2016-06-23 10:42:07 +0200854int32_t AudioDeviceModuleImpl::SetRecordingSampleRate(
855 const uint32_t samplesPerSec) {
Max Morin098e6c52016-06-28 09:36:25 +0200856 LOG(INFO) << __FUNCTION__ << "(" << samplesPerSec << ")";
henrika4af73662017-10-11 13:16:17 +0200857 CHECKinitialized_();
858 if (audio_device_->SetRecordingSampleRate(samplesPerSec) != 0) {
Max Morin787eeed2016-06-23 10:42:07 +0200859 return -1;
860 }
henrika4af73662017-10-11 13:16:17 +0200861 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000862}
863
Max Morin787eeed2016-06-23 10:42:07 +0200864int32_t AudioDeviceModuleImpl::RecordingSampleRate(
865 uint32_t* samplesPerSec) const {
Max Morin098e6c52016-06-28 09:36:25 +0200866 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200867 CHECKinitialized_();
868 int32_t sampleRate = audio_device_buffer_.RecordingSampleRate();
Max Morin787eeed2016-06-23 10:42:07 +0200869 if (sampleRate == -1) {
Max Morin098e6c52016-06-28 09:36:25 +0200870 LOG(LERROR) << "failed to retrieve the sample rate";
Max Morin787eeed2016-06-23 10:42:07 +0200871 return -1;
872 }
Max Morin787eeed2016-06-23 10:42:07 +0200873 *samplesPerSec = sampleRate;
Max Morin2c332bb2016-07-04 09:03:42 +0200874 LOG(INFO) << "output: " << *samplesPerSec;
henrika4af73662017-10-11 13:16:17 +0200875 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000876}
877
Max Morin787eeed2016-06-23 10:42:07 +0200878int32_t AudioDeviceModuleImpl::SetPlayoutSampleRate(
879 const uint32_t samplesPerSec) {
Max Morin098e6c52016-06-28 09:36:25 +0200880 LOG(INFO) << __FUNCTION__ << "(" << samplesPerSec << ")";
henrika4af73662017-10-11 13:16:17 +0200881 CHECKinitialized_();
882 if (audio_device_->SetPlayoutSampleRate(samplesPerSec) != 0) {
Max Morin787eeed2016-06-23 10:42:07 +0200883 return -1;
884 }
henrika4af73662017-10-11 13:16:17 +0200885 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000886}
887
Max Morin787eeed2016-06-23 10:42:07 +0200888int32_t AudioDeviceModuleImpl::PlayoutSampleRate(
889 uint32_t* samplesPerSec) const {
Max Morin098e6c52016-06-28 09:36:25 +0200890 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200891 CHECKinitialized_();
892 int32_t sampleRate = audio_device_buffer_.PlayoutSampleRate();
Max Morin787eeed2016-06-23 10:42:07 +0200893 if (sampleRate == -1) {
Max Morin098e6c52016-06-28 09:36:25 +0200894 LOG(LERROR) << "failed to retrieve the sample rate";
Max Morin787eeed2016-06-23 10:42:07 +0200895 return -1;
896 }
Max Morin787eeed2016-06-23 10:42:07 +0200897 *samplesPerSec = sampleRate;
Max Morin2c332bb2016-07-04 09:03:42 +0200898 LOG(INFO) << "output: " << *samplesPerSec;
Max Morin787eeed2016-06-23 10:42:07 +0200899 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000900}
901
henrika4af73662017-10-11 13:16:17 +0200902int32_t AudioDeviceModuleImpl::SetLoudspeakerStatus(bool enable) {
903 LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
904 CHECKinitialized_();
905 if (audio_device_->SetLoudspeakerStatus(enable) != 0) {
906 return -1;
907 }
908 return 0;
909}
niklase@google.com470e71d2011-07-07 08:21:25 +0000910
henrikac14f5ff2015-09-23 14:08:33 +0200911int32_t AudioDeviceModuleImpl::GetLoudspeakerStatus(bool* enabled) const {
Max Morin098e6c52016-06-28 09:36:25 +0200912 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200913 CHECKinitialized_();
Max Morin098e6c52016-06-28 09:36:25 +0200914 int32_t ok = 0;
henrika4af73662017-10-11 13:16:17 +0200915 if (audio_device_->GetLoudspeakerStatus(*enabled) != 0) {
Max Morin098e6c52016-06-28 09:36:25 +0200916 ok = -1;
henrikac14f5ff2015-09-23 14:08:33 +0200917 }
Max Morin2c332bb2016-07-04 09:03:42 +0200918 LOG(INFO) << "output: " << ok;
Max Morin098e6c52016-06-28 09:36:25 +0200919 return ok;
andrew@webrtc.orga3c6d612011-09-13 17:17:49 +0000920}
921
henrika@webrtc.orga954c072014-12-09 16:22:09 +0000922bool AudioDeviceModuleImpl::BuiltInAECIsAvailable() const {
Max Morin098e6c52016-06-28 09:36:25 +0200923 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200924 CHECKinitialized__BOOL();
925 bool isAvailable = audio_device_->BuiltInAECIsAvailable();
Max Morin2c332bb2016-07-04 09:03:42 +0200926 LOG(INFO) << "output: " << isAvailable;
Max Morin098e6c52016-06-28 09:36:25 +0200927 return isAvailable;
henrika@webrtc.orga954c072014-12-09 16:22:09 +0000928}
929
henrikac14f5ff2015-09-23 14:08:33 +0200930int32_t AudioDeviceModuleImpl::EnableBuiltInAEC(bool enable) {
Max Morin098e6c52016-06-28 09:36:25 +0200931 LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200932 CHECKinitialized_();
933 int32_t ok = audio_device_->EnableBuiltInAEC(enable);
Max Morin2c332bb2016-07-04 09:03:42 +0200934 LOG(INFO) << "output: " << ok;
Max Morin098e6c52016-06-28 09:36:25 +0200935 return ok;
henrikac14f5ff2015-09-23 14:08:33 +0200936}
937
938bool AudioDeviceModuleImpl::BuiltInAGCIsAvailable() const {
Max Morin098e6c52016-06-28 09:36:25 +0200939 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200940 CHECKinitialized__BOOL();
941 bool isAvailable = audio_device_->BuiltInAGCIsAvailable();
Max Morin2c332bb2016-07-04 09:03:42 +0200942 LOG(INFO) << "output: " << isAvailable;
Max Morin098e6c52016-06-28 09:36:25 +0200943 return isAvailable;
henrikac14f5ff2015-09-23 14:08:33 +0200944}
945
946int32_t AudioDeviceModuleImpl::EnableBuiltInAGC(bool enable) {
Max Morin098e6c52016-06-28 09:36:25 +0200947 LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200948 CHECKinitialized_();
949 int32_t ok = audio_device_->EnableBuiltInAGC(enable);
Max Morin2c332bb2016-07-04 09:03:42 +0200950 LOG(INFO) << "output: " << ok;
Max Morin098e6c52016-06-28 09:36:25 +0200951 return ok;
henrikac14f5ff2015-09-23 14:08:33 +0200952}
953
954bool AudioDeviceModuleImpl::BuiltInNSIsAvailable() const {
Max Morin098e6c52016-06-28 09:36:25 +0200955 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200956 CHECKinitialized__BOOL();
957 bool isAvailable = audio_device_->BuiltInNSIsAvailable();
Max Morin2c332bb2016-07-04 09:03:42 +0200958 LOG(INFO) << "output: " << isAvailable;
Max Morin098e6c52016-06-28 09:36:25 +0200959 return isAvailable;
henrikac14f5ff2015-09-23 14:08:33 +0200960}
961
962int32_t AudioDeviceModuleImpl::EnableBuiltInNS(bool enable) {
Max Morin098e6c52016-06-28 09:36:25 +0200963 LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200964 CHECKinitialized_();
965 int32_t ok = audio_device_->EnableBuiltInNS(enable);
Max Morin2c332bb2016-07-04 09:03:42 +0200966 LOG(INFO) << "output: " << ok;
Max Morin098e6c52016-06-28 09:36:25 +0200967 return ok;
henrikac14f5ff2015-09-23 14:08:33 +0200968}
969
maxmorin88e31a32016-08-16 00:56:09 -0700970#if defined(WEBRTC_IOS)
henrikaba35d052015-07-14 17:04:08 +0200971int AudioDeviceModuleImpl::GetPlayoutAudioParameters(
972 AudioParameters* params) const {
Max Morin098e6c52016-06-28 09:36:25 +0200973 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200974 int r = audio_device_->GetPlayoutAudioParameters(params);
Max Morin2c332bb2016-07-04 09:03:42 +0200975 LOG(INFO) << "output: " << r;
Max Morin098e6c52016-06-28 09:36:25 +0200976 return r;
henrikaba35d052015-07-14 17:04:08 +0200977}
978
979int AudioDeviceModuleImpl::GetRecordAudioParameters(
980 AudioParameters* params) const {
Max Morin098e6c52016-06-28 09:36:25 +0200981 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200982 int r = audio_device_->GetRecordAudioParameters(params);
Max Morin2c332bb2016-07-04 09:03:42 +0200983 LOG(INFO) << "output: " << r;
Max Morin098e6c52016-06-28 09:36:25 +0200984 return r;
henrikaba35d052015-07-14 17:04:08 +0200985}
maxmorin88e31a32016-08-16 00:56:09 -0700986#endif // WEBRTC_IOS
henrikaba35d052015-07-14 17:04:08 +0200987
Max Morin787eeed2016-06-23 10:42:07 +0200988AudioDeviceModuleImpl::PlatformType AudioDeviceModuleImpl::Platform() const {
Max Morin098e6c52016-06-28 09:36:25 +0200989 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200990 return platform_type_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000991}
992
Max Morin787eeed2016-06-23 10:42:07 +0200993AudioDeviceModule::AudioLayer AudioDeviceModuleImpl::PlatformAudioLayer()
994 const {
Max Morin098e6c52016-06-28 09:36:25 +0200995 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200996 return audio_layer_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000997}
998
999} // namespace webrtc