1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 *
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
11 #include "webrtc/base/checks.h"
12 #include "webrtc/base/logging.h"
13 #include "webrtc/base/checks.h"
14 #include "webrtc/base/refcount.h"
15 #include "webrtc/base/timeutils.h"
16 #include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"
17 #include "webrtc/modules/audio_device/audio_device_config.h"
18 #include "webrtc/modules/audio_device/audio_device_generic.h"
19 #include "webrtc/modules/audio_device/audio_device_impl.h"
20 #include "webrtc/system_wrappers/include/metrics.h"
21
22 #include <assert.h>
23 #include <string.h>
24
25 #if defined(WEBRTC_DUMMY_AUDIO_BUILD)
26 // do not include platform specific headers
27 #elif defined(_WIN32)
28 #include "audio_device_wave_win.h"
29 #if defined(WEBRTC_WINDOWS_CORE_AUDIO_BUILD)
30 #include "audio_device_core_win.h"
31 #endif
32 #elif defined(WEBRTC_ANDROID_OPENSLES)
33 #include <stdlib.h>
34 #include <dlfcn.h>
35 #include "webrtc/modules/audio_device/android/audio_device_template.h"
36 #include "webrtc/modules/audio_device/android/audio_manager.h"
37 #include "webrtc/modules/audio_device/android/audio_record_jni.h"
38 #include "webrtc/modules/audio_device/android/audio_track_jni.h"
39 #include "webrtc/modules/audio_device/android/opensles_player.h"
40 #include "webrtc/modules/audio_device/android/opensles_recorder.h"
41 #elif defined(WEBRTC_AUDIO_SNDIO)
42 #include "audio_device_sndio.h"
43 #elif defined(WEBRTC_LINUX) || defined(WEBRTC_BSD)
44 #if defined(LINUX_ALSA)
45 #include "audio_device_alsa_linux.h"
46 #endif
47 #if defined(LINUX_PULSE)
48 #include "audio_device_pulse_linux.h"
49 #endif
50 #elif defined(WEBRTC_IOS)
51 #include "audio_device_ios.h"
52 #elif defined(WEBRTC_MAC)
53 #include "audio_device_mac.h"
54 #endif
55
56 #if defined(WEBRTC_DUMMY_FILE_DEVICES)
57 #include "webrtc/modules/audio_device/dummy/file_audio_device_factory.h"
58 #endif
59
60 #include "webrtc/modules/audio_device/dummy/audio_device_dummy.h"
61 #include "webrtc/modules/audio_device/dummy/file_audio_device.h"
62 #include "webrtc/system_wrappers/include/critical_section_wrapper.h"
63
64 #define CHECK_INITIALIZED() \
65 { \
66 if (!_initialized) { \
67 return -1; \
68 }; \
69 }
70
71 #define CHECK_INITIALIZED_BOOL() \
72 { \
73 if (!_initialized) { \
74 return false; \
75 }; \
76 }
77
78 namespace webrtc {
79
80 // ============================================================================
81 // Static methods
82 // ============================================================================
83
84 // ----------------------------------------------------------------------------
85 // AudioDeviceModule::Create()
86 // ----------------------------------------------------------------------------
87
Create(const int32_t id,const AudioLayer audio_layer)88 rtc::scoped_refptr<AudioDeviceModule> AudioDeviceModule::Create(
89 const int32_t id,
90 const AudioLayer audio_layer) {
91 LOG(INFO) << __FUNCTION__;
92 // Create the generic ref counted (platform independent) implementation.
93 rtc::scoped_refptr<AudioDeviceModuleImpl> audioDevice(
94 new rtc::RefCountedObject<AudioDeviceModuleImpl>(id, audio_layer));
95
96 // Ensure that the current platform is supported.
97 if (audioDevice->CheckPlatform() == -1) {
98 return nullptr;
99 }
100
101 // Create the platform-dependent implementation.
102 if (audioDevice->CreatePlatformSpecificObjects() == -1) {
103 return nullptr;
104 }
105
106 // Ensure that the generic audio buffer can communicate with the
107 // platform-specific parts.
108 if (audioDevice->AttachAudioBuffer() == -1) {
109 return nullptr;
110 }
111
112 WebRtcSpl_Init();
113
114 return audioDevice;
115 }
116
117 // ============================================================================
118 // Construction & Destruction
119 // ============================================================================
120
121 // ----------------------------------------------------------------------------
122 // AudioDeviceModuleImpl - ctor
123 // ----------------------------------------------------------------------------
124
AudioDeviceModuleImpl(const int32_t id,const AudioLayer audioLayer)125 AudioDeviceModuleImpl::AudioDeviceModuleImpl(const int32_t id,
126 const AudioLayer audioLayer)
127 : _critSect(*CriticalSectionWrapper::CreateCriticalSection()),
128 _critSectEventCb(*CriticalSectionWrapper::CreateCriticalSection()),
129 _critSectAudioCb(*CriticalSectionWrapper::CreateCriticalSection()),
130 _ptrCbAudioDeviceObserver(NULL),
131 _ptrAudioDevice(NULL),
132 _id(id),
133 _platformAudioLayer(audioLayer),
134 _lastProcessTime(rtc::TimeMillis()),
135 _platformType(kPlatformNotSupported),
136 _initialized(false),
137 _lastError(kAdmErrNone) {
138 LOG(INFO) << __FUNCTION__;
139 }
140
141 // ----------------------------------------------------------------------------
142 // CheckPlatform
143 // ----------------------------------------------------------------------------
144
CheckPlatform()145 int32_t AudioDeviceModuleImpl::CheckPlatform() {
146 LOG(INFO) << __FUNCTION__;
147
148 // Ensure that the current platform is supported
149 //
150 PlatformType platform(kPlatformNotSupported);
151
152 #if defined(_WIN32)
153 platform = kPlatformWin32;
154 LOG(INFO) << "current platform is Win32";
155 #elif defined(WEBRTC_ANDROID)
156 platform = kPlatformAndroid;
157 LOG(INFO) << "current platform is Android";
158 #elif defined(WEBRTC_AUDIO_SNDIO)
159 platform = kPlatformSndio;
160 LOG(INFO) << "current platform is POSIX using SNDIO";
161 #elif defined(WEBRTC_LINUX) || defined(WEBRTC_BSD)
162 platform = kPlatformLinux;
163 LOG(INFO) << "current platform is Linux";
164 #elif defined(WEBRTC_IOS)
165 platform = kPlatformIOS;
166 LOG(INFO) << "current platform is IOS";
167 #elif defined(WEBRTC_MAC)
168 platform = kPlatformMac;
169 LOG(INFO) << "current platform is Mac";
170 #endif
171
172 if (platform == kPlatformNotSupported) {
173 LOG(LERROR) << "current platform is not supported => this module will self "
174 "destruct!";
175 return -1;
176 }
177
178 // Store valid output results
179 //
180 _platformType = platform;
181
182 return 0;
183 }
184
185 // ----------------------------------------------------------------------------
186 // CreatePlatformSpecificObjects
187 // ----------------------------------------------------------------------------
188
CreatePlatformSpecificObjects()189 int32_t AudioDeviceModuleImpl::CreatePlatformSpecificObjects() {
190 LOG(INFO) << __FUNCTION__;
191
192 AudioDeviceGeneric* ptrAudioDevice(NULL);
193
194 #if defined(WEBRTC_DUMMY_AUDIO_BUILD)
195 ptrAudioDevice = new AudioDeviceDummy(Id());
196 LOG(INFO) << "Dummy Audio APIs will be utilized";
197 #elif defined(WEBRTC_DUMMY_FILE_DEVICES)
198 ptrAudioDevice = FileAudioDeviceFactory::CreateFileAudioDevice(Id());
199 if (ptrAudioDevice) {
200 LOG(INFO) << "Will use file-playing dummy device.";
201 } else {
202 // Create a dummy device instead.
203 ptrAudioDevice = new AudioDeviceDummy(Id());
204 LOG(INFO) << "Dummy Audio APIs will be utilized";
205 }
206 #else
207 AudioLayer audioLayer(PlatformAudioLayer());
208
209 // Create the *Windows* implementation of the Audio Device
210 //
211 #if defined(_WIN32)
212 if ((audioLayer == kWindowsWaveAudio)
213 #if !defined(WEBRTC_WINDOWS_CORE_AUDIO_BUILD)
214 // Wave audio is default if Core audio is not supported in this build
215 || (audioLayer == kPlatformDefaultAudio)
216 #endif
217 ) {
218 // create *Windows Wave Audio* implementation
219 ptrAudioDevice = new AudioDeviceWindowsWave(Id());
220 LOG(INFO) << "Windows Wave APIs will be utilized";
221 }
222 #if defined(WEBRTC_WINDOWS_CORE_AUDIO_BUILD)
223 if ((audioLayer == kWindowsCoreAudio) ||
224 (audioLayer == kPlatformDefaultAudio)) {
225 LOG(INFO) << "attempting to use the Windows Core Audio APIs...";
226
227 if (AudioDeviceWindowsCore::CoreAudioIsSupported()) {
228 // create *Windows Core Audio* implementation
229 ptrAudioDevice = new AudioDeviceWindowsCore(Id());
230 LOG(INFO) << "Windows Core Audio APIs will be utilized";
231 } else {
232 // create *Windows Wave Audio* implementation
233 ptrAudioDevice = new AudioDeviceWindowsWave(Id());
234 if (ptrAudioDevice != NULL) {
235 // Core Audio was not supported => revert to Windows Wave instead
236 _platformAudioLayer =
237 kWindowsWaveAudio; // modify the state set at construction
238 LOG(WARNING) << "Windows Core Audio is *not* supported => Wave APIs "
239 "will be utilized instead";
240 }
241 }
242 }
243 #endif // defined(WEBRTC_WINDOWS_CORE_AUDIO_BUILD)
244 #endif // #if defined(_WIN32)
245
246 #if defined(WEBRTC_ANDROID)
247 // Create an Android audio manager.
248 _audioManagerAndroid.reset(new AudioManager());
249 // Select best possible combination of audio layers.
250 // Check if the OpenSLES library is available before going further.
251 void* opensles_lib = dlopen("libOpenSLES.so", RTLD_LAZY);
252 if (audioLayer == kPlatformDefaultAudio) {
253 if (_audioManagerAndroid->IsLowLatencyPlayoutSupported() &&
254 _audioManagerAndroid->IsLowLatencyRecordSupported() &&
255 opensles_lib) {
256 // Use OpenSL ES for both playout and recording.
257 audioLayer = kAndroidOpenSLESAudio;
258 } else if (_audioManagerAndroid->IsLowLatencyPlayoutSupported() &&
259 !_audioManagerAndroid->IsLowLatencyRecordSupported() &&
260 opensles_lib) {
261 // Use OpenSL ES for output on devices that only supports the
262 // low-latency output audio path.
263 audioLayer = kAndroidJavaInputAndOpenSLESOutputAudio;
264 } else {
265 // Use Java-based audio in both directions when low-latency output is
266 // not supported.
267 audioLayer = kAndroidJavaAudio;
268 }
269 }
270 if (opensles_lib) {
271 // TODO: We hit a pthread_mutex_unlock failure when trying to release this.
272 // It doesn't seem necessary anyway.
273 // That worked, close for now and proceed normally.
274 //dlclose(opensles_lib);
275 }
276 AudioManager* audio_manager = _audioManagerAndroid.get();
277 if (audioLayer == kAndroidJavaAudio) {
278 // Java audio for both input and output audio.
279 ptrAudioDevice = new AudioDeviceTemplate<AudioRecordJni, AudioTrackJni>(
280 audioLayer, audio_manager);
281 } else if (audioLayer == kAndroidOpenSLESAudio) {
282 // OpenSL ES based audio for both input and output audio.
283 ptrAudioDevice = new AudioDeviceTemplate<OpenSLESRecorder, OpenSLESPlayer>(
284 audioLayer, audio_manager);
285 } else if (audioLayer == kAndroidJavaInputAndOpenSLESOutputAudio) {
286 // Java audio for input and OpenSL ES for output audio (i.e. mixed APIs).
287 // This combination provides low-latency output audio and at the same
288 // time support for HW AEC using the AudioRecord Java API.
289 ptrAudioDevice = new AudioDeviceTemplate<AudioRecordJni, OpenSLESPlayer>(
290 audioLayer, audio_manager);
291 } else {
292 // Invalid audio layer.
293 ptrAudioDevice = nullptr;
294 }
295 // END #if defined(WEBRTC_ANDROID)
296 #elif defined(WEBRTC_AUDIO_SNDIO)
297 ptrAudioDevice = new AudioDeviceSndio(Id());
298 if (ptrAudioDevice != NULL)
299 {
300 LOG(INFO) << "attempting to use the Sndio audio API...";
301 _platformAudioLayer = kSndioAudio;
302 }
303 #elif defined(WEBRTC_LINUX) || defined(WEBRTC_BSD)
304
305 // Create the *Linux* implementation of the Audio Device
306 //
307 if ((audioLayer == kLinuxPulseAudio) ||
308 (audioLayer == kPlatformDefaultAudio)) {
309 #if defined(LINUX_PULSE)
310 LOG(INFO) << "attempting to use the Linux PulseAudio APIs...";
311
312 // create *Linux PulseAudio* implementation
313 AudioDeviceLinuxPulse* pulseDevice = new AudioDeviceLinuxPulse(Id());
314 if (pulseDevice->Init() == AudioDeviceGeneric::InitStatus::OK) {
315 ptrAudioDevice = pulseDevice;
316 LOG(INFO) << "Linux PulseAudio APIs will be utilized";
317 } else {
318 delete pulseDevice;
319 #endif
320 #if defined(LINUX_ALSA)
321 // create *Linux ALSA Audio* implementation
322 ptrAudioDevice = new AudioDeviceLinuxALSA(Id());
323 if (ptrAudioDevice != NULL) {
324 // Pulse Audio was not supported => revert to ALSA instead
325 _platformAudioLayer =
326 kLinuxAlsaAudio; // modify the state set at construction
327 LOG(WARNING) << "Linux PulseAudio is *not* supported => ALSA APIs will "
328 "be utilized instead";
329 }
330 #endif
331 #if defined(LINUX_PULSE)
332 }
333 #endif
334 } else if (audioLayer == kLinuxAlsaAudio) {
335 #if defined(LINUX_ALSA)
336 // create *Linux ALSA Audio* implementation
337 ptrAudioDevice = new AudioDeviceLinuxALSA(Id());
338 LOG(INFO) << "Linux ALSA APIs will be utilized";
339 #endif
340 }
341 #endif // #if defined(WEBRTC_LINUX) || defined(WEBRTC_BSD)
342
343 // Create the *iPhone* implementation of the Audio Device
344 //
345 #if defined(WEBRTC_IOS)
346 if (audioLayer == kPlatformDefaultAudio) {
347 // Create iOS Audio Device implementation.
348 ptrAudioDevice = new AudioDeviceIOS();
349 LOG(INFO) << "iPhone Audio APIs will be utilized";
350 }
351 // END #if defined(WEBRTC_IOS)
352
353 // Create the *Mac* implementation of the Audio Device
354 //
355 #elif defined(WEBRTC_MAC)
356 if (audioLayer == kPlatformDefaultAudio) {
357 // Create *Mac Audio* implementation
358 ptrAudioDevice = new AudioDeviceMac(Id());
359 LOG(INFO) << "Mac OS X Audio APIs will be utilized";
360 }
361 #endif // WEBRTC_MAC
362
363 // Create the *Dummy* implementation of the Audio Device
364 // Available for all platforms
365 //
366 if (audioLayer == kDummyAudio) {
367 // Create *Dummy Audio* implementation
368 assert(!ptrAudioDevice);
369 ptrAudioDevice = new AudioDeviceDummy(Id());
370 LOG(INFO) << "Dummy Audio APIs will be utilized";
371 }
372 #endif // if defined(WEBRTC_DUMMY_AUDIO_BUILD)
373
374 if (ptrAudioDevice == NULL) {
375 LOG(LERROR)
376 << "unable to create the platform specific audio device implementation";
377 return -1;
378 }
379
380 // Store valid output pointers
381 //
382 _ptrAudioDevice = ptrAudioDevice;
383
384 return 0;
385 }
386
387 // ----------------------------------------------------------------------------
388 // AttachAudioBuffer
389 //
390 // Install "bridge" between the platform implemetation and the generic
391 // implementation. The "child" shall set the native sampling rate and the
392 // number of channels in this function call.
393 // ----------------------------------------------------------------------------
394
AttachAudioBuffer()395 int32_t AudioDeviceModuleImpl::AttachAudioBuffer() {
396 LOG(INFO) << __FUNCTION__;
397
398 _audioDeviceBuffer.SetId(_id);
399 _ptrAudioDevice->AttachAudioBuffer(&_audioDeviceBuffer);
400 return 0;
401 }
402
403 // ----------------------------------------------------------------------------
404 // ~AudioDeviceModuleImpl - dtor
405 // ----------------------------------------------------------------------------
406
~AudioDeviceModuleImpl()407 AudioDeviceModuleImpl::~AudioDeviceModuleImpl() {
408 LOG(INFO) << __FUNCTION__;
409
410 if (_ptrAudioDevice) {
411 delete _ptrAudioDevice;
412 _ptrAudioDevice = NULL;
413 }
414
415 delete &_critSect;
416 delete &_critSectEventCb;
417 delete &_critSectAudioCb;
418 }
419
420 // ============================================================================
421 // Module
422 // ============================================================================
423
424 // ----------------------------------------------------------------------------
425 // Module::TimeUntilNextProcess
426 //
427 // Returns the number of milliseconds until the module want a worker thread
428 // to call Process().
429 // ----------------------------------------------------------------------------
430
TimeUntilNextProcess()431 int64_t AudioDeviceModuleImpl::TimeUntilNextProcess() {
432 int64_t now = rtc::TimeMillis();
433 int64_t deltaProcess = kAdmMaxIdleTimeProcess - (now - _lastProcessTime);
434 return deltaProcess;
435 }
436
437 // ----------------------------------------------------------------------------
438 // Module::Process
439 //
440 // Check for posted error and warning reports. Generate callbacks if
441 // new reports exists.
442 // ----------------------------------------------------------------------------
443
Process()444 void AudioDeviceModuleImpl::Process() {
445 _lastProcessTime = rtc::TimeMillis();
446
447 // kPlayoutWarning
448 if (_ptrAudioDevice->PlayoutWarning()) {
449 CriticalSectionScoped lock(&_critSectEventCb);
450 if (_ptrCbAudioDeviceObserver) {
451 LOG(WARNING) << "=> OnWarningIsReported(kPlayoutWarning)";
452 _ptrCbAudioDeviceObserver->OnWarningIsReported(
453 AudioDeviceObserver::kPlayoutWarning);
454 }
455 _ptrAudioDevice->ClearPlayoutWarning();
456 }
457
458 // kPlayoutError
459 if (_ptrAudioDevice->PlayoutError()) {
460 CriticalSectionScoped lock(&_critSectEventCb);
461 if (_ptrCbAudioDeviceObserver) {
462 LOG(LERROR) << "=> OnErrorIsReported(kPlayoutError)";
463 _ptrCbAudioDeviceObserver->OnErrorIsReported(
464 AudioDeviceObserver::kPlayoutError);
465 }
466 _ptrAudioDevice->ClearPlayoutError();
467 }
468
469 // kRecordingWarning
470 if (_ptrAudioDevice->RecordingWarning()) {
471 CriticalSectionScoped lock(&_critSectEventCb);
472 if (_ptrCbAudioDeviceObserver) {
473 LOG(WARNING) << "=> OnWarningIsReported(kRecordingWarning)";
474 _ptrCbAudioDeviceObserver->OnWarningIsReported(
475 AudioDeviceObserver::kRecordingWarning);
476 }
477 _ptrAudioDevice->ClearRecordingWarning();
478 }
479
480 // kRecordingError
481 if (_ptrAudioDevice->RecordingError()) {
482 CriticalSectionScoped lock(&_critSectEventCb);
483 if (_ptrCbAudioDeviceObserver) {
484 LOG(LERROR) << "=> OnErrorIsReported(kRecordingError)";
485 _ptrCbAudioDeviceObserver->OnErrorIsReported(
486 AudioDeviceObserver::kRecordingError);
487 }
488 _ptrAudioDevice->ClearRecordingError();
489 }
490 }
491
492 // ============================================================================
493 // Public API
494 // ============================================================================
495
496 // ----------------------------------------------------------------------------
497 // ActiveAudioLayer
498 // ----------------------------------------------------------------------------
499
ActiveAudioLayer(AudioLayer * audioLayer) const500 int32_t AudioDeviceModuleImpl::ActiveAudioLayer(AudioLayer* audioLayer) const {
501 LOG(INFO) << __FUNCTION__;
502 AudioLayer activeAudio;
503 if (_ptrAudioDevice->ActiveAudioLayer(activeAudio) == -1) {
504 return -1;
505 }
506 *audioLayer = activeAudio;
507 return 0;
508 }
509
510 // ----------------------------------------------------------------------------
511 // LastError
512 // ----------------------------------------------------------------------------
513
LastError() const514 AudioDeviceModule::ErrorCode AudioDeviceModuleImpl::LastError() const {
515 LOG(INFO) << __FUNCTION__;
516 return _lastError;
517 }
518
519 // ----------------------------------------------------------------------------
520 // Init
521 // ----------------------------------------------------------------------------
522
Init()523 int32_t AudioDeviceModuleImpl::Init() {
524 LOG(INFO) << __FUNCTION__;
525 if (_initialized)
526 return 0;
527 RTC_CHECK(_ptrAudioDevice);
528
529 AudioDeviceGeneric::InitStatus status = _ptrAudioDevice->Init();
530 RTC_HISTOGRAM_ENUMERATION(
531 "WebRTC.Audio.InitializationResult", static_cast<int>(status),
532 static_cast<int>(AudioDeviceGeneric::InitStatus::NUM_STATUSES));
533 if (status != AudioDeviceGeneric::InitStatus::OK) {
534 LOG(LS_ERROR) << "Audio device initialization failed.";
535 return -1;
536 }
537
538 _initialized = true;
539 return 0;
540 }
541
542 // ----------------------------------------------------------------------------
543 // Terminate
544 // ----------------------------------------------------------------------------
545
Terminate()546 int32_t AudioDeviceModuleImpl::Terminate() {
547 LOG(INFO) << __FUNCTION__;
548 if (!_initialized)
549 return 0;
550
551 if (_ptrAudioDevice->Terminate() == -1) {
552 return -1;
553 }
554
555 _initialized = false;
556 return 0;
557 }
558
559 // ----------------------------------------------------------------------------
560 // Initialized
561 // ----------------------------------------------------------------------------
562
Initialized() const563 bool AudioDeviceModuleImpl::Initialized() const {
564 LOG(INFO) << __FUNCTION__ << ": " << _initialized;
565 return (_initialized);
566 }
567
568 // ----------------------------------------------------------------------------
569 // InitSpeaker
570 // ----------------------------------------------------------------------------
571
InitSpeaker()572 int32_t AudioDeviceModuleImpl::InitSpeaker() {
573 LOG(INFO) << __FUNCTION__;
574 CHECK_INITIALIZED();
575 return (_ptrAudioDevice->InitSpeaker());
576 }
577
578 // ----------------------------------------------------------------------------
579 // InitMicrophone
580 // ----------------------------------------------------------------------------
581
InitMicrophone()582 int32_t AudioDeviceModuleImpl::InitMicrophone() {
583 LOG(INFO) << __FUNCTION__;
584 CHECK_INITIALIZED();
585 return (_ptrAudioDevice->InitMicrophone());
586 }
587
588 // ----------------------------------------------------------------------------
589 // SpeakerVolumeIsAvailable
590 // ----------------------------------------------------------------------------
591
SpeakerVolumeIsAvailable(bool * available)592 int32_t AudioDeviceModuleImpl::SpeakerVolumeIsAvailable(bool* available) {
593 LOG(INFO) << __FUNCTION__;
594 CHECK_INITIALIZED();
595
596 bool isAvailable(0);
597
598 if (_ptrAudioDevice->SpeakerVolumeIsAvailable(isAvailable) == -1) {
599 return -1;
600 }
601
602 *available = isAvailable;
603 LOG(INFO) << "output: " << isAvailable;
604 return (0);
605 }
606
607 // ----------------------------------------------------------------------------
608 // SetSpeakerVolume
609 // ----------------------------------------------------------------------------
610
SetSpeakerVolume(uint32_t volume)611 int32_t AudioDeviceModuleImpl::SetSpeakerVolume(uint32_t volume) {
612 LOG(INFO) << __FUNCTION__ << "(" << volume << ")";
613 CHECK_INITIALIZED();
614 return (_ptrAudioDevice->SetSpeakerVolume(volume));
615 }
616
617 // ----------------------------------------------------------------------------
618 // SpeakerVolume
619 // ----------------------------------------------------------------------------
620
SpeakerVolume(uint32_t * volume) const621 int32_t AudioDeviceModuleImpl::SpeakerVolume(uint32_t* volume) const {
622 LOG(INFO) << __FUNCTION__;
623 CHECK_INITIALIZED();
624
625 uint32_t level(0);
626
627 if (_ptrAudioDevice->SpeakerVolume(level) == -1) {
628 return -1;
629 }
630
631 *volume = level;
632 LOG(INFO) << "output: " << *volume;
633 return (0);
634 }
635
636 // ----------------------------------------------------------------------------
637 // SetWaveOutVolume
638 // ----------------------------------------------------------------------------
639
SetWaveOutVolume(uint16_t volumeLeft,uint16_t volumeRight)640 int32_t AudioDeviceModuleImpl::SetWaveOutVolume(uint16_t volumeLeft,
641 uint16_t volumeRight) {
642 LOG(INFO) << __FUNCTION__ << "(" << volumeLeft << ", " << volumeRight << ")";
643 CHECK_INITIALIZED();
644 return (_ptrAudioDevice->SetWaveOutVolume(volumeLeft, volumeRight));
645 }
646
647 // ----------------------------------------------------------------------------
648 // WaveOutVolume
649 // ----------------------------------------------------------------------------
650
WaveOutVolume(uint16_t * volumeLeft,uint16_t * volumeRight) const651 int32_t AudioDeviceModuleImpl::WaveOutVolume(uint16_t* volumeLeft,
652 uint16_t* volumeRight) const {
653 LOG(INFO) << __FUNCTION__;
654 CHECK_INITIALIZED();
655
656 uint16_t volLeft(0);
657 uint16_t volRight(0);
658
659 if (_ptrAudioDevice->WaveOutVolume(volLeft, volRight) == -1) {
660 return -1;
661 }
662
663 *volumeLeft = volLeft;
664 *volumeRight = volRight;
665 LOG(INFO) << "output: " << *volumeLeft << ", " << *volumeRight;
666
667 return (0);
668 }
669
670 // ----------------------------------------------------------------------------
671 // SpeakerIsInitialized
672 // ----------------------------------------------------------------------------
673
SpeakerIsInitialized() const674 bool AudioDeviceModuleImpl::SpeakerIsInitialized() const {
675 LOG(INFO) << __FUNCTION__;
676 CHECK_INITIALIZED_BOOL();
677
678 bool isInitialized = _ptrAudioDevice->SpeakerIsInitialized();
679 LOG(INFO) << "output: " << isInitialized;
680 return (isInitialized);
681 }
682
683 // ----------------------------------------------------------------------------
684 // MicrophoneIsInitialized
685 // ----------------------------------------------------------------------------
686
MicrophoneIsInitialized() const687 bool AudioDeviceModuleImpl::MicrophoneIsInitialized() const {
688 LOG(INFO) << __FUNCTION__;
689 CHECK_INITIALIZED_BOOL();
690
691 bool isInitialized = _ptrAudioDevice->MicrophoneIsInitialized();
692 LOG(INFO) << "output: " << isInitialized;
693 return (isInitialized);
694 }
695
696 // ----------------------------------------------------------------------------
697 // MaxSpeakerVolume
698 // ----------------------------------------------------------------------------
699
MaxSpeakerVolume(uint32_t * maxVolume) const700 int32_t AudioDeviceModuleImpl::MaxSpeakerVolume(uint32_t* maxVolume) const {
701 CHECK_INITIALIZED();
702
703 uint32_t maxVol(0);
704
705 if (_ptrAudioDevice->MaxSpeakerVolume(maxVol) == -1) {
706 return -1;
707 }
708
709 *maxVolume = maxVol;
710 return (0);
711 }
712
713 // ----------------------------------------------------------------------------
714 // MinSpeakerVolume
715 // ----------------------------------------------------------------------------
716
MinSpeakerVolume(uint32_t * minVolume) const717 int32_t AudioDeviceModuleImpl::MinSpeakerVolume(uint32_t* minVolume) const {
718 CHECK_INITIALIZED();
719
720 uint32_t minVol(0);
721
722 if (_ptrAudioDevice->MinSpeakerVolume(minVol) == -1) {
723 return -1;
724 }
725
726 *minVolume = minVol;
727 return (0);
728 }
729
730 // ----------------------------------------------------------------------------
731 // SpeakerVolumeStepSize
732 // ----------------------------------------------------------------------------
733
SpeakerVolumeStepSize(uint16_t * stepSize) const734 int32_t AudioDeviceModuleImpl::SpeakerVolumeStepSize(uint16_t* stepSize) const {
735 LOG(INFO) << __FUNCTION__;
736 CHECK_INITIALIZED();
737
738 uint16_t delta(0);
739
740 if (_ptrAudioDevice->SpeakerVolumeStepSize(delta) == -1) {
741 LOG(LERROR) << "failed to retrieve the speaker-volume step size";
742 return -1;
743 }
744
745 *stepSize = delta;
746 LOG(INFO) << "output: " << *stepSize;
747 return (0);
748 }
749
750 // ----------------------------------------------------------------------------
751 // SpeakerMuteIsAvailable
752 // ----------------------------------------------------------------------------
753
SpeakerMuteIsAvailable(bool * available)754 int32_t AudioDeviceModuleImpl::SpeakerMuteIsAvailable(bool* available) {
755 LOG(INFO) << __FUNCTION__;
756 CHECK_INITIALIZED();
757
758 bool isAvailable(0);
759
760 if (_ptrAudioDevice->SpeakerMuteIsAvailable(isAvailable) == -1) {
761 return -1;
762 }
763
764 *available = isAvailable;
765 LOG(INFO) << "output: " << isAvailable;
766 return (0);
767 }
768
769 // ----------------------------------------------------------------------------
770 // SetSpeakerMute
771 // ----------------------------------------------------------------------------
772
SetSpeakerMute(bool enable)773 int32_t AudioDeviceModuleImpl::SetSpeakerMute(bool enable) {
774 LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
775 CHECK_INITIALIZED();
776 return (_ptrAudioDevice->SetSpeakerMute(enable));
777 }
778
779 // ----------------------------------------------------------------------------
780 // SpeakerMute
781 // ----------------------------------------------------------------------------
782
SpeakerMute(bool * enabled) const783 int32_t AudioDeviceModuleImpl::SpeakerMute(bool* enabled) const {
784 LOG(INFO) << __FUNCTION__;
785 CHECK_INITIALIZED();
786
787 bool muted(false);
788
789 if (_ptrAudioDevice->SpeakerMute(muted) == -1) {
790 return -1;
791 }
792
793 *enabled = muted;
794 LOG(INFO) << "output: " << muted;
795 return (0);
796 }
797
798 // ----------------------------------------------------------------------------
799 // MicrophoneMuteIsAvailable
800 // ----------------------------------------------------------------------------
801
MicrophoneMuteIsAvailable(bool * available)802 int32_t AudioDeviceModuleImpl::MicrophoneMuteIsAvailable(bool* available) {
803 LOG(INFO) << __FUNCTION__;
804 CHECK_INITIALIZED();
805
806 bool isAvailable(0);
807
808 if (_ptrAudioDevice->MicrophoneMuteIsAvailable(isAvailable) == -1) {
809 return -1;
810 }
811
812 *available = isAvailable;
813 LOG(INFO) << "output: " << isAvailable;
814 return (0);
815 }
816
817 // ----------------------------------------------------------------------------
818 // SetMicrophoneMute
819 // ----------------------------------------------------------------------------
820
SetMicrophoneMute(bool enable)821 int32_t AudioDeviceModuleImpl::SetMicrophoneMute(bool enable) {
822 LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
823 CHECK_INITIALIZED();
824 return (_ptrAudioDevice->SetMicrophoneMute(enable));
825 }
826
827 // ----------------------------------------------------------------------------
828 // MicrophoneMute
829 // ----------------------------------------------------------------------------
830
MicrophoneMute(bool * enabled) const831 int32_t AudioDeviceModuleImpl::MicrophoneMute(bool* enabled) const {
832 LOG(INFO) << __FUNCTION__;
833 CHECK_INITIALIZED();
834
835 bool muted(false);
836
837 if (_ptrAudioDevice->MicrophoneMute(muted) == -1) {
838 return -1;
839 }
840
841 *enabled = muted;
842 LOG(INFO) << "output: " << muted;
843 return (0);
844 }
845
846 // ----------------------------------------------------------------------------
847 // MicrophoneBoostIsAvailable
848 // ----------------------------------------------------------------------------
849
MicrophoneBoostIsAvailable(bool * available)850 int32_t AudioDeviceModuleImpl::MicrophoneBoostIsAvailable(bool* available) {
851 LOG(INFO) << __FUNCTION__;
852 CHECK_INITIALIZED();
853
854 bool isAvailable(0);
855
856 if (_ptrAudioDevice->MicrophoneBoostIsAvailable(isAvailable) == -1) {
857 return -1;
858 }
859
860 *available = isAvailable;
861 LOG(INFO) << "output: " << isAvailable;
862 return (0);
863 }
864
865 // ----------------------------------------------------------------------------
866 // SetMicrophoneBoost
867 // ----------------------------------------------------------------------------
868
SetMicrophoneBoost(bool enable)869 int32_t AudioDeviceModuleImpl::SetMicrophoneBoost(bool enable) {
870 LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
871 CHECK_INITIALIZED();
872 return (_ptrAudioDevice->SetMicrophoneBoost(enable));
873 }
874
875 // ----------------------------------------------------------------------------
876 // MicrophoneBoost
877 // ----------------------------------------------------------------------------
878
MicrophoneBoost(bool * enabled) const879 int32_t AudioDeviceModuleImpl::MicrophoneBoost(bool* enabled) const {
880 LOG(INFO) << __FUNCTION__;
881 CHECK_INITIALIZED();
882
883 bool onOff(false);
884
885 if (_ptrAudioDevice->MicrophoneBoost(onOff) == -1) {
886 return -1;
887 }
888
889 *enabled = onOff;
890 LOG(INFO) << "output: " << onOff;
891 return (0);
892 }
893
894 // ----------------------------------------------------------------------------
895 // MicrophoneVolumeIsAvailable
896 // ----------------------------------------------------------------------------
897
MicrophoneVolumeIsAvailable(bool * available)898 int32_t AudioDeviceModuleImpl::MicrophoneVolumeIsAvailable(bool* available) {
899 LOG(INFO) << __FUNCTION__;
900 CHECK_INITIALIZED();
901
902 bool isAvailable(0);
903
904 if (_ptrAudioDevice->MicrophoneVolumeIsAvailable(isAvailable) == -1) {
905 return -1;
906 }
907
908 *available = isAvailable;
909 LOG(INFO) << "output: " << isAvailable;
910 return (0);
911 }
912
913 // ----------------------------------------------------------------------------
914 // SetMicrophoneVolume
915 // ----------------------------------------------------------------------------
916
SetMicrophoneVolume(uint32_t volume)917 int32_t AudioDeviceModuleImpl::SetMicrophoneVolume(uint32_t volume) {
918 LOG(INFO) << __FUNCTION__ << "(" << volume << ")";
919 CHECK_INITIALIZED();
920 return (_ptrAudioDevice->SetMicrophoneVolume(volume));
921 }
922
923 // ----------------------------------------------------------------------------
924 // MicrophoneVolume
925 // ----------------------------------------------------------------------------
926
MicrophoneVolume(uint32_t * volume) const927 int32_t AudioDeviceModuleImpl::MicrophoneVolume(uint32_t* volume) const {
928 LOG(INFO) << __FUNCTION__;
929 CHECK_INITIALIZED();
930
931 uint32_t level(0);
932
933 if (_ptrAudioDevice->MicrophoneVolume(level) == -1) {
934 return -1;
935 }
936
937 *volume = level;
938 LOG(INFO) << "output: " << *volume;
939 return (0);
940 }
941
942 // ----------------------------------------------------------------------------
943 // StereoRecordingIsAvailable
944 // ----------------------------------------------------------------------------
945
StereoRecordingIsAvailable(bool * available) const946 int32_t AudioDeviceModuleImpl::StereoRecordingIsAvailable(
947 bool* available) const {
948 LOG(INFO) << __FUNCTION__;
949 CHECK_INITIALIZED();
950
951 bool isAvailable(0);
952
953 if (_ptrAudioDevice->StereoRecordingIsAvailable(isAvailable) == -1) {
954 return -1;
955 }
956
957 *available = isAvailable;
958 LOG(INFO) << "output: " << isAvailable;
959 return (0);
960 }
961
962 // ----------------------------------------------------------------------------
963 // SetStereoRecording
964 // ----------------------------------------------------------------------------
965
SetStereoRecording(bool enable)966 int32_t AudioDeviceModuleImpl::SetStereoRecording(bool enable) {
967 LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
968 CHECK_INITIALIZED();
969
970 if (_ptrAudioDevice->RecordingIsInitialized()) {
971 LOG(WARNING) << "recording in stereo is not supported";
972 return -1;
973 }
974
975 if (_ptrAudioDevice->SetStereoRecording(enable) == -1) {
976 LOG(WARNING) << "failed to change stereo recording";
977 return -1;
978 }
979
980 int8_t nChannels(1);
981 if (enable) {
982 nChannels = 2;
983 }
984 _audioDeviceBuffer.SetRecordingChannels(nChannels);
985
986 return 0;
987 }
988
989 // ----------------------------------------------------------------------------
990 // StereoRecording
991 // ----------------------------------------------------------------------------
992
StereoRecording(bool * enabled) const993 int32_t AudioDeviceModuleImpl::StereoRecording(bool* enabled) const {
994 LOG(INFO) << __FUNCTION__;
995 CHECK_INITIALIZED();
996
997 bool stereo(false);
998
999 if (_ptrAudioDevice->StereoRecording(stereo) == -1) {
1000 return -1;
1001 }
1002
1003 *enabled = stereo;
1004 LOG(INFO) << "output: " << stereo;
1005 return (0);
1006 }
1007
1008 // ----------------------------------------------------------------------------
1009 // SetRecordingChannel
1010 // ----------------------------------------------------------------------------
1011
SetRecordingChannel(const ChannelType channel)1012 int32_t AudioDeviceModuleImpl::SetRecordingChannel(const ChannelType channel) {
1013 if (channel == kChannelBoth) {
1014 LOG(INFO) << __FUNCTION__ << "(both)";
1015 } else if (channel == kChannelLeft) {
1016 LOG(INFO) << __FUNCTION__ << "(left)";
1017 } else {
1018 LOG(INFO) << __FUNCTION__ << "(right)";
1019 }
1020 CHECK_INITIALIZED();
1021
1022 bool stereo(false);
1023
1024 if (_ptrAudioDevice->StereoRecording(stereo) == -1) {
1025 LOG(WARNING) << "recording in stereo is not supported";
1026 return -1;
1027 }
1028
1029 return (_audioDeviceBuffer.SetRecordingChannel(channel));
1030 }
1031
1032 // ----------------------------------------------------------------------------
1033 // RecordingChannel
1034 // ----------------------------------------------------------------------------
1035
RecordingChannel(ChannelType * channel) const1036 int32_t AudioDeviceModuleImpl::RecordingChannel(ChannelType* channel) const {
1037 LOG(INFO) << __FUNCTION__;
1038 CHECK_INITIALIZED();
1039
1040 ChannelType chType;
1041
1042 if (_audioDeviceBuffer.RecordingChannel(chType) == -1) {
1043 return -1;
1044 }
1045
1046 *channel = chType;
1047 if (*channel == kChannelBoth) {
1048 LOG(INFO) << "output: both";
1049 } else if (*channel == kChannelLeft) {
1050 LOG(INFO) << "output: left";
1051 } else {
1052 LOG(INFO) << "output: right";
1053 }
1054 return (0);
1055 }
1056
1057 // ----------------------------------------------------------------------------
1058 // StereoPlayoutIsAvailable
1059 // ----------------------------------------------------------------------------
1060
StereoPlayoutIsAvailable(bool * available) const1061 int32_t AudioDeviceModuleImpl::StereoPlayoutIsAvailable(bool* available) const {
1062 LOG(INFO) << __FUNCTION__;
1063 CHECK_INITIALIZED();
1064
1065 bool isAvailable(0);
1066
1067 if (_ptrAudioDevice->StereoPlayoutIsAvailable(isAvailable) == -1) {
1068 return -1;
1069 }
1070
1071 *available = isAvailable;
1072 LOG(INFO) << "output: " << isAvailable;
1073 return (0);
1074 }
1075
1076 // ----------------------------------------------------------------------------
1077 // SetStereoPlayout
1078 // ----------------------------------------------------------------------------
1079
SetStereoPlayout(bool enable)1080 int32_t AudioDeviceModuleImpl::SetStereoPlayout(bool enable) {
1081 LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
1082 CHECK_INITIALIZED();
1083
1084 if (_ptrAudioDevice->PlayoutIsInitialized()) {
1085 LOG(LERROR)
1086 << "unable to set stereo mode while playing side is initialized";
1087 return -1;
1088 }
1089
1090 if (_ptrAudioDevice->SetStereoPlayout(enable)) {
1091 LOG(WARNING) << "stereo playout is not supported";
1092 return -1;
1093 }
1094
1095 int8_t nChannels(1);
1096 if (enable) {
1097 nChannels = 2;
1098 }
1099 _audioDeviceBuffer.SetPlayoutChannels(nChannels);
1100
1101 return 0;
1102 }
1103
1104 // ----------------------------------------------------------------------------
1105 // StereoPlayout
1106 // ----------------------------------------------------------------------------
1107
StereoPlayout(bool * enabled) const1108 int32_t AudioDeviceModuleImpl::StereoPlayout(bool* enabled) const {
1109 LOG(INFO) << __FUNCTION__;
1110 CHECK_INITIALIZED();
1111
1112 bool stereo(false);
1113
1114 if (_ptrAudioDevice->StereoPlayout(stereo) == -1) {
1115 return -1;
1116 }
1117
1118 *enabled = stereo;
1119 LOG(INFO) << "output: " << stereo;
1120 return (0);
1121 }
1122
1123 // ----------------------------------------------------------------------------
1124 // SetAGC
1125 // ----------------------------------------------------------------------------
1126
SetAGC(bool enable)1127 int32_t AudioDeviceModuleImpl::SetAGC(bool enable) {
1128 LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
1129 CHECK_INITIALIZED();
1130 return (_ptrAudioDevice->SetAGC(enable));
1131 }
1132
1133 // ----------------------------------------------------------------------------
1134 // AGC
1135 // ----------------------------------------------------------------------------
1136
AGC() const1137 bool AudioDeviceModuleImpl::AGC() const {
1138 LOG(INFO) << __FUNCTION__;
1139 CHECK_INITIALIZED_BOOL();
1140 return (_ptrAudioDevice->AGC());
1141 }
1142
1143 // ----------------------------------------------------------------------------
1144 // PlayoutIsAvailable
1145 // ----------------------------------------------------------------------------
1146
PlayoutIsAvailable(bool * available)1147 int32_t AudioDeviceModuleImpl::PlayoutIsAvailable(bool* available) {
1148 LOG(INFO) << __FUNCTION__;
1149 CHECK_INITIALIZED();
1150
1151 bool isAvailable(0);
1152
1153 if (_ptrAudioDevice->PlayoutIsAvailable(isAvailable) == -1) {
1154 return -1;
1155 }
1156
1157 *available = isAvailable;
1158 LOG(INFO) << "output: " << isAvailable;
1159 return (0);
1160 }
1161
1162 // ----------------------------------------------------------------------------
1163 // RecordingIsAvailable
1164 // ----------------------------------------------------------------------------
1165
RecordingIsAvailable(bool * available)1166 int32_t AudioDeviceModuleImpl::RecordingIsAvailable(bool* available) {
1167 LOG(INFO) << __FUNCTION__;
1168 CHECK_INITIALIZED();
1169
1170 bool isAvailable(0);
1171
1172 if (_ptrAudioDevice->RecordingIsAvailable(isAvailable) == -1) {
1173 return -1;
1174 }
1175
1176 *available = isAvailable;
1177 LOG(INFO) << "output: " << isAvailable;
1178 return (0);
1179 }
1180
1181 // ----------------------------------------------------------------------------
1182 // MaxMicrophoneVolume
1183 // ----------------------------------------------------------------------------
1184
MaxMicrophoneVolume(uint32_t * maxVolume) const1185 int32_t AudioDeviceModuleImpl::MaxMicrophoneVolume(uint32_t* maxVolume) const {
1186 CHECK_INITIALIZED();
1187
1188 uint32_t maxVol(0);
1189
1190 if (_ptrAudioDevice->MaxMicrophoneVolume(maxVol) == -1) {
1191 return -1;
1192 }
1193
1194 *maxVolume = maxVol;
1195 return (0);
1196 }
1197
1198 // ----------------------------------------------------------------------------
1199 // MinMicrophoneVolume
1200 // ----------------------------------------------------------------------------
1201
MinMicrophoneVolume(uint32_t * minVolume) const1202 int32_t AudioDeviceModuleImpl::MinMicrophoneVolume(uint32_t* minVolume) const {
1203 CHECK_INITIALIZED();
1204
1205 uint32_t minVol(0);
1206
1207 if (_ptrAudioDevice->MinMicrophoneVolume(minVol) == -1) {
1208 return -1;
1209 }
1210
1211 *minVolume = minVol;
1212 return (0);
1213 }
1214
1215 // ----------------------------------------------------------------------------
1216 // MicrophoneVolumeStepSize
1217 // ----------------------------------------------------------------------------
1218
MicrophoneVolumeStepSize(uint16_t * stepSize) const1219 int32_t AudioDeviceModuleImpl::MicrophoneVolumeStepSize(
1220 uint16_t* stepSize) const {
1221 LOG(INFO) << __FUNCTION__;
1222 CHECK_INITIALIZED();
1223
1224 uint16_t delta(0);
1225
1226 if (_ptrAudioDevice->MicrophoneVolumeStepSize(delta) == -1) {
1227 return -1;
1228 }
1229
1230 *stepSize = delta;
1231 LOG(INFO) << "output: " << *stepSize;
1232 return (0);
1233 }
1234
1235 // ----------------------------------------------------------------------------
1236 // PlayoutDevices
1237 // ----------------------------------------------------------------------------
1238
PlayoutDevices()1239 int16_t AudioDeviceModuleImpl::PlayoutDevices() {
1240 LOG(INFO) << __FUNCTION__;
1241 CHECK_INITIALIZED();
1242
1243 uint16_t nPlayoutDevices = _ptrAudioDevice->PlayoutDevices();
1244 LOG(INFO) << "output: " << nPlayoutDevices;
1245 return ((int16_t)(nPlayoutDevices));
1246 }
1247
1248 // ----------------------------------------------------------------------------
1249 // SetPlayoutDevice I (II)
1250 // ----------------------------------------------------------------------------
1251
SetPlayoutDevice(uint16_t index)1252 int32_t AudioDeviceModuleImpl::SetPlayoutDevice(uint16_t index) {
1253 LOG(INFO) << __FUNCTION__ << "(" << index << ")";
1254 CHECK_INITIALIZED();
1255 return (_ptrAudioDevice->SetPlayoutDevice(index));
1256 }
1257
1258 // ----------------------------------------------------------------------------
1259 // SetPlayoutDevice II (II)
1260 // ----------------------------------------------------------------------------
1261
SetPlayoutDevice(WindowsDeviceType device)1262 int32_t AudioDeviceModuleImpl::SetPlayoutDevice(WindowsDeviceType device) {
1263 LOG(INFO) << __FUNCTION__;
1264 CHECK_INITIALIZED();
1265
1266 return (_ptrAudioDevice->SetPlayoutDevice(device));
1267 }
1268
1269 // ----------------------------------------------------------------------------
1270 // PlayoutDeviceName
1271 // ----------------------------------------------------------------------------
1272
PlayoutDeviceName(uint16_t index,char name[kAdmMaxDeviceNameSize],char guid[kAdmMaxGuidSize])1273 int32_t AudioDeviceModuleImpl::PlayoutDeviceName(
1274 uint16_t index,
1275 char name[kAdmMaxDeviceNameSize],
1276 char guid[kAdmMaxGuidSize]) {
1277 LOG(INFO) << __FUNCTION__ << "(" << index << ", ...)";
1278 CHECK_INITIALIZED();
1279
1280 if (name == NULL) {
1281 _lastError = kAdmErrArgument;
1282 return -1;
1283 }
1284
1285 if (_ptrAudioDevice->PlayoutDeviceName(index, name, guid) == -1) {
1286 return -1;
1287 }
1288
1289 if (name != NULL) {
1290 LOG(INFO) << "output: name = " << name;
1291 }
1292 if (guid != NULL) {
1293 LOG(INFO) << "output: guid = " << guid;
1294 }
1295
1296 return (0);
1297 }
1298
1299 // ----------------------------------------------------------------------------
1300 // RecordingDeviceName
1301 // ----------------------------------------------------------------------------
1302
RecordingDeviceName(uint16_t index,char name[kAdmMaxDeviceNameSize],char guid[kAdmMaxGuidSize])1303 int32_t AudioDeviceModuleImpl::RecordingDeviceName(
1304 uint16_t index,
1305 char name[kAdmMaxDeviceNameSize],
1306 char guid[kAdmMaxGuidSize]) {
1307 LOG(INFO) << __FUNCTION__ << "(" << index << ", ...)";
1308 CHECK_INITIALIZED();
1309
1310 if (name == NULL) {
1311 _lastError = kAdmErrArgument;
1312 return -1;
1313 }
1314
1315 if (_ptrAudioDevice->RecordingDeviceName(index, name, guid) == -1) {
1316 return -1;
1317 }
1318
1319 if (name != NULL) {
1320 LOG(INFO) << "output: name = " << name;
1321 }
1322 if (guid != NULL) {
1323 LOG(INFO) << "output: guid = " << guid;
1324 }
1325
1326 return (0);
1327 }
1328
1329 // ----------------------------------------------------------------------------
1330 // RecordingDevices
1331 // ----------------------------------------------------------------------------
1332
RecordingDevices()1333 int16_t AudioDeviceModuleImpl::RecordingDevices() {
1334 LOG(INFO) << __FUNCTION__;
1335 CHECK_INITIALIZED();
1336
1337 uint16_t nRecordingDevices = _ptrAudioDevice->RecordingDevices();
1338
1339 LOG(INFO) << "output: " << nRecordingDevices;
1340 return ((int16_t)nRecordingDevices);
1341 }
1342
1343 // ----------------------------------------------------------------------------
1344 // SetRecordingDevice I (II)
1345 // ----------------------------------------------------------------------------
1346
SetRecordingDevice(uint16_t index)1347 int32_t AudioDeviceModuleImpl::SetRecordingDevice(uint16_t index) {
1348 LOG(INFO) << __FUNCTION__ << "(" << index << ")";
1349 CHECK_INITIALIZED();
1350 return (_ptrAudioDevice->SetRecordingDevice(index));
1351 }
1352
1353 // ----------------------------------------------------------------------------
1354 // SetRecordingDevice II (II)
1355 // ----------------------------------------------------------------------------
1356
SetRecordingDevice(WindowsDeviceType device)1357 int32_t AudioDeviceModuleImpl::SetRecordingDevice(WindowsDeviceType device) {
1358 LOG(INFO) << __FUNCTION__;
1359 CHECK_INITIALIZED();
1360
1361 return (_ptrAudioDevice->SetRecordingDevice(device));
1362 }
1363
1364 // ----------------------------------------------------------------------------
1365 // InitPlayout
1366 // ----------------------------------------------------------------------------
1367
InitPlayout()1368 int32_t AudioDeviceModuleImpl::InitPlayout() {
1369 LOG(INFO) << __FUNCTION__;
1370 CHECK_INITIALIZED();
1371 if (PlayoutIsInitialized()) {
1372 return 0;
1373 }
1374 int32_t result = _ptrAudioDevice->InitPlayout();
1375 LOG(INFO) << "output: " << result;
1376 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.InitPlayoutSuccess",
1377 static_cast<int>(result == 0));
1378 return result;
1379 }
1380
1381 // ----------------------------------------------------------------------------
1382 // InitRecording
1383 // ----------------------------------------------------------------------------
1384
InitRecording()1385 int32_t AudioDeviceModuleImpl::InitRecording() {
1386 LOG(INFO) << __FUNCTION__;
1387 CHECK_INITIALIZED();
1388 if (RecordingIsInitialized()) {
1389 return 0;
1390 }
1391 int32_t result = _ptrAudioDevice->InitRecording();
1392 LOG(INFO) << "output: " << result;
1393 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.InitRecordingSuccess",
1394 static_cast<int>(result == 0));
1395 return result;
1396 }
1397
1398 // ----------------------------------------------------------------------------
1399 // PlayoutIsInitialized
1400 // ----------------------------------------------------------------------------
1401
PlayoutIsInitialized() const1402 bool AudioDeviceModuleImpl::PlayoutIsInitialized() const {
1403 LOG(INFO) << __FUNCTION__;
1404 CHECK_INITIALIZED_BOOL();
1405 return (_ptrAudioDevice->PlayoutIsInitialized());
1406 }
1407
1408 // ----------------------------------------------------------------------------
1409 // RecordingIsInitialized
1410 // ----------------------------------------------------------------------------
1411
RecordingIsInitialized() const1412 bool AudioDeviceModuleImpl::RecordingIsInitialized() const {
1413 LOG(INFO) << __FUNCTION__;
1414 CHECK_INITIALIZED_BOOL();
1415 return (_ptrAudioDevice->RecordingIsInitialized());
1416 }
1417
1418 // ----------------------------------------------------------------------------
1419 // StartPlayout
1420 // ----------------------------------------------------------------------------
1421
StartPlayout()1422 int32_t AudioDeviceModuleImpl::StartPlayout() {
1423 LOG(INFO) << __FUNCTION__;
1424 CHECK_INITIALIZED();
1425 if (Playing()) {
1426 return 0;
1427 }
1428 _audioDeviceBuffer.StartPlayout();
1429 int32_t result = _ptrAudioDevice->StartPlayout();
1430 LOG(INFO) << "output: " << result;
1431 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StartPlayoutSuccess",
1432 static_cast<int>(result == 0));
1433 return result;
1434 }
1435
1436 // ----------------------------------------------------------------------------
1437 // StopPlayout
1438 // ----------------------------------------------------------------------------
1439
StopPlayout()1440 int32_t AudioDeviceModuleImpl::StopPlayout() {
1441 LOG(INFO) << __FUNCTION__;
1442 CHECK_INITIALIZED();
1443 int32_t result = _ptrAudioDevice->StopPlayout();
1444 _audioDeviceBuffer.StopPlayout();
1445 LOG(INFO) << "output: " << result;
1446 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StopPlayoutSuccess",
1447 static_cast<int>(result == 0));
1448 return result;
1449 }
1450
1451 // ----------------------------------------------------------------------------
1452 // Playing
1453 // ----------------------------------------------------------------------------
1454
Playing() const1455 bool AudioDeviceModuleImpl::Playing() const {
1456 LOG(INFO) << __FUNCTION__;
1457 CHECK_INITIALIZED_BOOL();
1458 return (_ptrAudioDevice->Playing());
1459 }
1460
1461 // ----------------------------------------------------------------------------
1462 // StartRecording
1463 // ----------------------------------------------------------------------------
1464
StartRecording()1465 int32_t AudioDeviceModuleImpl::StartRecording() {
1466 LOG(INFO) << __FUNCTION__;
1467 CHECK_INITIALIZED();
1468 if (Recording()) {
1469 return 0;
1470 }
1471 _audioDeviceBuffer.StartRecording();
1472 int32_t result = _ptrAudioDevice->StartRecording();
1473 LOG(INFO) << "output: " << result;
1474 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StartRecordingSuccess",
1475 static_cast<int>(result == 0));
1476 return result;
1477 }
1478 // ----------------------------------------------------------------------------
1479 // StopRecording
1480 // ----------------------------------------------------------------------------
1481
StopRecording()1482 int32_t AudioDeviceModuleImpl::StopRecording() {
1483 LOG(INFO) << __FUNCTION__;
1484 CHECK_INITIALIZED();
1485 int32_t result = _ptrAudioDevice->StopRecording();
1486 _audioDeviceBuffer.StopRecording();
1487 LOG(INFO) << "output: " << result;
1488 RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StopRecordingSuccess",
1489 static_cast<int>(result == 0));
1490 return result;
1491 }
1492
1493 // ----------------------------------------------------------------------------
1494 // Recording
1495 // ----------------------------------------------------------------------------
1496
Recording() const1497 bool AudioDeviceModuleImpl::Recording() const {
1498 LOG(INFO) << __FUNCTION__;
1499 CHECK_INITIALIZED_BOOL();
1500 return (_ptrAudioDevice->Recording());
1501 }
1502
1503 // ----------------------------------------------------------------------------
1504 // RegisterEventObserver
1505 // ----------------------------------------------------------------------------
1506
RegisterEventObserver(AudioDeviceObserver * eventCallback)1507 int32_t AudioDeviceModuleImpl::RegisterEventObserver(
1508 AudioDeviceObserver* eventCallback) {
1509 LOG(INFO) << __FUNCTION__;
1510 CriticalSectionScoped lock(&_critSectEventCb);
1511 _ptrCbAudioDeviceObserver = eventCallback;
1512
1513 return 0;
1514 }
1515
1516 // ----------------------------------------------------------------------------
1517 // RegisterAudioCallback
1518 // ----------------------------------------------------------------------------
1519
RegisterAudioCallback(AudioTransport * audioCallback)1520 int32_t AudioDeviceModuleImpl::RegisterAudioCallback(
1521 AudioTransport* audioCallback) {
1522 LOG(INFO) << __FUNCTION__;
1523 CriticalSectionScoped lock(&_critSectAudioCb);
1524 return _audioDeviceBuffer.RegisterAudioCallback(audioCallback);
1525 }
1526
1527 // ----------------------------------------------------------------------------
1528 // StartRawInputFileRecording
1529 // ----------------------------------------------------------------------------
1530
StartRawInputFileRecording(const char pcmFileNameUTF8[kAdmMaxFileNameSize])1531 int32_t AudioDeviceModuleImpl::StartRawInputFileRecording(
1532 const char pcmFileNameUTF8[kAdmMaxFileNameSize]) {
1533 LOG(INFO) << __FUNCTION__;
1534 CHECK_INITIALIZED();
1535
1536 if (NULL == pcmFileNameUTF8) {
1537 return -1;
1538 }
1539
1540 return (_audioDeviceBuffer.StartInputFileRecording(pcmFileNameUTF8));
1541 }
1542
1543 // ----------------------------------------------------------------------------
1544 // StopRawInputFileRecording
1545 // ----------------------------------------------------------------------------
1546
StopRawInputFileRecording()1547 int32_t AudioDeviceModuleImpl::StopRawInputFileRecording() {
1548 LOG(INFO) << __FUNCTION__;
1549 CHECK_INITIALIZED();
1550
1551 return (_audioDeviceBuffer.StopInputFileRecording());
1552 }
1553
1554 // ----------------------------------------------------------------------------
1555 // StartRawOutputFileRecording
1556 // ----------------------------------------------------------------------------
1557
StartRawOutputFileRecording(const char pcmFileNameUTF8[kAdmMaxFileNameSize])1558 int32_t AudioDeviceModuleImpl::StartRawOutputFileRecording(
1559 const char pcmFileNameUTF8[kAdmMaxFileNameSize]) {
1560 LOG(INFO) << __FUNCTION__;
1561 CHECK_INITIALIZED();
1562
1563 if (NULL == pcmFileNameUTF8) {
1564 return -1;
1565 }
1566
1567 return (_audioDeviceBuffer.StartOutputFileRecording(pcmFileNameUTF8));
1568 }
1569
1570 // ----------------------------------------------------------------------------
1571 // StopRawOutputFileRecording
1572 // ----------------------------------------------------------------------------
1573
StopRawOutputFileRecording()1574 int32_t AudioDeviceModuleImpl::StopRawOutputFileRecording() {
1575 LOG(INFO) << __FUNCTION__;
1576 CHECK_INITIALIZED();
1577
1578 return (_audioDeviceBuffer.StopOutputFileRecording());
1579 }
1580
1581 // ----------------------------------------------------------------------------
1582 // SetPlayoutBuffer
1583 // ----------------------------------------------------------------------------
1584
SetPlayoutBuffer(const BufferType type,uint16_t sizeMS)1585 int32_t AudioDeviceModuleImpl::SetPlayoutBuffer(const BufferType type,
1586 uint16_t sizeMS) {
1587 if (type == kFixedBufferSize) {
1588 LOG(INFO) << __FUNCTION__ << "(fixed buffer, " << sizeMS << "ms)";
1589 } else if (type == kAdaptiveBufferSize) {
1590 LOG(INFO) << __FUNCTION__ << "(adaptive buffer, " << sizeMS << "ms)";
1591 } else {
1592 LOG(INFO) << __FUNCTION__ << "(?, " << sizeMS << "ms)";
1593 }
1594 CHECK_INITIALIZED();
1595
1596 if (_ptrAudioDevice->PlayoutIsInitialized()) {
1597 LOG(LERROR) << "unable to modify the playout buffer while playing side is "
1598 "initialized";
1599 return -1;
1600 }
1601
1602 int32_t ret(0);
1603
1604 if (kFixedBufferSize == type) {
1605 if (sizeMS < kAdmMinPlayoutBufferSizeMs ||
1606 sizeMS > kAdmMaxPlayoutBufferSizeMs) {
1607 LOG(LERROR) << "size parameter is out of range";
1608 return -1;
1609 }
1610 }
1611
1612 if ((ret = _ptrAudioDevice->SetPlayoutBuffer(type, sizeMS)) == -1) {
1613 LOG(LERROR) << "failed to set the playout buffer (error: " << LastError()
1614 << ")";
1615 }
1616
1617 return ret;
1618 }
1619
1620 // ----------------------------------------------------------------------------
1621 // PlayoutBuffer
1622 // ----------------------------------------------------------------------------
1623
PlayoutBuffer(BufferType * type,uint16_t * sizeMS) const1624 int32_t AudioDeviceModuleImpl::PlayoutBuffer(BufferType* type,
1625 uint16_t* sizeMS) const {
1626 LOG(INFO) << __FUNCTION__;
1627 CHECK_INITIALIZED();
1628
1629 BufferType bufType;
1630 uint16_t size(0);
1631
1632 if (_ptrAudioDevice->PlayoutBuffer(bufType, size) == -1) {
1633 LOG(LERROR) << "failed to retrieve the buffer type and size";
1634 return -1;
1635 }
1636
1637 *type = bufType;
1638 *sizeMS = size;
1639
1640 LOG(INFO) << "output: type = " << *type << ", sizeMS = " << *sizeMS;
1641 return (0);
1642 }
1643
1644 // ----------------------------------------------------------------------------
1645 // PlayoutDelay
1646 // ----------------------------------------------------------------------------
1647
PlayoutDelay(uint16_t * delayMS) const1648 int32_t AudioDeviceModuleImpl::PlayoutDelay(uint16_t* delayMS) const {
1649 CHECK_INITIALIZED();
1650
1651 uint16_t delay(0);
1652
1653 if (_ptrAudioDevice->PlayoutDelay(delay) == -1) {
1654 LOG(LERROR) << "failed to retrieve the playout delay";
1655 return -1;
1656 }
1657
1658 *delayMS = delay;
1659 return (0);
1660 }
1661
1662 // ----------------------------------------------------------------------------
1663 // RecordingDelay
1664 // ----------------------------------------------------------------------------
1665
RecordingDelay(uint16_t * delayMS) const1666 int32_t AudioDeviceModuleImpl::RecordingDelay(uint16_t* delayMS) const {
1667 LOG(INFO) << __FUNCTION__;
1668 CHECK_INITIALIZED();
1669
1670 uint16_t delay(0);
1671
1672 if (_ptrAudioDevice->RecordingDelay(delay) == -1) {
1673 LOG(LERROR) << "failed to retrieve the recording delay";
1674 return -1;
1675 }
1676
1677 *delayMS = delay;
1678 LOG(INFO) << "output: " << *delayMS;
1679 return (0);
1680 }
1681
1682 // ----------------------------------------------------------------------------
1683 // CPULoad
1684 // ----------------------------------------------------------------------------
1685
CPULoad(uint16_t * load) const1686 int32_t AudioDeviceModuleImpl::CPULoad(uint16_t* load) const {
1687 LOG(INFO) << __FUNCTION__;
1688 CHECK_INITIALIZED();
1689
1690 uint16_t cpuLoad(0);
1691
1692 if (_ptrAudioDevice->CPULoad(cpuLoad) == -1) {
1693 LOG(LERROR) << "failed to retrieve the CPU load";
1694 return -1;
1695 }
1696
1697 *load = cpuLoad;
1698 LOG(INFO) << "output: " << *load;
1699 return (0);
1700 }
1701
1702 // ----------------------------------------------------------------------------
1703 // SetRecordingSampleRate
1704 // ----------------------------------------------------------------------------
1705
SetRecordingSampleRate(const uint32_t samplesPerSec)1706 int32_t AudioDeviceModuleImpl::SetRecordingSampleRate(
1707 const uint32_t samplesPerSec) {
1708 LOG(INFO) << __FUNCTION__ << "(" << samplesPerSec << ")";
1709 CHECK_INITIALIZED();
1710
1711 if (_ptrAudioDevice->SetRecordingSampleRate(samplesPerSec) != 0) {
1712 return -1;
1713 }
1714
1715 return (0);
1716 }
1717
1718 // ----------------------------------------------------------------------------
1719 // RecordingSampleRate
1720 // ----------------------------------------------------------------------------
1721
RecordingSampleRate(uint32_t * samplesPerSec) const1722 int32_t AudioDeviceModuleImpl::RecordingSampleRate(
1723 uint32_t* samplesPerSec) const {
1724 LOG(INFO) << __FUNCTION__;
1725 CHECK_INITIALIZED();
1726
1727 int32_t sampleRate = _audioDeviceBuffer.RecordingSampleRate();
1728
1729 if (sampleRate == -1) {
1730 LOG(LERROR) << "failed to retrieve the sample rate";
1731 return -1;
1732 }
1733
1734 *samplesPerSec = sampleRate;
1735 LOG(INFO) << "output: " << *samplesPerSec;
1736 return (0);
1737 }
1738
1739 // ----------------------------------------------------------------------------
1740 // SetPlayoutSampleRate
1741 // ----------------------------------------------------------------------------
1742
SetPlayoutSampleRate(const uint32_t samplesPerSec)1743 int32_t AudioDeviceModuleImpl::SetPlayoutSampleRate(
1744 const uint32_t samplesPerSec) {
1745 LOG(INFO) << __FUNCTION__ << "(" << samplesPerSec << ")";
1746 CHECK_INITIALIZED();
1747
1748 if (_ptrAudioDevice->SetPlayoutSampleRate(samplesPerSec) != 0) {
1749 return -1;
1750 }
1751
1752 return (0);
1753 }
1754
1755 // ----------------------------------------------------------------------------
1756 // PlayoutSampleRate
1757 // ----------------------------------------------------------------------------
1758
PlayoutSampleRate(uint32_t * samplesPerSec) const1759 int32_t AudioDeviceModuleImpl::PlayoutSampleRate(
1760 uint32_t* samplesPerSec) const {
1761 LOG(INFO) << __FUNCTION__;
1762 CHECK_INITIALIZED();
1763
1764 int32_t sampleRate = _audioDeviceBuffer.PlayoutSampleRate();
1765
1766 if (sampleRate == -1) {
1767 LOG(LERROR) << "failed to retrieve the sample rate";
1768 return -1;
1769 }
1770
1771 *samplesPerSec = sampleRate;
1772 LOG(INFO) << "output: " << *samplesPerSec;
1773 return (0);
1774 }
1775
1776 // ----------------------------------------------------------------------------
1777 // ResetAudioDevice
1778 // ----------------------------------------------------------------------------
1779
ResetAudioDevice()1780 int32_t AudioDeviceModuleImpl::ResetAudioDevice() {
1781 LOG(INFO) << __FUNCTION__;
1782 FATAL() << "Should never be called";
1783 return -1;
1784 }
1785
1786 // ----------------------------------------------------------------------------
1787 // SetLoudspeakerStatus
1788 // ----------------------------------------------------------------------------
1789
SetLoudspeakerStatus(bool enable)1790 int32_t AudioDeviceModuleImpl::SetLoudspeakerStatus(bool enable) {
1791 LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
1792 CHECK_INITIALIZED();
1793
1794 if (_ptrAudioDevice->SetLoudspeakerStatus(enable) != 0) {
1795 return -1;
1796 }
1797
1798 return 0;
1799 }
1800
1801 // ----------------------------------------------------------------------------
1802 // GetLoudspeakerStatus
1803 // ----------------------------------------------------------------------------
1804
GetLoudspeakerStatus(bool * enabled) const1805 int32_t AudioDeviceModuleImpl::GetLoudspeakerStatus(bool* enabled) const {
1806 LOG(INFO) << __FUNCTION__;
1807 CHECK_INITIALIZED();
1808 int32_t ok = 0;
1809 if (_ptrAudioDevice->GetLoudspeakerStatus(*enabled) != 0) {
1810 ok = -1;
1811 }
1812 LOG(INFO) << "output: " << ok;
1813 return ok;
1814 }
1815
BuiltInAECIsAvailable() const1816 bool AudioDeviceModuleImpl::BuiltInAECIsAvailable() const {
1817 LOG(INFO) << __FUNCTION__;
1818 CHECK_INITIALIZED_BOOL();
1819 bool isAvailable = _ptrAudioDevice->BuiltInAECIsAvailable();
1820 LOG(INFO) << "output: " << isAvailable;
1821 return isAvailable;
1822 }
1823
EnableBuiltInAEC(bool enable)1824 int32_t AudioDeviceModuleImpl::EnableBuiltInAEC(bool enable) {
1825 LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
1826 CHECK_INITIALIZED();
1827 int32_t ok = _ptrAudioDevice->EnableBuiltInAEC(enable);
1828 LOG(INFO) << "output: " << ok;
1829 return ok;
1830 }
1831
BuiltInAGCIsAvailable() const1832 bool AudioDeviceModuleImpl::BuiltInAGCIsAvailable() const {
1833 LOG(INFO) << __FUNCTION__;
1834 CHECK_INITIALIZED_BOOL();
1835 bool isAvailable = _ptrAudioDevice->BuiltInAGCIsAvailable();
1836 LOG(INFO) << "output: " << isAvailable;
1837 return isAvailable;
1838 }
1839
EnableBuiltInAGC(bool enable)1840 int32_t AudioDeviceModuleImpl::EnableBuiltInAGC(bool enable) {
1841 LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
1842 CHECK_INITIALIZED();
1843 int32_t ok = _ptrAudioDevice->EnableBuiltInAGC(enable);
1844 LOG(INFO) << "output: " << ok;
1845 return ok;
1846 }
1847
BuiltInNSIsAvailable() const1848 bool AudioDeviceModuleImpl::BuiltInNSIsAvailable() const {
1849 LOG(INFO) << __FUNCTION__;
1850 CHECK_INITIALIZED_BOOL();
1851 bool isAvailable = _ptrAudioDevice->BuiltInNSIsAvailable();
1852 LOG(INFO) << "output: " << isAvailable;
1853 return isAvailable;
1854 }
1855
EnableBuiltInNS(bool enable)1856 int32_t AudioDeviceModuleImpl::EnableBuiltInNS(bool enable) {
1857 LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
1858 CHECK_INITIALIZED();
1859 int32_t ok = _ptrAudioDevice->EnableBuiltInNS(enable);
1860 LOG(INFO) << "output: " << ok;
1861 return ok;
1862 }
1863
1864 #if defined(WEBRTC_IOS)
GetPlayoutAudioParameters(AudioParameters * params) const1865 int AudioDeviceModuleImpl::GetPlayoutAudioParameters(
1866 AudioParameters* params) const {
1867 LOG(INFO) << __FUNCTION__;
1868 int r = _ptrAudioDevice->GetPlayoutAudioParameters(params);
1869 LOG(INFO) << "output: " << r;
1870 return r;
1871 }
1872
GetRecordAudioParameters(AudioParameters * params) const1873 int AudioDeviceModuleImpl::GetRecordAudioParameters(
1874 AudioParameters* params) const {
1875 LOG(INFO) << __FUNCTION__;
1876 int r = _ptrAudioDevice->GetRecordAudioParameters(params);
1877 LOG(INFO) << "output: " << r;
1878 return r;
1879 }
1880 #endif // WEBRTC_IOS
1881
1882 // ============================================================================
1883 // Private Methods
1884 // ============================================================================
1885
1886 // ----------------------------------------------------------------------------
1887 // Platform
1888 // ----------------------------------------------------------------------------
1889
Platform() const1890 AudioDeviceModuleImpl::PlatformType AudioDeviceModuleImpl::Platform() const {
1891 LOG(INFO) << __FUNCTION__;
1892 return _platformType;
1893 }
1894
1895 // ----------------------------------------------------------------------------
1896 // PlatformAudioLayer
1897 // ----------------------------------------------------------------------------
1898
PlatformAudioLayer() const1899 AudioDeviceModule::AudioLayer AudioDeviceModuleImpl::PlatformAudioLayer()
1900 const {
1901 LOG(INFO) << __FUNCTION__;
1902 return _platformAudioLayer;
1903 }
1904
1905 } // namespace webrtc
1906