Commit c37e2ccc authored by Gijs Vermeulen's avatar Gijs Vermeulen Committed by Alexandre Julliard

qdvd: Support aggregation.

parent 986aa52f
......@@ -21051,6 +21051,7 @@ wine_fn_config_makefile dlls/qasf/tests enable_tests
wine_fn_config_makefile dlls/qcap enable_qcap
wine_fn_config_makefile dlls/qcap/tests enable_tests
wine_fn_config_makefile dlls/qdvd enable_qdvd
wine_fn_config_makefile dlls/qdvd/tests enable_tests
wine_fn_config_makefile dlls/qedit enable_qedit
wine_fn_config_makefile dlls/qedit/tests enable_tests
wine_fn_config_makefile dlls/qmgr enable_qmgr
......
......@@ -3634,6 +3634,7 @@ WINE_CONFIG_MAKEFILE(dlls/qasf/tests)
WINE_CONFIG_MAKEFILE(dlls/qcap)
WINE_CONFIG_MAKEFILE(dlls/qcap/tests)
WINE_CONFIG_MAKEFILE(dlls/qdvd)
WINE_CONFIG_MAKEFILE(dlls/qdvd/tests)
WINE_CONFIG_MAKEFILE(dlls/qedit)
WINE_CONFIG_MAKEFILE(dlls/qedit/tests)
WINE_CONFIG_MAKEFILE(dlls/qmgr)
......
......@@ -24,26 +24,29 @@ WINE_DEFAULT_DEBUG_CHANNEL(qdvd);
struct graph_builder
{
IUnknown IUnknown_inner;
IDvdGraphBuilder IDvdGraphBuilder_iface;
IUnknown *outer_unk;
LONG refcount;
};
static struct graph_builder *impl_from_IDvdGraphBuilder(IDvdGraphBuilder *iface)
static struct graph_builder *impl_from_IUnknown(IUnknown *iface)
{
return CONTAINING_RECORD(iface, struct graph_builder, IDvdGraphBuilder_iface);
return CONTAINING_RECORD(iface, struct graph_builder, IUnknown_inner);
}
static ULONG WINAPI graph_builder_AddRef(IDvdGraphBuilder *iface)
static ULONG WINAPI inner_AddRef(IUnknown *iface)
{
struct graph_builder *builder = impl_from_IDvdGraphBuilder(iface);
struct graph_builder *builder = impl_from_IUnknown(iface);
ULONG refcount = InterlockedIncrement(&builder->refcount);
TRACE("%p increasing refcount to %u.\n", builder, refcount);
return refcount;
}
static ULONG WINAPI graph_builder_Release(IDvdGraphBuilder *iface)
static ULONG WINAPI inner_Release(IUnknown *iface)
{
struct graph_builder *builder = impl_from_IDvdGraphBuilder(iface);
struct graph_builder *builder = impl_from_IUnknown(iface);
ULONG refcount = InterlockedDecrement(&builder->refcount);
TRACE("%p decreasing refcount to %u.\n", builder, refcount);
if (!refcount)
......@@ -51,12 +54,16 @@ static ULONG WINAPI graph_builder_Release(IDvdGraphBuilder *iface)
return refcount;
}
static HRESULT WINAPI graph_builder_QueryInterface(IDvdGraphBuilder *iface, REFIID iid, void **out)
static HRESULT WINAPI inner_QueryInterface(IUnknown *iface, REFIID iid, void **out)
{
struct graph_builder *builder = impl_from_IUnknown(iface);
TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
if (IsEqualGUID(iid, &IID_IDvdGraphBuilder) || IsEqualGUID(iid, &IID_IUnknown))
*out = iface;
if (IsEqualGUID(iid, &IID_IUnknown))
*out = &builder->IUnknown_inner;
else if (IsEqualGUID(iid, &IID_IDvdGraphBuilder))
*out = &builder->IDvdGraphBuilder_iface;
else
{
*out = NULL;
......@@ -68,6 +75,36 @@ static HRESULT WINAPI graph_builder_QueryInterface(IDvdGraphBuilder *iface, REFI
return S_OK;
}
static const IUnknownVtbl inner_vtbl =
{
inner_QueryInterface,
inner_AddRef,
inner_Release,
};
static struct graph_builder *impl_from_IDvdGraphBuilder(IDvdGraphBuilder *iface)
{
return CONTAINING_RECORD(iface, struct graph_builder, IDvdGraphBuilder_iface);
}
static ULONG WINAPI graph_builder_AddRef(IDvdGraphBuilder *iface)
{
struct graph_builder *builder = impl_from_IDvdGraphBuilder(iface);
return IUnknown_AddRef(builder->outer_unk);
}
static ULONG WINAPI graph_builder_Release(IDvdGraphBuilder *iface)
{
struct graph_builder *builder = impl_from_IDvdGraphBuilder(iface);
return IUnknown_Release(builder->outer_unk);
}
static HRESULT WINAPI graph_builder_QueryInterface(IDvdGraphBuilder *iface, REFIID iid, void **out)
{
struct graph_builder *builder = impl_from_IDvdGraphBuilder(iface);
return IUnknown_QueryInterface(builder->outer_unk, iid, out);
}
static HRESULT WINAPI graph_builder_GetFiltergraph(IDvdGraphBuilder *iface, IGraphBuilder **graph)
{
FIXME("iface %p, graph %p, stub!\n", iface, graph);
......@@ -96,7 +133,7 @@ static const struct IDvdGraphBuilderVtbl graph_builder_vtbl =
graph_builder_RenderDvdVideoVolume,
};
HRESULT graph_builder_create(IUnknown **out)
HRESULT graph_builder_create(IUnknown *outer, IUnknown **out)
{
struct graph_builder *builder;
......@@ -104,9 +141,11 @@ HRESULT graph_builder_create(IUnknown **out)
return E_OUTOFMEMORY;
builder->IDvdGraphBuilder_iface.lpVtbl = &graph_builder_vtbl;
builder->IUnknown_inner.lpVtbl = &inner_vtbl;
builder->refcount = 1;
builder->outer_unk = outer ? outer : &builder->IUnknown_inner;
TRACE("Created DVD graph builder %p.\n", builder);
*out = (IUnknown *)&builder->IDvdGraphBuilder_iface;
*out = &builder->IUnknown_inner;
return S_OK;
}
......@@ -28,7 +28,7 @@ static HINSTANCE qdvd_instance;
struct class_factory
{
IClassFactory IClassFactory_iface;
HRESULT (*create_instance)(IUnknown **out);
HRESULT (*create_instance)(IUnknown *outer, IUnknown **out);
};
static struct class_factory *impl_from_IClassFactory(IClassFactory *iface)
......@@ -73,10 +73,10 @@ static HRESULT WINAPI class_factory_CreateInstance(IClassFactory *iface,
*out = NULL;
if (outer)
return CLASS_E_NOAGGREGATION;
if (outer && !IsEqualGUID(iid, &IID_IUnknown))
return E_NOINTERFACE;
if (SUCCEEDED(hr = factory->create_instance(&unk)))
if (SUCCEEDED(hr = factory->create_instance(outer, &unk)))
{
hr = IUnknown_QueryInterface(unk, iid, out);
IUnknown_Release(unk);
......
......@@ -25,6 +25,6 @@
#include "dshow.h"
#include "wine/debug.h"
HRESULT graph_builder_create(IUnknown **out) DECLSPEC_HIDDEN;
HRESULT graph_builder_create(IUnknown *outer, IUnknown **out) DECLSPEC_HIDDEN;
#endif /* QDVD_PRIVATE_H */
TESTDLL = qdvd.dll
IMPORTS = strmiids uuid ole32
C_SRCS = \
graph.c
/*
* Graph builder unit tests
*
* Copyright 2020 Gijs Vermeulen
*
* 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 "dshow.h"
#include "wine/strmbase.h"
#include "wine/test.h"
static IDvdGraphBuilder *create_graph_builder(void)
{
IDvdGraphBuilder *graph = NULL;
HRESULT hr = CoCreateInstance(&CLSID_DvdGraphBuilder, NULL,
CLSCTX_INPROC_SERVER, &IID_IDvdGraphBuilder, (void **)&graph);
ok(hr == S_OK, "Got hr %#x.\n", hr);
return graph;
}
static ULONG get_refcount(void *iface)
{
IUnknown *unknown = iface;
IUnknown_AddRef(unknown);
return IUnknown_Release(unknown);
}
#define check_interface(a, b, c) check_interface_(__LINE__, a, b, c)
static void check_interface_(unsigned int line, void *iface_ptr, REFIID iid, BOOL supported)
{
IUnknown *iface = iface_ptr;
HRESULT hr, expected_hr;
IUnknown *unk;
expected_hr = supported ? S_OK : E_NOINTERFACE;
hr = IUnknown_QueryInterface(iface, iid, (void **)&unk);
ok_(__FILE__, line)(hr == expected_hr, "Got hr %#x, expected %#x.\n", hr, expected_hr);
if (SUCCEEDED(hr))
IUnknown_Release(unk);
}
static void test_interfaces(void)
{
IDvdGraphBuilder *graph = create_graph_builder();
check_interface(graph, &IID_IDvdGraphBuilder, TRUE);
check_interface(graph, &IID_IUnknown, TRUE);
check_interface(graph, &IID_IBaseFilter, FALSE);
IDvdGraphBuilder_Release(graph);
}
static const GUID test_iid = {0x33333333};
static LONG outer_ref = 1;
static HRESULT WINAPI outer_QueryInterface(IUnknown *iface, REFIID iid, void **out)
{
if (IsEqualGUID(iid, &IID_IUnknown)
|| IsEqualGUID(iid, &IID_IDvdGraphBuilder)
|| IsEqualGUID(iid, &test_iid))
{
*out = (IUnknown *)0xdeadbeef;
return S_OK;
}
ok(0, "unexpected call %s\n", wine_dbgstr_guid(iid));
return E_NOINTERFACE;
}
static ULONG WINAPI outer_AddRef(IUnknown *iface)
{
return InterlockedIncrement(&outer_ref);
}
static ULONG WINAPI outer_Release(IUnknown *iface)
{
return InterlockedDecrement(&outer_ref);
}
static const IUnknownVtbl outer_vtbl =
{
outer_QueryInterface,
outer_AddRef,
outer_Release,
};
static IUnknown test_outer = {&outer_vtbl};
static void test_aggregation(void)
{
IDvdGraphBuilder *graph, *graph2;
IUnknown *unk, *unk2;
HRESULT hr;
ULONG ref;
graph = (IDvdGraphBuilder *)0xdeadbeef;
hr = CoCreateInstance(&CLSID_DvdGraphBuilder, &test_outer, CLSCTX_INPROC_SERVER,
&IID_IDvdGraphBuilder, (void **)&graph);
ok(hr == E_NOINTERFACE, "Got hr %#x.\n", hr);
ok(!graph, "Got interface %p.\n", graph);
hr = CoCreateInstance(&CLSID_DvdGraphBuilder, &test_outer, CLSCTX_INPROC_SERVER,
&IID_IUnknown, (void **)&unk);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(outer_ref == 1, "Got unexpected refcount %d.\n", outer_ref);
ok(unk != &test_outer, "Returned IUnknown should not be outer IUnknown.\n");
ref = get_refcount(unk);
ok(ref == 1, "Got unexpected refcount %d.\n", ref);
ref = IUnknown_AddRef(unk);
ok(ref == 2, "Got unexpected refcount %d.\n", ref);
ok(outer_ref == 1, "Got unexpected refcount %d.\n", outer_ref);
ref = IUnknown_Release(unk);
ok(ref == 1, "Got unexpected refcount %d.\n", ref);
ok(outer_ref == 1, "Got unexpected refcount %d.\n", outer_ref);
hr = IUnknown_QueryInterface(unk, &IID_IUnknown, (void **)&unk2);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(unk2 == unk, "Got unexpected IUnknown %p.\n", unk2);
IUnknown_Release(unk2);
hr = IUnknown_QueryInterface(unk, &IID_IDvdGraphBuilder, (void **)&graph);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IDvdGraphBuilder_QueryInterface(graph, &IID_IUnknown, (void **)&unk2);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(unk2 == (IUnknown *)0xdeadbeef, "Got unexpected IUnknown %p.\n", unk2);
hr = IDvdGraphBuilder_QueryInterface(graph, &IID_IDvdGraphBuilder, (void **)&graph2);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(graph2 == (IDvdGraphBuilder *)0xdeadbeef, "Got unexpected IDvdGraphBuilder %p.\n", graph2);
hr = IUnknown_QueryInterface(unk, &test_iid, (void **)&unk2);
ok(hr == E_NOINTERFACE, "Got hr %#x.\n", hr);
ok(!unk2, "Got unexpected IUnknown %p.\n", unk2);
hr = IDvdGraphBuilder_QueryInterface(graph, &test_iid, (void **)&unk2);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(unk2 == (IUnknown *)0xdeadbeef, "Got unexpected IUnknown %p.\n", unk2);
IDvdGraphBuilder_Release(graph);
ref = IUnknown_Release(unk);
ok(!ref, "Got unexpected refcount %d.\n", ref);
ok(outer_ref == 1, "Got unexpected refcount %d.\n", outer_ref);
}
START_TEST(graph)
{
CoInitializeEx(NULL, COINIT_MULTITHREADED);
test_interfaces();
test_aggregation();
CoUninitialize();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment