[PATCH 3/5] winepulse.drv: Implement GetPropValue.

Gabriel Ivăncescu gabrielopcode at gmail.com
Wed Feb 9 09:54:56 CST 2022


On 09/02/2022 16:19, Nikolay Sivov wrote:
> 
> 
> 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?
> 

Unfortunately I don't know almost anything about mmdevapi, I did work on 
rebasing the patchset in staging though so at least I'm familiar with it 
on the winepulse side. winealsa.drv seems to have similar logic though, 
so you might be right, this could be made more generic for sure.

I'm not sure what's the best way to do that. This function returns a 
VARIANT, but for this specific prop key, it needs to return a structure 
of sorts. It needs info about:

1) Bus type (PCI, USB)
2) Vendor ID
3) Product ID
4) Device ID

What do you suggest to return? Something custom?

BTW am I correct to assume that this function (GetPropValue) is only 
called by mmdevapi and thus is internal/its signature can be changed? Or 
is it possible for an app to call it? Because if the latter I'm afraid I 
can't see a way out.



More information about the wine-devel mailing list