Brendan McGrath : quartz/filtergraph: Iterate over all source pins in ExploreGraph().
Alexandre Julliard
julliard at winehq.org
Tue Oct 9 16:22:47 CDT 2018
Module: wine
Branch: master
Commit: 9f0534301321c9192c9e3a705b2bae84a2081745
URL: https://source.winehq.org/git/wine.git/?a=commit;h=9f0534301321c9192c9e3a705b2bae84a2081745
Author: Brendan McGrath <brendan at redmandi.com>
Date: Tue Oct 9 10:07:36 2018 -0500
quartz/filtergraph: Iterate over all source pins in ExploreGraph().
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/quartz/filtergraph.c | 91 +++++++----------------------------------------
1 file changed, 13 insertions(+), 78 deletions(-)
diff --git a/dlls/quartz/filtergraph.c b/dlls/quartz/filtergraph.c
index 07d40db..7abffa5 100644
--- a/dlls/quartz/filtergraph.c
+++ b/dlls/quartz/filtergraph.c
@@ -974,68 +974,6 @@ static HRESULT GetFilterInfo(IMoniker* pMoniker, VARIANT* pvar)
return hr;
}
-static HRESULT GetInternalConnections(IBaseFilter* pfilter, IPin* pinputpin, IPin*** pppins, ULONG* pnb)
-{
- HRESULT hr;
- ULONG nb = 0;
-
- TRACE("(%p, %p, %p, %p)\n", pfilter, pinputpin, pppins, pnb);
- hr = IPin_QueryInternalConnections(pinputpin, NULL, &nb);
- if (hr == S_OK) {
- /* Rendered input */
- } else if (hr == S_FALSE) {
- *pppins = CoTaskMemAlloc(sizeof(IPin*)*nb);
- hr = IPin_QueryInternalConnections(pinputpin, *pppins, &nb);
- if (hr != S_OK) {
- WARN("Error (%x)\n", hr);
- }
- } else if (hr == E_NOTIMPL) {
- /* Input connected to all outputs */
- IEnumPins* penumpins;
- IPin* ppin;
- int i = 0;
- TRACE("E_NOTIMPL\n");
- hr = IBaseFilter_EnumPins(pfilter, &penumpins);
- if (FAILED(hr)) {
- WARN("filter Enumpins failed (%x)\n", hr);
- return hr;
- }
- i = 0;
- /* Count output pins */
- while(IEnumPins_Next(penumpins, 1, &ppin, &nb) == S_OK) {
- PIN_DIRECTION pindir;
- IPin_QueryDirection(ppin, &pindir);
- if (pindir == PINDIR_OUTPUT)
- i++;
- IPin_Release(ppin);
- }
- *pppins = CoTaskMemAlloc(sizeof(IPin*)*i);
- /* Retrieve output pins */
- IEnumPins_Reset(penumpins);
- i = 0;
- while(IEnumPins_Next(penumpins, 1, &ppin, &nb) == S_OK) {
- PIN_DIRECTION pindir;
- IPin_QueryDirection(ppin, &pindir);
- if (pindir == PINDIR_OUTPUT)
- (*pppins)[i++] = ppin;
- else
- IPin_Release(ppin);
- }
- IEnumPins_Release(penumpins);
- nb = i;
- if (FAILED(hr)) {
- WARN("Next failed (%x)\n", hr);
- return hr;
- }
- } else if (FAILED(hr)) {
- WARN("Cannot get internal connection (%x)\n", hr);
- return hr;
- }
-
- *pnb = nb;
- 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)
@@ -2087,12 +2025,12 @@ static HRESULT ExploreGraph(IFilterGraphImpl* pGraph, IPin* pOutputPin, fnFoundF
{
IAMFilterMiscFlags *flags;
IMediaSeeking *seeking;
+ IEnumPins *enumpins;
+ PIN_DIRECTION dir;
HRESULT hr;
IPin* pInputPin;
- IPin** ppPins;
- ULONG nb;
- ULONG i;
PIN_INFO PinInfo;
+ IPin *pin;
TRACE("%p %p\n", pGraph, pOutputPin);
PinInfo.pFilter = NULL;
@@ -2102,26 +2040,23 @@ static HRESULT ExploreGraph(IFilterGraphImpl* pGraph, IPin* pOutputPin, fnFoundF
if (SUCCEEDED(hr))
{
hr = IPin_QueryPinInfo(pInputPin, &PinInfo);
- if (SUCCEEDED(hr))
- hr = GetInternalConnections(PinInfo.pFilter, pInputPin, &ppPins, &nb);
IPin_Release(pInputPin);
}
if (SUCCEEDED(hr))
+ hr = IBaseFilter_EnumPins(PinInfo.pFilter, &enumpins);
+
+ if (SUCCEEDED(hr))
{
- if (nb)
+ while (IEnumPins_Next(enumpins, 1, &pin, NULL) == S_OK)
{
- for(i = 0; i < nb; i++)
- {
- /* Explore the graph downstream from this pin
- * FIXME: We should prevent exploring from a pin more than once. This can happens when
- * several input pins are connected to the same output (a MUX for instance). */
- ExploreGraph(pGraph, ppPins[i], FoundFilter, data);
- IPin_Release(ppPins[i]);
- }
-
- CoTaskMemFree(ppPins);
+ IPin_QueryDirection(pin, &dir);
+ if (dir == PINDIR_OUTPUT)
+ ExploreGraph(pGraph, pin, FoundFilter, data);
+ IPin_Release(pin);
}
+
+ IEnumPins_Release(enumpins);
TRACE("Doing stuff with filter %p\n", PinInfo.pFilter);
if (SUCCEEDED(IBaseFilter_QueryInterface(PinInfo.pFilter,
More information about the wine-cvs
mailing list