MCPcopy Create free account
hub / github.com/LibreVR/Revive / ovr_GetAudioDeviceOutGuid

Function ovr_GetAudioDeviceOutGuid

Revive/REV_CAPI_Audio.cpp:294–329  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

292}
293
294OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetAudioDeviceOutGuid(GUID* deviceOutGuid)
295{
296 REV_TRACE(ovr_GetAudioDeviceOutGuid);
297
298 if (!deviceOutGuid)
299 return ovrError_InvalidParameter;
300
301 // Query and cache the result
302 static GUID cachedGuid = GUID_NULL;
303 if (cachedGuid == GUID_NULL)
304 {
305 char endpoint[OVR_AUDIO_MAX_DEVICE_STR_SIZE] = {};
306 vr::ETrackedPropertyError error = vr::TrackedProp_Success;
307 uint32_t size = vr::VRSystem()->GetStringTrackedDeviceProperty(
308 vr::k_unTrackedDeviceIndex_Hmd,
309 vr::Prop_Audio_DefaultPlaybackDeviceId_String,
310 endpoint, OVR_AUDIO_MAX_DEVICE_STR_SIZE, &error);
311 if (error == vr::TrackedProp_Success)
312 {
313 HRESULT com = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
314 ovrResult result = AudioEndPointToGuid(endpoint, size, &cachedGuid);
315 if (SUCCEEDED(com))
316 CoUninitialize();
317 if (OVR_FAILURE(result))
318 return result;
319 }
320 else
321 {
322 // Return the default without caching so we can attempt again later
323 HRESULT hr = GetDeviceID(&DSDEVID_DefaultPlayback, deviceOutGuid);
324 return SUCCEEDED(hr) ? ovrSuccess : ovrError_AudioInputDeviceNotFound;
325 }
326 }
327 *deviceOutGuid = cachedGuid;
328 return ovrSuccess;
329}
330
331OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetAudioDeviceInGuidStr(WCHAR deviceInStrBuffer[OVR_AUDIO_MAX_DEVICE_STR_SIZE])
332{

Callers

nothing calls this directly

Calls 1

AudioEndPointToGuidFunction · 0.70

Tested by

no test coverage detected