Skip to content

Commit

Permalink
winepulse.drv: Use ROOT\MEDIA device path for non-USB/non-PCI devices.
Browse files Browse the repository at this point in the history
In most cases it is the default pulse audio sink. The path convention
follows what Windows does for virtual audio interfaces.

Fixes Cyberpunk 2077 on 4.0 audio setups.

CW-Bug-Id: #20202
  • Loading branch information
ivyl committed Mar 22, 2022
1 parent 889426e commit 887a9f4
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions dlls/winepulse.drv/pulse.c
Original file line number Diff line number Diff line change
Expand Up @@ -2164,27 +2164,28 @@ 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;
Expand Down

0 comments on commit 887a9f4

Please sign in to comment.