mfmediaengine: Duplicate configuration attributes.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2020-06-02 12:35:13 +03:00 committed by Alexandre Julliard
parent 13aafb43a3
commit 4bbb7b6649
2 changed files with 16 additions and 11 deletions

View File

@ -1,6 +1,6 @@
MODULE = mfmediaengine.dll MODULE = mfmediaengine.dll
IMPORTLIB = mfmediaengine IMPORTLIB = mfmediaengine
IMPORTS = mf mfuuid uuid IMPORTS = mfplat mf mfuuid uuid
EXTRADLLFLAGS = -mno-cygwin EXTRADLLFLAGS = -mno-cygwin

View File

@ -23,6 +23,7 @@
#include "windef.h" #include "windef.h"
#include "winbase.h" #include "winbase.h"
#include "mfapi.h"
#include "mfmediaengine.h" #include "mfmediaengine.h"
#include "mferror.h" #include "mferror.h"
#include "dxgi.h" #include "dxgi.h"
@ -72,9 +73,7 @@ struct media_engine
IMFAsyncCallback session_events; IMFAsyncCallback session_events;
LONG refcount; LONG refcount;
IMFMediaEngineNotify *callback; IMFMediaEngineNotify *callback;
UINT64 playback_hwnd; IMFAttributes *attributes;
DXGI_FORMAT output_format;
IMFDXGIDeviceManager *dxgi_manager;
enum media_engine_mode mode; enum media_engine_mode mode;
unsigned int flags; unsigned int flags;
double playback_rate; double playback_rate;
@ -192,10 +191,10 @@ static void free_media_engine(struct media_engine *engine)
{ {
if (engine->callback) if (engine->callback)
IMFMediaEngineNotify_Release(engine->callback); IMFMediaEngineNotify_Release(engine->callback);
if (engine->dxgi_manager)
IMFDXGIDeviceManager_Release(engine->dxgi_manager);
if (engine->session) if (engine->session)
IMFMediaSession_Release(engine->session); IMFMediaSession_Release(engine->session);
if (engine->attributes)
IMFAttributes_Release(engine->attributes);
DeleteCriticalSection(&engine->cs); DeleteCriticalSection(&engine->cs);
heap_free(engine); heap_free(engine);
} }
@ -750,6 +749,8 @@ static ULONG WINAPI media_engine_factory_Release(IMFMediaEngineClassFactory *ifa
static HRESULT init_media_engine(DWORD flags, IMFAttributes *attributes, struct media_engine *engine) static HRESULT init_media_engine(DWORD flags, IMFAttributes *attributes, struct media_engine *engine)
{ {
DXGI_FORMAT output_format;
UINT64 playback_hwnd;
HRESULT hr; HRESULT hr;
engine->IMFMediaEngine_iface.lpVtbl = &media_engine_vtbl; engine->IMFMediaEngine_iface.lpVtbl = &media_engine_vtbl;
@ -772,11 +773,15 @@ static HRESULT init_media_engine(DWORD flags, IMFAttributes *attributes, struct
if (FAILED(hr = IMFMediaSession_BeginGetEvent(engine->session, &engine->session_events, NULL))) if (FAILED(hr = IMFMediaSession_BeginGetEvent(engine->session, &engine->session_events, NULL)))
return hr; return hr;
IMFAttributes_GetUINT64(attributes, &MF_MEDIA_ENGINE_PLAYBACK_HWND, &engine->playback_hwnd); if (FAILED(hr = MFCreateAttributes(&engine->attributes, 0)))
IMFAttributes_GetUnknown(attributes, &MF_MEDIA_ENGINE_DXGI_MANAGER, &IID_IMFDXGIDeviceManager, return hr;
(void **)&engine->dxgi_manager);
hr = IMFAttributes_GetUINT32(attributes, &MF_MEDIA_ENGINE_VIDEO_OUTPUT_FORMAT, &engine->output_format); if (FAILED(hr = IMFAttributes_CopyAllItems(attributes, engine->attributes)))
if (engine->playback_hwnd) /* FIXME: handle MF_MEDIA_ENGINE_PLAYBACK_VISUAL */ return hr;
IMFAttributes_GetUINT64(attributes, &MF_MEDIA_ENGINE_PLAYBACK_HWND, &playback_hwnd);
hr = IMFAttributes_GetUINT32(attributes, &MF_MEDIA_ENGINE_VIDEO_OUTPUT_FORMAT, &output_format);
if (playback_hwnd) /* FIXME: handle MF_MEDIA_ENGINE_PLAYBACK_VISUAL */
engine->mode = MEDIA_ENGINE_RENDERING_MODE; engine->mode = MEDIA_ENGINE_RENDERING_MODE;
else else
{ {