Line data Source code
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 :
88 0 : rtc::scoped_refptr<AudioDeviceModule> AudioDeviceModule::Create(
89 : const int32_t id,
90 : const AudioLayer audio_layer) {
91 0 : LOG(INFO) << __FUNCTION__;
92 : // Create the generic ref counted (platform independent) implementation.
93 : rtc::scoped_refptr<AudioDeviceModuleImpl> audioDevice(
94 0 : new rtc::RefCountedObject<AudioDeviceModuleImpl>(id, audio_layer));
95 :
96 : // Ensure that the current platform is supported.
97 0 : if (audioDevice->CheckPlatform() == -1) {
98 0 : return nullptr;
99 : }
100 :
101 : // Create the platform-dependent implementation.
102 0 : if (audioDevice->CreatePlatformSpecificObjects() == -1) {
103 0 : return nullptr;
104 : }
105 :
106 : // Ensure that the generic audio buffer can communicate with the
107 : // platform-specific parts.
108 0 : if (audioDevice->AttachAudioBuffer() == -1) {
109 0 : return nullptr;
110 : }
111 :
112 0 : WebRtcSpl_Init();
113 :
114 0 : return audioDevice;
115 : }
116 :
117 : // ============================================================================
118 : // Construction & Destruction
119 : // ============================================================================
120 :
121 : // ----------------------------------------------------------------------------
122 : // AudioDeviceModuleImpl - ctor
123 : // ----------------------------------------------------------------------------
124 :
125 0 : AudioDeviceModuleImpl::AudioDeviceModuleImpl(const int32_t id,
126 0 : const AudioLayer audioLayer)
127 0 : : _critSect(*CriticalSectionWrapper::CreateCriticalSection()),
128 0 : _critSectEventCb(*CriticalSectionWrapper::CreateCriticalSection()),
129 0 : _critSectAudioCb(*CriticalSectionWrapper::CreateCriticalSection()),
130 : _ptrCbAudioDeviceObserver(NULL),
131 : _ptrAudioDevice(NULL),
132 : _id(id),
133 : _platformAudioLayer(audioLayer),
134 0 : _lastProcessTime(rtc::TimeMillis()),
135 : _platformType(kPlatformNotSupported),
136 : _initialized(false),
137 0 : _lastError(kAdmErrNone) {
138 0 : LOG(INFO) << __FUNCTION__;
139 0 : }
140 :
141 : // ----------------------------------------------------------------------------
142 : // CheckPlatform
143 : // ----------------------------------------------------------------------------
144 :
145 0 : int32_t AudioDeviceModuleImpl::CheckPlatform() {
146 0 : LOG(INFO) << __FUNCTION__;
147 :
148 : // Ensure that the current platform is supported
149 : //
150 0 : 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 0 : platform = kPlatformLinux;
163 0 : 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 0 : if (platform == kPlatformNotSupported) {
173 0 : LOG(LERROR) << "current platform is not supported => this module will self "
174 0 : "destruct!";
175 0 : return -1;
176 : }
177 :
178 : // Store valid output results
179 : //
180 0 : _platformType = platform;
181 :
182 0 : return 0;
183 : }
184 :
185 : // ----------------------------------------------------------------------------
186 : // CreatePlatformSpecificObjects
187 : // ----------------------------------------------------------------------------
188 :
189 0 : int32_t AudioDeviceModuleImpl::CreatePlatformSpecificObjects() {
190 0 : LOG(INFO) << __FUNCTION__;
191 :
192 0 : 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 0 : 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 0 : if ((audioLayer == kLinuxPulseAudio) ||
308 : (audioLayer == kPlatformDefaultAudio)) {
309 : #if defined(LINUX_PULSE)
310 0 : LOG(INFO) << "attempting to use the Linux PulseAudio APIs...";
311 :
312 : // create *Linux PulseAudio* implementation
313 0 : AudioDeviceLinuxPulse* pulseDevice = new AudioDeviceLinuxPulse(Id());
314 0 : if (pulseDevice->Init() == AudioDeviceGeneric::InitStatus::OK) {
315 0 : ptrAudioDevice = pulseDevice;
316 0 : LOG(INFO) << "Linux PulseAudio APIs will be utilized";
317 : } else {
318 0 : 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 0 : if (audioLayer == kDummyAudio) {
367 : // Create *Dummy Audio* implementation
368 0 : assert(!ptrAudioDevice);
369 0 : ptrAudioDevice = new AudioDeviceDummy(Id());
370 0 : LOG(INFO) << "Dummy Audio APIs will be utilized";
371 : }
372 : #endif // if defined(WEBRTC_DUMMY_AUDIO_BUILD)
373 :
374 0 : if (ptrAudioDevice == NULL) {
375 0 : LOG(LERROR)
376 0 : << "unable to create the platform specific audio device implementation";
377 0 : return -1;
378 : }
379 :
380 : // Store valid output pointers
381 : //
382 0 : _ptrAudioDevice = ptrAudioDevice;
383 :
384 0 : 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 :
395 0 : int32_t AudioDeviceModuleImpl::AttachAudioBuffer() {
396 0 : LOG(INFO) << __FUNCTION__;
397 :
398 0 : _audioDeviceBuffer.SetId(_id);
399 0 : _ptrAudioDevice->AttachAudioBuffer(&_audioDeviceBuffer);
400 0 : return 0;
401 : }
402 :
403 : // ----------------------------------------------------------------------------
404 : // ~AudioDeviceModuleImpl - dtor
405 : // ----------------------------------------------------------------------------
406 :
407 0 : AudioDeviceModuleImpl::~AudioDeviceModuleImpl() {
408 0 : LOG(INFO) << __FUNCTION__;
409 :
410 0 : if (_ptrAudioDevice) {
411 0 : delete _ptrAudioDevice;
412 0 : _ptrAudioDevice = NULL;
413 : }
414 :
415 0 : delete &_critSect;
416 0 : delete &_critSectEventCb;
417 0 : delete &_critSectAudioCb;
418 0 : }
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 :
431 0 : int64_t AudioDeviceModuleImpl::TimeUntilNextProcess() {
432 0 : int64_t now = rtc::TimeMillis();
433 0 : int64_t deltaProcess = kAdmMaxIdleTimeProcess - (now - _lastProcessTime);
434 0 : 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 :
444 0 : void AudioDeviceModuleImpl::Process() {
445 0 : _lastProcessTime = rtc::TimeMillis();
446 :
447 : // kPlayoutWarning
448 0 : if (_ptrAudioDevice->PlayoutWarning()) {
449 0 : CriticalSectionScoped lock(&_critSectEventCb);
450 0 : if (_ptrCbAudioDeviceObserver) {
451 0 : LOG(WARNING) << "=> OnWarningIsReported(kPlayoutWarning)";
452 0 : _ptrCbAudioDeviceObserver->OnWarningIsReported(
453 0 : AudioDeviceObserver::kPlayoutWarning);
454 : }
455 0 : _ptrAudioDevice->ClearPlayoutWarning();
456 : }
457 :
458 : // kPlayoutError
459 0 : if (_ptrAudioDevice->PlayoutError()) {
460 0 : CriticalSectionScoped lock(&_critSectEventCb);
461 0 : if (_ptrCbAudioDeviceObserver) {
462 0 : LOG(LERROR) << "=> OnErrorIsReported(kPlayoutError)";
463 0 : _ptrCbAudioDeviceObserver->OnErrorIsReported(
464 0 : AudioDeviceObserver::kPlayoutError);
465 : }
466 0 : _ptrAudioDevice->ClearPlayoutError();
467 : }
468 :
469 : // kRecordingWarning
470 0 : if (_ptrAudioDevice->RecordingWarning()) {
471 0 : CriticalSectionScoped lock(&_critSectEventCb);
472 0 : if (_ptrCbAudioDeviceObserver) {
473 0 : LOG(WARNING) << "=> OnWarningIsReported(kRecordingWarning)";
474 0 : _ptrCbAudioDeviceObserver->OnWarningIsReported(
475 0 : AudioDeviceObserver::kRecordingWarning);
476 : }
477 0 : _ptrAudioDevice->ClearRecordingWarning();
478 : }
479 :
480 : // kRecordingError
481 0 : if (_ptrAudioDevice->RecordingError()) {
482 0 : CriticalSectionScoped lock(&_critSectEventCb);
483 0 : if (_ptrCbAudioDeviceObserver) {
484 0 : LOG(LERROR) << "=> OnErrorIsReported(kRecordingError)";
485 0 : _ptrCbAudioDeviceObserver->OnErrorIsReported(
486 0 : AudioDeviceObserver::kRecordingError);
487 : }
488 0 : _ptrAudioDevice->ClearRecordingError();
489 : }
490 0 : }
491 :
492 : // ============================================================================
493 : // Public API
494 : // ============================================================================
495 :
496 : // ----------------------------------------------------------------------------
497 : // ActiveAudioLayer
498 : // ----------------------------------------------------------------------------
499 :
500 0 : int32_t AudioDeviceModuleImpl::ActiveAudioLayer(AudioLayer* audioLayer) const {
501 0 : LOG(INFO) << __FUNCTION__;
502 : AudioLayer activeAudio;
503 0 : if (_ptrAudioDevice->ActiveAudioLayer(activeAudio) == -1) {
504 0 : return -1;
505 : }
506 0 : *audioLayer = activeAudio;
507 0 : return 0;
508 : }
509 :
510 : // ----------------------------------------------------------------------------
511 : // LastError
512 : // ----------------------------------------------------------------------------
513 :
514 0 : AudioDeviceModule::ErrorCode AudioDeviceModuleImpl::LastError() const {
515 0 : LOG(INFO) << __FUNCTION__;
516 0 : return _lastError;
517 : }
518 :
519 : // ----------------------------------------------------------------------------
520 : // Init
521 : // ----------------------------------------------------------------------------
522 :
523 0 : int32_t AudioDeviceModuleImpl::Init() {
524 0 : LOG(INFO) << __FUNCTION__;
525 0 : if (_initialized)
526 0 : return 0;
527 0 : RTC_CHECK(_ptrAudioDevice);
528 :
529 0 : AudioDeviceGeneric::InitStatus status = _ptrAudioDevice->Init();
530 0 : RTC_HISTOGRAM_ENUMERATION(
531 : "WebRTC.Audio.InitializationResult", static_cast<int>(status),
532 : static_cast<int>(AudioDeviceGeneric::InitStatus::NUM_STATUSES));
533 0 : if (status != AudioDeviceGeneric::InitStatus::OK) {
534 0 : LOG(LS_ERROR) << "Audio device initialization failed.";
535 0 : return -1;
536 : }
537 :
538 0 : _initialized = true;
539 0 : return 0;
540 : }
541 :
542 : // ----------------------------------------------------------------------------
543 : // Terminate
544 : // ----------------------------------------------------------------------------
545 :
546 0 : int32_t AudioDeviceModuleImpl::Terminate() {
547 0 : LOG(INFO) << __FUNCTION__;
548 0 : if (!_initialized)
549 0 : return 0;
550 :
551 0 : if (_ptrAudioDevice->Terminate() == -1) {
552 0 : return -1;
553 : }
554 :
555 0 : _initialized = false;
556 0 : return 0;
557 : }
558 :
559 : // ----------------------------------------------------------------------------
560 : // Initialized
561 : // ----------------------------------------------------------------------------
562 :
563 0 : bool AudioDeviceModuleImpl::Initialized() const {
564 0 : LOG(INFO) << __FUNCTION__ << ": " << _initialized;
565 0 : return (_initialized);
566 : }
567 :
568 : // ----------------------------------------------------------------------------
569 : // InitSpeaker
570 : // ----------------------------------------------------------------------------
571 :
572 0 : int32_t AudioDeviceModuleImpl::InitSpeaker() {
573 0 : LOG(INFO) << __FUNCTION__;
574 0 : CHECK_INITIALIZED();
575 0 : return (_ptrAudioDevice->InitSpeaker());
576 : }
577 :
578 : // ----------------------------------------------------------------------------
579 : // InitMicrophone
580 : // ----------------------------------------------------------------------------
581 :
582 0 : int32_t AudioDeviceModuleImpl::InitMicrophone() {
583 0 : LOG(INFO) << __FUNCTION__;
584 0 : CHECK_INITIALIZED();
585 0 : return (_ptrAudioDevice->InitMicrophone());
586 : }
587 :
588 : // ----------------------------------------------------------------------------
589 : // SpeakerVolumeIsAvailable
590 : // ----------------------------------------------------------------------------
591 :
592 0 : int32_t AudioDeviceModuleImpl::SpeakerVolumeIsAvailable(bool* available) {
593 0 : LOG(INFO) << __FUNCTION__;
594 0 : CHECK_INITIALIZED();
595 :
596 0 : bool isAvailable(0);
597 :
598 0 : if (_ptrAudioDevice->SpeakerVolumeIsAvailable(isAvailable) == -1) {
599 0 : return -1;
600 : }
601 :
602 0 : *available = isAvailable;
603 0 : LOG(INFO) << "output: " << isAvailable;
604 0 : return (0);
605 : }
606 :
607 : // ----------------------------------------------------------------------------
608 : // SetSpeakerVolume
609 : // ----------------------------------------------------------------------------
610 :
611 0 : int32_t AudioDeviceModuleImpl::SetSpeakerVolume(uint32_t volume) {
612 0 : LOG(INFO) << __FUNCTION__ << "(" << volume << ")";
613 0 : CHECK_INITIALIZED();
614 0 : return (_ptrAudioDevice->SetSpeakerVolume(volume));
615 : }
616 :
617 : // ----------------------------------------------------------------------------
618 : // SpeakerVolume
619 : // ----------------------------------------------------------------------------
620 :
621 0 : int32_t AudioDeviceModuleImpl::SpeakerVolume(uint32_t* volume) const {
622 0 : LOG(INFO) << __FUNCTION__;
623 0 : CHECK_INITIALIZED();
624 :
625 0 : uint32_t level(0);
626 :
627 0 : if (_ptrAudioDevice->SpeakerVolume(level) == -1) {
628 0 : return -1;
629 : }
630 :
631 0 : *volume = level;
632 0 : LOG(INFO) << "output: " << *volume;
633 0 : return (0);
634 : }
635 :
636 : // ----------------------------------------------------------------------------
637 : // SetWaveOutVolume
638 : // ----------------------------------------------------------------------------
639 :
640 0 : int32_t AudioDeviceModuleImpl::SetWaveOutVolume(uint16_t volumeLeft,
641 : uint16_t volumeRight) {
642 0 : LOG(INFO) << __FUNCTION__ << "(" << volumeLeft << ", " << volumeRight << ")";
643 0 : CHECK_INITIALIZED();
644 0 : return (_ptrAudioDevice->SetWaveOutVolume(volumeLeft, volumeRight));
645 : }
646 :
647 : // ----------------------------------------------------------------------------
648 : // WaveOutVolume
649 : // ----------------------------------------------------------------------------
650 :
651 0 : int32_t AudioDeviceModuleImpl::WaveOutVolume(uint16_t* volumeLeft,
652 : uint16_t* volumeRight) const {
653 0 : LOG(INFO) << __FUNCTION__;
654 0 : CHECK_INITIALIZED();
655 :
656 0 : uint16_t volLeft(0);
657 0 : uint16_t volRight(0);
658 :
659 0 : if (_ptrAudioDevice->WaveOutVolume(volLeft, volRight) == -1) {
660 0 : return -1;
661 : }
662 :
663 0 : *volumeLeft = volLeft;
664 0 : *volumeRight = volRight;
665 0 : LOG(INFO) << "output: " << *volumeLeft << ", " << *volumeRight;
666 :
667 0 : return (0);
668 : }
669 :
670 : // ----------------------------------------------------------------------------
671 : // SpeakerIsInitialized
672 : // ----------------------------------------------------------------------------
673 :
674 0 : bool AudioDeviceModuleImpl::SpeakerIsInitialized() const {
675 0 : LOG(INFO) << __FUNCTION__;
676 0 : CHECK_INITIALIZED_BOOL();
677 :
678 0 : bool isInitialized = _ptrAudioDevice->SpeakerIsInitialized();
679 0 : LOG(INFO) << "output: " << isInitialized;
680 0 : return (isInitialized);
681 : }
682 :
683 : // ----------------------------------------------------------------------------
684 : // MicrophoneIsInitialized
685 : // ----------------------------------------------------------------------------
686 :
687 0 : bool AudioDeviceModuleImpl::MicrophoneIsInitialized() const {
688 0 : LOG(INFO) << __FUNCTION__;
689 0 : CHECK_INITIALIZED_BOOL();
690 :
691 0 : bool isInitialized = _ptrAudioDevice->MicrophoneIsInitialized();
692 0 : LOG(INFO) << "output: " << isInitialized;
693 0 : return (isInitialized);
694 : }
695 :
696 : // ----------------------------------------------------------------------------
697 : // MaxSpeakerVolume
698 : // ----------------------------------------------------------------------------
699 :
700 0 : int32_t AudioDeviceModuleImpl::MaxSpeakerVolume(uint32_t* maxVolume) const {
701 0 : CHECK_INITIALIZED();
702 :
703 0 : uint32_t maxVol(0);
704 :
705 0 : if (_ptrAudioDevice->MaxSpeakerVolume(maxVol) == -1) {
706 0 : return -1;
707 : }
708 :
709 0 : *maxVolume = maxVol;
710 0 : return (0);
711 : }
712 :
713 : // ----------------------------------------------------------------------------
714 : // MinSpeakerVolume
715 : // ----------------------------------------------------------------------------
716 :
717 0 : int32_t AudioDeviceModuleImpl::MinSpeakerVolume(uint32_t* minVolume) const {
718 0 : CHECK_INITIALIZED();
719 :
720 0 : uint32_t minVol(0);
721 :
722 0 : if (_ptrAudioDevice->MinSpeakerVolume(minVol) == -1) {
723 0 : return -1;
724 : }
725 :
726 0 : *minVolume = minVol;
727 0 : return (0);
728 : }
729 :
730 : // ----------------------------------------------------------------------------
731 : // SpeakerVolumeStepSize
732 : // ----------------------------------------------------------------------------
733 :
734 0 : int32_t AudioDeviceModuleImpl::SpeakerVolumeStepSize(uint16_t* stepSize) const {
735 0 : LOG(INFO) << __FUNCTION__;
736 0 : CHECK_INITIALIZED();
737 :
738 0 : uint16_t delta(0);
739 :
740 0 : if (_ptrAudioDevice->SpeakerVolumeStepSize(delta) == -1) {
741 0 : LOG(LERROR) << "failed to retrieve the speaker-volume step size";
742 0 : return -1;
743 : }
744 :
745 0 : *stepSize = delta;
746 0 : LOG(INFO) << "output: " << *stepSize;
747 0 : return (0);
748 : }
749 :
750 : // ----------------------------------------------------------------------------
751 : // SpeakerMuteIsAvailable
752 : // ----------------------------------------------------------------------------
753 :
754 0 : int32_t AudioDeviceModuleImpl::SpeakerMuteIsAvailable(bool* available) {
755 0 : LOG(INFO) << __FUNCTION__;
756 0 : CHECK_INITIALIZED();
757 :
758 0 : bool isAvailable(0);
759 :
760 0 : if (_ptrAudioDevice->SpeakerMuteIsAvailable(isAvailable) == -1) {
761 0 : return -1;
762 : }
763 :
764 0 : *available = isAvailable;
765 0 : LOG(INFO) << "output: " << isAvailable;
766 0 : return (0);
767 : }
768 :
769 : // ----------------------------------------------------------------------------
770 : // SetSpeakerMute
771 : // ----------------------------------------------------------------------------
772 :
773 0 : int32_t AudioDeviceModuleImpl::SetSpeakerMute(bool enable) {
774 0 : LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
775 0 : CHECK_INITIALIZED();
776 0 : return (_ptrAudioDevice->SetSpeakerMute(enable));
777 : }
778 :
779 : // ----------------------------------------------------------------------------
780 : // SpeakerMute
781 : // ----------------------------------------------------------------------------
782 :
783 0 : int32_t AudioDeviceModuleImpl::SpeakerMute(bool* enabled) const {
784 0 : LOG(INFO) << __FUNCTION__;
785 0 : CHECK_INITIALIZED();
786 :
787 0 : bool muted(false);
788 :
789 0 : if (_ptrAudioDevice->SpeakerMute(muted) == -1) {
790 0 : return -1;
791 : }
792 :
793 0 : *enabled = muted;
794 0 : LOG(INFO) << "output: " << muted;
795 0 : return (0);
796 : }
797 :
798 : // ----------------------------------------------------------------------------
799 : // MicrophoneMuteIsAvailable
800 : // ----------------------------------------------------------------------------
801 :
802 0 : int32_t AudioDeviceModuleImpl::MicrophoneMuteIsAvailable(bool* available) {
803 0 : LOG(INFO) << __FUNCTION__;
804 0 : CHECK_INITIALIZED();
805 :
806 0 : bool isAvailable(0);
807 :
808 0 : if (_ptrAudioDevice->MicrophoneMuteIsAvailable(isAvailable) == -1) {
809 0 : return -1;
810 : }
811 :
812 0 : *available = isAvailable;
813 0 : LOG(INFO) << "output: " << isAvailable;
814 0 : return (0);
815 : }
816 :
817 : // ----------------------------------------------------------------------------
818 : // SetMicrophoneMute
819 : // ----------------------------------------------------------------------------
820 :
821 0 : int32_t AudioDeviceModuleImpl::SetMicrophoneMute(bool enable) {
822 0 : LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
823 0 : CHECK_INITIALIZED();
824 0 : return (_ptrAudioDevice->SetMicrophoneMute(enable));
825 : }
826 :
827 : // ----------------------------------------------------------------------------
828 : // MicrophoneMute
829 : // ----------------------------------------------------------------------------
830 :
831 0 : int32_t AudioDeviceModuleImpl::MicrophoneMute(bool* enabled) const {
832 0 : LOG(INFO) << __FUNCTION__;
833 0 : CHECK_INITIALIZED();
834 :
835 0 : bool muted(false);
836 :
837 0 : if (_ptrAudioDevice->MicrophoneMute(muted) == -1) {
838 0 : return -1;
839 : }
840 :
841 0 : *enabled = muted;
842 0 : LOG(INFO) << "output: " << muted;
843 0 : return (0);
844 : }
845 :
846 : // ----------------------------------------------------------------------------
847 : // MicrophoneBoostIsAvailable
848 : // ----------------------------------------------------------------------------
849 :
850 0 : int32_t AudioDeviceModuleImpl::MicrophoneBoostIsAvailable(bool* available) {
851 0 : LOG(INFO) << __FUNCTION__;
852 0 : CHECK_INITIALIZED();
853 :
854 0 : bool isAvailable(0);
855 :
856 0 : if (_ptrAudioDevice->MicrophoneBoostIsAvailable(isAvailable) == -1) {
857 0 : return -1;
858 : }
859 :
860 0 : *available = isAvailable;
861 0 : LOG(INFO) << "output: " << isAvailable;
862 0 : return (0);
863 : }
864 :
865 : // ----------------------------------------------------------------------------
866 : // SetMicrophoneBoost
867 : // ----------------------------------------------------------------------------
868 :
869 0 : int32_t AudioDeviceModuleImpl::SetMicrophoneBoost(bool enable) {
870 0 : LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
871 0 : CHECK_INITIALIZED();
872 0 : return (_ptrAudioDevice->SetMicrophoneBoost(enable));
873 : }
874 :
875 : // ----------------------------------------------------------------------------
876 : // MicrophoneBoost
877 : // ----------------------------------------------------------------------------
878 :
879 0 : int32_t AudioDeviceModuleImpl::MicrophoneBoost(bool* enabled) const {
880 0 : LOG(INFO) << __FUNCTION__;
881 0 : CHECK_INITIALIZED();
882 :
883 0 : bool onOff(false);
884 :
885 0 : if (_ptrAudioDevice->MicrophoneBoost(onOff) == -1) {
886 0 : return -1;
887 : }
888 :
889 0 : *enabled = onOff;
890 0 : LOG(INFO) << "output: " << onOff;
891 0 : return (0);
892 : }
893 :
894 : // ----------------------------------------------------------------------------
895 : // MicrophoneVolumeIsAvailable
896 : // ----------------------------------------------------------------------------
897 :
898 0 : int32_t AudioDeviceModuleImpl::MicrophoneVolumeIsAvailable(bool* available) {
899 0 : LOG(INFO) << __FUNCTION__;
900 0 : CHECK_INITIALIZED();
901 :
902 0 : bool isAvailable(0);
903 :
904 0 : if (_ptrAudioDevice->MicrophoneVolumeIsAvailable(isAvailable) == -1) {
905 0 : return -1;
906 : }
907 :
908 0 : *available = isAvailable;
909 0 : LOG(INFO) << "output: " << isAvailable;
910 0 : return (0);
911 : }
912 :
913 : // ----------------------------------------------------------------------------
914 : // SetMicrophoneVolume
915 : // ----------------------------------------------------------------------------
916 :
917 0 : int32_t AudioDeviceModuleImpl::SetMicrophoneVolume(uint32_t volume) {
918 0 : LOG(INFO) << __FUNCTION__ << "(" << volume << ")";
919 0 : CHECK_INITIALIZED();
920 0 : return (_ptrAudioDevice->SetMicrophoneVolume(volume));
921 : }
922 :
923 : // ----------------------------------------------------------------------------
924 : // MicrophoneVolume
925 : // ----------------------------------------------------------------------------
926 :
927 0 : int32_t AudioDeviceModuleImpl::MicrophoneVolume(uint32_t* volume) const {
928 0 : LOG(INFO) << __FUNCTION__;
929 0 : CHECK_INITIALIZED();
930 :
931 0 : uint32_t level(0);
932 :
933 0 : if (_ptrAudioDevice->MicrophoneVolume(level) == -1) {
934 0 : return -1;
935 : }
936 :
937 0 : *volume = level;
938 0 : LOG(INFO) << "output: " << *volume;
939 0 : return (0);
940 : }
941 :
942 : // ----------------------------------------------------------------------------
943 : // StereoRecordingIsAvailable
944 : // ----------------------------------------------------------------------------
945 :
946 0 : int32_t AudioDeviceModuleImpl::StereoRecordingIsAvailable(
947 : bool* available) const {
948 0 : LOG(INFO) << __FUNCTION__;
949 0 : CHECK_INITIALIZED();
950 :
951 0 : bool isAvailable(0);
952 :
953 0 : if (_ptrAudioDevice->StereoRecordingIsAvailable(isAvailable) == -1) {
954 0 : return -1;
955 : }
956 :
957 0 : *available = isAvailable;
958 0 : LOG(INFO) << "output: " << isAvailable;
959 0 : return (0);
960 : }
961 :
962 : // ----------------------------------------------------------------------------
963 : // SetStereoRecording
964 : // ----------------------------------------------------------------------------
965 :
966 0 : int32_t AudioDeviceModuleImpl::SetStereoRecording(bool enable) {
967 0 : LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
968 0 : CHECK_INITIALIZED();
969 :
970 0 : if (_ptrAudioDevice->RecordingIsInitialized()) {
971 0 : LOG(WARNING) << "recording in stereo is not supported";
972 0 : return -1;
973 : }
974 :
975 0 : if (_ptrAudioDevice->SetStereoRecording(enable) == -1) {
976 0 : LOG(WARNING) << "failed to change stereo recording";
977 0 : return -1;
978 : }
979 :
980 0 : int8_t nChannels(1);
981 0 : if (enable) {
982 0 : nChannels = 2;
983 : }
984 0 : _audioDeviceBuffer.SetRecordingChannels(nChannels);
985 :
986 0 : return 0;
987 : }
988 :
989 : // ----------------------------------------------------------------------------
990 : // StereoRecording
991 : // ----------------------------------------------------------------------------
992 :
993 0 : int32_t AudioDeviceModuleImpl::StereoRecording(bool* enabled) const {
994 0 : LOG(INFO) << __FUNCTION__;
995 0 : CHECK_INITIALIZED();
996 :
997 0 : bool stereo(false);
998 :
999 0 : if (_ptrAudioDevice->StereoRecording(stereo) == -1) {
1000 0 : return -1;
1001 : }
1002 :
1003 0 : *enabled = stereo;
1004 0 : LOG(INFO) << "output: " << stereo;
1005 0 : return (0);
1006 : }
1007 :
1008 : // ----------------------------------------------------------------------------
1009 : // SetRecordingChannel
1010 : // ----------------------------------------------------------------------------
1011 :
1012 0 : int32_t AudioDeviceModuleImpl::SetRecordingChannel(const ChannelType channel) {
1013 0 : if (channel == kChannelBoth) {
1014 0 : LOG(INFO) << __FUNCTION__ << "(both)";
1015 0 : } else if (channel == kChannelLeft) {
1016 0 : LOG(INFO) << __FUNCTION__ << "(left)";
1017 : } else {
1018 0 : LOG(INFO) << __FUNCTION__ << "(right)";
1019 : }
1020 0 : CHECK_INITIALIZED();
1021 :
1022 0 : bool stereo(false);
1023 :
1024 0 : if (_ptrAudioDevice->StereoRecording(stereo) == -1) {
1025 0 : LOG(WARNING) << "recording in stereo is not supported";
1026 0 : return -1;
1027 : }
1028 :
1029 0 : return (_audioDeviceBuffer.SetRecordingChannel(channel));
1030 : }
1031 :
1032 : // ----------------------------------------------------------------------------
1033 : // RecordingChannel
1034 : // ----------------------------------------------------------------------------
1035 :
1036 0 : int32_t AudioDeviceModuleImpl::RecordingChannel(ChannelType* channel) const {
1037 0 : LOG(INFO) << __FUNCTION__;
1038 0 : CHECK_INITIALIZED();
1039 :
1040 : ChannelType chType;
1041 :
1042 0 : if (_audioDeviceBuffer.RecordingChannel(chType) == -1) {
1043 0 : return -1;
1044 : }
1045 :
1046 0 : *channel = chType;
1047 0 : if (*channel == kChannelBoth) {
1048 0 : LOG(INFO) << "output: both";
1049 0 : } else if (*channel == kChannelLeft) {
1050 0 : LOG(INFO) << "output: left";
1051 : } else {
1052 0 : LOG(INFO) << "output: right";
1053 : }
1054 0 : return (0);
1055 : }
1056 :
1057 : // ----------------------------------------------------------------------------
1058 : // StereoPlayoutIsAvailable
1059 : // ----------------------------------------------------------------------------
1060 :
1061 0 : int32_t AudioDeviceModuleImpl::StereoPlayoutIsAvailable(bool* available) const {
1062 0 : LOG(INFO) << __FUNCTION__;
1063 0 : CHECK_INITIALIZED();
1064 :
1065 0 : bool isAvailable(0);
1066 :
1067 0 : if (_ptrAudioDevice->StereoPlayoutIsAvailable(isAvailable) == -1) {
1068 0 : return -1;
1069 : }
1070 :
1071 0 : *available = isAvailable;
1072 0 : LOG(INFO) << "output: " << isAvailable;
1073 0 : return (0);
1074 : }
1075 :
1076 : // ----------------------------------------------------------------------------
1077 : // SetStereoPlayout
1078 : // ----------------------------------------------------------------------------
1079 :
1080 0 : int32_t AudioDeviceModuleImpl::SetStereoPlayout(bool enable) {
1081 0 : LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
1082 0 : CHECK_INITIALIZED();
1083 :
1084 0 : if (_ptrAudioDevice->PlayoutIsInitialized()) {
1085 0 : LOG(LERROR)
1086 0 : << "unable to set stereo mode while playing side is initialized";
1087 0 : return -1;
1088 : }
1089 :
1090 0 : if (_ptrAudioDevice->SetStereoPlayout(enable)) {
1091 0 : LOG(WARNING) << "stereo playout is not supported";
1092 0 : return -1;
1093 : }
1094 :
1095 0 : int8_t nChannels(1);
1096 0 : if (enable) {
1097 0 : nChannels = 2;
1098 : }
1099 0 : _audioDeviceBuffer.SetPlayoutChannels(nChannels);
1100 :
1101 0 : return 0;
1102 : }
1103 :
1104 : // ----------------------------------------------------------------------------
1105 : // StereoPlayout
1106 : // ----------------------------------------------------------------------------
1107 :
1108 0 : int32_t AudioDeviceModuleImpl::StereoPlayout(bool* enabled) const {
1109 0 : LOG(INFO) << __FUNCTION__;
1110 0 : CHECK_INITIALIZED();
1111 :
1112 0 : bool stereo(false);
1113 :
1114 0 : if (_ptrAudioDevice->StereoPlayout(stereo) == -1) {
1115 0 : return -1;
1116 : }
1117 :
1118 0 : *enabled = stereo;
1119 0 : LOG(INFO) << "output: " << stereo;
1120 0 : return (0);
1121 : }
1122 :
1123 : // ----------------------------------------------------------------------------
1124 : // SetAGC
1125 : // ----------------------------------------------------------------------------
1126 :
1127 0 : int32_t AudioDeviceModuleImpl::SetAGC(bool enable) {
1128 0 : LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
1129 0 : CHECK_INITIALIZED();
1130 0 : return (_ptrAudioDevice->SetAGC(enable));
1131 : }
1132 :
1133 : // ----------------------------------------------------------------------------
1134 : // AGC
1135 : // ----------------------------------------------------------------------------
1136 :
1137 0 : bool AudioDeviceModuleImpl::AGC() const {
1138 0 : LOG(INFO) << __FUNCTION__;
1139 0 : CHECK_INITIALIZED_BOOL();
1140 0 : return (_ptrAudioDevice->AGC());
1141 : }
1142 :
1143 : // ----------------------------------------------------------------------------
1144 : // PlayoutIsAvailable
1145 : // ----------------------------------------------------------------------------
1146 :
1147 0 : int32_t AudioDeviceModuleImpl::PlayoutIsAvailable(bool* available) {
1148 0 : LOG(INFO) << __FUNCTION__;
1149 0 : CHECK_INITIALIZED();
1150 :
1151 0 : bool isAvailable(0);
1152 :
1153 0 : if (_ptrAudioDevice->PlayoutIsAvailable(isAvailable) == -1) {
1154 0 : return -1;
1155 : }
1156 :
1157 0 : *available = isAvailable;
1158 0 : LOG(INFO) << "output: " << isAvailable;
1159 0 : return (0);
1160 : }
1161 :
1162 : // ----------------------------------------------------------------------------
1163 : // RecordingIsAvailable
1164 : // ----------------------------------------------------------------------------
1165 :
1166 0 : int32_t AudioDeviceModuleImpl::RecordingIsAvailable(bool* available) {
1167 0 : LOG(INFO) << __FUNCTION__;
1168 0 : CHECK_INITIALIZED();
1169 :
1170 0 : bool isAvailable(0);
1171 :
1172 0 : if (_ptrAudioDevice->RecordingIsAvailable(isAvailable) == -1) {
1173 0 : return -1;
1174 : }
1175 :
1176 0 : *available = isAvailable;
1177 0 : LOG(INFO) << "output: " << isAvailable;
1178 0 : return (0);
1179 : }
1180 :
1181 : // ----------------------------------------------------------------------------
1182 : // MaxMicrophoneVolume
1183 : // ----------------------------------------------------------------------------
1184 :
1185 0 : int32_t AudioDeviceModuleImpl::MaxMicrophoneVolume(uint32_t* maxVolume) const {
1186 0 : CHECK_INITIALIZED();
1187 :
1188 0 : uint32_t maxVol(0);
1189 :
1190 0 : if (_ptrAudioDevice->MaxMicrophoneVolume(maxVol) == -1) {
1191 0 : return -1;
1192 : }
1193 :
1194 0 : *maxVolume = maxVol;
1195 0 : return (0);
1196 : }
1197 :
1198 : // ----------------------------------------------------------------------------
1199 : // MinMicrophoneVolume
1200 : // ----------------------------------------------------------------------------
1201 :
1202 0 : int32_t AudioDeviceModuleImpl::MinMicrophoneVolume(uint32_t* minVolume) const {
1203 0 : CHECK_INITIALIZED();
1204 :
1205 0 : uint32_t minVol(0);
1206 :
1207 0 : if (_ptrAudioDevice->MinMicrophoneVolume(minVol) == -1) {
1208 0 : return -1;
1209 : }
1210 :
1211 0 : *minVolume = minVol;
1212 0 : return (0);
1213 : }
1214 :
1215 : // ----------------------------------------------------------------------------
1216 : // MicrophoneVolumeStepSize
1217 : // ----------------------------------------------------------------------------
1218 :
1219 0 : int32_t AudioDeviceModuleImpl::MicrophoneVolumeStepSize(
1220 : uint16_t* stepSize) const {
1221 0 : LOG(INFO) << __FUNCTION__;
1222 0 : CHECK_INITIALIZED();
1223 :
1224 0 : uint16_t delta(0);
1225 :
1226 0 : if (_ptrAudioDevice->MicrophoneVolumeStepSize(delta) == -1) {
1227 0 : return -1;
1228 : }
1229 :
1230 0 : *stepSize = delta;
1231 0 : LOG(INFO) << "output: " << *stepSize;
1232 0 : return (0);
1233 : }
1234 :
1235 : // ----------------------------------------------------------------------------
1236 : // PlayoutDevices
1237 : // ----------------------------------------------------------------------------
1238 :
1239 0 : int16_t AudioDeviceModuleImpl::PlayoutDevices() {
1240 0 : LOG(INFO) << __FUNCTION__;
1241 0 : CHECK_INITIALIZED();
1242 :
1243 0 : uint16_t nPlayoutDevices = _ptrAudioDevice->PlayoutDevices();
1244 0 : LOG(INFO) << "output: " << nPlayoutDevices;
1245 0 : return ((int16_t)(nPlayoutDevices));
1246 : }
1247 :
1248 : // ----------------------------------------------------------------------------
1249 : // SetPlayoutDevice I (II)
1250 : // ----------------------------------------------------------------------------
1251 :
1252 0 : int32_t AudioDeviceModuleImpl::SetPlayoutDevice(uint16_t index) {
1253 0 : LOG(INFO) << __FUNCTION__ << "(" << index << ")";
1254 0 : CHECK_INITIALIZED();
1255 0 : return (_ptrAudioDevice->SetPlayoutDevice(index));
1256 : }
1257 :
1258 : // ----------------------------------------------------------------------------
1259 : // SetPlayoutDevice II (II)
1260 : // ----------------------------------------------------------------------------
1261 :
1262 0 : int32_t AudioDeviceModuleImpl::SetPlayoutDevice(WindowsDeviceType device) {
1263 0 : LOG(INFO) << __FUNCTION__;
1264 0 : CHECK_INITIALIZED();
1265 :
1266 0 : return (_ptrAudioDevice->SetPlayoutDevice(device));
1267 : }
1268 :
1269 : // ----------------------------------------------------------------------------
1270 : // PlayoutDeviceName
1271 : // ----------------------------------------------------------------------------
1272 :
1273 0 : int32_t AudioDeviceModuleImpl::PlayoutDeviceName(
1274 : uint16_t index,
1275 : char name[kAdmMaxDeviceNameSize],
1276 : char guid[kAdmMaxGuidSize]) {
1277 0 : LOG(INFO) << __FUNCTION__ << "(" << index << ", ...)";
1278 0 : CHECK_INITIALIZED();
1279 :
1280 0 : if (name == NULL) {
1281 0 : _lastError = kAdmErrArgument;
1282 0 : return -1;
1283 : }
1284 :
1285 0 : if (_ptrAudioDevice->PlayoutDeviceName(index, name, guid) == -1) {
1286 0 : return -1;
1287 : }
1288 :
1289 0 : if (name != NULL) {
1290 0 : LOG(INFO) << "output: name = " << name;
1291 : }
1292 0 : if (guid != NULL) {
1293 0 : LOG(INFO) << "output: guid = " << guid;
1294 : }
1295 :
1296 0 : return (0);
1297 : }
1298 :
1299 : // ----------------------------------------------------------------------------
1300 : // RecordingDeviceName
1301 : // ----------------------------------------------------------------------------
1302 :
1303 0 : int32_t AudioDeviceModuleImpl::RecordingDeviceName(
1304 : uint16_t index,
1305 : char name[kAdmMaxDeviceNameSize],
1306 : char guid[kAdmMaxGuidSize]) {
1307 0 : LOG(INFO) << __FUNCTION__ << "(" << index << ", ...)";
1308 0 : CHECK_INITIALIZED();
1309 :
1310 0 : if (name == NULL) {
1311 0 : _lastError = kAdmErrArgument;
1312 0 : return -1;
1313 : }
1314 :
1315 0 : if (_ptrAudioDevice->RecordingDeviceName(index, name, guid) == -1) {
1316 0 : return -1;
1317 : }
1318 :
1319 0 : if (name != NULL) {
1320 0 : LOG(INFO) << "output: name = " << name;
1321 : }
1322 0 : if (guid != NULL) {
1323 0 : LOG(INFO) << "output: guid = " << guid;
1324 : }
1325 :
1326 0 : return (0);
1327 : }
1328 :
1329 : // ----------------------------------------------------------------------------
1330 : // RecordingDevices
1331 : // ----------------------------------------------------------------------------
1332 :
1333 0 : int16_t AudioDeviceModuleImpl::RecordingDevices() {
1334 0 : LOG(INFO) << __FUNCTION__;
1335 0 : CHECK_INITIALIZED();
1336 :
1337 0 : uint16_t nRecordingDevices = _ptrAudioDevice->RecordingDevices();
1338 :
1339 0 : LOG(INFO) << "output: " << nRecordingDevices;
1340 0 : return ((int16_t)nRecordingDevices);
1341 : }
1342 :
1343 : // ----------------------------------------------------------------------------
1344 : // SetRecordingDevice I (II)
1345 : // ----------------------------------------------------------------------------
1346 :
1347 0 : int32_t AudioDeviceModuleImpl::SetRecordingDevice(uint16_t index) {
1348 0 : LOG(INFO) << __FUNCTION__ << "(" << index << ")";
1349 0 : CHECK_INITIALIZED();
1350 0 : return (_ptrAudioDevice->SetRecordingDevice(index));
1351 : }
1352 :
1353 : // ----------------------------------------------------------------------------
1354 : // SetRecordingDevice II (II)
1355 : // ----------------------------------------------------------------------------
1356 :
1357 0 : int32_t AudioDeviceModuleImpl::SetRecordingDevice(WindowsDeviceType device) {
1358 0 : LOG(INFO) << __FUNCTION__;
1359 0 : CHECK_INITIALIZED();
1360 :
1361 0 : return (_ptrAudioDevice->SetRecordingDevice(device));
1362 : }
1363 :
1364 : // ----------------------------------------------------------------------------
1365 : // InitPlayout
1366 : // ----------------------------------------------------------------------------
1367 :
1368 0 : int32_t AudioDeviceModuleImpl::InitPlayout() {
1369 0 : LOG(INFO) << __FUNCTION__;
1370 0 : CHECK_INITIALIZED();
1371 0 : if (PlayoutIsInitialized()) {
1372 0 : return 0;
1373 : }
1374 0 : int32_t result = _ptrAudioDevice->InitPlayout();
1375 0 : LOG(INFO) << "output: " << result;
1376 0 : RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.InitPlayoutSuccess",
1377 : static_cast<int>(result == 0));
1378 0 : return result;
1379 : }
1380 :
1381 : // ----------------------------------------------------------------------------
1382 : // InitRecording
1383 : // ----------------------------------------------------------------------------
1384 :
1385 0 : int32_t AudioDeviceModuleImpl::InitRecording() {
1386 0 : LOG(INFO) << __FUNCTION__;
1387 0 : CHECK_INITIALIZED();
1388 0 : if (RecordingIsInitialized()) {
1389 0 : return 0;
1390 : }
1391 0 : int32_t result = _ptrAudioDevice->InitRecording();
1392 0 : LOG(INFO) << "output: " << result;
1393 0 : RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.InitRecordingSuccess",
1394 : static_cast<int>(result == 0));
1395 0 : return result;
1396 : }
1397 :
1398 : // ----------------------------------------------------------------------------
1399 : // PlayoutIsInitialized
1400 : // ----------------------------------------------------------------------------
1401 :
1402 0 : bool AudioDeviceModuleImpl::PlayoutIsInitialized() const {
1403 0 : LOG(INFO) << __FUNCTION__;
1404 0 : CHECK_INITIALIZED_BOOL();
1405 0 : return (_ptrAudioDevice->PlayoutIsInitialized());
1406 : }
1407 :
1408 : // ----------------------------------------------------------------------------
1409 : // RecordingIsInitialized
1410 : // ----------------------------------------------------------------------------
1411 :
1412 0 : bool AudioDeviceModuleImpl::RecordingIsInitialized() const {
1413 0 : LOG(INFO) << __FUNCTION__;
1414 0 : CHECK_INITIALIZED_BOOL();
1415 0 : return (_ptrAudioDevice->RecordingIsInitialized());
1416 : }
1417 :
1418 : // ----------------------------------------------------------------------------
1419 : // StartPlayout
1420 : // ----------------------------------------------------------------------------
1421 :
1422 0 : int32_t AudioDeviceModuleImpl::StartPlayout() {
1423 0 : LOG(INFO) << __FUNCTION__;
1424 0 : CHECK_INITIALIZED();
1425 0 : if (Playing()) {
1426 0 : return 0;
1427 : }
1428 0 : _audioDeviceBuffer.StartPlayout();
1429 0 : int32_t result = _ptrAudioDevice->StartPlayout();
1430 0 : LOG(INFO) << "output: " << result;
1431 0 : RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StartPlayoutSuccess",
1432 : static_cast<int>(result == 0));
1433 0 : return result;
1434 : }
1435 :
1436 : // ----------------------------------------------------------------------------
1437 : // StopPlayout
1438 : // ----------------------------------------------------------------------------
1439 :
1440 0 : int32_t AudioDeviceModuleImpl::StopPlayout() {
1441 0 : LOG(INFO) << __FUNCTION__;
1442 0 : CHECK_INITIALIZED();
1443 0 : int32_t result = _ptrAudioDevice->StopPlayout();
1444 0 : _audioDeviceBuffer.StopPlayout();
1445 0 : LOG(INFO) << "output: " << result;
1446 0 : RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StopPlayoutSuccess",
1447 : static_cast<int>(result == 0));
1448 0 : return result;
1449 : }
1450 :
1451 : // ----------------------------------------------------------------------------
1452 : // Playing
1453 : // ----------------------------------------------------------------------------
1454 :
1455 0 : bool AudioDeviceModuleImpl::Playing() const {
1456 0 : LOG(INFO) << __FUNCTION__;
1457 0 : CHECK_INITIALIZED_BOOL();
1458 0 : return (_ptrAudioDevice->Playing());
1459 : }
1460 :
1461 : // ----------------------------------------------------------------------------
1462 : // StartRecording
1463 : // ----------------------------------------------------------------------------
1464 :
1465 0 : int32_t AudioDeviceModuleImpl::StartRecording() {
1466 0 : LOG(INFO) << __FUNCTION__;
1467 0 : CHECK_INITIALIZED();
1468 0 : if (Recording()) {
1469 0 : return 0;
1470 : }
1471 0 : _audioDeviceBuffer.StartRecording();
1472 0 : int32_t result = _ptrAudioDevice->StartRecording();
1473 0 : LOG(INFO) << "output: " << result;
1474 0 : RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StartRecordingSuccess",
1475 : static_cast<int>(result == 0));
1476 0 : return result;
1477 : }
1478 : // ----------------------------------------------------------------------------
1479 : // StopRecording
1480 : // ----------------------------------------------------------------------------
1481 :
1482 0 : int32_t AudioDeviceModuleImpl::StopRecording() {
1483 0 : LOG(INFO) << __FUNCTION__;
1484 0 : CHECK_INITIALIZED();
1485 0 : int32_t result = _ptrAudioDevice->StopRecording();
1486 0 : _audioDeviceBuffer.StopRecording();
1487 0 : LOG(INFO) << "output: " << result;
1488 0 : RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StopRecordingSuccess",
1489 : static_cast<int>(result == 0));
1490 0 : return result;
1491 : }
1492 :
1493 : // ----------------------------------------------------------------------------
1494 : // Recording
1495 : // ----------------------------------------------------------------------------
1496 :
1497 0 : bool AudioDeviceModuleImpl::Recording() const {
1498 0 : LOG(INFO) << __FUNCTION__;
1499 0 : CHECK_INITIALIZED_BOOL();
1500 0 : return (_ptrAudioDevice->Recording());
1501 : }
1502 :
1503 : // ----------------------------------------------------------------------------
1504 : // RegisterEventObserver
1505 : // ----------------------------------------------------------------------------
1506 :
1507 0 : int32_t AudioDeviceModuleImpl::RegisterEventObserver(
1508 : AudioDeviceObserver* eventCallback) {
1509 0 : LOG(INFO) << __FUNCTION__;
1510 0 : CriticalSectionScoped lock(&_critSectEventCb);
1511 0 : _ptrCbAudioDeviceObserver = eventCallback;
1512 :
1513 0 : return 0;
1514 : }
1515 :
1516 : // ----------------------------------------------------------------------------
1517 : // RegisterAudioCallback
1518 : // ----------------------------------------------------------------------------
1519 :
1520 0 : int32_t AudioDeviceModuleImpl::RegisterAudioCallback(
1521 : AudioTransport* audioCallback) {
1522 0 : LOG(INFO) << __FUNCTION__;
1523 0 : CriticalSectionScoped lock(&_critSectAudioCb);
1524 0 : return _audioDeviceBuffer.RegisterAudioCallback(audioCallback);
1525 : }
1526 :
1527 : // ----------------------------------------------------------------------------
1528 : // StartRawInputFileRecording
1529 : // ----------------------------------------------------------------------------
1530 :
1531 0 : int32_t AudioDeviceModuleImpl::StartRawInputFileRecording(
1532 : const char pcmFileNameUTF8[kAdmMaxFileNameSize]) {
1533 0 : LOG(INFO) << __FUNCTION__;
1534 0 : CHECK_INITIALIZED();
1535 :
1536 0 : if (NULL == pcmFileNameUTF8) {
1537 0 : return -1;
1538 : }
1539 :
1540 0 : return (_audioDeviceBuffer.StartInputFileRecording(pcmFileNameUTF8));
1541 : }
1542 :
1543 : // ----------------------------------------------------------------------------
1544 : // StopRawInputFileRecording
1545 : // ----------------------------------------------------------------------------
1546 :
1547 0 : int32_t AudioDeviceModuleImpl::StopRawInputFileRecording() {
1548 0 : LOG(INFO) << __FUNCTION__;
1549 0 : CHECK_INITIALIZED();
1550 :
1551 0 : return (_audioDeviceBuffer.StopInputFileRecording());
1552 : }
1553 :
1554 : // ----------------------------------------------------------------------------
1555 : // StartRawOutputFileRecording
1556 : // ----------------------------------------------------------------------------
1557 :
1558 0 : int32_t AudioDeviceModuleImpl::StartRawOutputFileRecording(
1559 : const char pcmFileNameUTF8[kAdmMaxFileNameSize]) {
1560 0 : LOG(INFO) << __FUNCTION__;
1561 0 : CHECK_INITIALIZED();
1562 :
1563 0 : if (NULL == pcmFileNameUTF8) {
1564 0 : return -1;
1565 : }
1566 :
1567 0 : return (_audioDeviceBuffer.StartOutputFileRecording(pcmFileNameUTF8));
1568 : }
1569 :
1570 : // ----------------------------------------------------------------------------
1571 : // StopRawOutputFileRecording
1572 : // ----------------------------------------------------------------------------
1573 :
1574 0 : int32_t AudioDeviceModuleImpl::StopRawOutputFileRecording() {
1575 0 : LOG(INFO) << __FUNCTION__;
1576 0 : CHECK_INITIALIZED();
1577 :
1578 0 : return (_audioDeviceBuffer.StopOutputFileRecording());
1579 : }
1580 :
1581 : // ----------------------------------------------------------------------------
1582 : // SetPlayoutBuffer
1583 : // ----------------------------------------------------------------------------
1584 :
1585 0 : int32_t AudioDeviceModuleImpl::SetPlayoutBuffer(const BufferType type,
1586 : uint16_t sizeMS) {
1587 0 : if (type == kFixedBufferSize) {
1588 0 : LOG(INFO) << __FUNCTION__ << "(fixed buffer, " << sizeMS << "ms)";
1589 0 : } else if (type == kAdaptiveBufferSize) {
1590 0 : LOG(INFO) << __FUNCTION__ << "(adaptive buffer, " << sizeMS << "ms)";
1591 : } else {
1592 0 : LOG(INFO) << __FUNCTION__ << "(?, " << sizeMS << "ms)";
1593 : }
1594 0 : CHECK_INITIALIZED();
1595 :
1596 0 : if (_ptrAudioDevice->PlayoutIsInitialized()) {
1597 0 : LOG(LERROR) << "unable to modify the playout buffer while playing side is "
1598 0 : "initialized";
1599 0 : return -1;
1600 : }
1601 :
1602 0 : int32_t ret(0);
1603 :
1604 0 : if (kFixedBufferSize == type) {
1605 0 : if (sizeMS < kAdmMinPlayoutBufferSizeMs ||
1606 0 : sizeMS > kAdmMaxPlayoutBufferSizeMs) {
1607 0 : LOG(LERROR) << "size parameter is out of range";
1608 0 : return -1;
1609 : }
1610 : }
1611 :
1612 0 : if ((ret = _ptrAudioDevice->SetPlayoutBuffer(type, sizeMS)) == -1) {
1613 0 : LOG(LERROR) << "failed to set the playout buffer (error: " << LastError()
1614 0 : << ")";
1615 : }
1616 :
1617 0 : return ret;
1618 : }
1619 :
1620 : // ----------------------------------------------------------------------------
1621 : // PlayoutBuffer
1622 : // ----------------------------------------------------------------------------
1623 :
1624 0 : int32_t AudioDeviceModuleImpl::PlayoutBuffer(BufferType* type,
1625 : uint16_t* sizeMS) const {
1626 0 : LOG(INFO) << __FUNCTION__;
1627 0 : CHECK_INITIALIZED();
1628 :
1629 : BufferType bufType;
1630 0 : uint16_t size(0);
1631 :
1632 0 : if (_ptrAudioDevice->PlayoutBuffer(bufType, size) == -1) {
1633 0 : LOG(LERROR) << "failed to retrieve the buffer type and size";
1634 0 : return -1;
1635 : }
1636 :
1637 0 : *type = bufType;
1638 0 : *sizeMS = size;
1639 :
1640 0 : LOG(INFO) << "output: type = " << *type << ", sizeMS = " << *sizeMS;
1641 0 : return (0);
1642 : }
1643 :
1644 : // ----------------------------------------------------------------------------
1645 : // PlayoutDelay
1646 : // ----------------------------------------------------------------------------
1647 :
1648 0 : int32_t AudioDeviceModuleImpl::PlayoutDelay(uint16_t* delayMS) const {
1649 0 : CHECK_INITIALIZED();
1650 :
1651 0 : uint16_t delay(0);
1652 :
1653 0 : if (_ptrAudioDevice->PlayoutDelay(delay) == -1) {
1654 0 : LOG(LERROR) << "failed to retrieve the playout delay";
1655 0 : return -1;
1656 : }
1657 :
1658 0 : *delayMS = delay;
1659 0 : return (0);
1660 : }
1661 :
1662 : // ----------------------------------------------------------------------------
1663 : // RecordingDelay
1664 : // ----------------------------------------------------------------------------
1665 :
1666 0 : int32_t AudioDeviceModuleImpl::RecordingDelay(uint16_t* delayMS) const {
1667 0 : LOG(INFO) << __FUNCTION__;
1668 0 : CHECK_INITIALIZED();
1669 :
1670 0 : uint16_t delay(0);
1671 :
1672 0 : if (_ptrAudioDevice->RecordingDelay(delay) == -1) {
1673 0 : LOG(LERROR) << "failed to retrieve the recording delay";
1674 0 : return -1;
1675 : }
1676 :
1677 0 : *delayMS = delay;
1678 0 : LOG(INFO) << "output: " << *delayMS;
1679 0 : return (0);
1680 : }
1681 :
1682 : // ----------------------------------------------------------------------------
1683 : // CPULoad
1684 : // ----------------------------------------------------------------------------
1685 :
1686 0 : int32_t AudioDeviceModuleImpl::CPULoad(uint16_t* load) const {
1687 0 : LOG(INFO) << __FUNCTION__;
1688 0 : CHECK_INITIALIZED();
1689 :
1690 0 : uint16_t cpuLoad(0);
1691 :
1692 0 : if (_ptrAudioDevice->CPULoad(cpuLoad) == -1) {
1693 0 : LOG(LERROR) << "failed to retrieve the CPU load";
1694 0 : return -1;
1695 : }
1696 :
1697 0 : *load = cpuLoad;
1698 0 : LOG(INFO) << "output: " << *load;
1699 0 : return (0);
1700 : }
1701 :
1702 : // ----------------------------------------------------------------------------
1703 : // SetRecordingSampleRate
1704 : // ----------------------------------------------------------------------------
1705 :
1706 0 : int32_t AudioDeviceModuleImpl::SetRecordingSampleRate(
1707 : const uint32_t samplesPerSec) {
1708 0 : LOG(INFO) << __FUNCTION__ << "(" << samplesPerSec << ")";
1709 0 : CHECK_INITIALIZED();
1710 :
1711 0 : if (_ptrAudioDevice->SetRecordingSampleRate(samplesPerSec) != 0) {
1712 0 : return -1;
1713 : }
1714 :
1715 0 : return (0);
1716 : }
1717 :
1718 : // ----------------------------------------------------------------------------
1719 : // RecordingSampleRate
1720 : // ----------------------------------------------------------------------------
1721 :
1722 0 : int32_t AudioDeviceModuleImpl::RecordingSampleRate(
1723 : uint32_t* samplesPerSec) const {
1724 0 : LOG(INFO) << __FUNCTION__;
1725 0 : CHECK_INITIALIZED();
1726 :
1727 0 : int32_t sampleRate = _audioDeviceBuffer.RecordingSampleRate();
1728 :
1729 0 : if (sampleRate == -1) {
1730 0 : LOG(LERROR) << "failed to retrieve the sample rate";
1731 0 : return -1;
1732 : }
1733 :
1734 0 : *samplesPerSec = sampleRate;
1735 0 : LOG(INFO) << "output: " << *samplesPerSec;
1736 0 : return (0);
1737 : }
1738 :
1739 : // ----------------------------------------------------------------------------
1740 : // SetPlayoutSampleRate
1741 : // ----------------------------------------------------------------------------
1742 :
1743 0 : int32_t AudioDeviceModuleImpl::SetPlayoutSampleRate(
1744 : const uint32_t samplesPerSec) {
1745 0 : LOG(INFO) << __FUNCTION__ << "(" << samplesPerSec << ")";
1746 0 : CHECK_INITIALIZED();
1747 :
1748 0 : if (_ptrAudioDevice->SetPlayoutSampleRate(samplesPerSec) != 0) {
1749 0 : return -1;
1750 : }
1751 :
1752 0 : return (0);
1753 : }
1754 :
1755 : // ----------------------------------------------------------------------------
1756 : // PlayoutSampleRate
1757 : // ----------------------------------------------------------------------------
1758 :
1759 0 : int32_t AudioDeviceModuleImpl::PlayoutSampleRate(
1760 : uint32_t* samplesPerSec) const {
1761 0 : LOG(INFO) << __FUNCTION__;
1762 0 : CHECK_INITIALIZED();
1763 :
1764 0 : int32_t sampleRate = _audioDeviceBuffer.PlayoutSampleRate();
1765 :
1766 0 : if (sampleRate == -1) {
1767 0 : LOG(LERROR) << "failed to retrieve the sample rate";
1768 0 : return -1;
1769 : }
1770 :
1771 0 : *samplesPerSec = sampleRate;
1772 0 : LOG(INFO) << "output: " << *samplesPerSec;
1773 0 : return (0);
1774 : }
1775 :
1776 : // ----------------------------------------------------------------------------
1777 : // ResetAudioDevice
1778 : // ----------------------------------------------------------------------------
1779 :
1780 0 : int32_t AudioDeviceModuleImpl::ResetAudioDevice() {
1781 0 : LOG(INFO) << __FUNCTION__;
1782 0 : FATAL() << "Should never be called";
1783 : return -1;
1784 : }
1785 :
1786 : // ----------------------------------------------------------------------------
1787 : // SetLoudspeakerStatus
1788 : // ----------------------------------------------------------------------------
1789 :
1790 0 : int32_t AudioDeviceModuleImpl::SetLoudspeakerStatus(bool enable) {
1791 0 : LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
1792 0 : CHECK_INITIALIZED();
1793 :
1794 0 : if (_ptrAudioDevice->SetLoudspeakerStatus(enable) != 0) {
1795 0 : return -1;
1796 : }
1797 :
1798 0 : return 0;
1799 : }
1800 :
1801 : // ----------------------------------------------------------------------------
1802 : // GetLoudspeakerStatus
1803 : // ----------------------------------------------------------------------------
1804 :
1805 0 : int32_t AudioDeviceModuleImpl::GetLoudspeakerStatus(bool* enabled) const {
1806 0 : LOG(INFO) << __FUNCTION__;
1807 0 : CHECK_INITIALIZED();
1808 0 : int32_t ok = 0;
1809 0 : if (_ptrAudioDevice->GetLoudspeakerStatus(*enabled) != 0) {
1810 0 : ok = -1;
1811 : }
1812 0 : LOG(INFO) << "output: " << ok;
1813 0 : return ok;
1814 : }
1815 :
1816 0 : bool AudioDeviceModuleImpl::BuiltInAECIsAvailable() const {
1817 0 : LOG(INFO) << __FUNCTION__;
1818 0 : CHECK_INITIALIZED_BOOL();
1819 0 : bool isAvailable = _ptrAudioDevice->BuiltInAECIsAvailable();
1820 0 : LOG(INFO) << "output: " << isAvailable;
1821 0 : return isAvailable;
1822 : }
1823 :
1824 0 : int32_t AudioDeviceModuleImpl::EnableBuiltInAEC(bool enable) {
1825 0 : LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
1826 0 : CHECK_INITIALIZED();
1827 0 : int32_t ok = _ptrAudioDevice->EnableBuiltInAEC(enable);
1828 0 : LOG(INFO) << "output: " << ok;
1829 0 : return ok;
1830 : }
1831 :
1832 0 : bool AudioDeviceModuleImpl::BuiltInAGCIsAvailable() const {
1833 0 : LOG(INFO) << __FUNCTION__;
1834 0 : CHECK_INITIALIZED_BOOL();
1835 0 : bool isAvailable = _ptrAudioDevice->BuiltInAGCIsAvailable();
1836 0 : LOG(INFO) << "output: " << isAvailable;
1837 0 : return isAvailable;
1838 : }
1839 :
1840 0 : int32_t AudioDeviceModuleImpl::EnableBuiltInAGC(bool enable) {
1841 0 : LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
1842 0 : CHECK_INITIALIZED();
1843 0 : int32_t ok = _ptrAudioDevice->EnableBuiltInAGC(enable);
1844 0 : LOG(INFO) << "output: " << ok;
1845 0 : return ok;
1846 : }
1847 :
1848 0 : bool AudioDeviceModuleImpl::BuiltInNSIsAvailable() const {
1849 0 : LOG(INFO) << __FUNCTION__;
1850 0 : CHECK_INITIALIZED_BOOL();
1851 0 : bool isAvailable = _ptrAudioDevice->BuiltInNSIsAvailable();
1852 0 : LOG(INFO) << "output: " << isAvailable;
1853 0 : return isAvailable;
1854 : }
1855 :
1856 0 : int32_t AudioDeviceModuleImpl::EnableBuiltInNS(bool enable) {
1857 0 : LOG(INFO) << __FUNCTION__ << "(" << enable << ")";
1858 0 : CHECK_INITIALIZED();
1859 0 : int32_t ok = _ptrAudioDevice->EnableBuiltInNS(enable);
1860 0 : LOG(INFO) << "output: " << ok;
1861 0 : return ok;
1862 : }
1863 :
1864 : #if defined(WEBRTC_IOS)
1865 : 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 :
1873 : 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 :
1890 0 : AudioDeviceModuleImpl::PlatformType AudioDeviceModuleImpl::Platform() const {
1891 0 : LOG(INFO) << __FUNCTION__;
1892 0 : return _platformType;
1893 : }
1894 :
1895 : // ----------------------------------------------------------------------------
1896 : // PlatformAudioLayer
1897 : // ----------------------------------------------------------------------------
1898 :
1899 0 : AudioDeviceModule::AudioLayer AudioDeviceModuleImpl::PlatformAudioLayer()
1900 : const {
1901 0 : LOG(INFO) << __FUNCTION__;
1902 0 : return _platformAudioLayer;
1903 : }
1904 :
1905 : } // namespace webrtc
|