forked from Mirrors/wine-wine
quartz/tests: Clean up CommitDecommitTest().
Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
(cherry picked from commit 83dc66730e
)
Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
oldstable
parent
12fb7e9a75
commit
8c60e37443
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Unit tests for Direct Show functions
|
* Memory allocator unit tests
|
||||||
*
|
*
|
||||||
* Copyright (C) 2005 Christian Costa
|
* Copyright (C) 2005 Christian Costa
|
||||||
*
|
*
|
||||||
|
@ -19,72 +19,73 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define COBJMACROS
|
#define COBJMACROS
|
||||||
|
|
||||||
#include "wine/test.h"
|
|
||||||
#include "uuids.h"
|
|
||||||
#include "dshow.h"
|
#include "dshow.h"
|
||||||
#include "control.h"
|
#include "wine/test.h"
|
||||||
|
|
||||||
static void CommitDecommitTest(void)
|
static IMemAllocator *create_allocator(void)
|
||||||
{
|
{
|
||||||
IMemAllocator* pMemAllocator;
|
IMemAllocator *allocator = NULL;
|
||||||
|
HRESULT hr = CoCreateInstance(&CLSID_MemoryAllocator, NULL, CLSCTX_INPROC_SERVER,
|
||||||
|
&IID_IMemAllocator, (void **)&allocator);
|
||||||
|
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||||
|
return allocator;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_commit(void)
|
||||||
|
{
|
||||||
|
ALLOCATOR_PROPERTIES req_props = {2, 65536, 1, 0}, ret_props;
|
||||||
|
IMemAllocator *allocator = create_allocator();
|
||||||
|
IMediaSample *sample, *sample2;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
BYTE *data;
|
||||||
|
|
||||||
hr = CoCreateInstance(&CLSID_MemoryAllocator, NULL, CLSCTX_INPROC_SERVER, &IID_IMemAllocator, (LPVOID*)&pMemAllocator);
|
hr = IMemAllocator_SetProperties(allocator, &req_props, &ret_props);
|
||||||
ok(hr==S_OK, "Unable to create memory allocator %x\n", hr);
|
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||||
|
|
||||||
if (hr == S_OK)
|
hr = IMemAllocator_GetBuffer(allocator, &sample, NULL, NULL, 0);
|
||||||
{
|
ok(hr == VFW_E_NOT_COMMITTED, "Got hr %#x.\n", hr);
|
||||||
ALLOCATOR_PROPERTIES RequestedProps;
|
|
||||||
ALLOCATOR_PROPERTIES ActualProps;
|
|
||||||
|
|
||||||
IMediaSample *sample = NULL, *sample2 = NULL;
|
hr = IMemAllocator_Commit(allocator);
|
||||||
|
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||||
|
hr = IMemAllocator_Commit(allocator);
|
||||||
|
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||||
|
|
||||||
RequestedProps.cBuffers = 2;
|
hr = IMemAllocator_GetBuffer(allocator, &sample, NULL, NULL, 0);
|
||||||
RequestedProps.cbBuffer = 65536;
|
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||||
RequestedProps.cbAlign = 1;
|
IMediaSample_Release(sample);
|
||||||
RequestedProps.cbPrefix = 0;
|
|
||||||
|
|
||||||
hr = IMemAllocator_SetProperties(pMemAllocator, &RequestedProps, &ActualProps);
|
hr = IMemAllocator_Decommit(allocator);
|
||||||
ok(hr==S_OK, "SetProperties returned: %x\n", hr);
|
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||||
|
hr = IMemAllocator_Decommit(allocator);
|
||||||
|
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||||
|
|
||||||
hr = IMemAllocator_Commit(pMemAllocator);
|
/* Extant samples remain valid even after Decommit() is called. */
|
||||||
ok(hr==S_OK, "Commit returned: %x\n", hr);
|
hr = IMemAllocator_Commit(allocator);
|
||||||
hr = IMemAllocator_Commit(pMemAllocator);
|
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||||
ok(hr==S_OK, "Commit returned: %x\n", hr);
|
|
||||||
|
|
||||||
hr = IMemAllocator_GetBuffer(pMemAllocator, &sample, NULL, NULL, 0);
|
hr = IMemAllocator_GetBuffer(allocator, &sample, NULL, NULL, 0);
|
||||||
ok(hr==S_OK, "Could not get a buffer: %x\n", hr);
|
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||||
|
|
||||||
hr = IMemAllocator_Decommit(pMemAllocator);
|
hr = IMediaSample_GetPointer(sample, &data);
|
||||||
ok(hr==S_OK, "Decommit returned: %x\n", hr);
|
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||||
hr = IMemAllocator_Decommit(pMemAllocator);
|
|
||||||
ok(hr==S_OK, "Cecommit returned: %x\n", hr);
|
|
||||||
|
|
||||||
/* Decommit and recommit while holding a sample */
|
hr = IMemAllocator_Decommit(allocator);
|
||||||
if (sample)
|
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||||
{
|
|
||||||
hr = IMemAllocator_Commit(pMemAllocator);
|
|
||||||
ok(hr==S_OK, "Commit returned: %x\n", hr);
|
|
||||||
|
|
||||||
hr = IMemAllocator_GetBuffer(pMemAllocator, &sample2, NULL, NULL, 0);
|
memset(data, 0xcc, 65536);
|
||||||
ok(hr==S_OK, "Could not get a buffer: %x\n", hr);
|
|
||||||
IMediaSample_Release(sample);
|
|
||||||
if (sample2)
|
|
||||||
IMediaSample_Release(sample2);
|
|
||||||
|
|
||||||
hr = IMemAllocator_Decommit(pMemAllocator);
|
hr = IMemAllocator_GetBuffer(allocator, &sample2, NULL, NULL, 0);
|
||||||
ok(hr==S_OK, "Cecommit returned: %x\n", hr);
|
ok(hr == VFW_E_NOT_COMMITTED, "Got hr %#x.\n", hr);
|
||||||
}
|
|
||||||
IMemAllocator_Release(pMemAllocator);
|
IMediaSample_Release(sample);
|
||||||
}
|
IMemAllocator_Release(allocator);
|
||||||
}
|
}
|
||||||
|
|
||||||
START_TEST(memallocator)
|
START_TEST(memallocator)
|
||||||
{
|
{
|
||||||
CoInitialize(NULL);
|
CoInitialize(NULL);
|
||||||
|
|
||||||
CommitDecommitTest();
|
test_commit();
|
||||||
|
|
||||||
CoUninitialize();
|
CoUninitialize();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue