Signed-off-by: Gijs Vermeulen gijsvrm@gmail.com --- dlls/mfplat/main.c | 12 ++++++++++++ dlls/mfplat/mfplat.spec | 4 ++-- dlls/mfplat/tests/mfplat.c | 21 +++++++++++++++++++++ include/mfapi.h | 7 +++++++ 4 files changed, 42 insertions(+), 2 deletions(-)
diff --git a/dlls/mfplat/main.c b/dlls/mfplat/main.c index 21240dfbeb..8d9a26d702 100644 --- a/dlls/mfplat/main.c +++ b/dlls/mfplat/main.c @@ -3871,3 +3871,15 @@ HRESULT WINAPI MFCreateSample(IMFSample **sample)
return S_OK; } + +void *WINAPI MFHeapAlloc(SIZE_T size, ULONG flags, char *file, int line, EAllocationType type) +{ + TRACE("%lu %x %s %d %x\n", size, flags, debugstr_a(file), line, type); + return HeapAlloc(GetProcessHeap(), flags, size); +} + +void WINAPI MFHeapFree(void *p) +{ + TRACE("%p\n", p); + heap_free(p); +} diff --git a/dlls/mfplat/mfplat.spec b/dlls/mfplat/mfplat.spec index 8f5ee77406..57a87ef8d2 100644 --- a/dlls/mfplat/mfplat.spec +++ b/dlls/mfplat/mfplat.spec @@ -103,8 +103,8 @@ @ stub MFGetUncompressedVideoFormat @ stub MFGetWorkQueueMMCSSClass @ stub MFGetWorkQueueMMCSSTaskId -@ stub MFHeapAlloc -@ stub MFHeapFree +@ stdcall MFHeapAlloc(long long str long long) +@ stdcall MFHeapFree(ptr) @ stub MFInitAMMediaTypeFromMFMediaType @ stub MFInitAttributesFromBlob @ stub MFInitMediaTypeFromAMMediaType diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index a7b5620d32..7247879fe0 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -41,6 +41,8 @@ static HRESULT (WINAPI *pMFCopyImage)(BYTE *dest, LONG deststride, const BYTE *s static HRESULT (WINAPI *pMFCreateSourceResolver)(IMFSourceResolver **resolver); static HRESULT (WINAPI *pMFCreateMFByteStreamOnStream)(IStream *stream, IMFByteStream **bytestream); static HRESULT (WINAPI *pMFCreateMemoryBuffer)(DWORD max_length, IMFMediaBuffer **buffer); +static void* (WINAPI *pMFHeapAlloc)(size_t size, ULONG flags, char *file, int line, EAllocationType type); +static void (WINAPI *pMFHeapFree)(void *p);
DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
@@ -314,6 +316,8 @@ static void init_functions(void) X(MFCreateSourceResolver); X(MFCreateMFByteStreamOnStream); X(MFCreateMemoryBuffer); + X(MFHeapAlloc); + X(MFHeapFree); #undef X }
@@ -913,6 +917,22 @@ static void test_MFCopyImage(void) ok(!memcmp(dest, src, 16), "Unexpected buffer contents.\n"); }
+static void test_MFHeapAlloc(void) +{ + void* res; + + if (!pMFHeapAlloc) + { + win_skip("MFHeapAlloc() is not available.\n"); + return; + } + + res = pMFHeapAlloc(16, 0, NULL, 0, eAllocationTypeIgnore); + ok(res != NULL, "MFHeapAlloc failed\n"); + + pMFHeapFree(res); +} + START_TEST(mfplat) { CoInitialize(NULL); @@ -932,6 +952,7 @@ START_TEST(mfplat) test_MFCreateAsyncResult(); test_allocate_queue(); test_MFCopyImage(); + test_MFHeapAlloc();
CoUninitialize(); } diff --git a/include/mfapi.h b/include/mfapi.h index d70a300a3c..79b05c69e1 100644 --- a/include/mfapi.h +++ b/include/mfapi.h @@ -68,6 +68,13 @@ typedef struct tagMFASYNCRESULT HANDLE hEvent; } MFASYNCRESULT;
+typedef enum _EAllocationType { + eAllocationTypeDynamic, + eAllocationTypeRT, + eAllocationTypePageable, + eAllocationTypeIgnore +} EAllocationType; + DEFINE_GUID(MF_MT_AVG_BITRATE, 0x20332624, 0xfb0d, 0x4d9e, 0xbd, 0x0d, 0xcb, 0xf6, 0x78, 0x6c, 0x10, 0x2e); DEFINE_GUID(MF_MT_FRAME_RATE, 0xc459a2e8, 0x3d2c, 0x4e44, 0xb1, 0x32, 0xfe, 0xe5, 0x15, 0x6c, 0x7b, 0xb0); DEFINE_GUID(MF_MT_FRAME_SIZE, 0x1652c33d, 0xd6b2, 0x4012, 0xb8, 0x34, 0x72, 0x03, 0x08, 0x49, 0xa3, 0x7d);
Gijs Vermeulen gijsvrm@gmail.com wrote:
+void *WINAPI MFHeapAlloc(SIZE_T size, ULONG flags, char *file, int line, EAllocationType type) +{
- TRACE("%lu %x %s %d %x\n", size, flags, debugstr_a(file), line, type);
- return HeapAlloc(GetProcessHeap(), flags, size);
+}
+void WINAPI MFHeapFree(void *p) +{
- TRACE("%p\n", p);
- heap_free(p);
+}
Probabaly for consistency both should either call HeapAlloc/HeapFree or heap_alloc/heap_free, but since Alloc uses flags Free should likely call HeapFree.