diff options
author | Ling Hu <ling.hu@nokia.com> | 2012-06-28 15:27:13 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-06-29 05:59:46 +0200 |
commit | eb5b216ac42da2dfb2479ad0f1b140665e3268a3 (patch) | |
tree | be625dc159dd5653ad095103ad22c37d2ecacdf1 /src/plugins/wmf/wmfserviceplugin.cpp | |
parent | 340f18d4b5b43408c501772b581088b4aba387e9 (diff) |
Refactoring wmf plugin
make mf startup/shutdwon inside plugin instead of player component
make sourceresolver a common component for a wmf related tasks.
Change-Id: I49cdc4fa512a62398a68cd2be2f522f567d11c7c
Reviewed-by: Michael Goddard <michael.goddard@nokia.com>
Diffstat (limited to 'src/plugins/wmf/wmfserviceplugin.cpp')
-rw-r--r-- | src/plugins/wmf/wmfserviceplugin.cpp | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/src/plugins/wmf/wmfserviceplugin.cpp b/src/plugins/wmf/wmfserviceplugin.cpp index 34536ba96..a796b81ea 100644 --- a/src/plugins/wmf/wmfserviceplugin.cpp +++ b/src/plugins/wmf/wmfserviceplugin.cpp @@ -48,19 +48,46 @@ #include "mfplayerservice.h" #endif +#include <mfapi.h> + +namespace +{ +static int g_refCount = 0; +void addRefCount() +{ + g_refCount++; + if (g_refCount == 1) { + CoInitialize(NULL); + MFStartup(MF_VERSION); + } +} + +void releaseRefCount() +{ + g_refCount--; + if (g_refCount == 0) { + MFShutdown(); + CoUninitialize(); + } +} + +} + QMediaService* WMFServicePlugin::create(QString const& key) { #ifdef QMEDIA_MEDIAFOUNDATION_PLAYER - if (key == QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER)) + if (key == QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER)) { + addRefCount(); return new MFPlayerService; + } #endif - //qDebug() << "unsupported key:" << key; return 0; } void WMFServicePlugin::release(QMediaService *service) { + releaseRefCount(); delete service; } |