Commit d2d3a9c4 authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

quartz: Standardize COM aggregation for FilterMapper.

parent 692814e1
...@@ -47,14 +47,12 @@ WINE_DEFAULT_DEBUG_CHANNEL(quartz); ...@@ -47,14 +47,12 @@ WINE_DEFAULT_DEBUG_CHANNEL(quartz);
typedef struct FilterMapper3Impl typedef struct FilterMapper3Impl
{ {
IUnknown IUnknown_inner;
IFilterMapper3 IFilterMapper3_iface; IFilterMapper3 IFilterMapper3_iface;
IFilterMapper IFilterMapper_iface; IFilterMapper IFilterMapper_iface;
IAMFilterData IAMFilterData_iface; IAMFilterData IAMFilterData_iface;
const IUnknownVtbl *IInner_vtbl; IUnknown *outer_unk;
LONG refCount; LONG ref;
IUnknown * pUnkOuter;
BOOL bUnkOuterValid;
BOOL bAggregatable;
} FilterMapper3Impl; } FilterMapper3Impl;
static const IUnknownVtbl IInner_VTable; static const IUnknownVtbl IInner_VTable;
...@@ -77,9 +75,9 @@ static inline FilterMapper3Impl *impl_from_IAMFilterData( IAMFilterData *iface ) ...@@ -77,9 +75,9 @@ static inline FilterMapper3Impl *impl_from_IAMFilterData( IAMFilterData *iface )
return CONTAINING_RECORD(iface, FilterMapper3Impl, IAMFilterData_iface); return CONTAINING_RECORD(iface, FilterMapper3Impl, IAMFilterData_iface);
} }
static inline FilterMapper3Impl *impl_from_inner_IUnknown( IUnknown *iface ) static inline FilterMapper3Impl *impl_from_IUnknown( IUnknown *iface )
{ {
return (FilterMapper3Impl *)((char*)iface - FIELD_OFFSET(FilterMapper3Impl, IInner_vtbl)); return CONTAINING_RECORD(iface, FilterMapper3Impl, IUnknown_inner);
} }
static const WCHAR wszClsidSlash[] = {'C','L','S','I','D','\\',0}; static const WCHAR wszClsidSlash[] = {'C','L','S','I','D','\\',0};
...@@ -192,16 +190,18 @@ HRESULT FilterMapper2_create(IUnknown *pUnkOuter, LPVOID *ppObj) ...@@ -192,16 +190,18 @@ HRESULT FilterMapper2_create(IUnknown *pUnkOuter, LPVOID *ppObj)
if (!pFM2impl) if (!pFM2impl)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
pFM2impl->pUnkOuter = pUnkOuter; pFM2impl->IUnknown_inner.lpVtbl = &IInner_VTable;
pFM2impl->bUnkOuterValid = FALSE;
pFM2impl->bAggregatable = FALSE;
pFM2impl->IInner_vtbl = &IInner_VTable;
pFM2impl->IFilterMapper3_iface.lpVtbl = &fm3vtbl; pFM2impl->IFilterMapper3_iface.lpVtbl = &fm3vtbl;
pFM2impl->IFilterMapper_iface.lpVtbl = &fmvtbl; pFM2impl->IFilterMapper_iface.lpVtbl = &fmvtbl;
pFM2impl->IAMFilterData_iface.lpVtbl = &AMFilterDataVtbl; pFM2impl->IAMFilterData_iface.lpVtbl = &AMFilterDataVtbl;
pFM2impl->refCount = 1; pFM2impl->ref = 1;
*ppObj = pFM2impl; if (pUnkOuter)
pFM2impl->outer_unk = pUnkOuter;
else
pFM2impl->outer_unk = &pFM2impl->IUnknown_inner;
*ppObj = &pFM2impl->IUnknown_inner;
TRACE("-- created at %p\n", pFM2impl); TRACE("-- created at %p\n", pFM2impl);
...@@ -226,21 +226,17 @@ HRESULT FilterMapper_create(IUnknown *pUnkOuter, LPVOID *ppObj) ...@@ -226,21 +226,17 @@ HRESULT FilterMapper_create(IUnknown *pUnkOuter, LPVOID *ppObj)
/*** IUnknown (inner) methods ***/ /*** IUnknown (inner) methods ***/
static HRESULT WINAPI Inner_QueryInterface(IUnknown * iface, REFIID riid, LPVOID * ppv) static HRESULT WINAPI Inner_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)
{ {
FilterMapper3Impl *This = impl_from_inner_IUnknown(iface); FilterMapper3Impl *This = impl_from_IUnknown(iface);
TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), ppv);
if (This->bAggregatable) TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), ppv);
This->bUnkOuterValid = TRUE;
*ppv = NULL; *ppv = NULL;
if (IsEqualIID(riid, &IID_IUnknown)) if (IsEqualIID(riid, &IID_IUnknown))
*ppv = &This->IInner_vtbl; *ppv = &This->IUnknown_inner;
else if (IsEqualIID(riid, &IID_IFilterMapper2) || else if (IsEqualIID(riid, &IID_IFilterMapper2) || IsEqualIID(riid, &IID_IFilterMapper3))
IsEqualIID(riid, &IID_IFilterMapper3)) *ppv = &This->IFilterMapper3_iface;
*ppv = This;
else if (IsEqualIID(riid, &IID_IFilterMapper)) else if (IsEqualIID(riid, &IID_IFilterMapper))
*ppv = &This->IFilterMapper_iface; *ppv = &This->IFilterMapper_iface;
else if (IsEqualIID(riid, &IID_IAMFilterData)) else if (IsEqualIID(riid, &IID_IAMFilterData))
...@@ -256,29 +252,27 @@ static HRESULT WINAPI Inner_QueryInterface(IUnknown * iface, REFIID riid, LPVOID ...@@ -256,29 +252,27 @@ static HRESULT WINAPI Inner_QueryInterface(IUnknown * iface, REFIID riid, LPVOID
return E_NOINTERFACE; return E_NOINTERFACE;
} }
static ULONG WINAPI Inner_AddRef(IUnknown * iface) static ULONG WINAPI Inner_AddRef(IUnknown *iface)
{ {
FilterMapper3Impl *This = impl_from_inner_IUnknown(iface); FilterMapper3Impl *This = impl_from_IUnknown(iface);
ULONG refCount = InterlockedIncrement(&This->refCount); ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p)->() AddRef from %d\n", This, refCount - 1); TRACE("(%p)->(): new ref = %d\n", This, ref);
return refCount; return ref;
} }
static ULONG WINAPI Inner_Release(IUnknown * iface) static ULONG WINAPI Inner_Release(IUnknown *iface)
{ {
FilterMapper3Impl *This = impl_from_inner_IUnknown(iface); FilterMapper3Impl *This = impl_from_IUnknown(iface);
ULONG refCount = InterlockedDecrement(&This->refCount); ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p)->() Release from %d\n", This, refCount + 1); TRACE("(%p)->(): new ref = %d\n", This, ref);
if (refCount == 0) if (ref == 0)
{
CoTaskMemFree(This); CoTaskMemFree(This);
return 0;
} return ref;
return refCount;
} }
static const IUnknownVtbl IInner_VTable = static const IUnknownVtbl IInner_VTable =
...@@ -292,48 +286,21 @@ static HRESULT WINAPI FilterMapper3_QueryInterface(IFilterMapper3 * iface, REFII ...@@ -292,48 +286,21 @@ static HRESULT WINAPI FilterMapper3_QueryInterface(IFilterMapper3 * iface, REFII
{ {
FilterMapper3Impl *This = impl_from_IFilterMapper3(iface); FilterMapper3Impl *This = impl_from_IFilterMapper3(iface);
if (This->bAggregatable) return IUnknown_QueryInterface(This->outer_unk, riid, ppv);
This->bUnkOuterValid = TRUE;
if (This->pUnkOuter)
{
if (This->bAggregatable)
return IUnknown_QueryInterface(This->pUnkOuter, riid, ppv);
if (IsEqualIID(riid, &IID_IUnknown))
{
HRESULT hr;
IUnknown_AddRef((IUnknown *)&(This->IInner_vtbl));
hr = IUnknown_QueryInterface((IUnknown *)&(This->IInner_vtbl), riid, ppv);
IUnknown_Release((IUnknown *)&(This->IInner_vtbl));
This->bAggregatable = TRUE;
return hr;
}
*ppv = NULL;
return E_NOINTERFACE;
}
return IUnknown_QueryInterface((IUnknown *)&(This->IInner_vtbl), riid, ppv);
} }
static ULONG WINAPI FilterMapper3_AddRef(IFilterMapper3 * iface) static ULONG WINAPI FilterMapper3_AddRef(IFilterMapper3 * iface)
{ {
FilterMapper3Impl *This = impl_from_IFilterMapper3(iface); FilterMapper3Impl *This = impl_from_IFilterMapper3(iface);
if (This->pUnkOuter && This->bUnkOuterValid) return IUnknown_AddRef(This->outer_unk);
return IUnknown_AddRef(This->pUnkOuter);
return IUnknown_AddRef((IUnknown *)&(This->IInner_vtbl));
} }
static ULONG WINAPI FilterMapper3_Release(IFilterMapper3 * iface) static ULONG WINAPI FilterMapper3_Release(IFilterMapper3 * iface)
{ {
FilterMapper3Impl *This = impl_from_IFilterMapper3(iface); FilterMapper3Impl *This = impl_from_IFilterMapper3(iface);
if (This->pUnkOuter && This->bUnkOuterValid) return IUnknown_Release(This->outer_unk);
return IUnknown_Release(This->pUnkOuter);
return IUnknown_Release((IUnknown *)&(This->IInner_vtbl));
} }
/*** IFilterMapper3 methods ***/ /*** IFilterMapper3 methods ***/
...@@ -1206,14 +1173,14 @@ static ULONG WINAPI FilterMapper_AddRef(IFilterMapper * iface) ...@@ -1206,14 +1173,14 @@ static ULONG WINAPI FilterMapper_AddRef(IFilterMapper * iface)
{ {
FilterMapper3Impl *This = impl_from_IFilterMapper(iface); FilterMapper3Impl *This = impl_from_IFilterMapper(iface);
return FilterMapper3_AddRef(&This->IFilterMapper3_iface); return IUnknown_AddRef(This->outer_unk);
} }
static ULONG WINAPI FilterMapper_Release(IFilterMapper * iface) static ULONG WINAPI FilterMapper_Release(IFilterMapper * iface)
{ {
FilterMapper3Impl *This = impl_from_IFilterMapper(iface); FilterMapper3Impl *This = impl_from_IFilterMapper(iface);
return FilterMapper3_Release(&This->IFilterMapper3_iface); return IUnknown_Release(This->outer_unk);
} }
/*** IFilterMapper methods ***/ /*** IFilterMapper methods ***/
...@@ -1708,21 +1675,21 @@ static HRESULT WINAPI AMFilterData_QueryInterface(IAMFilterData * iface, REFIID ...@@ -1708,21 +1675,21 @@ static HRESULT WINAPI AMFilterData_QueryInterface(IAMFilterData * iface, REFIID
{ {
FilterMapper3Impl *This = impl_from_IAMFilterData(iface); FilterMapper3Impl *This = impl_from_IAMFilterData(iface);
return FilterMapper3_QueryInterface(&This->IFilterMapper3_iface, riid, ppv); return IUnknown_QueryInterface(This->outer_unk, riid, ppv);
} }
static ULONG WINAPI AMFilterData_AddRef(IAMFilterData * iface) static ULONG WINAPI AMFilterData_AddRef(IAMFilterData * iface)
{ {
FilterMapper3Impl *This = impl_from_IAMFilterData(iface); FilterMapper3Impl *This = impl_from_IAMFilterData(iface);
return FilterMapper3_AddRef(&This->IFilterMapper3_iface); return IUnknown_AddRef(This->outer_unk);
} }
static ULONG WINAPI AMFilterData_Release(IAMFilterData * iface) static ULONG WINAPI AMFilterData_Release(IAMFilterData * iface)
{ {
FilterMapper3Impl *This = impl_from_IAMFilterData(iface); FilterMapper3Impl *This = impl_from_IAMFilterData(iface);
return FilterMapper3_Release(&This->IFilterMapper3_iface); return IUnknown_Release(This->outer_unk);
} }
/*** IAMFilterData methods ***/ /*** IAMFilterData methods ***/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment