ReactOS 0.4.15-dev-7958-gcd0bb1a
memallocator.c File Reference
#include "wine/test.h"
#include "uuids.h"
#include "dshow.h"
#include "control.h"
Include dependency graph for memallocator.c:

Go to the source code of this file.

Macros

#define COBJMACROS
 

Functions

static void CommitDecommitTest (void)
 
 START_TEST (memallocator)
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 21 of file memallocator.c.

Function Documentation

◆ CommitDecommitTest()

static void CommitDecommitTest ( void  )
static

Definition at line 28 of file memallocator.c.

29{
30 IMemAllocator* pMemAllocator;
31 HRESULT hr;
32
33 hr = CoCreateInstance(&CLSID_MemoryAllocator, NULL, CLSCTX_INPROC_SERVER, &IID_IMemAllocator, (LPVOID*)&pMemAllocator);
34 ok(hr==S_OK, "Unable to create memory allocator %x\n", hr);
35
36 if (hr == S_OK)
37 {
38 ALLOCATOR_PROPERTIES RequestedProps;
39 ALLOCATOR_PROPERTIES ActualProps;
40
41 IMediaSample *sample = NULL, *sample2 = NULL;
42
43 RequestedProps.cBuffers = 2;
44 RequestedProps.cbBuffer = 65536;
45 RequestedProps.cbAlign = 1;
46 RequestedProps.cbPrefix = 0;
47
48 hr = IMemAllocator_SetProperties(pMemAllocator, &RequestedProps, &ActualProps);
49 ok(hr==S_OK, "SetProperties returned: %x\n", hr);
50
51 hr = IMemAllocator_Commit(pMemAllocator);
52 ok(hr==S_OK, "Commit returned: %x\n", hr);
53 hr = IMemAllocator_Commit(pMemAllocator);
54 ok(hr==S_OK, "Commit returned: %x\n", hr);
55
56 hr = IMemAllocator_GetBuffer(pMemAllocator, &sample, NULL, NULL, 0);
57 ok(hr==S_OK, "Could not get a buffer: %x\n", hr);
58
59 hr = IMemAllocator_Decommit(pMemAllocator);
60 ok(hr==S_OK, "Decommit returned: %x\n", hr);
61 hr = IMemAllocator_Decommit(pMemAllocator);
62 ok(hr==S_OK, "Cecommit returned: %x\n", hr);
63
64 /* Decommit and recommit while holding a sample */
65 if (sample)
66 {
67 hr = IMemAllocator_Commit(pMemAllocator);
68 ok(hr==S_OK, "Commit returned: %x\n", hr);
69
70 hr = IMemAllocator_GetBuffer(pMemAllocator, &sample2, NULL, NULL, 0);
71 ok(hr==S_OK, "Could not get a buffer: %x\n", hr);
72 IMediaSample_Release(sample);
73 if (sample2)
74 IMediaSample_Release(sample2);
75
76 hr = IMemAllocator_Decommit(pMemAllocator);
77 ok(hr==S_OK, "Cecommit returned: %x\n", hr);
78 }
79 IMemAllocator_Release(pMemAllocator);
80 }
81}
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
#define S_OK
Definition: intsafe.h:52
HRESULT hr
Definition: shlfolder.c:183

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( memallocator  )

Definition at line 83 of file memallocator.c.

84{
86
88
90}
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
static void CommitDecommitTest(void)
Definition: memallocator.c:28