[PATCH 2/4] evr/tests: Avoid Vista crashes when testing the IMFVideoSampleAllocator interface.
Francois Gouget
fgouget at codeweavers.com
Thu Nov 26 10:40:37 CST 2020
Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---
dlls/evr/tests/evr.c | 161 ++++++++++++++++++++++---------------------
1 file changed, 84 insertions(+), 77 deletions(-)
diff --git a/dlls/evr/tests/evr.c b/dlls/evr/tests/evr.c
index cfab5e73070..ce791db21b1 100644
--- a/dlls/evr/tests/evr.c
+++ b/dlls/evr/tests/evr.c
@@ -1364,6 +1364,8 @@ static void test_MFCreateVideoSampleAllocator(void)
HRESULT hr;
BYTE *data;
+ video_type = create_video_type(&MFVideoFormat_RGB32);
+
hr = MFCreateVideoSampleAllocator(&IID_IUnknown, (void **)&unk);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
IUnknown_Release(unk);
@@ -1372,111 +1374,116 @@ static void test_MFCreateVideoSampleAllocator(void)
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = IMFVideoSampleAllocator_QueryInterface(allocator, &IID_IMFVideoSampleAllocatorCallback, (void **)&allocator_cb);
- ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
-
- hr = IMFVideoSampleAllocatorCallback_SetCallback(allocator_cb, NULL);
- ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
-
- hr = IMFVideoSampleAllocatorCallback_SetCallback(allocator_cb, &test_notify);
- ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
-
- hr = IMFVideoSampleAllocatorCallback_SetCallback(allocator_cb, NULL);
- ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+ if (hr == E_NOINTERFACE) /* Vista */
+ win_skip("IID_IMFVideoSampleAllocatorCallback is not supported\n");
+ else
+ {
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
- hr = IMFVideoSampleAllocatorCallback_GetFreeSampleCount(allocator_cb, NULL);
- ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+ hr = IMFVideoSampleAllocatorCallback_SetCallback(allocator_cb, NULL);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
- count = 10;
- hr = IMFVideoSampleAllocatorCallback_GetFreeSampleCount(allocator_cb, &count);
- ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
- ok(!count, "Unexpected count %d.\n", count);
+ hr = IMFVideoSampleAllocatorCallback_SetCallback(allocator_cb, &test_notify);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
- hr = IMFVideoSampleAllocator_UninitializeSampleAllocator(allocator);
- ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+ hr = IMFVideoSampleAllocatorCallback_SetCallback(allocator_cb, NULL);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
- hr = IMFVideoSampleAllocator_AllocateSample(allocator, &sample);
- ok(hr == MF_E_NOT_INITIALIZED, "Unexpected hr %#x.\n", hr);
+ hr = IMFVideoSampleAllocatorCallback_GetFreeSampleCount(allocator_cb, NULL);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
- hr = IMFVideoSampleAllocator_SetDirectXManager(allocator, NULL);
- ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+ count = 10;
+ hr = IMFVideoSampleAllocatorCallback_GetFreeSampleCount(allocator_cb, &count);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+ ok(!count, "Unexpected count %d.\n", count);
- hr = MFCreateMediaType(&media_type);
- ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+ hr = IMFVideoSampleAllocator_UninitializeSampleAllocator(allocator);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
- /* It expects IMFVideoMediaType aka video major type. Exact return code is E_NOINTERFACE,
- likely coming from querying for IMFVideoMediaType. Does not seem valuable to match it. */
- hr = IMFVideoSampleAllocator_InitializeSampleAllocator(allocator, 2, media_type);
- ok(FAILED(hr), "Unexpected hr %#x.\n", hr);
+ hr = IMFVideoSampleAllocator_AllocateSample(allocator, &sample);
+ ok(hr == MF_E_NOT_INITIALIZED, "Unexpected hr %#x.\n", hr);
- video_type = create_video_type(&MFVideoFormat_RGB32);
+ hr = IMFVideoSampleAllocator_SetDirectXManager(allocator, NULL);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
- hr = IMFVideoSampleAllocator_InitializeSampleAllocator(allocator, 2, video_type);
- ok(hr == MF_E_INVALIDMEDIATYPE, "Unexpected hr %#x.\n", hr);
+ hr = MFCreateMediaType(&media_type);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
- /* Frame size is required. */
- hr = IMFMediaType_SetUINT64(video_type, &MF_MT_FRAME_SIZE, (UINT64) 320 << 32 | 240);
- ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
- hr = IMFVideoSampleAllocator_InitializeSampleAllocator(allocator, 0, video_type);
- ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+ /* It expects IMFVideoMediaType aka video major type. Exact return
+ * code is E_NOINTERFACE, likely coming from querying for
+ * IMFVideoMediaType. Does not seem valuable to match it.
+ */
+ hr = IMFVideoSampleAllocator_InitializeSampleAllocator(allocator, 2, media_type);
+ ok(FAILED(hr), "Unexpected hr %#x.\n", hr);
- hr = IMFVideoSampleAllocatorCallback_GetFreeSampleCount(allocator_cb, &count);
- ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
- ok(count == 1, "Unexpected count %d.\n", count);
+ hr = IMFVideoSampleAllocator_InitializeSampleAllocator(allocator, 2, video_type);
+ ok(hr == MF_E_INVALIDMEDIATYPE, "Unexpected hr %#x.\n", hr);
- sample = NULL;
- hr = IMFVideoSampleAllocator_AllocateSample(allocator, &sample);
- ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
- refcount = get_refcount(sample);
+ /* Frame size is required. */
+ hr = IMFMediaType_SetUINT64(video_type, &MF_MT_FRAME_SIZE, (UINT64) 320 << 32 | 240);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+ hr = IMFVideoSampleAllocator_InitializeSampleAllocator(allocator, 0, video_type);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
- hr = IMFVideoSampleAllocator_AllocateSample(allocator, &sample2);
- ok(hr == MF_E_SAMPLEALLOCATOR_EMPTY, "Unexpected hr %#x.\n", hr);
+ hr = IMFVideoSampleAllocatorCallback_GetFreeSampleCount(allocator_cb, &count);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+ ok(count == 1, "Unexpected count %d.\n", count);
- /* Reinitialize with active sample. */
- hr = IMFVideoSampleAllocator_InitializeSampleAllocator(allocator, 4, video_type);
- ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
- ok(refcount == get_refcount(sample), "Unexpected refcount %u.\n", get_refcount(sample));
+ sample = NULL;
+ hr = IMFVideoSampleAllocator_AllocateSample(allocator, &sample);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+ refcount = get_refcount(sample);
- hr = IMFVideoSampleAllocatorCallback_GetFreeSampleCount(allocator_cb, &count);
- ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
- ok(count == 4, "Unexpected count %d.\n", count);
+ hr = IMFVideoSampleAllocator_AllocateSample(allocator, &sample2);
+ ok(hr == MF_E_SAMPLEALLOCATOR_EMPTY, "Unexpected hr %#x.\n", hr);
- hr = IMFSample_QueryInterface(sample, &IID_IMFDesiredSample, (void **)&unk);
- ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
- IUnknown_Release(unk);
+ /* Reinitialize with active sample. */
+ hr = IMFVideoSampleAllocator_InitializeSampleAllocator(allocator, 4, video_type);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+ ok(refcount == get_refcount(sample), "Unexpected refcount %u.\n", get_refcount(sample));
- hr = IMFSample_QueryInterface(sample, &IID_IMFTrackedSample, (void **)&unk);
- ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
- IUnknown_Release(unk);
+ hr = IMFVideoSampleAllocatorCallback_GetFreeSampleCount(allocator_cb, &count);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+ ok(count == 4, "Unexpected count %d.\n", count);
- hr = IMFSample_GetBufferByIndex(sample, 0, &buffer);
- ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+ hr = IMFSample_QueryInterface(sample, &IID_IMFDesiredSample, (void **)&unk);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+ IUnknown_Release(unk);
- hr = IMFMediaBuffer_QueryInterface(buffer, &IID_IMFGetService, (void **)&gs);
- ok(hr == S_OK || broken(hr == E_NOINTERFACE) /* Win7 */, "Unexpected hr %#x.\n", hr);
+ hr = IMFSample_QueryInterface(sample, &IID_IMFTrackedSample, (void **)&unk);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+ IUnknown_Release(unk);
- /* Device manager wasn't set, sample gets regular memory buffers. */
- if (SUCCEEDED(hr))
- {
- hr = IMFGetService_GetService(gs, &MR_BUFFER_SERVICE, &IID_IDirect3DSurface9, (void **)&surface);
- ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr);
- IMFGetService_Release(gs);
- }
+ hr = IMFSample_GetBufferByIndex(sample, 0, &buffer);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
- hr = IMFMediaBuffer_QueryInterface(buffer, &IID_IMF2DBuffer, (void **)&unk);
- ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
- IUnknown_Release(unk);
+ hr = IMFMediaBuffer_QueryInterface(buffer, &IID_IMFGetService, (void **)&gs);
+ ok(hr == S_OK || broken(hr == E_NOINTERFACE) /* Win7 */, "Unexpected hr %#x.\n", hr);
- IMFMediaBuffer_Release(buffer);
+ /* Device manager wasn't set, sample gets regular memory buffers. */
+ if (SUCCEEDED(hr))
+ {
+ hr = IMFGetService_GetService(gs, &MR_BUFFER_SERVICE, &IID_IDirect3DSurface9, (void **)&surface);
+ ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr);
+ IMFGetService_Release(gs);
+ }
- IMFSample_Release(sample);
+ hr = IMFMediaBuffer_QueryInterface(buffer, &IID_IMF2DBuffer, (void **)&unk);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+ IUnknown_Release(unk);
- IMFVideoSampleAllocatorCallback_Release(allocator_cb);
+ IMFMediaBuffer_Release(buffer);
+ IMFSample_Release(sample);
+ IMFVideoSampleAllocatorCallback_Release(allocator_cb);
+ }
IMFVideoSampleAllocator_Release(allocator);
hr = MFCreateVideoSampleAllocator(&IID_IMFVideoSampleAllocatorCallback, (void **)&unk);
- ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
- IUnknown_Release(unk);
+ ok(hr == S_OK || broken(hr == E_NOINTERFACE) /* Vista */,
+ "Unexpected hr %#x.\n", hr);
+ if (SUCCEEDED(hr))
+ IUnknown_Release(unk);
/* Using device manager */
window = create_window();
--
2.20.1
More information about the wine-devel
mailing list