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