2005-08-22 11:27:41 +02:00
|
|
|
/*
|
|
|
|
* 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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2005-08-22 11:27:41 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include "wine/test.h"
|
|
|
|
#include "uuids.h"
|
|
|
|
#include "dshow.h"
|
|
|
|
#include "control.h"
|
|
|
|
|
2006-02-06 13:13:28 +01:00
|
|
|
static void CommitDecommitTest(void)
|
2005-08-22 11:27:41 +02:00
|
|
|
{
|
|
|
|
IMemAllocator* pMemAllocator;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_MemoryAllocator, NULL, CLSCTX_INPROC_SERVER, &IID_IMemAllocator, (LPVOID*)&pMemAllocator);
|
2006-10-08 00:48:51 +02:00
|
|
|
ok(hr==S_OK, "Unable to create memory allocator %x\n", hr);
|
2005-08-22 11:27:41 +02:00
|
|
|
|
|
|
|
if (hr == S_OK)
|
|
|
|
{
|
2008-04-28 18:26:20 +02:00
|
|
|
ALLOCATOR_PROPERTIES RequestedProps;
|
|
|
|
ALLOCATOR_PROPERTIES ActualProps;
|
2005-08-22 11:27:41 +02:00
|
|
|
|
2008-04-28 18:26:20 +02:00
|
|
|
IMediaSample *sample = NULL, *sample2 = NULL;
|
|
|
|
|
|
|
|
RequestedProps.cBuffers = 2;
|
|
|
|
RequestedProps.cbBuffer = 65536;
|
|
|
|
RequestedProps.cbAlign = 1;
|
|
|
|
RequestedProps.cbPrefix = 0;
|
2005-08-22 11:27:41 +02:00
|
|
|
|
|
|
|
hr = IMemAllocator_SetProperties(pMemAllocator, &RequestedProps, &ActualProps);
|
2006-10-08 00:48:51 +02:00
|
|
|
ok(hr==S_OK, "SetProperties returned: %x\n", hr);
|
2005-08-22 11:27:41 +02:00
|
|
|
|
|
|
|
hr = IMemAllocator_Commit(pMemAllocator);
|
2006-10-08 00:48:51 +02:00
|
|
|
ok(hr==S_OK, "Commit returned: %x\n", hr);
|
2005-08-22 11:27:41 +02:00
|
|
|
hr = IMemAllocator_Commit(pMemAllocator);
|
2006-10-08 00:48:51 +02:00
|
|
|
ok(hr==S_OK, "Commit returned: %x\n", hr);
|
2005-08-22 11:27:41 +02:00
|
|
|
|
2008-04-28 18:26:20 +02:00
|
|
|
hr = IMemAllocator_GetBuffer(pMemAllocator, &sample, NULL, NULL, 0);
|
|
|
|
ok(hr==S_OK, "Could not get a buffer: %x\n", hr);
|
|
|
|
|
2005-08-22 11:27:41 +02:00
|
|
|
hr = IMemAllocator_Decommit(pMemAllocator);
|
2006-10-08 00:48:51 +02:00
|
|
|
ok(hr==S_OK, "Decommit returned: %x\n", hr);
|
2005-08-22 11:27:41 +02:00
|
|
|
hr = IMemAllocator_Decommit(pMemAllocator);
|
2006-10-08 00:48:51 +02:00
|
|
|
ok(hr==S_OK, "Cecommit returned: %x\n", hr);
|
2005-08-22 11:27:41 +02:00
|
|
|
|
2008-04-28 18:26:20 +02:00
|
|
|
/* Decommit and recommit while holding a sample */
|
|
|
|
if (sample)
|
|
|
|
{
|
|
|
|
hr = IMemAllocator_Commit(pMemAllocator);
|
|
|
|
ok(hr==S_OK, "Commit returned: %x\n", hr);
|
|
|
|
|
|
|
|
hr = IMemAllocator_GetBuffer(pMemAllocator, &sample2, NULL, NULL, 0);
|
|
|
|
ok(hr==S_OK, "Could not get a buffer: %x\n", hr);
|
|
|
|
IUnknown_Release(sample);
|
|
|
|
if (sample2)
|
|
|
|
IUnknown_Release(sample2);
|
|
|
|
|
|
|
|
hr = IMemAllocator_Decommit(pMemAllocator);
|
|
|
|
ok(hr==S_OK, "Cecommit returned: %x\n", hr);
|
|
|
|
}
|
|
|
|
IMemAllocator_Release(pMemAllocator);
|
2005-08-22 11:27:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
START_TEST(memallocator)
|
|
|
|
{
|
|
|
|
CoInitialize(NULL);
|
|
|
|
|
|
|
|
CommitDecommitTest();
|
2008-05-19 17:04:48 +02:00
|
|
|
|
|
|
|
CoUninitialize();
|
2005-08-22 11:27:41 +02:00
|
|
|
}
|