[PATCH v4 0/3] MR9915: mmedvapi: Device name changes.
The test in the last commit would still need an implementation, which turned out to be more complicated than the possible benefits. -- v4: mmdevapi: Adjust device names. https://gitlab.winehq.org/wine/wine/-/merge_requests/9915
From: Bernhard Kölbl <bkoelbl@codeweavers.com> --- dlls/mmdevapi/tests/propstore.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/dlls/mmdevapi/tests/propstore.c b/dlls/mmdevapi/tests/propstore.c index b333a556567..284e8b94368 100644 --- a/dlls/mmdevapi/tests/propstore.c +++ b/dlls/mmdevapi/tests/propstore.c @@ -43,15 +43,12 @@ static void test_propertystore(IPropertyStore *store) const WAVEFORMATEXTENSIBLE *format; HRESULT hr; PROPVARIANT pv; - char temp[128]; - temp[sizeof(temp)-1] = 0; pv.vt = VT_EMPTY; hr = IPropertyStore_GetValue(store, &PKEY_AudioEndpoint_GUID, &pv); ok(hr == S_OK, "Failed with %08lx\n", hr); ok(pv.vt == VT_LPWSTR, "Value should be %i, is %i\n", VT_LPWSTR, pv.vt); - WideCharToMultiByte(CP_ACP, 0, pv.pwszVal, -1, temp, sizeof(temp)-1, NULL, NULL); - trace("guid: %s\n", temp); + trace("guid: %s\n", debugstr_w(pv.pwszVal)); PropVariantClear(&pv); pv.vt = VT_EMPTY; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9915
From: Bernhard Kölbl <bkoelbl@codeweavers.com> --- dlls/mmdevapi/tests/propstore.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/dlls/mmdevapi/tests/propstore.c b/dlls/mmdevapi/tests/propstore.c index 284e8b94368..51d87592c55 100644 --- a/dlls/mmdevapi/tests/propstore.c +++ b/dlls/mmdevapi/tests/propstore.c @@ -41,8 +41,9 @@ static const WCHAR software_renderW[] = static void test_propertystore(IPropertyStore *store) { const WAVEFORMATEXTENSIBLE *format; + WCHAR temp[256] = { 0 }; + PROPVARIANT pv, pv2; HRESULT hr; - PROPVARIANT pv; pv.vt = VT_EMPTY; hr = IPropertyStore_GetValue(store, &PKEY_AudioEndpoint_GUID, &pv); @@ -55,6 +56,22 @@ static void test_propertystore(IPropertyStore *store) hr = IPropertyStore_GetValue(store, (const PROPERTYKEY*)&DEVPKEY_DeviceInterface_FriendlyName, &pv); ok(hr == S_OK, "Failed with %08lx\n", hr); ok(pv.vt == VT_LPWSTR && pv.pwszVal, "FriendlyName value had wrong type: 0x%x or was NULL\n", pv.vt); + + pv2.vt = VT_EMPTY; + hr = IPropertyStore_GetValue(store, (const PROPERTYKEY*)&DEVPKEY_Device_DeviceDesc, &pv2); + ok(hr == S_OK, "Failed with %#lx\n", hr); + ok(pv2.vt == VT_LPWSTR && pv2.pwszVal, "Device_DeviceDesc value had wrong type: %#x or was NULL\n", pv2.vt); + + swprintf(temp, ARRAY_SIZE(temp), L"%ls (%ls)", pv2.pwszVal, pv.pwszVal); + + PropVariantClear(&pv); + PropVariantClear(&pv2); + + pv.vt = VT_EMPTY; + hr = IPropertyStore_GetValue(store, (const PROPERTYKEY*)&DEVPKEY_Device_FriendlyName, &pv); + ok(hr == S_OK, "Failed with %#lx\n", hr); + ok(pv.vt == VT_LPWSTR && pv.pwszVal, "Device_FriendlyName value had wrong type: %#x or was NULL\n", pv.vt); + todo_wine ok(!wcscmp(temp, pv.pwszVal), "Expected Device_FriendlyName %s, but got %s\n", debugstr_w(temp), debugstr_w(pv.pwszVal)); PropVariantClear(&pv); pv.vt = VT_EMPTY; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9915
From: Bernhard Kölbl <bkoelbl@codeweavers.com> --- dlls/mmdevapi/devenum.c | 12 +++++++++++- dlls/mmdevapi/tests/propstore.c | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/dlls/mmdevapi/devenum.c b/dlls/mmdevapi/devenum.c index d147d246636..69436f6faca 100644 --- a/dlls/mmdevapi/devenum.c +++ b/dlls/mmdevapi/devenum.c @@ -497,6 +497,8 @@ static MMDevice *MMDevice_Create(const WCHAR *name, GUID *id, EDataFlow flow, DW if (!RegCreateKeyExW(key, L"Properties", 0, NULL, 0, KEY_WRITE|KEY_READ|KEY_WOW64_64KEY, NULL, &keyprop, NULL)) { PROPVARIANT pv; + WCHAR *type; + DWORD len; pv.vt = VT_LPWSTR; pv.pwszVal = cur->drv_id; @@ -515,10 +517,18 @@ static MMDevice *MMDevice_Create(const WCHAR *name, GUID *id, EDataFlow flow, DW PropVariantClear(&pv2); } - MMDevice_SetPropValue(id, flow, (const PROPERTYKEY*)&DEVPKEY_Device_FriendlyName, &pv); MMDevice_SetPropValue(id, flow, (const PROPERTYKEY*)&DEVPKEY_DeviceInterface_FriendlyName, &pv); + + pv.pwszVal = type = (WCHAR *)(flow == eCapture ? L"Microphone" : L"Speakers"); MMDevice_SetPropValue(id, flow, (const PROPERTYKEY*)&DEVPKEY_Device_DeviceDesc, &pv); + len = (wcslen(type) + wcslen(cur->drv_id) + wcslen(L" ()") + 1) * sizeof(WCHAR); + pv.vt = VT_LPWSTR; + pv.pwszVal = CoTaskMemAlloc(len); + swprintf(pv.pwszVal, len, L"%ls (%ls)", type, cur->drv_id); + MMDevice_SetPropValue(id, flow, (const PROPERTYKEY*)&DEVPKEY_Device_FriendlyName, &pv); + CoTaskMemFree(pv.pwszVal); + pv.pwszVal = guidstr; MMDevice_SetPropValue(id, flow, &deviceinterface_key, &pv); diff --git a/dlls/mmdevapi/tests/propstore.c b/dlls/mmdevapi/tests/propstore.c index 51d87592c55..5c15ba24aee 100644 --- a/dlls/mmdevapi/tests/propstore.c +++ b/dlls/mmdevapi/tests/propstore.c @@ -71,7 +71,7 @@ static void test_propertystore(IPropertyStore *store) hr = IPropertyStore_GetValue(store, (const PROPERTYKEY*)&DEVPKEY_Device_FriendlyName, &pv); ok(hr == S_OK, "Failed with %#lx\n", hr); ok(pv.vt == VT_LPWSTR && pv.pwszVal, "Device_FriendlyName value had wrong type: %#x or was NULL\n", pv.vt); - todo_wine ok(!wcscmp(temp, pv.pwszVal), "Expected Device_FriendlyName %s, but got %s\n", debugstr_w(temp), debugstr_w(pv.pwszVal)); + ok(!wcscmp(temp, pv.pwszVal), "Expected Device_FriendlyName %s, but got %s\n", debugstr_w(temp), debugstr_w(pv.pwszVal)); PropVariantClear(&pv); pv.vt = VT_EMPTY; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9915
On Tue Jan 20 16:18:47 2026 +0000, Bernhard Kölbl wrote:
changed this line in [version 4 of the diff](/wine/wine/-/merge_requests/9915/diffs?diff_id=238951&start_sha=0f285ddae314f32a89137507c997de0c9343d37d#f53eee1d426bd2e6275f47ef72ee630c76d65055_527_522) I think it's good now?
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/9915#note_127420
This merge request was approved by Paul Gofman. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/9915
Huw Davies (@huw) commented about dlls/mmdevapi/devenum.c:
PropVariantClear(&pv2); }
- MMDevice_SetPropValue(id, flow, (const PROPERTYKEY*)&DEVPKEY_Device_FriendlyName, &pv); MMDevice_SetPropValue(id, flow, (const PROPERTYKEY*)&DEVPKEY_DeviceInterface_FriendlyName, &pv); + + pv.pwszVal = type = (WCHAR *)(flow == eCapture ? L"Microphone" : L"Speakers"); MMDevice_SetPropValue(id, flow, (const PROPERTYKEY*)&DEVPKEY_Device_DeviceDesc, &pv);
+ len = (wcslen(type) + wcslen(cur->drv_id) + wcslen(L" ()") + 1) * sizeof(WCHAR); + pv.vt = VT_LPWSTR; + pv.pwszVal = CoTaskMemAlloc(len); + swprintf(pv.pwszVal, len, L"%ls (%ls)", type, cur->drv_id);
The second param of `swprintf` should be `len/2`. Better yet, keep `len` to be lengths and just multiply by `sizeof(WCHAR)` in the allocation. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/9915#note_129015
participants (4)
-
Bernhard Kölbl -
Bernhard Kölbl (@besentv) -
Huw Davies (@huw) -
Paul Gofman (@gofman)