Nikolay Sivov : mfplay: Automatically initialize Media Foundation.
Alexandre Julliard
julliard at winehq.org
Mon Apr 5 16:28:24 CDT 2021
Module: wine
Branch: master
Commit: 2efb464bab2752bf63453244a63c4243e66d154f
URL: https://source.winehq.org/git/wine.git/?a=commit;h=2efb464bab2752bf63453244a63c4243e66d154f
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Mon Apr 5 09:10:58 2021 +0300
mfplay: Automatically initialize Media Foundation.
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/mfplay/Makefile.in | 2 +-
dlls/mfplay/player.c | 19 +++++++++++++++++++
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/dlls/mfplay/Makefile.in b/dlls/mfplay/Makefile.in
index b21ce0e2161..91a8e5cc5a6 100644
--- a/dlls/mfplay/Makefile.in
+++ b/dlls/mfplay/Makefile.in
@@ -1,6 +1,6 @@
MODULE = mfplay.dll
IMPORTLIB = mfplay
-IMPORTS = uuid mfuuid
+IMPORTS = mfplat uuid mfuuid
EXTRADLLFLAGS = -mno-cygwin -Wb,--prefer-native
diff --git a/dlls/mfplay/player.c b/dlls/mfplay/player.c
index 6905812835a..0305f663924 100644
--- a/dlls/mfplay/player.c
+++ b/dlls/mfplay/player.c
@@ -22,6 +22,7 @@
#include "windef.h"
#include "winbase.h"
+#include "mfapi.h"
#include "mfplay.h"
#include "wine/debug.h"
@@ -29,6 +30,20 @@
WINE_DEFAULT_DEBUG_CHANNEL(mfplat);
+static LONG startup_refcount;
+
+static void platform_startup(void)
+{
+ if (InterlockedIncrement(&startup_refcount) == 1)
+ MFStartup(MF_VERSION, MFSTARTUP_FULL);
+}
+
+static void platform_shutdown(void)
+{
+ if (InterlockedDecrement(&startup_refcount) == 0)
+ MFShutdown();
+}
+
struct media_player
{
IMFPMediaPlayer IMFPMediaPlayer_iface;
@@ -81,6 +96,8 @@ static ULONG WINAPI media_player_Release(IMFPMediaPlayer *iface)
if (player->callback)
IMFPMediaPlayerCallback_Release(player->callback);
heap_free(player);
+
+ platform_shutdown();
}
return refcount;
@@ -405,6 +422,8 @@ HRESULT WINAPI MFPCreateMediaPlayer(const WCHAR *url, BOOL start_playback, MFP_C
if (object->callback)
IMFPMediaPlayerCallback_AddRef(object->callback);
+ platform_startup();
+
*player = &object->IMFPMediaPlayer_iface;
return S_OK;
More information about the wine-cvs
mailing list