Commit 3b48ba6c authored by Thomas Faber's avatar Thomas Faber Committed by Alexandre Julliard

quartz: Don't cache IFilterMapper2 interface in FilterGraph2.

parent 689f0484
...@@ -176,7 +176,6 @@ typedef struct _IFilterGraphImpl { ...@@ -176,7 +176,6 @@ typedef struct _IFilterGraphImpl {
IUnknown *outer_unk; IUnknown *outer_unk;
LONG ref; LONG ref;
IUnknown *punkFilterMapper2; IUnknown *punkFilterMapper2;
IFilterMapper2 * pFilterMapper2;
IBaseFilter ** ppFiltersInGraph; IBaseFilter ** ppFiltersInGraph;
LPWSTR * pFilterNames; LPWSTR * pFilterNames;
ULONG nFilters; ULONG nFilters;
...@@ -265,11 +264,11 @@ static HRESULT WINAPI FilterGraphInner_QueryInterface(IUnknown *iface, REFIID ri ...@@ -265,11 +264,11 @@ static HRESULT WINAPI FilterGraphInner_QueryInterface(IUnknown *iface, REFIID ri
TRACE(" requesting IFilterMapper interface from aggregated filtermapper (%p)\n", *ppvObj); TRACE(" requesting IFilterMapper interface from aggregated filtermapper (%p)\n", *ppvObj);
return IUnknown_QueryInterface(This->punkFilterMapper2, riid, ppvObj); return IUnknown_QueryInterface(This->punkFilterMapper2, riid, ppvObj);
} else if (IsEqualGUID(&IID_IFilterMapper2, riid)) { } else if (IsEqualGUID(&IID_IFilterMapper2, riid)) {
*ppvObj = This->pFilterMapper2;
TRACE(" returning IFilterMapper2 interface from aggregated filtermapper (%p)\n", *ppvObj); TRACE(" returning IFilterMapper2 interface from aggregated filtermapper (%p)\n", *ppvObj);
return IUnknown_QueryInterface(This->punkFilterMapper2, riid, ppvObj);
} else if (IsEqualGUID(&IID_IFilterMapper3, riid)) { } else if (IsEqualGUID(&IID_IFilterMapper3, riid)) {
*ppvObj = This->pFilterMapper2;
TRACE(" returning IFilterMapper3 interface from aggregated filtermapper (%p)\n", *ppvObj); TRACE(" returning IFilterMapper3 interface from aggregated filtermapper (%p)\n", *ppvObj);
return IUnknown_QueryInterface(This->punkFilterMapper2, riid, ppvObj);
} else if (IsEqualGUID(&IID_IGraphVersion, riid)) { } else if (IsEqualGUID(&IID_IGraphVersion, riid)) {
*ppvObj = &This->IGraphConfig_iface; *ppvObj = &This->IGraphConfig_iface;
TRACE(" returning IGraphConfig interface (%p)\n", *ppvObj); TRACE(" returning IGraphConfig interface (%p)\n", *ppvObj);
...@@ -319,9 +318,6 @@ static ULONG WINAPI FilterGraphInner_Release(IUnknown *iface) ...@@ -319,9 +318,6 @@ static ULONG WINAPI FilterGraphInner_Release(IUnknown *iface)
IUnknown_Release(This->ItfCacheEntries[i].iface); IUnknown_Release(This->ItfCacheEntries[i].iface);
} }
/* AddRef on controlling IUnknown, to compensate for Release of cached IFilterMapper2 */
IUnknown_AddRef(This->outer_unk);
IFilterMapper2_Release(This->pFilterMapper2);
IUnknown_Release(This->punkFilterMapper2); IUnknown_Release(This->punkFilterMapper2);
if (This->pSite) IUnknown_Release(This->pSite); if (This->pSite) IUnknown_Release(This->pSite);
...@@ -910,6 +906,7 @@ static HRESULT WINAPI FilterGraph2_Connect(IFilterGraph2 *iface, IPin *ppinOut, ...@@ -910,6 +906,7 @@ static HRESULT WINAPI FilterGraph2_Connect(IFilterGraph2 *iface, IPin *ppinOut,
CLSID FilterCLSID; CLSID FilterCLSID;
PIN_DIRECTION dir; PIN_DIRECTION dir;
unsigned int i = 0; unsigned int i = 0;
IFilterMapper2 *pFilterMapper2 = NULL;
TRACE("(%p/%p)->(%p, %p)\n", This, iface, ppinOut, ppinIn); TRACE("(%p/%p)->(%p, %p)\n", This, iface, ppinOut, ppinIn);
...@@ -999,10 +996,16 @@ static HRESULT WINAPI FilterGraph2_Connect(IFilterGraph2 *iface, IPin *ppinOut, ...@@ -999,10 +996,16 @@ static HRESULT WINAPI FilterGraph2_Connect(IFilterGraph2 *iface, IPin *ppinOut,
TRACE("MajorType %s\n", debugstr_guid(&mt->majortype)); TRACE("MajorType %s\n", debugstr_guid(&mt->majortype));
TRACE("SubType %s\n", debugstr_guid(&mt->subtype)); TRACE("SubType %s\n", debugstr_guid(&mt->subtype));
hr = IUnknown_QueryInterface(This->punkFilterMapper2, &IID_IFilterMapper2, (void**)&pFilterMapper2);
if (FAILED(hr)) {
WARN("Unable to get IFilterMapper2 (%x)\n", hr);
goto out;
}
/* Try to find a suitable filter that can connect to the pin to render */ /* Try to find a suitable filter that can connect to the pin to render */
tab[0] = mt->majortype; tab[0] = mt->majortype;
tab[1] = mt->subtype; tab[1] = mt->subtype;
hr = IFilterMapper2_EnumMatchingFilters(This->pFilterMapper2, &pEnumMoniker, 0, FALSE, MERIT_UNLIKELY, TRUE, 1, tab, NULL, NULL, FALSE, FALSE, 0, NULL, NULL, NULL); hr = IFilterMapper2_EnumMatchingFilters(pFilterMapper2, &pEnumMoniker, 0, FALSE, MERIT_UNLIKELY, TRUE, 1, tab, NULL, NULL, FALSE, FALSE, 0, NULL, NULL, NULL);
if (FAILED(hr)) { if (FAILED(hr)) {
WARN("Unable to enum filters (%x)\n", hr); WARN("Unable to enum filters (%x)\n", hr);
goto out; goto out;
...@@ -1172,6 +1175,8 @@ error: ...@@ -1172,6 +1175,8 @@ error:
IEnumMoniker_Release(pEnumMoniker); IEnumMoniker_Release(pEnumMoniker);
out: out:
if (pFilterMapper2)
IFilterMapper2_Release(pFilterMapper2);
if (penummt) if (penummt)
IEnumMediaTypes_Release(penummt); IEnumMediaTypes_Release(penummt);
if (mt) if (mt)
...@@ -1267,6 +1272,7 @@ static HRESULT WINAPI FilterGraph2_Render(IFilterGraph2 *iface, IPin *ppinOut) ...@@ -1267,6 +1272,7 @@ static HRESULT WINAPI FilterGraph2_Render(IFilterGraph2 *iface, IPin *ppinOut)
ULONG nb; ULONG nb;
IMoniker* pMoniker; IMoniker* pMoniker;
INT x; INT x;
IFilterMapper2 *pFilterMapper2 = NULL;
TRACE("(%p/%p)->(%p)\n", This, iface, ppinOut); TRACE("(%p/%p)->(%p)\n", This, iface, ppinOut);
...@@ -1376,10 +1382,20 @@ static HRESULT WINAPI FilterGraph2_Render(IFilterGraph2 *iface, IPin *ppinOut) ...@@ -1376,10 +1382,20 @@ static HRESULT WINAPI FilterGraph2_Render(IFilterGraph2 *iface, IPin *ppinOut)
continue; continue;
} }
if (pFilterMapper2 == NULL)
{
hr = IUnknown_QueryInterface(This->punkFilterMapper2, &IID_IFilterMapper2, (void**)&pFilterMapper2);
if (FAILED(hr))
{
WARN("Unable to query IFilterMapper2 (%x)\n", hr);
break;
}
}
/* Try to find a suitable renderer with the same media type */ /* Try to find a suitable renderer with the same media type */
tab[0] = mt->majortype; tab[0] = mt->majortype;
tab[1] = mt->subtype; tab[1] = mt->subtype;
hr = IFilterMapper2_EnumMatchingFilters(This->pFilterMapper2, &pEnumMoniker, 0, FALSE, MERIT_UNLIKELY, TRUE, 1, tab, NULL, NULL, FALSE, FALSE, 0, NULL, NULL, NULL); hr = IFilterMapper2_EnumMatchingFilters(pFilterMapper2, &pEnumMoniker, 0, FALSE, MERIT_UNLIKELY, TRUE, 1, tab, NULL, NULL, FALSE, FALSE, 0, NULL, NULL, NULL);
if (FAILED(hr)) if (FAILED(hr))
{ {
WARN("Unable to enum filters (%x)\n", hr); WARN("Unable to enum filters (%x)\n", hr);
...@@ -1493,6 +1509,9 @@ error: ...@@ -1493,6 +1509,9 @@ error:
hr = S_OK; hr = S_OK;
} }
if (pFilterMapper2)
IFilterMapper2_Release(pFilterMapper2);
IEnumMediaTypes_Release(penummt); IEnumMediaTypes_Release(penummt);
return hr; return hr;
} }
...@@ -5708,14 +5727,6 @@ HRESULT FilterGraph_create(IUnknown *pUnkOuter, LPVOID *ppObj) ...@@ -5708,14 +5727,6 @@ HRESULT FilterGraph_create(IUnknown *pUnkOuter, LPVOID *ppObj)
hr = CoCreateInstance(&CLSID_FilterMapper2, fimpl->outer_unk, CLSCTX_INPROC_SERVER, hr = CoCreateInstance(&CLSID_FilterMapper2, fimpl->outer_unk, CLSCTX_INPROC_SERVER,
&IID_IUnknown, (void**)&fimpl->punkFilterMapper2); &IID_IUnknown, (void**)&fimpl->punkFilterMapper2);
if (SUCCEEDED(hr))
hr = IUnknown_QueryInterface(fimpl->punkFilterMapper2, &IID_IFilterMapper2,
(void**)&fimpl->pFilterMapper2);
if (SUCCEEDED(hr))
/* Release controlling IUnknown - compensate refcount increase from caching IFilterMapper2 interface. */
IUnknown_Release(fimpl->outer_unk);
if (FAILED(hr)) { if (FAILED(hr)) {
ERR("Unable to create filter mapper (%x)\n", hr); ERR("Unable to create filter mapper (%x)\n", hr);
if (fimpl->punkFilterMapper2) IUnknown_Release(fimpl->punkFilterMapper2); if (fimpl->punkFilterMapper2) IUnknown_Release(fimpl->punkFilterMapper2);
......
...@@ -1942,9 +1942,7 @@ static void test_aggregate_filter_graph(void) ...@@ -1942,9 +1942,7 @@ static void test_aggregate_filter_graph(void)
ok(punk != &unk_outer.IUnknown_iface, "punk = %p, expected not %p\n", punk, &unk_outer.IUnknown_iface); ok(punk != &unk_outer.IUnknown_iface, "punk = %p, expected not %p\n", punk, &unk_outer.IUnknown_iface);
IUnknown_Release(punk); IUnknown_Release(punk);
todo_wine
ok(unk_outer.AddRef_called == 0, "IUnknownImpl_AddRef called %d times\n", unk_outer.AddRef_called); ok(unk_outer.AddRef_called == 0, "IUnknownImpl_AddRef called %d times\n", unk_outer.AddRef_called);
todo_wine
ok(unk_outer.Release_called == 0, "IUnknownImpl_Release called %d times\n", unk_outer.Release_called); ok(unk_outer.Release_called == 0, "IUnknownImpl_Release called %d times\n", unk_outer.Release_called);
unk_outer.AddRef_called = 0; unk_outer.AddRef_called = 0;
unk_outer.Release_called = 0; unk_outer.Release_called = 0;
......
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