| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 break; | 75 break; |
| 76 } | 76 } |
| 77 | 77 |
| 78 // Save the audio device layer for Init() | 78 // Save the audio device layer for Init() |
| 79 _shared->set_audio_device_layer(wantedLayer); | 79 _shared->set_audio_device_layer(wantedLayer); |
| 80 | 80 |
| 81 return 0; | 81 return 0; |
| 82 } | 82 } |
| 83 | 83 |
| 84 int VoEHardwareImpl::GetAudioDeviceLayer(AudioLayers& audioLayer) { | 84 int VoEHardwareImpl::GetAudioDeviceLayer(AudioLayers& audioLayer) { |
| 85 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), | |
| 86 "GetAudioDeviceLayer(devices=?)"); | |
| 87 | |
| 88 // Can always be called regardless of VoE state | 85 // Can always be called regardless of VoE state |
| 89 | 86 |
| 90 AudioDeviceModule::AudioLayer activeLayer( | 87 AudioDeviceModule::AudioLayer activeLayer( |
| 91 AudioDeviceModule::kPlatformDefaultAudio); | 88 AudioDeviceModule::kPlatformDefaultAudio); |
| 92 | 89 |
| 93 if (_shared->audio_device()) { | 90 if (_shared->audio_device()) { |
| 94 // Get active audio layer from ADM | 91 // Get active audio layer from ADM |
| 95 if (_shared->audio_device()->ActiveAudioLayer(&activeLayer) != 0) { | 92 if (_shared->audio_device()->ActiveAudioLayer(&activeLayer) != 0) { |
| 96 _shared->SetLastError(VE_UNDEFINED_SC_ERR, kTraceError, | 93 _shared->SetLastError(VE_UNDEFINED_SC_ERR, kTraceError, |
| 97 " Audio Device error"); | 94 " Audio Device error"); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 117 audioLayer = kAudioLinuxAlsa; | 114 audioLayer = kAudioLinuxAlsa; |
| 118 break; | 115 break; |
| 119 case AudioDeviceModule::kLinuxPulseAudio: | 116 case AudioDeviceModule::kLinuxPulseAudio: |
| 120 audioLayer = kAudioLinuxPulse; | 117 audioLayer = kAudioLinuxPulse; |
| 121 break; | 118 break; |
| 122 default: | 119 default: |
| 123 _shared->SetLastError(VE_UNDEFINED_SC_ERR, kTraceError, | 120 _shared->SetLastError(VE_UNDEFINED_SC_ERR, kTraceError, |
| 124 " unknown audio layer"); | 121 " unknown audio layer"); |
| 125 } | 122 } |
| 126 | 123 |
| 127 WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_shared->instance_id(), -1), | |
| 128 " Output: audioLayer=%d", audioLayer); | |
| 129 | |
| 130 return 0; | 124 return 0; |
| 131 } | 125 } |
| 132 int VoEHardwareImpl::GetNumOfRecordingDevices(int& devices) { | 126 int VoEHardwareImpl::GetNumOfRecordingDevices(int& devices) { |
| 133 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), | |
| 134 "GetNumOfRecordingDevices(devices=?)"); | |
| 135 | |
| 136 if (!_shared->statistics().Initialized()) { | 127 if (!_shared->statistics().Initialized()) { |
| 137 _shared->SetLastError(VE_NOT_INITED, kTraceError); | 128 _shared->SetLastError(VE_NOT_INITED, kTraceError); |
| 138 return -1; | 129 return -1; |
| 139 } | 130 } |
| 140 | 131 |
| 141 devices = static_cast<int>(_shared->audio_device()->RecordingDevices()); | 132 devices = static_cast<int>(_shared->audio_device()->RecordingDevices()); |
| 142 | 133 |
| 143 WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_shared->instance_id(), -1), | |
| 144 " Output: devices=%d", devices); | |
| 145 | |
| 146 return 0; | 134 return 0; |
| 147 } | 135 } |
| 148 | 136 |
| 149 int VoEHardwareImpl::GetNumOfPlayoutDevices(int& devices) { | 137 int VoEHardwareImpl::GetNumOfPlayoutDevices(int& devices) { |
| 150 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), | |
| 151 "GetNumOfPlayoutDevices(devices=?)"); | |
| 152 | |
| 153 if (!_shared->statistics().Initialized()) { | 138 if (!_shared->statistics().Initialized()) { |
| 154 _shared->SetLastError(VE_NOT_INITED, kTraceError); | 139 _shared->SetLastError(VE_NOT_INITED, kTraceError); |
| 155 return -1; | 140 return -1; |
| 156 } | 141 } |
| 157 | 142 |
| 158 devices = static_cast<int>(_shared->audio_device()->PlayoutDevices()); | 143 devices = static_cast<int>(_shared->audio_device()->PlayoutDevices()); |
| 159 | 144 |
| 160 WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_shared->instance_id(), -1), | |
| 161 " Output: devices=%d", devices); | |
| 162 | |
| 163 return 0; | 145 return 0; |
| 164 } | 146 } |
| 165 | 147 |
| 166 int VoEHardwareImpl::GetRecordingDeviceName(int index, | 148 int VoEHardwareImpl::GetRecordingDeviceName(int index, |
| 167 char strNameUTF8[128], | 149 char strNameUTF8[128], |
| 168 char strGuidUTF8[128]) { | 150 char strGuidUTF8[128]) { |
| 169 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), | |
| 170 "GetRecordingDeviceName(index=%d)", index); | |
| 171 | |
| 172 if (!_shared->statistics().Initialized()) { | 151 if (!_shared->statistics().Initialized()) { |
| 173 _shared->SetLastError(VE_NOT_INITED, kTraceError); | 152 _shared->SetLastError(VE_NOT_INITED, kTraceError); |
| 174 return -1; | 153 return -1; |
| 175 } | 154 } |
| 176 if (strNameUTF8 == NULL) { | 155 if (strNameUTF8 == NULL) { |
| 177 _shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError, | 156 _shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError, |
| 178 "GetRecordingDeviceName() invalid argument"); | 157 "GetRecordingDeviceName() invalid argument"); |
| 179 return -1; | 158 return -1; |
| 180 } | 159 } |
| 181 | 160 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 193 | 172 |
| 194 // Get names from module | 173 // Get names from module |
| 195 if (_shared->audio_device()->RecordingDeviceName(index, name, guid) != 0) { | 174 if (_shared->audio_device()->RecordingDeviceName(index, name, guid) != 0) { |
| 196 _shared->SetLastError(VE_CANNOT_RETRIEVE_DEVICE_NAME, kTraceError, | 175 _shared->SetLastError(VE_CANNOT_RETRIEVE_DEVICE_NAME, kTraceError, |
| 197 "GetRecordingDeviceName() failed to get device name"); | 176 "GetRecordingDeviceName() failed to get device name"); |
| 198 return -1; | 177 return -1; |
| 199 } | 178 } |
| 200 | 179 |
| 201 // Copy to vectors supplied by user | 180 // Copy to vectors supplied by user |
| 202 strncpy(strNameUTF8, name, strLen); | 181 strncpy(strNameUTF8, name, strLen); |
| 203 WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_shared->instance_id(), -1), | |
| 204 " Output: strNameUTF8=%s", strNameUTF8); | |
| 205 | 182 |
| 206 if (strGuidUTF8 != NULL) { | 183 if (strGuidUTF8 != NULL) { |
| 207 strncpy(strGuidUTF8, guid, strLen); | 184 strncpy(strGuidUTF8, guid, strLen); |
| 208 WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, | |
| 209 VoEId(_shared->instance_id(), -1), " Output: strGuidUTF8=%s", | |
| 210 strGuidUTF8); | |
| 211 } | 185 } |
| 212 | 186 |
| 213 return 0; | 187 return 0; |
| 214 } | 188 } |
| 215 | 189 |
| 216 int VoEHardwareImpl::GetPlayoutDeviceName(int index, | 190 int VoEHardwareImpl::GetPlayoutDeviceName(int index, |
| 217 char strNameUTF8[128], | 191 char strNameUTF8[128], |
| 218 char strGuidUTF8[128]) { | 192 char strGuidUTF8[128]) { |
| 219 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), | |
| 220 "GetPlayoutDeviceName(index=%d)", index); | |
| 221 | |
| 222 if (!_shared->statistics().Initialized()) { | 193 if (!_shared->statistics().Initialized()) { |
| 223 _shared->SetLastError(VE_NOT_INITED, kTraceError); | 194 _shared->SetLastError(VE_NOT_INITED, kTraceError); |
| 224 return -1; | 195 return -1; |
| 225 } | 196 } |
| 226 if (strNameUTF8 == NULL) { | 197 if (strNameUTF8 == NULL) { |
| 227 _shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError, | 198 _shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError, |
| 228 "GetPlayoutDeviceName() invalid argument"); | 199 "GetPlayoutDeviceName() invalid argument"); |
| 229 return -1; | 200 return -1; |
| 230 } | 201 } |
| 231 | 202 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 243 | 214 |
| 244 // Get names from module | 215 // Get names from module |
| 245 if (_shared->audio_device()->PlayoutDeviceName(index, name, guid) != 0) { | 216 if (_shared->audio_device()->PlayoutDeviceName(index, name, guid) != 0) { |
| 246 _shared->SetLastError(VE_CANNOT_RETRIEVE_DEVICE_NAME, kTraceError, | 217 _shared->SetLastError(VE_CANNOT_RETRIEVE_DEVICE_NAME, kTraceError, |
| 247 "GetPlayoutDeviceName() failed to get device name"); | 218 "GetPlayoutDeviceName() failed to get device name"); |
| 248 return -1; | 219 return -1; |
| 249 } | 220 } |
| 250 | 221 |
| 251 // Copy to vectors supplied by user | 222 // Copy to vectors supplied by user |
| 252 strncpy(strNameUTF8, name, strLen); | 223 strncpy(strNameUTF8, name, strLen); |
| 253 WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_shared->instance_id(), -1), | |
| 254 " Output: strNameUTF8=%s", strNameUTF8); | |
| 255 | 224 |
| 256 if (strGuidUTF8 != NULL) { | 225 if (strGuidUTF8 != NULL) { |
| 257 strncpy(strGuidUTF8, guid, strLen); | 226 strncpy(strGuidUTF8, guid, strLen); |
| 258 WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, | |
| 259 VoEId(_shared->instance_id(), -1), " Output: strGuidUTF8=%s", | |
| 260 strGuidUTF8); | |
| 261 } | 227 } |
| 262 | 228 |
| 263 return 0; | 229 return 0; |
| 264 } | 230 } |
| 265 | 231 |
| 266 int VoEHardwareImpl::SetRecordingDevice(int index, | 232 int VoEHardwareImpl::SetRecordingDevice(int index, |
| 267 StereoChannel recordingChannel) { | 233 StereoChannel recordingChannel) { |
| 268 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), | 234 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
| 269 "SetRecordingDevice(index=%d, recordingChannel=%d)", index, | 235 "SetRecordingDevice(index=%d, recordingChannel=%d)", index, |
| 270 (int)recordingChannel); | 236 (int)recordingChannel); |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), | 432 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
| 467 "%s", __FUNCTION__); | 433 "%s", __FUNCTION__); |
| 468 if (!_shared->statistics().Initialized()) { | 434 if (!_shared->statistics().Initialized()) { |
| 469 _shared->SetLastError(VE_NOT_INITED, kTraceError); | 435 _shared->SetLastError(VE_NOT_INITED, kTraceError); |
| 470 return false; | 436 return false; |
| 471 } | 437 } |
| 472 return _shared->audio_device()->SetRecordingSampleRate(samples_per_sec); | 438 return _shared->audio_device()->SetRecordingSampleRate(samples_per_sec); |
| 473 } | 439 } |
| 474 | 440 |
| 475 int VoEHardwareImpl::RecordingSampleRate(unsigned int* samples_per_sec) const { | 441 int VoEHardwareImpl::RecordingSampleRate(unsigned int* samples_per_sec) const { |
| 476 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), | |
| 477 "%s", __FUNCTION__); | |
| 478 if (!_shared->statistics().Initialized()) { | 442 if (!_shared->statistics().Initialized()) { |
| 479 _shared->SetLastError(VE_NOT_INITED, kTraceError); | 443 _shared->SetLastError(VE_NOT_INITED, kTraceError); |
| 480 return false; | 444 return false; |
| 481 } | 445 } |
| 482 return _shared->audio_device()->RecordingSampleRate(samples_per_sec); | 446 return _shared->audio_device()->RecordingSampleRate(samples_per_sec); |
| 483 } | 447 } |
| 484 | 448 |
| 485 int VoEHardwareImpl::SetPlayoutSampleRate(unsigned int samples_per_sec) { | 449 int VoEHardwareImpl::SetPlayoutSampleRate(unsigned int samples_per_sec) { |
| 486 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), | 450 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
| 487 "%s", __FUNCTION__); | 451 "%s", __FUNCTION__); |
| 488 if (!_shared->statistics().Initialized()) { | 452 if (!_shared->statistics().Initialized()) { |
| 489 _shared->SetLastError(VE_NOT_INITED, kTraceError); | 453 _shared->SetLastError(VE_NOT_INITED, kTraceError); |
| 490 return false; | 454 return false; |
| 491 } | 455 } |
| 492 return _shared->audio_device()->SetPlayoutSampleRate(samples_per_sec); | 456 return _shared->audio_device()->SetPlayoutSampleRate(samples_per_sec); |
| 493 } | 457 } |
| 494 | 458 |
| 495 int VoEHardwareImpl::PlayoutSampleRate(unsigned int* samples_per_sec) const { | 459 int VoEHardwareImpl::PlayoutSampleRate(unsigned int* samples_per_sec) const { |
| 496 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), | |
| 497 "%s", __FUNCTION__); | |
| 498 if (!_shared->statistics().Initialized()) { | 460 if (!_shared->statistics().Initialized()) { |
| 499 _shared->SetLastError(VE_NOT_INITED, kTraceError); | 461 _shared->SetLastError(VE_NOT_INITED, kTraceError); |
| 500 return false; | 462 return false; |
| 501 } | 463 } |
| 502 return _shared->audio_device()->PlayoutSampleRate(samples_per_sec); | 464 return _shared->audio_device()->PlayoutSampleRate(samples_per_sec); |
| 503 } | 465 } |
| 504 | 466 |
| 505 bool VoEHardwareImpl::BuiltInAECIsAvailable() const { | 467 bool VoEHardwareImpl::BuiltInAECIsAvailable() const { |
| 506 if (!_shared->statistics().Initialized()) { | 468 if (!_shared->statistics().Initialized()) { |
| 507 _shared->SetLastError(VE_NOT_INITED, kTraceError); | 469 _shared->SetLastError(VE_NOT_INITED, kTraceError); |
| 508 return false; | 470 return false; |
| 509 } | 471 } |
| 510 return _shared->audio_device()->BuiltInAECIsAvailable(); | 472 return _shared->audio_device()->BuiltInAECIsAvailable(); |
| 511 } | 473 } |
| 512 | 474 |
| 513 int VoEHardwareImpl::EnableBuiltInAEC(bool enable) { | 475 int VoEHardwareImpl::EnableBuiltInAEC(bool enable) { |
| 514 if (!_shared->statistics().Initialized()) { | 476 if (!_shared->statistics().Initialized()) { |
| 515 _shared->SetLastError(VE_NOT_INITED, kTraceError); | 477 _shared->SetLastError(VE_NOT_INITED, kTraceError); |
| 516 return -1; | 478 return -1; |
| 517 } | 479 } |
| 518 return _shared->audio_device()->EnableBuiltInAEC(enable); | 480 return _shared->audio_device()->EnableBuiltInAEC(enable); |
| 519 } | 481 } |
| 520 | 482 |
| 521 #endif // WEBRTC_VOICE_ENGINE_HARDWARE_API | 483 #endif // WEBRTC_VOICE_ENGINE_HARDWARE_API |
| 522 | 484 |
| 523 } // namespace webrtc | 485 } // namespace webrtc |
| OLD | NEW |