blob: 5701f5948a065de3e671f2851736b738ec94a60f [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"
12#include "common_audio/signal_processing/include/signal_processing_library.h"
13#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"
18#include "rtc_base/timeutils.h"
19#include "system_wrappers/include/metrics.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000020
andrew@webrtc.orga3c6d612011-09-13 17:17:49 +000021#include <assert.h>
xians@google.combf5d2ba2011-08-16 07:44:19 +000022#include <string.h>
niklase@google.com470e71d2011-07-07 08:21:25 +000023
24#if defined(_WIN32)
Max Morin787eeed2016-06-23 10:42:07 +020025#if defined(WEBRTC_WINDOWS_CORE_AUDIO_BUILD)
26#include "audio_device_core_win.h"
27#endif
leozwang@google.com39f20512011-07-15 16:29:40 +000028#elif defined(WEBRTC_ANDROID)
henrikab2619892015-05-18 16:49:16 +020029#include <stdlib.h>
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020030#include "modules/audio_device/android/audio_device_template.h"
31#include "modules/audio_device/android/audio_manager.h"
32#include "modules/audio_device/android/audio_record_jni.h"
33#include "modules/audio_device/android/audio_track_jni.h"
34#include "modules/audio_device/android/opensles_player.h"
35#include "modules/audio_device/android/opensles_recorder.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000036#elif defined(WEBRTC_LINUX)
Max Morin787eeed2016-06-23 10:42:07 +020037#if defined(LINUX_ALSA)
38#include "audio_device_alsa_linux.h"
39#endif
Tommi68898a22015-05-19 17:28:07 +020040#if defined(LINUX_PULSE)
Max Morin787eeed2016-06-23 10:42:07 +020041#include "audio_device_pulse_linux.h"
Tommi68898a22015-05-19 17:28:07 +020042#endif
sjlee@webrtc.org414fa7f2012-09-11 17:25:46 +000043#elif defined(WEBRTC_IOS)
Max Morin787eeed2016-06-23 10:42:07 +020044#include "audio_device_ios.h"
andrew@webrtc.orgf3b65db2012-09-06 18:17:00 +000045#elif defined(WEBRTC_MAC)
Max Morin787eeed2016-06-23 10:42:07 +020046#include "audio_device_mac.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000047#endif
phoglund@webrtc.org8454ad12014-06-11 14:12:04 +000048
49#if defined(WEBRTC_DUMMY_FILE_DEVICES)
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020050#include "modules/audio_device/dummy/file_audio_device_factory.h"
phoglund@webrtc.org8454ad12014-06-11 14:12:04 +000051#endif
52
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020053#include "modules/audio_device/dummy/audio_device_dummy.h"
54#include "modules/audio_device/dummy/file_audio_device.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000055
Max Morin787eeed2016-06-23 10:42:07 +020056#define CHECK_INITIALIZED() \
57 { \
58 if (!_initialized) { \
59 return -1; \
60 }; \
61 }
niklase@google.com470e71d2011-07-07 08:21:25 +000062
Max Morin787eeed2016-06-23 10:42:07 +020063#define CHECK_INITIALIZED_BOOL() \
64 { \
65 if (!_initialized) { \
66 return false; \
67 }; \
68 }
niklase@google.com470e71d2011-07-07 08:21:25 +000069
Peter Boström1d194412016-03-21 16:44:31 +010070namespace webrtc {
henrike@webrtc.org70efc322012-02-23 17:45:33 +000071
niklase@google.com470e71d2011-07-07 08:21:25 +000072// ============================================================================
73// Static methods
74// ============================================================================
75
76// ----------------------------------------------------------------------------
77// AudioDeviceModule::Create()
78// ----------------------------------------------------------------------------
79
Peter Boström4adbbcf2016-05-03 15:51:26 -040080rtc::scoped_refptr<AudioDeviceModule> AudioDeviceModule::Create(
Peter Boström1d194412016-03-21 16:44:31 +010081 const int32_t id,
Peter Boström4adbbcf2016-05-03 15:51:26 -040082 const AudioLayer audio_layer) {
Max Morin098e6c52016-06-28 09:36:25 +020083 LOG(INFO) << __FUNCTION__;
Max Morin787eeed2016-06-23 10:42:07 +020084 // Create the generic ref counted (platform independent) implementation.
85 rtc::scoped_refptr<AudioDeviceModuleImpl> audioDevice(
86 new rtc::RefCountedObject<AudioDeviceModuleImpl>(id, audio_layer));
niklase@google.com470e71d2011-07-07 08:21:25 +000087
Max Morin787eeed2016-06-23 10:42:07 +020088 // Ensure that the current platform is supported.
89 if (audioDevice->CheckPlatform() == -1) {
90 return nullptr;
91 }
niklase@google.com470e71d2011-07-07 08:21:25 +000092
Max Morin787eeed2016-06-23 10:42:07 +020093 // Create the platform-dependent implementation.
94 if (audioDevice->CreatePlatformSpecificObjects() == -1) {
95 return nullptr;
96 }
niklase@google.com470e71d2011-07-07 08:21:25 +000097
Max Morin787eeed2016-06-23 10:42:07 +020098 // Ensure that the generic audio buffer can communicate with the
99 // platform-specific parts.
100 if (audioDevice->AttachAudioBuffer() == -1) {
101 return nullptr;
102 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000103
Max Morin787eeed2016-06-23 10:42:07 +0200104 WebRtcSpl_Init();
kma@webrtc.orgac4d70d2012-10-05 00:19:01 +0000105
Max Morin787eeed2016-06-23 10:42:07 +0200106 return audioDevice;
niklase@google.com470e71d2011-07-07 08:21:25 +0000107}
108
niklase@google.com470e71d2011-07-07 08:21:25 +0000109// ============================================================================
110// Construction & Destruction
111// ============================================================================
112
113// ----------------------------------------------------------------------------
114// AudioDeviceModuleImpl - ctor
115// ----------------------------------------------------------------------------
116
Max Morin787eeed2016-06-23 10:42:07 +0200117AudioDeviceModuleImpl::AudioDeviceModuleImpl(const int32_t id,
118 const AudioLayer audioLayer)
Fredrik Solenberga32dd012017-10-04 13:27:21 +0200119 : _ptrAudioDevice(NULL),
Max Morin787eeed2016-06-23 10:42:07 +0200120 _id(id),
121 _platformAudioLayer(audioLayer),
Max Morin787eeed2016-06-23 10:42:07 +0200122 _platformType(kPlatformNotSupported),
123 _initialized(false),
124 _lastError(kAdmErrNone) {
Max Morin098e6c52016-06-28 09:36:25 +0200125 LOG(INFO) << __FUNCTION__;
niklase@google.com470e71d2011-07-07 08:21:25 +0000126}
127
128// ----------------------------------------------------------------------------
129// CheckPlatform
130// ----------------------------------------------------------------------------
131
Max Morin787eeed2016-06-23 10:42:07 +0200132int32_t AudioDeviceModuleImpl::CheckPlatform() {
Max Morin098e6c52016-06-28 09:36:25 +0200133 LOG(INFO) << __FUNCTION__;
niklase@google.com470e71d2011-07-07 08:21:25 +0000134
Max Morin787eeed2016-06-23 10:42:07 +0200135 // Ensure that the current platform is supported
136 //
137 PlatformType platform(kPlatformNotSupported);
niklase@google.com470e71d2011-07-07 08:21:25 +0000138
139#if defined(_WIN32)
Max Morin787eeed2016-06-23 10:42:07 +0200140 platform = kPlatformWin32;
Max Morin098e6c52016-06-28 09:36:25 +0200141 LOG(INFO) << "current platform is Win32";
leozwang@google.com522f42b2011-09-19 17:39:05 +0000142#elif defined(WEBRTC_ANDROID)
Max Morin787eeed2016-06-23 10:42:07 +0200143 platform = kPlatformAndroid;
Max Morin098e6c52016-06-28 09:36:25 +0200144 LOG(INFO) << "current platform is Android";
niklase@google.com470e71d2011-07-07 08:21:25 +0000145#elif defined(WEBRTC_LINUX)
Max Morin787eeed2016-06-23 10:42:07 +0200146 platform = kPlatformLinux;
Max Morin098e6c52016-06-28 09:36:25 +0200147 LOG(INFO) << "current platform is Linux";
sjlee@webrtc.org414fa7f2012-09-11 17:25:46 +0000148#elif defined(WEBRTC_IOS)
Max Morin787eeed2016-06-23 10:42:07 +0200149 platform = kPlatformIOS;
Max Morin098e6c52016-06-28 09:36:25 +0200150 LOG(INFO) << "current platform is IOS";
andrew@webrtc.orgf3b65db2012-09-06 18:17:00 +0000151#elif defined(WEBRTC_MAC)
Max Morin787eeed2016-06-23 10:42:07 +0200152 platform = kPlatformMac;
Max Morin098e6c52016-06-28 09:36:25 +0200153 LOG(INFO) << "current platform is Mac";
niklase@google.com470e71d2011-07-07 08:21:25 +0000154#endif
155
Max Morin787eeed2016-06-23 10:42:07 +0200156 if (platform == kPlatformNotSupported) {
Max Morin098e6c52016-06-28 09:36:25 +0200157 LOG(LERROR) << "current platform is not supported => this module will self "
158 "destruct!";
Max Morin787eeed2016-06-23 10:42:07 +0200159 return -1;
160 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000161
Max Morin787eeed2016-06-23 10:42:07 +0200162 // Store valid output results
163 //
164 _platformType = platform;
niklase@google.com470e71d2011-07-07 08:21:25 +0000165
Max Morin787eeed2016-06-23 10:42:07 +0200166 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000167}
168
niklase@google.com470e71d2011-07-07 08:21:25 +0000169// ----------------------------------------------------------------------------
170// CreatePlatformSpecificObjects
171// ----------------------------------------------------------------------------
172
Max Morin787eeed2016-06-23 10:42:07 +0200173int32_t AudioDeviceModuleImpl::CreatePlatformSpecificObjects() {
Max Morin098e6c52016-06-28 09:36:25 +0200174 LOG(INFO) << __FUNCTION__;
niklase@google.com470e71d2011-07-07 08:21:25 +0000175
Max Morin787eeed2016-06-23 10:42:07 +0200176 AudioDeviceGeneric* ptrAudioDevice(NULL);
niklase@google.com470e71d2011-07-07 08:21:25 +0000177
xians@google.combf5d2ba2011-08-16 07:44:19 +0000178#if defined(WEBRTC_DUMMY_AUDIO_BUILD)
Max Morin787eeed2016-06-23 10:42:07 +0200179 ptrAudioDevice = new AudioDeviceDummy(Id());
Max Morin098e6c52016-06-28 09:36:25 +0200180 LOG(INFO) << "Dummy Audio APIs will be utilized";
phoglund@webrtc.org8454ad12014-06-11 14:12:04 +0000181#elif defined(WEBRTC_DUMMY_FILE_DEVICES)
Max Morin787eeed2016-06-23 10:42:07 +0200182 ptrAudioDevice = FileAudioDeviceFactory::CreateFileAudioDevice(Id());
noahric6a355902016-08-17 15:19:50 -0700183 if (ptrAudioDevice) {
184 LOG(INFO) << "Will use file-playing dummy device.";
185 } else {
186 // Create a dummy device instead.
187 ptrAudioDevice = new AudioDeviceDummy(Id());
188 LOG(INFO) << "Dummy Audio APIs will be utilized";
189 }
xians@google.combf5d2ba2011-08-16 07:44:19 +0000190#else
Max Morin787eeed2016-06-23 10:42:07 +0200191 AudioLayer audioLayer(PlatformAudioLayer());
niklase@google.com470e71d2011-07-07 08:21:25 +0000192
Max Morin787eeed2016-06-23 10:42:07 +0200193// Create the *Windows* implementation of the Audio Device
194//
niklase@google.com470e71d2011-07-07 08:21:25 +0000195#if defined(WEBRTC_WINDOWS_CORE_AUDIO_BUILD)
Max Morin787eeed2016-06-23 10:42:07 +0200196 if ((audioLayer == kWindowsCoreAudio) ||
197 (audioLayer == kPlatformDefaultAudio)) {
Max Morin098e6c52016-06-28 09:36:25 +0200198 LOG(INFO) << "attempting to use the Windows Core Audio APIs...";
niklase@google.com470e71d2011-07-07 08:21:25 +0000199
Max Morin787eeed2016-06-23 10:42:07 +0200200 if (AudioDeviceWindowsCore::CoreAudioIsSupported()) {
201 // create *Windows Core Audio* implementation
sazab4aa4eb2017-07-19 01:12:36 -0700202 ptrAudioDevice = new AudioDeviceWindowsCore();
Max Morin098e6c52016-06-28 09:36:25 +0200203 LOG(INFO) << "Windows Core Audio APIs will be utilized";
niklase@google.com470e71d2011-07-07 08:21:25 +0000204 }
Max Morin787eeed2016-06-23 10:42:07 +0200205 }
206#endif // defined(WEBRTC_WINDOWS_CORE_AUDIO_BUILD)
niklase@google.com470e71d2011-07-07 08:21:25 +0000207
henrike@webrtc.org9ee75e92013-12-11 21:42:44 +0000208#if defined(WEBRTC_ANDROID)
Max Morin787eeed2016-06-23 10:42:07 +0200209 // Create an Android audio manager.
210 _audioManagerAndroid.reset(new AudioManager());
211 // Select best possible combination of audio layers.
212 if (audioLayer == kPlatformDefaultAudio) {
henrika918b5542016-09-19 15:44:09 +0200213 if (_audioManagerAndroid->IsLowLatencyPlayoutSupported() &&
214 _audioManagerAndroid->IsLowLatencyRecordSupported()) {
215 // Use OpenSL ES for both playout and recording.
216 audioLayer = kAndroidOpenSLESAudio;
217 } else if (_audioManagerAndroid->IsLowLatencyPlayoutSupported() &&
218 !_audioManagerAndroid->IsLowLatencyRecordSupported()) {
219 // Use OpenSL ES for output on devices that only supports the
Max Morin787eeed2016-06-23 10:42:07 +0200220 // low-latency output audio path.
221 audioLayer = kAndroidJavaInputAndOpenSLESOutputAudio;
henrikab2619892015-05-18 16:49:16 +0200222 } else {
henrika918b5542016-09-19 15:44:09 +0200223 // Use Java-based audio in both directions when low-latency output is
224 // not supported.
Max Morin787eeed2016-06-23 10:42:07 +0200225 audioLayer = kAndroidJavaAudio;
niklase@google.com470e71d2011-07-07 08:21:25 +0000226 }
Max Morin787eeed2016-06-23 10:42:07 +0200227 }
228 AudioManager* audio_manager = _audioManagerAndroid.get();
229 if (audioLayer == kAndroidJavaAudio) {
230 // Java audio for both input and output audio.
231 ptrAudioDevice = new AudioDeviceTemplate<AudioRecordJni, AudioTrackJni>(
232 audioLayer, audio_manager);
henrika918b5542016-09-19 15:44:09 +0200233 } else if (audioLayer == kAndroidOpenSLESAudio) {
234 // OpenSL ES based audio for both input and output audio.
235 ptrAudioDevice = new AudioDeviceTemplate<OpenSLESRecorder, OpenSLESPlayer>(
236 audioLayer, audio_manager);
Max Morin787eeed2016-06-23 10:42:07 +0200237 } else if (audioLayer == kAndroidJavaInputAndOpenSLESOutputAudio) {
238 // Java audio for input and OpenSL ES for output audio (i.e. mixed APIs).
239 // This combination provides low-latency output audio and at the same
240 // time support for HW AEC using the AudioRecord Java API.
241 ptrAudioDevice = new AudioDeviceTemplate<AudioRecordJni, OpenSLESPlayer>(
242 audioLayer, audio_manager);
243 } else {
244 // Invalid audio layer.
henrika918b5542016-09-19 15:44:09 +0200245 ptrAudioDevice = nullptr;
Max Morin787eeed2016-06-23 10:42:07 +0200246 }
247// END #if defined(WEBRTC_ANDROID)
niklase@google.com470e71d2011-07-07 08:21:25 +0000248
Max Morin787eeed2016-06-23 10:42:07 +0200249// Create the *Linux* implementation of the Audio Device
250//
niklase@google.com470e71d2011-07-07 08:21:25 +0000251#elif defined(WEBRTC_LINUX)
Max Morin787eeed2016-06-23 10:42:07 +0200252 if ((audioLayer == kLinuxPulseAudio) ||
253 (audioLayer == kPlatformDefaultAudio)) {
niklase@google.com470e71d2011-07-07 08:21:25 +0000254#if defined(LINUX_PULSE)
Max Morin098e6c52016-06-28 09:36:25 +0200255 LOG(INFO) << "attempting to use the Linux PulseAudio APIs...";
niklase@google.com470e71d2011-07-07 08:21:25 +0000256
Max Morin787eeed2016-06-23 10:42:07 +0200257 // create *Linux PulseAudio* implementation
saza43a85f02017-07-18 04:12:29 -0700258 AudioDeviceLinuxPulse* pulseDevice = new AudioDeviceLinuxPulse();
Max Morin84cab202016-07-01 13:35:19 +0200259 if (pulseDevice->Init() == AudioDeviceGeneric::InitStatus::OK) {
Max Morin787eeed2016-06-23 10:42:07 +0200260 ptrAudioDevice = pulseDevice;
Max Morin098e6c52016-06-28 09:36:25 +0200261 LOG(INFO) << "Linux PulseAudio APIs will be utilized";
Max Morin787eeed2016-06-23 10:42:07 +0200262 } else {
263 delete pulseDevice;
niklase@google.com470e71d2011-07-07 08:21:25 +0000264#endif
265#if defined(LINUX_ALSA)
Max Morin787eeed2016-06-23 10:42:07 +0200266 // create *Linux ALSA Audio* implementation
saza43a85f02017-07-18 04:12:29 -0700267 ptrAudioDevice = new AudioDeviceLinuxALSA();
Max Morin787eeed2016-06-23 10:42:07 +0200268 if (ptrAudioDevice != NULL) {
269 // Pulse Audio was not supported => revert to ALSA instead
270 _platformAudioLayer =
271 kLinuxAlsaAudio; // modify the state set at construction
Max Morin098e6c52016-06-28 09:36:25 +0200272 LOG(WARNING) << "Linux PulseAudio is *not* supported => ALSA APIs will "
273 "be utilized instead";
Max Morin787eeed2016-06-23 10:42:07 +0200274 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000275#endif
276#if defined(LINUX_PULSE)
niklase@google.com470e71d2011-07-07 08:21:25 +0000277 }
Max Morin787eeed2016-06-23 10:42:07 +0200278#endif
279 } else if (audioLayer == kLinuxAlsaAudio) {
niklase@google.com470e71d2011-07-07 08:21:25 +0000280#if defined(LINUX_ALSA)
Max Morin787eeed2016-06-23 10:42:07 +0200281 // create *Linux ALSA Audio* implementation
saza43a85f02017-07-18 04:12:29 -0700282 ptrAudioDevice = new AudioDeviceLinuxALSA();
Max Morin098e6c52016-06-28 09:36:25 +0200283 LOG(INFO) << "Linux ALSA APIs will be utilized";
niklase@google.com470e71d2011-07-07 08:21:25 +0000284#endif
Max Morin787eeed2016-06-23 10:42:07 +0200285 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000286#endif // #if defined(WEBRTC_LINUX)
287
Max Morin787eeed2016-06-23 10:42:07 +0200288// Create the *iPhone* implementation of the Audio Device
289//
sjlee@webrtc.org414fa7f2012-09-11 17:25:46 +0000290#if defined(WEBRTC_IOS)
Max Morin787eeed2016-06-23 10:42:07 +0200291 if (audioLayer == kPlatformDefaultAudio) {
292 // Create iOS Audio Device implementation.
293 ptrAudioDevice = new AudioDeviceIOS();
Max Morin098e6c52016-06-28 09:36:25 +0200294 LOG(INFO) << "iPhone Audio APIs will be utilized";
Max Morin787eeed2016-06-23 10:42:07 +0200295 }
296// END #if defined(WEBRTC_IOS)
niklase@google.com470e71d2011-07-07 08:21:25 +0000297
Max Morin787eeed2016-06-23 10:42:07 +0200298// Create the *Mac* implementation of the Audio Device
299//
andrew@webrtc.orgf3b65db2012-09-06 18:17:00 +0000300#elif defined(WEBRTC_MAC)
Max Morin787eeed2016-06-23 10:42:07 +0200301 if (audioLayer == kPlatformDefaultAudio) {
302 // Create *Mac Audio* implementation
sazab4aa4eb2017-07-19 01:12:36 -0700303 ptrAudioDevice = new AudioDeviceMac();
Max Morin098e6c52016-06-28 09:36:25 +0200304 LOG(INFO) << "Mac OS X Audio APIs will be utilized";
Max Morin787eeed2016-06-23 10:42:07 +0200305 }
andrew@webrtc.orgf3b65db2012-09-06 18:17:00 +0000306#endif // WEBRTC_MAC
niklase@google.com470e71d2011-07-07 08:21:25 +0000307
Max Morin787eeed2016-06-23 10:42:07 +0200308 // Create the *Dummy* implementation of the Audio Device
309 // Available for all platforms
310 //
311 if (audioLayer == kDummyAudio) {
312 // Create *Dummy Audio* implementation
313 assert(!ptrAudioDevice);
314 ptrAudioDevice = new AudioDeviceDummy(Id());
Max Morin098e6c52016-06-28 09:36:25 +0200315 LOG(INFO) << "Dummy Audio APIs will be utilized";
Max Morin787eeed2016-06-23 10:42:07 +0200316 }
xians@google.combf5d2ba2011-08-16 07:44:19 +0000317#endif // if defined(WEBRTC_DUMMY_AUDIO_BUILD)
niklase@google.com470e71d2011-07-07 08:21:25 +0000318
Max Morin787eeed2016-06-23 10:42:07 +0200319 if (ptrAudioDevice == NULL) {
Max Morin098e6c52016-06-28 09:36:25 +0200320 LOG(LERROR)
321 << "unable to create the platform specific audio device implementation";
Max Morin787eeed2016-06-23 10:42:07 +0200322 return -1;
323 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000324
Max Morin787eeed2016-06-23 10:42:07 +0200325 // Store valid output pointers
326 //
327 _ptrAudioDevice = ptrAudioDevice;
niklase@google.com470e71d2011-07-07 08:21:25 +0000328
Max Morin787eeed2016-06-23 10:42:07 +0200329 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000330}
331
332// ----------------------------------------------------------------------------
333// AttachAudioBuffer
334//
335// Install "bridge" between the platform implemetation and the generic
336// implementation. The "child" shall set the native sampling rate and the
337// number of channels in this function call.
338// ----------------------------------------------------------------------------
339
Max Morin787eeed2016-06-23 10:42:07 +0200340int32_t AudioDeviceModuleImpl::AttachAudioBuffer() {
Max Morin098e6c52016-06-28 09:36:25 +0200341 LOG(INFO) << __FUNCTION__;
niklase@google.com470e71d2011-07-07 08:21:25 +0000342
Max Morin787eeed2016-06-23 10:42:07 +0200343 _audioDeviceBuffer.SetId(_id);
344 _ptrAudioDevice->AttachAudioBuffer(&_audioDeviceBuffer);
345 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000346}
347
348// ----------------------------------------------------------------------------
349// ~AudioDeviceModuleImpl - dtor
350// ----------------------------------------------------------------------------
351
Max Morin787eeed2016-06-23 10:42:07 +0200352AudioDeviceModuleImpl::~AudioDeviceModuleImpl() {
Max Morin098e6c52016-06-28 09:36:25 +0200353 LOG(INFO) << __FUNCTION__;
Max Morin787eeed2016-06-23 10:42:07 +0200354 if (_ptrAudioDevice) {
355 delete _ptrAudioDevice;
356 _ptrAudioDevice = NULL;
357 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000358}
359
360// ============================================================================
niklase@google.com470e71d2011-07-07 08:21:25 +0000361// Public API
362// ============================================================================
363
364// ----------------------------------------------------------------------------
365// ActiveAudioLayer
366// ----------------------------------------------------------------------------
367
henrikab2619892015-05-18 16:49:16 +0200368int32_t AudioDeviceModuleImpl::ActiveAudioLayer(AudioLayer* audioLayer) const {
Max Morin098e6c52016-06-28 09:36:25 +0200369 LOG(INFO) << __FUNCTION__;
henrikab2619892015-05-18 16:49:16 +0200370 AudioLayer activeAudio;
371 if (_ptrAudioDevice->ActiveAudioLayer(activeAudio) == -1) {
372 return -1;
373 }
374 *audioLayer = activeAudio;
375 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000376}
377
378// ----------------------------------------------------------------------------
379// LastError
380// ----------------------------------------------------------------------------
381
Max Morin787eeed2016-06-23 10:42:07 +0200382AudioDeviceModule::ErrorCode AudioDeviceModuleImpl::LastError() const {
Max Morin098e6c52016-06-28 09:36:25 +0200383 LOG(INFO) << __FUNCTION__;
Max Morin787eeed2016-06-23 10:42:07 +0200384 return _lastError;
niklase@google.com470e71d2011-07-07 08:21:25 +0000385}
386
387// ----------------------------------------------------------------------------
388// Init
389// ----------------------------------------------------------------------------
390
Max Morin787eeed2016-06-23 10:42:07 +0200391int32_t AudioDeviceModuleImpl::Init() {
Max Morin098e6c52016-06-28 09:36:25 +0200392 LOG(INFO) << __FUNCTION__;
Max Morin787eeed2016-06-23 10:42:07 +0200393 if (_initialized)
niklase@google.com470e71d2011-07-07 08:21:25 +0000394 return 0;
Max Morin84cab202016-07-01 13:35:19 +0200395 RTC_CHECK(_ptrAudioDevice);
Max Morin787eeed2016-06-23 10:42:07 +0200396
Max Morin84cab202016-07-01 13:35:19 +0200397 AudioDeviceGeneric::InitStatus status = _ptrAudioDevice->Init();
398 RTC_HISTOGRAM_ENUMERATION(
399 "WebRTC.Audio.InitializationResult", static_cast<int>(status),
400 static_cast<int>(AudioDeviceGeneric::InitStatus::NUM_STATUSES));
401 if (status != AudioDeviceGeneric::InitStatus::OK) {
402 LOG(LS_ERROR) << "Audio device initialization failed.";
Max Morin787eeed2016-06-23 10:42:07 +0200403 return -1;
404 }
405
406 _initialized = true;
407 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000408}
409
410// ----------------------------------------------------------------------------
411// Terminate
412// ----------------------------------------------------------------------------
413
Max Morin787eeed2016-06-23 10:42:07 +0200414int32_t AudioDeviceModuleImpl::Terminate() {
Max Morin098e6c52016-06-28 09:36:25 +0200415 LOG(INFO) << __FUNCTION__;
Max Morin787eeed2016-06-23 10:42:07 +0200416 if (!_initialized)
niklase@google.com470e71d2011-07-07 08:21:25 +0000417 return 0;
Max Morin787eeed2016-06-23 10:42:07 +0200418
419 if (_ptrAudioDevice->Terminate() == -1) {
420 return -1;
421 }
422
423 _initialized = false;
424 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000425}
426
427// ----------------------------------------------------------------------------
428// Initialized
429// ----------------------------------------------------------------------------
430
Max Morin787eeed2016-06-23 10:42:07 +0200431bool AudioDeviceModuleImpl::Initialized() const {
Max Morin098e6c52016-06-28 09:36:25 +0200432 LOG(INFO) << __FUNCTION__ << ": " << _initialized;
Max Morin787eeed2016-06-23 10:42:07 +0200433 return (_initialized);
niklase@google.com470e71d2011-07-07 08:21:25 +0000434}
435
436// ----------------------------------------------------------------------------
niklase@google.com470e71d2011-07-07 08:21:25 +0000437// InitSpeaker
438// ----------------------------------------------------------------------------
439
Max Morin787eeed2016-06-23 10:42:07 +0200440int32_t AudioDeviceModuleImpl::InitSpeaker() {
Max Morin098e6c52016-06-28 09:36:25 +0200441 LOG(INFO) << __FUNCTION__;
Max Morin787eeed2016-06-23 10:42:07 +0200442 CHECK_INITIALIZED();
443 return (_ptrAudioDevice->InitSpeaker());
niklase@google.com470e71d2011-07-07 08:21:25 +0000444}
445
446// ----------------------------------------------------------------------------
niklase@google.com470e71d2011-07-07 08:21:25 +0000447// InitMicrophone
448// ----------------------------------------------------------------------------
449
Max Morin787eeed2016-06-23 10:42:07 +0200450int32_t AudioDeviceModuleImpl::InitMicrophone() {
Max Morin098e6c52016-06-28 09:36:25 +0200451 LOG(INFO) << __FUNCTION__;
Max Morin787eeed2016-06-23 10:42:07 +0200452 CHECK_INITIALIZED();
453 return (_ptrAudioDevice->InitMicrophone());
niklase@google.com470e71d2011-07-07 08:21:25 +0000454}
455
456// ----------------------------------------------------------------------------
457// SpeakerVolumeIsAvailable
458// ----------------------------------------------------------------------------
459
Max Morin787eeed2016-06-23 10:42:07 +0200460int32_t AudioDeviceModuleImpl::SpeakerVolumeIsAvailable(bool* available) {
Max Morin098e6c52016-06-28 09:36:25 +0200461 LOG(INFO) << __FUNCTION__;
Max Morin787eeed2016-06-23 10:42:07 +0200462 CHECK_INITIALIZED();
niklase@google.com470e71d2011-07-07 08:21:25 +0000463
Max Morin787eeed2016-06-23 10:42:07 +0200464 bool isAvailable(0);
niklase@google.com470e71d2011-07-07 08:21:25 +0000465
Max Morin787eeed2016-06-23 10:42:07 +0200466 if (_ptrAudioDevice->SpeakerVolumeIsAvailable(isAvailable) == -1) {
467 return -1;
468 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000469
Max Morin787eeed2016-06-23 10:42:07 +0200470 *available = isAvailable;
Max Morin2c332bb2016-07-04 09:03:42 +0200471 LOG(INFO) << "output: " << isAvailable;
Max Morin787eeed2016-06-23 10:42:07 +0200472 return (0);
niklase@google.com470e71d2011-07-07 08:21:25 +0000473}
474
475// ----------------------------------------------------------------------------
476// SetSpeakerVolume
477// ----------------------------------------------------------------------------
478
Max Morin787eeed2016-06-23 10:42:07 +0200479int32_t AudioDeviceModuleImpl::SetSpeakerVolume(uint32_t volume) {
Max Morin098e6c52016-06-28 09:36:25 +0200480 LOG(INFO) << __FUNCTION__ << "(" << volume << ")";
Max Morin787eeed2016-06-23 10:42:07 +0200481 CHECK_INITIALIZED();
482 return (_ptrAudioDevice->SetSpeakerVolume(volume));
niklase@google.com470e71d2011-07-07 08:21:25 +0000483}
484
485// ----------------------------------------------------------------------------
486// SpeakerVolume
487// ----------------------------------------------------------------------------
488
Max Morin787eeed2016-06-23 10:42:07 +0200489int32_t AudioDeviceModuleImpl::SpeakerVolume(uint32_t* volume) const {
Max Morin098e6c52016-06-28 09:36:25 +0200490 LOG(INFO) << __FUNCTION__;
Max Morin787eeed2016-06-23 10:42:07 +0200491 CHECK_INITIALIZED();
niklase@google.com470e71d2011-07-07 08:21:25 +0000492
Max Morin787eeed2016-06-23 10:42:07 +0200493 uint32_t level(0);
niklase@google.com470e71d2011-07-07 08:21:25 +0000494
Max Morin787eeed2016-06-23 10:42:07 +0200495 if (_ptrAudioDevice->SpeakerVolume(level) == -1) {
496 return -1;
497 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000498
Max Morin787eeed2016-06-23 10:42:07 +0200499 *volume = level;
Max Morin2c332bb2016-07-04 09:03:42 +0200500 LOG(INFO) << "output: " << *volume;
Max Morin787eeed2016-06-23 10:42:07 +0200501 return (0);
niklase@google.com470e71d2011-07-07 08:21:25 +0000502}
503
504// ----------------------------------------------------------------------------
niklase@google.com470e71d2011-07-07 08:21:25 +0000505// SpeakerIsInitialized
506// ----------------------------------------------------------------------------
507
Max Morin787eeed2016-06-23 10:42:07 +0200508bool AudioDeviceModuleImpl::SpeakerIsInitialized() const {
Max Morin098e6c52016-06-28 09:36:25 +0200509 LOG(INFO) << __FUNCTION__;
Max Morin787eeed2016-06-23 10:42:07 +0200510 CHECK_INITIALIZED_BOOL();
niklase@google.com470e71d2011-07-07 08:21:25 +0000511
Max Morin787eeed2016-06-23 10:42:07 +0200512 bool isInitialized = _ptrAudioDevice->SpeakerIsInitialized();
Max Morin2c332bb2016-07-04 09:03:42 +0200513 LOG(INFO) << "output: " << isInitialized;
Max Morin787eeed2016-06-23 10:42:07 +0200514 return (isInitialized);
niklase@google.com470e71d2011-07-07 08:21:25 +0000515}
516
517// ----------------------------------------------------------------------------
518// MicrophoneIsInitialized
519// ----------------------------------------------------------------------------
520
Max Morin787eeed2016-06-23 10:42:07 +0200521bool AudioDeviceModuleImpl::MicrophoneIsInitialized() const {
Max Morin098e6c52016-06-28 09:36:25 +0200522 LOG(INFO) << __FUNCTION__;
Max Morin787eeed2016-06-23 10:42:07 +0200523 CHECK_INITIALIZED_BOOL();
niklase@google.com470e71d2011-07-07 08:21:25 +0000524
Max Morin787eeed2016-06-23 10:42:07 +0200525 bool isInitialized = _ptrAudioDevice->MicrophoneIsInitialized();
Max Morin2c332bb2016-07-04 09:03:42 +0200526 LOG(INFO) << "output: " << isInitialized;
Max Morin787eeed2016-06-23 10:42:07 +0200527 return (isInitialized);
niklase@google.com470e71d2011-07-07 08:21:25 +0000528}
529
530// ----------------------------------------------------------------------------
531// MaxSpeakerVolume
532// ----------------------------------------------------------------------------
533
Max Morin787eeed2016-06-23 10:42:07 +0200534int32_t AudioDeviceModuleImpl::MaxSpeakerVolume(uint32_t* maxVolume) const {
535 CHECK_INITIALIZED();
niklase@google.com470e71d2011-07-07 08:21:25 +0000536
Max Morin787eeed2016-06-23 10:42:07 +0200537 uint32_t maxVol(0);
niklase@google.com470e71d2011-07-07 08:21:25 +0000538
Max Morin787eeed2016-06-23 10:42:07 +0200539 if (_ptrAudioDevice->MaxSpeakerVolume(maxVol) == -1) {
540 return -1;
541 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000542
Max Morin787eeed2016-06-23 10:42:07 +0200543 *maxVolume = maxVol;
Max Morin787eeed2016-06-23 10:42:07 +0200544 return (0);
niklase@google.com470e71d2011-07-07 08:21:25 +0000545}
546
547// ----------------------------------------------------------------------------
548// MinSpeakerVolume
549// ----------------------------------------------------------------------------
550
Max Morin787eeed2016-06-23 10:42:07 +0200551int32_t AudioDeviceModuleImpl::MinSpeakerVolume(uint32_t* minVolume) const {
552 CHECK_INITIALIZED();
niklase@google.com470e71d2011-07-07 08:21:25 +0000553
Max Morin787eeed2016-06-23 10:42:07 +0200554 uint32_t minVol(0);
niklase@google.com470e71d2011-07-07 08:21:25 +0000555
Max Morin787eeed2016-06-23 10:42:07 +0200556 if (_ptrAudioDevice->MinSpeakerVolume(minVol) == -1) {
557 return -1;
558 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000559
Max Morin787eeed2016-06-23 10:42:07 +0200560 *minVolume = minVol;
Max Morin787eeed2016-06-23 10:42:07 +0200561 return (0);
niklase@google.com470e71d2011-07-07 08:21:25 +0000562}
563
564// ----------------------------------------------------------------------------
niklase@google.com470e71d2011-07-07 08:21:25 +0000565// SpeakerMuteIsAvailable
566// ----------------------------------------------------------------------------
567
Max Morin787eeed2016-06-23 10:42:07 +0200568int32_t AudioDeviceModuleImpl::SpeakerMuteIsAvailable(bool* available) {
Max Morin098e6c52016-06-28 09:36:25 +0200569 LOG(INFO) << __FUNCTION__;
Max Morin787eeed2016-06-23 10:42:07 +0200570 CHECK_INITIALIZED();
niklase@google.com470e71d2011-07-07 08:21:25 +0000571
Max Morin787eeed2016-06-23 10:42:07 +0200572 bool isAvailable(0);
niklase@google.com470e71d2011-07-07 08:21:25 +0000573
Max Morin787eeed2016-06-23 10:42:07 +0200574 if (_ptrAudioDevice->SpeakerMuteIsAvailable(isAvailable) == -1) {
575 return -1;
576 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000577
Max Morin787eeed2016-06-23 10:42:07 +0200578 *available = isAvailable;
Max Morin2c332bb2016-07-04 09:03:42 +0200579 LOG(INFO) << "output: " << isAvailable;
Max Morin787eeed2016-06-23 10:42:07 +0200580 return (0);
niklase@google.com470e71d2011-07-07 08:21:25 +0000581}
582
583// ----------------------------------------------------------------------------
584// SetSpeakerMute
585// ----------------------------------------------------------------------------
586
Max Morin787eeed2016-06-23 10:42:07 +0200587int32_t AudioDeviceModuleImpl::SetSpeakerMute(bool enable) {
Max Morin098e6c52016-06-28 09:36:25 +0200588 LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
Max Morin787eeed2016-06-23 10:42:07 +0200589 CHECK_INITIALIZED();
590 return (_ptrAudioDevice->SetSpeakerMute(enable));
niklase@google.com470e71d2011-07-07 08:21:25 +0000591}
592
593// ----------------------------------------------------------------------------
594// SpeakerMute
595// ----------------------------------------------------------------------------
596
Max Morin787eeed2016-06-23 10:42:07 +0200597int32_t AudioDeviceModuleImpl::SpeakerMute(bool* enabled) const {
Max Morin098e6c52016-06-28 09:36:25 +0200598 LOG(INFO) << __FUNCTION__;
Max Morin787eeed2016-06-23 10:42:07 +0200599 CHECK_INITIALIZED();
niklase@google.com470e71d2011-07-07 08:21:25 +0000600
Max Morin787eeed2016-06-23 10:42:07 +0200601 bool muted(false);
niklase@google.com470e71d2011-07-07 08:21:25 +0000602
Max Morin787eeed2016-06-23 10:42:07 +0200603 if (_ptrAudioDevice->SpeakerMute(muted) == -1) {
604 return -1;
605 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000606
Max Morin787eeed2016-06-23 10:42:07 +0200607 *enabled = muted;
Max Morin2c332bb2016-07-04 09:03:42 +0200608 LOG(INFO) << "output: " << muted;
Max Morin787eeed2016-06-23 10:42:07 +0200609 return (0);
niklase@google.com470e71d2011-07-07 08:21:25 +0000610}
611
612// ----------------------------------------------------------------------------
613// MicrophoneMuteIsAvailable
614// ----------------------------------------------------------------------------
615
Max Morin787eeed2016-06-23 10:42:07 +0200616int32_t AudioDeviceModuleImpl::MicrophoneMuteIsAvailable(bool* available) {
Max Morin098e6c52016-06-28 09:36:25 +0200617 LOG(INFO) << __FUNCTION__;
Max Morin787eeed2016-06-23 10:42:07 +0200618 CHECK_INITIALIZED();
niklase@google.com470e71d2011-07-07 08:21:25 +0000619
Max Morin787eeed2016-06-23 10:42:07 +0200620 bool isAvailable(0);
niklase@google.com470e71d2011-07-07 08:21:25 +0000621
Max Morin787eeed2016-06-23 10:42:07 +0200622 if (_ptrAudioDevice->MicrophoneMuteIsAvailable(isAvailable) == -1) {
623 return -1;
624 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000625
Max Morin787eeed2016-06-23 10:42:07 +0200626 *available = isAvailable;
Max Morin2c332bb2016-07-04 09:03:42 +0200627 LOG(INFO) << "output: " << isAvailable;
Max Morin787eeed2016-06-23 10:42:07 +0200628 return (0);
niklase@google.com470e71d2011-07-07 08:21:25 +0000629}
630
631// ----------------------------------------------------------------------------
632// SetMicrophoneMute
633// ----------------------------------------------------------------------------
634
Max Morin787eeed2016-06-23 10:42:07 +0200635int32_t AudioDeviceModuleImpl::SetMicrophoneMute(bool enable) {
Max Morin098e6c52016-06-28 09:36:25 +0200636 LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
Max Morin787eeed2016-06-23 10:42:07 +0200637 CHECK_INITIALIZED();
638 return (_ptrAudioDevice->SetMicrophoneMute(enable));
niklase@google.com470e71d2011-07-07 08:21:25 +0000639}
640
641// ----------------------------------------------------------------------------
642// MicrophoneMute
643// ----------------------------------------------------------------------------
644
Max Morin787eeed2016-06-23 10:42:07 +0200645int32_t AudioDeviceModuleImpl::MicrophoneMute(bool* enabled) const {
Max Morin098e6c52016-06-28 09:36:25 +0200646 LOG(INFO) << __FUNCTION__;
Max Morin787eeed2016-06-23 10:42:07 +0200647 CHECK_INITIALIZED();
niklase@google.com470e71d2011-07-07 08:21:25 +0000648
Max Morin787eeed2016-06-23 10:42:07 +0200649 bool muted(false);
niklase@google.com470e71d2011-07-07 08:21:25 +0000650
Max Morin787eeed2016-06-23 10:42:07 +0200651 if (_ptrAudioDevice->MicrophoneMute(muted) == -1) {
652 return -1;
653 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000654
Max Morin787eeed2016-06-23 10:42:07 +0200655 *enabled = muted;
Max Morin2c332bb2016-07-04 09:03:42 +0200656 LOG(INFO) << "output: " << muted;
Max Morin787eeed2016-06-23 10:42:07 +0200657 return (0);
niklase@google.com470e71d2011-07-07 08:21:25 +0000658}
659
660// ----------------------------------------------------------------------------
niklase@google.com470e71d2011-07-07 08:21:25 +0000661// MicrophoneVolumeIsAvailable
662// ----------------------------------------------------------------------------
663
Max Morin787eeed2016-06-23 10:42:07 +0200664int32_t AudioDeviceModuleImpl::MicrophoneVolumeIsAvailable(bool* available) {
Max Morin098e6c52016-06-28 09:36:25 +0200665 LOG(INFO) << __FUNCTION__;
Max Morin787eeed2016-06-23 10:42:07 +0200666 CHECK_INITIALIZED();
niklase@google.com470e71d2011-07-07 08:21:25 +0000667
Max Morin787eeed2016-06-23 10:42:07 +0200668 bool isAvailable(0);
niklase@google.com470e71d2011-07-07 08:21:25 +0000669
Max Morin787eeed2016-06-23 10:42:07 +0200670 if (_ptrAudioDevice->MicrophoneVolumeIsAvailable(isAvailable) == -1) {
671 return -1;
672 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000673
Max Morin787eeed2016-06-23 10:42:07 +0200674 *available = isAvailable;
Max Morin2c332bb2016-07-04 09:03:42 +0200675 LOG(INFO) << "output: " << isAvailable;
Max Morin787eeed2016-06-23 10:42:07 +0200676 return (0);
niklase@google.com470e71d2011-07-07 08:21:25 +0000677}
678
679// ----------------------------------------------------------------------------
680// SetMicrophoneVolume
681// ----------------------------------------------------------------------------
682
Max Morin787eeed2016-06-23 10:42:07 +0200683int32_t AudioDeviceModuleImpl::SetMicrophoneVolume(uint32_t volume) {
Max Morin098e6c52016-06-28 09:36:25 +0200684 LOG(INFO) << __FUNCTION__ << "(" << volume << ")";
Max Morin787eeed2016-06-23 10:42:07 +0200685 CHECK_INITIALIZED();
686 return (_ptrAudioDevice->SetMicrophoneVolume(volume));
niklase@google.com470e71d2011-07-07 08:21:25 +0000687}
688
689// ----------------------------------------------------------------------------
690// MicrophoneVolume
691// ----------------------------------------------------------------------------
692
Max Morin787eeed2016-06-23 10:42:07 +0200693int32_t AudioDeviceModuleImpl::MicrophoneVolume(uint32_t* volume) const {
Max Morin098e6c52016-06-28 09:36:25 +0200694 LOG(INFO) << __FUNCTION__;
Max Morin787eeed2016-06-23 10:42:07 +0200695 CHECK_INITIALIZED();
niklase@google.com470e71d2011-07-07 08:21:25 +0000696
Max Morin787eeed2016-06-23 10:42:07 +0200697 uint32_t level(0);
niklase@google.com470e71d2011-07-07 08:21:25 +0000698
Max Morin787eeed2016-06-23 10:42:07 +0200699 if (_ptrAudioDevice->MicrophoneVolume(level) == -1) {
700 return -1;
701 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000702
Max Morin787eeed2016-06-23 10:42:07 +0200703 *volume = level;
Max Morin2c332bb2016-07-04 09:03:42 +0200704 LOG(INFO) << "output: " << *volume;
Max Morin787eeed2016-06-23 10:42:07 +0200705 return (0);
niklase@google.com470e71d2011-07-07 08:21:25 +0000706}
707
708// ----------------------------------------------------------------------------
709// StereoRecordingIsAvailable
710// ----------------------------------------------------------------------------
711
Max Morin787eeed2016-06-23 10:42:07 +0200712int32_t AudioDeviceModuleImpl::StereoRecordingIsAvailable(
713 bool* available) const {
Max Morin098e6c52016-06-28 09:36:25 +0200714 LOG(INFO) << __FUNCTION__;
Max Morin787eeed2016-06-23 10:42:07 +0200715 CHECK_INITIALIZED();
niklase@google.com470e71d2011-07-07 08:21:25 +0000716
Max Morin787eeed2016-06-23 10:42:07 +0200717 bool isAvailable(0);
niklase@google.com470e71d2011-07-07 08:21:25 +0000718
Max Morin787eeed2016-06-23 10:42:07 +0200719 if (_ptrAudioDevice->StereoRecordingIsAvailable(isAvailable) == -1) {
720 return -1;
721 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000722
Max Morin787eeed2016-06-23 10:42:07 +0200723 *available = isAvailable;
Max Morin2c332bb2016-07-04 09:03:42 +0200724 LOG(INFO) << "output: " << isAvailable;
Max Morin787eeed2016-06-23 10:42:07 +0200725 return (0);
niklase@google.com470e71d2011-07-07 08:21:25 +0000726}
727
728// ----------------------------------------------------------------------------
729// SetStereoRecording
730// ----------------------------------------------------------------------------
731
Max Morin787eeed2016-06-23 10:42:07 +0200732int32_t AudioDeviceModuleImpl::SetStereoRecording(bool enable) {
Max Morin098e6c52016-06-28 09:36:25 +0200733 LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
Max Morin787eeed2016-06-23 10:42:07 +0200734 CHECK_INITIALIZED();
niklase@google.com470e71d2011-07-07 08:21:25 +0000735
Max Morin787eeed2016-06-23 10:42:07 +0200736 if (_ptrAudioDevice->RecordingIsInitialized()) {
Max Morin098e6c52016-06-28 09:36:25 +0200737 LOG(WARNING) << "recording in stereo is not supported";
Max Morin787eeed2016-06-23 10:42:07 +0200738 return -1;
739 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000740
Max Morin787eeed2016-06-23 10:42:07 +0200741 if (_ptrAudioDevice->SetStereoRecording(enable) == -1) {
Max Morin2c332bb2016-07-04 09:03:42 +0200742 LOG(WARNING) << "failed to change stereo recording";
Max Morin787eeed2016-06-23 10:42:07 +0200743 return -1;
744 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000745
Max Morin787eeed2016-06-23 10:42:07 +0200746 int8_t nChannels(1);
747 if (enable) {
748 nChannels = 2;
749 }
750 _audioDeviceBuffer.SetRecordingChannels(nChannels);
niklase@google.com470e71d2011-07-07 08:21:25 +0000751
Max Morin787eeed2016-06-23 10:42:07 +0200752 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000753}
754
755// ----------------------------------------------------------------------------
756// StereoRecording
757// ----------------------------------------------------------------------------
758
Max Morin787eeed2016-06-23 10:42:07 +0200759int32_t AudioDeviceModuleImpl::StereoRecording(bool* enabled) const {
Max Morin098e6c52016-06-28 09:36:25 +0200760 LOG(INFO) << __FUNCTION__;
Max Morin787eeed2016-06-23 10:42:07 +0200761 CHECK_INITIALIZED();
niklase@google.com470e71d2011-07-07 08:21:25 +0000762
Max Morin787eeed2016-06-23 10:42:07 +0200763 bool stereo(false);
niklase@google.com470e71d2011-07-07 08:21:25 +0000764
Max Morin787eeed2016-06-23 10:42:07 +0200765 if (_ptrAudioDevice->StereoRecording(stereo) == -1) {
766 return -1;
767 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000768
Max Morin787eeed2016-06-23 10:42:07 +0200769 *enabled = stereo;
Max Morin2c332bb2016-07-04 09:03:42 +0200770 LOG(INFO) << "output: " << stereo;
Max Morin787eeed2016-06-23 10:42:07 +0200771 return (0);
niklase@google.com470e71d2011-07-07 08:21:25 +0000772}
773
774// ----------------------------------------------------------------------------
775// SetRecordingChannel
776// ----------------------------------------------------------------------------
777
Max Morin787eeed2016-06-23 10:42:07 +0200778int32_t AudioDeviceModuleImpl::SetRecordingChannel(const ChannelType channel) {
779 if (channel == kChannelBoth) {
Max Morin098e6c52016-06-28 09:36:25 +0200780 LOG(INFO) << __FUNCTION__ << "(both)";
Max Morin787eeed2016-06-23 10:42:07 +0200781 } else if (channel == kChannelLeft) {
Max Morin098e6c52016-06-28 09:36:25 +0200782 LOG(INFO) << __FUNCTION__ << "(left)";
Max Morin787eeed2016-06-23 10:42:07 +0200783 } else {
Max Morin098e6c52016-06-28 09:36:25 +0200784 LOG(INFO) << __FUNCTION__ << "(right)";
Max Morin787eeed2016-06-23 10:42:07 +0200785 }
786 CHECK_INITIALIZED();
niklase@google.com470e71d2011-07-07 08:21:25 +0000787
Max Morin787eeed2016-06-23 10:42:07 +0200788 bool stereo(false);
niklase@google.com470e71d2011-07-07 08:21:25 +0000789
Max Morin787eeed2016-06-23 10:42:07 +0200790 if (_ptrAudioDevice->StereoRecording(stereo) == -1) {
Max Morin098e6c52016-06-28 09:36:25 +0200791 LOG(WARNING) << "recording in stereo is not supported";
Max Morin787eeed2016-06-23 10:42:07 +0200792 return -1;
793 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000794
Max Morin787eeed2016-06-23 10:42:07 +0200795 return (_audioDeviceBuffer.SetRecordingChannel(channel));
niklase@google.com470e71d2011-07-07 08:21:25 +0000796}
797
798// ----------------------------------------------------------------------------
799// RecordingChannel
800// ----------------------------------------------------------------------------
801
Max Morin787eeed2016-06-23 10:42:07 +0200802int32_t AudioDeviceModuleImpl::RecordingChannel(ChannelType* channel) const {
Max Morin098e6c52016-06-28 09:36:25 +0200803 LOG(INFO) << __FUNCTION__;
Max Morin787eeed2016-06-23 10:42:07 +0200804 CHECK_INITIALIZED();
niklase@google.com470e71d2011-07-07 08:21:25 +0000805
Max Morin787eeed2016-06-23 10:42:07 +0200806 ChannelType chType;
niklase@google.com470e71d2011-07-07 08:21:25 +0000807
Max Morin787eeed2016-06-23 10:42:07 +0200808 if (_audioDeviceBuffer.RecordingChannel(chType) == -1) {
809 return -1;
810 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000811
Max Morin787eeed2016-06-23 10:42:07 +0200812 *channel = chType;
Max Morin787eeed2016-06-23 10:42:07 +0200813 if (*channel == kChannelBoth) {
Max Morin2c332bb2016-07-04 09:03:42 +0200814 LOG(INFO) << "output: both";
Max Morin787eeed2016-06-23 10:42:07 +0200815 } else if (*channel == kChannelLeft) {
Max Morin2c332bb2016-07-04 09:03:42 +0200816 LOG(INFO) << "output: left";
Max Morin787eeed2016-06-23 10:42:07 +0200817 } else {
Max Morin2c332bb2016-07-04 09:03:42 +0200818 LOG(INFO) << "output: right";
Max Morin787eeed2016-06-23 10:42:07 +0200819 }
Max Morin787eeed2016-06-23 10:42:07 +0200820 return (0);
niklase@google.com470e71d2011-07-07 08:21:25 +0000821}
822
823// ----------------------------------------------------------------------------
824// StereoPlayoutIsAvailable
825// ----------------------------------------------------------------------------
826
Max Morin787eeed2016-06-23 10:42:07 +0200827int32_t AudioDeviceModuleImpl::StereoPlayoutIsAvailable(bool* available) const {
Max Morin098e6c52016-06-28 09:36:25 +0200828 LOG(INFO) << __FUNCTION__;
Max Morin787eeed2016-06-23 10:42:07 +0200829 CHECK_INITIALIZED();
niklase@google.com470e71d2011-07-07 08:21:25 +0000830
Max Morin787eeed2016-06-23 10:42:07 +0200831 bool isAvailable(0);
niklase@google.com470e71d2011-07-07 08:21:25 +0000832
Max Morin787eeed2016-06-23 10:42:07 +0200833 if (_ptrAudioDevice->StereoPlayoutIsAvailable(isAvailable) == -1) {
834 return -1;
835 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000836
Max Morin787eeed2016-06-23 10:42:07 +0200837 *available = isAvailable;
Max Morin2c332bb2016-07-04 09:03:42 +0200838 LOG(INFO) << "output: " << isAvailable;
Max Morin787eeed2016-06-23 10:42:07 +0200839 return (0);
niklase@google.com470e71d2011-07-07 08:21:25 +0000840}
841
842// ----------------------------------------------------------------------------
843// SetStereoPlayout
844// ----------------------------------------------------------------------------
845
Max Morin787eeed2016-06-23 10:42:07 +0200846int32_t AudioDeviceModuleImpl::SetStereoPlayout(bool enable) {
Max Morin098e6c52016-06-28 09:36:25 +0200847 LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
Max Morin787eeed2016-06-23 10:42:07 +0200848 CHECK_INITIALIZED();
niklase@google.com470e71d2011-07-07 08:21:25 +0000849
Max Morin787eeed2016-06-23 10:42:07 +0200850 if (_ptrAudioDevice->PlayoutIsInitialized()) {
Max Morin098e6c52016-06-28 09:36:25 +0200851 LOG(LERROR)
852 << "unable to set stereo mode while playing side is initialized";
Max Morin787eeed2016-06-23 10:42:07 +0200853 return -1;
854 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000855
Max Morin787eeed2016-06-23 10:42:07 +0200856 if (_ptrAudioDevice->SetStereoPlayout(enable)) {
Max Morin098e6c52016-06-28 09:36:25 +0200857 LOG(WARNING) << "stereo playout is not supported";
Max Morin787eeed2016-06-23 10:42:07 +0200858 return -1;
859 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000860
Max Morin787eeed2016-06-23 10:42:07 +0200861 int8_t nChannels(1);
862 if (enable) {
863 nChannels = 2;
864 }
865 _audioDeviceBuffer.SetPlayoutChannels(nChannels);
niklase@google.com470e71d2011-07-07 08:21:25 +0000866
Max Morin787eeed2016-06-23 10:42:07 +0200867 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000868}
869
870// ----------------------------------------------------------------------------
871// StereoPlayout
872// ----------------------------------------------------------------------------
873
Max Morin787eeed2016-06-23 10:42:07 +0200874int32_t AudioDeviceModuleImpl::StereoPlayout(bool* enabled) const {
Max Morin098e6c52016-06-28 09:36:25 +0200875 LOG(INFO) << __FUNCTION__;
Max Morin787eeed2016-06-23 10:42:07 +0200876 CHECK_INITIALIZED();
niklase@google.com470e71d2011-07-07 08:21:25 +0000877
Max Morin787eeed2016-06-23 10:42:07 +0200878 bool stereo(false);
niklase@google.com470e71d2011-07-07 08:21:25 +0000879
Max Morin787eeed2016-06-23 10:42:07 +0200880 if (_ptrAudioDevice->StereoPlayout(stereo) == -1) {
881 return -1;
882 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000883
Max Morin787eeed2016-06-23 10:42:07 +0200884 *enabled = stereo;
Max Morin2c332bb2016-07-04 09:03:42 +0200885 LOG(INFO) << "output: " << stereo;
Max Morin787eeed2016-06-23 10:42:07 +0200886 return (0);
niklase@google.com470e71d2011-07-07 08:21:25 +0000887}
888
889// ----------------------------------------------------------------------------
890// SetAGC
891// ----------------------------------------------------------------------------
892
Max Morin787eeed2016-06-23 10:42:07 +0200893int32_t AudioDeviceModuleImpl::SetAGC(bool enable) {
Max Morin098e6c52016-06-28 09:36:25 +0200894 LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
Max Morin787eeed2016-06-23 10:42:07 +0200895 CHECK_INITIALIZED();
896 return (_ptrAudioDevice->SetAGC(enable));
niklase@google.com470e71d2011-07-07 08:21:25 +0000897}
898
899// ----------------------------------------------------------------------------
900// AGC
901// ----------------------------------------------------------------------------
902
Max Morin787eeed2016-06-23 10:42:07 +0200903bool AudioDeviceModuleImpl::AGC() const {
Max Morin098e6c52016-06-28 09:36:25 +0200904 LOG(INFO) << __FUNCTION__;
Max Morin787eeed2016-06-23 10:42:07 +0200905 CHECK_INITIALIZED_BOOL();
906 return (_ptrAudioDevice->AGC());
niklase@google.com470e71d2011-07-07 08:21:25 +0000907}
908
909// ----------------------------------------------------------------------------
910// PlayoutIsAvailable
911// ----------------------------------------------------------------------------
912
Max Morin787eeed2016-06-23 10:42:07 +0200913int32_t AudioDeviceModuleImpl::PlayoutIsAvailable(bool* available) {
Max Morin098e6c52016-06-28 09:36:25 +0200914 LOG(INFO) << __FUNCTION__;
Max Morin787eeed2016-06-23 10:42:07 +0200915 CHECK_INITIALIZED();
niklase@google.com470e71d2011-07-07 08:21:25 +0000916
Max Morin787eeed2016-06-23 10:42:07 +0200917 bool isAvailable(0);
niklase@google.com470e71d2011-07-07 08:21:25 +0000918
Max Morin787eeed2016-06-23 10:42:07 +0200919 if (_ptrAudioDevice->PlayoutIsAvailable(isAvailable) == -1) {
920 return -1;
921 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000922
Max Morin787eeed2016-06-23 10:42:07 +0200923 *available = isAvailable;
Max Morin2c332bb2016-07-04 09:03:42 +0200924 LOG(INFO) << "output: " << isAvailable;
Max Morin787eeed2016-06-23 10:42:07 +0200925 return (0);
niklase@google.com470e71d2011-07-07 08:21:25 +0000926}
927
928// ----------------------------------------------------------------------------
929// RecordingIsAvailable
930// ----------------------------------------------------------------------------
931
Max Morin787eeed2016-06-23 10:42:07 +0200932int32_t AudioDeviceModuleImpl::RecordingIsAvailable(bool* available) {
Max Morin098e6c52016-06-28 09:36:25 +0200933 LOG(INFO) << __FUNCTION__;
Max Morin787eeed2016-06-23 10:42:07 +0200934 CHECK_INITIALIZED();
niklase@google.com470e71d2011-07-07 08:21:25 +0000935
Max Morin787eeed2016-06-23 10:42:07 +0200936 bool isAvailable(0);
niklase@google.com470e71d2011-07-07 08:21:25 +0000937
Max Morin787eeed2016-06-23 10:42:07 +0200938 if (_ptrAudioDevice->RecordingIsAvailable(isAvailable) == -1) {
939 return -1;
940 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000941
Max Morin787eeed2016-06-23 10:42:07 +0200942 *available = isAvailable;
Max Morin2c332bb2016-07-04 09:03:42 +0200943 LOG(INFO) << "output: " << isAvailable;
Max Morin787eeed2016-06-23 10:42:07 +0200944 return (0);
niklase@google.com470e71d2011-07-07 08:21:25 +0000945}
946
947// ----------------------------------------------------------------------------
948// MaxMicrophoneVolume
949// ----------------------------------------------------------------------------
950
Max Morin787eeed2016-06-23 10:42:07 +0200951int32_t AudioDeviceModuleImpl::MaxMicrophoneVolume(uint32_t* maxVolume) const {
Max Morin787eeed2016-06-23 10:42:07 +0200952 CHECK_INITIALIZED();
niklase@google.com470e71d2011-07-07 08:21:25 +0000953
Max Morin787eeed2016-06-23 10:42:07 +0200954 uint32_t maxVol(0);
niklase@google.com470e71d2011-07-07 08:21:25 +0000955
Max Morin787eeed2016-06-23 10:42:07 +0200956 if (_ptrAudioDevice->MaxMicrophoneVolume(maxVol) == -1) {
957 return -1;
958 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000959
Max Morin787eeed2016-06-23 10:42:07 +0200960 *maxVolume = maxVol;
Max Morin787eeed2016-06-23 10:42:07 +0200961 return (0);
niklase@google.com470e71d2011-07-07 08:21:25 +0000962}
963
964// ----------------------------------------------------------------------------
965// MinMicrophoneVolume
966// ----------------------------------------------------------------------------
967
Max Morin787eeed2016-06-23 10:42:07 +0200968int32_t AudioDeviceModuleImpl::MinMicrophoneVolume(uint32_t* minVolume) const {
969 CHECK_INITIALIZED();
niklase@google.com470e71d2011-07-07 08:21:25 +0000970
Max Morin787eeed2016-06-23 10:42:07 +0200971 uint32_t minVol(0);
niklase@google.com470e71d2011-07-07 08:21:25 +0000972
Max Morin787eeed2016-06-23 10:42:07 +0200973 if (_ptrAudioDevice->MinMicrophoneVolume(minVol) == -1) {
974 return -1;
975 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000976
Max Morin787eeed2016-06-23 10:42:07 +0200977 *minVolume = minVol;
Max Morin787eeed2016-06-23 10:42:07 +0200978 return (0);
niklase@google.com470e71d2011-07-07 08:21:25 +0000979}
980
981// ----------------------------------------------------------------------------
niklase@google.com470e71d2011-07-07 08:21:25 +0000982// PlayoutDevices
983// ----------------------------------------------------------------------------
984
Max Morin787eeed2016-06-23 10:42:07 +0200985int16_t AudioDeviceModuleImpl::PlayoutDevices() {
Max Morin098e6c52016-06-28 09:36:25 +0200986 LOG(INFO) << __FUNCTION__;
Max Morin787eeed2016-06-23 10:42:07 +0200987 CHECK_INITIALIZED();
niklase@google.com470e71d2011-07-07 08:21:25 +0000988
Max Morin787eeed2016-06-23 10:42:07 +0200989 uint16_t nPlayoutDevices = _ptrAudioDevice->PlayoutDevices();
Max Morin2c332bb2016-07-04 09:03:42 +0200990 LOG(INFO) << "output: " << nPlayoutDevices;
Max Morin787eeed2016-06-23 10:42:07 +0200991 return ((int16_t)(nPlayoutDevices));
niklase@google.com470e71d2011-07-07 08:21:25 +0000992}
993
994// ----------------------------------------------------------------------------
995// SetPlayoutDevice I (II)
996// ----------------------------------------------------------------------------
997
Max Morin787eeed2016-06-23 10:42:07 +0200998int32_t AudioDeviceModuleImpl::SetPlayoutDevice(uint16_t index) {
Max Morin098e6c52016-06-28 09:36:25 +0200999 LOG(INFO) << __FUNCTION__ << "(" << index << ")";
Max Morin787eeed2016-06-23 10:42:07 +02001000 CHECK_INITIALIZED();
1001 return (_ptrAudioDevice->SetPlayoutDevice(index));
niklase@google.com470e71d2011-07-07 08:21:25 +00001002}
1003
1004// ----------------------------------------------------------------------------
1005// SetPlayoutDevice II (II)
1006// ----------------------------------------------------------------------------
1007
Max Morin787eeed2016-06-23 10:42:07 +02001008int32_t AudioDeviceModuleImpl::SetPlayoutDevice(WindowsDeviceType device) {
Max Morin098e6c52016-06-28 09:36:25 +02001009 LOG(INFO) << __FUNCTION__;
Max Morin787eeed2016-06-23 10:42:07 +02001010 CHECK_INITIALIZED();
niklase@google.com470e71d2011-07-07 08:21:25 +00001011
Max Morin787eeed2016-06-23 10:42:07 +02001012 return (_ptrAudioDevice->SetPlayoutDevice(device));
niklase@google.com470e71d2011-07-07 08:21:25 +00001013}
1014
1015// ----------------------------------------------------------------------------
1016// PlayoutDeviceName
1017// ----------------------------------------------------------------------------
1018
pbos@webrtc.org25509882013-04-09 10:30:35 +00001019int32_t AudioDeviceModuleImpl::PlayoutDeviceName(
1020 uint16_t index,
leozwang@webrtc.org28f39132012-03-01 18:01:48 +00001021 char name[kAdmMaxDeviceNameSize],
Max Morin787eeed2016-06-23 10:42:07 +02001022 char guid[kAdmMaxGuidSize]) {
Max Morin098e6c52016-06-28 09:36:25 +02001023 LOG(INFO) << __FUNCTION__ << "(" << index << ", ...)";
Max Morin787eeed2016-06-23 10:42:07 +02001024 CHECK_INITIALIZED();
niklase@google.com470e71d2011-07-07 08:21:25 +00001025
Max Morin787eeed2016-06-23 10:42:07 +02001026 if (name == NULL) {
1027 _lastError = kAdmErrArgument;
1028 return -1;
1029 }
niklase@google.com470e71d2011-07-07 08:21:25 +00001030
Max Morin787eeed2016-06-23 10:42:07 +02001031 if (_ptrAudioDevice->PlayoutDeviceName(index, name, guid) == -1) {
1032 return -1;
1033 }
niklase@google.com470e71d2011-07-07 08:21:25 +00001034
Max Morin787eeed2016-06-23 10:42:07 +02001035 if (name != NULL) {
Max Morin2c332bb2016-07-04 09:03:42 +02001036 LOG(INFO) << "output: name = " << name;
Max Morin787eeed2016-06-23 10:42:07 +02001037 }
1038 if (guid != NULL) {
Max Morin2c332bb2016-07-04 09:03:42 +02001039 LOG(INFO) << "output: guid = " << guid;
Max Morin787eeed2016-06-23 10:42:07 +02001040 }
niklase@google.com470e71d2011-07-07 08:21:25 +00001041
Max Morin787eeed2016-06-23 10:42:07 +02001042 return (0);
niklase@google.com470e71d2011-07-07 08:21:25 +00001043}
1044
1045// ----------------------------------------------------------------------------
1046// RecordingDeviceName
1047// ----------------------------------------------------------------------------
1048
pbos@webrtc.org25509882013-04-09 10:30:35 +00001049int32_t AudioDeviceModuleImpl::RecordingDeviceName(
1050 uint16_t index,
leozwang@webrtc.org28f39132012-03-01 18:01:48 +00001051 char name[kAdmMaxDeviceNameSize],
Max Morin787eeed2016-06-23 10:42:07 +02001052 char guid[kAdmMaxGuidSize]) {
Max Morin098e6c52016-06-28 09:36:25 +02001053 LOG(INFO) << __FUNCTION__ << "(" << index << ", ...)";
Max Morin787eeed2016-06-23 10:42:07 +02001054 CHECK_INITIALIZED();
niklase@google.com470e71d2011-07-07 08:21:25 +00001055
Max Morin787eeed2016-06-23 10:42:07 +02001056 if (name == NULL) {
1057 _lastError = kAdmErrArgument;
1058 return -1;
1059 }
niklase@google.com470e71d2011-07-07 08:21:25 +00001060
Max Morin787eeed2016-06-23 10:42:07 +02001061 if (_ptrAudioDevice->RecordingDeviceName(index, name, guid) == -1) {
1062 return -1;
1063 }
niklase@google.com470e71d2011-07-07 08:21:25 +00001064
Max Morin787eeed2016-06-23 10:42:07 +02001065 if (name != NULL) {
Max Morin2c332bb2016-07-04 09:03:42 +02001066 LOG(INFO) << "output: name = " << name;
Max Morin787eeed2016-06-23 10:42:07 +02001067 }
1068 if (guid != NULL) {
Max Morin2c332bb2016-07-04 09:03:42 +02001069 LOG(INFO) << "output: guid = " << guid;
Max Morin787eeed2016-06-23 10:42:07 +02001070 }
niklase@google.com470e71d2011-07-07 08:21:25 +00001071
Max Morin787eeed2016-06-23 10:42:07 +02001072 return (0);
niklase@google.com470e71d2011-07-07 08:21:25 +00001073}
1074
1075// ----------------------------------------------------------------------------
1076// RecordingDevices
1077// ----------------------------------------------------------------------------
1078
Max Morin787eeed2016-06-23 10:42:07 +02001079int16_t AudioDeviceModuleImpl::RecordingDevices() {
Max Morin098e6c52016-06-28 09:36:25 +02001080 LOG(INFO) << __FUNCTION__;
Max Morin787eeed2016-06-23 10:42:07 +02001081 CHECK_INITIALIZED();
niklase@google.com470e71d2011-07-07 08:21:25 +00001082
Max Morin787eeed2016-06-23 10:42:07 +02001083 uint16_t nRecordingDevices = _ptrAudioDevice->RecordingDevices();
niklase@google.com470e71d2011-07-07 08:21:25 +00001084
Max Morin2c332bb2016-07-04 09:03:42 +02001085 LOG(INFO) << "output: " << nRecordingDevices;
Max Morin787eeed2016-06-23 10:42:07 +02001086 return ((int16_t)nRecordingDevices);
niklase@google.com470e71d2011-07-07 08:21:25 +00001087}
1088
1089// ----------------------------------------------------------------------------
1090// SetRecordingDevice I (II)
1091// ----------------------------------------------------------------------------
1092
Max Morin787eeed2016-06-23 10:42:07 +02001093int32_t AudioDeviceModuleImpl::SetRecordingDevice(uint16_t index) {
Max Morin098e6c52016-06-28 09:36:25 +02001094 LOG(INFO) << __FUNCTION__ << "(" << index << ")";
Max Morin787eeed2016-06-23 10:42:07 +02001095 CHECK_INITIALIZED();
1096 return (_ptrAudioDevice->SetRecordingDevice(index));
niklase@google.com470e71d2011-07-07 08:21:25 +00001097}
1098
1099// ----------------------------------------------------------------------------
1100// SetRecordingDevice II (II)
1101// ----------------------------------------------------------------------------
1102
Max Morin787eeed2016-06-23 10:42:07 +02001103int32_t AudioDeviceModuleImpl::SetRecordingDevice(WindowsDeviceType device) {
Max Morin098e6c52016-06-28 09:36:25 +02001104 LOG(INFO) << __FUNCTION__;
Max Morin787eeed2016-06-23 10:42:07 +02001105 CHECK_INITIALIZED();
niklase@google.com470e71d2011-07-07 08:21:25 +00001106
Max Morin787eeed2016-06-23 10:42:07 +02001107 return (_ptrAudioDevice->SetRecordingDevice(device));
niklase@google.com470e71d2011-07-07 08:21:25 +00001108}
1109
1110// ----------------------------------------------------------------------------
1111// InitPlayout
1112// ----------------------------------------------------------------------------
1113
Max Morin787eeed2016-06-23 10:42:07 +02001114int32_t AudioDeviceModuleImpl::InitPlayout() {
Max Morin098e6c52016-06-28 09:36:25 +02001115 LOG(INFO) << __FUNCTION__;
Max Morin787eeed2016-06-23 10:42:07 +02001116 CHECK_INITIALIZED();
maxmorin8c695b42016-07-25 02:46:44 -07001117 if (PlayoutIsInitialized()) {
1118 return 0;
1119 }
Max Morin84cab202016-07-01 13:35:19 +02001120 int32_t result = _ptrAudioDevice->InitPlayout();
1121 LOG(INFO) << "output: " << result;
1122 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.InitPlayoutSuccess",
1123 static_cast<int>(result == 0));
1124 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +00001125}
1126
1127// ----------------------------------------------------------------------------
1128// InitRecording
1129// ----------------------------------------------------------------------------
1130
Max Morin787eeed2016-06-23 10:42:07 +02001131int32_t AudioDeviceModuleImpl::InitRecording() {
Max Morin098e6c52016-06-28 09:36:25 +02001132 LOG(INFO) << __FUNCTION__;
Max Morin787eeed2016-06-23 10:42:07 +02001133 CHECK_INITIALIZED();
maxmorin8c695b42016-07-25 02:46:44 -07001134 if (RecordingIsInitialized()) {
1135 return 0;
1136 }
Max Morin84cab202016-07-01 13:35:19 +02001137 int32_t result = _ptrAudioDevice->InitRecording();
1138 LOG(INFO) << "output: " << result;
1139 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.InitRecordingSuccess",
1140 static_cast<int>(result == 0));
1141 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +00001142}
1143
1144// ----------------------------------------------------------------------------
1145// PlayoutIsInitialized
1146// ----------------------------------------------------------------------------
1147
Max Morin787eeed2016-06-23 10:42:07 +02001148bool AudioDeviceModuleImpl::PlayoutIsInitialized() const {
Max Morin098e6c52016-06-28 09:36:25 +02001149 LOG(INFO) << __FUNCTION__;
Max Morin787eeed2016-06-23 10:42:07 +02001150 CHECK_INITIALIZED_BOOL();
1151 return (_ptrAudioDevice->PlayoutIsInitialized());
niklase@google.com470e71d2011-07-07 08:21:25 +00001152}
1153
1154// ----------------------------------------------------------------------------
1155// RecordingIsInitialized
1156// ----------------------------------------------------------------------------
1157
Max Morin787eeed2016-06-23 10:42:07 +02001158bool AudioDeviceModuleImpl::RecordingIsInitialized() const {
Max Morin098e6c52016-06-28 09:36:25 +02001159 LOG(INFO) << __FUNCTION__;
Max Morin787eeed2016-06-23 10:42:07 +02001160 CHECK_INITIALIZED_BOOL();
1161 return (_ptrAudioDevice->RecordingIsInitialized());
niklase@google.com470e71d2011-07-07 08:21:25 +00001162}
1163
1164// ----------------------------------------------------------------------------
1165// StartPlayout
1166// ----------------------------------------------------------------------------
1167
Max Morin787eeed2016-06-23 10:42:07 +02001168int32_t AudioDeviceModuleImpl::StartPlayout() {
Max Morin098e6c52016-06-28 09:36:25 +02001169 LOG(INFO) << __FUNCTION__;
Max Morin787eeed2016-06-23 10:42:07 +02001170 CHECK_INITIALIZED();
maxmorin8c695b42016-07-25 02:46:44 -07001171 if (Playing()) {
1172 return 0;
1173 }
henrikaba156cf2016-10-31 08:18:50 -07001174 _audioDeviceBuffer.StartPlayout();
Max Morin84cab202016-07-01 13:35:19 +02001175 int32_t result = _ptrAudioDevice->StartPlayout();
1176 LOG(INFO) << "output: " << result;
1177 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StartPlayoutSuccess",
1178 static_cast<int>(result == 0));
1179 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +00001180}
1181
1182// ----------------------------------------------------------------------------
1183// StopPlayout
1184// ----------------------------------------------------------------------------
1185
Max Morin787eeed2016-06-23 10:42:07 +02001186int32_t AudioDeviceModuleImpl::StopPlayout() {
Max Morin098e6c52016-06-28 09:36:25 +02001187 LOG(INFO) << __FUNCTION__;
Max Morin787eeed2016-06-23 10:42:07 +02001188 CHECK_INITIALIZED();
Max Morin84cab202016-07-01 13:35:19 +02001189 int32_t result = _ptrAudioDevice->StopPlayout();
henrikaba156cf2016-10-31 08:18:50 -07001190 _audioDeviceBuffer.StopPlayout();
Max Morin84cab202016-07-01 13:35:19 +02001191 LOG(INFO) << "output: " << result;
1192 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StopPlayoutSuccess",
1193 static_cast<int>(result == 0));
1194 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +00001195}
1196
1197// ----------------------------------------------------------------------------
1198// Playing
1199// ----------------------------------------------------------------------------
1200
Max Morin787eeed2016-06-23 10:42:07 +02001201bool AudioDeviceModuleImpl::Playing() const {
Max Morin098e6c52016-06-28 09:36:25 +02001202 LOG(INFO) << __FUNCTION__;
Max Morin787eeed2016-06-23 10:42:07 +02001203 CHECK_INITIALIZED_BOOL();
1204 return (_ptrAudioDevice->Playing());
niklase@google.com470e71d2011-07-07 08:21:25 +00001205}
1206
1207// ----------------------------------------------------------------------------
1208// StartRecording
1209// ----------------------------------------------------------------------------
1210
Max Morin787eeed2016-06-23 10:42:07 +02001211int32_t AudioDeviceModuleImpl::StartRecording() {
Max Morin098e6c52016-06-28 09:36:25 +02001212 LOG(INFO) << __FUNCTION__;
Max Morin787eeed2016-06-23 10:42:07 +02001213 CHECK_INITIALIZED();
maxmorin8c695b42016-07-25 02:46:44 -07001214 if (Recording()) {
1215 return 0;
1216 }
henrikaba156cf2016-10-31 08:18:50 -07001217 _audioDeviceBuffer.StartRecording();
Max Morin84cab202016-07-01 13:35:19 +02001218 int32_t result = _ptrAudioDevice->StartRecording();
1219 LOG(INFO) << "output: " << result;
1220 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StartRecordingSuccess",
1221 static_cast<int>(result == 0));
1222 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +00001223}
1224// ----------------------------------------------------------------------------
1225// StopRecording
1226// ----------------------------------------------------------------------------
1227
Max Morin787eeed2016-06-23 10:42:07 +02001228int32_t AudioDeviceModuleImpl::StopRecording() {
Max Morin098e6c52016-06-28 09:36:25 +02001229 LOG(INFO) << __FUNCTION__;
Max Morin787eeed2016-06-23 10:42:07 +02001230 CHECK_INITIALIZED();
Max Morin84cab202016-07-01 13:35:19 +02001231 int32_t result = _ptrAudioDevice->StopRecording();
henrikaba156cf2016-10-31 08:18:50 -07001232 _audioDeviceBuffer.StopRecording();
Max Morin84cab202016-07-01 13:35:19 +02001233 LOG(INFO) << "output: " << result;
1234 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StopRecordingSuccess",
1235 static_cast<int>(result == 0));
1236 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +00001237}
1238
1239// ----------------------------------------------------------------------------
1240// Recording
1241// ----------------------------------------------------------------------------
1242
Max Morin787eeed2016-06-23 10:42:07 +02001243bool AudioDeviceModuleImpl::Recording() const {
Max Morin098e6c52016-06-28 09:36:25 +02001244 LOG(INFO) << __FUNCTION__;
Max Morin787eeed2016-06-23 10:42:07 +02001245 CHECK_INITIALIZED_BOOL();
1246 return (_ptrAudioDevice->Recording());
niklase@google.com470e71d2011-07-07 08:21:25 +00001247}
1248
1249// ----------------------------------------------------------------------------
niklase@google.com470e71d2011-07-07 08:21:25 +00001250// RegisterAudioCallback
1251// ----------------------------------------------------------------------------
1252
Max Morin787eeed2016-06-23 10:42:07 +02001253int32_t AudioDeviceModuleImpl::RegisterAudioCallback(
1254 AudioTransport* audioCallback) {
Max Morin098e6c52016-06-28 09:36:25 +02001255 LOG(INFO) << __FUNCTION__;
kthelgason6bfe49c2017-03-30 01:14:41 -07001256 rtc::CritScope lock(&_critSectAudioCb);
henrikaf5022222016-11-07 15:56:59 +01001257 return _audioDeviceBuffer.RegisterAudioCallback(audioCallback);
niklase@google.com470e71d2011-07-07 08:21:25 +00001258}
1259
1260// ----------------------------------------------------------------------------
niklase@google.com470e71d2011-07-07 08:21:25 +00001261// PlayoutDelay
1262// ----------------------------------------------------------------------------
1263
Max Morin787eeed2016-06-23 10:42:07 +02001264int32_t AudioDeviceModuleImpl::PlayoutDelay(uint16_t* delayMS) const {
Max Morin787eeed2016-06-23 10:42:07 +02001265 CHECK_INITIALIZED();
niklase@google.com470e71d2011-07-07 08:21:25 +00001266
Max Morin787eeed2016-06-23 10:42:07 +02001267 uint16_t delay(0);
niklase@google.com470e71d2011-07-07 08:21:25 +00001268
Max Morin787eeed2016-06-23 10:42:07 +02001269 if (_ptrAudioDevice->PlayoutDelay(delay) == -1) {
Max Morin098e6c52016-06-28 09:36:25 +02001270 LOG(LERROR) << "failed to retrieve the playout delay";
Max Morin787eeed2016-06-23 10:42:07 +02001271 return -1;
1272 }
niklase@google.com470e71d2011-07-07 08:21:25 +00001273
Max Morin787eeed2016-06-23 10:42:07 +02001274 *delayMS = delay;
Max Morin787eeed2016-06-23 10:42:07 +02001275 return (0);
niklase@google.com470e71d2011-07-07 08:21:25 +00001276}
1277
1278// ----------------------------------------------------------------------------
1279// RecordingDelay
1280// ----------------------------------------------------------------------------
1281
Max Morin787eeed2016-06-23 10:42:07 +02001282int32_t AudioDeviceModuleImpl::RecordingDelay(uint16_t* delayMS) const {
Max Morin098e6c52016-06-28 09:36:25 +02001283 LOG(INFO) << __FUNCTION__;
Max Morin787eeed2016-06-23 10:42:07 +02001284 CHECK_INITIALIZED();
niklase@google.com470e71d2011-07-07 08:21:25 +00001285
Max Morin787eeed2016-06-23 10:42:07 +02001286 uint16_t delay(0);
niklase@google.com470e71d2011-07-07 08:21:25 +00001287
Max Morin787eeed2016-06-23 10:42:07 +02001288 if (_ptrAudioDevice->RecordingDelay(delay) == -1) {
Max Morin098e6c52016-06-28 09:36:25 +02001289 LOG(LERROR) << "failed to retrieve the recording delay";
Max Morin787eeed2016-06-23 10:42:07 +02001290 return -1;
1291 }
niklase@google.com470e71d2011-07-07 08:21:25 +00001292
Max Morin787eeed2016-06-23 10:42:07 +02001293 *delayMS = delay;
Max Morin2c332bb2016-07-04 09:03:42 +02001294 LOG(INFO) << "output: " << *delayMS;
Max Morin787eeed2016-06-23 10:42:07 +02001295 return (0);
niklase@google.com470e71d2011-07-07 08:21:25 +00001296}
1297
1298// ----------------------------------------------------------------------------
niklase@google.com470e71d2011-07-07 08:21:25 +00001299// SetRecordingSampleRate
1300// ----------------------------------------------------------------------------
1301
Max Morin787eeed2016-06-23 10:42:07 +02001302int32_t AudioDeviceModuleImpl::SetRecordingSampleRate(
1303 const uint32_t samplesPerSec) {
Max Morin098e6c52016-06-28 09:36:25 +02001304 LOG(INFO) << __FUNCTION__ << "(" << samplesPerSec << ")";
Max Morin787eeed2016-06-23 10:42:07 +02001305 CHECK_INITIALIZED();
niklase@google.com470e71d2011-07-07 08:21:25 +00001306
Max Morin787eeed2016-06-23 10:42:07 +02001307 if (_ptrAudioDevice->SetRecordingSampleRate(samplesPerSec) != 0) {
1308 return -1;
1309 }
niklase@google.com470e71d2011-07-07 08:21:25 +00001310
Max Morin787eeed2016-06-23 10:42:07 +02001311 return (0);
niklase@google.com470e71d2011-07-07 08:21:25 +00001312}
1313
1314// ----------------------------------------------------------------------------
1315// RecordingSampleRate
1316// ----------------------------------------------------------------------------
1317
Max Morin787eeed2016-06-23 10:42:07 +02001318int32_t AudioDeviceModuleImpl::RecordingSampleRate(
1319 uint32_t* samplesPerSec) const {
Max Morin098e6c52016-06-28 09:36:25 +02001320 LOG(INFO) << __FUNCTION__;
Max Morin787eeed2016-06-23 10:42:07 +02001321 CHECK_INITIALIZED();
niklase@google.com470e71d2011-07-07 08:21:25 +00001322
Max Morin787eeed2016-06-23 10:42:07 +02001323 int32_t sampleRate = _audioDeviceBuffer.RecordingSampleRate();
niklase@google.com470e71d2011-07-07 08:21:25 +00001324
Max Morin787eeed2016-06-23 10:42:07 +02001325 if (sampleRate == -1) {
Max Morin098e6c52016-06-28 09:36:25 +02001326 LOG(LERROR) << "failed to retrieve the sample rate";
Max Morin787eeed2016-06-23 10:42:07 +02001327 return -1;
1328 }
niklase@google.com470e71d2011-07-07 08:21:25 +00001329
Max Morin787eeed2016-06-23 10:42:07 +02001330 *samplesPerSec = sampleRate;
Max Morin2c332bb2016-07-04 09:03:42 +02001331 LOG(INFO) << "output: " << *samplesPerSec;
Max Morin787eeed2016-06-23 10:42:07 +02001332 return (0);
niklase@google.com470e71d2011-07-07 08:21:25 +00001333}
1334
1335// ----------------------------------------------------------------------------
1336// SetPlayoutSampleRate
1337// ----------------------------------------------------------------------------
1338
Max Morin787eeed2016-06-23 10:42:07 +02001339int32_t AudioDeviceModuleImpl::SetPlayoutSampleRate(
1340 const uint32_t samplesPerSec) {
Max Morin098e6c52016-06-28 09:36:25 +02001341 LOG(INFO) << __FUNCTION__ << "(" << samplesPerSec << ")";
Max Morin787eeed2016-06-23 10:42:07 +02001342 CHECK_INITIALIZED();
niklase@google.com470e71d2011-07-07 08:21:25 +00001343
Max Morin787eeed2016-06-23 10:42:07 +02001344 if (_ptrAudioDevice->SetPlayoutSampleRate(samplesPerSec) != 0) {
1345 return -1;
1346 }
niklase@google.com470e71d2011-07-07 08:21:25 +00001347
Max Morin787eeed2016-06-23 10:42:07 +02001348 return (0);
niklase@google.com470e71d2011-07-07 08:21:25 +00001349}
1350
1351// ----------------------------------------------------------------------------
1352// PlayoutSampleRate
1353// ----------------------------------------------------------------------------
1354
Max Morin787eeed2016-06-23 10:42:07 +02001355int32_t AudioDeviceModuleImpl::PlayoutSampleRate(
1356 uint32_t* samplesPerSec) const {
Max Morin098e6c52016-06-28 09:36:25 +02001357 LOG(INFO) << __FUNCTION__;
Max Morin787eeed2016-06-23 10:42:07 +02001358 CHECK_INITIALIZED();
niklase@google.com470e71d2011-07-07 08:21:25 +00001359
Max Morin787eeed2016-06-23 10:42:07 +02001360 int32_t sampleRate = _audioDeviceBuffer.PlayoutSampleRate();
niklase@google.com470e71d2011-07-07 08:21:25 +00001361
Max Morin787eeed2016-06-23 10:42:07 +02001362 if (sampleRate == -1) {
Max Morin098e6c52016-06-28 09:36:25 +02001363 LOG(LERROR) << "failed to retrieve the sample rate";
Max Morin787eeed2016-06-23 10:42:07 +02001364 return -1;
1365 }
niklase@google.com470e71d2011-07-07 08:21:25 +00001366
Max Morin787eeed2016-06-23 10:42:07 +02001367 *samplesPerSec = sampleRate;
Max Morin2c332bb2016-07-04 09:03:42 +02001368 LOG(INFO) << "output: " << *samplesPerSec;
Max Morin787eeed2016-06-23 10:42:07 +02001369 return (0);
niklase@google.com470e71d2011-07-07 08:21:25 +00001370}
1371
1372// ----------------------------------------------------------------------------
niklase@google.com470e71d2011-07-07 08:21:25 +00001373// SetLoudspeakerStatus
1374// ----------------------------------------------------------------------------
1375
Max Morin787eeed2016-06-23 10:42:07 +02001376int32_t AudioDeviceModuleImpl::SetLoudspeakerStatus(bool enable) {
Max Morin098e6c52016-06-28 09:36:25 +02001377 LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
Max Morin787eeed2016-06-23 10:42:07 +02001378 CHECK_INITIALIZED();
niklase@google.com470e71d2011-07-07 08:21:25 +00001379
Max Morin787eeed2016-06-23 10:42:07 +02001380 if (_ptrAudioDevice->SetLoudspeakerStatus(enable) != 0) {
1381 return -1;
1382 }
niklase@google.com470e71d2011-07-07 08:21:25 +00001383
Max Morin787eeed2016-06-23 10:42:07 +02001384 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +00001385}
1386
1387// ----------------------------------------------------------------------------
1388// GetLoudspeakerStatus
1389// ----------------------------------------------------------------------------
1390
henrikac14f5ff2015-09-23 14:08:33 +02001391int32_t AudioDeviceModuleImpl::GetLoudspeakerStatus(bool* enabled) const {
Max Morin098e6c52016-06-28 09:36:25 +02001392 LOG(INFO) << __FUNCTION__;
henrika@webrtc.orga954c072014-12-09 16:22:09 +00001393 CHECK_INITIALIZED();
Max Morin098e6c52016-06-28 09:36:25 +02001394 int32_t ok = 0;
henrikac14f5ff2015-09-23 14:08:33 +02001395 if (_ptrAudioDevice->GetLoudspeakerStatus(*enabled) != 0) {
Max Morin098e6c52016-06-28 09:36:25 +02001396 ok = -1;
henrikac14f5ff2015-09-23 14:08:33 +02001397 }
Max Morin2c332bb2016-07-04 09:03:42 +02001398 LOG(INFO) << "output: " << ok;
Max Morin098e6c52016-06-28 09:36:25 +02001399 return ok;
andrew@webrtc.orga3c6d612011-09-13 17:17:49 +00001400}
1401
henrika@webrtc.orga954c072014-12-09 16:22:09 +00001402bool AudioDeviceModuleImpl::BuiltInAECIsAvailable() const {
Max Morin098e6c52016-06-28 09:36:25 +02001403 LOG(INFO) << __FUNCTION__;
henrika@webrtc.orga954c072014-12-09 16:22:09 +00001404 CHECK_INITIALIZED_BOOL();
Max Morin098e6c52016-06-28 09:36:25 +02001405 bool isAvailable = _ptrAudioDevice->BuiltInAECIsAvailable();
Max Morin2c332bb2016-07-04 09:03:42 +02001406 LOG(INFO) << "output: " << isAvailable;
Max Morin098e6c52016-06-28 09:36:25 +02001407 return isAvailable;
henrika@webrtc.orga954c072014-12-09 16:22:09 +00001408}
1409
henrikac14f5ff2015-09-23 14:08:33 +02001410int32_t AudioDeviceModuleImpl::EnableBuiltInAEC(bool enable) {
Max Morin098e6c52016-06-28 09:36:25 +02001411 LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrikac14f5ff2015-09-23 14:08:33 +02001412 CHECK_INITIALIZED();
Max Morin098e6c52016-06-28 09:36:25 +02001413 int32_t ok = _ptrAudioDevice->EnableBuiltInAEC(enable);
Max Morin2c332bb2016-07-04 09:03:42 +02001414 LOG(INFO) << "output: " << ok;
Max Morin098e6c52016-06-28 09:36:25 +02001415 return ok;
henrikac14f5ff2015-09-23 14:08:33 +02001416}
1417
1418bool AudioDeviceModuleImpl::BuiltInAGCIsAvailable() const {
Max Morin098e6c52016-06-28 09:36:25 +02001419 LOG(INFO) << __FUNCTION__;
henrikac14f5ff2015-09-23 14:08:33 +02001420 CHECK_INITIALIZED_BOOL();
Max Morin098e6c52016-06-28 09:36:25 +02001421 bool isAvailable = _ptrAudioDevice->BuiltInAGCIsAvailable();
Max Morin2c332bb2016-07-04 09:03:42 +02001422 LOG(INFO) << "output: " << isAvailable;
Max Morin098e6c52016-06-28 09:36:25 +02001423 return isAvailable;
henrikac14f5ff2015-09-23 14:08:33 +02001424}
1425
1426int32_t AudioDeviceModuleImpl::EnableBuiltInAGC(bool enable) {
Max Morin098e6c52016-06-28 09:36:25 +02001427 LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrikac14f5ff2015-09-23 14:08:33 +02001428 CHECK_INITIALIZED();
Max Morin098e6c52016-06-28 09:36:25 +02001429 int32_t ok = _ptrAudioDevice->EnableBuiltInAGC(enable);
Max Morin2c332bb2016-07-04 09:03:42 +02001430 LOG(INFO) << "output: " << ok;
Max Morin098e6c52016-06-28 09:36:25 +02001431 return ok;
henrikac14f5ff2015-09-23 14:08:33 +02001432}
1433
1434bool AudioDeviceModuleImpl::BuiltInNSIsAvailable() const {
Max Morin098e6c52016-06-28 09:36:25 +02001435 LOG(INFO) << __FUNCTION__;
henrikac14f5ff2015-09-23 14:08:33 +02001436 CHECK_INITIALIZED_BOOL();
Max Morin098e6c52016-06-28 09:36:25 +02001437 bool isAvailable = _ptrAudioDevice->BuiltInNSIsAvailable();
Max Morin2c332bb2016-07-04 09:03:42 +02001438 LOG(INFO) << "output: " << isAvailable;
Max Morin098e6c52016-06-28 09:36:25 +02001439 return isAvailable;
henrikac14f5ff2015-09-23 14:08:33 +02001440}
1441
1442int32_t AudioDeviceModuleImpl::EnableBuiltInNS(bool enable) {
Max Morin098e6c52016-06-28 09:36:25 +02001443 LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
henrikac14f5ff2015-09-23 14:08:33 +02001444 CHECK_INITIALIZED();
Max Morin098e6c52016-06-28 09:36:25 +02001445 int32_t ok = _ptrAudioDevice->EnableBuiltInNS(enable);
Max Morin2c332bb2016-07-04 09:03:42 +02001446 LOG(INFO) << "output: " << ok;
Max Morin098e6c52016-06-28 09:36:25 +02001447 return ok;
henrikac14f5ff2015-09-23 14:08:33 +02001448}
1449
maxmorin88e31a32016-08-16 00:56:09 -07001450#if defined(WEBRTC_IOS)
henrikaba35d052015-07-14 17:04:08 +02001451int AudioDeviceModuleImpl::GetPlayoutAudioParameters(
1452 AudioParameters* params) const {
Max Morin098e6c52016-06-28 09:36:25 +02001453 LOG(INFO) << __FUNCTION__;
1454 int r = _ptrAudioDevice->GetPlayoutAudioParameters(params);
Max Morin2c332bb2016-07-04 09:03:42 +02001455 LOG(INFO) << "output: " << r;
Max Morin098e6c52016-06-28 09:36:25 +02001456 return r;
henrikaba35d052015-07-14 17:04:08 +02001457}
1458
1459int AudioDeviceModuleImpl::GetRecordAudioParameters(
1460 AudioParameters* params) const {
Max Morin098e6c52016-06-28 09:36:25 +02001461 LOG(INFO) << __FUNCTION__;
1462 int r = _ptrAudioDevice->GetRecordAudioParameters(params);
Max Morin2c332bb2016-07-04 09:03:42 +02001463 LOG(INFO) << "output: " << r;
Max Morin098e6c52016-06-28 09:36:25 +02001464 return r;
henrikaba35d052015-07-14 17:04:08 +02001465}
maxmorin88e31a32016-08-16 00:56:09 -07001466#endif // WEBRTC_IOS
henrikaba35d052015-07-14 17:04:08 +02001467
niklase@google.com470e71d2011-07-07 08:21:25 +00001468// ============================================================================
1469// Private Methods
1470// ============================================================================
1471
1472// ----------------------------------------------------------------------------
1473// Platform
1474// ----------------------------------------------------------------------------
1475
Max Morin787eeed2016-06-23 10:42:07 +02001476AudioDeviceModuleImpl::PlatformType AudioDeviceModuleImpl::Platform() const {
Max Morin098e6c52016-06-28 09:36:25 +02001477 LOG(INFO) << __FUNCTION__;
Max Morin787eeed2016-06-23 10:42:07 +02001478 return _platformType;
niklase@google.com470e71d2011-07-07 08:21:25 +00001479}
1480
1481// ----------------------------------------------------------------------------
1482// PlatformAudioLayer
1483// ----------------------------------------------------------------------------
1484
Max Morin787eeed2016-06-23 10:42:07 +02001485AudioDeviceModule::AudioLayer AudioDeviceModuleImpl::PlatformAudioLayer()
1486 const {
Max Morin098e6c52016-06-28 09:36:25 +02001487 LOG(INFO) << __FUNCTION__;
Max Morin787eeed2016-06-23 10:42:07 +02001488 return _platformAudioLayer;
niklase@google.com470e71d2011-07-07 08:21:25 +00001489}
1490
1491} // namespace webrtc