[v3 PATCH 6/6] mfplat: Implement MFHeap[Alloc|Free].
Nikolay Sivov
nsivov at codeweavers.com
Fri Feb 22 01:36:54 CST 2019
From: Gijs Vermeulen <gijsvrm at gmail.com>
Signed-off-by: Gijs Vermeulen <gijsvrm at gmail.com>
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
dlls/mfplat/main.c | 18 ++++++++++++++++++
dlls/mfplat/mfplat.spec | 4 ++--
dlls/mfplat/tests/mfplat.c | 21 +++++++++++++++++++++
include/mfapi.h | 10 ++++++++++
4 files changed, 51 insertions(+), 2 deletions(-)
diff --git a/dlls/mfplat/main.c b/dlls/mfplat/main.c
index e9b0abb041..a38c03b4d1 100644
--- a/dlls/mfplat/main.c
+++ b/dlls/mfplat/main.c
@@ -4124,3 +4124,21 @@ HRESULT WINAPI MFCreateCollection(IMFCollection **collection)
return S_OK;
}
+
+/***********************************************************************
+ * MFHeapAlloc (mfplat.@)
+ */
+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);
+}
+
+/***********************************************************************
+ * MFHeapFree (mfplat.@)
+ */
+void WINAPI MFHeapFree(void *p)
+{
+ TRACE("%p\n", p);
+ HeapFree(GetProcessHeap(), 0, p);
+}
diff --git a/dlls/mfplat/mfplat.spec b/dlls/mfplat/mfplat.spec
index b35b33558f..c4e0b2abfa 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 d0ae80a1e3..609faa5d00 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
}
@@ -1015,6 +1019,22 @@ static void test_MFCreateCollection(void)
IMFCollection_Release(collection);
}
+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);
@@ -1035,6 +1055,7 @@ START_TEST(mfplat)
test_allocate_queue();
test_MFCopyImage();
test_MFCreateCollection();
+ test_MFHeapAlloc();
CoUninitialize();
}
diff --git a/include/mfapi.h b/include/mfapi.h
index 5797db1152..7c47213d85 100644
--- a/include/mfapi.h
+++ b/include/mfapi.h
@@ -68,6 +68,14 @@ 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);
@@ -94,6 +102,8 @@ HRESULT WINAPI MFCreateMediaEvent(MediaEventType type, REFGUID extended_type, HR
HRESULT WINAPI MFCreateMediaType(IMFMediaType **type);
HRESULT WINAPI MFCreateSample(IMFSample **sample);
HRESULT WINAPI MFCreateMemoryBuffer(DWORD max_length, IMFMediaBuffer **buffer);
+void * WINAPI MFHeapAlloc(SIZE_T size, ULONG flags, char *file, int line, EAllocationType type);
+void WINAPI MFHeapFree(void *ptr);
HRESULT WINAPI MFGetTimerPeriodicity(DWORD *periodicity);
HRESULT WINAPI MFTEnum(GUID category, UINT32 flags, MFT_REGISTER_TYPE_INFO *input_type,
MFT_REGISTER_TYPE_INFO *output_type, IMFAttributes *attributes,
--
2.20.1
More information about the wine-devel
mailing list