strmbase: COM cleanup for BaseFilter.

This commit is contained in:
Aric Stewart 2012-03-24 11:42:27 -05:00 committed by Alexandre Julliard
parent 7fe02c47f3
commit 29d3c75442
8 changed files with 27 additions and 24 deletions

View File

@ -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))
{

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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;
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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;