Return S_OK when committing/decomitting an already
committed/decommitted allocator.
Add corresponding test case.
Improve traces.
diff --git a/dlls/quartz/memallocator.c b/dlls/quartz/memallocator.c
index 1eb53a8..3bdb273 100644
--- a/dlls/quartz/memallocator.c
+++ b/dlls/quartz/memallocator.c
@@ -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 */
diff --git a/dlls/quartz/tests/.cvsignore b/dlls/quartz/tests/.cvsignore
index 5c103bd..43322bd 100644
--- a/dlls/quartz/tests/.cvsignore
+++ b/dlls/quartz/tests/.cvsignore
@@ -1,3 +1,4 @@
Makefile
filtergraph.ok
+memallocator.ok
testlist.c
diff --git a/dlls/quartz/tests/Makefile.in b/dlls/quartz/tests/Makefile.in
index 7edc40c..a90dd00 100644
--- a/dlls/quartz/tests/Makefile.in
+++ b/dlls/quartz/tests/Makefile.in
@@ -7,7 +7,8 @@
EXTRALIBS = -lstrmiids
CTESTS = \
- filtergraph.c
+ filtergraph.c \
+ memallocator.c
@MAKE_TEST_RULES@
diff --git a/dlls/quartz/tests/memallocator.c b/dlls/quartz/tests/memallocator.c
new file mode 100644
index 0000000..4acb133
--- /dev/null
+++ b/dlls/quartz/tests/memallocator.c
@@ -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();
+}