| 87 | } |
| 88 | |
| 89 | OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetAudioDeviceOutWaveId(UINT* deviceOutId) |
| 90 | { |
| 91 | REV_TRACE(ovr_GetAudioDeviceOutWaveId); |
| 92 | |
| 93 | if (!deviceOutId) |
| 94 | return ovrError_InvalidParameter; |
| 95 | |
| 96 | // Query and cache the result |
| 97 | static UINT cachedId = 0; |
| 98 | if (!cachedId && Runtime::Get().AudioDevice) |
| 99 | { |
| 100 | XR_FUNCTION(g_Instance, GetAudioOutputDeviceGuidOculus); |
| 101 | |
| 102 | MMRESULT mmr; |
| 103 | WCHAR strEndpointIdKey[OVR_AUDIO_MAX_DEVICE_STR_SIZE] = {}; |
| 104 | XrResult result = GetAudioOutputDeviceGuidOculus(g_Instance, strEndpointIdKey); |
| 105 | if (XR_FAILED(result)) |
| 106 | return ovrError_AudioOutputDeviceNotFound; |
| 107 | |
| 108 | // Get the size of the endpoint ID string. |
| 109 | size_t cbEndpointIdKey = wcsnlen_s(strEndpointIdKey, OVR_AUDIO_MAX_DEVICE_STR_SIZE) * sizeof(WCHAR); |
| 110 | |
| 111 | // Include terminating null in string size. |
| 112 | cbEndpointIdKey += sizeof(WCHAR); |
| 113 | |
| 114 | // Each for-loop iteration below compares the endpoint ID |
| 115 | // string of the audio endpoint device to the endpoint ID |
| 116 | // string of an enumerated waveOut device. If the strings |
| 117 | // match, then we've found the waveOut device that is |
| 118 | // assigned to the specified device role. |
| 119 | UINT waveOutId; |
| 120 | UINT cWaveOutDevices = waveOutGetNumDevs(); |
| 121 | WCHAR strEndpointId[OVR_AUDIO_MAX_DEVICE_STR_SIZE] = {}; |
| 122 | for (waveOutId = 0; waveOutId < cWaveOutDevices; waveOutId++) |
| 123 | { |
| 124 | size_t cbEndpointId = 0; |
| 125 | |
| 126 | // Get the size (including the terminating null) of |
| 127 | // the endpoint ID string of the waveOut device. |
| 128 | mmr = waveOutMessage((HWAVEOUT)UIntToPtr(waveOutId), |
| 129 | DRV_QUERYFUNCTIONINSTANCEIDSIZE, |
| 130 | (DWORD_PTR)&cbEndpointId, NULL); |
| 131 | if (mmr != MMSYSERR_NOERROR || |
| 132 | cbEndpointIdKey != cbEndpointId) // do sizes match? |
| 133 | { |
| 134 | continue; // not a matching device |
| 135 | } |
| 136 | |
| 137 | // Get the endpoint ID string for this waveOut device. |
| 138 | mmr = waveOutMessage((HWAVEOUT)UIntToPtr(waveOutId), |
| 139 | DRV_QUERYFUNCTIONINSTANCEID, |
| 140 | (DWORD_PTR)strEndpointId, |
| 141 | cbEndpointId); |
| 142 | if (mmr != MMSYSERR_NOERROR) |
| 143 | { |
| 144 | continue; |
| 145 | } |
| 146 |
nothing calls this directly
no outgoing calls
no test coverage detected