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