Commit 2efb464b authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

mfplay: Automatically initialize Media Foundation.

parent 97ed08cb
MODULE = mfplay.dll
IMPORTLIB = mfplay
IMPORTS = uuid mfuuid
IMPORTS = mfplat uuid mfuuid
EXTRADLLFLAGS = -mno-cygwin -Wb,--prefer-native
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment