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

Function ovr_GetAudioDeviceInGuidStr

Revive/REV_CAPI_Audio.cpp:331–358  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

329}
330
331OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetAudioDeviceInGuidStr(WCHAR deviceInStrBuffer[OVR_AUDIO_MAX_DEVICE_STR_SIZE])
332{
333 REV_TRACE(ovr_GetAudioDeviceInGuidStr);
334
335 if (!deviceInStrBuffer)
336 return ovrError_InvalidParameter;
337
338 char endpoint[OVR_AUDIO_MAX_DEVICE_STR_SIZE] = {};
339 vr::ETrackedPropertyError error = vr::TrackedProp_Success;
340 uint32_t size = vr::VRSystem()->GetStringTrackedDeviceProperty(
341 vr::k_unTrackedDeviceIndex_Hmd,
342 vr::Prop_Audio_DefaultRecordingDeviceId_String,
343 endpoint, OVR_AUDIO_MAX_DEVICE_STR_SIZE, &error);
344 if (error == vr::TrackedProp_Success)
345 {
346 if (size > OVR_AUDIO_MAX_DEVICE_STR_SIZE)
347 return ovrError_InsufficientArraySize;
348 if (!MultiByteToWideChar(CP_UTF8, MB_PRECOMPOSED, endpoint, size, deviceInStrBuffer, OVR_AUDIO_MAX_DEVICE_STR_SIZE))
349 return ovrError_MemoryAllocationFailure;
350 return ovrSuccess;
351 }
352
353 HRESULT com = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
354 ovrResult result = GetDefaultAudioEndpoint(eCapture, deviceInStrBuffer);
355 if (SUCCEEDED(com))
356 CoUninitialize();
357 return result;
358}
359
360OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetAudioDeviceInGuid(GUID* deviceInGuid)
361{

Callers

nothing calls this directly

Calls 1

GetDefaultAudioEndpointFunction · 0.70

Tested by

no test coverage detected