quartz/filtergraph: Don't use QueryInternalConnections() to find output pins in FilterGraph2_Connect().

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2018-09-20 10:36:18 -05:00 committed by Alexandre Julliard
parent 2fea063245
commit 6eb05abf5f
1 changed files with 52 additions and 50 deletions

View File

@ -1036,6 +1036,55 @@ static HRESULT GetInternalConnections(IBaseFilter* pfilter, IPin* pinputpin, IPi
return S_OK; return S_OK;
} }
/* Attempt to connect one of the output pins on filter to sink. Helper for
* FilterGraph2_Connect(). */
static HRESULT connect_output_pin(IFilterGraphImpl *graph, IBaseFilter *filter, IPin *sink)
{
IEnumPins *enumpins;
PIN_DIRECTION dir;
HRESULT hr;
WCHAR *id;
IPin *pin;
hr = IBaseFilter_EnumPins(filter, &enumpins);
if (FAILED(hr))
return hr;
while (IEnumPins_Next(enumpins, 1, &pin, NULL) == S_OK)
{
IPin_QueryDirection(pin, &dir);
if (dir == PINDIR_OUTPUT)
{
hr = IPin_QueryId(pin, &id);
if (FAILED(hr))
{
IPin_Release(pin);
IEnumPins_Release(enumpins);
return hr;
}
if (id[0] == '~')
{
TRACE("Skipping non-rendered pin %s.\n", debugstr_w(id));
IPin_Release(pin);
IEnumPins_Release(enumpins);
return E_FAIL;
}
if (SUCCEEDED(IFilterGraph2_Connect(&graph->IFilterGraph2_iface, pin, sink)))
{
IPin_Release(pin);
IEnumPins_Release(enumpins);
return S_OK;
}
}
IPin_Release(pin);
}
IEnumPins_Release(enumpins);
return VFW_E_CANNOT_CONNECT;
}
/*** IGraphBuilder methods ***/ /*** IGraphBuilder methods ***/
static HRESULT WINAPI FilterGraph2_Connect(IFilterGraph2 *iface, IPin *ppinOut, IPin *ppinIn) static HRESULT WINAPI FilterGraph2_Connect(IFilterGraph2 *iface, IPin *ppinOut, IPin *ppinIn)
{ {
@ -1047,13 +1096,11 @@ static HRESULT WINAPI FilterGraph2_Connect(IFilterGraph2 *iface, IPin *ppinOut,
IEnumPins* penumpins; IEnumPins* penumpins;
IEnumMoniker* pEnumMoniker; IEnumMoniker* pEnumMoniker;
GUID tab[2]; GUID tab[2];
ULONG nb = 0;
IMoniker* pMoniker; IMoniker* pMoniker;
ULONG pin; ULONG pin;
PIN_INFO PinInfo; PIN_INFO PinInfo;
CLSID FilterCLSID; CLSID FilterCLSID;
PIN_DIRECTION dir; PIN_DIRECTION dir;
unsigned int i = 0;
IFilterMapper2 *pFilterMapper2 = NULL; IFilterMapper2 *pFilterMapper2 = NULL;
TRACE("(%p/%p)->(%p, %p)\n", This, iface, ppinOut, ppinIn); TRACE("(%p/%p)->(%p, %p)\n", This, iface, ppinOut, ppinIn);
@ -1162,11 +1209,10 @@ static HRESULT WINAPI FilterGraph2_Connect(IFilterGraph2 *iface, IPin *ppinOut,
} }
hr = VFW_E_CANNOT_RENDER; hr = VFW_E_CANNOT_RENDER;
while(IEnumMoniker_Next(pEnumMoniker, 1, &pMoniker, &nb) == S_OK) while (IEnumMoniker_Next(pEnumMoniker, 1, &pMoniker, NULL) == S_OK)
{ {
VARIANT var; VARIANT var;
GUID clsid; GUID clsid;
IPin** ppins = NULL;
IPin* ppinfilter = NULL; IPin* ppinfilter = NULL;
IBaseFilter* pfilter = NULL; IBaseFilter* pfilter = NULL;
IAMGraphBuilderCallback *callback = NULL; IAMGraphBuilderCallback *callback = NULL;
@ -1263,52 +1309,10 @@ static HRESULT WINAPI FilterGraph2_Connect(IFilterGraph2 *iface, IPin *ppinOut,
} }
TRACE("Successfully connected to filter, follow chain...\n"); TRACE("Successfully connected to filter, follow chain...\n");
/* Render all output pins of the filter by calling IFilterGraph2_Connect on each of them */ if (SUCCEEDED(hr = connect_output_pin(This, pfilter, ppinIn)))
hr = GetInternalConnections(pfilter, ppinfilter, &ppins, &nb); {
if (SUCCEEDED(hr)) {
if (nb == 0) {
IPin_Disconnect(ppinfilter);
IPin_Disconnect(ppinOut);
goto error;
}
TRACE("pins to consider: %d\n", nb);
for(i = 0; i < nb; i++)
{
LPWSTR pinname = NULL;
TRACE("Processing pin %u\n", i);
hr = IPin_QueryId(ppins[i], &pinname);
if (SUCCEEDED(hr))
{
if (pinname[0] == '~')
{
TRACE("Pinname=%s, skipping\n", debugstr_w(pinname));
hr = E_FAIL;
}
else
hr = IFilterGraph2_Connect(iface, ppins[i], ppinIn);
CoTaskMemFree(pinname);
}
if (FAILED(hr)) {
TRACE("Cannot connect pin %p (%x)\n", ppinfilter, hr);
}
IPin_Release(ppins[i]);
if (SUCCEEDED(hr)) break;
}
while (++i < nb) IPin_Release(ppins[i]);
CoTaskMemFree(ppins);
IPin_Release(ppinfilter); IPin_Release(ppinfilter);
IBaseFilter_Release(pfilter); IBaseFilter_Release(pfilter);
if (FAILED(hr))
{
IPin_Disconnect(ppinfilter);
IPin_Disconnect(ppinOut);
IFilterGraph2_RemoveFilter(iface, pfilter);
continue;
}
break; break;
} }
@ -1319,8 +1323,6 @@ error:
IFilterGraph2_RemoveFilter(iface, pfilter); IFilterGraph2_RemoveFilter(iface, pfilter);
IBaseFilter_Release(pfilter); IBaseFilter_Release(pfilter);
} }
while (++i < nb) IPin_Release(ppins[i]);
CoTaskMemFree(ppins);
} }
IEnumMoniker_Release(pEnumMoniker); IEnumMoniker_Release(pEnumMoniker);