[PATCH 0/4] 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. -- 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 | 17 ++++++++++++++++- dlls/mmdevapi/tests/propstore.c | 2 +- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/dlls/mmdevapi/devenum.c b/dlls/mmdevapi/devenum.c index d147d246636..66d950854fd 100644 --- a/dlls/mmdevapi/devenum.c +++ b/dlls/mmdevapi/devenum.c @@ -496,7 +496,9 @@ static MMDevice *MMDevice_Create(const WCHAR *name, GUID *id, EDataFlow flow, DW RegSetValueExW(key, L"DeviceState", 0, REG_DWORD, (const BYTE*)&state, sizeof(DWORD)); if (!RegCreateKeyExW(key, L"Properties", 0, NULL, 0, KEY_WRITE|KEY_READ|KEY_WOW64_64KEY, NULL, &keyprop, NULL)) { + const WCHAR *type = L"Other Device"; PROPVARIANT pv; + DWORD len; pv.vt = VT_LPWSTR; pv.pwszVal = cur->drv_id; @@ -515,10 +517,23 @@ 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); + + if (flow == eCapture) + type = L"Microphone"; + else if (flow == eRender) + type = L"Speakers"; + + pv.pwszVal = (LPWSTR)type; 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
From: Bernhard Kölbl <bkoelbl@codeweavers.com> --- dlls/mmdevapi/tests/propstore.c | 56 ++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/dlls/mmdevapi/tests/propstore.c b/dlls/mmdevapi/tests/propstore.c index 5c15ba24aee..fb6766e5eef 100644 --- a/dlls/mmdevapi/tests/propstore.c +++ b/dlls/mmdevapi/tests/propstore.c @@ -37,6 +37,8 @@ static BOOL (WINAPI *pIsWow64Process)(HANDLE, BOOL *); static const WCHAR software_renderW[] = L"Software\\Microsoft\\Windows\\CurrentVersion\\MMDevices\\Audio\\Render"; +static const WCHAR software_captureW[] = + L"Software\\Microsoft\\Windows\\CurrentVersion\\MMDevices\\Audio\\Capture"; static void test_propertystore(IPropertyStore *store) { @@ -216,6 +218,49 @@ static void test_setvalue_on_wow64(IPropertyStore *store) "Wrong error when opening mmdevices Render key: %lu\n", ret); } +static void test_registry_values(IPropertyStore *store, EDataFlow data_flow) +{ + const WCHAR *root, *friendly_name = L"{A45C254E-DF1C-4EFD-8020-67D146A850E0},14"; + HKEY root_key, props_key, dev_key; + PROPVARIANT pv, pv2; + WCHAR value[128]; + LSTATUS status; + DWORD size; + HRESULT hr; + + root = data_flow ? software_captureW : software_renderW; + + pv.vt = VT_EMPTY; + hr = IPropertyStore_GetValue(store, &PKEY_AudioEndpoint_GUID, &pv); + ok(hr == S_OK, "IPropertyStore_GetValue failed with %#lx\n", hr); + + status = RegOpenKeyExW(HKEY_LOCAL_MACHINE, root, 0, KEY_READ | KEY_WOW64_64KEY, &root_key); + ok(!status, "RegOpenKeyExW failed with status %lu\n", status); + + status = RegOpenKeyExW(root_key, pv.pwszVal, 0, KEY_READ | KEY_WOW64_64KEY, &dev_key); + ok(!status, "RegOpenKeyExW failed with status %lu\n", status); + + status = RegOpenKeyExW(dev_key, L"Properties", 0, KEY_READ | KEY_WOW64_64KEY, &props_key); + ok(!status, "RegOpenKeyExW failed with status %lu\n", status); + + pv2.vt = VT_EMPTY; + hr = IPropertyStore_GetValue(store, (const PROPERTYKEY*)&DEVPKEY_Device_FriendlyName, &pv2); + ok(hr == S_OK, "IPropertyStore_GetValue failed with %#lx\n", hr); + ok(pv2.vt == VT_LPWSTR && pv2.pwszVal, "DeviceInterface_FriendlyName returned incorrect type %#x\n", pv2.vt); + + /* DEVPKEY_Device_FriendlyName does not exist in the registry. */ + size = ARRAY_SIZE(value); + status = RegQueryValueExW(props_key, friendly_name, NULL, NULL, (BYTE *)&value, &size); + todo_wine ok(status == ERROR_FILE_NOT_FOUND, "RegQueryValueExW returned unexpected value %lu\n", status); + + PropVariantClear(&pv2); + PropVariantClear(&pv); + + RegCloseKey(props_key); + RegCloseKey(dev_key); + RegCloseKey(root_key); +} + START_TEST(propstore) { HRESULT hr; @@ -235,13 +280,15 @@ START_TEST(propstore) hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_INPROC_SERVER, &IID_IMMDeviceEnumerator, (void**)&mme); ok(hr == S_OK, "Got hr %#lx.\n", hr); - hr = IMMDeviceEnumerator_EnumAudioEndpoints(mme, eRender, DEVICE_STATE_ACTIVE, &collection); + hr = IMMDeviceEnumerator_EnumAudioEndpoints(mme, eAll, DEVICE_STATE_ACTIVE, &collection); ok(hr == S_OK, "Got hr %#lx.\n", hr); hr = IMMDeviceCollection_GetCount(collection, &count); ok(hr == S_OK, "Got hr %#lx.\n", hr); for (i = 0; i < count; ++i) { + IMMEndpoint *endpoint; + EDataFlow data_flow; IMMDevice *dev; hr = IMMDeviceCollection_Item(collection, i, &dev); @@ -265,12 +312,19 @@ START_TEST(propstore) hr = IMMDevice_OpenPropertyStore(dev, STGM_READ, &store); ok(hr == S_OK, "Opening valid store returned %08lx\n", hr); + hr = IMMDevice_QueryInterface(dev, &IID_IMMEndpoint, (void **)&endpoint); + ok(hr == S_OK, "IMMDevice_QueryInterface returned %#lx\n", hr); + hr = IMMEndpoint_GetDataFlow(endpoint, &data_flow); + ok(hr == S_OK, "IMMEndpoint_GetDataFlow returned %#lx\n", hr); + test_propertystore(store); test_deviceinterface(store); test_getat(store); + test_registry_values(store, data_flow); if (is_wow64) test_setvalue_on_wow64(store); + IMMEndpoint_Release(endpoint); IPropertyStore_Release(store); IMMDevice_Release(dev); } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9915
participants (2)
-
Bernhard Kölbl -
Bernhard Kölbl (@besentv)