blob: c37e6184ed44784dfd27588d65dc5b64241f9d42 [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
Peter Boström4adbbcf2016-05-03 15:51:26 -040068rtc::scoped_refptr<AudioDeviceModule> AudioDeviceModule::Create(
Peter Boström1d194412016-03-21 16:44:31 +010069 const int32_t id,
Peter Boström4adbbcf2016-05-03 15:51:26 -040070 const AudioLayer audio_layer) {
Max Morin098e6c52016-06-28 09:36:25 +020071 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +020072 // Create the generic reference counted (platform independent) implementation.
Max Morin787eeed2016-06-23 10:42:07 +020073 rtc::scoped_refptr<AudioDeviceModuleImpl> audioDevice(
74 new rtc::RefCountedObject<AudioDeviceModuleImpl>(id, audio_layer));
niklase@google.com470e71d2011-07-07 08:21:25 +000075
Max Morin787eeed2016-06-23 10:42:07 +020076 // Ensure that the current platform is supported.
77 if (audioDevice->CheckPlatform() == -1) {
78 return nullptr;
79 }
niklase@google.com470e71d2011-07-07 08:21:25 +000080
Max Morin787eeed2016-06-23 10:42:07 +020081 // Create the platform-dependent implementation.
82 if (audioDevice->CreatePlatformSpecificObjects() == -1) {
83 return nullptr;
84 }
niklase@google.com470e71d2011-07-07 08:21:25 +000085
henrika4af73662017-10-11 13:16:17 +020086 // Ensure that the generic audio buffer can communicate with the platform
87 // specific parts.
Max Morin787eeed2016-06-23 10:42:07 +020088 if (audioDevice->AttachAudioBuffer() == -1) {
89 return nullptr;
90 }
niklase@google.com470e71d2011-07-07 08:21:25 +000091
Max Morin787eeed2016-06-23 10:42:07 +020092 return audioDevice;
niklase@google.com470e71d2011-07-07 08:21:25 +000093}
94
Max Morin787eeed2016-06-23 10:42:07 +020095AudioDeviceModuleImpl::AudioDeviceModuleImpl(const int32_t id,
96 const AudioLayer audioLayer)
henrika4af73662017-10-11 13:16:17 +020097 : id_(id), 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)
henrika4af73662017-10-11 13:16:17 +0200134 audio_device_.reset(new AudioDeviceDummy(Id()));
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)
henrika4af73662017-10-11 13:16:17 +0200137 audio_device_.reset(FileAudioDeviceFactory::CreateFileAudioDevice(Id()));
138 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.
henrika4af73662017-10-11 13:16:17 +0200142 audio_device_.reset(new AudioDeviceDummy(Id()));
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());
211 if (audio_device_->Init() == AudioDeviceGeneric::InitStatus::OK) {
Max Morin098e6c52016-06-28 09:36:25 +0200212 LOG(INFO) << "Linux PulseAudio APIs will be utilized";
Max Morin787eeed2016-06-23 10:42:07 +0200213 } else {
henrika4af73662017-10-11 13:16:17 +0200214 LOG(WARNING) << "Failed to initialize Linux PulseAudio "
215 "implementation.";
216 audio_device_.reset(nullptr);
niklase@google.com470e71d2011-07-07 08:21:25 +0000217#endif
218#if defined(LINUX_ALSA)
henrika4af73662017-10-11 13:16:17 +0200219 // Revert to Linux ALSA implementation instead.
220 audio_device_.reset(new AudioDeviceLinuxALSA());
221 audio_layer_ = kLinuxAlsaAudio;
222 LOG(WARNING) << "Linux PulseAudio is not supported => ALSA APIs will "
223 "be utilized instead.";
niklase@google.com470e71d2011-07-07 08:21:25 +0000224#endif
225#if defined(LINUX_PULSE)
niklase@google.com470e71d2011-07-07 08:21:25 +0000226 }
Max Morin787eeed2016-06-23 10:42:07 +0200227#endif
henrika4af73662017-10-11 13:16:17 +0200228 } else if (audio_layer == kLinuxAlsaAudio) {
niklase@google.com470e71d2011-07-07 08:21:25 +0000229#if defined(LINUX_ALSA)
henrika4af73662017-10-11 13:16:17 +0200230 // Linux ALSA implementation.
231 audio_device_.reset(new AudioDeviceLinuxALSA());
232 LOG(INFO) << "Linux ALSA APIs will be utilized.";
niklase@google.com470e71d2011-07-07 08:21:25 +0000233#endif
Max Morin787eeed2016-06-23 10:42:07 +0200234 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000235#endif // #if defined(WEBRTC_LINUX)
236
henrika4af73662017-10-11 13:16:17 +0200237// iOS ADM implementation.
sjlee@webrtc.org414fa7f2012-09-11 17:25:46 +0000238#if defined(WEBRTC_IOS)
henrika4af73662017-10-11 13:16:17 +0200239 if (audio_layer == kPlatformDefaultAudio) {
240 audio_device_.reset(new AudioDeviceIOS());
241 LOG(INFO) << "iPhone Audio APIs will be utilized.";
Max Morin787eeed2016-06-23 10:42:07 +0200242 }
243// END #if defined(WEBRTC_IOS)
niklase@google.com470e71d2011-07-07 08:21:25 +0000244
henrika4af73662017-10-11 13:16:17 +0200245// Mac OS X ADM implementation.
andrew@webrtc.orgf3b65db2012-09-06 18:17:00 +0000246#elif defined(WEBRTC_MAC)
henrika4af73662017-10-11 13:16:17 +0200247 if (audio_layer == kPlatformDefaultAudio) {
248 audio_device_.reset(new AudioDeviceMac());
249 LOG(INFO) << "Mac OS X Audio APIs will be utilized.";
Max Morin787eeed2016-06-23 10:42:07 +0200250 }
andrew@webrtc.orgf3b65db2012-09-06 18:17:00 +0000251#endif // WEBRTC_MAC
niklase@google.com470e71d2011-07-07 08:21:25 +0000252
henrika4af73662017-10-11 13:16:17 +0200253 // Dummy ADM implementation.
254 if (audio_layer == kDummyAudio) {
255 audio_device_.reset(new AudioDeviceDummy(Id()));
256 LOG(INFO) << "Dummy Audio APIs will be utilized.";
Max Morin787eeed2016-06-23 10:42:07 +0200257 }
xians@google.combf5d2ba2011-08-16 07:44:19 +0000258#endif // if defined(WEBRTC_DUMMY_AUDIO_BUILD)
niklase@google.com470e71d2011-07-07 08:21:25 +0000259
henrika4af73662017-10-11 13:16:17 +0200260 if (!audio_device_) {
261 LOG(LS_ERROR)
262 << "Failed to create the platform specific ADM implementation.";
Max Morin787eeed2016-06-23 10:42:07 +0200263 return -1;
264 }
Max Morin787eeed2016-06-23 10:42:07 +0200265 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000266}
267
Max Morin787eeed2016-06-23 10:42:07 +0200268int32_t AudioDeviceModuleImpl::AttachAudioBuffer() {
Max Morin098e6c52016-06-28 09:36:25 +0200269 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200270 audio_device_buffer_.SetId(id_);
271 audio_device_->AttachAudioBuffer(&audio_device_buffer_);
Max Morin787eeed2016-06-23 10:42:07 +0200272 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000273}
274
Max Morin787eeed2016-06-23 10:42:07 +0200275AudioDeviceModuleImpl::~AudioDeviceModuleImpl() {
Max Morin098e6c52016-06-28 09:36:25 +0200276 LOG(INFO) << __FUNCTION__;
niklase@google.com470e71d2011-07-07 08:21:25 +0000277}
278
henrikab2619892015-05-18 16:49:16 +0200279int32_t AudioDeviceModuleImpl::ActiveAudioLayer(AudioLayer* audioLayer) const {
Max Morin098e6c52016-06-28 09:36:25 +0200280 LOG(INFO) << __FUNCTION__;
henrikab2619892015-05-18 16:49:16 +0200281 AudioLayer activeAudio;
henrika4af73662017-10-11 13:16:17 +0200282 if (audio_device_->ActiveAudioLayer(activeAudio) == -1) {
henrikab2619892015-05-18 16:49:16 +0200283 return -1;
284 }
285 *audioLayer = activeAudio;
286 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000287}
288
henrika4af73662017-10-11 13:16:17 +0200289// TODO(henrika): remove this API.
Max Morin787eeed2016-06-23 10:42:07 +0200290AudioDeviceModule::ErrorCode AudioDeviceModuleImpl::LastError() const {
Max Morin098e6c52016-06-28 09:36:25 +0200291 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200292 LOG(WARNING) << "Not supported";
293 return kAdmErrNone;
niklase@google.com470e71d2011-07-07 08:21:25 +0000294}
295
Max Morin787eeed2016-06-23 10:42:07 +0200296int32_t AudioDeviceModuleImpl::Init() {
Max Morin098e6c52016-06-28 09:36:25 +0200297 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200298 if (initialized_)
niklase@google.com470e71d2011-07-07 08:21:25 +0000299 return 0;
henrika4af73662017-10-11 13:16:17 +0200300 RTC_CHECK(audio_device_);
301 AudioDeviceGeneric::InitStatus status = audio_device_->Init();
Max Morin84cab202016-07-01 13:35:19 +0200302 RTC_HISTOGRAM_ENUMERATION(
303 "WebRTC.Audio.InitializationResult", static_cast<int>(status),
304 static_cast<int>(AudioDeviceGeneric::InitStatus::NUM_STATUSES));
305 if (status != AudioDeviceGeneric::InitStatus::OK) {
306 LOG(LS_ERROR) << "Audio device initialization failed.";
Max Morin787eeed2016-06-23 10:42:07 +0200307 return -1;
308 }
henrika4af73662017-10-11 13:16:17 +0200309 initialized_ = true;
Max Morin787eeed2016-06-23 10:42:07 +0200310 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000311}
312
Max Morin787eeed2016-06-23 10:42:07 +0200313int32_t AudioDeviceModuleImpl::Terminate() {
Max Morin098e6c52016-06-28 09:36:25 +0200314 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200315 if (!initialized_)
niklase@google.com470e71d2011-07-07 08:21:25 +0000316 return 0;
henrika4af73662017-10-11 13:16:17 +0200317 if (audio_device_->Terminate() == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200318 return -1;
319 }
henrika4af73662017-10-11 13:16:17 +0200320 initialized_ = false;
Max Morin787eeed2016-06-23 10:42:07 +0200321 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000322}
323
Max Morin787eeed2016-06-23 10:42:07 +0200324bool AudioDeviceModuleImpl::Initialized() const {
henrika4af73662017-10-11 13:16:17 +0200325 LOG(INFO) << __FUNCTION__ << ": " << initialized_;
326 return initialized_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000327}
328
Max Morin787eeed2016-06-23 10:42:07 +0200329int32_t AudioDeviceModuleImpl::InitSpeaker() {
Max Morin098e6c52016-06-28 09:36:25 +0200330 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200331 CHECKinitialized_();
332 return audio_device_->InitSpeaker();
niklase@google.com470e71d2011-07-07 08:21:25 +0000333}
334
Max Morin787eeed2016-06-23 10:42:07 +0200335int32_t AudioDeviceModuleImpl::InitMicrophone() {
Max Morin098e6c52016-06-28 09:36:25 +0200336 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200337 CHECKinitialized_();
338 return audio_device_->InitMicrophone();
niklase@google.com470e71d2011-07-07 08:21:25 +0000339}
340
Max Morin787eeed2016-06-23 10:42:07 +0200341int32_t AudioDeviceModuleImpl::SpeakerVolumeIsAvailable(bool* available) {
Max Morin098e6c52016-06-28 09:36:25 +0200342 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200343 CHECKinitialized_();
344 bool isAvailable = false;
345 if (audio_device_->SpeakerVolumeIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200346 return -1;
347 }
Max Morin787eeed2016-06-23 10:42:07 +0200348 *available = isAvailable;
Max Morin2c332bb2016-07-04 09:03:42 +0200349 LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200350 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000351}
352
Max Morin787eeed2016-06-23 10:42:07 +0200353int32_t AudioDeviceModuleImpl::SetSpeakerVolume(uint32_t volume) {
Max Morin098e6c52016-06-28 09:36:25 +0200354 LOG(INFO) << __FUNCTION__ << "(" << volume << ")";
henrika4af73662017-10-11 13:16:17 +0200355 CHECKinitialized_();
356 return audio_device_->SetSpeakerVolume(volume);
niklase@google.com470e71d2011-07-07 08:21:25 +0000357}
358
Max Morin787eeed2016-06-23 10:42:07 +0200359int32_t AudioDeviceModuleImpl::SpeakerVolume(uint32_t* volume) const {
Max Morin098e6c52016-06-28 09:36:25 +0200360 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200361 CHECKinitialized_();
362 uint32_t level = 0;
363 if (audio_device_->SpeakerVolume(level) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200364 return -1;
365 }
Max Morin787eeed2016-06-23 10:42:07 +0200366 *volume = level;
Max Morin2c332bb2016-07-04 09:03:42 +0200367 LOG(INFO) << "output: " << *volume;
henrika4af73662017-10-11 13:16:17 +0200368 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000369}
370
Max Morin787eeed2016-06-23 10:42:07 +0200371bool AudioDeviceModuleImpl::SpeakerIsInitialized() const {
Max Morin098e6c52016-06-28 09:36:25 +0200372 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200373 CHECKinitialized__BOOL();
374 bool isInitialized = audio_device_->SpeakerIsInitialized();
Max Morin2c332bb2016-07-04 09:03:42 +0200375 LOG(INFO) << "output: " << isInitialized;
henrika4af73662017-10-11 13:16:17 +0200376 return isInitialized;
niklase@google.com470e71d2011-07-07 08:21:25 +0000377}
378
Max Morin787eeed2016-06-23 10:42:07 +0200379bool AudioDeviceModuleImpl::MicrophoneIsInitialized() const {
Max Morin098e6c52016-06-28 09:36:25 +0200380 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200381 CHECKinitialized__BOOL();
382 bool isInitialized = audio_device_->MicrophoneIsInitialized();
Max Morin2c332bb2016-07-04 09:03:42 +0200383 LOG(INFO) << "output: " << isInitialized;
henrika4af73662017-10-11 13:16:17 +0200384 return isInitialized;
niklase@google.com470e71d2011-07-07 08:21:25 +0000385}
386
Max Morin787eeed2016-06-23 10:42:07 +0200387int32_t AudioDeviceModuleImpl::MaxSpeakerVolume(uint32_t* maxVolume) const {
henrika4af73662017-10-11 13:16:17 +0200388 CHECKinitialized_();
389 uint32_t maxVol = 0;
390 if (audio_device_->MaxSpeakerVolume(maxVol) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200391 return -1;
392 }
Max Morin787eeed2016-06-23 10:42:07 +0200393 *maxVolume = maxVol;
henrika4af73662017-10-11 13:16:17 +0200394 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000395}
396
Max Morin787eeed2016-06-23 10:42:07 +0200397int32_t AudioDeviceModuleImpl::MinSpeakerVolume(uint32_t* minVolume) const {
henrika4af73662017-10-11 13:16:17 +0200398 CHECKinitialized_();
399 uint32_t minVol = 0;
400 if (audio_device_->MinSpeakerVolume(minVol) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200401 return -1;
402 }
Max Morin787eeed2016-06-23 10:42:07 +0200403 *minVolume = minVol;
henrika4af73662017-10-11 13:16:17 +0200404 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000405}
406
Max Morin787eeed2016-06-23 10:42:07 +0200407int32_t AudioDeviceModuleImpl::SpeakerMuteIsAvailable(bool* available) {
Max Morin098e6c52016-06-28 09:36:25 +0200408 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200409 CHECKinitialized_();
410 bool isAvailable = false;
411 if (audio_device_->SpeakerMuteIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200412 return -1;
413 }
Max Morin787eeed2016-06-23 10:42:07 +0200414 *available = isAvailable;
Max Morin2c332bb2016-07-04 09:03:42 +0200415 LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200416 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000417}
418
Max Morin787eeed2016-06-23 10:42:07 +0200419int32_t AudioDeviceModuleImpl::SetSpeakerMute(bool enable) {
Max Morin098e6c52016-06-28 09:36:25 +0200420 LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200421 CHECKinitialized_();
422 return audio_device_->SetSpeakerMute(enable);
niklase@google.com470e71d2011-07-07 08:21:25 +0000423}
424
Max Morin787eeed2016-06-23 10:42:07 +0200425int32_t AudioDeviceModuleImpl::SpeakerMute(bool* enabled) const {
Max Morin098e6c52016-06-28 09:36:25 +0200426 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200427 CHECKinitialized_();
428 bool muted = false;
429 if (audio_device_->SpeakerMute(muted) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200430 return -1;
431 }
Max Morin787eeed2016-06-23 10:42:07 +0200432 *enabled = muted;
Max Morin2c332bb2016-07-04 09:03:42 +0200433 LOG(INFO) << "output: " << muted;
henrika4af73662017-10-11 13:16:17 +0200434 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000435}
436
Max Morin787eeed2016-06-23 10:42:07 +0200437int32_t AudioDeviceModuleImpl::MicrophoneMuteIsAvailable(bool* available) {
Max Morin098e6c52016-06-28 09:36:25 +0200438 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200439 CHECKinitialized_();
440 bool isAvailable = false;
441 if (audio_device_->MicrophoneMuteIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200442 return -1;
443 }
Max Morin787eeed2016-06-23 10:42:07 +0200444 *available = isAvailable;
Max Morin2c332bb2016-07-04 09:03:42 +0200445 LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200446 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000447}
448
Max Morin787eeed2016-06-23 10:42:07 +0200449int32_t AudioDeviceModuleImpl::SetMicrophoneMute(bool enable) {
Max Morin098e6c52016-06-28 09:36:25 +0200450 LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200451 CHECKinitialized_();
452 return (audio_device_->SetMicrophoneMute(enable));
niklase@google.com470e71d2011-07-07 08:21:25 +0000453}
454
Max Morin787eeed2016-06-23 10:42:07 +0200455int32_t AudioDeviceModuleImpl::MicrophoneMute(bool* enabled) const {
Max Morin098e6c52016-06-28 09:36:25 +0200456 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200457 CHECKinitialized_();
458 bool muted = false;
459 if (audio_device_->MicrophoneMute(muted) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200460 return -1;
461 }
Max Morin787eeed2016-06-23 10:42:07 +0200462 *enabled = muted;
Max Morin2c332bb2016-07-04 09:03:42 +0200463 LOG(INFO) << "output: " << muted;
henrika4af73662017-10-11 13:16:17 +0200464 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000465}
466
Max Morin787eeed2016-06-23 10:42:07 +0200467int32_t AudioDeviceModuleImpl::MicrophoneVolumeIsAvailable(bool* available) {
Max Morin098e6c52016-06-28 09:36:25 +0200468 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200469 CHECKinitialized_();
470 bool isAvailable = false;
471 if (audio_device_->MicrophoneVolumeIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200472 return -1;
473 }
Max Morin787eeed2016-06-23 10:42:07 +0200474 *available = isAvailable;
Max Morin2c332bb2016-07-04 09:03:42 +0200475 LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200476 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000477}
478
Max Morin787eeed2016-06-23 10:42:07 +0200479int32_t AudioDeviceModuleImpl::SetMicrophoneVolume(uint32_t volume) {
Max Morin098e6c52016-06-28 09:36:25 +0200480 LOG(INFO) << __FUNCTION__ << "(" << volume << ")";
henrika4af73662017-10-11 13:16:17 +0200481 CHECKinitialized_();
482 return (audio_device_->SetMicrophoneVolume(volume));
niklase@google.com470e71d2011-07-07 08:21:25 +0000483}
484
Max Morin787eeed2016-06-23 10:42:07 +0200485int32_t AudioDeviceModuleImpl::MicrophoneVolume(uint32_t* volume) const {
Max Morin098e6c52016-06-28 09:36:25 +0200486 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200487 CHECKinitialized_();
488 uint32_t level = 0;
489 if (audio_device_->MicrophoneVolume(level) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200490 return -1;
491 }
Max Morin787eeed2016-06-23 10:42:07 +0200492 *volume = level;
Max Morin2c332bb2016-07-04 09:03:42 +0200493 LOG(INFO) << "output: " << *volume;
henrika4af73662017-10-11 13:16:17 +0200494 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000495}
496
Max Morin787eeed2016-06-23 10:42:07 +0200497int32_t AudioDeviceModuleImpl::StereoRecordingIsAvailable(
498 bool* available) const {
Max Morin098e6c52016-06-28 09:36:25 +0200499 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200500 CHECKinitialized_();
501 bool isAvailable = false;
502 if (audio_device_->StereoRecordingIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200503 return -1;
504 }
Max Morin787eeed2016-06-23 10:42:07 +0200505 *available = isAvailable;
Max Morin2c332bb2016-07-04 09:03:42 +0200506 LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200507 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000508}
509
Max Morin787eeed2016-06-23 10:42:07 +0200510int32_t AudioDeviceModuleImpl::SetStereoRecording(bool enable) {
Max Morin098e6c52016-06-28 09:36:25 +0200511 LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200512 CHECKinitialized_();
513 if (audio_device_->RecordingIsInitialized()) {
Max Morin098e6c52016-06-28 09:36:25 +0200514 LOG(WARNING) << "recording in stereo is not supported";
Max Morin787eeed2016-06-23 10:42:07 +0200515 return -1;
516 }
henrika4af73662017-10-11 13:16:17 +0200517 if (audio_device_->SetStereoRecording(enable) == -1) {
Max Morin2c332bb2016-07-04 09:03:42 +0200518 LOG(WARNING) << "failed to change stereo recording";
Max Morin787eeed2016-06-23 10:42:07 +0200519 return -1;
520 }
Max Morin787eeed2016-06-23 10:42:07 +0200521 int8_t nChannels(1);
522 if (enable) {
523 nChannels = 2;
524 }
henrika4af73662017-10-11 13:16:17 +0200525 audio_device_buffer_.SetRecordingChannels(nChannels);
Max Morin787eeed2016-06-23 10:42:07 +0200526 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000527}
528
Max Morin787eeed2016-06-23 10:42:07 +0200529int32_t AudioDeviceModuleImpl::StereoRecording(bool* enabled) const {
Max Morin098e6c52016-06-28 09:36:25 +0200530 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200531 CHECKinitialized_();
532 bool stereo = false;
533 if (audio_device_->StereoRecording(stereo) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200534 return -1;
535 }
Max Morin787eeed2016-06-23 10:42:07 +0200536 *enabled = stereo;
Max Morin2c332bb2016-07-04 09:03:42 +0200537 LOG(INFO) << "output: " << stereo;
henrika4af73662017-10-11 13:16:17 +0200538 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000539}
540
Max Morin787eeed2016-06-23 10:42:07 +0200541int32_t AudioDeviceModuleImpl::SetRecordingChannel(const ChannelType channel) {
542 if (channel == kChannelBoth) {
Max Morin098e6c52016-06-28 09:36:25 +0200543 LOG(INFO) << __FUNCTION__ << "(both)";
Max Morin787eeed2016-06-23 10:42:07 +0200544 } else if (channel == kChannelLeft) {
Max Morin098e6c52016-06-28 09:36:25 +0200545 LOG(INFO) << __FUNCTION__ << "(left)";
Max Morin787eeed2016-06-23 10:42:07 +0200546 } else {
Max Morin098e6c52016-06-28 09:36:25 +0200547 LOG(INFO) << __FUNCTION__ << "(right)";
Max Morin787eeed2016-06-23 10:42:07 +0200548 }
henrika4af73662017-10-11 13:16:17 +0200549 CHECKinitialized_();
550 bool stereo = false;
551 if (audio_device_->StereoRecording(stereo) == -1) {
Max Morin098e6c52016-06-28 09:36:25 +0200552 LOG(WARNING) << "recording in stereo is not supported";
Max Morin787eeed2016-06-23 10:42:07 +0200553 return -1;
554 }
henrika4af73662017-10-11 13:16:17 +0200555 return audio_device_buffer_.SetRecordingChannel(channel);
niklase@google.com470e71d2011-07-07 08:21:25 +0000556}
557
Max Morin787eeed2016-06-23 10:42:07 +0200558int32_t AudioDeviceModuleImpl::RecordingChannel(ChannelType* channel) const {
Max Morin098e6c52016-06-28 09:36:25 +0200559 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200560 CHECKinitialized_();
Max Morin787eeed2016-06-23 10:42:07 +0200561 ChannelType chType;
henrika4af73662017-10-11 13:16:17 +0200562 if (audio_device_buffer_.RecordingChannel(chType) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200563 return -1;
564 }
Max Morin787eeed2016-06-23 10:42:07 +0200565 *channel = chType;
Max Morin787eeed2016-06-23 10:42:07 +0200566 if (*channel == kChannelBoth) {
Max Morin2c332bb2016-07-04 09:03:42 +0200567 LOG(INFO) << "output: both";
Max Morin787eeed2016-06-23 10:42:07 +0200568 } else if (*channel == kChannelLeft) {
Max Morin2c332bb2016-07-04 09:03:42 +0200569 LOG(INFO) << "output: left";
Max Morin787eeed2016-06-23 10:42:07 +0200570 } else {
Max Morin2c332bb2016-07-04 09:03:42 +0200571 LOG(INFO) << "output: right";
Max Morin787eeed2016-06-23 10:42:07 +0200572 }
henrika4af73662017-10-11 13:16:17 +0200573 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000574}
575
Max Morin787eeed2016-06-23 10:42:07 +0200576int32_t AudioDeviceModuleImpl::StereoPlayoutIsAvailable(bool* available) const {
Max Morin098e6c52016-06-28 09:36:25 +0200577 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200578 CHECKinitialized_();
579 bool isAvailable = false;
580 if (audio_device_->StereoPlayoutIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200581 return -1;
582 }
Max Morin787eeed2016-06-23 10:42:07 +0200583 *available = isAvailable;
Max Morin2c332bb2016-07-04 09:03:42 +0200584 LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200585 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000586}
587
Max Morin787eeed2016-06-23 10:42:07 +0200588int32_t AudioDeviceModuleImpl::SetStereoPlayout(bool enable) {
Max Morin098e6c52016-06-28 09:36:25 +0200589 LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200590 CHECKinitialized_();
591 if (audio_device_->PlayoutIsInitialized()) {
Max Morin098e6c52016-06-28 09:36:25 +0200592 LOG(LERROR)
593 << "unable to set stereo mode while playing side is initialized";
Max Morin787eeed2016-06-23 10:42:07 +0200594 return -1;
595 }
henrika4af73662017-10-11 13:16:17 +0200596 if (audio_device_->SetStereoPlayout(enable)) {
Max Morin098e6c52016-06-28 09:36:25 +0200597 LOG(WARNING) << "stereo playout is not supported";
Max Morin787eeed2016-06-23 10:42:07 +0200598 return -1;
599 }
Max Morin787eeed2016-06-23 10:42:07 +0200600 int8_t nChannels(1);
601 if (enable) {
602 nChannels = 2;
603 }
henrika4af73662017-10-11 13:16:17 +0200604 audio_device_buffer_.SetPlayoutChannels(nChannels);
Max Morin787eeed2016-06-23 10:42:07 +0200605 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000606}
607
Max Morin787eeed2016-06-23 10:42:07 +0200608int32_t AudioDeviceModuleImpl::StereoPlayout(bool* enabled) const {
Max Morin098e6c52016-06-28 09:36:25 +0200609 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200610 CHECKinitialized_();
611 bool stereo = false;
612 if (audio_device_->StereoPlayout(stereo) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200613 return -1;
614 }
Max Morin787eeed2016-06-23 10:42:07 +0200615 *enabled = stereo;
Max Morin2c332bb2016-07-04 09:03:42 +0200616 LOG(INFO) << "output: " << stereo;
henrika4af73662017-10-11 13:16:17 +0200617 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000618}
619
Max Morin787eeed2016-06-23 10:42:07 +0200620int32_t AudioDeviceModuleImpl::SetAGC(bool enable) {
Max Morin098e6c52016-06-28 09:36:25 +0200621 LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200622 CHECKinitialized_();
623 return (audio_device_->SetAGC(enable));
niklase@google.com470e71d2011-07-07 08:21:25 +0000624}
625
Max Morin787eeed2016-06-23 10:42:07 +0200626bool AudioDeviceModuleImpl::AGC() const {
Max Morin098e6c52016-06-28 09:36:25 +0200627 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200628 CHECKinitialized__BOOL();
629 return audio_device_->AGC();
niklase@google.com470e71d2011-07-07 08:21:25 +0000630}
631
Max Morin787eeed2016-06-23 10:42:07 +0200632int32_t AudioDeviceModuleImpl::PlayoutIsAvailable(bool* available) {
Max Morin098e6c52016-06-28 09:36:25 +0200633 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200634 CHECKinitialized_();
635 bool isAvailable = false;
636 if (audio_device_->PlayoutIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200637 return -1;
638 }
Max Morin787eeed2016-06-23 10:42:07 +0200639 *available = isAvailable;
Max Morin2c332bb2016-07-04 09:03:42 +0200640 LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200641 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000642}
643
Max Morin787eeed2016-06-23 10:42:07 +0200644int32_t AudioDeviceModuleImpl::RecordingIsAvailable(bool* available) {
Max Morin098e6c52016-06-28 09:36:25 +0200645 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200646 CHECKinitialized_();
647 bool isAvailable = false;
648 if (audio_device_->RecordingIsAvailable(isAvailable) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200649 return -1;
650 }
Max Morin787eeed2016-06-23 10:42:07 +0200651 *available = isAvailable;
Max Morin2c332bb2016-07-04 09:03:42 +0200652 LOG(INFO) << "output: " << isAvailable;
henrika4af73662017-10-11 13:16:17 +0200653 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000654}
655
Max Morin787eeed2016-06-23 10:42:07 +0200656int32_t AudioDeviceModuleImpl::MaxMicrophoneVolume(uint32_t* maxVolume) const {
henrika4af73662017-10-11 13:16:17 +0200657 CHECKinitialized_();
Max Morin787eeed2016-06-23 10:42:07 +0200658 uint32_t maxVol(0);
henrika4af73662017-10-11 13:16:17 +0200659 if (audio_device_->MaxMicrophoneVolume(maxVol) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200660 return -1;
661 }
Max Morin787eeed2016-06-23 10:42:07 +0200662 *maxVolume = maxVol;
henrika4af73662017-10-11 13:16:17 +0200663 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000664}
665
Max Morin787eeed2016-06-23 10:42:07 +0200666int32_t AudioDeviceModuleImpl::MinMicrophoneVolume(uint32_t* minVolume) const {
henrika4af73662017-10-11 13:16:17 +0200667 CHECKinitialized_();
Max Morin787eeed2016-06-23 10:42:07 +0200668 uint32_t minVol(0);
henrika4af73662017-10-11 13:16:17 +0200669 if (audio_device_->MinMicrophoneVolume(minVol) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200670 return -1;
671 }
Max Morin787eeed2016-06-23 10:42:07 +0200672 *minVolume = minVol;
henrika4af73662017-10-11 13:16:17 +0200673 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000674}
675
Max Morin787eeed2016-06-23 10:42:07 +0200676int16_t AudioDeviceModuleImpl::PlayoutDevices() {
Max Morin098e6c52016-06-28 09:36:25 +0200677 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200678 CHECKinitialized_();
679 uint16_t nPlayoutDevices = audio_device_->PlayoutDevices();
Max Morin2c332bb2016-07-04 09:03:42 +0200680 LOG(INFO) << "output: " << nPlayoutDevices;
henrika4af73662017-10-11 13:16:17 +0200681 return (int16_t)(nPlayoutDevices);
niklase@google.com470e71d2011-07-07 08:21:25 +0000682}
683
Max Morin787eeed2016-06-23 10:42:07 +0200684int32_t AudioDeviceModuleImpl::SetPlayoutDevice(uint16_t index) {
Max Morin098e6c52016-06-28 09:36:25 +0200685 LOG(INFO) << __FUNCTION__ << "(" << index << ")";
henrika4af73662017-10-11 13:16:17 +0200686 CHECKinitialized_();
687 return audio_device_->SetPlayoutDevice(index);
niklase@google.com470e71d2011-07-07 08:21:25 +0000688}
689
Max Morin787eeed2016-06-23 10:42:07 +0200690int32_t AudioDeviceModuleImpl::SetPlayoutDevice(WindowsDeviceType device) {
Max Morin098e6c52016-06-28 09:36:25 +0200691 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200692 CHECKinitialized_();
693 return audio_device_->SetPlayoutDevice(device);
niklase@google.com470e71d2011-07-07 08:21:25 +0000694}
695
pbos@webrtc.org25509882013-04-09 10:30:35 +0000696int32_t AudioDeviceModuleImpl::PlayoutDeviceName(
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_->PlayoutDeviceName(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
pbos@webrtc.org25509882013-04-09 10:30:35 +0000717int32_t AudioDeviceModuleImpl::RecordingDeviceName(
718 uint16_t index,
leozwang@webrtc.org28f39132012-03-01 18:01:48 +0000719 char name[kAdmMaxDeviceNameSize],
Max Morin787eeed2016-06-23 10:42:07 +0200720 char guid[kAdmMaxGuidSize]) {
Max Morin098e6c52016-06-28 09:36:25 +0200721 LOG(INFO) << __FUNCTION__ << "(" << index << ", ...)";
henrika4af73662017-10-11 13:16:17 +0200722 CHECKinitialized_();
Max Morin787eeed2016-06-23 10:42:07 +0200723 if (name == NULL) {
Max Morin787eeed2016-06-23 10:42:07 +0200724 return -1;
725 }
henrika4af73662017-10-11 13:16:17 +0200726 if (audio_device_->RecordingDeviceName(index, name, guid) == -1) {
Max Morin787eeed2016-06-23 10:42:07 +0200727 return -1;
728 }
Max Morin787eeed2016-06-23 10:42:07 +0200729 if (name != NULL) {
Max Morin2c332bb2016-07-04 09:03:42 +0200730 LOG(INFO) << "output: name = " << name;
Max Morin787eeed2016-06-23 10:42:07 +0200731 }
732 if (guid != NULL) {
Max Morin2c332bb2016-07-04 09:03:42 +0200733 LOG(INFO) << "output: guid = " << guid;
Max Morin787eeed2016-06-23 10:42:07 +0200734 }
henrika4af73662017-10-11 13:16:17 +0200735 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000736}
737
Max Morin787eeed2016-06-23 10:42:07 +0200738int16_t AudioDeviceModuleImpl::RecordingDevices() {
Max Morin098e6c52016-06-28 09:36:25 +0200739 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200740 CHECKinitialized_();
741 uint16_t nRecordingDevices = audio_device_->RecordingDevices();
Max Morin2c332bb2016-07-04 09:03:42 +0200742 LOG(INFO) << "output: " << nRecordingDevices;
henrika4af73662017-10-11 13:16:17 +0200743 return (int16_t)nRecordingDevices;
niklase@google.com470e71d2011-07-07 08:21:25 +0000744}
745
Max Morin787eeed2016-06-23 10:42:07 +0200746int32_t AudioDeviceModuleImpl::SetRecordingDevice(uint16_t index) {
Max Morin098e6c52016-06-28 09:36:25 +0200747 LOG(INFO) << __FUNCTION__ << "(" << index << ")";
henrika4af73662017-10-11 13:16:17 +0200748 CHECKinitialized_();
749 return audio_device_->SetRecordingDevice(index);
niklase@google.com470e71d2011-07-07 08:21:25 +0000750}
751
Max Morin787eeed2016-06-23 10:42:07 +0200752int32_t AudioDeviceModuleImpl::SetRecordingDevice(WindowsDeviceType device) {
Max Morin098e6c52016-06-28 09:36:25 +0200753 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200754 CHECKinitialized_();
755 return audio_device_->SetRecordingDevice(device);
niklase@google.com470e71d2011-07-07 08:21:25 +0000756}
757
Max Morin787eeed2016-06-23 10:42:07 +0200758int32_t AudioDeviceModuleImpl::InitPlayout() {
Max Morin098e6c52016-06-28 09:36:25 +0200759 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200760 CHECKinitialized_();
maxmorin8c695b42016-07-25 02:46:44 -0700761 if (PlayoutIsInitialized()) {
762 return 0;
763 }
henrika4af73662017-10-11 13:16:17 +0200764 int32_t result = audio_device_->InitPlayout();
Max Morin84cab202016-07-01 13:35:19 +0200765 LOG(INFO) << "output: " << result;
766 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.InitPlayoutSuccess",
767 static_cast<int>(result == 0));
768 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000769}
770
Max Morin787eeed2016-06-23 10:42:07 +0200771int32_t AudioDeviceModuleImpl::InitRecording() {
Max Morin098e6c52016-06-28 09:36:25 +0200772 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200773 CHECKinitialized_();
maxmorin8c695b42016-07-25 02:46:44 -0700774 if (RecordingIsInitialized()) {
775 return 0;
776 }
henrika4af73662017-10-11 13:16:17 +0200777 int32_t result = audio_device_->InitRecording();
Max Morin84cab202016-07-01 13:35:19 +0200778 LOG(INFO) << "output: " << result;
779 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.InitRecordingSuccess",
780 static_cast<int>(result == 0));
781 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000782}
783
Max Morin787eeed2016-06-23 10:42:07 +0200784bool AudioDeviceModuleImpl::PlayoutIsInitialized() const {
Max Morin098e6c52016-06-28 09:36:25 +0200785 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200786 CHECKinitialized__BOOL();
787 return audio_device_->PlayoutIsInitialized();
niklase@google.com470e71d2011-07-07 08:21:25 +0000788}
789
Max Morin787eeed2016-06-23 10:42:07 +0200790bool AudioDeviceModuleImpl::RecordingIsInitialized() const {
Max Morin098e6c52016-06-28 09:36:25 +0200791 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200792 CHECKinitialized__BOOL();
793 return audio_device_->RecordingIsInitialized();
niklase@google.com470e71d2011-07-07 08:21:25 +0000794}
795
Max Morin787eeed2016-06-23 10:42:07 +0200796int32_t AudioDeviceModuleImpl::StartPlayout() {
Max Morin098e6c52016-06-28 09:36:25 +0200797 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200798 CHECKinitialized_();
maxmorin8c695b42016-07-25 02:46:44 -0700799 if (Playing()) {
800 return 0;
801 }
henrika4af73662017-10-11 13:16:17 +0200802 audio_device_buffer_.StartPlayout();
803 int32_t result = audio_device_->StartPlayout();
Max Morin84cab202016-07-01 13:35:19 +0200804 LOG(INFO) << "output: " << result;
805 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StartPlayoutSuccess",
806 static_cast<int>(result == 0));
807 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000808}
809
Max Morin787eeed2016-06-23 10:42:07 +0200810int32_t AudioDeviceModuleImpl::StopPlayout() {
Max Morin098e6c52016-06-28 09:36:25 +0200811 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200812 CHECKinitialized_();
813 int32_t result = audio_device_->StopPlayout();
814 audio_device_buffer_.StopPlayout();
Max Morin84cab202016-07-01 13:35:19 +0200815 LOG(INFO) << "output: " << result;
816 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StopPlayoutSuccess",
817 static_cast<int>(result == 0));
818 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000819}
820
Max Morin787eeed2016-06-23 10:42:07 +0200821bool AudioDeviceModuleImpl::Playing() const {
Max Morin098e6c52016-06-28 09:36:25 +0200822 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200823 CHECKinitialized__BOOL();
824 return audio_device_->Playing();
niklase@google.com470e71d2011-07-07 08:21:25 +0000825}
826
Max Morin787eeed2016-06-23 10:42:07 +0200827int32_t AudioDeviceModuleImpl::StartRecording() {
Max Morin098e6c52016-06-28 09:36:25 +0200828 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200829 CHECKinitialized_();
maxmorin8c695b42016-07-25 02:46:44 -0700830 if (Recording()) {
831 return 0;
832 }
henrika4af73662017-10-11 13:16:17 +0200833 audio_device_buffer_.StartRecording();
834 int32_t result = audio_device_->StartRecording();
Max Morin84cab202016-07-01 13:35:19 +0200835 LOG(INFO) << "output: " << result;
836 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StartRecordingSuccess",
837 static_cast<int>(result == 0));
838 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000839}
niklase@google.com470e71d2011-07-07 08:21:25 +0000840
Max Morin787eeed2016-06-23 10:42:07 +0200841int32_t AudioDeviceModuleImpl::StopRecording() {
Max Morin098e6c52016-06-28 09:36:25 +0200842 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200843 CHECKinitialized_();
844 int32_t result = audio_device_->StopRecording();
845 audio_device_buffer_.StopRecording();
Max Morin84cab202016-07-01 13:35:19 +0200846 LOG(INFO) << "output: " << result;
847 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StopRecordingSuccess",
848 static_cast<int>(result == 0));
849 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000850}
851
Max Morin787eeed2016-06-23 10:42:07 +0200852bool AudioDeviceModuleImpl::Recording() const {
Max Morin098e6c52016-06-28 09:36:25 +0200853 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200854 CHECKinitialized__BOOL();
855 return audio_device_->Recording();
niklase@google.com470e71d2011-07-07 08:21:25 +0000856}
857
Max Morin787eeed2016-06-23 10:42:07 +0200858int32_t AudioDeviceModuleImpl::RegisterAudioCallback(
859 AudioTransport* audioCallback) {
Max Morin098e6c52016-06-28 09:36:25 +0200860 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200861 return audio_device_buffer_.RegisterAudioCallback(audioCallback);
niklase@google.com470e71d2011-07-07 08:21:25 +0000862}
863
Max Morin787eeed2016-06-23 10:42:07 +0200864int32_t AudioDeviceModuleImpl::PlayoutDelay(uint16_t* delayMS) const {
henrika4af73662017-10-11 13:16:17 +0200865 CHECKinitialized_();
866 uint16_t delay = 0;
867 if (audio_device_->PlayoutDelay(delay) == -1) {
Max Morin098e6c52016-06-28 09:36:25 +0200868 LOG(LERROR) << "failed to retrieve the playout delay";
Max Morin787eeed2016-06-23 10:42:07 +0200869 return -1;
870 }
Max Morin787eeed2016-06-23 10:42:07 +0200871 *delayMS = delay;
henrika4af73662017-10-11 13:16:17 +0200872 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000873}
874
Max Morin787eeed2016-06-23 10:42:07 +0200875int32_t AudioDeviceModuleImpl::RecordingDelay(uint16_t* delayMS) const {
Max Morin098e6c52016-06-28 09:36:25 +0200876 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200877 CHECKinitialized_();
878 uint16_t delay = 0;
879 if (audio_device_->RecordingDelay(delay) == -1) {
Max Morin098e6c52016-06-28 09:36:25 +0200880 LOG(LERROR) << "failed to retrieve the recording delay";
Max Morin787eeed2016-06-23 10:42:07 +0200881 return -1;
882 }
Max Morin787eeed2016-06-23 10:42:07 +0200883 *delayMS = delay;
Max Morin2c332bb2016-07-04 09:03:42 +0200884 LOG(INFO) << "output: " << *delayMS;
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::SetRecordingSampleRate(
889 const uint32_t samplesPerSec) {
Max Morin098e6c52016-06-28 09:36:25 +0200890 LOG(INFO) << __FUNCTION__ << "(" << samplesPerSec << ")";
henrika4af73662017-10-11 13:16:17 +0200891 CHECKinitialized_();
892 if (audio_device_->SetRecordingSampleRate(samplesPerSec) != 0) {
Max Morin787eeed2016-06-23 10:42:07 +0200893 return -1;
894 }
henrika4af73662017-10-11 13:16:17 +0200895 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000896}
897
Max Morin787eeed2016-06-23 10:42:07 +0200898int32_t AudioDeviceModuleImpl::RecordingSampleRate(
899 uint32_t* samplesPerSec) const {
Max Morin098e6c52016-06-28 09:36:25 +0200900 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200901 CHECKinitialized_();
902 int32_t sampleRate = audio_device_buffer_.RecordingSampleRate();
Max Morin787eeed2016-06-23 10:42:07 +0200903 if (sampleRate == -1) {
Max Morin098e6c52016-06-28 09:36:25 +0200904 LOG(LERROR) << "failed to retrieve the sample rate";
Max Morin787eeed2016-06-23 10:42:07 +0200905 return -1;
906 }
Max Morin787eeed2016-06-23 10:42:07 +0200907 *samplesPerSec = sampleRate;
Max Morin2c332bb2016-07-04 09:03:42 +0200908 LOG(INFO) << "output: " << *samplesPerSec;
henrika4af73662017-10-11 13:16:17 +0200909 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000910}
911
Max Morin787eeed2016-06-23 10:42:07 +0200912int32_t AudioDeviceModuleImpl::SetPlayoutSampleRate(
913 const uint32_t samplesPerSec) {
Max Morin098e6c52016-06-28 09:36:25 +0200914 LOG(INFO) << __FUNCTION__ << "(" << samplesPerSec << ")";
henrika4af73662017-10-11 13:16:17 +0200915 CHECKinitialized_();
916 if (audio_device_->SetPlayoutSampleRate(samplesPerSec) != 0) {
Max Morin787eeed2016-06-23 10:42:07 +0200917 return -1;
918 }
henrika4af73662017-10-11 13:16:17 +0200919 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000920}
921
Max Morin787eeed2016-06-23 10:42:07 +0200922int32_t AudioDeviceModuleImpl::PlayoutSampleRate(
923 uint32_t* samplesPerSec) const {
Max Morin098e6c52016-06-28 09:36:25 +0200924 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200925 CHECKinitialized_();
926 int32_t sampleRate = audio_device_buffer_.PlayoutSampleRate();
Max Morin787eeed2016-06-23 10:42:07 +0200927 if (sampleRate == -1) {
Max Morin098e6c52016-06-28 09:36:25 +0200928 LOG(LERROR) << "failed to retrieve the sample rate";
Max Morin787eeed2016-06-23 10:42:07 +0200929 return -1;
930 }
Max Morin787eeed2016-06-23 10:42:07 +0200931 *samplesPerSec = sampleRate;
Max Morin2c332bb2016-07-04 09:03:42 +0200932 LOG(INFO) << "output: " << *samplesPerSec;
Max Morin787eeed2016-06-23 10:42:07 +0200933 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000934}
935
henrika4af73662017-10-11 13:16:17 +0200936int32_t AudioDeviceModuleImpl::SetLoudspeakerStatus(bool enable) {
937 LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
938 CHECKinitialized_();
939 if (audio_device_->SetLoudspeakerStatus(enable) != 0) {
940 return -1;
941 }
942 return 0;
943}
niklase@google.com470e71d2011-07-07 08:21:25 +0000944
henrikac14f5ff2015-09-23 14:08:33 +0200945int32_t AudioDeviceModuleImpl::GetLoudspeakerStatus(bool* enabled) const {
Max Morin098e6c52016-06-28 09:36:25 +0200946 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200947 CHECKinitialized_();
Max Morin098e6c52016-06-28 09:36:25 +0200948 int32_t ok = 0;
henrika4af73662017-10-11 13:16:17 +0200949 if (audio_device_->GetLoudspeakerStatus(*enabled) != 0) {
Max Morin098e6c52016-06-28 09:36:25 +0200950 ok = -1;
henrikac14f5ff2015-09-23 14:08:33 +0200951 }
Max Morin2c332bb2016-07-04 09:03:42 +0200952 LOG(INFO) << "output: " << ok;
Max Morin098e6c52016-06-28 09:36:25 +0200953 return ok;
andrew@webrtc.orga3c6d612011-09-13 17:17:49 +0000954}
955
henrika@webrtc.orga954c072014-12-09 16:22:09 +0000956bool AudioDeviceModuleImpl::BuiltInAECIsAvailable() const {
Max Morin098e6c52016-06-28 09:36:25 +0200957 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200958 CHECKinitialized__BOOL();
959 bool isAvailable = audio_device_->BuiltInAECIsAvailable();
Max Morin2c332bb2016-07-04 09:03:42 +0200960 LOG(INFO) << "output: " << isAvailable;
Max Morin098e6c52016-06-28 09:36:25 +0200961 return isAvailable;
henrika@webrtc.orga954c072014-12-09 16:22:09 +0000962}
963
henrikac14f5ff2015-09-23 14:08:33 +0200964int32_t AudioDeviceModuleImpl::EnableBuiltInAEC(bool enable) {
Max Morin098e6c52016-06-28 09:36:25 +0200965 LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200966 CHECKinitialized_();
967 int32_t ok = audio_device_->EnableBuiltInAEC(enable);
Max Morin2c332bb2016-07-04 09:03:42 +0200968 LOG(INFO) << "output: " << ok;
Max Morin098e6c52016-06-28 09:36:25 +0200969 return ok;
henrikac14f5ff2015-09-23 14:08:33 +0200970}
971
972bool AudioDeviceModuleImpl::BuiltInAGCIsAvailable() const {
Max Morin098e6c52016-06-28 09:36:25 +0200973 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200974 CHECKinitialized__BOOL();
975 bool isAvailable = audio_device_->BuiltInAGCIsAvailable();
Max Morin2c332bb2016-07-04 09:03:42 +0200976 LOG(INFO) << "output: " << isAvailable;
Max Morin098e6c52016-06-28 09:36:25 +0200977 return isAvailable;
henrikac14f5ff2015-09-23 14:08:33 +0200978}
979
980int32_t AudioDeviceModuleImpl::EnableBuiltInAGC(bool enable) {
Max Morin098e6c52016-06-28 09:36:25 +0200981 LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200982 CHECKinitialized_();
983 int32_t ok = audio_device_->EnableBuiltInAGC(enable);
Max Morin2c332bb2016-07-04 09:03:42 +0200984 LOG(INFO) << "output: " << ok;
Max Morin098e6c52016-06-28 09:36:25 +0200985 return ok;
henrikac14f5ff2015-09-23 14:08:33 +0200986}
987
988bool AudioDeviceModuleImpl::BuiltInNSIsAvailable() const {
Max Morin098e6c52016-06-28 09:36:25 +0200989 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +0200990 CHECKinitialized__BOOL();
991 bool isAvailable = audio_device_->BuiltInNSIsAvailable();
Max Morin2c332bb2016-07-04 09:03:42 +0200992 LOG(INFO) << "output: " << isAvailable;
Max Morin098e6c52016-06-28 09:36:25 +0200993 return isAvailable;
henrikac14f5ff2015-09-23 14:08:33 +0200994}
995
996int32_t AudioDeviceModuleImpl::EnableBuiltInNS(bool enable) {
Max Morin098e6c52016-06-28 09:36:25 +0200997 LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrika4af73662017-10-11 13:16:17 +0200998 CHECKinitialized_();
999 int32_t ok = audio_device_->EnableBuiltInNS(enable);
Max Morin2c332bb2016-07-04 09:03:42 +02001000 LOG(INFO) << "output: " << ok;
Max Morin098e6c52016-06-28 09:36:25 +02001001 return ok;
henrikac14f5ff2015-09-23 14:08:33 +02001002}
1003
maxmorin88e31a32016-08-16 00:56:09 -07001004#if defined(WEBRTC_IOS)
henrikaba35d052015-07-14 17:04:08 +02001005int AudioDeviceModuleImpl::GetPlayoutAudioParameters(
1006 AudioParameters* params) const {
Max Morin098e6c52016-06-28 09:36:25 +02001007 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +02001008 int r = audio_device_->GetPlayoutAudioParameters(params);
Max Morin2c332bb2016-07-04 09:03:42 +02001009 LOG(INFO) << "output: " << r;
Max Morin098e6c52016-06-28 09:36:25 +02001010 return r;
henrikaba35d052015-07-14 17:04:08 +02001011}
1012
1013int AudioDeviceModuleImpl::GetRecordAudioParameters(
1014 AudioParameters* params) const {
Max Morin098e6c52016-06-28 09:36:25 +02001015 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +02001016 int r = audio_device_->GetRecordAudioParameters(params);
Max Morin2c332bb2016-07-04 09:03:42 +02001017 LOG(INFO) << "output: " << r;
Max Morin098e6c52016-06-28 09:36:25 +02001018 return r;
henrikaba35d052015-07-14 17:04:08 +02001019}
maxmorin88e31a32016-08-16 00:56:09 -07001020#endif // WEBRTC_IOS
henrikaba35d052015-07-14 17:04:08 +02001021
Max Morin787eeed2016-06-23 10:42:07 +02001022AudioDeviceModuleImpl::PlatformType AudioDeviceModuleImpl::Platform() const {
Max Morin098e6c52016-06-28 09:36:25 +02001023 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +02001024 return platform_type_;
niklase@google.com470e71d2011-07-07 08:21:25 +00001025}
1026
Max Morin787eeed2016-06-23 10:42:07 +02001027AudioDeviceModule::AudioLayer AudioDeviceModuleImpl::PlatformAudioLayer()
1028 const {
Max Morin098e6c52016-06-28 09:36:25 +02001029 LOG(INFO) << __FUNCTION__;
henrika4af73662017-10-11 13:16:17 +02001030 return audio_layer_;
niklase@google.com470e71d2011-07-07 08:21:25 +00001031}
1032
1033} // namespace webrtc