MCPcopy Create free account
hub / github.com/bulletphysics/bullet3 / deviceQueryCallback

Function deviceQueryCallback

examples/TinyAudio/RtAudio.cpp:7321–7408  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7319}
7320
7321static BOOL CALLBACK deviceQueryCallback(LPGUID lpguid,
7322 LPCTSTR description,
7323 LPCTSTR /*module*/,
7324 LPVOID lpContext)
7325{
7326 struct DsProbeData &probeInfo = *(struct DsProbeData *)lpContext;
7327 std::vector<struct DsDevice> &dsDevices = *probeInfo.dsDevices;
7328
7329 HRESULT hr;
7330 bool validDevice = false;
7331 if (probeInfo.isInput == true)
7332 {
7333 DSCCAPS caps;
7334 LPDIRECTSOUNDCAPTURE object;
7335
7336 hr = DirectSoundCaptureCreate(lpguid, &object, NULL);
7337 if (hr != DS_OK) return TRUE;
7338
7339 caps.dwSize = sizeof(caps);
7340 hr = object->GetCaps(&caps);
7341 if (hr == DS_OK)
7342 {
7343 if (caps.dwChannels > 0 && caps.dwFormats > 0)
7344 validDevice = true;
7345 }
7346 object->Release();
7347 }
7348 else
7349 {
7350 DSCAPS caps;
7351 LPDIRECTSOUND object;
7352 hr = DirectSoundCreate(lpguid, &object, NULL);
7353 if (hr != DS_OK) return TRUE;
7354
7355 caps.dwSize = sizeof(caps);
7356 hr = object->GetCaps(&caps);
7357 if (hr == DS_OK)
7358 {
7359 if (caps.dwFlags & DSCAPS_PRIMARYMONO || caps.dwFlags & DSCAPS_PRIMARYSTEREO)
7360 validDevice = true;
7361 }
7362 object->Release();
7363 }
7364
7365 // If good device, then save its name and guid.
7366 std::string name = convertCharPointerToStdString(description);
7367 //if ( name == "Primary Sound Driver" || name == "Primary Sound Capture Driver" )
7368 if (lpguid == NULL)
7369 name = "Default Device";
7370 if (validDevice)
7371 {
7372 for (unsigned int i = 0; i < dsDevices.size(); i++)
7373 {
7374 if (dsDevices[i].name == name)
7375 {
7376 dsDevices[i].found = true;
7377 if (probeInfo.isInput)
7378 {

Callers

nothing calls this directly

Calls 4

ReleaseMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected