MCPcopy Create free account
hub / github.com/LabSound/LabSound / deviceQueryCallback

Function deviceQueryCallback

src/backends/RtAudio/RtAudio.cpp:7658–7745  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7656}
7657
7658static BOOL CALLBACK deviceQueryCallback(LPGUID lpguid,
7659 LPCTSTR description,
7660 LPCTSTR /*module*/,
7661 LPVOID lpContext)
7662{
7663 struct DsProbeData & probeInfo = *(struct DsProbeData *) lpContext;
7664 std::vector<struct DsDevice> & dsDevices = *probeInfo.dsDevices;
7665
7666 HRESULT hr;
7667 bool validDevice = false;
7668 if (probeInfo.isInput == true)
7669 {
7670 DSCCAPS caps;
7671 LPDIRECTSOUNDCAPTURE object;
7672
7673 hr = DirectSoundCaptureCreate(lpguid, &object, NULL);
7674 if (hr != DS_OK) return TRUE;
7675
7676 caps.dwSize = sizeof(caps);
7677 hr = object->GetCaps(&caps);
7678 if (hr == DS_OK)
7679 {
7680 if (caps.dwChannels > 0 && caps.dwFormats > 0)
7681 validDevice = true;
7682 }
7683 object->Release();
7684 }
7685 else
7686 {
7687 DSCAPS caps;
7688 LPDIRECTSOUND object;
7689 hr = DirectSoundCreate(lpguid, &object, NULL);
7690 if (hr != DS_OK) return TRUE;
7691
7692 caps.dwSize = sizeof(caps);
7693 hr = object->GetCaps(&caps);
7694 if (hr == DS_OK)
7695 {
7696 if (caps.dwFlags & DSCAPS_PRIMARYMONO || caps.dwFlags & DSCAPS_PRIMARYSTEREO)
7697 validDevice = true;
7698 }
7699 object->Release();
7700 }
7701
7702 // If good device, then save its name and guid.
7703 std::string name = convertCharPointerToStdString(description);
7704 //if ( name == "Primary Sound Driver" || name == "Primary Sound Capture Driver" )
7705 if (lpguid == NULL)
7706 name = "Default Device";
7707 if (validDevice)
7708 {
7709 for (unsigned int i = 0; i < dsDevices.size(); i++)
7710 {
7711 if (dsDevices[i].name == name)
7712 {
7713 dsDevices[i].found = true;
7714 if (probeInfo.isInput)
7715 {

Callers

nothing calls this directly

Calls 2

sizeMethod · 0.80

Tested by

no test coverage detected