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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #include "modules/audio_device/audio_device_impl.h" |
| 12 | #include "common_audio/signal_processing/include/signal_processing_library.h" |
| 13 | #include "modules/audio_device/audio_device_config.h" |
| 14 | #include "modules/audio_device/audio_device_generic.h" |
| 15 | #include "rtc_base/checks.h" |
| 16 | #include "rtc_base/logging.h" |
| 17 | #include "rtc_base/refcount.h" |
Niels Möller | bf6937a | 2017-10-03 10:42:04 +0200 | [diff] [blame^] | 18 | #include "rtc_base/refcountedobject.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 19 | #include "rtc_base/timeutils.h" |
| 20 | #include "system_wrappers/include/metrics.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 21 | |
andrew@webrtc.org | a3c6d61 | 2011-09-13 17:17:49 +0000 | [diff] [blame] | 22 | #include <assert.h> |
xians@google.com | bf5d2ba | 2011-08-16 07:44:19 +0000 | [diff] [blame] | 23 | #include <string.h> |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 24 | |
| 25 | #if defined(_WIN32) |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 26 | #if defined(WEBRTC_WINDOWS_CORE_AUDIO_BUILD) |
| 27 | #include "audio_device_core_win.h" |
| 28 | #endif |
leozwang@google.com | 39f2051 | 2011-07-15 16:29:40 +0000 | [diff] [blame] | 29 | #elif defined(WEBRTC_ANDROID) |
henrika | b261989 | 2015-05-18 16:49:16 +0200 | [diff] [blame] | 30 | #include <stdlib.h> |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 31 | #include "modules/audio_device/android/audio_device_template.h" |
| 32 | #include "modules/audio_device/android/audio_manager.h" |
| 33 | #include "modules/audio_device/android/audio_record_jni.h" |
| 34 | #include "modules/audio_device/android/audio_track_jni.h" |
| 35 | #include "modules/audio_device/android/opensles_player.h" |
| 36 | #include "modules/audio_device/android/opensles_recorder.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 37 | #elif defined(WEBRTC_LINUX) |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 38 | #if defined(LINUX_ALSA) |
| 39 | #include "audio_device_alsa_linux.h" |
| 40 | #endif |
Tommi | 68898a2 | 2015-05-19 17:28:07 +0200 | [diff] [blame] | 41 | #if defined(LINUX_PULSE) |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 42 | #include "audio_device_pulse_linux.h" |
Tommi | 68898a2 | 2015-05-19 17:28:07 +0200 | [diff] [blame] | 43 | #endif |
sjlee@webrtc.org | 414fa7f | 2012-09-11 17:25:46 +0000 | [diff] [blame] | 44 | #elif defined(WEBRTC_IOS) |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 45 | #include "audio_device_ios.h" |
andrew@webrtc.org | f3b65db | 2012-09-06 18:17:00 +0000 | [diff] [blame] | 46 | #elif defined(WEBRTC_MAC) |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 47 | #include "audio_device_mac.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 48 | #endif |
phoglund@webrtc.org | 8454ad1 | 2014-06-11 14:12:04 +0000 | [diff] [blame] | 49 | |
| 50 | #if defined(WEBRTC_DUMMY_FILE_DEVICES) |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 51 | #include "modules/audio_device/dummy/file_audio_device_factory.h" |
phoglund@webrtc.org | 8454ad1 | 2014-06-11 14:12:04 +0000 | [diff] [blame] | 52 | #endif |
| 53 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 54 | #include "modules/audio_device/dummy/audio_device_dummy.h" |
| 55 | #include "modules/audio_device/dummy/file_audio_device.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 56 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 57 | #define CHECK_INITIALIZED() \ |
| 58 | { \ |
| 59 | if (!_initialized) { \ |
| 60 | return -1; \ |
| 61 | }; \ |
| 62 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 63 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 64 | #define CHECK_INITIALIZED_BOOL() \ |
| 65 | { \ |
| 66 | if (!_initialized) { \ |
| 67 | return false; \ |
| 68 | }; \ |
| 69 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 70 | |
Peter Boström | 1d19441 | 2016-03-21 16:44:31 +0100 | [diff] [blame] | 71 | namespace webrtc { |
henrike@webrtc.org | 70efc32 | 2012-02-23 17:45:33 +0000 | [diff] [blame] | 72 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 73 | // ============================================================================ |
| 74 | // Static methods |
| 75 | // ============================================================================ |
| 76 | |
| 77 | // ---------------------------------------------------------------------------- |
| 78 | // AudioDeviceModule::Create() |
| 79 | // ---------------------------------------------------------------------------- |
| 80 | |
Peter Boström | 4adbbcf | 2016-05-03 15:51:26 -0400 | [diff] [blame] | 81 | rtc::scoped_refptr<AudioDeviceModule> AudioDeviceModule::Create( |
Peter Boström | 1d19441 | 2016-03-21 16:44:31 +0100 | [diff] [blame] | 82 | const int32_t id, |
Peter Boström | 4adbbcf | 2016-05-03 15:51:26 -0400 | [diff] [blame] | 83 | const AudioLayer audio_layer) { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 84 | LOG(INFO) << __FUNCTION__; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 85 | // Create the generic ref counted (platform independent) implementation. |
| 86 | rtc::scoped_refptr<AudioDeviceModuleImpl> audioDevice( |
| 87 | new rtc::RefCountedObject<AudioDeviceModuleImpl>(id, audio_layer)); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 88 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 89 | // Ensure that the current platform is supported. |
| 90 | if (audioDevice->CheckPlatform() == -1) { |
| 91 | return nullptr; |
| 92 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 93 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 94 | // Create the platform-dependent implementation. |
| 95 | if (audioDevice->CreatePlatformSpecificObjects() == -1) { |
| 96 | return nullptr; |
| 97 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 98 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 99 | // Ensure that the generic audio buffer can communicate with the |
| 100 | // platform-specific parts. |
| 101 | if (audioDevice->AttachAudioBuffer() == -1) { |
| 102 | return nullptr; |
| 103 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 104 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 105 | WebRtcSpl_Init(); |
kma@webrtc.org | ac4d70d | 2012-10-05 00:19:01 +0000 | [diff] [blame] | 106 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 107 | return audioDevice; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 108 | } |
| 109 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 110 | // ============================================================================ |
| 111 | // Construction & Destruction |
| 112 | // ============================================================================ |
| 113 | |
| 114 | // ---------------------------------------------------------------------------- |
| 115 | // AudioDeviceModuleImpl - ctor |
| 116 | // ---------------------------------------------------------------------------- |
| 117 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 118 | AudioDeviceModuleImpl::AudioDeviceModuleImpl(const int32_t id, |
| 119 | const AudioLayer audioLayer) |
Fredrik Solenberg | a32dd01 | 2017-10-04 13:27:21 +0200 | [diff] [blame] | 120 | : _ptrAudioDevice(NULL), |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 121 | _id(id), |
| 122 | _platformAudioLayer(audioLayer), |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 123 | _platformType(kPlatformNotSupported), |
| 124 | _initialized(false), |
| 125 | _lastError(kAdmErrNone) { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 126 | LOG(INFO) << __FUNCTION__; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 127 | } |
| 128 | |
| 129 | // ---------------------------------------------------------------------------- |
| 130 | // CheckPlatform |
| 131 | // ---------------------------------------------------------------------------- |
| 132 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 133 | int32_t AudioDeviceModuleImpl::CheckPlatform() { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 134 | LOG(INFO) << __FUNCTION__; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 135 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 136 | // Ensure that the current platform is supported |
| 137 | // |
| 138 | PlatformType platform(kPlatformNotSupported); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 139 | |
| 140 | #if defined(_WIN32) |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 141 | platform = kPlatformWin32; |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 142 | LOG(INFO) << "current platform is Win32"; |
leozwang@google.com | 522f42b | 2011-09-19 17:39:05 +0000 | [diff] [blame] | 143 | #elif defined(WEBRTC_ANDROID) |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 144 | platform = kPlatformAndroid; |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 145 | LOG(INFO) << "current platform is Android"; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 146 | #elif defined(WEBRTC_LINUX) |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 147 | platform = kPlatformLinux; |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 148 | LOG(INFO) << "current platform is Linux"; |
sjlee@webrtc.org | 414fa7f | 2012-09-11 17:25:46 +0000 | [diff] [blame] | 149 | #elif defined(WEBRTC_IOS) |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 150 | platform = kPlatformIOS; |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 151 | LOG(INFO) << "current platform is IOS"; |
andrew@webrtc.org | f3b65db | 2012-09-06 18:17:00 +0000 | [diff] [blame] | 152 | #elif defined(WEBRTC_MAC) |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 153 | platform = kPlatformMac; |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 154 | LOG(INFO) << "current platform is Mac"; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 155 | #endif |
| 156 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 157 | if (platform == kPlatformNotSupported) { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 158 | LOG(LERROR) << "current platform is not supported => this module will self " |
| 159 | "destruct!"; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 160 | return -1; |
| 161 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 162 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 163 | // Store valid output results |
| 164 | // |
| 165 | _platformType = platform; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 166 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 167 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 168 | } |
| 169 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 170 | // ---------------------------------------------------------------------------- |
| 171 | // CreatePlatformSpecificObjects |
| 172 | // ---------------------------------------------------------------------------- |
| 173 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 174 | int32_t AudioDeviceModuleImpl::CreatePlatformSpecificObjects() { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 175 | LOG(INFO) << __FUNCTION__; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 176 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 177 | AudioDeviceGeneric* ptrAudioDevice(NULL); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 178 | |
xians@google.com | bf5d2ba | 2011-08-16 07:44:19 +0000 | [diff] [blame] | 179 | #if defined(WEBRTC_DUMMY_AUDIO_BUILD) |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 180 | ptrAudioDevice = new AudioDeviceDummy(Id()); |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 181 | LOG(INFO) << "Dummy Audio APIs will be utilized"; |
phoglund@webrtc.org | 8454ad1 | 2014-06-11 14:12:04 +0000 | [diff] [blame] | 182 | #elif defined(WEBRTC_DUMMY_FILE_DEVICES) |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 183 | ptrAudioDevice = FileAudioDeviceFactory::CreateFileAudioDevice(Id()); |
noahric | 6a35590 | 2016-08-17 15:19:50 -0700 | [diff] [blame] | 184 | if (ptrAudioDevice) { |
| 185 | LOG(INFO) << "Will use file-playing dummy device."; |
| 186 | } else { |
| 187 | // Create a dummy device instead. |
| 188 | ptrAudioDevice = new AudioDeviceDummy(Id()); |
| 189 | LOG(INFO) << "Dummy Audio APIs will be utilized"; |
| 190 | } |
xians@google.com | bf5d2ba | 2011-08-16 07:44:19 +0000 | [diff] [blame] | 191 | #else |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 192 | AudioLayer audioLayer(PlatformAudioLayer()); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 193 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 194 | // Create the *Windows* implementation of the Audio Device |
| 195 | // |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 196 | #if defined(WEBRTC_WINDOWS_CORE_AUDIO_BUILD) |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 197 | if ((audioLayer == kWindowsCoreAudio) || |
| 198 | (audioLayer == kPlatformDefaultAudio)) { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 199 | LOG(INFO) << "attempting to use the Windows Core Audio APIs..."; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 200 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 201 | if (AudioDeviceWindowsCore::CoreAudioIsSupported()) { |
| 202 | // create *Windows Core Audio* implementation |
saza | b4aa4eb | 2017-07-19 01:12:36 -0700 | [diff] [blame] | 203 | ptrAudioDevice = new AudioDeviceWindowsCore(); |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 204 | LOG(INFO) << "Windows Core Audio APIs will be utilized"; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 205 | } |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 206 | } |
| 207 | #endif // defined(WEBRTC_WINDOWS_CORE_AUDIO_BUILD) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 208 | |
henrike@webrtc.org | 9ee75e9 | 2013-12-11 21:42:44 +0000 | [diff] [blame] | 209 | #if defined(WEBRTC_ANDROID) |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 210 | // Create an Android audio manager. |
| 211 | _audioManagerAndroid.reset(new AudioManager()); |
| 212 | // Select best possible combination of audio layers. |
| 213 | if (audioLayer == kPlatformDefaultAudio) { |
henrika | 918b554 | 2016-09-19 15:44:09 +0200 | [diff] [blame] | 214 | if (_audioManagerAndroid->IsLowLatencyPlayoutSupported() && |
| 215 | _audioManagerAndroid->IsLowLatencyRecordSupported()) { |
| 216 | // Use OpenSL ES for both playout and recording. |
| 217 | audioLayer = kAndroidOpenSLESAudio; |
| 218 | } else if (_audioManagerAndroid->IsLowLatencyPlayoutSupported() && |
| 219 | !_audioManagerAndroid->IsLowLatencyRecordSupported()) { |
| 220 | // Use OpenSL ES for output on devices that only supports the |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 221 | // low-latency output audio path. |
| 222 | audioLayer = kAndroidJavaInputAndOpenSLESOutputAudio; |
henrika | b261989 | 2015-05-18 16:49:16 +0200 | [diff] [blame] | 223 | } else { |
henrika | 918b554 | 2016-09-19 15:44:09 +0200 | [diff] [blame] | 224 | // Use Java-based audio in both directions when low-latency output is |
| 225 | // not supported. |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 226 | audioLayer = kAndroidJavaAudio; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 227 | } |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 228 | } |
| 229 | AudioManager* audio_manager = _audioManagerAndroid.get(); |
| 230 | if (audioLayer == kAndroidJavaAudio) { |
| 231 | // Java audio for both input and output audio. |
| 232 | ptrAudioDevice = new AudioDeviceTemplate<AudioRecordJni, AudioTrackJni>( |
| 233 | audioLayer, audio_manager); |
henrika | 918b554 | 2016-09-19 15:44:09 +0200 | [diff] [blame] | 234 | } else if (audioLayer == kAndroidOpenSLESAudio) { |
| 235 | // OpenSL ES based audio for both input and output audio. |
| 236 | ptrAudioDevice = new AudioDeviceTemplate<OpenSLESRecorder, OpenSLESPlayer>( |
| 237 | audioLayer, audio_manager); |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 238 | } else if (audioLayer == kAndroidJavaInputAndOpenSLESOutputAudio) { |
| 239 | // Java audio for input and OpenSL ES for output audio (i.e. mixed APIs). |
| 240 | // This combination provides low-latency output audio and at the same |
| 241 | // time support for HW AEC using the AudioRecord Java API. |
| 242 | ptrAudioDevice = new AudioDeviceTemplate<AudioRecordJni, OpenSLESPlayer>( |
| 243 | audioLayer, audio_manager); |
| 244 | } else { |
| 245 | // Invalid audio layer. |
henrika | 918b554 | 2016-09-19 15:44:09 +0200 | [diff] [blame] | 246 | ptrAudioDevice = nullptr; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 247 | } |
| 248 | // END #if defined(WEBRTC_ANDROID) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 249 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 250 | // Create the *Linux* implementation of the Audio Device |
| 251 | // |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 252 | #elif defined(WEBRTC_LINUX) |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 253 | if ((audioLayer == kLinuxPulseAudio) || |
| 254 | (audioLayer == kPlatformDefaultAudio)) { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 255 | #if defined(LINUX_PULSE) |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 256 | LOG(INFO) << "attempting to use the Linux PulseAudio APIs..."; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 257 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 258 | // create *Linux PulseAudio* implementation |
saza | 43a85f0 | 2017-07-18 04:12:29 -0700 | [diff] [blame] | 259 | AudioDeviceLinuxPulse* pulseDevice = new AudioDeviceLinuxPulse(); |
Max Morin | 84cab20 | 2016-07-01 13:35:19 +0200 | [diff] [blame] | 260 | if (pulseDevice->Init() == AudioDeviceGeneric::InitStatus::OK) { |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 261 | ptrAudioDevice = pulseDevice; |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 262 | LOG(INFO) << "Linux PulseAudio APIs will be utilized"; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 263 | } else { |
| 264 | delete pulseDevice; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 265 | #endif |
| 266 | #if defined(LINUX_ALSA) |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 267 | // create *Linux ALSA Audio* implementation |
saza | 43a85f0 | 2017-07-18 04:12:29 -0700 | [diff] [blame] | 268 | ptrAudioDevice = new AudioDeviceLinuxALSA(); |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 269 | if (ptrAudioDevice != NULL) { |
| 270 | // Pulse Audio was not supported => revert to ALSA instead |
| 271 | _platformAudioLayer = |
| 272 | kLinuxAlsaAudio; // modify the state set at construction |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 273 | LOG(WARNING) << "Linux PulseAudio is *not* supported => ALSA APIs will " |
| 274 | "be utilized instead"; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 275 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 276 | #endif |
| 277 | #if defined(LINUX_PULSE) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 278 | } |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 279 | #endif |
| 280 | } else if (audioLayer == kLinuxAlsaAudio) { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 281 | #if defined(LINUX_ALSA) |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 282 | // create *Linux ALSA Audio* implementation |
saza | 43a85f0 | 2017-07-18 04:12:29 -0700 | [diff] [blame] | 283 | ptrAudioDevice = new AudioDeviceLinuxALSA(); |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 284 | LOG(INFO) << "Linux ALSA APIs will be utilized"; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 285 | #endif |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 286 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 287 | #endif // #if defined(WEBRTC_LINUX) |
| 288 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 289 | // Create the *iPhone* implementation of the Audio Device |
| 290 | // |
sjlee@webrtc.org | 414fa7f | 2012-09-11 17:25:46 +0000 | [diff] [blame] | 291 | #if defined(WEBRTC_IOS) |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 292 | if (audioLayer == kPlatformDefaultAudio) { |
| 293 | // Create iOS Audio Device implementation. |
| 294 | ptrAudioDevice = new AudioDeviceIOS(); |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 295 | LOG(INFO) << "iPhone Audio APIs will be utilized"; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 296 | } |
| 297 | // END #if defined(WEBRTC_IOS) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 298 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 299 | // Create the *Mac* implementation of the Audio Device |
| 300 | // |
andrew@webrtc.org | f3b65db | 2012-09-06 18:17:00 +0000 | [diff] [blame] | 301 | #elif defined(WEBRTC_MAC) |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 302 | if (audioLayer == kPlatformDefaultAudio) { |
| 303 | // Create *Mac Audio* implementation |
saza | b4aa4eb | 2017-07-19 01:12:36 -0700 | [diff] [blame] | 304 | ptrAudioDevice = new AudioDeviceMac(); |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 305 | LOG(INFO) << "Mac OS X Audio APIs will be utilized"; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 306 | } |
andrew@webrtc.org | f3b65db | 2012-09-06 18:17:00 +0000 | [diff] [blame] | 307 | #endif // WEBRTC_MAC |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 308 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 309 | // Create the *Dummy* implementation of the Audio Device |
| 310 | // Available for all platforms |
| 311 | // |
| 312 | if (audioLayer == kDummyAudio) { |
| 313 | // Create *Dummy Audio* implementation |
| 314 | assert(!ptrAudioDevice); |
| 315 | ptrAudioDevice = new AudioDeviceDummy(Id()); |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 316 | LOG(INFO) << "Dummy Audio APIs will be utilized"; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 317 | } |
xians@google.com | bf5d2ba | 2011-08-16 07:44:19 +0000 | [diff] [blame] | 318 | #endif // if defined(WEBRTC_DUMMY_AUDIO_BUILD) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 319 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 320 | if (ptrAudioDevice == NULL) { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 321 | LOG(LERROR) |
| 322 | << "unable to create the platform specific audio device implementation"; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 323 | return -1; |
| 324 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 325 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 326 | // Store valid output pointers |
| 327 | // |
| 328 | _ptrAudioDevice = ptrAudioDevice; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 329 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 330 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 331 | } |
| 332 | |
| 333 | // ---------------------------------------------------------------------------- |
| 334 | // AttachAudioBuffer |
| 335 | // |
| 336 | // Install "bridge" between the platform implemetation and the generic |
| 337 | // implementation. The "child" shall set the native sampling rate and the |
| 338 | // number of channels in this function call. |
| 339 | // ---------------------------------------------------------------------------- |
| 340 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 341 | int32_t AudioDeviceModuleImpl::AttachAudioBuffer() { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 342 | LOG(INFO) << __FUNCTION__; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 343 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 344 | _audioDeviceBuffer.SetId(_id); |
| 345 | _ptrAudioDevice->AttachAudioBuffer(&_audioDeviceBuffer); |
| 346 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 347 | } |
| 348 | |
| 349 | // ---------------------------------------------------------------------------- |
| 350 | // ~AudioDeviceModuleImpl - dtor |
| 351 | // ---------------------------------------------------------------------------- |
| 352 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 353 | AudioDeviceModuleImpl::~AudioDeviceModuleImpl() { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 354 | LOG(INFO) << __FUNCTION__; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 355 | if (_ptrAudioDevice) { |
| 356 | delete _ptrAudioDevice; |
| 357 | _ptrAudioDevice = NULL; |
| 358 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 359 | } |
| 360 | |
| 361 | // ============================================================================ |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 362 | // Public API |
| 363 | // ============================================================================ |
| 364 | |
| 365 | // ---------------------------------------------------------------------------- |
| 366 | // ActiveAudioLayer |
| 367 | // ---------------------------------------------------------------------------- |
| 368 | |
henrika | b261989 | 2015-05-18 16:49:16 +0200 | [diff] [blame] | 369 | int32_t AudioDeviceModuleImpl::ActiveAudioLayer(AudioLayer* audioLayer) const { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 370 | LOG(INFO) << __FUNCTION__; |
henrika | b261989 | 2015-05-18 16:49:16 +0200 | [diff] [blame] | 371 | AudioLayer activeAudio; |
| 372 | if (_ptrAudioDevice->ActiveAudioLayer(activeAudio) == -1) { |
| 373 | return -1; |
| 374 | } |
| 375 | *audioLayer = activeAudio; |
| 376 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 377 | } |
| 378 | |
| 379 | // ---------------------------------------------------------------------------- |
| 380 | // LastError |
| 381 | // ---------------------------------------------------------------------------- |
| 382 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 383 | AudioDeviceModule::ErrorCode AudioDeviceModuleImpl::LastError() const { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 384 | LOG(INFO) << __FUNCTION__; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 385 | return _lastError; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 386 | } |
| 387 | |
| 388 | // ---------------------------------------------------------------------------- |
| 389 | // Init |
| 390 | // ---------------------------------------------------------------------------- |
| 391 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 392 | int32_t AudioDeviceModuleImpl::Init() { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 393 | LOG(INFO) << __FUNCTION__; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 394 | if (_initialized) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 395 | return 0; |
Max Morin | 84cab20 | 2016-07-01 13:35:19 +0200 | [diff] [blame] | 396 | RTC_CHECK(_ptrAudioDevice); |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 397 | |
Max Morin | 84cab20 | 2016-07-01 13:35:19 +0200 | [diff] [blame] | 398 | AudioDeviceGeneric::InitStatus status = _ptrAudioDevice->Init(); |
| 399 | RTC_HISTOGRAM_ENUMERATION( |
| 400 | "WebRTC.Audio.InitializationResult", static_cast<int>(status), |
| 401 | static_cast<int>(AudioDeviceGeneric::InitStatus::NUM_STATUSES)); |
| 402 | if (status != AudioDeviceGeneric::InitStatus::OK) { |
| 403 | LOG(LS_ERROR) << "Audio device initialization failed."; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 404 | return -1; |
| 405 | } |
| 406 | |
| 407 | _initialized = true; |
| 408 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 409 | } |
| 410 | |
| 411 | // ---------------------------------------------------------------------------- |
| 412 | // Terminate |
| 413 | // ---------------------------------------------------------------------------- |
| 414 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 415 | int32_t AudioDeviceModuleImpl::Terminate() { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 416 | LOG(INFO) << __FUNCTION__; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 417 | if (!_initialized) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 418 | return 0; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 419 | |
| 420 | if (_ptrAudioDevice->Terminate() == -1) { |
| 421 | return -1; |
| 422 | } |
| 423 | |
| 424 | _initialized = false; |
| 425 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 426 | } |
| 427 | |
| 428 | // ---------------------------------------------------------------------------- |
| 429 | // Initialized |
| 430 | // ---------------------------------------------------------------------------- |
| 431 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 432 | bool AudioDeviceModuleImpl::Initialized() const { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 433 | LOG(INFO) << __FUNCTION__ << ": " << _initialized; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 434 | return (_initialized); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 435 | } |
| 436 | |
| 437 | // ---------------------------------------------------------------------------- |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 438 | // InitSpeaker |
| 439 | // ---------------------------------------------------------------------------- |
| 440 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 441 | int32_t AudioDeviceModuleImpl::InitSpeaker() { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 442 | LOG(INFO) << __FUNCTION__; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 443 | CHECK_INITIALIZED(); |
| 444 | return (_ptrAudioDevice->InitSpeaker()); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 445 | } |
| 446 | |
| 447 | // ---------------------------------------------------------------------------- |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 448 | // InitMicrophone |
| 449 | // ---------------------------------------------------------------------------- |
| 450 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 451 | int32_t AudioDeviceModuleImpl::InitMicrophone() { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 452 | LOG(INFO) << __FUNCTION__; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 453 | CHECK_INITIALIZED(); |
| 454 | return (_ptrAudioDevice->InitMicrophone()); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 455 | } |
| 456 | |
| 457 | // ---------------------------------------------------------------------------- |
| 458 | // SpeakerVolumeIsAvailable |
| 459 | // ---------------------------------------------------------------------------- |
| 460 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 461 | int32_t AudioDeviceModuleImpl::SpeakerVolumeIsAvailable(bool* available) { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 462 | LOG(INFO) << __FUNCTION__; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 463 | CHECK_INITIALIZED(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 464 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 465 | bool isAvailable(0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 466 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 467 | if (_ptrAudioDevice->SpeakerVolumeIsAvailable(isAvailable) == -1) { |
| 468 | return -1; |
| 469 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 470 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 471 | *available = isAvailable; |
Max Morin | 2c332bb | 2016-07-04 09:03:42 +0200 | [diff] [blame] | 472 | LOG(INFO) << "output: " << isAvailable; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 473 | return (0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 474 | } |
| 475 | |
| 476 | // ---------------------------------------------------------------------------- |
| 477 | // SetSpeakerVolume |
| 478 | // ---------------------------------------------------------------------------- |
| 479 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 480 | int32_t AudioDeviceModuleImpl::SetSpeakerVolume(uint32_t volume) { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 481 | LOG(INFO) << __FUNCTION__ << "(" << volume << ")"; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 482 | CHECK_INITIALIZED(); |
| 483 | return (_ptrAudioDevice->SetSpeakerVolume(volume)); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 484 | } |
| 485 | |
| 486 | // ---------------------------------------------------------------------------- |
| 487 | // SpeakerVolume |
| 488 | // ---------------------------------------------------------------------------- |
| 489 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 490 | int32_t AudioDeviceModuleImpl::SpeakerVolume(uint32_t* volume) const { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 491 | LOG(INFO) << __FUNCTION__; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 492 | CHECK_INITIALIZED(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 493 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 494 | uint32_t level(0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 495 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 496 | if (_ptrAudioDevice->SpeakerVolume(level) == -1) { |
| 497 | return -1; |
| 498 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 499 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 500 | *volume = level; |
Max Morin | 2c332bb | 2016-07-04 09:03:42 +0200 | [diff] [blame] | 501 | LOG(INFO) << "output: " << *volume; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 502 | return (0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 503 | } |
| 504 | |
| 505 | // ---------------------------------------------------------------------------- |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 506 | // SpeakerIsInitialized |
| 507 | // ---------------------------------------------------------------------------- |
| 508 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 509 | bool AudioDeviceModuleImpl::SpeakerIsInitialized() const { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 510 | LOG(INFO) << __FUNCTION__; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 511 | CHECK_INITIALIZED_BOOL(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 512 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 513 | bool isInitialized = _ptrAudioDevice->SpeakerIsInitialized(); |
Max Morin | 2c332bb | 2016-07-04 09:03:42 +0200 | [diff] [blame] | 514 | LOG(INFO) << "output: " << isInitialized; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 515 | return (isInitialized); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 516 | } |
| 517 | |
| 518 | // ---------------------------------------------------------------------------- |
| 519 | // MicrophoneIsInitialized |
| 520 | // ---------------------------------------------------------------------------- |
| 521 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 522 | bool AudioDeviceModuleImpl::MicrophoneIsInitialized() const { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 523 | LOG(INFO) << __FUNCTION__; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 524 | CHECK_INITIALIZED_BOOL(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 525 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 526 | bool isInitialized = _ptrAudioDevice->MicrophoneIsInitialized(); |
Max Morin | 2c332bb | 2016-07-04 09:03:42 +0200 | [diff] [blame] | 527 | LOG(INFO) << "output: " << isInitialized; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 528 | return (isInitialized); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 529 | } |
| 530 | |
| 531 | // ---------------------------------------------------------------------------- |
| 532 | // MaxSpeakerVolume |
| 533 | // ---------------------------------------------------------------------------- |
| 534 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 535 | int32_t AudioDeviceModuleImpl::MaxSpeakerVolume(uint32_t* maxVolume) const { |
| 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 | uint32_t maxVol(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->MaxSpeakerVolume(maxVol) == -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 | *maxVolume = maxVol; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 545 | return (0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 546 | } |
| 547 | |
| 548 | // ---------------------------------------------------------------------------- |
| 549 | // MinSpeakerVolume |
| 550 | // ---------------------------------------------------------------------------- |
| 551 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 552 | int32_t AudioDeviceModuleImpl::MinSpeakerVolume(uint32_t* minVolume) const { |
| 553 | CHECK_INITIALIZED(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 554 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 555 | uint32_t minVol(0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 556 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 557 | if (_ptrAudioDevice->MinSpeakerVolume(minVol) == -1) { |
| 558 | return -1; |
| 559 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 560 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 561 | *minVolume = minVol; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 562 | return (0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 563 | } |
| 564 | |
| 565 | // ---------------------------------------------------------------------------- |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 566 | // SpeakerMuteIsAvailable |
| 567 | // ---------------------------------------------------------------------------- |
| 568 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 569 | int32_t AudioDeviceModuleImpl::SpeakerMuteIsAvailable(bool* available) { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 570 | LOG(INFO) << __FUNCTION__; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 571 | CHECK_INITIALIZED(); |
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 | bool isAvailable(0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 574 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 575 | if (_ptrAudioDevice->SpeakerMuteIsAvailable(isAvailable) == -1) { |
| 576 | return -1; |
| 577 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 578 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 579 | *available = isAvailable; |
Max Morin | 2c332bb | 2016-07-04 09:03:42 +0200 | [diff] [blame] | 580 | LOG(INFO) << "output: " << isAvailable; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 581 | return (0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 582 | } |
| 583 | |
| 584 | // ---------------------------------------------------------------------------- |
| 585 | // SetSpeakerMute |
| 586 | // ---------------------------------------------------------------------------- |
| 587 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 588 | int32_t AudioDeviceModuleImpl::SetSpeakerMute(bool enable) { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 589 | LOG(INFO) << __FUNCTION__ << "(" << enable << ")"; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 590 | CHECK_INITIALIZED(); |
| 591 | return (_ptrAudioDevice->SetSpeakerMute(enable)); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 592 | } |
| 593 | |
| 594 | // ---------------------------------------------------------------------------- |
| 595 | // SpeakerMute |
| 596 | // ---------------------------------------------------------------------------- |
| 597 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 598 | int32_t AudioDeviceModuleImpl::SpeakerMute(bool* enabled) const { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 599 | LOG(INFO) << __FUNCTION__; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 600 | CHECK_INITIALIZED(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 601 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 602 | bool muted(false); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 603 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 604 | if (_ptrAudioDevice->SpeakerMute(muted) == -1) { |
| 605 | return -1; |
| 606 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 607 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 608 | *enabled = muted; |
Max Morin | 2c332bb | 2016-07-04 09:03:42 +0200 | [diff] [blame] | 609 | LOG(INFO) << "output: " << muted; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 610 | return (0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 611 | } |
| 612 | |
| 613 | // ---------------------------------------------------------------------------- |
| 614 | // MicrophoneMuteIsAvailable |
| 615 | // ---------------------------------------------------------------------------- |
| 616 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 617 | int32_t AudioDeviceModuleImpl::MicrophoneMuteIsAvailable(bool* available) { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 618 | LOG(INFO) << __FUNCTION__; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 619 | CHECK_INITIALIZED(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 620 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 621 | bool isAvailable(0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 622 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 623 | if (_ptrAudioDevice->MicrophoneMuteIsAvailable(isAvailable) == -1) { |
| 624 | return -1; |
| 625 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 626 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 627 | *available = isAvailable; |
Max Morin | 2c332bb | 2016-07-04 09:03:42 +0200 | [diff] [blame] | 628 | LOG(INFO) << "output: " << isAvailable; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 629 | return (0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 630 | } |
| 631 | |
| 632 | // ---------------------------------------------------------------------------- |
| 633 | // SetMicrophoneMute |
| 634 | // ---------------------------------------------------------------------------- |
| 635 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 636 | int32_t AudioDeviceModuleImpl::SetMicrophoneMute(bool enable) { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 637 | LOG(INFO) << __FUNCTION__ << "(" << enable << ")"; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 638 | CHECK_INITIALIZED(); |
| 639 | return (_ptrAudioDevice->SetMicrophoneMute(enable)); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 640 | } |
| 641 | |
| 642 | // ---------------------------------------------------------------------------- |
| 643 | // MicrophoneMute |
| 644 | // ---------------------------------------------------------------------------- |
| 645 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 646 | int32_t AudioDeviceModuleImpl::MicrophoneMute(bool* enabled) const { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 647 | LOG(INFO) << __FUNCTION__; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 648 | CHECK_INITIALIZED(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 649 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 650 | bool muted(false); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 651 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 652 | if (_ptrAudioDevice->MicrophoneMute(muted) == -1) { |
| 653 | return -1; |
| 654 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 655 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 656 | *enabled = muted; |
Max Morin | 2c332bb | 2016-07-04 09:03:42 +0200 | [diff] [blame] | 657 | LOG(INFO) << "output: " << muted; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 658 | return (0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 659 | } |
| 660 | |
| 661 | // ---------------------------------------------------------------------------- |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 662 | // MicrophoneVolumeIsAvailable |
| 663 | // ---------------------------------------------------------------------------- |
| 664 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 665 | int32_t AudioDeviceModuleImpl::MicrophoneVolumeIsAvailable(bool* available) { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 666 | LOG(INFO) << __FUNCTION__; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 667 | CHECK_INITIALIZED(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 668 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 669 | bool isAvailable(0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 670 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 671 | if (_ptrAudioDevice->MicrophoneVolumeIsAvailable(isAvailable) == -1) { |
| 672 | return -1; |
| 673 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 674 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 675 | *available = isAvailable; |
Max Morin | 2c332bb | 2016-07-04 09:03:42 +0200 | [diff] [blame] | 676 | LOG(INFO) << "output: " << isAvailable; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 677 | return (0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 678 | } |
| 679 | |
| 680 | // ---------------------------------------------------------------------------- |
| 681 | // SetMicrophoneVolume |
| 682 | // ---------------------------------------------------------------------------- |
| 683 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 684 | int32_t AudioDeviceModuleImpl::SetMicrophoneVolume(uint32_t volume) { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 685 | LOG(INFO) << __FUNCTION__ << "(" << volume << ")"; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 686 | CHECK_INITIALIZED(); |
| 687 | return (_ptrAudioDevice->SetMicrophoneVolume(volume)); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 688 | } |
| 689 | |
| 690 | // ---------------------------------------------------------------------------- |
| 691 | // MicrophoneVolume |
| 692 | // ---------------------------------------------------------------------------- |
| 693 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 694 | int32_t AudioDeviceModuleImpl::MicrophoneVolume(uint32_t* volume) const { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 695 | LOG(INFO) << __FUNCTION__; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 696 | CHECK_INITIALIZED(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 697 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 698 | uint32_t level(0); |
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 | if (_ptrAudioDevice->MicrophoneVolume(level) == -1) { |
| 701 | return -1; |
| 702 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 703 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 704 | *volume = level; |
Max Morin | 2c332bb | 2016-07-04 09:03:42 +0200 | [diff] [blame] | 705 | LOG(INFO) << "output: " << *volume; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 706 | return (0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 707 | } |
| 708 | |
| 709 | // ---------------------------------------------------------------------------- |
| 710 | // StereoRecordingIsAvailable |
| 711 | // ---------------------------------------------------------------------------- |
| 712 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 713 | int32_t AudioDeviceModuleImpl::StereoRecordingIsAvailable( |
| 714 | bool* available) const { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 715 | LOG(INFO) << __FUNCTION__; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 716 | CHECK_INITIALIZED(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 717 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 718 | bool isAvailable(0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 719 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 720 | if (_ptrAudioDevice->StereoRecordingIsAvailable(isAvailable) == -1) { |
| 721 | return -1; |
| 722 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 723 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 724 | *available = isAvailable; |
Max Morin | 2c332bb | 2016-07-04 09:03:42 +0200 | [diff] [blame] | 725 | LOG(INFO) << "output: " << isAvailable; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 726 | return (0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 727 | } |
| 728 | |
| 729 | // ---------------------------------------------------------------------------- |
| 730 | // SetStereoRecording |
| 731 | // ---------------------------------------------------------------------------- |
| 732 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 733 | int32_t AudioDeviceModuleImpl::SetStereoRecording(bool enable) { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 734 | LOG(INFO) << __FUNCTION__ << "(" << enable << ")"; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 735 | CHECK_INITIALIZED(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 736 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 737 | if (_ptrAudioDevice->RecordingIsInitialized()) { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 738 | LOG(WARNING) << "recording in stereo is not supported"; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 739 | return -1; |
| 740 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 741 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 742 | if (_ptrAudioDevice->SetStereoRecording(enable) == -1) { |
Max Morin | 2c332bb | 2016-07-04 09:03:42 +0200 | [diff] [blame] | 743 | LOG(WARNING) << "failed to change stereo recording"; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 744 | return -1; |
| 745 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 746 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 747 | int8_t nChannels(1); |
| 748 | if (enable) { |
| 749 | nChannels = 2; |
| 750 | } |
| 751 | _audioDeviceBuffer.SetRecordingChannels(nChannels); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 752 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 753 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 754 | } |
| 755 | |
| 756 | // ---------------------------------------------------------------------------- |
| 757 | // StereoRecording |
| 758 | // ---------------------------------------------------------------------------- |
| 759 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 760 | int32_t AudioDeviceModuleImpl::StereoRecording(bool* enabled) const { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 761 | LOG(INFO) << __FUNCTION__; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 762 | CHECK_INITIALIZED(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 763 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 764 | bool stereo(false); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 765 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 766 | if (_ptrAudioDevice->StereoRecording(stereo) == -1) { |
| 767 | return -1; |
| 768 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 769 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 770 | *enabled = stereo; |
Max Morin | 2c332bb | 2016-07-04 09:03:42 +0200 | [diff] [blame] | 771 | LOG(INFO) << "output: " << stereo; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 772 | return (0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 773 | } |
| 774 | |
| 775 | // ---------------------------------------------------------------------------- |
| 776 | // SetRecordingChannel |
| 777 | // ---------------------------------------------------------------------------- |
| 778 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 779 | int32_t AudioDeviceModuleImpl::SetRecordingChannel(const ChannelType channel) { |
| 780 | if (channel == kChannelBoth) { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 781 | LOG(INFO) << __FUNCTION__ << "(both)"; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 782 | } else if (channel == kChannelLeft) { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 783 | LOG(INFO) << __FUNCTION__ << "(left)"; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 784 | } else { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 785 | LOG(INFO) << __FUNCTION__ << "(right)"; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 786 | } |
| 787 | CHECK_INITIALIZED(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 788 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 789 | bool stereo(false); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 790 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 791 | if (_ptrAudioDevice->StereoRecording(stereo) == -1) { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 792 | LOG(WARNING) << "recording in stereo is not supported"; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 793 | return -1; |
| 794 | } |
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 | return (_audioDeviceBuffer.SetRecordingChannel(channel)); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 797 | } |
| 798 | |
| 799 | // ---------------------------------------------------------------------------- |
| 800 | // RecordingChannel |
| 801 | // ---------------------------------------------------------------------------- |
| 802 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 803 | int32_t AudioDeviceModuleImpl::RecordingChannel(ChannelType* channel) const { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 804 | LOG(INFO) << __FUNCTION__; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 805 | CHECK_INITIALIZED(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 806 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 807 | ChannelType chType; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 808 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 809 | if (_audioDeviceBuffer.RecordingChannel(chType) == -1) { |
| 810 | return -1; |
| 811 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 812 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 813 | *channel = chType; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 814 | if (*channel == kChannelBoth) { |
Max Morin | 2c332bb | 2016-07-04 09:03:42 +0200 | [diff] [blame] | 815 | LOG(INFO) << "output: both"; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 816 | } else if (*channel == kChannelLeft) { |
Max Morin | 2c332bb | 2016-07-04 09:03:42 +0200 | [diff] [blame] | 817 | LOG(INFO) << "output: left"; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 818 | } else { |
Max Morin | 2c332bb | 2016-07-04 09:03:42 +0200 | [diff] [blame] | 819 | LOG(INFO) << "output: right"; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 820 | } |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 821 | return (0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 822 | } |
| 823 | |
| 824 | // ---------------------------------------------------------------------------- |
| 825 | // StereoPlayoutIsAvailable |
| 826 | // ---------------------------------------------------------------------------- |
| 827 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 828 | int32_t AudioDeviceModuleImpl::StereoPlayoutIsAvailable(bool* available) const { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 829 | LOG(INFO) << __FUNCTION__; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 830 | CHECK_INITIALIZED(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 831 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 832 | bool isAvailable(0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 833 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 834 | if (_ptrAudioDevice->StereoPlayoutIsAvailable(isAvailable) == -1) { |
| 835 | return -1; |
| 836 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 837 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 838 | *available = isAvailable; |
Max Morin | 2c332bb | 2016-07-04 09:03:42 +0200 | [diff] [blame] | 839 | LOG(INFO) << "output: " << isAvailable; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 840 | return (0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 841 | } |
| 842 | |
| 843 | // ---------------------------------------------------------------------------- |
| 844 | // SetStereoPlayout |
| 845 | // ---------------------------------------------------------------------------- |
| 846 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 847 | int32_t AudioDeviceModuleImpl::SetStereoPlayout(bool enable) { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 848 | LOG(INFO) << __FUNCTION__ << "(" << enable << ")"; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 849 | CHECK_INITIALIZED(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 850 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 851 | if (_ptrAudioDevice->PlayoutIsInitialized()) { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 852 | LOG(LERROR) |
| 853 | << "unable to set stereo mode while playing side is initialized"; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 854 | return -1; |
| 855 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 856 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 857 | if (_ptrAudioDevice->SetStereoPlayout(enable)) { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 858 | LOG(WARNING) << "stereo playout is not supported"; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 859 | return -1; |
| 860 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 861 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 862 | int8_t nChannels(1); |
| 863 | if (enable) { |
| 864 | nChannels = 2; |
| 865 | } |
| 866 | _audioDeviceBuffer.SetPlayoutChannels(nChannels); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 867 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 868 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 869 | } |
| 870 | |
| 871 | // ---------------------------------------------------------------------------- |
| 872 | // StereoPlayout |
| 873 | // ---------------------------------------------------------------------------- |
| 874 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 875 | int32_t AudioDeviceModuleImpl::StereoPlayout(bool* enabled) const { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 876 | LOG(INFO) << __FUNCTION__; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 877 | CHECK_INITIALIZED(); |
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 | bool stereo(false); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 880 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 881 | if (_ptrAudioDevice->StereoPlayout(stereo) == -1) { |
| 882 | return -1; |
| 883 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 884 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 885 | *enabled = stereo; |
Max Morin | 2c332bb | 2016-07-04 09:03:42 +0200 | [diff] [blame] | 886 | LOG(INFO) << "output: " << stereo; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 887 | return (0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 888 | } |
| 889 | |
| 890 | // ---------------------------------------------------------------------------- |
| 891 | // SetAGC |
| 892 | // ---------------------------------------------------------------------------- |
| 893 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 894 | int32_t AudioDeviceModuleImpl::SetAGC(bool enable) { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 895 | LOG(INFO) << __FUNCTION__ << "(" << enable << ")"; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 896 | CHECK_INITIALIZED(); |
| 897 | return (_ptrAudioDevice->SetAGC(enable)); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 898 | } |
| 899 | |
| 900 | // ---------------------------------------------------------------------------- |
| 901 | // AGC |
| 902 | // ---------------------------------------------------------------------------- |
| 903 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 904 | bool AudioDeviceModuleImpl::AGC() const { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 905 | LOG(INFO) << __FUNCTION__; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 906 | CHECK_INITIALIZED_BOOL(); |
| 907 | return (_ptrAudioDevice->AGC()); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 908 | } |
| 909 | |
| 910 | // ---------------------------------------------------------------------------- |
| 911 | // PlayoutIsAvailable |
| 912 | // ---------------------------------------------------------------------------- |
| 913 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 914 | int32_t AudioDeviceModuleImpl::PlayoutIsAvailable(bool* available) { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 915 | LOG(INFO) << __FUNCTION__; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 916 | CHECK_INITIALIZED(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 917 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 918 | bool isAvailable(0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 919 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 920 | if (_ptrAudioDevice->PlayoutIsAvailable(isAvailable) == -1) { |
| 921 | return -1; |
| 922 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 923 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 924 | *available = isAvailable; |
Max Morin | 2c332bb | 2016-07-04 09:03:42 +0200 | [diff] [blame] | 925 | LOG(INFO) << "output: " << isAvailable; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 926 | return (0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 927 | } |
| 928 | |
| 929 | // ---------------------------------------------------------------------------- |
| 930 | // RecordingIsAvailable |
| 931 | // ---------------------------------------------------------------------------- |
| 932 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 933 | int32_t AudioDeviceModuleImpl::RecordingIsAvailable(bool* available) { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 934 | LOG(INFO) << __FUNCTION__; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 935 | CHECK_INITIALIZED(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 936 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 937 | bool isAvailable(0); |
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 | if (_ptrAudioDevice->RecordingIsAvailable(isAvailable) == -1) { |
| 940 | return -1; |
| 941 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 942 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 943 | *available = isAvailable; |
Max Morin | 2c332bb | 2016-07-04 09:03:42 +0200 | [diff] [blame] | 944 | LOG(INFO) << "output: " << isAvailable; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 945 | return (0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 946 | } |
| 947 | |
| 948 | // ---------------------------------------------------------------------------- |
| 949 | // MaxMicrophoneVolume |
| 950 | // ---------------------------------------------------------------------------- |
| 951 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 952 | int32_t AudioDeviceModuleImpl::MaxMicrophoneVolume(uint32_t* maxVolume) const { |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 953 | CHECK_INITIALIZED(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 954 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 955 | uint32_t maxVol(0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 956 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 957 | if (_ptrAudioDevice->MaxMicrophoneVolume(maxVol) == -1) { |
| 958 | return -1; |
| 959 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 960 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 961 | *maxVolume = maxVol; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 962 | return (0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 963 | } |
| 964 | |
| 965 | // ---------------------------------------------------------------------------- |
| 966 | // MinMicrophoneVolume |
| 967 | // ---------------------------------------------------------------------------- |
| 968 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 969 | int32_t AudioDeviceModuleImpl::MinMicrophoneVolume(uint32_t* minVolume) const { |
| 970 | CHECK_INITIALIZED(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 971 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 972 | uint32_t minVol(0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 973 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 974 | if (_ptrAudioDevice->MinMicrophoneVolume(minVol) == -1) { |
| 975 | return -1; |
| 976 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 977 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 978 | *minVolume = minVol; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 979 | return (0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 980 | } |
| 981 | |
| 982 | // ---------------------------------------------------------------------------- |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 983 | // PlayoutDevices |
| 984 | // ---------------------------------------------------------------------------- |
| 985 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 986 | int16_t AudioDeviceModuleImpl::PlayoutDevices() { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 987 | LOG(INFO) << __FUNCTION__; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 988 | CHECK_INITIALIZED(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 989 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 990 | uint16_t nPlayoutDevices = _ptrAudioDevice->PlayoutDevices(); |
Max Morin | 2c332bb | 2016-07-04 09:03:42 +0200 | [diff] [blame] | 991 | LOG(INFO) << "output: " << nPlayoutDevices; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 992 | return ((int16_t)(nPlayoutDevices)); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 993 | } |
| 994 | |
| 995 | // ---------------------------------------------------------------------------- |
| 996 | // SetPlayoutDevice I (II) |
| 997 | // ---------------------------------------------------------------------------- |
| 998 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 999 | int32_t AudioDeviceModuleImpl::SetPlayoutDevice(uint16_t index) { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1000 | LOG(INFO) << __FUNCTION__ << "(" << index << ")"; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1001 | CHECK_INITIALIZED(); |
| 1002 | return (_ptrAudioDevice->SetPlayoutDevice(index)); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1003 | } |
| 1004 | |
| 1005 | // ---------------------------------------------------------------------------- |
| 1006 | // SetPlayoutDevice II (II) |
| 1007 | // ---------------------------------------------------------------------------- |
| 1008 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1009 | int32_t AudioDeviceModuleImpl::SetPlayoutDevice(WindowsDeviceType device) { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1010 | LOG(INFO) << __FUNCTION__; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1011 | CHECK_INITIALIZED(); |
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 | return (_ptrAudioDevice->SetPlayoutDevice(device)); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1014 | } |
| 1015 | |
| 1016 | // ---------------------------------------------------------------------------- |
| 1017 | // PlayoutDeviceName |
| 1018 | // ---------------------------------------------------------------------------- |
| 1019 | |
pbos@webrtc.org | 2550988 | 2013-04-09 10:30:35 +0000 | [diff] [blame] | 1020 | int32_t AudioDeviceModuleImpl::PlayoutDeviceName( |
| 1021 | uint16_t index, |
leozwang@webrtc.org | 28f3913 | 2012-03-01 18:01:48 +0000 | [diff] [blame] | 1022 | char name[kAdmMaxDeviceNameSize], |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1023 | char guid[kAdmMaxGuidSize]) { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1024 | LOG(INFO) << __FUNCTION__ << "(" << index << ", ...)"; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1025 | CHECK_INITIALIZED(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1026 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1027 | if (name == NULL) { |
| 1028 | _lastError = kAdmErrArgument; |
| 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->PlayoutDeviceName(index, name, guid) == -1) { |
| 1033 | return -1; |
| 1034 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1035 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1036 | if (name != NULL) { |
Max Morin | 2c332bb | 2016-07-04 09:03:42 +0200 | [diff] [blame] | 1037 | LOG(INFO) << "output: name = " << name; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1038 | } |
| 1039 | if (guid != NULL) { |
Max Morin | 2c332bb | 2016-07-04 09:03:42 +0200 | [diff] [blame] | 1040 | LOG(INFO) << "output: guid = " << guid; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1041 | } |
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 | // RecordingDeviceName |
| 1048 | // ---------------------------------------------------------------------------- |
| 1049 | |
pbos@webrtc.org | 2550988 | 2013-04-09 10:30:35 +0000 | [diff] [blame] | 1050 | int32_t AudioDeviceModuleImpl::RecordingDeviceName( |
| 1051 | uint16_t index, |
leozwang@webrtc.org | 28f3913 | 2012-03-01 18:01:48 +0000 | [diff] [blame] | 1052 | char name[kAdmMaxDeviceNameSize], |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1053 | char guid[kAdmMaxGuidSize]) { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1054 | LOG(INFO) << __FUNCTION__ << "(" << index << ", ...)"; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1055 | CHECK_INITIALIZED(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1056 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1057 | if (name == NULL) { |
| 1058 | _lastError = kAdmErrArgument; |
| 1059 | return -1; |
| 1060 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1061 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1062 | if (_ptrAudioDevice->RecordingDeviceName(index, name, guid) == -1) { |
| 1063 | return -1; |
| 1064 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1065 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1066 | if (name != NULL) { |
Max Morin | 2c332bb | 2016-07-04 09:03:42 +0200 | [diff] [blame] | 1067 | LOG(INFO) << "output: name = " << name; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1068 | } |
| 1069 | if (guid != NULL) { |
Max Morin | 2c332bb | 2016-07-04 09:03:42 +0200 | [diff] [blame] | 1070 | LOG(INFO) << "output: guid = " << guid; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1071 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1072 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1073 | return (0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1074 | } |
| 1075 | |
| 1076 | // ---------------------------------------------------------------------------- |
| 1077 | // RecordingDevices |
| 1078 | // ---------------------------------------------------------------------------- |
| 1079 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1080 | int16_t AudioDeviceModuleImpl::RecordingDevices() { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1081 | LOG(INFO) << __FUNCTION__; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1082 | CHECK_INITIALIZED(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1083 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1084 | uint16_t nRecordingDevices = _ptrAudioDevice->RecordingDevices(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1085 | |
Max Morin | 2c332bb | 2016-07-04 09:03:42 +0200 | [diff] [blame] | 1086 | LOG(INFO) << "output: " << nRecordingDevices; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1087 | return ((int16_t)nRecordingDevices); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1088 | } |
| 1089 | |
| 1090 | // ---------------------------------------------------------------------------- |
| 1091 | // SetRecordingDevice I (II) |
| 1092 | // ---------------------------------------------------------------------------- |
| 1093 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1094 | int32_t AudioDeviceModuleImpl::SetRecordingDevice(uint16_t index) { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1095 | LOG(INFO) << __FUNCTION__ << "(" << index << ")"; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1096 | CHECK_INITIALIZED(); |
| 1097 | return (_ptrAudioDevice->SetRecordingDevice(index)); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1098 | } |
| 1099 | |
| 1100 | // ---------------------------------------------------------------------------- |
| 1101 | // SetRecordingDevice II (II) |
| 1102 | // ---------------------------------------------------------------------------- |
| 1103 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1104 | int32_t AudioDeviceModuleImpl::SetRecordingDevice(WindowsDeviceType device) { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1105 | LOG(INFO) << __FUNCTION__; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1106 | CHECK_INITIALIZED(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1107 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1108 | return (_ptrAudioDevice->SetRecordingDevice(device)); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1109 | } |
| 1110 | |
| 1111 | // ---------------------------------------------------------------------------- |
| 1112 | // InitPlayout |
| 1113 | // ---------------------------------------------------------------------------- |
| 1114 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1115 | int32_t AudioDeviceModuleImpl::InitPlayout() { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1116 | LOG(INFO) << __FUNCTION__; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1117 | CHECK_INITIALIZED(); |
maxmorin | 8c695b4 | 2016-07-25 02:46:44 -0700 | [diff] [blame] | 1118 | if (PlayoutIsInitialized()) { |
| 1119 | return 0; |
| 1120 | } |
Max Morin | 84cab20 | 2016-07-01 13:35:19 +0200 | [diff] [blame] | 1121 | int32_t result = _ptrAudioDevice->InitPlayout(); |
| 1122 | LOG(INFO) << "output: " << result; |
| 1123 | RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.InitPlayoutSuccess", |
| 1124 | static_cast<int>(result == 0)); |
| 1125 | return result; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1126 | } |
| 1127 | |
| 1128 | // ---------------------------------------------------------------------------- |
| 1129 | // InitRecording |
| 1130 | // ---------------------------------------------------------------------------- |
| 1131 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1132 | int32_t AudioDeviceModuleImpl::InitRecording() { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1133 | LOG(INFO) << __FUNCTION__; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1134 | CHECK_INITIALIZED(); |
maxmorin | 8c695b4 | 2016-07-25 02:46:44 -0700 | [diff] [blame] | 1135 | if (RecordingIsInitialized()) { |
| 1136 | return 0; |
| 1137 | } |
Max Morin | 84cab20 | 2016-07-01 13:35:19 +0200 | [diff] [blame] | 1138 | int32_t result = _ptrAudioDevice->InitRecording(); |
| 1139 | LOG(INFO) << "output: " << result; |
| 1140 | RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.InitRecordingSuccess", |
| 1141 | static_cast<int>(result == 0)); |
| 1142 | return result; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1143 | } |
| 1144 | |
| 1145 | // ---------------------------------------------------------------------------- |
| 1146 | // PlayoutIsInitialized |
| 1147 | // ---------------------------------------------------------------------------- |
| 1148 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1149 | bool AudioDeviceModuleImpl::PlayoutIsInitialized() const { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1150 | LOG(INFO) << __FUNCTION__; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1151 | CHECK_INITIALIZED_BOOL(); |
| 1152 | return (_ptrAudioDevice->PlayoutIsInitialized()); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1153 | } |
| 1154 | |
| 1155 | // ---------------------------------------------------------------------------- |
| 1156 | // RecordingIsInitialized |
| 1157 | // ---------------------------------------------------------------------------- |
| 1158 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1159 | bool AudioDeviceModuleImpl::RecordingIsInitialized() const { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1160 | LOG(INFO) << __FUNCTION__; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1161 | CHECK_INITIALIZED_BOOL(); |
| 1162 | return (_ptrAudioDevice->RecordingIsInitialized()); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1163 | } |
| 1164 | |
| 1165 | // ---------------------------------------------------------------------------- |
| 1166 | // StartPlayout |
| 1167 | // ---------------------------------------------------------------------------- |
| 1168 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1169 | int32_t AudioDeviceModuleImpl::StartPlayout() { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1170 | LOG(INFO) << __FUNCTION__; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1171 | CHECK_INITIALIZED(); |
maxmorin | 8c695b4 | 2016-07-25 02:46:44 -0700 | [diff] [blame] | 1172 | if (Playing()) { |
| 1173 | return 0; |
| 1174 | } |
henrika | ba156cf | 2016-10-31 08:18:50 -0700 | [diff] [blame] | 1175 | _audioDeviceBuffer.StartPlayout(); |
Max Morin | 84cab20 | 2016-07-01 13:35:19 +0200 | [diff] [blame] | 1176 | int32_t result = _ptrAudioDevice->StartPlayout(); |
| 1177 | LOG(INFO) << "output: " << result; |
| 1178 | RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StartPlayoutSuccess", |
| 1179 | static_cast<int>(result == 0)); |
| 1180 | return result; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1181 | } |
| 1182 | |
| 1183 | // ---------------------------------------------------------------------------- |
| 1184 | // StopPlayout |
| 1185 | // ---------------------------------------------------------------------------- |
| 1186 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1187 | int32_t AudioDeviceModuleImpl::StopPlayout() { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1188 | LOG(INFO) << __FUNCTION__; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1189 | CHECK_INITIALIZED(); |
Max Morin | 84cab20 | 2016-07-01 13:35:19 +0200 | [diff] [blame] | 1190 | int32_t result = _ptrAudioDevice->StopPlayout(); |
henrika | ba156cf | 2016-10-31 08:18:50 -0700 | [diff] [blame] | 1191 | _audioDeviceBuffer.StopPlayout(); |
Max Morin | 84cab20 | 2016-07-01 13:35:19 +0200 | [diff] [blame] | 1192 | LOG(INFO) << "output: " << result; |
| 1193 | RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StopPlayoutSuccess", |
| 1194 | static_cast<int>(result == 0)); |
| 1195 | return result; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1196 | } |
| 1197 | |
| 1198 | // ---------------------------------------------------------------------------- |
| 1199 | // Playing |
| 1200 | // ---------------------------------------------------------------------------- |
| 1201 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1202 | bool AudioDeviceModuleImpl::Playing() const { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1203 | LOG(INFO) << __FUNCTION__; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1204 | CHECK_INITIALIZED_BOOL(); |
| 1205 | return (_ptrAudioDevice->Playing()); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1206 | } |
| 1207 | |
| 1208 | // ---------------------------------------------------------------------------- |
| 1209 | // StartRecording |
| 1210 | // ---------------------------------------------------------------------------- |
| 1211 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1212 | int32_t AudioDeviceModuleImpl::StartRecording() { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1213 | LOG(INFO) << __FUNCTION__; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1214 | CHECK_INITIALIZED(); |
maxmorin | 8c695b4 | 2016-07-25 02:46:44 -0700 | [diff] [blame] | 1215 | if (Recording()) { |
| 1216 | return 0; |
| 1217 | } |
henrika | ba156cf | 2016-10-31 08:18:50 -0700 | [diff] [blame] | 1218 | _audioDeviceBuffer.StartRecording(); |
Max Morin | 84cab20 | 2016-07-01 13:35:19 +0200 | [diff] [blame] | 1219 | int32_t result = _ptrAudioDevice->StartRecording(); |
| 1220 | LOG(INFO) << "output: " << result; |
| 1221 | RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StartRecordingSuccess", |
| 1222 | static_cast<int>(result == 0)); |
| 1223 | return result; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1224 | } |
| 1225 | // ---------------------------------------------------------------------------- |
| 1226 | // StopRecording |
| 1227 | // ---------------------------------------------------------------------------- |
| 1228 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1229 | int32_t AudioDeviceModuleImpl::StopRecording() { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1230 | LOG(INFO) << __FUNCTION__; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1231 | CHECK_INITIALIZED(); |
Max Morin | 84cab20 | 2016-07-01 13:35:19 +0200 | [diff] [blame] | 1232 | int32_t result = _ptrAudioDevice->StopRecording(); |
henrika | ba156cf | 2016-10-31 08:18:50 -0700 | [diff] [blame] | 1233 | _audioDeviceBuffer.StopRecording(); |
Max Morin | 84cab20 | 2016-07-01 13:35:19 +0200 | [diff] [blame] | 1234 | LOG(INFO) << "output: " << result; |
| 1235 | RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.StopRecordingSuccess", |
| 1236 | static_cast<int>(result == 0)); |
| 1237 | return result; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1238 | } |
| 1239 | |
| 1240 | // ---------------------------------------------------------------------------- |
| 1241 | // Recording |
| 1242 | // ---------------------------------------------------------------------------- |
| 1243 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1244 | bool AudioDeviceModuleImpl::Recording() const { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1245 | LOG(INFO) << __FUNCTION__; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1246 | CHECK_INITIALIZED_BOOL(); |
| 1247 | return (_ptrAudioDevice->Recording()); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1248 | } |
| 1249 | |
| 1250 | // ---------------------------------------------------------------------------- |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1251 | // RegisterAudioCallback |
| 1252 | // ---------------------------------------------------------------------------- |
| 1253 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1254 | int32_t AudioDeviceModuleImpl::RegisterAudioCallback( |
| 1255 | AudioTransport* audioCallback) { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1256 | LOG(INFO) << __FUNCTION__; |
kthelgason | 6bfe49c | 2017-03-30 01:14:41 -0700 | [diff] [blame] | 1257 | rtc::CritScope lock(&_critSectAudioCb); |
henrika | f502222 | 2016-11-07 15:56:59 +0100 | [diff] [blame] | 1258 | return _audioDeviceBuffer.RegisterAudioCallback(audioCallback); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1259 | } |
| 1260 | |
| 1261 | // ---------------------------------------------------------------------------- |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1262 | // PlayoutDelay |
| 1263 | // ---------------------------------------------------------------------------- |
| 1264 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1265 | int32_t AudioDeviceModuleImpl::PlayoutDelay(uint16_t* delayMS) const { |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1266 | CHECK_INITIALIZED(); |
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 | uint16_t delay(0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1269 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1270 | if (_ptrAudioDevice->PlayoutDelay(delay) == -1) { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1271 | LOG(LERROR) << "failed to retrieve the playout delay"; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1272 | return -1; |
| 1273 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1274 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1275 | *delayMS = delay; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1276 | return (0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1277 | } |
| 1278 | |
| 1279 | // ---------------------------------------------------------------------------- |
| 1280 | // RecordingDelay |
| 1281 | // ---------------------------------------------------------------------------- |
| 1282 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1283 | int32_t AudioDeviceModuleImpl::RecordingDelay(uint16_t* delayMS) const { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1284 | LOG(INFO) << __FUNCTION__; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1285 | CHECK_INITIALIZED(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1286 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1287 | uint16_t delay(0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1288 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1289 | if (_ptrAudioDevice->RecordingDelay(delay) == -1) { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1290 | LOG(LERROR) << "failed to retrieve the recording delay"; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1291 | return -1; |
| 1292 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1293 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1294 | *delayMS = delay; |
Max Morin | 2c332bb | 2016-07-04 09:03:42 +0200 | [diff] [blame] | 1295 | LOG(INFO) << "output: " << *delayMS; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1296 | return (0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1297 | } |
| 1298 | |
| 1299 | // ---------------------------------------------------------------------------- |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1300 | // SetRecordingSampleRate |
| 1301 | // ---------------------------------------------------------------------------- |
| 1302 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1303 | int32_t AudioDeviceModuleImpl::SetRecordingSampleRate( |
| 1304 | const uint32_t samplesPerSec) { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1305 | LOG(INFO) << __FUNCTION__ << "(" << samplesPerSec << ")"; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1306 | CHECK_INITIALIZED(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1307 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1308 | if (_ptrAudioDevice->SetRecordingSampleRate(samplesPerSec) != 0) { |
| 1309 | return -1; |
| 1310 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1311 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1312 | return (0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1313 | } |
| 1314 | |
| 1315 | // ---------------------------------------------------------------------------- |
| 1316 | // RecordingSampleRate |
| 1317 | // ---------------------------------------------------------------------------- |
| 1318 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1319 | int32_t AudioDeviceModuleImpl::RecordingSampleRate( |
| 1320 | uint32_t* samplesPerSec) const { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1321 | LOG(INFO) << __FUNCTION__; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1322 | CHECK_INITIALIZED(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1323 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1324 | int32_t sampleRate = _audioDeviceBuffer.RecordingSampleRate(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1325 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1326 | if (sampleRate == -1) { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1327 | LOG(LERROR) << "failed to retrieve the sample rate"; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1328 | return -1; |
| 1329 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1330 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1331 | *samplesPerSec = sampleRate; |
Max Morin | 2c332bb | 2016-07-04 09:03:42 +0200 | [diff] [blame] | 1332 | LOG(INFO) << "output: " << *samplesPerSec; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1333 | return (0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1334 | } |
| 1335 | |
| 1336 | // ---------------------------------------------------------------------------- |
| 1337 | // SetPlayoutSampleRate |
| 1338 | // ---------------------------------------------------------------------------- |
| 1339 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1340 | int32_t AudioDeviceModuleImpl::SetPlayoutSampleRate( |
| 1341 | const uint32_t samplesPerSec) { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1342 | LOG(INFO) << __FUNCTION__ << "(" << samplesPerSec << ")"; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1343 | CHECK_INITIALIZED(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1344 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1345 | if (_ptrAudioDevice->SetPlayoutSampleRate(samplesPerSec) != 0) { |
| 1346 | return -1; |
| 1347 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1348 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1349 | return (0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1350 | } |
| 1351 | |
| 1352 | // ---------------------------------------------------------------------------- |
| 1353 | // PlayoutSampleRate |
| 1354 | // ---------------------------------------------------------------------------- |
| 1355 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1356 | int32_t AudioDeviceModuleImpl::PlayoutSampleRate( |
| 1357 | uint32_t* samplesPerSec) const { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1358 | LOG(INFO) << __FUNCTION__; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1359 | CHECK_INITIALIZED(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1360 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1361 | int32_t sampleRate = _audioDeviceBuffer.PlayoutSampleRate(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1362 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1363 | if (sampleRate == -1) { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1364 | LOG(LERROR) << "failed to retrieve the sample rate"; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1365 | return -1; |
| 1366 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1367 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1368 | *samplesPerSec = sampleRate; |
Max Morin | 2c332bb | 2016-07-04 09:03:42 +0200 | [diff] [blame] | 1369 | LOG(INFO) << "output: " << *samplesPerSec; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1370 | return (0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1371 | } |
| 1372 | |
| 1373 | // ---------------------------------------------------------------------------- |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1374 | // SetLoudspeakerStatus |
| 1375 | // ---------------------------------------------------------------------------- |
| 1376 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1377 | int32_t AudioDeviceModuleImpl::SetLoudspeakerStatus(bool enable) { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1378 | LOG(INFO) << __FUNCTION__ << "(" << enable << ")"; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1379 | CHECK_INITIALIZED(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1380 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1381 | if (_ptrAudioDevice->SetLoudspeakerStatus(enable) != 0) { |
| 1382 | return -1; |
| 1383 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1384 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1385 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1386 | } |
| 1387 | |
| 1388 | // ---------------------------------------------------------------------------- |
| 1389 | // GetLoudspeakerStatus |
| 1390 | // ---------------------------------------------------------------------------- |
| 1391 | |
henrika | c14f5ff | 2015-09-23 14:08:33 +0200 | [diff] [blame] | 1392 | int32_t AudioDeviceModuleImpl::GetLoudspeakerStatus(bool* enabled) const { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1393 | LOG(INFO) << __FUNCTION__; |
henrika@webrtc.org | a954c07 | 2014-12-09 16:22:09 +0000 | [diff] [blame] | 1394 | CHECK_INITIALIZED(); |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1395 | int32_t ok = 0; |
henrika | c14f5ff | 2015-09-23 14:08:33 +0200 | [diff] [blame] | 1396 | if (_ptrAudioDevice->GetLoudspeakerStatus(*enabled) != 0) { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1397 | ok = -1; |
henrika | c14f5ff | 2015-09-23 14:08:33 +0200 | [diff] [blame] | 1398 | } |
Max Morin | 2c332bb | 2016-07-04 09:03:42 +0200 | [diff] [blame] | 1399 | LOG(INFO) << "output: " << ok; |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1400 | return ok; |
andrew@webrtc.org | a3c6d61 | 2011-09-13 17:17:49 +0000 | [diff] [blame] | 1401 | } |
| 1402 | |
henrika@webrtc.org | a954c07 | 2014-12-09 16:22:09 +0000 | [diff] [blame] | 1403 | bool AudioDeviceModuleImpl::BuiltInAECIsAvailable() const { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1404 | LOG(INFO) << __FUNCTION__; |
henrika@webrtc.org | a954c07 | 2014-12-09 16:22:09 +0000 | [diff] [blame] | 1405 | CHECK_INITIALIZED_BOOL(); |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1406 | bool isAvailable = _ptrAudioDevice->BuiltInAECIsAvailable(); |
Max Morin | 2c332bb | 2016-07-04 09:03:42 +0200 | [diff] [blame] | 1407 | LOG(INFO) << "output: " << isAvailable; |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1408 | return isAvailable; |
henrika@webrtc.org | a954c07 | 2014-12-09 16:22:09 +0000 | [diff] [blame] | 1409 | } |
| 1410 | |
henrika | c14f5ff | 2015-09-23 14:08:33 +0200 | [diff] [blame] | 1411 | int32_t AudioDeviceModuleImpl::EnableBuiltInAEC(bool enable) { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1412 | LOG(INFO) << __FUNCTION__ << "(" << enable << ")"; |
henrika | c14f5ff | 2015-09-23 14:08:33 +0200 | [diff] [blame] | 1413 | CHECK_INITIALIZED(); |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1414 | int32_t ok = _ptrAudioDevice->EnableBuiltInAEC(enable); |
Max Morin | 2c332bb | 2016-07-04 09:03:42 +0200 | [diff] [blame] | 1415 | LOG(INFO) << "output: " << ok; |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1416 | return ok; |
henrika | c14f5ff | 2015-09-23 14:08:33 +0200 | [diff] [blame] | 1417 | } |
| 1418 | |
| 1419 | bool AudioDeviceModuleImpl::BuiltInAGCIsAvailable() const { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1420 | LOG(INFO) << __FUNCTION__; |
henrika | c14f5ff | 2015-09-23 14:08:33 +0200 | [diff] [blame] | 1421 | CHECK_INITIALIZED_BOOL(); |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1422 | bool isAvailable = _ptrAudioDevice->BuiltInAGCIsAvailable(); |
Max Morin | 2c332bb | 2016-07-04 09:03:42 +0200 | [diff] [blame] | 1423 | LOG(INFO) << "output: " << isAvailable; |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1424 | return isAvailable; |
henrika | c14f5ff | 2015-09-23 14:08:33 +0200 | [diff] [blame] | 1425 | } |
| 1426 | |
| 1427 | int32_t AudioDeviceModuleImpl::EnableBuiltInAGC(bool enable) { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1428 | LOG(INFO) << __FUNCTION__ << "(" << enable << ")"; |
henrika | c14f5ff | 2015-09-23 14:08:33 +0200 | [diff] [blame] | 1429 | CHECK_INITIALIZED(); |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1430 | int32_t ok = _ptrAudioDevice->EnableBuiltInAGC(enable); |
Max Morin | 2c332bb | 2016-07-04 09:03:42 +0200 | [diff] [blame] | 1431 | LOG(INFO) << "output: " << ok; |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1432 | return ok; |
henrika | c14f5ff | 2015-09-23 14:08:33 +0200 | [diff] [blame] | 1433 | } |
| 1434 | |
| 1435 | bool AudioDeviceModuleImpl::BuiltInNSIsAvailable() const { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1436 | LOG(INFO) << __FUNCTION__; |
henrika | c14f5ff | 2015-09-23 14:08:33 +0200 | [diff] [blame] | 1437 | CHECK_INITIALIZED_BOOL(); |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1438 | bool isAvailable = _ptrAudioDevice->BuiltInNSIsAvailable(); |
Max Morin | 2c332bb | 2016-07-04 09:03:42 +0200 | [diff] [blame] | 1439 | LOG(INFO) << "output: " << isAvailable; |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1440 | return isAvailable; |
henrika | c14f5ff | 2015-09-23 14:08:33 +0200 | [diff] [blame] | 1441 | } |
| 1442 | |
| 1443 | int32_t AudioDeviceModuleImpl::EnableBuiltInNS(bool enable) { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1444 | LOG(INFO) << __FUNCTION__ << "(" << enable << ")"; |
henrika | c14f5ff | 2015-09-23 14:08:33 +0200 | [diff] [blame] | 1445 | CHECK_INITIALIZED(); |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1446 | int32_t ok = _ptrAudioDevice->EnableBuiltInNS(enable); |
Max Morin | 2c332bb | 2016-07-04 09:03:42 +0200 | [diff] [blame] | 1447 | LOG(INFO) << "output: " << ok; |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1448 | return ok; |
henrika | c14f5ff | 2015-09-23 14:08:33 +0200 | [diff] [blame] | 1449 | } |
| 1450 | |
maxmorin | 88e31a3 | 2016-08-16 00:56:09 -0700 | [diff] [blame] | 1451 | #if defined(WEBRTC_IOS) |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 1452 | int AudioDeviceModuleImpl::GetPlayoutAudioParameters( |
| 1453 | AudioParameters* params) const { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1454 | LOG(INFO) << __FUNCTION__; |
| 1455 | int r = _ptrAudioDevice->GetPlayoutAudioParameters(params); |
Max Morin | 2c332bb | 2016-07-04 09:03:42 +0200 | [diff] [blame] | 1456 | LOG(INFO) << "output: " << r; |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1457 | return r; |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 1458 | } |
| 1459 | |
| 1460 | int AudioDeviceModuleImpl::GetRecordAudioParameters( |
| 1461 | AudioParameters* params) const { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1462 | LOG(INFO) << __FUNCTION__; |
| 1463 | int r = _ptrAudioDevice->GetRecordAudioParameters(params); |
Max Morin | 2c332bb | 2016-07-04 09:03:42 +0200 | [diff] [blame] | 1464 | LOG(INFO) << "output: " << r; |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1465 | return r; |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 1466 | } |
maxmorin | 88e31a3 | 2016-08-16 00:56:09 -0700 | [diff] [blame] | 1467 | #endif // WEBRTC_IOS |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 1468 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1469 | // ============================================================================ |
| 1470 | // Private Methods |
| 1471 | // ============================================================================ |
| 1472 | |
| 1473 | // ---------------------------------------------------------------------------- |
| 1474 | // Platform |
| 1475 | // ---------------------------------------------------------------------------- |
| 1476 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1477 | AudioDeviceModuleImpl::PlatformType AudioDeviceModuleImpl::Platform() const { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1478 | LOG(INFO) << __FUNCTION__; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1479 | return _platformType; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1480 | } |
| 1481 | |
| 1482 | // ---------------------------------------------------------------------------- |
| 1483 | // PlatformAudioLayer |
| 1484 | // ---------------------------------------------------------------------------- |
| 1485 | |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1486 | AudioDeviceModule::AudioLayer AudioDeviceModuleImpl::PlatformAudioLayer() |
| 1487 | const { |
Max Morin | 098e6c5 | 2016-06-28 09:36:25 +0200 | [diff] [blame] | 1488 | LOG(INFO) << __FUNCTION__; |
Max Morin | 787eeed | 2016-06-23 10:42:07 +0200 | [diff] [blame] | 1489 | return _platformAudioLayer; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1490 | } |
| 1491 | |
| 1492 | } // namespace webrtc |