[1/3] quartz: Better handle error conditions when connections fail

Chris Robinson chris.kcat at gmail.com
Mon Feb 19 19:26:10 CST 2007


-------------- next part --------------
From e675e14b75bc52936812e4713349510504ebda51 Mon Sep 17 00:00:00 2001
From: Chris Robinson <chris.kcat at gmail.com>
Date: Sun, 18 Feb 2007 09:10:03 -0800
Subject: quartz: Better handle error conditions when connections fail

---
 dlls/quartz/filtergraph.c |   43 +++++++++++++++++++++++++++----------------
 1 files changed, 27 insertions(+), 16 deletions(-)

diff --git a/dlls/quartz/filtergraph.c b/dlls/quartz/filtergraph.c
index 8a0225e..ff341a7 100644
--- a/dlls/quartz/filtergraph.c
+++ b/dlls/quartz/filtergraph.c
@@ -774,6 +774,8 @@ static HRESULT WINAPI GraphBuilder_Connect(IGraphBuilder *iface,
         }
 
         hr = IEnumPins_Next(penumpins, 1, &ppinfilter, &pin);
+        IEnumPins_Release(penumpins);
+
         if (FAILED(hr)) {
             ERR("Next (%x)\n", hr);
             goto error;
@@ -782,7 +784,6 @@ static HRESULT WINAPI GraphBuilder_Connect(IGraphBuilder *iface,
             ERR("No Pin\n");
             goto error;
         }
-        IEnumPins_Release(penumpins);
 
         hr = IPin_Connect(ppinOut, ppinfilter, NULL);
         if (FAILED(hr)) {
@@ -796,6 +797,10 @@ static HRESULT WINAPI GraphBuilder_Connect(IGraphBuilder *iface,
 
         if (SUCCEEDED(hr)) {
             int i;
+            if (nb == 0) {
+                IPin_Disconnect(ppinOut);
+                goto error;
+            }
             TRACE("pins to consider: %d\n", nb);
             for(i = 0; i < nb; i++) {
                 TRACE("Processing pin %d\n", i);
@@ -1010,7 +1015,7 @@ static HRESULT WINAPI GraphBuilder_RenderFile(IGraphBuilder *iface,
         return hr;
     }
 
-    hr = E_FAIL;
+    hr = VFW_E_CANNOT_RENDER;
     while(IEnumMoniker_Next(pEnumMoniker, 1, &pMoniker, &nb) == S_OK)
     {
         VARIANT var;
@@ -1047,29 +1052,35 @@ static HRESULT WINAPI GraphBuilder_RenderFile(IGraphBuilder *iface,
 
         if (SUCCEEDED(hr))
             hr = IPin_Connect(ppinreader, ppinsplitter, NULL);
-        if (SUCCEEDED(hr)) {
-            /* Make sure there's some output pins in the filter */
+
+        /* Make sure there's some output pins in the filter */
+        if (SUCCEEDED(hr))
             hr = GetInternalConnections(psplitter, ppinsplitter, &ppins, &nb);
-            if (SUCCEEDED(hr)) {
-                if(nb > 0) {
-                    TRACE("Successfully connected to filter\n");
-                    break;
-                }
-                CoTaskMemFree(ppins);
-                ppins = NULL;
+        if (SUCCEEDED(hr)) {
+            if(nb == 0) {
+                IPin_Disconnect(ppinreader);
+                TRACE("No output pins found in filter\n");
+                hr = VFW_E_CANNOT_RENDER;
             }
-
-            TRACE("No output pins found in filter\n");
-            hr = VFW_E_CANNOT_RENDER;
         }
 
         IPin_Release(ppinsplitter);
         ppinsplitter = NULL;
+
+        if (SUCCEEDED(hr)) {
+            TRACE("Successfully connected to filter\n");
+            break;
+        }
+
+        TRACE("Cannot connect to filter (%x), trying next one\n", hr);
+
+        if (ppins) {
+            CoTaskMemFree(ppins);
+            ppins = NULL;
+        }
         IGraphBuilder_RemoveFilter(iface, psplitter);
         IBaseFilter_Release(psplitter);
         ppinsplitter = NULL;
-
-        TRACE("Cannot connect to filter (%x), trying next one\n", hr);
     }
 
     /* Render all output pin of the splitter by calling IGraphBuilder_Render on each of them */
-- 
1.4.4.4



More information about the wine-patches mailing list