[PATCH 0/1] MR5472: winecoreaudio: Correctly handle devices whose UID contains non-ASCII characters.
This should fix audio issues for users with certain USB audio devices (possibly including the Creative Pebble V3 and RØDECaster Pro II). The Core Audio UID can contain non-ASCII characters and is converted to UTF-8 by `unix_get_endpoint_ids`. But we were using `CFStringGetLength` to calculate the resulting size, which returns the length in UTF-16 code pairs. This resulted in any UIDs containing non-ASCII characters being truncated, `dev_id_from_device` later failing, and audio not working. Instead use `CFStringGetBytes` to calculate the resulting UTF-8 size, and to do the conversion. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/5472
From: Brendan Shanks <bshanks(a)codeweavers.com> --- dlls/winecoreaudio.drv/coreaudio.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/dlls/winecoreaudio.drv/coreaudio.c b/dlls/winecoreaudio.drv/coreaudio.c index d78744455a8..a79a0d16839 100644 --- a/dlls/winecoreaudio.drv/coreaudio.c +++ b/dlls/winecoreaudio.drv/coreaudio.c @@ -325,7 +325,12 @@ static NTSTATUS unix_get_endpoint_ids(void *args) for(i = 0; i < params->num; i++){ const SIZE_T name_len = CFStringGetLength(info[i].name) + 1; - const SIZE_T device_len = CFStringGetLength(info[i].uid) + 1; + CFIndex device_len; + + CFStringGetBytes(info[i].uid, CFRangeMake(0, CFStringGetLength(info[i].uid)), kCFStringEncodingUTF8, + 0, false, NULL, 0, &device_len); + device_len++; /* for null terminator */ + needed += name_len * sizeof(WCHAR) + ((device_len + 1) & ~1); if(needed <= params->size){ @@ -336,7 +341,8 @@ static NTSTATUS unix_get_endpoint_ids(void *args) offset += name_len * sizeof(WCHAR); endpoint->device = offset; - CFStringGetCString(info[i].uid, (char *)params->endpoints + offset, params->size - offset, kCFStringEncodingUTF8); + CFStringGetBytes(info[i].uid, CFRangeMake(0, CFStringGetLength(info[i].uid)), kCFStringEncodingUTF8, + 0, false, (UInt8 *)params->endpoints + offset, params->size - offset, NULL); ((char *)params->endpoints)[offset + device_len - 1] = '\0'; offset += (device_len + 1) & ~1; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/5472
participants (2)
-
Brendan Shanks -
Brendan Shanks (@bshanks)