[PATCH 1/7] mfplat/tests: Check that buffers are properly aligned.
Nikolay Sivov
nsivov at codeweavers.com
Mon Feb 14 12:51:20 CST 2022
On 2/14/22 19:07, Giovanni Mascellani wrote:
>
> - hr = MFCreateAlignedMemoryBuffer(201, MF_8_BYTE_ALIGNMENT, &buffer);
> + hr = MFCreateAlignedMemoryBuffer(201, MF_512_BYTE_ALIGNMENT, &buffer);
> ok(hr == S_OK, "Failed to create memory buffer, hr %#x.\n", hr);
>
> hr = IMFMediaBuffer_GetCurrentLength(buffer, &length);
> @@ -2279,6 +2279,8 @@ static void test_system_memory_buffer(void)
> hr = IMFMediaBuffer_Lock(buffer, &data, &max, &length);
> ok(hr == S_OK, "Failed to lock, hr %#x.\n", hr);
> ok(max == 201 && length == 10, "Unexpected length.\n");
> + todo_wine
> + ok(((uintptr_t)data & MF_512_BYTE_ALIGNMENT) == 0, "Data at %p is insufficiently aligned.\n", data);
> hr = IMFMediaBuffer_Unlock(buffer);
> ok(hr == S_OK, "Failed to unlock, hr %#x.\n", hr);
>
Thanks, looks like this checks out for alignment values I tried. There
is one issue with using _aligned_malloc() for this - it requires power
of 2 for alignment argument, understandably. Media buffer function does
not have this requirement. So while we definitely want this fixed, I
suggest focusing on tests first, and maybe not using _aligned_malloc(),
it will require to keep additional pointer, and a single helper to
allocate such buffer. This will also help by using regular
calloc()/free() for everything we allocate.
More information about the wine-devel
mailing list