include: Implement C_ASSERT() using the C11 _Static_assert() if available.
[wine.git] / dlls / qdvd / graph.c
blobab9ea856feeaa46723307479f4211554ea1a55e0
1 /*
2 * Graph builder
4 * Copyright 2020 Gijs Vermeulen
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "qdvd_private.h"
23 WINE_DEFAULT_DEBUG_CHANNEL(quartz);
25 struct graph_builder
27 IUnknown IUnknown_inner;
28 IDvdGraphBuilder IDvdGraphBuilder_iface;
30 IUnknown *outer_unk;
31 LONG refcount;
34 static struct graph_builder *impl_from_IUnknown(IUnknown *iface)
36 return CONTAINING_RECORD(iface, struct graph_builder, IUnknown_inner);
39 static ULONG WINAPI inner_AddRef(IUnknown *iface)
41 struct graph_builder *builder = impl_from_IUnknown(iface);
42 ULONG refcount = InterlockedIncrement(&builder->refcount);
43 TRACE("%p increasing refcount to %lu.\n", builder, refcount);
44 return refcount;
47 static ULONG WINAPI inner_Release(IUnknown *iface)
49 struct graph_builder *builder = impl_from_IUnknown(iface);
50 ULONG refcount = InterlockedDecrement(&builder->refcount);
51 TRACE("%p decreasing refcount to %lu.\n", builder, refcount);
52 if (!refcount)
53 free(builder);
54 return refcount;
57 static HRESULT WINAPI inner_QueryInterface(IUnknown *iface, REFIID iid, void **out)
59 struct graph_builder *builder = impl_from_IUnknown(iface);
61 TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
63 if (IsEqualGUID(iid, &IID_IUnknown))
64 *out = &builder->IUnknown_inner;
65 else if (IsEqualGUID(iid, &IID_IDvdGraphBuilder))
66 *out = &builder->IDvdGraphBuilder_iface;
67 else
69 *out = NULL;
70 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
71 return E_NOINTERFACE;
74 IUnknown_AddRef((IUnknown *)*out);
75 return S_OK;
78 static const IUnknownVtbl inner_vtbl =
80 inner_QueryInterface,
81 inner_AddRef,
82 inner_Release,
85 static struct graph_builder *impl_from_IDvdGraphBuilder(IDvdGraphBuilder *iface)
87 return CONTAINING_RECORD(iface, struct graph_builder, IDvdGraphBuilder_iface);
90 static ULONG WINAPI graph_builder_AddRef(IDvdGraphBuilder *iface)
92 struct graph_builder *builder = impl_from_IDvdGraphBuilder(iface);
93 return IUnknown_AddRef(builder->outer_unk);
96 static ULONG WINAPI graph_builder_Release(IDvdGraphBuilder *iface)
98 struct graph_builder *builder = impl_from_IDvdGraphBuilder(iface);
99 return IUnknown_Release(builder->outer_unk);
102 static HRESULT WINAPI graph_builder_QueryInterface(IDvdGraphBuilder *iface, REFIID iid, void **out)
104 struct graph_builder *builder = impl_from_IDvdGraphBuilder(iface);
105 return IUnknown_QueryInterface(builder->outer_unk, iid, out);
108 static HRESULT WINAPI graph_builder_GetFiltergraph(IDvdGraphBuilder *iface, IGraphBuilder **graph)
110 FIXME("iface %p, graph %p, stub!\n", iface, graph);
111 return E_NOTIMPL;
114 static HRESULT WINAPI graph_builder_GetDvdInterface(IDvdGraphBuilder *iface, REFIID iid, void **out)
116 FIXME("iface %p, iid %s, out %p, stub!\n", iface, debugstr_guid(iid), out);
117 return E_NOTIMPL;
120 static HRESULT WINAPI graph_builder_RenderDvdVideoVolume(IDvdGraphBuilder *iface, const WCHAR *path, DWORD flags, AM_DVD_RENDERSTATUS *status)
122 FIXME("iface %p, path %s, flags %#lx, status %p, stub!\n", iface, debugstr_w(path), flags, status);
123 return E_NOTIMPL;
126 static const struct IDvdGraphBuilderVtbl graph_builder_vtbl =
128 graph_builder_QueryInterface,
129 graph_builder_AddRef,
130 graph_builder_Release,
131 graph_builder_GetFiltergraph,
132 graph_builder_GetDvdInterface,
133 graph_builder_RenderDvdVideoVolume,
136 HRESULT graph_builder_create(IUnknown *outer, IUnknown **out)
138 struct graph_builder *builder;
140 if (!(builder = calloc(1, sizeof(*builder))))
141 return E_OUTOFMEMORY;
143 builder->IDvdGraphBuilder_iface.lpVtbl = &graph_builder_vtbl;
144 builder->IUnknown_inner.lpVtbl = &inner_vtbl;
145 builder->refcount = 1;
146 builder->outer_unk = outer ? outer : &builder->IUnknown_inner;
148 TRACE("Created DVD graph builder %p.\n", builder);
149 *out = &builder->IUnknown_inner;
150 return S_OK;