2012-03-28 00:38:39 +02:00
|
|
|
/*
|
|
|
|
* Some unit tests for devenum
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012 Christian Costa
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include "initguid.h"
|
2020-04-16 21:46:06 +02:00
|
|
|
#include "dshow.h"
|
|
|
|
#include "dmo.h"
|
|
|
|
#include "dmodshow.h"
|
2018-03-11 05:11:52 +01:00
|
|
|
#include "dsound.h"
|
2018-03-31 23:25:14 +02:00
|
|
|
#include "mmddk.h"
|
2018-03-31 23:25:18 +02:00
|
|
|
#include "vfw.h"
|
2019-03-20 08:44:10 +01:00
|
|
|
#include "setupapi.h"
|
2020-04-16 21:46:06 +02:00
|
|
|
#include "wine/test.h"
|
2018-03-11 05:11:52 +01:00
|
|
|
|
|
|
|
DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
|
2012-03-28 00:38:39 +02:00
|
|
|
|
2020-04-15 05:22:47 +02:00
|
|
|
static void test_devenum(void)
|
2012-03-28 00:38:39 +02:00
|
|
|
{
|
2018-03-07 03:57:06 +01:00
|
|
|
IEnumMoniker *enum_cat, *enum_moniker;
|
2012-03-28 00:38:39 +02:00
|
|
|
ICreateDevEnum* create_devenum;
|
2018-03-07 03:57:06 +01:00
|
|
|
IPropertyBag *prop_bag;
|
|
|
|
IMoniker *moniker;
|
|
|
|
GUID cat_guid, clsid;
|
2018-07-30 04:06:05 +02:00
|
|
|
WCHAR *displayname;
|
2020-04-15 05:22:47 +02:00
|
|
|
IBindCtx *bindctx;
|
2020-04-16 21:46:04 +02:00
|
|
|
HRESULT hr, hr2;
|
|
|
|
IUnknown *unk;
|
2018-03-07 03:57:06 +01:00
|
|
|
VARIANT var;
|
2019-04-06 02:41:13 +02:00
|
|
|
int count;
|
2012-03-28 00:38:39 +02:00
|
|
|
|
2018-03-07 03:57:06 +01:00
|
|
|
hr = CoCreateInstance(&CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC,
|
2012-03-28 00:38:39 +02:00
|
|
|
&IID_ICreateDevEnum, (LPVOID*)&create_devenum);
|
2018-03-07 03:57:06 +01:00
|
|
|
ok(hr == S_OK, "Failed to create devenum: %#x\n", hr);
|
2012-03-28 00:38:39 +02:00
|
|
|
|
2018-03-07 03:57:06 +01:00
|
|
|
hr = ICreateDevEnum_CreateClassEnumerator(create_devenum, &CLSID_ActiveMovieCategories, &enum_cat, 0);
|
|
|
|
ok(hr == S_OK, "Failed to enum categories: %#x\n", hr);
|
|
|
|
|
|
|
|
while (IEnumMoniker_Next(enum_cat, 1, &moniker, NULL) == S_OK)
|
2012-03-28 00:38:39 +02:00
|
|
|
{
|
2020-04-15 05:22:47 +02:00
|
|
|
hr = IMoniker_BindToStorage(moniker, NULL, NULL, &IID_IPropertyBag, (void **)&prop_bag);
|
2018-03-07 03:57:06 +01:00
|
|
|
ok(hr == S_OK, "IMoniker_BindToStorage failed: %#x\n", hr);
|
|
|
|
|
|
|
|
VariantInit(&var);
|
2020-04-14 07:16:00 +02:00
|
|
|
hr = IPropertyBag_Read(prop_bag, L"CLSID", &var, NULL);
|
2018-03-07 03:57:06 +01:00
|
|
|
ok(hr == S_OK, "Failed to read CLSID: %#x\n", hr);
|
2012-03-28 00:38:39 +02:00
|
|
|
|
2018-03-07 03:57:06 +01:00
|
|
|
hr = CLSIDFromString(V_BSTR(&var), &cat_guid);
|
|
|
|
ok(hr == S_OK, "got %#x\n", hr);
|
|
|
|
|
2018-07-30 04:06:05 +02:00
|
|
|
VariantClear(&var);
|
2020-04-14 07:16:00 +02:00
|
|
|
hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL);
|
2018-07-30 04:06:05 +02:00
|
|
|
ok(hr == S_OK, "Failed to read FriendlyName: %#x\n", hr);
|
|
|
|
|
|
|
|
if (winetest_debug > 1)
|
|
|
|
trace("%s %s:\n", wine_dbgstr_guid(&cat_guid), wine_dbgstr_w(V_BSTR(&var)));
|
|
|
|
|
2018-12-17 21:45:02 +01:00
|
|
|
VariantClear(&var);
|
2018-03-07 03:57:06 +01:00
|
|
|
IPropertyBag_Release(prop_bag);
|
|
|
|
IMoniker_Release(moniker);
|
|
|
|
|
|
|
|
hr = ICreateDevEnum_CreateClassEnumerator(create_devenum, &cat_guid, &enum_moniker, 0);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to enum devices: %#x\n", hr);
|
|
|
|
|
|
|
|
if (hr == S_OK)
|
2012-03-28 00:38:39 +02:00
|
|
|
{
|
2019-04-06 02:41:13 +02:00
|
|
|
count = 0;
|
|
|
|
|
2012-03-28 00:38:39 +02:00
|
|
|
while (IEnumMoniker_Next(enum_moniker, 1, &moniker, NULL) == S_OK)
|
|
|
|
{
|
2018-07-30 04:06:05 +02:00
|
|
|
hr = IMoniker_GetDisplayName(moniker, NULL, NULL, &displayname);
|
|
|
|
ok(hr == S_OK, "got %#x\n", hr);
|
|
|
|
|
2017-03-10 11:26:53 +01:00
|
|
|
hr = IMoniker_GetClassID(moniker, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "IMoniker_GetClassID should failed %x\n", hr);
|
|
|
|
|
|
|
|
hr = IMoniker_GetClassID(moniker, &clsid);
|
|
|
|
ok(hr == S_OK, "IMoniker_GetClassID failed with error %x\n", hr);
|
|
|
|
ok(IsEqualGUID(&clsid, &CLSID_CDeviceMoniker),
|
|
|
|
"Expected CLSID_CDeviceMoniker got %s\n", wine_dbgstr_guid(&clsid));
|
2012-03-28 00:38:39 +02:00
|
|
|
|
|
|
|
VariantInit(&var);
|
2020-04-15 05:22:47 +02:00
|
|
|
hr = IMoniker_BindToStorage(moniker, NULL, NULL, &IID_IPropertyBag, (LPVOID*)&prop_bag);
|
2012-03-28 00:38:39 +02:00
|
|
|
ok(hr == S_OK, "IMoniker_BindToStorage failed with error %x\n", hr);
|
|
|
|
|
2020-04-14 07:16:00 +02:00
|
|
|
hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL);
|
2019-03-20 08:44:10 +01:00
|
|
|
ok((hr == S_OK) | (hr == ERROR_KEY_DOES_NOT_EXIST),
|
|
|
|
"IPropertyBag_Read failed: %#x\n", hr);
|
2012-03-28 00:38:39 +02:00
|
|
|
|
2018-03-07 03:57:06 +01:00
|
|
|
if (winetest_debug > 1)
|
2018-07-30 04:06:05 +02:00
|
|
|
trace(" %s %s\n", wine_dbgstr_w(displayname), wine_dbgstr_w(V_BSTR(&var)));
|
2014-01-09 11:11:45 +01:00
|
|
|
|
2020-04-15 05:22:47 +02:00
|
|
|
hr = IMoniker_BindToObject(moniker, NULL, NULL, &IID_IUnknown, NULL);
|
2018-04-28 19:30:09 +02:00
|
|
|
ok(hr == E_POINTER, "got %#x\n", hr);
|
|
|
|
|
2020-04-16 21:46:04 +02:00
|
|
|
VariantClear(&var);
|
|
|
|
hr = IPropertyBag_Read(prop_bag, L"CLSID", &var, NULL);
|
|
|
|
/* Instantiating the WMT Screen Capture Filter crashes on Windows XP. */
|
|
|
|
if (hr != S_OK || wcscmp(V_BSTR(&var), L"{31087270-D348-432C-899E-2D2F38FF29A0}"))
|
|
|
|
{
|
|
|
|
hr = IMoniker_BindToObject(moniker, NULL, NULL, &IID_IUnknown, (void **)&unk);
|
|
|
|
if (hr == S_OK)
|
|
|
|
IUnknown_Release(unk);
|
|
|
|
hr2 = IMoniker_BindToObject(moniker, NULL, (IMoniker *)0xdeadbeef,
|
|
|
|
&IID_IUnknown, (void **)&unk);
|
|
|
|
if (hr2 == S_OK)
|
|
|
|
IUnknown_Release(unk);
|
|
|
|
ok(hr2 == hr, "Expected hr %#x, got %#x.\n", hr, hr2);
|
|
|
|
}
|
|
|
|
|
2020-04-15 05:22:47 +02:00
|
|
|
hr = CreateBindCtx(0, &bindctx);
|
|
|
|
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
|
|
|
hr = IMoniker_BindToStorage(moniker, bindctx, NULL, &IID_IPropertyBag, (LPVOID*)&prop_bag);
|
|
|
|
ok(hr == S_OK, "IMoniker_BindToStorage failed with error %x\n", hr);
|
|
|
|
IPropertyBag_Release(prop_bag);
|
|
|
|
IBindCtx_Release(bindctx);
|
|
|
|
|
2018-12-13 04:21:13 +01:00
|
|
|
VariantClear(&var);
|
2018-07-30 04:06:05 +02:00
|
|
|
CoTaskMemFree(displayname);
|
2018-03-07 03:57:06 +01:00
|
|
|
IPropertyBag_Release(prop_bag);
|
2012-03-28 00:38:39 +02:00
|
|
|
IMoniker_Release(moniker);
|
2019-04-06 02:41:13 +02:00
|
|
|
count++;
|
2012-03-28 00:38:39 +02:00
|
|
|
}
|
|
|
|
IEnumMoniker_Release(enum_moniker);
|
2019-04-06 02:41:13 +02:00
|
|
|
|
|
|
|
ok(count > 0, "CreateClassEnumerator() returned S_OK but no devices were enumerated.\n");
|
2012-03-28 00:38:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-13 04:21:13 +01:00
|
|
|
IEnumMoniker_Release(enum_cat);
|
2012-03-28 00:38:39 +02:00
|
|
|
ICreateDevEnum_Release(create_devenum);
|
|
|
|
}
|
2018-07-30 04:06:06 +02:00
|
|
|
|
2017-03-27 17:41:23 +02:00
|
|
|
static void test_moniker_isequal(void)
|
|
|
|
{
|
|
|
|
HRESULT res;
|
|
|
|
ICreateDevEnum *create_devenum = NULL;
|
|
|
|
IEnumMoniker *enum_moniker0 = NULL, *enum_moniker1 = NULL;
|
|
|
|
IMoniker *moniker0 = NULL, *moniker1 = NULL;
|
|
|
|
|
|
|
|
res = CoCreateInstance(&CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC,
|
|
|
|
&IID_ICreateDevEnum, (LPVOID*)&create_devenum);
|
|
|
|
if (FAILED(res))
|
|
|
|
{
|
|
|
|
skip("Cannot create SystemDeviceEnum object (%x)\n", res);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
res = ICreateDevEnum_CreateClassEnumerator(create_devenum, &CLSID_LegacyAmFilterCategory, &enum_moniker0, 0);
|
|
|
|
ok(SUCCEEDED(res), "Cannot create enum moniker (res = %x)\n", res);
|
|
|
|
if (SUCCEEDED(res))
|
|
|
|
{
|
2017-06-13 11:50:01 +02:00
|
|
|
if (IEnumMoniker_Next(enum_moniker0, 1, &moniker0, NULL) == S_OK &&
|
|
|
|
IEnumMoniker_Next(enum_moniker0, 1, &moniker1, NULL) == S_OK)
|
2017-03-27 17:41:23 +02:00
|
|
|
{
|
|
|
|
res = IMoniker_IsEqual(moniker0, moniker1);
|
|
|
|
ok(res == S_FALSE, "IMoniker_IsEqual should fail (res = %x)\n", res);
|
|
|
|
|
|
|
|
res = IMoniker_IsEqual(moniker1, moniker0);
|
|
|
|
ok(res == S_FALSE, "IMoniker_IsEqual should fail (res = %x)\n", res);
|
|
|
|
|
|
|
|
IMoniker_Release(moniker0);
|
|
|
|
IMoniker_Release(moniker1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
skip("Cannot get moniker for testing.\n");
|
|
|
|
}
|
|
|
|
IEnumMoniker_Release(enum_moniker0);
|
|
|
|
|
|
|
|
res = ICreateDevEnum_CreateClassEnumerator(create_devenum, &CLSID_LegacyAmFilterCategory, &enum_moniker0, 0);
|
|
|
|
ok(SUCCEEDED(res), "Cannot create enum moniker (res = %x)\n", res);
|
|
|
|
res = ICreateDevEnum_CreateClassEnumerator(create_devenum, &CLSID_AudioRendererCategory, &enum_moniker1, 0);
|
|
|
|
ok(SUCCEEDED(res), "Cannot create enum moniker (res = %x)\n", res);
|
|
|
|
if (SUCCEEDED(res))
|
|
|
|
{
|
2017-06-13 11:50:01 +02:00
|
|
|
if (IEnumMoniker_Next(enum_moniker0, 1, &moniker0, NULL) == S_OK &&
|
|
|
|
IEnumMoniker_Next(enum_moniker1, 1, &moniker1, NULL) == S_OK)
|
2017-03-27 17:41:23 +02:00
|
|
|
{
|
|
|
|
res = IMoniker_IsEqual(moniker0, moniker1);
|
|
|
|
ok(res == S_FALSE, "IMoniker_IsEqual should failed (res = %x)\n", res);
|
|
|
|
|
|
|
|
res = IMoniker_IsEqual(moniker1, moniker0);
|
|
|
|
ok(res == S_FALSE, "IMoniker_IsEqual should failed (res = %x)\n", res);
|
|
|
|
|
|
|
|
IMoniker_Release(moniker0);
|
|
|
|
IMoniker_Release(moniker1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
skip("Cannot get moniker for testing.\n");
|
|
|
|
}
|
|
|
|
IEnumMoniker_Release(enum_moniker0);
|
|
|
|
IEnumMoniker_Release(enum_moniker1);
|
|
|
|
|
|
|
|
res = ICreateDevEnum_CreateClassEnumerator(create_devenum, &CLSID_LegacyAmFilterCategory, &enum_moniker0, 0);
|
|
|
|
ok(SUCCEEDED(res), "Cannot create enum moniker (res = %x)\n", res);
|
|
|
|
res = ICreateDevEnum_CreateClassEnumerator(create_devenum, &CLSID_LegacyAmFilterCategory, &enum_moniker1, 0);
|
|
|
|
ok(SUCCEEDED(res), "Cannot create enum moniker (res = %x)\n", res);
|
|
|
|
if (SUCCEEDED(res))
|
|
|
|
{
|
2017-06-13 11:50:01 +02:00
|
|
|
if (IEnumMoniker_Next(enum_moniker0, 1, &moniker0, NULL) == S_OK &&
|
|
|
|
IEnumMoniker_Next(enum_moniker1, 1, &moniker1, NULL) == S_OK)
|
2017-03-27 17:41:23 +02:00
|
|
|
{
|
|
|
|
res = IMoniker_IsEqual(moniker0, moniker1);
|
|
|
|
ok(res == S_OK, "IMoniker_IsEqual failed (res = %x)\n", res);
|
|
|
|
|
|
|
|
res = IMoniker_IsEqual(moniker1, moniker0);
|
|
|
|
ok(res == S_OK, "IMoniker_IsEqual failed (res = %x)\n", res);
|
|
|
|
|
|
|
|
IMoniker_Release(moniker0);
|
|
|
|
IMoniker_Release(moniker1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
skip("Cannot get moniker for testing.\n");
|
|
|
|
}
|
|
|
|
IEnumMoniker_Release(enum_moniker0);
|
|
|
|
IEnumMoniker_Release(enum_moniker1);
|
|
|
|
|
|
|
|
ICreateDevEnum_Release(create_devenum);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2012-03-28 00:38:39 +02:00
|
|
|
|
2018-03-07 03:57:07 +01:00
|
|
|
static BOOL find_moniker(const GUID *class, IMoniker *needle)
|
|
|
|
{
|
|
|
|
ICreateDevEnum *devenum;
|
|
|
|
IEnumMoniker *enum_mon;
|
|
|
|
IMoniker *mon;
|
|
|
|
BOOL found = FALSE;
|
|
|
|
|
|
|
|
CoCreateInstance(&CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC, &IID_ICreateDevEnum, (void **)&devenum);
|
2020-05-14 00:03:08 +02:00
|
|
|
if (ICreateDevEnum_CreateClassEnumerator(devenum, class, &enum_mon, 0) == S_OK)
|
2018-03-07 03:57:07 +01:00
|
|
|
{
|
2020-05-14 00:03:08 +02:00
|
|
|
while (!found && IEnumMoniker_Next(enum_mon, 1, &mon, NULL) == S_OK)
|
|
|
|
{
|
|
|
|
if (IMoniker_IsEqual(mon, needle) == S_OK)
|
|
|
|
found = TRUE;
|
2018-03-07 03:57:07 +01:00
|
|
|
|
2020-05-14 00:03:08 +02:00
|
|
|
IMoniker_Release(mon);
|
|
|
|
}
|
2018-03-07 03:57:07 +01:00
|
|
|
|
2020-05-14 00:03:08 +02:00
|
|
|
IEnumMoniker_Release(enum_mon);
|
|
|
|
}
|
2018-03-07 03:57:07 +01:00
|
|
|
ICreateDevEnum_Release(devenum);
|
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_GUID(CLSID_TestFilter, 0xdeadbeef,0xcf51,0x43e6,0xb6,0xc5,0x29,0x9e,0xa8,0xb6,0xb5,0x91);
|
|
|
|
|
|
|
|
static void test_register_filter(void)
|
|
|
|
{
|
|
|
|
IFilterMapper2 *mapper2;
|
|
|
|
IMoniker *mon = NULL;
|
|
|
|
REGFILTER2 rgf2 = {0};
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC, &IID_IFilterMapper2, (void **)&mapper2);
|
|
|
|
ok(hr == S_OK, "Failed to create FilterMapper2: %#x\n", hr);
|
|
|
|
|
|
|
|
rgf2.dwVersion = 2;
|
|
|
|
rgf2.dwMerit = MERIT_UNLIKELY;
|
|
|
|
S2(U(rgf2)).cPins2 = 0;
|
|
|
|
|
2020-04-14 07:16:00 +02:00
|
|
|
hr = IFilterMapper2_RegisterFilter(mapper2, &CLSID_TestFilter, L"devenum test", &mon, NULL, NULL, &rgf2);
|
2018-03-07 03:57:07 +01:00
|
|
|
if (hr == E_ACCESSDENIED)
|
|
|
|
{
|
|
|
|
skip("Not enough permissions to register filters\n");
|
|
|
|
IFilterMapper2_Release(mapper2);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ok(hr == S_OK, "RegisterFilter failed: %#x\n", hr);
|
|
|
|
|
|
|
|
ok(find_moniker(&CLSID_LegacyAmFilterCategory, mon), "filter should be registered\n");
|
|
|
|
|
|
|
|
hr = IFilterMapper2_UnregisterFilter(mapper2, NULL, NULL, &CLSID_TestFilter);
|
|
|
|
ok(hr == S_OK, "UnregisterFilter failed: %#x\n", hr);
|
|
|
|
|
|
|
|
ok(!find_moniker(&CLSID_LegacyAmFilterCategory, mon), "filter should not be registered\n");
|
|
|
|
IMoniker_Release(mon);
|
|
|
|
|
|
|
|
mon = NULL;
|
2020-04-14 07:16:00 +02:00
|
|
|
hr = IFilterMapper2_RegisterFilter(mapper2, &CLSID_TestFilter, L"devenum test", &mon, &CLSID_AudioRendererCategory, NULL, &rgf2);
|
2018-03-07 03:57:07 +01:00
|
|
|
ok(hr == S_OK, "RegisterFilter failed: %#x\n", hr);
|
|
|
|
|
|
|
|
ok(find_moniker(&CLSID_AudioRendererCategory, mon), "filter should be registered\n");
|
|
|
|
|
|
|
|
hr = IFilterMapper2_UnregisterFilter(mapper2, &CLSID_AudioRendererCategory, NULL, &CLSID_TestFilter);
|
|
|
|
ok(hr == S_OK, "UnregisterFilter failed: %#x\n", hr);
|
|
|
|
|
|
|
|
ok(!find_moniker(&CLSID_AudioRendererCategory, mon), "filter should not be registered\n");
|
|
|
|
IMoniker_Release(mon);
|
|
|
|
|
|
|
|
IFilterMapper2_Release(mapper2);
|
|
|
|
}
|
2012-03-28 00:38:39 +02:00
|
|
|
|
2018-03-07 03:57:08 +01:00
|
|
|
static IMoniker *check_display_name_(int line, IParseDisplayName *parser, WCHAR *buffer)
|
|
|
|
{
|
|
|
|
IMoniker *mon;
|
|
|
|
ULONG eaten;
|
|
|
|
HRESULT hr;
|
|
|
|
WCHAR *str;
|
|
|
|
|
|
|
|
hr = IParseDisplayName_ParseDisplayName(parser, NULL, buffer, &eaten, &mon);
|
|
|
|
ok_(__FILE__, line)(hr == S_OK, "ParseDisplayName failed: %#x\n", hr);
|
|
|
|
|
|
|
|
hr = IMoniker_GetDisplayName(mon, NULL, NULL, &str);
|
|
|
|
ok_(__FILE__, line)(hr == S_OK, "GetDisplayName failed: %#x\n", hr);
|
2020-04-14 07:16:00 +02:00
|
|
|
ok_(__FILE__, line)(!wcscmp(str, buffer), "got %s\n", wine_dbgstr_w(str));
|
2018-03-07 03:57:08 +01:00
|
|
|
|
|
|
|
CoTaskMemFree(str);
|
|
|
|
|
|
|
|
return mon;
|
|
|
|
}
|
|
|
|
#define check_display_name(parser, buffer) check_display_name_(__LINE__, parser, buffer)
|
|
|
|
|
|
|
|
static void test_directshow_filter(void)
|
|
|
|
{
|
2020-04-14 07:16:01 +02:00
|
|
|
SAFEARRAYBOUND bound = {.cElements = 10};
|
2018-03-07 03:57:08 +01:00
|
|
|
IParseDisplayName *parser;
|
|
|
|
IPropertyBag *prop_bag;
|
2020-04-14 07:16:01 +02:00
|
|
|
void *array_data;
|
2018-03-07 03:57:08 +01:00
|
|
|
IMoniker *mon;
|
|
|
|
WCHAR buffer[200];
|
|
|
|
LRESULT res;
|
|
|
|
VARIANT var;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
/* Test ParseDisplayName and GetDisplayName */
|
|
|
|
hr = CoCreateInstance(&CLSID_CDeviceMoniker, NULL, CLSCTX_INPROC, &IID_IParseDisplayName, (void **)&parser);
|
|
|
|
ok(hr == S_OK, "Failed to create ParseDisplayName: %#x\n", hr);
|
|
|
|
|
2020-04-14 07:16:00 +02:00
|
|
|
wcscpy(buffer, L"@device:sw:");
|
|
|
|
StringFromGUID2(&CLSID_AudioRendererCategory, buffer + wcslen(buffer), CHARS_IN_GUID);
|
|
|
|
wcscat(buffer, L"\\test");
|
2018-03-07 03:57:08 +01:00
|
|
|
mon = check_display_name(parser, buffer);
|
|
|
|
|
|
|
|
/* Test writing and reading from the property bag */
|
|
|
|
ok(!find_moniker(&CLSID_AudioRendererCategory, mon), "filter should not be registered\n");
|
|
|
|
|
|
|
|
hr = IMoniker_BindToStorage(mon, NULL, NULL, &IID_IPropertyBag, (void **)&prop_bag);
|
|
|
|
ok(hr == S_OK, "BindToStorage failed: %#x\n", hr);
|
|
|
|
|
|
|
|
VariantInit(&var);
|
2020-04-14 07:16:00 +02:00
|
|
|
hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL);
|
2018-03-07 03:57:08 +01:00
|
|
|
ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "got %#x\n", hr);
|
|
|
|
|
|
|
|
/* writing causes the key to be created */
|
|
|
|
V_VT(&var) = VT_BSTR;
|
2020-04-14 07:16:00 +02:00
|
|
|
V_BSTR(&var) = SysAllocString(L"test");
|
|
|
|
hr = IPropertyBag_Write(prop_bag, L"FriendlyName", &var);
|
2018-03-07 03:57:08 +01:00
|
|
|
if (hr != E_ACCESSDENIED)
|
|
|
|
{
|
|
|
|
ok(hr == S_OK, "Write failed: %#x\n", hr);
|
|
|
|
|
|
|
|
ok(find_moniker(&CLSID_AudioRendererCategory, mon), "filter should be registered\n");
|
|
|
|
|
|
|
|
VariantClear(&var);
|
2020-04-14 07:16:01 +02:00
|
|
|
V_VT(&var) = VT_EMPTY;
|
2020-04-14 07:16:00 +02:00
|
|
|
hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL);
|
2020-04-14 07:16:01 +02:00
|
|
|
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
|
|
|
ok(V_VT(&var) == VT_BSTR, "Got type %#x.\n", V_VT(&var));
|
|
|
|
ok(!wcscmp(V_BSTR(&var), L"test"), "Got name %s.\n", wine_dbgstr_w(V_BSTR(&var)));
|
|
|
|
|
|
|
|
VariantClear(&var);
|
|
|
|
V_VT(&var) = VT_LPWSTR;
|
|
|
|
hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL);
|
2020-04-14 07:16:02 +02:00
|
|
|
ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr);
|
2020-04-14 07:16:01 +02:00
|
|
|
|
|
|
|
V_VT(&var) = VT_BSTR;
|
|
|
|
hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL);
|
|
|
|
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
|
|
|
ok(V_VT(&var) == VT_BSTR, "Got type %#x.\n", V_VT(&var));
|
|
|
|
ok(!wcscmp(V_BSTR(&var), L"test"), "Got name %s.\n", wine_dbgstr_w(V_BSTR(&var)));
|
|
|
|
|
|
|
|
V_VT(&var) = VT_LPWSTR;
|
|
|
|
hr = IPropertyBag_Write(prop_bag, L"FriendlyName", &var);
|
2020-04-15 05:22:48 +02:00
|
|
|
ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr);
|
2020-04-14 07:16:01 +02:00
|
|
|
VariantClear(&var);
|
|
|
|
|
|
|
|
V_VT(&var) = VT_I4;
|
|
|
|
V_I4(&var) = 0xdeadbeef;
|
|
|
|
hr = IPropertyBag_Write(prop_bag, L"foobar", &var);
|
|
|
|
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
|
|
|
|
|
|
|
V_VT(&var) = VT_EMPTY;
|
|
|
|
hr = IPropertyBag_Read(prop_bag, L"foobar", &var, NULL);
|
|
|
|
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
|
|
|
ok(V_VT(&var) == VT_I4, "Got type %#x.\n", V_VT(&var));
|
|
|
|
ok(V_I4(&var) == 0xdeadbeef, "Got value %#x.\n", V_I4(&var));
|
|
|
|
|
|
|
|
V_VT(&var) = VT_UI4;
|
|
|
|
hr = IPropertyBag_Read(prop_bag, L"foobar", &var, NULL);
|
2020-04-14 07:16:03 +02:00
|
|
|
ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr);
|
2020-04-14 07:16:01 +02:00
|
|
|
V_VT(&var) = VT_BSTR;
|
|
|
|
hr = IPropertyBag_Read(prop_bag, L"foobar", &var, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr);
|
|
|
|
|
|
|
|
V_VT(&var) = VT_I4;
|
|
|
|
hr = IPropertyBag_Read(prop_bag, L"foobar", &var, NULL);
|
|
|
|
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
|
|
|
ok(V_VT(&var) == VT_I4, "Got type %#x.\n", V_VT(&var));
|
|
|
|
ok(V_I4(&var) == 0xdeadbeef, "Got value %#x.\n", V_I4(&var));
|
|
|
|
|
|
|
|
V_VT(&var) = VT_UI4;
|
|
|
|
hr = IPropertyBag_Write(prop_bag, L"foobar", &var);
|
2020-04-15 05:22:48 +02:00
|
|
|
ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr);
|
2020-04-14 07:16:01 +02:00
|
|
|
|
|
|
|
V_VT(&var) = VT_ARRAY | VT_UI1;
|
|
|
|
V_ARRAY(&var) = SafeArrayCreate(VT_UI1, 1, &bound);
|
|
|
|
SafeArrayAccessData(V_ARRAY(&var), &array_data);
|
|
|
|
memcpy(array_data, "test data", 10);
|
|
|
|
SafeArrayUnaccessData(V_ARRAY(&var));
|
|
|
|
hr = IPropertyBag_Write(prop_bag, L"foobar", &var);
|
|
|
|
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
|
|
|
|
|
|
|
VariantClear(&var);
|
|
|
|
V_VT(&var) = VT_EMPTY;
|
|
|
|
hr = IPropertyBag_Read(prop_bag, L"foobar", &var, NULL);
|
|
|
|
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
|
|
|
ok(V_VT(&var) == (VT_ARRAY | VT_UI1), "Got type %#x.\n", V_VT(&var));
|
|
|
|
SafeArrayAccessData(V_ARRAY(&var), &array_data);
|
|
|
|
ok(!memcmp(array_data, "test data", 10), "Got wrong data.\n");
|
|
|
|
SafeArrayUnaccessData(V_ARRAY(&var));
|
2018-03-07 03:57:08 +01:00
|
|
|
|
|
|
|
IMoniker_Release(mon);
|
|
|
|
|
|
|
|
/* devenum doesn't give us a way to unregister—we have to do that manually */
|
2020-04-14 07:16:00 +02:00
|
|
|
wcscpy(buffer, L"CLSID\\");
|
|
|
|
StringFromGUID2(&CLSID_AudioRendererCategory, buffer + wcslen(buffer), CHARS_IN_GUID);
|
|
|
|
wcscat(buffer, L"\\Instance\\test");
|
2018-03-07 03:57:08 +01:00
|
|
|
res = RegDeleteKeyW(HKEY_CLASSES_ROOT, buffer);
|
|
|
|
ok(!res, "RegDeleteKey failed: %lu\n", res);
|
|
|
|
}
|
|
|
|
|
2018-03-07 03:57:09 +01:00
|
|
|
VariantClear(&var);
|
|
|
|
IPropertyBag_Release(prop_bag);
|
|
|
|
|
|
|
|
/* name can be anything */
|
|
|
|
|
2020-04-14 07:16:00 +02:00
|
|
|
wcscpy(buffer, L"@device:sw:test");
|
2018-03-07 03:57:09 +01:00
|
|
|
mon = check_display_name(parser, buffer);
|
|
|
|
|
|
|
|
hr = IMoniker_BindToStorage(mon, NULL, NULL, &IID_IPropertyBag, (void **)&prop_bag);
|
|
|
|
ok(hr == S_OK, "BindToStorage failed: %#x\n", hr);
|
|
|
|
|
|
|
|
VariantClear(&var);
|
2020-04-14 07:16:00 +02:00
|
|
|
hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL);
|
2018-03-07 03:57:09 +01:00
|
|
|
ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "got %#x\n", hr);
|
|
|
|
|
|
|
|
V_VT(&var) = VT_BSTR;
|
2020-04-14 07:16:00 +02:00
|
|
|
V_BSTR(&var) = SysAllocString(L"test");
|
|
|
|
hr = IPropertyBag_Write(prop_bag, L"FriendlyName", &var);
|
2018-03-07 03:57:09 +01:00
|
|
|
if (hr != E_ACCESSDENIED)
|
|
|
|
{
|
|
|
|
ok(hr == S_OK, "Write failed: %#x\n", hr);
|
|
|
|
|
|
|
|
VariantClear(&var);
|
2020-04-14 07:16:00 +02:00
|
|
|
hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL);
|
2018-03-07 03:57:09 +01:00
|
|
|
ok(hr == S_OK, "Read failed: %#x\n", hr);
|
2020-04-14 07:16:00 +02:00
|
|
|
ok(!wcscmp(V_BSTR(&var), L"test"), "got %s\n", wine_dbgstr_w(V_BSTR(&var)));
|
2018-03-07 03:57:09 +01:00
|
|
|
|
|
|
|
IMoniker_Release(mon);
|
|
|
|
|
|
|
|
/* vista+ stores it inside the Instance key */
|
|
|
|
RegDeleteKeyA(HKEY_CLASSES_ROOT, "CLSID\\test\\Instance");
|
|
|
|
|
|
|
|
res = RegDeleteKeyA(HKEY_CLASSES_ROOT, "CLSID\\test");
|
|
|
|
ok(!res, "RegDeleteKey failed: %lu\n", res);
|
|
|
|
}
|
|
|
|
|
2018-03-07 03:57:08 +01:00
|
|
|
VariantClear(&var);
|
|
|
|
IPropertyBag_Release(prop_bag);
|
|
|
|
IParseDisplayName_Release(parser);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_codec(void)
|
|
|
|
{
|
2020-04-14 07:16:01 +02:00
|
|
|
SAFEARRAYBOUND bound = {.cElements = 10};
|
2018-03-07 03:57:08 +01:00
|
|
|
IParseDisplayName *parser;
|
|
|
|
IPropertyBag *prop_bag;
|
2020-04-14 07:16:01 +02:00
|
|
|
void *array_data;
|
2018-03-07 03:57:08 +01:00
|
|
|
IMoniker *mon;
|
|
|
|
WCHAR buffer[200];
|
|
|
|
VARIANT var;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
/* Test ParseDisplayName and GetDisplayName */
|
|
|
|
hr = CoCreateInstance(&CLSID_CDeviceMoniker, NULL, CLSCTX_INPROC, &IID_IParseDisplayName, (void **)&parser);
|
|
|
|
ok(hr == S_OK, "Failed to create ParseDisplayName: %#x\n", hr);
|
|
|
|
|
2020-04-14 07:16:00 +02:00
|
|
|
wcscpy(buffer, L"@device:cm:");
|
|
|
|
StringFromGUID2(&CLSID_AudioRendererCategory, buffer + wcslen(buffer), CHARS_IN_GUID);
|
|
|
|
wcscat(buffer, L"\\test");
|
2018-03-07 03:57:08 +01:00
|
|
|
mon = check_display_name(parser, buffer);
|
|
|
|
|
|
|
|
/* Test writing and reading from the property bag */
|
|
|
|
ok(!find_moniker(&CLSID_AudioRendererCategory, mon), "codec should not be registered\n");
|
|
|
|
|
|
|
|
hr = IMoniker_BindToStorage(mon, NULL, NULL, &IID_IPropertyBag, (void **)&prop_bag);
|
|
|
|
ok(hr == S_OK, "BindToStorage failed: %#x\n", hr);
|
|
|
|
|
|
|
|
VariantInit(&var);
|
2020-04-14 07:16:00 +02:00
|
|
|
hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL);
|
2018-03-07 03:57:08 +01:00
|
|
|
ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "got %#x\n", hr);
|
|
|
|
|
|
|
|
V_VT(&var) = VT_BSTR;
|
2020-04-14 07:16:00 +02:00
|
|
|
V_BSTR(&var) = SysAllocString(L"test");
|
|
|
|
hr = IPropertyBag_Write(prop_bag, L"FriendlyName", &var);
|
2018-03-07 03:57:08 +01:00
|
|
|
ok(hr == S_OK, "Write failed: %#x\n", hr);
|
|
|
|
|
2020-04-14 07:16:01 +02:00
|
|
|
V_VT(&var) = VT_LPWSTR;
|
|
|
|
hr = IPropertyBag_Write(prop_bag, L"FriendlyName", &var);
|
2020-04-15 05:22:48 +02:00
|
|
|
ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr);
|
2020-04-14 07:16:01 +02:00
|
|
|
|
|
|
|
VariantClear(&var);
|
|
|
|
V_VT(&var) = VT_EMPTY;
|
|
|
|
hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL);
|
|
|
|
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
|
|
|
ok(V_VT(&var) == VT_BSTR, "Got type %#x.\n", V_VT(&var));
|
|
|
|
ok(!wcscmp(V_BSTR(&var), L"test"), "Got name %s.\n", wine_dbgstr_w(V_BSTR(&var)));
|
|
|
|
|
2018-03-07 03:57:08 +01:00
|
|
|
VariantClear(&var);
|
2020-04-14 07:16:01 +02:00
|
|
|
V_VT(&var) = VT_LPWSTR;
|
2020-04-14 07:16:00 +02:00
|
|
|
hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL);
|
2020-04-14 07:16:02 +02:00
|
|
|
ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr);
|
2020-04-14 07:16:01 +02:00
|
|
|
|
|
|
|
V_VT(&var) = VT_BSTR;
|
|
|
|
hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL);
|
|
|
|
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
|
|
|
ok(V_VT(&var) == VT_BSTR, "Got type %#x.\n", V_VT(&var));
|
|
|
|
ok(!wcscmp(V_BSTR(&var), L"test"), "Got name %s.\n", wine_dbgstr_w(V_BSTR(&var)));
|
|
|
|
|
|
|
|
V_VT(&var) = VT_I4;
|
|
|
|
V_I4(&var) = 0xdeadbeef;
|
|
|
|
hr = IPropertyBag_Write(prop_bag, L"foobar", &var);
|
|
|
|
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
|
|
|
|
|
|
|
V_VT(&var) = VT_EMPTY;
|
|
|
|
hr = IPropertyBag_Read(prop_bag, L"foobar", &var, NULL);
|
|
|
|
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
|
|
|
ok(V_VT(&var) == VT_I4, "Got type %#x.\n", V_VT(&var));
|
|
|
|
ok(V_I4(&var) == 0xdeadbeef, "Got value %#x.\n", V_I4(&var));
|
|
|
|
|
|
|
|
V_VT(&var) = VT_UI4;
|
|
|
|
hr = IPropertyBag_Read(prop_bag, L"foobar", &var, NULL);
|
2020-04-14 07:16:03 +02:00
|
|
|
ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr);
|
2020-04-14 07:16:01 +02:00
|
|
|
V_VT(&var) = VT_BSTR;
|
|
|
|
hr = IPropertyBag_Read(prop_bag, L"foobar", &var, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr);
|
|
|
|
|
|
|
|
V_VT(&var) = VT_I4;
|
|
|
|
hr = IPropertyBag_Read(prop_bag, L"foobar", &var, NULL);
|
|
|
|
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
|
|
|
ok(V_VT(&var) == VT_I4, "Got type %#x.\n", V_VT(&var));
|
|
|
|
ok(V_I4(&var) == 0xdeadbeef, "Got value %#x.\n", V_I4(&var));
|
|
|
|
|
|
|
|
V_VT(&var) = VT_UI4;
|
|
|
|
hr = IPropertyBag_Write(prop_bag, L"foobar", &var);
|
2020-04-15 05:22:48 +02:00
|
|
|
ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr);
|
2020-04-14 07:16:01 +02:00
|
|
|
|
|
|
|
V_VT(&var) = VT_ARRAY | VT_UI1;
|
|
|
|
V_ARRAY(&var) = SafeArrayCreate(VT_UI1, 1, &bound);
|
|
|
|
SafeArrayAccessData(V_ARRAY(&var), &array_data);
|
|
|
|
memcpy(array_data, "test data", 10);
|
|
|
|
SafeArrayUnaccessData(V_ARRAY(&var));
|
|
|
|
hr = IPropertyBag_Write(prop_bag, L"foobar", &var);
|
|
|
|
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
2018-03-07 03:57:08 +01:00
|
|
|
|
|
|
|
/* unlike DirectShow filters, these are automatically generated, so
|
|
|
|
* enumerating them will destroy the key */
|
|
|
|
ok(!find_moniker(&CLSID_AudioRendererCategory, mon), "codec should not be registered\n");
|
|
|
|
|
2018-12-13 04:21:13 +01:00
|
|
|
VariantClear(&var);
|
2020-04-14 07:16:00 +02:00
|
|
|
hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL);
|
2018-03-07 03:57:08 +01:00
|
|
|
ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "got %#x\n", hr);
|
|
|
|
|
|
|
|
IPropertyBag_Release(prop_bag);
|
|
|
|
IMoniker_Release(mon);
|
|
|
|
|
|
|
|
IParseDisplayName_Release(parser);
|
|
|
|
}
|
|
|
|
|
2020-05-14 00:03:08 +02:00
|
|
|
static void test_dmo(const GUID *dmo_category, const GUID *enum_category)
|
2018-06-25 00:20:29 +02:00
|
|
|
{
|
|
|
|
IParseDisplayName *parser;
|
|
|
|
IPropertyBag *prop_bag;
|
2020-04-16 21:46:06 +02:00
|
|
|
IBaseFilter *filter;
|
|
|
|
IMediaObject *dmo;
|
|
|
|
IEnumDMO *enumdmo;
|
2018-06-25 00:20:29 +02:00
|
|
|
WCHAR buffer[200];
|
|
|
|
IMoniker *mon;
|
|
|
|
VARIANT var;
|
2020-04-16 21:46:06 +02:00
|
|
|
WCHAR *name;
|
2018-06-25 00:20:29 +02:00
|
|
|
HRESULT hr;
|
2020-04-16 21:46:06 +02:00
|
|
|
GUID clsid;
|
2018-06-25 00:20:29 +02:00
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_CDeviceMoniker, NULL, CLSCTX_INPROC, &IID_IParseDisplayName, (void **)&parser);
|
|
|
|
ok(hr == S_OK, "Failed to create ParseDisplayName: %#x\n", hr);
|
|
|
|
|
2020-04-14 07:16:00 +02:00
|
|
|
wcscpy(buffer, L"@device:dmo:");
|
|
|
|
StringFromGUID2(&CLSID_TestFilter, buffer + wcslen(buffer), CHARS_IN_GUID);
|
2020-05-14 00:03:08 +02:00
|
|
|
StringFromGUID2(dmo_category, buffer + wcslen(buffer), CHARS_IN_GUID);
|
2018-06-25 00:20:29 +02:00
|
|
|
mon = check_display_name(parser, buffer);
|
|
|
|
|
2020-05-14 00:03:08 +02:00
|
|
|
ok(!find_moniker(enum_category, mon), "DMO should not be registered\n");
|
2018-06-25 00:20:29 +02:00
|
|
|
|
|
|
|
hr = IMoniker_BindToStorage(mon, NULL, NULL, &IID_IPropertyBag, (void **)&prop_bag);
|
|
|
|
ok(hr == S_OK, "got %#x\n", hr);
|
|
|
|
|
|
|
|
VariantInit(&var);
|
2020-04-14 07:16:00 +02:00
|
|
|
hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL);
|
2018-06-25 00:20:29 +02:00
|
|
|
ok(hr == E_FAIL, "got %#x\n", hr);
|
|
|
|
|
|
|
|
V_VT(&var) = VT_BSTR;
|
2020-04-14 07:16:00 +02:00
|
|
|
V_BSTR(&var) = SysAllocString(L"devenum test");
|
|
|
|
hr = IPropertyBag_Write(prop_bag, L"FriendlyName", &var);
|
2018-06-25 00:20:29 +02:00
|
|
|
ok(hr == E_ACCESSDENIED, "Write failed: %#x\n", hr);
|
|
|
|
|
2020-05-14 00:03:08 +02:00
|
|
|
hr = DMORegister(L"devenum test", &CLSID_TestFilter, dmo_category, 0, 0, NULL, 0, NULL);
|
2018-06-28 12:03:47 +02:00
|
|
|
if (hr != E_FAIL)
|
2018-06-25 00:20:29 +02:00
|
|
|
{
|
|
|
|
ok(hr == S_OK, "got %#x\n", hr);
|
|
|
|
|
2020-05-14 00:03:08 +02:00
|
|
|
ok(find_moniker(enum_category, mon), "DMO should be registered\n");
|
2018-06-25 00:20:30 +02:00
|
|
|
|
2018-06-25 00:20:29 +02:00
|
|
|
VariantClear(&var);
|
2020-04-14 07:16:00 +02:00
|
|
|
hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL);
|
2018-06-25 00:20:29 +02:00
|
|
|
ok(hr == S_OK, "got %#x\n", hr);
|
2020-04-14 07:16:00 +02:00
|
|
|
ok(!wcscmp(V_BSTR(&var), L"devenum test"), "got %s\n", wine_dbgstr_w(V_BSTR(&var)));
|
2018-06-25 00:20:29 +02:00
|
|
|
|
|
|
|
VariantClear(&var);
|
|
|
|
V_VT(&var) = VT_BSTR;
|
2020-04-14 07:16:00 +02:00
|
|
|
V_BSTR(&var) = SysAllocString(L"devenum test");
|
|
|
|
hr = IPropertyBag_Write(prop_bag, L"FriendlyName", &var);
|
2018-06-25 00:20:29 +02:00
|
|
|
ok(hr == E_ACCESSDENIED, "Write failed: %#x\n", hr);
|
|
|
|
|
|
|
|
VariantClear(&var);
|
2020-04-14 07:16:00 +02:00
|
|
|
hr = IPropertyBag_Read(prop_bag, L"CLSID", &var, NULL);
|
2018-06-25 00:20:29 +02:00
|
|
|
ok(hr == HRESULT_FROM_WIN32(ERROR_NOT_FOUND), "got %#x\n", hr);
|
|
|
|
|
2020-05-14 00:03:08 +02:00
|
|
|
hr = DMOUnregister(&CLSID_TestFilter, dmo_category);
|
2018-06-25 00:20:29 +02:00
|
|
|
ok(hr == S_OK, "got %#x\n", hr);
|
|
|
|
}
|
|
|
|
IPropertyBag_Release(prop_bag);
|
|
|
|
IMoniker_Release(mon);
|
2020-04-16 21:46:06 +02:00
|
|
|
|
|
|
|
hr = DMOEnum(&DMOCATEGORY_AUDIO_DECODER, 0, 0, NULL, 0, NULL, &enumdmo);
|
|
|
|
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
|
|
|
|
|
|
|
while (IEnumDMO_Next(enumdmo, 1, &clsid, &name, NULL) == S_OK)
|
|
|
|
{
|
|
|
|
wcscpy(buffer, L"@device:dmo:");
|
|
|
|
StringFromGUID2(&clsid, buffer + wcslen(buffer), CHARS_IN_GUID);
|
|
|
|
StringFromGUID2(&DMOCATEGORY_AUDIO_DECODER, buffer + wcslen(buffer), CHARS_IN_GUID);
|
|
|
|
mon = check_display_name(parser, buffer);
|
|
|
|
ok(find_moniker(&DMOCATEGORY_AUDIO_DECODER, mon), "DMO was not found.\n");
|
|
|
|
|
|
|
|
hr = IMoniker_BindToStorage(mon, NULL, NULL, &IID_IPropertyBag, (void **)&prop_bag);
|
|
|
|
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
|
|
|
|
|
|
|
VariantClear(&var);
|
|
|
|
hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL);
|
|
|
|
ok(hr == S_OK, "got %#x\n", hr);
|
|
|
|
ok(!wcscmp(V_BSTR(&var), name), "got %s\n", wine_dbgstr_w(V_BSTR(&var)));
|
|
|
|
|
|
|
|
VariantClear(&var);
|
|
|
|
V_VT(&var) = VT_BSTR;
|
|
|
|
V_BSTR(&var) = SysAllocString(L"devenum test");
|
|
|
|
hr = IPropertyBag_Write(prop_bag, L"FriendlyName", &var);
|
|
|
|
ok(hr == E_ACCESSDENIED, "Write failed: %#x\n", hr);
|
|
|
|
|
|
|
|
VariantClear(&var);
|
|
|
|
hr = IPropertyBag_Read(prop_bag, L"CLSID", &var, NULL);
|
|
|
|
ok(hr == HRESULT_FROM_WIN32(ERROR_NOT_FOUND), "got %#x\n", hr);
|
|
|
|
|
|
|
|
IPropertyBag_Release(prop_bag);
|
|
|
|
CoTaskMemFree(name);
|
|
|
|
|
|
|
|
hr = IMoniker_BindToObject(mon, NULL, NULL, &IID_IBaseFilter, (void **)&filter);
|
|
|
|
ok(hr == S_OK, "got %#x\n", hr);
|
|
|
|
|
|
|
|
hr = IBaseFilter_GetClassID(filter, &clsid);
|
|
|
|
ok(hr == S_OK, "got %#x\n", hr);
|
|
|
|
ok(IsEqualGUID(&clsid, &CLSID_DMOWrapperFilter), "Got CLSID %s.\n", debugstr_guid(&clsid));
|
|
|
|
|
|
|
|
hr = IBaseFilter_QueryInterface(filter, &IID_IMediaObject, (void **)&dmo);
|
|
|
|
ok(hr == S_OK, "got %#x\n", hr);
|
|
|
|
IMediaObject_Release(dmo);
|
|
|
|
|
|
|
|
IBaseFilter_Release(filter);
|
|
|
|
}
|
|
|
|
IEnumDMO_Release(enumdmo);
|
|
|
|
|
2018-06-25 00:20:29 +02:00
|
|
|
IParseDisplayName_Release(parser);
|
|
|
|
}
|
|
|
|
|
2018-03-11 05:11:51 +01:00
|
|
|
static void test_legacy_filter(void)
|
|
|
|
{
|
|
|
|
IParseDisplayName *parser;
|
|
|
|
IPropertyBag *prop_bag;
|
|
|
|
IFilterMapper *mapper;
|
|
|
|
IMoniker *mon;
|
|
|
|
WCHAR buffer[200];
|
|
|
|
VARIANT var;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_CDeviceMoniker, NULL, CLSCTX_INPROC, &IID_IParseDisplayName, (void **)&parser);
|
|
|
|
ok(hr == S_OK, "Failed to create ParseDisplayName: %#x\n", hr);
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC, &IID_IFilterMapper, (void **)&mapper);
|
|
|
|
ok(hr == S_OK, "Failed to create FilterMapper: %#x\n", hr);
|
|
|
|
|
2020-04-14 07:16:00 +02:00
|
|
|
hr = IFilterMapper_RegisterFilter(mapper, CLSID_TestFilter, L"test", 0xdeadbeef);
|
2018-03-11 05:11:51 +01:00
|
|
|
if (hr == VFW_E_BAD_KEY)
|
|
|
|
{
|
|
|
|
win_skip("not enough permissions to register filters\n");
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
ok(hr == S_OK, "RegisterFilter failed: %#x\n", hr);
|
|
|
|
|
2020-04-14 07:16:00 +02:00
|
|
|
wcscpy(buffer, L"@device:cm:");
|
|
|
|
StringFromGUID2(&CLSID_LegacyAmFilterCategory, buffer + wcslen(buffer), CHARS_IN_GUID);
|
|
|
|
wcscat(buffer, L"\\");
|
|
|
|
StringFromGUID2(&CLSID_TestFilter, buffer + wcslen(buffer), CHARS_IN_GUID);
|
2018-03-11 05:11:51 +01:00
|
|
|
|
|
|
|
mon = check_display_name(parser, buffer);
|
|
|
|
ok(find_moniker(&CLSID_LegacyAmFilterCategory, mon), "filter should be registered\n");
|
|
|
|
|
|
|
|
hr = IMoniker_BindToStorage(mon, NULL, NULL, &IID_IPropertyBag, (void **)&prop_bag);
|
|
|
|
ok(hr == S_OK, "BindToStorage failed: %#x\n", hr);
|
|
|
|
|
|
|
|
VariantInit(&var);
|
2020-04-14 07:16:00 +02:00
|
|
|
hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL);
|
2018-03-11 05:11:51 +01:00
|
|
|
ok(hr == S_OK, "Read failed: %#x\n", hr);
|
|
|
|
|
|
|
|
StringFromGUID2(&CLSID_TestFilter, buffer, CHARS_IN_GUID);
|
2020-04-14 07:16:00 +02:00
|
|
|
ok(!wcscmp(buffer, V_BSTR(&var)), "expected %s, got %s\n",
|
2018-03-11 05:11:51 +01:00
|
|
|
wine_dbgstr_w(buffer), wine_dbgstr_w(V_BSTR(&var)));
|
|
|
|
|
|
|
|
VariantClear(&var);
|
2020-04-14 07:16:00 +02:00
|
|
|
hr = IPropertyBag_Read(prop_bag, L"CLSID", &var, NULL);
|
2018-03-11 05:11:51 +01:00
|
|
|
ok(hr == S_OK, "Read failed: %#x\n", hr);
|
2020-04-14 07:16:00 +02:00
|
|
|
ok(!wcscmp(buffer, V_BSTR(&var)), "expected %s, got %s\n",
|
2018-03-11 05:11:51 +01:00
|
|
|
wine_dbgstr_w(buffer), wine_dbgstr_w(V_BSTR(&var)));
|
|
|
|
|
2018-12-13 04:21:13 +01:00
|
|
|
VariantClear(&var);
|
2018-03-11 05:11:51 +01:00
|
|
|
IPropertyBag_Release(prop_bag);
|
|
|
|
|
|
|
|
hr = IFilterMapper_UnregisterFilter(mapper, CLSID_TestFilter);
|
|
|
|
ok(hr == S_OK, "UnregisterFilter failed: %#x\n", hr);
|
|
|
|
|
|
|
|
ok(!find_moniker(&CLSID_LegacyAmFilterCategory, mon), "filter should not be registered\n");
|
|
|
|
IMoniker_Release(mon);
|
|
|
|
|
|
|
|
end:
|
|
|
|
IFilterMapper_Release(mapper);
|
|
|
|
IParseDisplayName_Release(parser);
|
|
|
|
}
|
|
|
|
|
2018-03-11 05:11:52 +01:00
|
|
|
static BOOL CALLBACK test_dsound(GUID *guid, const WCHAR *desc, const WCHAR *module, void *context)
|
|
|
|
{
|
|
|
|
IParseDisplayName *parser;
|
|
|
|
IPropertyBag *prop_bag;
|
|
|
|
IMoniker *mon;
|
|
|
|
WCHAR buffer[200];
|
|
|
|
WCHAR name[200];
|
|
|
|
VARIANT var;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if (guid)
|
|
|
|
{
|
2020-04-14 07:16:00 +02:00
|
|
|
wcscpy(name, L"DirectSound: ");
|
|
|
|
wcscat(name, desc);
|
2018-03-11 05:11:52 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-04-14 07:16:00 +02:00
|
|
|
wcscpy(name, L"Default DirectSound Device");
|
2018-03-11 05:11:52 +01:00
|
|
|
guid = (GUID *)&GUID_NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_CDeviceMoniker, NULL, CLSCTX_INPROC, &IID_IParseDisplayName, (void **)&parser);
|
|
|
|
ok(hr == S_OK, "Failed to create ParseDisplayName: %#x\n", hr);
|
|
|
|
|
2020-04-14 07:16:00 +02:00
|
|
|
wcscpy(buffer, L"@device:cm:");
|
|
|
|
StringFromGUID2(&CLSID_AudioRendererCategory, buffer + wcslen(buffer), CHARS_IN_GUID);
|
|
|
|
wcscat(buffer, L"\\");
|
|
|
|
wcscat(buffer, name);
|
2018-03-11 05:11:52 +01:00
|
|
|
|
|
|
|
mon = check_display_name(parser, buffer);
|
|
|
|
|
|
|
|
hr = IMoniker_BindToStorage(mon, NULL, NULL, &IID_IPropertyBag, (void **)&prop_bag);
|
|
|
|
ok(hr == S_OK, "BindToStorage failed: %#x\n", hr);
|
|
|
|
|
|
|
|
VariantInit(&var);
|
2020-04-14 07:16:00 +02:00
|
|
|
hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL);
|
2018-03-11 05:11:52 +01:00
|
|
|
if (hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND))
|
|
|
|
{
|
|
|
|
/* Win8+ uses the GUID instead of the device name */
|
|
|
|
IPropertyBag_Release(prop_bag);
|
|
|
|
IMoniker_Release(mon);
|
|
|
|
|
2020-04-14 07:16:00 +02:00
|
|
|
wcscpy(buffer, L"@device:cm:");
|
|
|
|
StringFromGUID2(&CLSID_AudioRendererCategory, buffer + wcslen(buffer), CHARS_IN_GUID);
|
|
|
|
wcscat(buffer, L"\\DirectSound: ");
|
|
|
|
StringFromGUID2(guid, buffer + wcslen(buffer) - 1, CHARS_IN_GUID);
|
2018-03-11 05:11:52 +01:00
|
|
|
|
|
|
|
mon = check_display_name(parser, buffer);
|
|
|
|
|
|
|
|
hr = IMoniker_BindToStorage(mon, NULL, NULL, &IID_IPropertyBag, (void **)&prop_bag);
|
|
|
|
ok(hr == S_OK, "BindToStorage failed: %#x\n", hr);
|
|
|
|
|
|
|
|
VariantInit(&var);
|
2020-04-14 07:16:00 +02:00
|
|
|
hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL);
|
2018-03-11 05:11:52 +01:00
|
|
|
}
|
|
|
|
ok(hr == S_OK, "Read failed: %#x\n", hr);
|
|
|
|
|
2020-04-14 07:16:00 +02:00
|
|
|
ok(!wcscmp(name, V_BSTR(&var)), "expected %s, got %s\n",
|
2018-03-11 05:11:52 +01:00
|
|
|
wine_dbgstr_w(name), wine_dbgstr_w(V_BSTR(&var)));
|
|
|
|
|
|
|
|
VariantClear(&var);
|
2020-04-14 07:16:00 +02:00
|
|
|
hr = IPropertyBag_Read(prop_bag, L"CLSID", &var, NULL);
|
2018-03-11 05:11:52 +01:00
|
|
|
ok(hr == S_OK, "Read failed: %#x\n", hr);
|
|
|
|
|
|
|
|
StringFromGUID2(&CLSID_DSoundRender, buffer, CHARS_IN_GUID);
|
2020-04-14 07:16:00 +02:00
|
|
|
ok(!wcscmp(buffer, V_BSTR(&var)), "expected %s, got %s\n",
|
2018-03-11 05:11:52 +01:00
|
|
|
wine_dbgstr_w(buffer), wine_dbgstr_w(V_BSTR(&var)));
|
|
|
|
|
|
|
|
VariantClear(&var);
|
2020-04-14 07:16:00 +02:00
|
|
|
hr = IPropertyBag_Read(prop_bag, L"DSGuid", &var, NULL);
|
2018-03-11 05:11:52 +01:00
|
|
|
ok(hr == S_OK, "Read failed: %#x\n", hr);
|
|
|
|
|
|
|
|
StringFromGUID2(guid, buffer, CHARS_IN_GUID);
|
2020-04-14 07:16:00 +02:00
|
|
|
ok(!wcscmp(buffer, V_BSTR(&var)), "expected %s, got %s\n",
|
2018-03-11 05:11:52 +01:00
|
|
|
wine_dbgstr_w(buffer), wine_dbgstr_w(V_BSTR(&var)));
|
|
|
|
|
2018-12-17 21:45:02 +01:00
|
|
|
VariantClear(&var);
|
2018-03-11 05:11:52 +01:00
|
|
|
IPropertyBag_Release(prop_bag);
|
|
|
|
IMoniker_Release(mon);
|
|
|
|
IParseDisplayName_Release(parser);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2018-03-31 23:25:14 +02:00
|
|
|
static void test_waveout(void)
|
|
|
|
{
|
|
|
|
IParseDisplayName *parser;
|
|
|
|
IPropertyBag *prop_bag;
|
|
|
|
IMoniker *mon;
|
|
|
|
WCHAR endpoint[200];
|
|
|
|
WAVEOUTCAPSW caps;
|
|
|
|
WCHAR buffer[200];
|
|
|
|
const WCHAR *name;
|
|
|
|
MMRESULT mmr;
|
|
|
|
int count, i;
|
|
|
|
VARIANT var;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_CDeviceMoniker, NULL, CLSCTX_INPROC, &IID_IParseDisplayName, (void **)&parser);
|
|
|
|
ok(hr == S_OK, "Failed to create ParseDisplayName: %#x\n", hr);
|
|
|
|
|
|
|
|
count = waveOutGetNumDevs();
|
|
|
|
|
|
|
|
for (i = -1; i < count; i++)
|
|
|
|
{
|
|
|
|
waveOutGetDevCapsW(i, &caps, sizeof(caps));
|
|
|
|
|
|
|
|
if (i == -1) /* WAVE_MAPPER */
|
2020-04-14 07:16:00 +02:00
|
|
|
name = L"Default WaveOut Device";
|
2018-03-31 23:25:14 +02:00
|
|
|
else
|
|
|
|
name = caps.szPname;
|
|
|
|
|
2020-04-14 07:16:00 +02:00
|
|
|
wcscpy(buffer, L"@device:cm:");
|
|
|
|
StringFromGUID2(&CLSID_AudioRendererCategory, buffer + wcslen(buffer), CHARS_IN_GUID);
|
|
|
|
wcscat(buffer, L"\\");
|
|
|
|
wcscat(buffer, name);
|
2018-03-31 23:25:14 +02:00
|
|
|
|
|
|
|
mon = check_display_name(parser, buffer);
|
|
|
|
|
|
|
|
hr = IMoniker_BindToStorage(mon, NULL, NULL, &IID_IPropertyBag, (void **)&prop_bag);
|
|
|
|
ok(hr == S_OK, "BindToStorage failed: %#x\n", hr);
|
|
|
|
|
|
|
|
VariantInit(&var);
|
2020-04-14 07:16:00 +02:00
|
|
|
hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL);
|
2018-03-31 23:25:14 +02:00
|
|
|
if (hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND))
|
|
|
|
{
|
|
|
|
IPropertyBag_Release(prop_bag);
|
|
|
|
IMoniker_Release(mon);
|
|
|
|
|
|
|
|
/* Win8+ uses the endpoint GUID instead of the device name */
|
|
|
|
mmr = waveOutMessage((HWAVEOUT)(DWORD_PTR) i, DRV_QUERYFUNCTIONINSTANCEID,
|
|
|
|
(DWORD_PTR) endpoint, sizeof(endpoint));
|
|
|
|
ok(!mmr, "waveOutMessage failed: %u\n", mmr);
|
|
|
|
|
2020-04-14 07:16:00 +02:00
|
|
|
wcscpy(buffer, L"@device:cm:");
|
|
|
|
StringFromGUID2(&CLSID_AudioRendererCategory, buffer + wcslen(buffer), CHARS_IN_GUID);
|
|
|
|
wcscat(buffer, L"\\wave:");
|
|
|
|
wcscat(buffer, wcschr(endpoint, '}') + 2);
|
2018-03-31 23:25:14 +02:00
|
|
|
|
|
|
|
mon = check_display_name(parser, buffer);
|
|
|
|
|
|
|
|
hr = IMoniker_BindToStorage(mon, NULL, NULL, &IID_IPropertyBag, (void **)&prop_bag);
|
|
|
|
ok(hr == S_OK, "BindToStorage failed: %#x\n", hr);
|
|
|
|
|
2020-04-14 07:16:00 +02:00
|
|
|
hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL);
|
2018-03-31 23:25:14 +02:00
|
|
|
}
|
|
|
|
ok(hr == S_OK, "Read failed: %#x\n", hr);
|
|
|
|
|
2020-04-14 07:16:00 +02:00
|
|
|
ok(!wcsncmp(name, V_BSTR(&var), wcslen(name)), "expected %s, got %s\n",
|
2018-03-31 23:25:14 +02:00
|
|
|
wine_dbgstr_w(name), wine_dbgstr_w(V_BSTR(&var)));
|
|
|
|
|
|
|
|
VariantClear(&var);
|
2020-04-14 07:16:00 +02:00
|
|
|
hr = IPropertyBag_Read(prop_bag, L"CLSID", &var, NULL);
|
2018-03-31 23:25:14 +02:00
|
|
|
ok(hr == S_OK, "Read failed: %#x\n", hr);
|
|
|
|
|
|
|
|
StringFromGUID2(&CLSID_AudioRender, buffer, CHARS_IN_GUID);
|
2020-04-14 07:16:00 +02:00
|
|
|
ok(!wcscmp(buffer, V_BSTR(&var)), "expected %s, got %s\n",
|
2018-03-31 23:25:14 +02:00
|
|
|
wine_dbgstr_w(buffer), wine_dbgstr_w(V_BSTR(&var)));
|
|
|
|
|
|
|
|
VariantClear(&var);
|
2020-04-14 07:16:00 +02:00
|
|
|
hr = IPropertyBag_Read(prop_bag, L"WaveOutId", &var, NULL);
|
2018-03-31 23:25:14 +02:00
|
|
|
ok(hr == S_OK, "Read failed: %#x\n", hr);
|
|
|
|
|
|
|
|
ok(V_I4(&var) == i, "expected %d, got %d\n", i, V_I4(&var));
|
|
|
|
|
|
|
|
IPropertyBag_Release(prop_bag);
|
|
|
|
IMoniker_Release(mon);
|
|
|
|
}
|
|
|
|
|
|
|
|
IParseDisplayName_Release(parser);
|
|
|
|
}
|
|
|
|
|
2018-03-31 23:25:16 +02:00
|
|
|
static void test_wavein(void)
|
|
|
|
{
|
|
|
|
IParseDisplayName *parser;
|
|
|
|
IPropertyBag *prop_bag;
|
|
|
|
IMoniker *mon;
|
|
|
|
WCHAR endpoint[200];
|
|
|
|
WCHAR buffer[200];
|
|
|
|
WAVEINCAPSW caps;
|
|
|
|
MMRESULT mmr;
|
|
|
|
int count, i;
|
|
|
|
VARIANT var;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_CDeviceMoniker, NULL, CLSCTX_INPROC, &IID_IParseDisplayName, (void **)&parser);
|
|
|
|
ok(hr == S_OK, "Failed to create ParseDisplayName: %#x\n", hr);
|
|
|
|
|
|
|
|
count = waveInGetNumDevs();
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
waveInGetDevCapsW(i, &caps, sizeof(caps));
|
|
|
|
|
2020-04-14 07:16:00 +02:00
|
|
|
wcscpy(buffer, L"@device:cm:");
|
|
|
|
StringFromGUID2(&CLSID_AudioInputDeviceCategory, buffer + wcslen(buffer), CHARS_IN_GUID);
|
|
|
|
wcscat(buffer, L"\\");
|
|
|
|
wcscat(buffer, caps.szPname);
|
2018-03-31 23:25:16 +02:00
|
|
|
|
|
|
|
mon = check_display_name(parser, buffer);
|
|
|
|
|
|
|
|
hr = IMoniker_BindToStorage(mon, NULL, NULL, &IID_IPropertyBag, (void **)&prop_bag);
|
|
|
|
ok(hr == S_OK, "BindToStorage failed: %#x\n", hr);
|
|
|
|
|
|
|
|
VariantInit(&var);
|
2020-04-14 07:16:00 +02:00
|
|
|
hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL);
|
2018-03-31 23:25:16 +02:00
|
|
|
if (hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND))
|
|
|
|
{
|
|
|
|
IPropertyBag_Release(prop_bag);
|
|
|
|
IMoniker_Release(mon);
|
|
|
|
|
|
|
|
/* Win8+ uses the endpoint GUID instead of the device name */
|
|
|
|
mmr = waveInMessage((HWAVEIN)(DWORD_PTR) i, DRV_QUERYFUNCTIONINSTANCEID,
|
|
|
|
(DWORD_PTR) endpoint, sizeof(endpoint));
|
|
|
|
ok(!mmr, "waveInMessage failed: %u\n", mmr);
|
|
|
|
|
2020-04-14 07:16:00 +02:00
|
|
|
wcscpy(buffer, L"@device:cm:");
|
|
|
|
StringFromGUID2(&CLSID_AudioInputDeviceCategory, buffer + wcslen(buffer), CHARS_IN_GUID);
|
|
|
|
wcscat(buffer, L"\\wave:");
|
|
|
|
wcscat(buffer, wcschr(endpoint, '}') + 2);
|
2018-03-31 23:25:16 +02:00
|
|
|
|
|
|
|
mon = check_display_name(parser, buffer);
|
|
|
|
|
|
|
|
hr = IMoniker_BindToStorage(mon, NULL, NULL, &IID_IPropertyBag, (void **)&prop_bag);
|
|
|
|
ok(hr == S_OK, "BindToStorage failed: %#x\n", hr);
|
|
|
|
|
2020-04-14 07:16:00 +02:00
|
|
|
hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL);
|
2018-03-31 23:25:16 +02:00
|
|
|
}
|
|
|
|
ok(hr == S_OK, "Read failed: %#x\n", hr);
|
|
|
|
|
2020-04-14 07:16:00 +02:00
|
|
|
ok(!wcsncmp(caps.szPname, V_BSTR(&var), wcslen(caps.szPname)), "expected %s, got %s\n",
|
2018-03-31 23:25:16 +02:00
|
|
|
wine_dbgstr_w(caps.szPname), wine_dbgstr_w(V_BSTR(&var)));
|
|
|
|
|
|
|
|
VariantClear(&var);
|
2020-04-14 07:16:00 +02:00
|
|
|
hr = IPropertyBag_Read(prop_bag, L"CLSID", &var, NULL);
|
2018-03-31 23:25:16 +02:00
|
|
|
ok(hr == S_OK, "Read failed: %#x\n", hr);
|
|
|
|
|
|
|
|
StringFromGUID2(&CLSID_AudioRecord, buffer, CHARS_IN_GUID);
|
2020-04-14 07:16:00 +02:00
|
|
|
ok(!wcscmp(buffer, V_BSTR(&var)), "expected %s, got %s\n",
|
2018-03-31 23:25:16 +02:00
|
|
|
wine_dbgstr_w(buffer), wine_dbgstr_w(V_BSTR(&var)));
|
|
|
|
|
|
|
|
VariantClear(&var);
|
2020-04-14 07:16:00 +02:00
|
|
|
hr = IPropertyBag_Read(prop_bag, L"WaveInId", &var, NULL);
|
2018-03-31 23:25:16 +02:00
|
|
|
ok(hr == S_OK, "Read failed: %#x\n", hr);
|
|
|
|
|
|
|
|
ok(V_I4(&var) == i, "expected %d, got %d\n", i, V_I4(&var));
|
|
|
|
|
|
|
|
IPropertyBag_Release(prop_bag);
|
|
|
|
IMoniker_Release(mon);
|
|
|
|
}
|
|
|
|
|
|
|
|
IParseDisplayName_Release(parser);
|
|
|
|
}
|
|
|
|
|
2018-03-31 23:25:17 +02:00
|
|
|
static void test_midiout(void)
|
|
|
|
{
|
|
|
|
IParseDisplayName *parser;
|
|
|
|
IPropertyBag *prop_bag;
|
|
|
|
IMoniker *mon;
|
|
|
|
MIDIOUTCAPSW caps;
|
|
|
|
WCHAR buffer[200];
|
|
|
|
const WCHAR *name;
|
|
|
|
int count, i;
|
|
|
|
VARIANT var;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_CDeviceMoniker, NULL, CLSCTX_INPROC, &IID_IParseDisplayName, (void **)&parser);
|
|
|
|
ok(hr == S_OK, "Failed to create ParseDisplayName: %#x\n", hr);
|
|
|
|
|
|
|
|
count = midiOutGetNumDevs();
|
|
|
|
|
|
|
|
for (i = -1; i < count; i++)
|
|
|
|
{
|
|
|
|
midiOutGetDevCapsW(i, &caps, sizeof(caps));
|
|
|
|
|
|
|
|
if (i == -1) /* MIDI_MAPPER */
|
2020-04-14 07:16:00 +02:00
|
|
|
name = L"Default MidiOut Device";
|
2018-03-31 23:25:17 +02:00
|
|
|
else
|
|
|
|
name = caps.szPname;
|
|
|
|
|
2020-04-14 07:16:00 +02:00
|
|
|
wcscpy(buffer, L"@device:cm:");
|
|
|
|
StringFromGUID2(&CLSID_MidiRendererCategory, buffer + wcslen(buffer), CHARS_IN_GUID);
|
|
|
|
wcscat(buffer, L"\\");
|
|
|
|
wcscat(buffer, name);
|
2018-03-31 23:25:17 +02:00
|
|
|
|
|
|
|
mon = check_display_name(parser, buffer);
|
|
|
|
|
|
|
|
hr = IMoniker_BindToStorage(mon, NULL, NULL, &IID_IPropertyBag, (void **)&prop_bag);
|
|
|
|
ok(hr == S_OK, "BindToStorage failed: %#x\n", hr);
|
|
|
|
|
|
|
|
VariantInit(&var);
|
2020-04-14 07:16:00 +02:00
|
|
|
hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL);
|
2018-03-31 23:25:17 +02:00
|
|
|
ok(hr == S_OK, "Read failed: %#x\n", hr);
|
|
|
|
|
2020-04-14 07:16:00 +02:00
|
|
|
ok(!wcscmp(name, V_BSTR(&var)), "expected %s, got %s\n",
|
2018-03-31 23:25:17 +02:00
|
|
|
wine_dbgstr_w(name), wine_dbgstr_w(V_BSTR(&var)));
|
|
|
|
|
|
|
|
VariantClear(&var);
|
2020-04-14 07:16:00 +02:00
|
|
|
hr = IPropertyBag_Read(prop_bag, L"CLSID", &var, NULL);
|
2018-03-31 23:25:17 +02:00
|
|
|
ok(hr == S_OK, "Read failed: %#x\n", hr);
|
|
|
|
|
|
|
|
StringFromGUID2(&CLSID_AVIMIDIRender, buffer, CHARS_IN_GUID);
|
2020-04-14 07:16:00 +02:00
|
|
|
ok(!wcscmp(buffer, V_BSTR(&var)), "expected %s, got %s\n",
|
2018-03-31 23:25:17 +02:00
|
|
|
wine_dbgstr_w(buffer), wine_dbgstr_w(V_BSTR(&var)));
|
|
|
|
|
|
|
|
VariantClear(&var);
|
2020-04-14 07:16:00 +02:00
|
|
|
hr = IPropertyBag_Read(prop_bag, L"MidiOutId", &var, NULL);
|
2018-03-31 23:25:17 +02:00
|
|
|
ok(hr == S_OK, "Read failed: %#x\n", hr);
|
|
|
|
|
|
|
|
ok(V_I4(&var) == i, "expected %d, got %d\n", i, V_I4(&var));
|
|
|
|
|
|
|
|
IPropertyBag_Release(prop_bag);
|
|
|
|
IMoniker_Release(mon);
|
|
|
|
}
|
|
|
|
|
|
|
|
IParseDisplayName_Release(parser);
|
|
|
|
}
|
|
|
|
|
2018-03-31 23:25:18 +02:00
|
|
|
static void test_vfw(void)
|
|
|
|
{
|
|
|
|
IParseDisplayName *parser;
|
|
|
|
IPropertyBag *prop_bag;
|
|
|
|
IMoniker *mon;
|
|
|
|
WCHAR buffer[200];
|
|
|
|
ICINFO info;
|
|
|
|
VARIANT var;
|
|
|
|
HRESULT hr;
|
|
|
|
int i = 0;
|
|
|
|
HIC hic;
|
|
|
|
|
|
|
|
if (broken(sizeof(void *) == 8))
|
|
|
|
{
|
|
|
|
win_skip("VFW codecs are not enumerated on 64-bit Windows\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_CDeviceMoniker, NULL, CLSCTX_INPROC, &IID_IParseDisplayName, (void **)&parser);
|
|
|
|
ok(hr == S_OK, "Failed to create ParseDisplayName: %#x\n", hr);
|
|
|
|
|
|
|
|
while (ICInfo(ICTYPE_VIDEO, i++, &info))
|
|
|
|
{
|
|
|
|
WCHAR name[5] = {LOBYTE(LOWORD(info.fccHandler)), HIBYTE(LOWORD(info.fccHandler)),
|
|
|
|
LOBYTE(HIWORD(info.fccHandler)), HIBYTE(HIWORD(info.fccHandler))};
|
|
|
|
|
|
|
|
hic = ICOpen(ICTYPE_VIDEO, info.fccHandler, ICMODE_QUERY);
|
|
|
|
ICGetInfo(hic, &info, sizeof(info));
|
|
|
|
ICClose(hic);
|
|
|
|
|
2020-04-14 07:16:00 +02:00
|
|
|
wcscpy(buffer, L"@device:cm:");
|
|
|
|
StringFromGUID2(&CLSID_VideoCompressorCategory, buffer + wcslen(buffer), CHARS_IN_GUID);
|
|
|
|
wcscat(buffer, L"\\");
|
|
|
|
wcscat(buffer, name);
|
2018-03-31 23:25:18 +02:00
|
|
|
|
|
|
|
mon = check_display_name(parser, buffer);
|
|
|
|
|
|
|
|
hr = IMoniker_BindToStorage(mon, NULL, NULL, &IID_IPropertyBag, (void **)&prop_bag);
|
|
|
|
ok(hr == S_OK, "BindToStorage failed: %#x\n", hr);
|
|
|
|
|
|
|
|
VariantInit(&var);
|
2020-04-14 07:16:00 +02:00
|
|
|
hr = IPropertyBag_Read(prop_bag, L"FriendlyName", &var, NULL);
|
2018-03-31 23:25:18 +02:00
|
|
|
ok(hr == S_OK, "Read failed: %#x\n", hr);
|
|
|
|
|
2020-04-14 07:16:00 +02:00
|
|
|
ok(!wcscmp(info.szDescription, V_BSTR(&var)), "expected %s, got %s\n",
|
2018-03-31 23:25:18 +02:00
|
|
|
wine_dbgstr_w(info.szDescription), wine_dbgstr_w(V_BSTR(&var)));
|
|
|
|
|
|
|
|
VariantClear(&var);
|
2020-04-14 07:16:00 +02:00
|
|
|
hr = IPropertyBag_Read(prop_bag, L"CLSID", &var, NULL);
|
2018-03-31 23:25:18 +02:00
|
|
|
ok(hr == S_OK, "Read failed: %#x\n", hr);
|
|
|
|
|
|
|
|
StringFromGUID2(&CLSID_AVICo, buffer, CHARS_IN_GUID);
|
2020-04-14 07:16:00 +02:00
|
|
|
ok(!wcscmp(buffer, V_BSTR(&var)), "expected %s, got %s\n",
|
2018-03-31 23:25:18 +02:00
|
|
|
wine_dbgstr_w(buffer), wine_dbgstr_w(V_BSTR(&var)));
|
|
|
|
|
|
|
|
VariantClear(&var);
|
2020-04-14 07:16:00 +02:00
|
|
|
hr = IPropertyBag_Read(prop_bag, L"FccHandler", &var, NULL);
|
2018-03-31 23:25:18 +02:00
|
|
|
ok(hr == S_OK, "Read failed: %#x\n", hr);
|
2020-04-14 07:16:00 +02:00
|
|
|
ok(!wcscmp(name, V_BSTR(&var)), "expected %s, got %s\n",
|
2018-03-31 23:25:18 +02:00
|
|
|
wine_dbgstr_w(name), wine_dbgstr_w(V_BSTR(&var)));
|
|
|
|
|
2018-12-13 04:21:13 +01:00
|
|
|
VariantClear(&var);
|
2018-03-31 23:25:18 +02:00
|
|
|
IPropertyBag_Release(prop_bag);
|
|
|
|
IMoniker_Release(mon);
|
|
|
|
}
|
|
|
|
|
|
|
|
IParseDisplayName_Release(parser);
|
|
|
|
}
|
|
|
|
|
2012-03-28 00:38:39 +02:00
|
|
|
START_TEST(devenum)
|
|
|
|
{
|
2012-06-16 19:36:24 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
CoInitialize(NULL);
|
|
|
|
|
2020-04-15 05:22:47 +02:00
|
|
|
test_devenum();
|
2017-03-27 17:41:23 +02:00
|
|
|
test_moniker_isequal();
|
2018-03-07 03:57:07 +01:00
|
|
|
test_register_filter();
|
2018-03-07 03:57:08 +01:00
|
|
|
test_directshow_filter();
|
|
|
|
test_codec();
|
2020-05-14 00:03:08 +02:00
|
|
|
test_dmo(&DMOCATEGORY_AUDIO_DECODER, &CLSID_LegacyAmFilterCategory);
|
|
|
|
test_dmo(&DMOCATEGORY_VIDEO_DECODER, &CLSID_LegacyAmFilterCategory);
|
|
|
|
test_dmo(&DMOCATEGORY_VIDEO_DECODER, &DMOCATEGORY_VIDEO_DECODER);
|
2017-03-27 17:41:23 +02:00
|
|
|
|
2018-03-11 05:11:51 +01:00
|
|
|
test_legacy_filter();
|
2018-03-11 05:11:52 +01:00
|
|
|
hr = DirectSoundEnumerateW(test_dsound, NULL);
|
|
|
|
ok(hr == S_OK, "got %#x\n", hr);
|
2018-03-31 23:25:14 +02:00
|
|
|
test_waveout();
|
2018-03-31 23:25:16 +02:00
|
|
|
test_wavein();
|
2018-03-31 23:25:17 +02:00
|
|
|
test_midiout();
|
2018-03-31 23:25:18 +02:00
|
|
|
test_vfw();
|
2018-03-11 05:11:51 +01:00
|
|
|
|
2012-06-16 19:36:24 +02:00
|
|
|
CoUninitialize();
|
2012-03-28 00:38:39 +02:00
|
|
|
}
|