gdiplus: Mark the Graphics object as busy before freeing it.
[wine/multimedia.git] / dlls / quartz / nullrenderer.c
blob16a24ac7a54f620c2264c662cae7f9c32a719dcf
1 /*
2 * Null Renderer (Promiscuous, not rendering anything at all!)
4 * Copyright 2004 Christian Costa
5 * Copyright 2008 Maarten Lankhorst
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "config.h"
24 #define NONAMELESSSTRUCT
25 #define NONAMELESSUNION
26 #include "quartz_private.h"
27 #include "pin.h"
29 #include "uuids.h"
30 #include "vfwmsgs.h"
31 #include "amvideo.h"
32 #include "windef.h"
33 #include "winbase.h"
34 #include "dshow.h"
35 #include "evcode.h"
36 #include "strmif.h"
37 #include "ddraw.h"
39 #include "wine/unicode.h"
40 #include "wine/debug.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(quartz);
44 typedef struct NullRendererImpl
46 BaseRenderer renderer;
47 IUnknown IUnknown_inner;
48 IAMFilterMiscFlags IAMFilterMiscFlags_iface;
49 IUnknown *outer_unk;
50 } NullRendererImpl;
52 static HRESULT WINAPI NullRenderer_DoRenderSample(BaseRenderer *iface, IMediaSample *pMediaSample)
54 return S_OK;
57 static HRESULT WINAPI NullRenderer_CheckMediaType(BaseRenderer *iface, const AM_MEDIA_TYPE * pmt)
59 TRACE("Not a stub!\n");
60 return S_OK;
63 static const BaseRendererFuncTable RendererFuncTable = {
64 NullRenderer_CheckMediaType,
65 NullRenderer_DoRenderSample,
66 /**/
67 NULL,
68 NULL,
69 NULL,
70 NULL,
71 NULL,
72 NULL,
73 NULL,
74 NULL,
75 NULL,
76 NULL,
77 /**/
78 NULL,
79 NULL,
80 NULL,
81 NULL,
82 NULL,
85 static inline NullRendererImpl *impl_from_IUnknown(IUnknown *iface)
87 return CONTAINING_RECORD(iface, NullRendererImpl, IUnknown_inner);
90 static HRESULT WINAPI NullRendererInner_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)
92 NullRendererImpl *This = impl_from_IUnknown(iface);
94 TRACE("(%p/%p)->(%s, %p)\n", This, iface, qzdebugstr_guid(riid), ppv);
96 *ppv = NULL;
98 if (IsEqualIID(riid, &IID_IUnknown))
99 *ppv = &This->IUnknown_inner;
100 else if (IsEqualIID(riid, &IID_IAMFilterMiscFlags))
101 *ppv = &This->IAMFilterMiscFlags_iface;
102 else
104 HRESULT hr;
105 hr = BaseRendererImpl_QueryInterface(&This->renderer.filter.IBaseFilter_iface, riid, ppv);
106 if (SUCCEEDED(hr))
107 return hr;
110 if (*ppv)
112 IUnknown_AddRef((IUnknown *)*ppv);
113 return S_OK;
116 if (!IsEqualIID(riid, &IID_IPin) && !IsEqualIID(riid, &IID_IVideoWindow))
117 FIXME("No interface for %s!\n", qzdebugstr_guid(riid));
119 return E_NOINTERFACE;
122 static ULONG WINAPI NullRendererInner_AddRef(IUnknown *iface)
124 NullRendererImpl *This = impl_from_IUnknown(iface);
125 return BaseFilterImpl_AddRef(&This->renderer.filter.IBaseFilter_iface);
128 static ULONG WINAPI NullRendererInner_Release(IUnknown *iface)
130 NullRendererImpl *This = impl_from_IUnknown(iface);
131 ULONG refCount = BaseFilterImpl_Release(&This->renderer.filter.IBaseFilter_iface);
133 if (!refCount)
135 TRACE("Destroying Null Renderer\n");
136 CoTaskMemFree(This);
139 return refCount;
142 static const IUnknownVtbl IInner_VTable =
144 NullRendererInner_QueryInterface,
145 NullRendererInner_AddRef,
146 NullRendererInner_Release
149 static inline NullRendererImpl *impl_from_IBaseFilter(IBaseFilter *iface)
151 return CONTAINING_RECORD(iface, NullRendererImpl, renderer.filter.IBaseFilter_iface);
154 static HRESULT WINAPI NullRenderer_QueryInterface(IBaseFilter * iface, REFIID riid, LPVOID * ppv)
156 NullRendererImpl *This = impl_from_IBaseFilter(iface);
157 return IUnknown_QueryInterface(This->outer_unk, riid, ppv);
160 static ULONG WINAPI NullRenderer_AddRef(IBaseFilter * iface)
162 NullRendererImpl *This = impl_from_IBaseFilter(iface);
163 return IUnknown_AddRef(This->outer_unk);
166 static ULONG WINAPI NullRenderer_Release(IBaseFilter * iface)
168 NullRendererImpl *This = impl_from_IBaseFilter(iface);
169 return IUnknown_Release(This->outer_unk);
172 static const IBaseFilterVtbl NullRenderer_Vtbl =
174 NullRenderer_QueryInterface,
175 NullRenderer_AddRef,
176 NullRenderer_Release,
177 BaseFilterImpl_GetClassID,
178 BaseRendererImpl_Stop,
179 BaseRendererImpl_Pause,
180 BaseRendererImpl_Run,
181 BaseRendererImpl_GetState,
182 BaseRendererImpl_SetSyncSource,
183 BaseFilterImpl_GetSyncSource,
184 BaseFilterImpl_EnumPins,
185 BaseRendererImpl_FindPin,
186 BaseFilterImpl_QueryFilterInfo,
187 BaseFilterImpl_JoinFilterGraph,
188 BaseFilterImpl_QueryVendorInfo
191 static NullRendererImpl *impl_from_IAMFilterMiscFlags(IAMFilterMiscFlags *iface)
193 return CONTAINING_RECORD(iface, NullRendererImpl, IAMFilterMiscFlags_iface);
196 static HRESULT WINAPI AMFilterMiscFlags_QueryInterface(IAMFilterMiscFlags *iface, REFIID riid,
197 void **ppv)
199 NullRendererImpl *This = impl_from_IAMFilterMiscFlags(iface);
200 return IUnknown_QueryInterface(This->outer_unk, riid, ppv);
203 static ULONG WINAPI AMFilterMiscFlags_AddRef(IAMFilterMiscFlags *iface)
205 NullRendererImpl *This = impl_from_IAMFilterMiscFlags(iface);
206 return IUnknown_AddRef(This->outer_unk);
209 static ULONG WINAPI AMFilterMiscFlags_Release(IAMFilterMiscFlags *iface)
211 NullRendererImpl *This = impl_from_IAMFilterMiscFlags(iface);
212 return IUnknown_Release(This->outer_unk);
215 static ULONG WINAPI AMFilterMiscFlags_GetMiscFlags(IAMFilterMiscFlags *iface)
217 return AM_FILTER_MISC_FLAGS_IS_RENDERER;
220 static const IAMFilterMiscFlagsVtbl IAMFilterMiscFlags_Vtbl = {
221 AMFilterMiscFlags_QueryInterface,
222 AMFilterMiscFlags_AddRef,
223 AMFilterMiscFlags_Release,
224 AMFilterMiscFlags_GetMiscFlags
227 HRESULT NullRenderer_create(IUnknown *pUnkOuter, void **ppv)
229 HRESULT hr;
230 NullRendererImpl *pNullRenderer;
232 TRACE("(%p, %p)\n", pUnkOuter, ppv);
234 *ppv = NULL;
236 pNullRenderer = CoTaskMemAlloc(sizeof(NullRendererImpl));
237 pNullRenderer->IUnknown_inner.lpVtbl = &IInner_VTable;
238 pNullRenderer->IAMFilterMiscFlags_iface.lpVtbl = &IAMFilterMiscFlags_Vtbl;
240 if (pUnkOuter)
241 pNullRenderer->outer_unk = pUnkOuter;
242 else
243 pNullRenderer->outer_unk = &pNullRenderer->IUnknown_inner;
245 hr = BaseRenderer_Init(&pNullRenderer->renderer, &NullRenderer_Vtbl, pUnkOuter,
246 &CLSID_NullRenderer, (DWORD_PTR)(__FILE__ ": NullRendererImpl.csFilter"),
247 &RendererFuncTable);
249 if (FAILED(hr))
251 BaseRendererImpl_Release(&pNullRenderer->renderer.filter.IBaseFilter_iface);
252 CoTaskMemFree(pNullRenderer);
254 else
255 *ppv = &pNullRenderer->IUnknown_inner;
257 return S_OK;