Maarten Lankhorst : quartz: Try to render any existing renderers before creating a new one.

Alexandre Julliard julliard at winehq.org
Sat Jun 21 05:39:09 CDT 2008


Module: wine
Branch: master
Commit: aaee8a1b0e19960b1d75cc3332f6197685cb6905
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=aaee8a1b0e19960b1d75cc3332f6197685cb6905

Author: Maarten Lankhorst <m.b.lankhorst at gmail.com>
Date:   Tue Jun 10 18:19:27 2008 +0200

quartz: Try to render any existing renderers before creating a new one.

---

 dlls/quartz/filtergraph.c |   73 ++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 69 insertions(+), 4 deletions(-)

diff --git a/dlls/quartz/filtergraph.c b/dlls/quartz/filtergraph.c
index bf929d2..7031c72 100644
--- a/dlls/quartz/filtergraph.c
+++ b/dlls/quartz/filtergraph.c
@@ -928,6 +928,7 @@ static HRESULT WINAPI FilterGraph2_Render(IFilterGraph2 *iface,
     GUID tab[2];
     ULONG nb;
     IMoniker* pMoniker;
+    INT x;
 
     TRACE("(%p/%p)->(%p)\n", This, iface, ppinOut);
 
@@ -943,12 +944,76 @@ static HRESULT WINAPI FilterGraph2_Render(IFilterGraph2 *iface,
         IBaseFilter_Release(PinInfo.pFilter);
     }
 
+    /* Try to find out if there is a renderer for the specified subtype already, and use that
+     */
+    EnterCriticalSection(&This->cs);
+    for (x = 0; x < This->nFilters; ++x)
+    {
+        BOOL renderer = TRUE;
+        IEnumPins *enumpins = NULL;
+        IPin *pin = NULL;
+
+        hr = IBaseFilter_EnumPins(This->ppFiltersInGraph[x], &enumpins);
+
+        if (FAILED(hr) || !enumpins)
+            continue;
+
+        IEnumPins_Reset(enumpins);
+        while (IEnumPins_Next(enumpins, 1, &pin, NULL) == S_OK)
+        {
+            PIN_DIRECTION dir = PINDIR_OUTPUT;
+
+            IPin_QueryDirection(pin, &dir);
+            IPin_Release(pin);
+            pin = NULL;
+            if (dir != PINDIR_INPUT)
+            {
+                renderer = FALSE;
+                break;
+            }
+        }
+
+        IEnumPins_Reset(enumpins);
+        if (renderer == TRUE)
+        {
+            while (IEnumPins_Next(enumpins, 1, &pin, NULL) == S_OK)
+            {
+                IPin *to = NULL;
+
+                IPin_ConnectedTo(pin, &to);
+
+                if (to == NULL)
+                {
+                    hr = IFilterGraph2_Connect(iface, ppinOut, pin);
+                    if (SUCCEEDED(hr))
+                    {
+                        IPin_Release(pin);
+                        IEnumPins_Release(enumpins);
+                        LeaveCriticalSection(&This->cs);
+                        ERR("Connected succesfully\n");
+                        return hr;
+                    }
+                }
+                else
+                    IPin_Release(to);
+
+                IPin_Release(pin);
+            }
+        }
+
+        IEnumPins_Release(enumpins);
+    }
+
+    LeaveCriticalSection(&This->cs);
+
     hr = IPin_EnumMediaTypes(ppinOut, &penummt);
     if (FAILED(hr)) {
         ERR("EnumMediaTypes (%x)\n", hr);
         return hr;
     }
 
+    IEnumMediaTypes_Reset(penummt);
+
     while(1)
     {
         hr = IEnumMediaTypes_Next(penummt, 1, &mt, &nbmt);
@@ -1016,7 +1081,7 @@ static HRESULT WINAPI FilterGraph2_Render(IFilterGraph2 *iface,
                goto error;
             }
 
-	    /* Connect the pin to render to the renderer */
+            /* Connect the pin to render to the renderer */
             hr = IFilterGraph2_Connect(iface, ppinOut, ppinfilter);
             if (FAILED(hr)) {
                 TRACE("Unable to connect to renderer (%x)\n", hr);
@@ -1033,10 +1098,10 @@ error:
                 IFilterGraph2_RemoveFilter(iface, pfilter);
                 IBaseFilter_Release(pfilter);
             }
-	}
-       
+        }
+
         DeleteMediaType(mt);
-        break;	
+        break;
     }
 
     IEnumMediaTypes_Release(penummt);




More information about the wine-cvs mailing list