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