Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
Il 20/01/22 11:35, Nikolay Sivov ha scritto:
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com
dlls/mfmediaengine/tests/mfmediaengine.c | 78 ++++++++++++++++-------- 1 file changed, 54 insertions(+), 24 deletions(-)
diff --git a/dlls/mfmediaengine/tests/mfmediaengine.c b/dlls/mfmediaengine/tests/mfmediaengine.c index ea63d4e284f..be0bd280db8 100644 --- a/dlls/mfmediaengine/tests/mfmediaengine.c +++ b/dlls/mfmediaengine/tests/mfmediaengine.c @@ -104,7 +104,12 @@ static ULONG WINAPI media_engine_notify_AddRef(IMFMediaEngineNotify *iface) static ULONG WINAPI media_engine_notify_Release(IMFMediaEngineNotify *iface) { struct media_engine_notify *notify = impl_from_IMFMediaEngineNotify(iface);
- return InterlockedDecrement(¬ify->refcount);
ULONG refcount = InterlockedDecrement(¬ify->refcount);
if (!refcount)
free(notify);
return refcount; }
static HRESULT WINAPI media_engine_notify_EventNotify(IMFMediaEngineNotify *iface, DWORD event, DWORD_PTR param1, DWORD param2)
@@ -120,6 +125,18 @@ static IMFMediaEngineNotifyVtbl media_engine_notify_vtbl = media_engine_notify_EventNotify, };
+static struct media_engine_notify *create_callback(void) +{
- struct media_engine_notify *object;
- object = calloc(1, sizeof(*object));
- object->IMFMediaEngineNotify_iface.lpVtbl = &media_engine_notify_vtbl;
- object->refcount = 1;
- return object;
+}
- static IMFMediaEngine *create_media_engine(IMFMediaEngineNotify *callback) { IMFDXGIDeviceManager *manager;
@@ -150,9 +167,8 @@ static IMFMediaEngine *create_media_engine(IMFMediaEngineNotify *callback)
static void test_factory(void) {
- struct media_engine_notify notify_impl = {{&media_engine_notify_vtbl}, 1};
- IMFMediaEngineNotify *notify = ¬ify_impl.IMFMediaEngineNotify_iface; IMFMediaEngineClassFactory *factory, *factory2;
- struct media_engine_notify *notify; IMFDXGIDeviceManager *manager; IMFMediaEngine *media_engine; IMFAttributes *attributes;
@@ -168,6 +184,8 @@ static void test_factory(void) return; }
- notify = create_callback();
/* Aggregation is not supported. */ hr = CoCreateInstance(&CLSID_MFMediaEngineClassFactory, (IUnknown *)factory, CLSCTX_INPROC_SERVER, &IID_IMFMediaEngineClassFactory, (void **)&factory2);
@@ -189,7 +207,7 @@ static void test_factory(void) ok(hr == MF_E_ATTRIBUTENOTFOUND, "IMFMediaEngineClassFactory_CreateInstance got %#x.\n", hr);
IMFAttributes_DeleteAllItems(attributes);
- hr = IMFAttributes_SetUnknown(attributes, &MF_MEDIA_ENGINE_CALLBACK, (IUnknown *)notify);
- hr = IMFAttributes_SetUnknown(attributes, &MF_MEDIA_ENGINE_CALLBACK, (IUnknown *)¬ify->IMFMediaEngineNotify_iface); ok(hr == S_OK, "IMFAttributes_SetUnknown failed: %#x.\n", hr); hr = IMFAttributes_SetUINT32(attributes, &MF_MEDIA_ENGINE_VIDEO_OUTPUT_FORMAT, DXGI_FORMAT_UNKNOWN); ok(hr == S_OK, "IMFAttributes_SetUINT32 failed: %#x.\n", hr);
@@ -199,23 +217,24 @@ static void test_factory(void) ok(hr == S_OK, "IMFMediaEngineClassFactory_CreateInstance failed: %#x.\n", hr); EXPECT_REF(factory, 1);
IMFMediaEngine_Release(media_engine); IMFAttributes_Release(attributes); IMFDXGIDeviceManager_Release(manager); IMFMediaEngineClassFactory_Release(factory);
IMFMediaEngineNotify_Release(¬ify->IMFMediaEngineNotify_iface); }
static void test_CreateInstance(void) {
- struct media_engine_notify notify_impl = {{&media_engine_notify_vtbl}, 1};
- IMFMediaEngineNotify *notify = ¬ify_impl.IMFMediaEngineNotify_iface;
struct media_engine_notify *notify; IMFDXGIDeviceManager *manager; IMFMediaEngine *media_engine; IMFAttributes *attributes; UINT token; HRESULT hr;
notify = create_callback();
hr = pMFCreateDXGIDeviceManager(&token, &manager); ok(hr == S_OK, "Failed to create dxgi device manager, hr %#x.\n", hr);
@@ -235,7 +254,7 @@ static void test_CreateInstance(void)
IMFAttributes_DeleteAllItems(attributes);
- hr = IMFAttributes_SetUnknown(attributes, &MF_MEDIA_ENGINE_CALLBACK, (IUnknown *)notify);
- hr = IMFAttributes_SetUnknown(attributes, &MF_MEDIA_ENGINE_CALLBACK, (IUnknown *)¬ify->IMFMediaEngineNotify_iface); ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr); hr = IMFAttributes_SetUINT32(attributes, &MF_MEDIA_ENGINE_VIDEO_OUTPUT_FORMAT, DXGI_FORMAT_UNKNOWN); ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
@@ -249,12 +268,12 @@ static void test_CreateInstance(void) IMFMediaEngine_Release(media_engine); IMFAttributes_Release(attributes); IMFDXGIDeviceManager_Release(manager);
IMFMediaEngineNotify_Release(¬ify->IMFMediaEngineNotify_iface); }
static void test_Shutdown(void) {
- struct media_engine_notify notify_impl = {{&media_engine_notify_vtbl}, 1};
- IMFMediaEngineNotify *callback = ¬ify_impl.IMFMediaEngineNotify_iface;
- struct media_engine_notify *notify; IMFMediaTimeRange *time_range; IMFMediaEngine *media_engine; unsigned int state;
@@ -263,7 +282,9 @@ static void test_Shutdown(void) HRESULT hr; BSTR str;
- media_engine = create_media_engine(callback);
notify = create_callback();
media_engine = create_media_engine(¬ify->IMFMediaEngineNotify_iface);
hr = IMFMediaEngine_Shutdown(media_engine); ok(hr == S_OK, "Failed to shut down, hr %#x.\n", hr);
@@ -403,12 +424,12 @@ todo_wine ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr);
IMFMediaEngine_Release(media_engine);
IMFMediaEngineNotify_Release(¬ify->IMFMediaEngineNotify_iface); }
static void test_Play(void) {
- struct media_engine_notify notify_impl = {{&media_engine_notify_vtbl}, 1};
- IMFMediaEngineNotify *callback = ¬ify_impl.IMFMediaEngineNotify_iface;
- struct media_engine_notify *notify; IMFMediaTimeRange *range, *range1; IMFMediaEngine *media_engine; LONGLONG pts;
@@ -416,7 +437,9 @@ static void test_Play(void) HRESULT hr; BOOL ret;
- media_engine = create_media_engine(callback);
notify = create_callback();
media_engine = create_media_engine(¬ify->IMFMediaEngineNotify_iface);
hr = IMFMediaEngine_GetBuffered(media_engine, &range); ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
@@ -465,7 +488,7 @@ static void test_Play(void) IMFMediaEngine_Release(media_engine);
/* Play -> Pause */
- media_engine = create_media_engine(callback);
media_engine = create_media_engine(¬ify->IMFMediaEngineNotify_iface);
hr = IMFMediaEngine_Play(media_engine); ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
@@ -480,17 +503,19 @@ static void test_Play(void) ok(!!ret, "Unexpected state %d.\n", ret);
IMFMediaEngine_Release(media_engine);
IMFMediaEngineNotify_Release(¬ify->IMFMediaEngineNotify_iface); }
static void test_playback_rate(void) {
- struct media_engine_notify notify_impl = {{&media_engine_notify_vtbl}, 1};
- IMFMediaEngineNotify *callback = ¬ify_impl.IMFMediaEngineNotify_iface;
- struct media_engine_notify *notify; IMFMediaEngine *media_engine; double rate; HRESULT hr;
- media_engine = create_media_engine(callback);
notify = create_callback();
media_engine = create_media_engine(¬ify->IMFMediaEngineNotify_iface);
rate = IMFMediaEngine_GetDefaultPlaybackRate(media_engine); ok(rate == 1.0, "Unexpected default rate.\n");
@@ -508,17 +533,19 @@ static void test_playback_rate(void) ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
IMFMediaEngine_Release(media_engine);
IMFMediaEngineNotify_Release(¬ify->IMFMediaEngineNotify_iface); }
static void test_mute(void) {
- struct media_engine_notify notify_impl = {{&media_engine_notify_vtbl}, 1};
- IMFMediaEngineNotify *callback = ¬ify_impl.IMFMediaEngineNotify_iface;
- struct media_engine_notify *notify; IMFMediaEngine *media_engine; HRESULT hr; BOOL ret;
- media_engine = create_media_engine(callback);
notify = create_callback();
media_engine = create_media_engine(¬ify->IMFMediaEngineNotify_iface);
ret = IMFMediaEngine_GetMuted(media_engine); ok(!ret, "Unexpected state.\n");
@@ -536,18 +563,20 @@ static void test_mute(void) ok(ret, "Unexpected state.\n");
IMFMediaEngine_Release(media_engine);
IMFMediaEngineNotify_Release(¬ify->IMFMediaEngineNotify_iface); }
static void test_error(void) {
- struct media_engine_notify notify_impl = {{&media_engine_notify_vtbl}, 1};
- IMFMediaEngineNotify *callback = ¬ify_impl.IMFMediaEngineNotify_iface;
- struct media_engine_notify *notify; IMFMediaEngine *media_engine; IMFMediaError *eo, *eo2; unsigned int code; HRESULT hr;
- media_engine = create_media_engine(callback);
notify = create_callback();
media_engine = create_media_engine(¬ify->IMFMediaEngineNotify_iface);
eo = (void *)0xdeadbeef; hr = IMFMediaEngine_GetError(media_engine, &eo);
@@ -620,6 +649,7 @@ static void test_error(void) ok(hr == E_FAIL, "Unexpected code %#x.\n", hr);
IMFMediaError_Release(eo);
IMFMediaEngineNotify_Release(¬ify->IMFMediaEngineNotify_iface); }
static void test_time_range(void)