Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mfmediaengine/main.c | 60 ++++++++++++++++++++++-- dlls/mfmediaengine/tests/mfmediaengine.c | 19 ++++++++ 2 files changed, 74 insertions(+), 5 deletions(-)
diff --git a/dlls/mfmediaengine/main.c b/dlls/mfmediaengine/main.c index 5b8d91d9632..b098844a7fa 100644 --- a/dlls/mfmediaengine/main.c +++ b/dlls/mfmediaengine/main.c @@ -114,6 +114,7 @@ struct rect struct media_engine { IMFMediaEngine IMFMediaEngine_iface; + IMFGetService IMFGetService_iface; IMFAsyncCallback session_events; IMFAsyncCallback load_handler; IMFSampleGrabberSinkCallback grabber_callback; @@ -722,6 +723,11 @@ static inline struct media_engine *impl_from_IMFMediaEngine(IMFMediaEngine *ifac return CONTAINING_RECORD(iface, struct media_engine, IMFMediaEngine_iface); }
+static inline struct media_engine *impl_from_IMFGetService(IMFGetService *iface) +{ + return CONTAINING_RECORD(iface, struct media_engine, IMFGetService_iface); +} + static struct media_engine *impl_from_session_events_IMFAsyncCallback(IMFAsyncCallback *iface) { return CONTAINING_RECORD(iface, struct media_engine, session_events); @@ -1254,19 +1260,28 @@ static const IMFAsyncCallbackVtbl media_engine_load_handler_vtbl =
static HRESULT WINAPI media_engine_QueryInterface(IMFMediaEngine *iface, REFIID riid, void **obj) { + struct media_engine *engine = impl_from_IMFMediaEngine(iface); + TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), obj);
if (IsEqualIID(riid, &IID_IMFMediaEngine) || IsEqualIID(riid, &IID_IUnknown)) { *obj = iface; - IMFMediaEngine_AddRef(iface); - return S_OK; + } + else if (IsEqualIID(riid, &IID_IMFGetService)) + { + *obj = &engine->IMFGetService_iface; + } + else + { + WARN("Unsupported interface %s.\n", debugstr_guid(riid)); + *obj = NULL; + return E_NOINTERFACE; }
- WARN("Unsupported interface %s.\n", debugstr_guid(riid)); - *obj = NULL; - return E_NOINTERFACE; + IUnknown_AddRef((IUnknown *)*obj); + return S_OK; }
static ULONG WINAPI media_engine_AddRef(IMFMediaEngine *iface) @@ -2288,6 +2303,40 @@ static const IMFMediaEngineVtbl media_engine_vtbl = media_engine_OnVideoStreamTick, };
+static HRESULT WINAPI media_engine_gs_QueryInterface(IMFGetService *iface, REFIID riid, void **obj) +{ + struct media_engine *engine = impl_from_IMFGetService(iface); + return IMFMediaEngine_QueryInterface(&engine->IMFMediaEngine_iface, riid, obj); +} + +static ULONG WINAPI media_engine_gs_AddRef(IMFGetService *iface) +{ + struct media_engine *engine = impl_from_IMFGetService(iface); + return IMFMediaEngine_AddRef(&engine->IMFMediaEngine_iface); +} + +static ULONG WINAPI media_engine_gs_Release(IMFGetService *iface) +{ + struct media_engine *engine = impl_from_IMFGetService(iface); + return IMFMediaEngine_Release(&engine->IMFMediaEngine_iface); +} + +static HRESULT WINAPI media_engine_gs_GetService(IMFGetService *iface, REFGUID service, + REFIID riid, void **object) +{ + FIXME("%p, %s, %s, %p stub.\n", iface, debugstr_guid(service), debugstr_guid(riid), object); + + return E_NOTIMPL; +} + +static const IMFGetServiceVtbl media_engine_get_service_vtbl = +{ + media_engine_gs_QueryInterface, + media_engine_gs_AddRef, + media_engine_gs_Release, + media_engine_gs_GetService, +}; + static HRESULT WINAPI media_engine_grabber_callback_QueryInterface(IMFSampleGrabberSinkCallback *iface, REFIID riid, void **obj) { @@ -2442,6 +2491,7 @@ static HRESULT init_media_engine(DWORD flags, IMFAttributes *attributes, struct HRESULT hr;
engine->IMFMediaEngine_iface.lpVtbl = &media_engine_vtbl; + engine->IMFGetService_iface.lpVtbl = &media_engine_get_service_vtbl; engine->session_events.lpVtbl = &media_engine_session_events_vtbl; engine->load_handler.lpVtbl = &media_engine_load_handler_vtbl; engine->grabber_callback.lpVtbl = &media_engine_grabber_callback_vtbl; diff --git a/dlls/mfmediaengine/tests/mfmediaengine.c b/dlls/mfmediaengine/tests/mfmediaengine.c index 096f6e3f2a5..ea63d4e284f 100644 --- a/dlls/mfmediaengine/tests/mfmediaengine.c +++ b/dlls/mfmediaengine/tests/mfmediaengine.c @@ -46,6 +46,21 @@ static void _expect_ref(IUnknown *obj, ULONG ref, int line) ok_(__FILE__,line)(rc == ref, "Unexpected refcount %d, expected %d.\n", rc, ref); }
+#define check_interface(a, b, c) check_interface_(__LINE__, a, b, c) +static void check_interface_(unsigned int line, void *iface_ptr, REFIID iid, BOOL supported) +{ + IUnknown *iface = iface_ptr; + HRESULT hr, expected_hr; + IUnknown *unk; + + expected_hr = supported ? S_OK : E_NOINTERFACE; + + hr = IUnknown_QueryInterface(iface, iid, (void **)&unk); + ok_(__FILE__, line)(hr == expected_hr, "Got hr %#x, expected %#x.\n", hr, expected_hr); + if (SUCCEEDED(hr)) + IUnknown_Release(unk); +} + static void init_functions(void) { HMODULE mod = GetModuleHandleA("mfplat.dll"); @@ -184,6 +199,7 @@ 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); @@ -227,6 +243,9 @@ static void test_CreateInstance(void) hr = IMFMediaEngineClassFactory_CreateInstance(factory, MF_MEDIA_ENGINE_WAITFORSTABLE_STATE, attributes, &media_engine); ok(hr == S_OK, "Failed to create media engine, hr %#x.\n", hr);
+ check_interface(media_engine, &IID_IMFMediaEngine, TRUE); + check_interface(media_engine, &IID_IMFGetService, TRUE); + IMFMediaEngine_Release(media_engine); IMFAttributes_Release(attributes); IMFDXGIDeviceManager_Release(manager);
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)
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)
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=105483
Your paranoid android.
=== w8 (32 bit report) ===
mfmediaengine: mfmediaengine.c:266: Test failed: Got hr 0x80004002, expected 0.
=== w8adm (32 bit report) ===
mfmediaengine: mfmediaengine.c:266: Test failed: Got hr 0x80004002, expected 0.
=== w864 (32 bit report) ===
mfmediaengine: mfmediaengine.c:266: Test failed: Got hr 0x80004002, expected 0.
=== w864 (64 bit report) ===
mfmediaengine: mfmediaengine.c:266: Test failed: Got hr 0x80004002, expected 0.
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- A newline too much has slipped in the code, but it is removed by the following commit.
Il 20/01/22 11:35, Nikolay Sivov ha scritto:
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com
dlls/mfmediaengine/main.c | 60 ++++++++++++++++++++++-- dlls/mfmediaengine/tests/mfmediaengine.c | 19 ++++++++ 2 files changed, 74 insertions(+), 5 deletions(-)
diff --git a/dlls/mfmediaengine/main.c b/dlls/mfmediaengine/main.c index 5b8d91d9632..b098844a7fa 100644 --- a/dlls/mfmediaengine/main.c +++ b/dlls/mfmediaengine/main.c @@ -114,6 +114,7 @@ struct rect struct media_engine { IMFMediaEngine IMFMediaEngine_iface;
- IMFGetService IMFGetService_iface; IMFAsyncCallback session_events; IMFAsyncCallback load_handler; IMFSampleGrabberSinkCallback grabber_callback;
@@ -722,6 +723,11 @@ static inline struct media_engine *impl_from_IMFMediaEngine(IMFMediaEngine *ifac return CONTAINING_RECORD(iface, struct media_engine, IMFMediaEngine_iface); }
+static inline struct media_engine *impl_from_IMFGetService(IMFGetService *iface) +{
- return CONTAINING_RECORD(iface, struct media_engine, IMFGetService_iface);
+}
- static struct media_engine *impl_from_session_events_IMFAsyncCallback(IMFAsyncCallback *iface) { return CONTAINING_RECORD(iface, struct media_engine, session_events);
@@ -1254,19 +1260,28 @@ static const IMFAsyncCallbackVtbl media_engine_load_handler_vtbl =
static HRESULT WINAPI media_engine_QueryInterface(IMFMediaEngine *iface, REFIID riid, void **obj) {
struct media_engine *engine = impl_from_IMFMediaEngine(iface);
TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), obj); if (IsEqualIID(riid, &IID_IMFMediaEngine) || IsEqualIID(riid, &IID_IUnknown)) { *obj = iface;
IMFMediaEngine_AddRef(iface);
return S_OK;
- }
- else if (IsEqualIID(riid, &IID_IMFGetService))
- {
*obj = &engine->IMFGetService_iface;
- }
- else
- {
WARN("Unsupported interface %s.\n", debugstr_guid(riid));
*obj = NULL;
return E_NOINTERFACE; }
- WARN("Unsupported interface %s.\n", debugstr_guid(riid));
- *obj = NULL;
- return E_NOINTERFACE;
IUnknown_AddRef((IUnknown *)*obj);
return S_OK; }
static ULONG WINAPI media_engine_AddRef(IMFMediaEngine *iface)
@@ -2288,6 +2303,40 @@ static const IMFMediaEngineVtbl media_engine_vtbl = media_engine_OnVideoStreamTick, };
+static HRESULT WINAPI media_engine_gs_QueryInterface(IMFGetService *iface, REFIID riid, void **obj) +{
- struct media_engine *engine = impl_from_IMFGetService(iface);
- return IMFMediaEngine_QueryInterface(&engine->IMFMediaEngine_iface, riid, obj);
+}
+static ULONG WINAPI media_engine_gs_AddRef(IMFGetService *iface) +{
- struct media_engine *engine = impl_from_IMFGetService(iface);
- return IMFMediaEngine_AddRef(&engine->IMFMediaEngine_iface);
+}
+static ULONG WINAPI media_engine_gs_Release(IMFGetService *iface) +{
- struct media_engine *engine = impl_from_IMFGetService(iface);
- return IMFMediaEngine_Release(&engine->IMFMediaEngine_iface);
+}
+static HRESULT WINAPI media_engine_gs_GetService(IMFGetService *iface, REFGUID service,
REFIID riid, void **object)
+{
- FIXME("%p, %s, %s, %p stub.\n", iface, debugstr_guid(service), debugstr_guid(riid), object);
- return E_NOTIMPL;
+}
+static const IMFGetServiceVtbl media_engine_get_service_vtbl = +{
- media_engine_gs_QueryInterface,
- media_engine_gs_AddRef,
- media_engine_gs_Release,
- media_engine_gs_GetService,
+};
- static HRESULT WINAPI media_engine_grabber_callback_QueryInterface(IMFSampleGrabberSinkCallback *iface, REFIID riid, void **obj) {
@@ -2442,6 +2491,7 @@ static HRESULT init_media_engine(DWORD flags, IMFAttributes *attributes, struct HRESULT hr;
engine->IMFMediaEngine_iface.lpVtbl = &media_engine_vtbl;
- engine->IMFGetService_iface.lpVtbl = &media_engine_get_service_vtbl; engine->session_events.lpVtbl = &media_engine_session_events_vtbl; engine->load_handler.lpVtbl = &media_engine_load_handler_vtbl; engine->grabber_callback.lpVtbl = &media_engine_grabber_callback_vtbl;
diff --git a/dlls/mfmediaengine/tests/mfmediaengine.c b/dlls/mfmediaengine/tests/mfmediaengine.c index 096f6e3f2a5..ea63d4e284f 100644 --- a/dlls/mfmediaengine/tests/mfmediaengine.c +++ b/dlls/mfmediaengine/tests/mfmediaengine.c @@ -46,6 +46,21 @@ static void _expect_ref(IUnknown *obj, ULONG ref, int line) ok_(__FILE__,line)(rc == ref, "Unexpected refcount %d, expected %d.\n", rc, ref); }
+#define check_interface(a, b, c) check_interface_(__LINE__, a, b, c) +static void check_interface_(unsigned int line, void *iface_ptr, REFIID iid, BOOL supported) +{
- IUnknown *iface = iface_ptr;
- HRESULT hr, expected_hr;
- IUnknown *unk;
- expected_hr = supported ? S_OK : E_NOINTERFACE;
- hr = IUnknown_QueryInterface(iface, iid, (void **)&unk);
- ok_(__FILE__, line)(hr == expected_hr, "Got hr %#x, expected %#x.\n", hr, expected_hr);
- if (SUCCEEDED(hr))
IUnknown_Release(unk);
+}
- static void init_functions(void) { HMODULE mod = GetModuleHandleA("mfplat.dll");
@@ -184,6 +199,7 @@ 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);
@@ -227,6 +243,9 @@ static void test_CreateInstance(void) hr = IMFMediaEngineClassFactory_CreateInstance(factory, MF_MEDIA_ENGINE_WAITFORSTABLE_STATE, attributes, &media_engine); ok(hr == S_OK, "Failed to create media engine, hr %#x.\n", hr);
- check_interface(media_engine, &IID_IMFMediaEngine, TRUE);
- check_interface(media_engine, &IID_IMFGetService, TRUE);
IMFMediaEngine_Release(media_engine); IMFAttributes_Release(attributes); IMFDXGIDeviceManager_Release(manager);
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=105482
Your paranoid android.
=== w8 (32 bit report) ===
mfmediaengine: mfmediaengine.c:247: Test failed: Got hr 0x80004002, expected 0.
=== w8adm (32 bit report) ===
mfmediaengine: mfmediaengine.c:247: Test failed: Got hr 0x80004002, expected 0.
=== w864 (32 bit report) ===
mfmediaengine: mfmediaengine.c:247: Test failed: Got hr 0x80004002, expected 0.
=== w864 (64 bit report) ===
mfmediaengine: mfmediaengine.c:247: Test failed: Got hr 0x80004002, expected 0.