[QUARTZ] Several fixes (take 2)

Christian Costa titan.costa at wanadoo.fr
Sun Jun 5 09:50:59 CDT 2005


Hi,

This version fixes the wrong trace spotted by Rolf Kalbermatter.

Changelog:
Fixed clock release in transform template.
AddRef pUnk in CopyMediaType.
Added CreateMediaType helper function and use it.
Replaced some DeleteMediaType calls to FreeMediaType to be in line with 
recent changes.
Fixed IEnumMediaTypesImpl_Next.
Clear media type when initializing pins.
Added some AddRef/Release traces.

Christian Costa   titan.costa at wanadoo.fr
-------------- next part --------------
Index: dlls/quartz/acmwrapper.c
===================================================================
RCS file: /home/wine/wine/dlls/quartz/acmwrapper.c,v
retrieving revision 1.4
diff -u -r1.4 acmwrapper.c
--- dlls/quartz/acmwrapper.c	22 Feb 2005 14:50:16 -0000	1.4
+++ dlls/quartz/acmwrapper.c	4 Jun 2005 23:50:28 -0000
@@ -211,7 +211,7 @@
         }
 	else
 	    FIXME("acmStreamOpen returned %d\n", res);
-	DeleteMediaType(outpmt);
+        FreeMediaType(outpmt);
         TRACE("Unable to find a suitable ACM decompressor\n");
     }
 
Index: dlls/quartz/enummedia.c
===================================================================
RCS file: /home/wine/wine/dlls/quartz/enummedia.c,v
retrieving revision 1.7
diff -u -r1.7 enummedia.c
--- dlls/quartz/enummedia.c	7 May 2005 12:12:29 -0000	1.7
+++ dlls/quartz/enummedia.c	4 Jun 2005 23:50:38 -0000
@@ -31,6 +31,8 @@
     if (!(pDest->pbFormat = CoTaskMemAlloc(pSrc->cbFormat)))
         return E_OUTOFMEMORY;
     memcpy(pDest->pbFormat, pSrc->pbFormat, pSrc->cbFormat);
+    if (pDest->pUnk)
+        IUnknown_AddRef(pDest->pUnk);
     return S_OK;
 }
 
@@ -48,13 +50,29 @@
     }
 }
 
+AM_MEDIA_TYPE * CreateMediaType(AM_MEDIA_TYPE const * pSrc)
+{
+    AM_MEDIA_TYPE * pDest;
+    
+    pDest = CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
+    if (!pDest)
+        return NULL;
+
+    if (FAILED(CopyMediaType(pDest, pSrc)))
+    {
+        CoTaskMemFree(pDest);
+	return NULL;
+    }
+
+    return pDest;
+}
+
 void DeleteMediaType(AM_MEDIA_TYPE * pMediaType)
 {
     FreeMediaType(pMediaType);
     CoTaskMemFree(pMediaType);
 }
 
-
 BOOL CompareMediaTypes(const AM_MEDIA_TYPE * pmt1, const AM_MEDIA_TYPE * pmt2, BOOL bWildcards)
 {
     TRACE("pmt1: ");
@@ -98,7 +116,8 @@
     pEnumMediaTypes->enumMediaDetails.cMediaTypes = pDetails->cMediaTypes;
     pEnumMediaTypes->enumMediaDetails.pMediaTypes = CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE) * pDetails->cMediaTypes);
     for (i = 0; i < pDetails->cMediaTypes; i++)
-        if (FAILED(CopyMediaType(&pEnumMediaTypes->enumMediaDetails.pMediaTypes[i], &pDetails->pMediaTypes[i]))) {
+        if (FAILED(CopyMediaType(&pEnumMediaTypes->enumMediaDetails.pMediaTypes[i], &pDetails->pMediaTypes[i])))
+        {
            while (i--)
               CoTaskMemFree(pEnumMediaTypes->enumMediaDetails.pMediaTypes[i].pbFormat);
            CoTaskMemFree(pEnumMediaTypes->enumMediaDetails.pMediaTypes);
@@ -135,7 +154,7 @@
     IEnumMediaTypesImpl *This = (IEnumMediaTypesImpl *)iface;
     ULONG refCount = InterlockedIncrement(&This->refCount);
 
-    TRACE("()\n");
+    TRACE("(%p)->() AddRef from %ld\n", iface, refCount - 1);
 
     return refCount;
 }
@@ -145,7 +164,7 @@
     IEnumMediaTypesImpl *This = (IEnumMediaTypesImpl *)iface;
     ULONG refCount = InterlockedDecrement(&This->refCount);
 
-    TRACE("()\n");
+    TRACE("(%p)->() Release from %ld\n", iface, refCount + 1);
 
     if (!refCount)
     {
@@ -172,13 +191,12 @@
     if (cFetched > 0)
     {
         ULONG i;
-        *ppMediaTypes = CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE) * cFetched);
         for (i = 0; i < cFetched; i++)
-            if (FAILED(CopyMediaType(&(*ppMediaTypes)[i], &This->enumMediaDetails.pMediaTypes[This->uIndex + i]))) {
+            if (!(ppMediaTypes[i] = CreateMediaType(&This->enumMediaDetails.pMediaTypes[This->uIndex + i])))
+            {
                 while (i--)
-                    CoTaskMemFree((*ppMediaTypes)[i].pbFormat);
-                CoTaskMemFree(*ppMediaTypes);
-                *ppMediaTypes = NULL;
+                    DeleteMediaType(ppMediaTypes[i]);
+                *pcFetched = 0;
                 return E_OUTOFMEMORY;
             }
     }
Index: dlls/quartz/filesource.c
===================================================================
RCS file: /home/wine/wine/dlls/quartz/filesource.c,v
retrieving revision 1.13
diff -u -r1.13 filesource.c
--- dlls/quartz/filesource.c	17 Mar 2005 19:00:09 -0000	1.13
+++ dlls/quartz/filesource.c	4 Jun 2005 23:50:41 -0000
@@ -821,7 +821,7 @@
     {
         IPin_Release(This->pin.pConnectedTo);
         This->pin.pConnectedTo = NULL;
-        DeleteMediaType(&This->pin.mtCurrent);
+        FreeMediaType(&This->pin.mtCurrent);
     }
 
     TRACE(" -- %lx\n", hr);
Index: dlls/quartz/parser.c
===================================================================
RCS file: /home/wine/wine/dlls/quartz/parser.c,v
retrieving revision 1.14
diff -u -r1.14 parser.c
--- dlls/quartz/parser.c	28 Mar 2005 14:17:51 -0000	1.14
+++ dlls/quartz/parser.c	4 Jun 2005 23:50:44 -0000
@@ -596,13 +596,13 @@
     Parser_OutputPin *This = (Parser_OutputPin *)iface;
     ULONG refCount = InterlockedDecrement(&This->pin.pin.refCount);
     
-    TRACE("()\n");
+    TRACE("(%p)->() Release from %ld\n", iface, refCount + 1);
     
     if (!refCount)
     {
-        DeleteMediaType(This->pmt);
+        FreeMediaType(This->pmt);
         CoTaskMemFree(This->pmt);
-        DeleteMediaType(&This->pin.pin.mtCurrent);
+        FreeMediaType(&This->pin.pin.mtCurrent);
         CoTaskMemFree(This);
         return 0;
     }
Index: dlls/quartz/pin.c
===================================================================
RCS file: /home/wine/wine/dlls/quartz/pin.c,v
retrieving revision 1.14
diff -u -r1.14 pin.c
--- dlls/quartz/pin.c	6 May 2005 14:34:44 -0000	1.14
+++ dlls/quartz/pin.c	4 Jun 2005 23:50:47 -0000
@@ -107,7 +107,7 @@
     {
         IPin_Release(This->pin.pConnectedTo);
         This->pin.pConnectedTo = NULL;
-        DeleteMediaType(&This->pin.mtCurrent);
+        FreeMediaType(&This->pin.mtCurrent);
     }
 
     TRACE(" -- %lx\n", hr);
@@ -154,6 +154,7 @@
     pPinImpl->pin.pUserData = pUserData;
     pPinImpl->pin.pCritSec = pCritSec;
     Copy_PinInfo(&pPinImpl->pin.pinInfo, pPinInfo);
+    ZeroMemory(&pPinImpl->pin.mtCurrent, sizeof(AM_MEDIA_TYPE));
 
     /* Input pin attributes */
     pPinImpl->fnSampleProc = pSampleProc;
@@ -177,6 +178,7 @@
     pPinImpl->pin.pUserData = pUserData;
     pPinImpl->pin.pCritSec = pCritSec;
     Copy_PinInfo(&pPinImpl->pin.pinInfo, pPinInfo);
+    ZeroMemory(&pPinImpl->pin.mtCurrent, sizeof(AM_MEDIA_TYPE));
 
     /* Output pin attributes */
     pPinImpl->pMemInputPin = NULL;
@@ -410,7 +412,7 @@
     
     if (!refCount)
     {
-        DeleteMediaType(&This->pin.mtCurrent);
+        FreeMediaType(&This->pin.mtCurrent);
         if (This->pAllocator)
             IMemAllocator_Release(This->pAllocator);
         CoTaskMemFree(This);
@@ -665,11 +667,11 @@
     OutputPin *This = (OutputPin *)iface;
     ULONG refCount = InterlockedDecrement(&This->pin.refCount);
     
-    TRACE("(%p/%p)->()\n", This, iface);
+    TRACE("(%p)->() Release from %ld\n", iface, refCount + 1);
     
     if (!refCount)
     {
-        DeleteMediaType(&This->pin.mtCurrent);
+        FreeMediaType(&This->pin.mtCurrent);
         CoTaskMemFree(This);
         return 0;
     }
@@ -1015,6 +1017,7 @@
     pPinImpl->pin.pUserData = pUserData;
     pPinImpl->pin.pCritSec = pCritSec;
     Copy_PinInfo(&pPinImpl->pin.pinInfo, pPinInfo);
+    ZeroMemory(&pPinImpl->pin.mtCurrent, sizeof(AM_MEDIA_TYPE));
 
     /* Input pin attributes */
     pPinImpl->fnSampleProc = pSampleProc;
Index: dlls/quartz/transform.c
===================================================================
RCS file: /home/wine/wine/dlls/quartz/transform.c,v
retrieving revision 1.4
diff -u -r1.4 transform.c
--- dlls/quartz/transform.c	28 Mar 2005 14:17:51 -0000	1.4
+++ dlls/quartz/transform.c	4 Jun 2005 23:50:49 -0000
@@ -275,7 +275,9 @@
         ULONG i;
 
         DeleteCriticalSection(&This->csFilter);
-        IReferenceClock_Release(This->pClock);
+
+        if (This->pClock)
+            IReferenceClock_Release(This->pClock);
 
         for (i = 0; i < 2; i++)
             IPin_Release(This->ppPins[i]);


More information about the wine-patches mailing list