gdi32: Use NtGdiExcludeClipRect for ExcludeClipRect implementation.
[wine.git] / dlls / quartz / passthrough.c
blob7f81ae8a1be0433db4b72d604753bcfb422bac5e
1 /*
2 * Seeking passthrough object
4 * Copyright 2020 Zebediah Figura for CodeWeavers
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 "quartz_private.h"
23 WINE_DEFAULT_DEBUG_CHANNEL(quartz);
25 struct seeking_passthrough
27 struct strmbase_passthrough passthrough;
29 IUnknown IUnknown_inner;
30 IUnknown *outer_unk;
31 LONG refcount;
34 static struct seeking_passthrough *impl_from_IUnknown(IUnknown *iface)
36 return CONTAINING_RECORD(iface, struct seeking_passthrough, IUnknown_inner);
39 static HRESULT WINAPI seeking_passthrough_QueryInterface(IUnknown *iface, REFIID iid, void **out)
41 struct seeking_passthrough *passthrough = impl_from_IUnknown(iface);
43 TRACE("passthrough %p, iid %s, out %p.\n", passthrough, debugstr_guid(iid), out);
45 if (IsEqualGUID(iid, &IID_IUnknown))
46 *out = iface;
47 else if (IsEqualGUID(iid, &IID_IMediaPosition))
48 *out = &passthrough->passthrough.IMediaPosition_iface;
49 else if (IsEqualGUID(iid, &IID_IMediaSeeking))
50 *out = &passthrough->passthrough.IMediaSeeking_iface;
51 else if (IsEqualGUID(iid, &IID_ISeekingPassThru))
52 *out = &passthrough->passthrough.ISeekingPassThru_iface;
53 else
55 *out = NULL;
56 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
57 return E_NOINTERFACE;
60 IUnknown_AddRef((IUnknown *)*out);
61 return S_OK;
64 static ULONG WINAPI seeking_passthrough_AddRef(IUnknown *iface)
66 struct seeking_passthrough *passthrough = impl_from_IUnknown(iface);
67 ULONG refcount = InterlockedIncrement(&passthrough->refcount);
69 TRACE("%p increasing refcount to %u.\n", passthrough, refcount);
70 return refcount;
73 static ULONG WINAPI seeking_passthrough_Release(IUnknown *iface)
75 struct seeking_passthrough *passthrough = impl_from_IUnknown(iface);
76 ULONG refcount = InterlockedDecrement(&passthrough->refcount);
78 TRACE("%p decreasing refcount to %u.\n", passthrough, refcount);
79 if (!refcount)
81 strmbase_passthrough_cleanup(&passthrough->passthrough);
82 free(passthrough);
84 InterlockedDecrement(&object_locks);
86 return refcount;
89 static const IUnknownVtbl seeking_passthrough_vtbl =
91 seeking_passthrough_QueryInterface,
92 seeking_passthrough_AddRef,
93 seeking_passthrough_Release,
96 HRESULT seeking_passthrough_create(IUnknown *outer, IUnknown **out)
98 struct seeking_passthrough *object;
100 TRACE("outer %p, out %p.\n", outer, out);
102 if (!(object = calloc(1, sizeof(*object))))
103 return E_OUTOFMEMORY;
105 object->IUnknown_inner.lpVtbl = &seeking_passthrough_vtbl;
106 object->outer_unk = outer ? outer : &object->IUnknown_inner;
107 object->refcount = 1;
109 strmbase_passthrough_init(&object->passthrough, object->outer_unk);
111 TRACE("Created seeking passthrough %p.\n", object);
112 *out = &object->IUnknown_inner;
113 return S_OK;