[PATCH 6/6] quartz/filtergraph: Check for AM_FILTER_MISC_FLAGS_IS_RENDERER or IMediaSeeking to count renderers.

Zebediah Figura z.figura12 at gmail.com
Tue Sep 25 23:30:23 CDT 2018


Instead of using IPin_QueryInternalConnections().

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
 dlls/quartz/filtergraph.c       | 49 +++++++++++++++++++++++++++++++++++------
 dlls/quartz/tests/filtergraph.c |  5 -----
 2 files changed, 42 insertions(+), 12 deletions(-)

diff --git a/dlls/quartz/filtergraph.c b/dlls/quartz/filtergraph.c
index 1857f92..baa5cb1 100644
--- a/dlls/quartz/filtergraph.c
+++ b/dlls/quartz/filtergraph.c
@@ -2118,8 +2118,34 @@ static HRESULT WINAPI MediaControl_Invoke(IMediaControl *iface, DISPID dispIdMem
 
 typedef HRESULT(WINAPI *fnFoundFilter)(IBaseFilter *, DWORD_PTR data);
 
+static BOOL has_output_pins(IBaseFilter *filter)
+{
+    IEnumPins *enumpins;
+    PIN_DIRECTION dir;
+    IPin *pin;
+
+    if (FAILED(IBaseFilter_EnumPins(filter, &enumpins)))
+        return FALSE;
+
+    while (IEnumPins_Next(enumpins, 1, &pin, NULL) == S_OK)
+    {
+        IPin_QueryDirection(pin, &dir);
+        IPin_Release(pin);
+        if (dir == PINDIR_OUTPUT)
+        {
+            IEnumPins_Release(enumpins);
+            return TRUE;
+        }
+    }
+
+    IEnumPins_Release(enumpins);
+    return FALSE;
+}
+
 static HRESULT ExploreGraph(IFilterGraphImpl* pGraph, IPin* pOutputPin, fnFoundFilter FoundFilter, DWORD_PTR data)
 {
+    IAMFilterMiscFlags *flags;
+    IMediaSeeking *seeking;
     HRESULT hr;
     IPin* pInputPin;
     IPin** ppPins;
@@ -2142,13 +2168,7 @@ static HRESULT ExploreGraph(IFilterGraphImpl* pGraph, IPin* pOutputPin, fnFoundF
 
     if (SUCCEEDED(hr))
     {
-        if (nb == 0)
-        {
-            TRACE("Reached a renderer\n");
-            /* Count renderers for end of stream notification */
-            pGraph->nRenderers++;
-        }
-        else
+        if (nb)
         {
             for(i = 0; i < nb; i++)
             {
@@ -2163,6 +2183,21 @@ static HRESULT ExploreGraph(IFilterGraphImpl* pGraph, IPin* pOutputPin, fnFoundF
         }
         TRACE("Doing stuff with filter %p\n", PinInfo.pFilter);
 
+        if (SUCCEEDED(IBaseFilter_QueryInterface(PinInfo.pFilter,
+                &IID_IAMFilterMiscFlags, (void **)&flags)))
+        {
+            if (IAMFilterMiscFlags_GetMiscFlags(flags) & AM_FILTER_MISC_FLAGS_IS_RENDERER)
+                pGraph->nRenderers++;
+            IAMFilterMiscFlags_Release(flags);
+        }
+        else if (SUCCEEDED(IBaseFilter_QueryInterface(PinInfo.pFilter,
+                &IID_IMediaSeeking, (void **)&seeking)))
+        {
+            if (!has_output_pins(PinInfo.pFilter))
+                pGraph->nRenderers++;
+            IMediaSeeking_Release(seeking);
+        }
+
         FoundFilter(PinInfo.pFilter, data);
     }
 
diff --git a/dlls/quartz/tests/filtergraph.c b/dlls/quartz/tests/filtergraph.c
index 1345e41..74a3b68 100644
--- a/dlls/quartz/tests/filtergraph.c
+++ b/dlls/quartz/tests/filtergraph.c
@@ -3080,10 +3080,8 @@ static void test_ec_complete(void)
     ok(hr == S_OK, "Got hr %#x.\n", hr);
 
     hr = IMediaEvent_GetEvent(eventsrc, &code, &param1, &param2, 0);
-todo_wine {
     ok(hr == S_OK, "Got hr %#x.\n", hr);
     ok(code == EC_COMPLETE, "Got code %#x.\n", code);
-}
     ok(param1 == S_OK, "Got param1 %#lx.\n", param1);
     ok(!param2, "Got param2 %#lx.\n", param2);
     hr = IMediaEvent_FreeEventParams(eventsrc, code, param1, param2);
@@ -3096,7 +3094,6 @@ todo_wine {
     ok(hr == S_OK, "Got hr %#x.\n", hr);
 
     hr = IMediaEvent_GetEvent(eventsrc, &code, &param1, &param2, 50);
-todo_wine
     ok(hr == E_ABORT, "Got hr %#x.\n", hr);
 
     IMediaControl_Stop(control);
@@ -3156,7 +3153,6 @@ todo_wine
     IFilterGraph2_ConnectDirect(graph, &source_pins[0].IPin_iface, &filter1_pin.IPin_iface, NULL);
 
     hr = check_ec_complete(graph, &filter1.IBaseFilter_iface);
-todo_wine
     ok(hr == E_ABORT, "Got hr %#x.\n", hr);
 
     IFilterGraph2_RemoveFilter(graph, &filter1.IBaseFilter_iface);
@@ -3185,7 +3181,6 @@ todo_wine
     IFilterGraph2_ConnectDirect(graph, &source_pins[0].IPin_iface, &filter1_pin.IPin_iface, NULL);
 
     hr = check_ec_complete(graph, &filter1.IBaseFilter_iface);
-todo_wine
     ok(hr == E_ABORT, "Got hr %#x.\n", hr);
 
     IMediaControl_Release(control);
-- 
2.7.4




More information about the wine-devel mailing list