[QUARTZ] Some pins bug fixes

Christian Costa titan.costa at wanadoo.fr
Sat Aug 14 07:52:44 CDT 2004


Hi,

Changelog:
Don't fail a connection because an input pin does not expose the 
IMemInputPin interface (pull pins typically).
Fixed a bug that made the connection possible whereas no suitable media 
type has be found during the negociation.
Fixed the release of the media sample in PullPin_Thread_Process.
Added and fixed a lot of traces.

Christian Costa   titan.costa at wanadoo.fr

-------------- next part --------------
Index: pin.c
===================================================================
RCS file: /home/wine/wine/dlls/quartz/pin.c,v
retrieving revision 1.3
diff -u -r1.3 pin.c
--- pin.c	18 Nov 2003 20:47:48 -0000	1.3
+++ pin.c	14 Aug 2004 11:42:31 -0000
@@ -80,17 +80,24 @@
         hr = IPin_QueryInterface(pReceivePin, &IID_IMemInputPin, (LPVOID)&This->pMemInputPin);
 
         if (SUCCEEDED(hr))
+        {
             hr = IMemInputPin_GetAllocator(This->pMemInputPin, &pMemAlloc);
 
-        if (SUCCEEDED(hr))
-            hr = IMemAllocator_SetProperties(pMemAlloc, &This->allocProps, &actual);
+            if (SUCCEEDED(hr))
+                hr = IMemAllocator_SetProperties(pMemAlloc, &This->allocProps, &actual);
 
-        if (pMemAlloc)
-            IMemAllocator_Release(pMemAlloc);
+            if (pMemAlloc)
+                IMemAllocator_Release(pMemAlloc);
 
-        /* break connection if we couldn't get the allocator */
-        if (FAILED(hr))
-            IPin_Disconnect(pReceivePin);
+            /* break connection if we couldn't get the allocator */
+            if (FAILED(hr))
+                IPin_Disconnect(pReceivePin);
+	}
+	else if (hr == E_NOINTERFACE)
+        {
+            /* Pull pins do not expose this interface, so don't fail */
+	    hr = S_OK;
+        }
     }
 
     if (FAILED(hr))
@@ -267,7 +274,7 @@
     HRESULT hr;
     ICOM_THIS(IPinImpl, iface);
 
-    TRACE("(%p)\n", pmt);
+    TRACE("(%p/%p)->(%p)\n", This, iface, pmt);
 
     EnterCriticalSection(This->pCritSec);
     {
@@ -291,7 +298,7 @@
 {
     ICOM_THIS(IPinImpl, iface);
 
-    TRACE("(%p)\n", pInfo);
+    TRACE("(%p/%p)->(%p)\n", This, iface, pInfo);
 
     Copy_PinInfo(pInfo, &This->pinInfo);
 
@@ -302,7 +309,7 @@
 {
     ICOM_THIS(IPinImpl, iface);
 
-    TRACE("(%p)\n", pPinDir);
+    TRACE("(%p/%p)->(%p)\n", This, iface, pPinDir);
 
     *pPinDir = This->pinInfo.dir;
 
@@ -313,7 +320,7 @@
 {
     ICOM_THIS(IPinImpl, iface);
 
-    TRACE("(%p)\n", Id);
+    TRACE("(%p/%p)->(%p)\n", This, iface, Id);
 
     *Id = CoTaskMemAlloc((strlenW(This->pinInfo.achName) + 1) * sizeof(WCHAR));
     if (!Id)
@@ -328,16 +335,17 @@
 {
     ICOM_THIS(IPinImpl, iface);
 
-    TRACE("(%p)\n", pmt);
+    TRACE("(%p/%p)->(%p)\n", This, iface, pmt);
 
     return (This->fnQueryAccept(This->pUserData, pmt) == S_OK ? S_OK : S_FALSE);
 }
 
 HRESULT WINAPI IPinImpl_EnumMediaTypes(IPin * iface, IEnumMediaTypes ** ppEnum)
 {
+    ICOM_THIS(IPinImpl, iface);
     ENUMMEDIADETAILS emd;
 
-    TRACE("(%p)\n", ppEnum);
+    TRACE("(%p/%p)->(%p)\n", This, iface, ppEnum);
 
     /* override this method to allow enumeration of your types */
     emd.cMediaTypes = 0;
@@ -348,7 +356,9 @@
 
 HRESULT WINAPI IPinImpl_QueryInternalConnections(IPin * iface, IPin ** apPin, ULONG * cPin)
 {
-    TRACE("(%p, %p)\n", apPin, cPin);
+    ICOM_THIS(IPinImpl, iface);
+
+    TRACE("(%p/%p)->(%p, %p)\n", This, iface, apPin, cPin);
 
     return E_NOTIMPL; /* to tell caller that all input pins connected to all output pins */
 }
@@ -359,7 +369,7 @@
 {
     ICOM_THIS(InputPin, iface);
 
-    TRACE("(%s, %p)\n", qzdebugstr_guid(riid), ppv);
+    TRACE("(%p)->(%s, %p)\n", iface, qzdebugstr_guid(riid), ppv);
 
     *ppv = NULL;
 
@@ -530,7 +540,7 @@
 {
     ICOM_THIS_From_IMemInputPin(InputPin, iface);
 
-    TRACE("MemInputPin_GetAllocator()\n");
+    TRACE("(%p/%p)->(%p)\n", This, iface, ppAllocator);
 
     *ppAllocator = This->pAllocator;
     if (*ppAllocator)
@@ -543,7 +553,7 @@
 {
     ICOM_THIS_From_IMemInputPin(InputPin, iface);
 
-    TRACE("()\n");
+    TRACE("(%p/%p)->(%p, %d)\n", This, iface, pAllocator, bReadOnly);
 
     if (This->pAllocator)
         IMemAllocator_Release(This->pAllocator);
@@ -556,7 +566,9 @@
 
 HRESULT WINAPI MemInputPin_GetAllocatorRequirements(IMemInputPin * iface, ALLOCATOR_PROPERTIES * pProps)
 {
-    TRACE("(%p)\n", pProps);
+    ICOM_THIS_From_IMemInputPin(InputPin, iface);
+
+    TRACE("(%p/%p)->(%p)\n", This, iface, pProps);
 
     /* override this method if you have any specific requirements */
 
@@ -568,15 +580,17 @@
     ICOM_THIS_From_IMemInputPin(InputPin, iface);
 
     /* this trace commented out for performance reasons */
-/*  TRACE("(%p)\n", pSample);*/
+    /*TRACE("(%p/%p)->(%p)\n", This, iface, pSample);*/
 
     return This->fnSampleProc(This->pin.pUserData, pSample);
 }
 
 HRESULT WINAPI MemInputPin_ReceiveMultiple(IMemInputPin * iface, IMediaSample ** pSamples, long nSamples, long *nSamplesProcessed)
 {
+    ICOM_THIS_From_IMemInputPin(InputPin, iface);
     HRESULT hr = S_OK;
-    TRACE("(%p, %ld, %p)\n", pSamples, nSamples, nSamplesProcessed);
+
+    TRACE("(%p/%p)->(%p, %ld, %p)\n", This, iface, pSamples, nSamples, nSamplesProcessed);
 
     for (*nSamplesProcessed = 0; *nSamplesProcessed < nSamples; (*nSamplesProcessed)++)
     {
@@ -590,7 +604,9 @@
 
 HRESULT WINAPI MemInputPin_ReceiveCanBlock(IMemInputPin * iface)
 {
-    FIXME("()\n");
+    ICOM_THIS_From_IMemInputPin(InputPin, iface);
+
+    FIXME("(%p/%p)->()\n", This, iface);
 
     /* FIXME: we should check whether any output pins will block */
 
@@ -613,7 +629,9 @@
 
 HRESULT WINAPI OutputPin_QueryInterface(IPin * iface, REFIID riid, LPVOID * ppv)
 {
-    TRACE("(%s, %p)\n", qzdebugstr_guid(riid), ppv);
+    ICOM_THIS(OutputPin, iface);
+
+    TRACE("(%p/%p)->(%s, %p)\n", This, iface, qzdebugstr_guid(riid), ppv);
 
     *ppv = NULL;
 
@@ -637,7 +655,7 @@
 {
     ICOM_THIS(OutputPin, iface);
     
-    TRACE("()\n");
+    TRACE("(%p/%p)->()\n", This, iface);
     
     if (!InterlockedDecrement(&This->pin.refCount))
     {
@@ -653,7 +671,7 @@
     HRESULT hr;
     ICOM_THIS(OutputPin, iface);
 
-    TRACE("(%p, %p)\n", pReceivePin, pmt);
+    TRACE("(%p/%p)->(%p, %p)\n", This, iface, pReceivePin, pmt);
     dump_AM_MEDIA_TYPE(pmt);
 
     /* If we try to connect to ourself, we will definitely deadlock.
@@ -696,6 +714,8 @@
             /* then try receiver filter's media types */
             if (hr != S_OK && SUCCEEDED(hr = IPin_EnumMediaTypes(pReceivePin, &pEnumCandidates))) /* if we haven't already connected successfully */
             {
+                hr = VFW_E_NO_ACCEPTABLE_TYPES; /* Assume the worst, but set to S_OK if connected successfully */
+
                 while (S_OK == IEnumMediaTypes_Next(pEnumCandidates, 1, &pmtCandidate, NULL))
                 {
                     if (( !pmt || CompareMediaTypes(pmt, pmtCandidate, TRUE) ) && 
@@ -763,7 +783,7 @@
 
 HRESULT WINAPI OutputPin_BeginFlush(IPin * iface)
 {
-    TRACE("()\n");
+    TRACE("(%p)->()\n", iface);
 
     /* not supposed to do anything in an output pin */
 
@@ -772,7 +792,7 @@
 
 HRESULT WINAPI OutputPin_EndFlush(IPin * iface)
 {
-    TRACE("()\n");
+    TRACE("(%p)->()\n", iface);
 
     /* not supposed to do anything in an output pin */
 
@@ -781,7 +801,7 @@
 
 HRESULT WINAPI OutputPin_NewSegment(IPin * iface, REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
 {
-    TRACE("(%lx%08lx, %lx%08lx, %e)\n", (ULONG)(tStart >> 32), (ULONG)tStart, (ULONG)(tStop >> 32), (ULONG)tStop, dRate);
+    TRACE("(%p)->(%lx%08lx, %lx%08lx, %e)\n", iface, (ULONG)(tStart >> 32), (ULONG)tStart, (ULONG)(tStop >> 32), (ULONG)tStop, dRate);
 
     /* not supposed to do anything in an output pin */
 
@@ -899,7 +919,7 @@
 {
     HRESULT hr;
 
-    TRACE("()\n");
+    TRACE("(%p)->()\n", This);
 
     EnterCriticalSection(This->pin.pCritSec);
     {
@@ -934,7 +954,7 @@
 {
     HRESULT hr;
 
-    TRACE("()\n");
+    TRACE("(%p)->()\n", This);
 
     EnterCriticalSection(This->pin.pCritSec);
     {
@@ -1026,7 +1046,7 @@
     HRESULT hr = S_OK;
     ICOM_THIS(PullPin, iface);
 
-    TRACE("(%p, %p)\n", pReceivePin, pmt);
+    TRACE("(%p/%p)->(%p, %p)\n", This, iface, pReceivePin, pmt);
     dump_AM_MEDIA_TYPE(pmt);
 
     EnterCriticalSection(This->pin.pCritSec);
@@ -1082,7 +1102,9 @@
 
 HRESULT WINAPI PullPin_QueryInterface(IPin * iface, REFIID riid, LPVOID * ppv)
 {
-    TRACE("(%s, %p)\n", qzdebugstr_guid(riid), ppv);
+    ICOM_THIS(PullPin, iface);
+
+    TRACE("(%p/%p)->(%s, %p)\n", This, iface, qzdebugstr_guid(riid), ppv);
 
     *ppv = NULL;
 
@@ -1106,7 +1128,7 @@
 {
     ICOM_THIS(PullPin, iface);
 
-    TRACE("()\n");
+    TRACE("(%p/%p)->()\n", This, iface);
 
     if (!InterlockedDecrement(&This->pin.refCount))
     {
@@ -1173,7 +1195,7 @@
             ERR("Processing error: %lx\n", hr);
         
         if (pSample)
-            IMemAllocator_ReleaseBuffer(This->pAlloc, pSample);
+            IMediaSample_Release(pSample);
     }
 }
 
@@ -1181,7 +1203,7 @@
 {
     ICOM_THIS(PullPin, iface);
 
-    TRACE("()\n");
+    TRACE("(%p/%p)->()\n", This, (LPVOID)iface);
 
     EnterCriticalSection(This->pin.pCritSec);
     {
@@ -1203,7 +1225,7 @@
 {
     HRESULT hr = S_OK;
 
-    TRACE("()\n");
+    TRACE("(%p)->()\n", This);
 
     assert(!This->hThread);
 
@@ -1233,6 +1255,7 @@
 HRESULT PullPin_StartProcessing(PullPin * This)
 {
     /* if we are connected */
+    TRACE("(%p)->()\n", This);
     if(This->pAlloc)
     {
         assert(This->hThread);
@@ -1281,7 +1304,7 @@
 
 HRESULT PullPin_Seek(PullPin * This, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop)
 {
-    FIXME("(%lx%08lx, %lx%08lx)\n", (LONG)(rtStart >> 32), (LONG)rtStart, (LONG)(rtStop >> 32), (LONG)rtStop);
+    FIXME("(%p)->(%lx%08lx, %lx%08lx)\n", This, (LONG)(rtStart >> 32), (LONG)rtStart, (LONG)(rtStop >> 32), (LONG)rtStop);
 
     PullPin_BeginFlush((IPin *)This);
     /* FIXME: need critical section? */
@@ -1294,25 +1317,25 @@
 
 HRESULT WINAPI PullPin_EndOfStream(IPin * iface)
 {
-    FIXME("()\n");
+    FIXME("(%p)->()\n", iface);
     return E_NOTIMPL;
 }
 
 HRESULT WINAPI PullPin_BeginFlush(IPin * iface)
 {
-    FIXME("()\n");
+    FIXME("(%p)->()\n", iface);
     return E_NOTIMPL;
 }
 
 HRESULT WINAPI PullPin_EndFlush(IPin * iface)
 {
-    FIXME("()\n");
+    FIXME("(%p)->()\n", iface);
     return E_NOTIMPL;
 }
 
 HRESULT WINAPI PullPin_NewSegment(IPin * iface, REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
 {
-    FIXME("()\n");
+    FIXME("(%p)->(%s, %s, %g)\n", iface, wine_dbgstr_longlong(tStart), wine_dbgstr_longlong(tStop), dRate);
     return E_NOTIMPL;
 }
 


More information about the wine-patches mailing list