Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/evr/Makefile.in | 2 +- dlls/evr/presenter.c | 21 ++++++++++++++++++++- dlls/evr/tests/evr.c | 37 +++++++++++++++++++++++++++++++++++-- 3 files changed, 56 insertions(+), 4 deletions(-)
diff --git a/dlls/evr/Makefile.in b/dlls/evr/Makefile.in index c8178297dab..6d936d65b79 100644 --- a/dlls/evr/Makefile.in +++ b/dlls/evr/Makefile.in @@ -1,6 +1,6 @@ MODULE = evr.dll IMPORTLIB = evr -IMPORTS = mfuuid strmiids strmbase uuid dxguid ole32 oleaut32 +IMPORTS = mfuuid strmiids strmbase uuid dxguid ole32 oleaut32 dxva2 DELAYIMPORTS = mfplat
EXTRADLLFLAGS = -mno-cygwin diff --git a/dlls/evr/presenter.c b/dlls/evr/presenter.c index 5e458f72f11..b60de4b82a1 100644 --- a/dlls/evr/presenter.c +++ b/dlls/evr/presenter.c @@ -22,6 +22,7 @@ #include "d3d9.h" #include "mfapi.h" #include "mferror.h" +#include "dxva2api.h"
#include "evr_classes.h" #include "evr_private.h" @@ -55,6 +56,8 @@ struct video_presenter IMFClock *clock; IMediaEventSink *event_sink;
+ IDirect3DDeviceManager9 *device_manager; + UINT reset_token; unsigned int state; CRITICAL_SECTION cs; }; @@ -174,6 +177,8 @@ static ULONG WINAPI video_presenter_inner_Release(IUnknown *iface) { video_presenter_clear_container(presenter); DeleteCriticalSection(&presenter->cs); + if (presenter->device_manager) + IDirect3DDeviceManager9_Release(presenter->device_manager); heap_free(presenter); }
@@ -606,7 +611,14 @@ static ULONG WINAPI video_presenter_getservice_Release(IMFGetService *iface)
static HRESULT WINAPI video_presenter_getservice_GetService(IMFGetService *iface, REFGUID service, REFIID riid, void **obj) { - FIXME("%p, %s, %s, %p.\n", iface, debugstr_guid(service), debugstr_guid(riid), obj); + struct video_presenter *presenter = impl_from_IMFGetService(iface); + + TRACE("%p, %s, %s, %p.\n", iface, debugstr_guid(service), debugstr_guid(riid), obj); + + if (IsEqualGUID(&MR_VIDEO_ACCELERATION_SERVICE, service)) + return IDirect3DDeviceManager9_QueryInterface(presenter->device_manager, riid, obj); + + FIXME("Unimplemented service %s.\n", debugstr_guid(service));
return E_NOTIMPL; } @@ -634,6 +646,7 @@ HRESULT WINAPI MFCreateVideoPresenter(IUnknown *owner, REFIID riid_device, REFII HRESULT evr_presenter_create(IUnknown *outer, void **out) { struct video_presenter *object; + HRESULT hr;
if (!(object = heap_alloc_zero(sizeof(*object)))) return E_OUTOFMEMORY; @@ -649,6 +662,12 @@ HRESULT evr_presenter_create(IUnknown *outer, void **out) object->refcount = 1; InitializeCriticalSection(&object->cs);
+ if (FAILED(hr = DXVA2CreateDirect3DDeviceManager9(&object->reset_token, &object->device_manager))) + { + IUnknown_Release(&object->IUnknown_inner); + return hr; + } + *out = &object->IUnknown_inner;
return S_OK; diff --git a/dlls/evr/tests/evr.c b/dlls/evr/tests/evr.c index b59da51e475..0dff691b59f 100644 --- a/dlls/evr/tests/evr.c +++ b/dlls/evr/tests/evr.c @@ -966,9 +966,14 @@ done:
static void test_default_presenter(void) { + D3DDEVICE_CREATION_PARAMETERS device_params = { 0 }; IMFVideoPresenter *presenter; IMFRateSupport *rate_support; + IDirect3DDevice9 *d3d_device; + IDirect3DDeviceManager9 *dm; IMFVideoDeviceID *deviceid; + IMFGetService *gs; + HANDLE handle; IUnknown *unk; float rate; HRESULT hr; @@ -1002,9 +1007,37 @@ static void test_default_presenter(void) ok(hr == S_OK, "Unexpected hr %#x.\n", hr); IUnknown_Release(unk);
- hr = IMFVideoPresenter_QueryInterface(presenter, &IID_IMFGetService, (void **)&unk); + hr = IMFVideoPresenter_QueryInterface(presenter, &IID_IMFGetService, (void **)&gs); ok(hr == S_OK, "Unexpected hr %#x.\n", hr); - IUnknown_Release(unk); + + hr = IMFGetService_GetService(gs, &MR_VIDEO_ACCELERATION_SERVICE, &IID_IDirect3DDeviceManager9, (void **)&dm); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = IDirect3DDeviceManager9_OpenDeviceHandle(dm, &handle); +todo_wine + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = IDirect3DDeviceManager9_LockDevice(dm, handle, &d3d_device, FALSE); +todo_wine + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + +if (SUCCEEDED(hr)) +{ + hr = IDirect3DDevice9_GetCreationParameters(d3d_device, &device_params); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + ok(device_params.hFocusWindow == GetDesktopWindow(), "Unexpected window %p.\n", device_params.hFocusWindow); + + IDirect3DDevice9_Release(d3d_device); + + hr = IDirect3DDeviceManager9_UnlockDevice(dm, handle, FALSE); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = IDirect3DDeviceManager9_CloseDeviceHandle(dm, handle); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); +} + IDirect3DDeviceManager9_Release(dm); + + IMFGetService_Release(gs);
/* Rate support. */ hr = IMFVideoPresenter_QueryInterface(presenter, &IID_IMFRateSupport, (void **)&rate_support);