mfplay: Automatically initialize Media Foundation.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
97ed08cb52
commit
2efb464bab
|
@ -1,6 +1,6 @@
|
|||
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;
|
||||
|
|
Loading…
Reference in New Issue