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