[PATCH v2 1/2] winepulse.drv: Set device path for all devices.

Arkadiusz Hiler wine at gitlab.winehq.org
Tue Jun 28 08:53:44 CDT 2022


From: Arkadiusz Hiler <ahiler at codeweavers.com>

Signed-off-by: Arkadiusz Hiler <ahiler at codeweavers.com>
---
 dlls/winepulse.drv/pulse.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/dlls/winepulse.drv/pulse.c b/dlls/winepulse.drv/pulse.c
index 0e504b6b6dd..42d73db45f9 100644
--- a/dlls/winepulse.drv/pulse.c
+++ b/dlls/winepulse.drv/pulse.c
@@ -2207,27 +2207,26 @@ static BOOL get_device_path(PhysDevice *dev, struct get_prop_value_params *param
 {
     const GUID *guid = params->guid;
     UINT serial_number;
-    const char *fmt;
     char path[128];
     int len;
 
+    /* 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];
+
     switch (dev->bus_type) {
     case phys_device_bus_pci:
-        fmt = "{1}.HDAUDIO\\FUNC_01&VEN_%04X&DEV_%04X\\%u&%08X";
+        len = sprintf(path, "{1}.HDAUDIO\\FUNC_01&VEN_%04X&DEV_%04X\\%u&%08X", dev->vendor_id, dev->product_id, dev->index, serial_number);
         break;
     case phys_device_bus_usb:
-        fmt = "{1}.USB\\VID_%04X&PID_%04X\\%u&%08X";
+        len = sprintf(path, "{1}.USB\\VID_%04X&PID_%04X\\%u&%08X", dev->vendor_id, dev->product_id, dev->index, serial_number);
         break;
     default:
-        return FALSE;
+        len = sprintf(path, "{1}.ROOT\\MEDIA\\%04u", dev->index);
+        break;
     }
 
-    /* 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 = sprintf(path, fmt, dev->vendor_id, dev->product_id, dev->index, serial_number);
     ntdll_umbstowcs(path, len + 1, params->wstr, ARRAY_SIZE(params->wstr));
 
     params->vt = VT_LPWSTR;
-- 
GitLab


https://gitlab.winehq.org/wine/wine/-/merge_requests/325



More information about the wine-devel mailing list