On 2/9/22 17:10, Gabriel Ivăncescu wrote:
+static HRESULT get_device_path(struct get_device_info_params *params, GUID *guid, PROPVARIANT *out) +{
- UINT serial_number;
- const WCHAR *fmt;
- WCHAR path[128];
- int len;
- switch (params->bus_type) {
- case phys_device_bus_pci:
fmt = L"{1}.HDAUDIO\\FUNC_01&VEN_%04X&DEV_%04X\\%u&%08X";
break;
- case phys_device_bus_usb:
fmt = L"{1}.USB\\VID_%04X&PID_%04X\\%u&%08X";
break;
- default:
return E_FAIL;
- }
- /* As hardly any audio devices have serial numbers, Windows instead
appears to use a persistent random number. We emulate this here
by instead using the last 8 hex digits of the GUID. */
- serial_number = (guid->Data4[4] << 24) | (guid->Data4[5] << 16) | (guid->Data4[6] << 8) | guid->Data4[7];
- len = swprintf(path, ARRAY_SIZE(path), fmt, params->vendor_id, params->product_id, params->index, serial_number);
- if (len < 0)
return E_FAIL;
Does this belong to winepulse or mmdevapi? Could it be shared, and not depend on the backend? Also, could this use some setupapi API instead of constructing device paths?