From 29d3c754424ccda2f6f07be0d4e6c0596c6234d7 Mon Sep 17 00:00:00 2001 From: Aric Stewart Date: Sat, 24 Mar 2012 11:42:27 -0500 Subject: [PATCH] strmbase: COM cleanup for BaseFilter. --- dlls/qcap/vfwcapture.c | 2 +- dlls/quartz/filesource.c | 10 +++++----- dlls/quartz/nullrenderer.c | 1 - dlls/quartz/videorenderer.c | 1 - dlls/strmbase/enumpins.c | 4 ++-- dlls/strmbase/filter.c | 29 +++++++++++++++++------------ dlls/strmbase/transform.c | 2 +- include/wine/strmbase.h | 2 +- 8 files changed, 27 insertions(+), 24 deletions(-) diff --git a/dlls/qcap/vfwcapture.c b/dlls/qcap/vfwcapture.c index 1138a64830b..68341ae8eb5 100644 --- a/dlls/qcap/vfwcapture.c +++ b/dlls/qcap/vfwcapture.c @@ -139,7 +139,7 @@ IUnknown * WINAPI QCAP_createVFWCaptureFilter(IUnknown *pUnkOuter, HRESULT *phr) pVfwCapture->IPersistPropertyBag_iface.lpVtbl = &IPersistPropertyBag_VTable; pVfwCapture->init = FALSE; - hr = VfwPin_Construct((IBaseFilter *)&pVfwCapture->filter.lpVtbl, + hr = VfwPin_Construct(&pVfwCapture->filter.IBaseFilter_iface, &pVfwCapture->filter.csFilter, &pVfwCapture->pOutputPin); if (FAILED(hr)) { diff --git a/dlls/quartz/filesource.c b/dlls/quartz/filesource.c index 79c70a494c2..2adb9408092 100644 --- a/dlls/quartz/filesource.c +++ b/dlls/quartz/filesource.c @@ -529,21 +529,21 @@ static HRESULT WINAPI FileSource_QueryInterface(IFileSourceFilter * iface, REFII { AsyncReader *This = impl_from_IFileSourceFilter(iface); - return IBaseFilter_QueryInterface((IFileSourceFilter*)&This->filter.lpVtbl, riid, ppv); + return IBaseFilter_QueryInterface(&This->filter.IBaseFilter_iface, riid, ppv); } static ULONG WINAPI FileSource_AddRef(IFileSourceFilter * iface) { AsyncReader *This = impl_from_IFileSourceFilter(iface); - return IBaseFilter_AddRef((IFileSourceFilter*)&This->filter.lpVtbl); + return IBaseFilter_AddRef(&This->filter.IBaseFilter_iface); } static ULONG WINAPI FileSource_Release(IFileSourceFilter * iface) { AsyncReader *This = impl_from_IFileSourceFilter(iface); - return IBaseFilter_Release((IFileSourceFilter*)&This->filter.lpVtbl); + return IBaseFilter_Release(&This->filter.IBaseFilter_iface); } static HRESULT WINAPI FileSource_Load(IFileSourceFilter * iface, LPCOLESTR pszFileName, const AM_MEDIA_TYPE * pmt) @@ -565,8 +565,8 @@ static HRESULT WINAPI FileSource_Load(IFileSourceFilter * iface, LPCOLESTR pszFi } /* create pin */ - hr = FileAsyncReader_Construct(hFile, (IBaseFilter *)&This->filter.lpVtbl, &This->filter.csFilter, &This->pOutputPin); - BaseFilterImpl_IncrementPinVersion((BaseFilter *)&This->filter.lpVtbl); + hr = FileAsyncReader_Construct(hFile, &This->filter.IBaseFilter_iface, &This->filter.csFilter, &This->pOutputPin); + BaseFilterImpl_IncrementPinVersion(&This->filter); if (SUCCEEDED(hr)) hr = IPin_QueryInterface(This->pOutputPin, &IID_IAsyncReader, (LPVOID *)&pReader); diff --git a/dlls/quartz/nullrenderer.c b/dlls/quartz/nullrenderer.c index 9fc1b44f1df..f850b40b123 100644 --- a/dlls/quartz/nullrenderer.c +++ b/dlls/quartz/nullrenderer.c @@ -227,7 +227,6 @@ static ULONG WINAPI NullRendererInner_Release(IUnknown * iface) IPin_Disconnect((IPin *)This->pInputPin); IPin_Release((IPin *)This->pInputPin); - This->filter.lpVtbl = NULL; if (This->seekthru_unk) IUnknown_Release(This->seekthru_unk); diff --git a/dlls/quartz/videorenderer.c b/dlls/quartz/videorenderer.c index 3e1004e0122..c21164f1d88 100644 --- a/dlls/quartz/videorenderer.c +++ b/dlls/quartz/videorenderer.c @@ -694,7 +694,6 @@ static ULONG WINAPI VideoRendererInner_Release(IUnknown * iface) IPin_Release((IPin *)This->pInputPin); - This->filter.lpVtbl = NULL; IUnknown_Release(This->seekthru_unk); This->filter.csFilter.DebugInfo->Spare[0] = 0; DeleteCriticalSection(&This->filter.csFilter); diff --git a/dlls/strmbase/enumpins.c b/dlls/strmbase/enumpins.c index 13c7c6efd4a..eab4d5b0e8a 100644 --- a/dlls/strmbase/enumpins.c +++ b/dlls/strmbase/enumpins.c @@ -66,7 +66,7 @@ HRESULT WINAPI EnumPins_Construct(BaseFilter *base, BaseFilter_GetPin receive_p pEnumPins->receive_pincount = receive_pincount; pEnumPins->receive_version = receive_version; pEnumPins->base = base; - IBaseFilter_AddRef((IBaseFilter*)base); + IBaseFilter_AddRef(&base->IBaseFilter_iface); *ppEnum = &pEnumPins->IEnumPins_iface; pEnumPins->Version = receive_version(base); @@ -115,7 +115,7 @@ static ULONG WINAPI IEnumPinsImpl_Release(IEnumPins * iface) if (!refCount) { - IBaseFilter_Release((IBaseFilter*)This->base); + IBaseFilter_Release(&This->base->IBaseFilter_iface); CoTaskMemFree(This); return 0; } diff --git a/dlls/strmbase/filter.c b/dlls/strmbase/filter.c index 6656cfaadc1..67f7c9ff226 100644 --- a/dlls/strmbase/filter.c +++ b/dlls/strmbase/filter.c @@ -29,9 +29,14 @@ WINE_DEFAULT_DEBUG_CHANNEL(strmbase); +static inline BaseFilter *impl_from_IBaseFilter(IBaseFilter *iface) +{ + return CONTAINING_RECORD(iface, BaseFilter, IBaseFilter_iface); +} + HRESULT WINAPI BaseFilterImpl_QueryInterface(IBaseFilter * iface, REFIID riid, LPVOID * ppv) { - BaseFilter *This = (BaseFilter *)iface; + BaseFilter *This = impl_from_IBaseFilter(iface); TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), ppv); *ppv = NULL; @@ -56,7 +61,7 @@ HRESULT WINAPI BaseFilterImpl_QueryInterface(IBaseFilter * iface, REFIID riid, L ULONG WINAPI BaseFilterImpl_AddRef(IBaseFilter * iface) { - BaseFilter *This = (BaseFilter*)iface; + BaseFilter *This = impl_from_IBaseFilter(iface); ULONG refCount = InterlockedIncrement(&This->refCount); TRACE("(%p)->() AddRef from %d\n", This, refCount - 1); @@ -66,7 +71,7 @@ ULONG WINAPI BaseFilterImpl_AddRef(IBaseFilter * iface) ULONG WINAPI BaseFilterImpl_Release(IBaseFilter * iface) { - BaseFilter *This = (BaseFilter *)iface; + BaseFilter *This = impl_from_IBaseFilter(iface); ULONG refCount = InterlockedDecrement(&This->refCount); TRACE("(%p)->() Release from %d\n", This, refCount + 1); @@ -76,7 +81,7 @@ ULONG WINAPI BaseFilterImpl_Release(IBaseFilter * iface) if (This->pClock) IReferenceClock_Release(This->pClock); - This->lpVtbl = NULL; + This->IBaseFilter_iface.lpVtbl = NULL; This->csFilter.DebugInfo->Spare[0] = 0; DeleteCriticalSection(&This->csFilter); } @@ -86,7 +91,7 @@ ULONG WINAPI BaseFilterImpl_Release(IBaseFilter * iface) HRESULT WINAPI BaseFilterImpl_GetClassID(IBaseFilter * iface, CLSID * pClsid) { - BaseFilter *This = (BaseFilter*)iface; + BaseFilter *This = impl_from_IBaseFilter(iface); TRACE("(%p)->(%p)\n", This, pClsid); *pClsid = This->clsid; @@ -96,7 +101,7 @@ HRESULT WINAPI BaseFilterImpl_GetClassID(IBaseFilter * iface, CLSID * pClsid) HRESULT WINAPI BaseFilterImpl_GetState(IBaseFilter * iface, DWORD dwMilliSecsTimeout, FILTER_STATE *pState ) { - BaseFilter *This = (BaseFilter*)iface; + BaseFilter *This = impl_from_IBaseFilter(iface); TRACE("(%p)->(%d, %p)\n", This, dwMilliSecsTimeout, pState); EnterCriticalSection(&This->csFilter); @@ -110,7 +115,7 @@ HRESULT WINAPI BaseFilterImpl_GetState(IBaseFilter * iface, DWORD dwMilliSecsTim HRESULT WINAPI BaseFilterImpl_SetSyncSource(IBaseFilter * iface, IReferenceClock *pClock) { - BaseFilter *This = (BaseFilter*)iface; + BaseFilter *This = impl_from_IBaseFilter(iface); TRACE("(%p)->(%p)\n", This, pClock); EnterCriticalSection(&This->csFilter); @@ -128,7 +133,7 @@ HRESULT WINAPI BaseFilterImpl_SetSyncSource(IBaseFilter * iface, IReferenceClock HRESULT WINAPI BaseFilterImpl_GetSyncSource(IBaseFilter * iface, IReferenceClock **ppClock) { - BaseFilter *This = (BaseFilter*)iface; + BaseFilter *This = impl_from_IBaseFilter(iface); TRACE("(%p)->(%p)\n", This, ppClock); EnterCriticalSection(&This->csFilter); @@ -144,7 +149,7 @@ HRESULT WINAPI BaseFilterImpl_GetSyncSource(IBaseFilter * iface, IReferenceClock HRESULT WINAPI BaseFilterImpl_EnumPins(IBaseFilter * iface, IEnumPins **ppEnum) { - BaseFilter *This = (BaseFilter*)iface; + BaseFilter *This = impl_from_IBaseFilter(iface); TRACE("(%p)->(%p)\n", iface, ppEnum); @@ -154,7 +159,7 @@ HRESULT WINAPI BaseFilterImpl_EnumPins(IBaseFilter * iface, IEnumPins **ppEnum) HRESULT WINAPI BaseFilterImpl_QueryFilterInfo(IBaseFilter * iface, FILTER_INFO *pInfo) { - BaseFilter *This = (BaseFilter*)iface; + BaseFilter *This = impl_from_IBaseFilter(iface); TRACE("(%p)->(%p)\n", This, pInfo); strcpyW(pInfo->achName, This->filterInfo.achName); @@ -169,7 +174,7 @@ HRESULT WINAPI BaseFilterImpl_QueryFilterInfo(IBaseFilter * iface, FILTER_INFO * HRESULT WINAPI BaseFilterImpl_JoinFilterGraph(IBaseFilter * iface, IFilterGraph *pGraph, LPCWSTR pName ) { HRESULT hr = S_OK; - BaseFilter *This = (BaseFilter*)iface; + BaseFilter *This = impl_from_IBaseFilter(iface); TRACE("(%p)->(%p, %s)\n", This, pGraph, debugstr_w(pName)); @@ -206,7 +211,7 @@ VOID WINAPI BaseFilterImpl_IncrementPinVersion(BaseFilter * This) HRESULT WINAPI BaseFilter_Init(BaseFilter * This, const IBaseFilterVtbl *Vtbl, const CLSID *pClsid, DWORD_PTR DebugInfo, const BaseFilterFuncTable* pBaseFuncsTable) { - This->lpVtbl = Vtbl; + This->IBaseFilter_iface.lpVtbl = Vtbl; This->refCount = 1; InitializeCriticalSection(&This->csFilter); This->state = State_Stopped; diff --git a/dlls/strmbase/transform.c b/dlls/strmbase/transform.c index 012f68a8ea1..b74eaae584d 100644 --- a/dlls/strmbase/transform.c +++ b/dlls/strmbase/transform.c @@ -233,7 +233,7 @@ HRESULT TransformFilter_Construct(const IBaseFilterVtbl *pVtbl, LONG filter_size if (SUCCEEDED(TransformFilter_Init(pVtbl, pClsid, pFuncsTable, pTf))) { - *ppTransformFilter = (IBaseFilter*)(&pTf->filter.lpVtbl); + *ppTransformFilter = &pTf->filter.IBaseFilter_iface; return S_OK; } diff --git a/include/wine/strmbase.h b/include/wine/strmbase.h index 89b1898d938..4c1f3fd0912 100644 --- a/include/wine/strmbase.h +++ b/include/wine/strmbase.h @@ -148,7 +148,7 @@ HRESULT BaseInputPin_Construct(const IPinVtbl *InputPin_Vtbl, const PIN_INFO * p typedef struct BaseFilter { - const struct IBaseFilterVtbl *lpVtbl; + IBaseFilter IBaseFilter_iface; LONG refCount; CRITICAL_SECTION csFilter;