Return S_OK when committing/decomitting an already
committed/decommitted allocator. Add corresponding test case. Improve traces.
This commit is contained in:
parent
eafa666bee
commit
8f3cc76ea2
|
@ -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 */
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
Makefile
|
||||
filtergraph.ok
|
||||
memallocator.ok
|
||||
testlist.c
|
||||
|
|
|
@ -7,7 +7,8 @@ IMPORTS = ole32 user32 gdi32 kernel32
|
|||
EXTRALIBS = -lstrmiids
|
||||
|
||||
CTESTS = \
|
||||
filtergraph.c
|
||||
filtergraph.c \
|
||||
memallocator.c
|
||||
|
||||
@MAKE_TEST_RULES@
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
Loading…
Reference in New Issue