| 358 | } |
| 359 | |
| 360 | OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetAudioDeviceInGuid(GUID* deviceInGuid) |
| 361 | { |
| 362 | REV_TRACE(ovr_GetAudioDeviceInGuid); |
| 363 | |
| 364 | if (!deviceInGuid) |
| 365 | return ovrError_InvalidParameter; |
| 366 | |
| 367 | // Query and cache the result |
| 368 | static GUID cachedGuid = GUID_NULL; |
| 369 | if (cachedGuid == GUID_NULL) |
| 370 | { |
| 371 | char endpoint[OVR_AUDIO_MAX_DEVICE_STR_SIZE] = {}; |
| 372 | vr::ETrackedPropertyError error = vr::TrackedProp_Success; |
| 373 | uint32_t size = vr::VRSystem()->GetStringTrackedDeviceProperty( |
| 374 | vr::k_unTrackedDeviceIndex_Hmd, |
| 375 | vr::Prop_Audio_DefaultRecordingDeviceId_String, |
| 376 | endpoint, OVR_AUDIO_MAX_DEVICE_STR_SIZE, &error); |
| 377 | if (error == vr::TrackedProp_Success) |
| 378 | { |
| 379 | HRESULT com = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); |
| 380 | ovrResult result = AudioEndPointToGuid(endpoint, size, &cachedGuid); |
| 381 | if (SUCCEEDED(com)) |
| 382 | CoUninitialize(); |
| 383 | if (OVR_FAILURE(result)) |
| 384 | return result; |
| 385 | } |
| 386 | else |
| 387 | { |
| 388 | // Return the default without caching so we can attempt again later |
| 389 | HRESULT hr = GetDeviceID(&DSDEVID_DefaultCapture, deviceInGuid); |
| 390 | return SUCCEEDED(hr) ? ovrSuccess : ovrError_AudioInputDeviceNotFound; |
| 391 | } |
| 392 | } |
| 393 | *deviceInGuid = cachedGuid; |
| 394 | return ovrSuccess; |
| 395 | } |
nothing calls this directly
no test coverage detected