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

Function ovr_GetAudioDeviceInWaveId

ReviveXR/REV_CAPI_Audio.cpp:174–257  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

172}
173
174OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetAudioDeviceInWaveId(UINT* deviceInId)
175{
176 REV_TRACE(ovr_GetAudioDeviceInWaveId);
177
178 if (!deviceInId)
179 return ovrError_InvalidParameter;
180
181 // Query and cache the result
182 static UINT cachedId = 0;
183 if (!cachedId && Runtime::Get().AudioDevice)
184 {
185 XR_FUNCTION(g_Instance, GetAudioInputDeviceGuidOculus);
186
187 MMRESULT mmr;
188 WCHAR strEndpointIdKey[OVR_AUDIO_MAX_DEVICE_STR_SIZE] = {};
189 XrResult result = GetAudioInputDeviceGuidOculus(g_Instance, strEndpointIdKey);
190 if (XR_FAILED(result))
191 return ovrError_AudioInputDeviceNotFound;
192
193 // Get the size of the endpoint ID string.
194 size_t cbEndpointIdKey = wcsnlen_s(strEndpointIdKey, OVR_AUDIO_MAX_DEVICE_STR_SIZE) * sizeof(WCHAR);
195
196 // Include terminating null in string size.
197 cbEndpointIdKey += sizeof(WCHAR);
198
199 // Each for-loop iteration below compares the endpoint ID
200 // string of the audio endpoint device to the endpoint ID
201 // string of an enumerated waveOut device. If the strings
202 // match, then we've found the waveIn device that is
203 // assigned to the specified device role.
204 UINT waveInId;
205 UINT cWaveInDevices = waveInGetNumDevs();
206 WCHAR strEndpointId[OVR_AUDIO_MAX_DEVICE_STR_SIZE] = {};
207 for (waveInId = 0; waveInId < cWaveInDevices; waveInId++)
208 {
209 size_t cbEndpointId = 0;
210
211 // Get the size (including the terminating null) of
212 // the endpoint ID string of the waveOut device.
213 mmr = waveInMessage((HWAVEIN)UIntToPtr(waveInId),
214 DRV_QUERYFUNCTIONINSTANCEIDSIZE,
215 (DWORD_PTR)&cbEndpointId, NULL);
216 if (mmr != MMSYSERR_NOERROR ||
217 cbEndpointIdKey != cbEndpointId) // do sizes match?
218 {
219 continue; // not a matching device
220 }
221
222 // Get the endpoint ID string for this waveOut device.
223 mmr = waveInMessage((HWAVEIN)UIntToPtr(waveInId),
224 DRV_QUERYFUNCTIONINSTANCEID,
225 (DWORD_PTR)strEndpointId,
226 cbEndpointId);
227 if (mmr != MMSYSERR_NOERROR)
228 {
229 continue;
230 }
231

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected