From 8f3cc76ea2df39481cd72a130dddc38ae3a78c09 Mon Sep 17 00:00:00 2001 From: Christian Costa Date: Mon, 22 Aug 2005 09:27:41 +0000 Subject: [PATCH] Return S_OK when committing/decomitting an already committed/decommitted allocator. Add corresponding test case. Improve traces. --- dlls/quartz/memallocator.c | 18 +++++------ dlls/quartz/tests/.cvsignore | 1 + dlls/quartz/tests/Makefile.in | 3 +- dlls/quartz/tests/memallocator.c | 70 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 82 insertions(+), 10 deletions(-) create mode 100644 dlls/quartz/tests/memallocator.c diff --git a/dlls/quartz/memallocator.c b/dlls/quartz/memallocator.c index 1eb53a8a261..3bdb273810b 100644 --- a/dlls/quartz/memallocator.c +++ b/dlls/quartz/memallocator.c @@ -116,7 +116,7 @@ static HRESULT BaseMemAllocator_Init(HRESULT (* fnAlloc)(IMemAllocator *), HRESU 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 @@ static HRESULT WINAPI BaseMemAllocator_SetProperties(IMemAllocator * iface, ALLO 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 @@ static HRESULT WINAPI BaseMemAllocator_GetProperties(IMemAllocator * iface, ALLO 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 @@ static HRESULT WINAPI BaseMemAllocator_Commit(IMemAllocator * iface) 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 @@ static HRESULT WINAPI BaseMemAllocator_Decommit(IMemAllocator * iface) 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 @@ static HRESULT WINAPI BaseMemAllocator_GetBuffer(IMemAllocator * iface, IMediaSa /* 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 @@ static HRESULT WINAPI BaseMemAllocator_ReleaseBuffer(IMemAllocator * iface, IMed 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 5c103bd85b5..43322bd830c 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 7edc40c05f8..a90dd0012e9 100644 --- a/dlls/quartz/tests/Makefile.in +++ b/dlls/quartz/tests/Makefile.in @@ -7,7 +7,8 @@ IMPORTS = ole32 user32 gdi32 kernel32 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 00000000000..4acb133bf56 --- /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 + +#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(); +} -- 2.11.4.GIT