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