[QUARTZ] Allocator commit/decommit fix

Christian Costa titan.costa at wanadoo.fr
Sat Aug 20 18:22:58 CDT 2005


Hi,

This patch fixes the preview in DVD Shrink.

Changelog:
Return S_OK when committing/decomitting an already committed/decommitted 
allocator.
Add corresponding test case.
Improve traces.

Christian Costa   titan.costa at wanadoo.fr

-------------- next part --------------
Index: dlls/quartz/memallocator.c
===================================================================
RCS file: /home/wine/wine/dlls/quartz/memallocator.c,v
retrieving revision 1.11
diff -u -r1.11 memallocator.c
--- dlls/quartz/memallocator.c	12 Jul 2005 19:21:36 -0000	1.11
+++ dlls/quartz/memallocator.c	20 Aug 2005 22:06:05 -0000
@@ -116,7 +116,7 @@
 static HRESULT WINAPI BaseMemAllocator_QueryInterface(IMemAllocator * iface, REFIID riid, LPVOID * ppv)
 {
     BaseMemAllocator *This = (BaseMemAllocator *)iface;
-    TRACE("(%s, %p)\n", qzdebugstr_guid(riid), ppv);
+    TRACE("(%p)->(%s, %p)\n", This, qzdebugstr_guid(riid), ppv);
 
     *ppv = NULL;
 
@@ -170,7 +170,7 @@
     BaseMemAllocator *This = (BaseMemAllocator *)iface;
     HRESULT hr;
 
-    TRACE("(%p, %p)\n", pRequest, pActual);
+    TRACE("(%p)->(%p, %p)\n", This, pRequest, pActual);
 
     EnterCriticalSection(&This->csState);
     {
@@ -207,7 +207,7 @@
     BaseMemAllocator *This = (BaseMemAllocator *)iface;
     HRESULT hr = S_OK;
 
-    TRACE("(%p)\n", pProps);
+    TRACE("(%p)->(%p)\n", This, pProps);
 
     EnterCriticalSection(&This->csState);
     {
@@ -232,14 +232,14 @@
     BaseMemAllocator *This = (BaseMemAllocator *)iface;
     HRESULT hr;
 
-    TRACE("()\n");
+    TRACE("(%p)->()\n", This);
 
     EnterCriticalSection(&This->csState);
     {
         if (!This->pProps)
             hr = VFW_E_SIZENOTSET;
         else if (This->bCommitted)
-            hr = VFW_E_ALREADY_COMMITTED;
+            hr = S_OK;
         else if (This->bDecommitQueued)
         {
             This->bDecommitQueued = FALSE;
@@ -272,12 +272,12 @@
     BaseMemAllocator *This = (BaseMemAllocator *)iface;
     HRESULT hr;
 
-    TRACE("()\n");
+    TRACE("(%p)->()\n", This);
 
     EnterCriticalSection(&This->csState);
     {
         if (!This->bCommitted)
-            hr = VFW_E_NOT_COMMITTED;
+            hr = S_OK;
         else
         {
             if (!list_empty(&This->used_list))
@@ -315,7 +315,7 @@
     /* NOTE: The pStartTime and pEndTime parameters are not applied to the sample. 
      * The allocator might use these values to determine which buffer it retrieves */
     
-    TRACE("(%p, %p, %p, %lx)\n", pSample, pStartTime, pEndTime, dwFlags);
+    TRACE("(%p)->(%p, %p, %p, %lx)\n", This, pSample, pStartTime, pEndTime, dwFlags);
 
     *pSample = NULL;
 
@@ -360,7 +360,7 @@
     StdMediaSample2 * pStdSample = (StdMediaSample2 *)pSample;
     HRESULT hr = S_OK;
     
-    TRACE("(%p)\n", pSample);
+    TRACE("(%p)->(%p)\n", This, pSample);
 
     /* FIXME: make sure that sample is currently on the used list */
 
Index: dlls/quartz/tests/Makefile.in
===================================================================
RCS file: /home/wine/wine/dlls/quartz/tests/Makefile.in,v
retrieving revision 1.2
diff -u -r1.2 Makefile.in
--- dlls/quartz/tests/Makefile.in	19 Aug 2004 19:31:20 -0000	1.2
+++ dlls/quartz/tests/Makefile.in	20 Aug 2005 22:06:06 -0000
@@ -7,6 +7,7 @@
 EXTRALIBS = -lstrmiids
 
 CTESTS = \
+	memallocator.c \
 	filtergraph.c
 
 @MAKE_TEST_RULES@
--- /dev/null	1970-01-01 01:00:00.000000000 +0100
+++ dlls/quartz/tests/memallocator.c	2005-08-21 00:12:02.000000000 +0100
@@ -0,0 +1,70 @@
+/*
+ * Unit tests for Direct Show functions
+ *
+ * Copyright (C) 2005 Christian Costa
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <assert.h>
+
+#define COBJMACROS
+
+#include "wine/test.h"
+#include "uuids.h"
+#include "dshow.h"
+#include "control.h"
+
+static void CommitDecommitTest()
+{
+    IMemAllocator* pMemAllocator;
+    HRESULT hr;
+
+    hr = CoCreateInstance(&CLSID_MemoryAllocator, NULL, CLSCTX_INPROC_SERVER, &IID_IMemAllocator, (LPVOID*)&pMemAllocator);
+    ok(hr==S_OK, "Unable to create memory allocator %lx\n", hr);
+
+    if (hr == S_OK)
+    {
+	ALLOCATOR_PROPERTIES RequestedProps;
+	ALLOCATOR_PROPERTIES ActualProps;
+
+	RequestedProps.cBuffers = 1;
+	RequestedProps.cbBuffer = 65536;
+	RequestedProps.cbAlign = 1;
+	RequestedProps.cbPrefix = 0;
+
+	hr = IMemAllocator_SetProperties(pMemAllocator, &RequestedProps, &ActualProps);
+	ok(hr==S_OK, "SetProperties returned: %lx\n", hr);
+
+	hr = IMemAllocator_Commit(pMemAllocator);
+	ok(hr==S_OK, "Commit returned: %lx\n", hr);
+	hr = IMemAllocator_Commit(pMemAllocator);
+	ok(hr==S_OK, "Commit returned: %lx\n", hr);
+
+	hr = IMemAllocator_Decommit(pMemAllocator);
+	ok(hr==S_OK, "Decommit returned: %lx\n", hr);
+	hr = IMemAllocator_Decommit(pMemAllocator);
+	ok(hr==S_OK, "Cecommit returned: %lx\n", hr);
+
+	IMemAllocator_Release(pMemAllocator);
+    }
+}
+
+START_TEST(memallocator)
+{
+    CoInitialize(NULL);
+
+    CommitDecommitTest();
+}


More information about the wine-patches mailing list