From 6e177b4dce1de3ad02b0f10d78e6557303897919 Mon Sep 17 00:00:00 2001 From: Ling Hu Date: Mon, 26 Mar 2012 10:51:14 +1000 Subject: Minor improvements on resource-policy interfaces Change-Id: I3e9c7c4d1fca90e0fb97b0058e9b5a5e34940025 Reviewed-by: Michael Goddard Reviewed-by: Dmytro Poplavskiy Reviewed-by: Jonas Rabbe --- src/multimedia/qmediaresourcepolicy_p.cpp | 8 +++++--- src/multimedia/qmediaresourcepolicy_p.h | 6 +++--- src/multimedia/qmediaresourceset_p.cpp | 5 +++++ src/multimedia/qmediaresourceset_p.h | 2 ++ 4 files changed, 15 insertions(+), 6 deletions(-) (limited to 'src/multimedia') diff --git a/src/multimedia/qmediaresourcepolicy_p.cpp b/src/multimedia/qmediaresourcepolicy_p.cpp index 630870c05..0262c0f85 100644 --- a/src/multimedia/qmediaresourcepolicy_p.cpp +++ b/src/multimedia/qmediaresourcepolicy_p.cpp @@ -86,9 +86,10 @@ QObject* QMediaResourcePolicy::createResourceSet(const QString& interfaceId) QMediaResourceSetFactoryInterface *factory = qobject_cast(resourcePolicyLoader() ->instance(QLatin1String("default"))); - if (!factory) - return 0; - QObject* obj = factory->create(interfaceId); + QObject* obj = 0; + if (factory) + obj = factory->create(interfaceId); + if (!obj) { if (interfaceId == QLatin1String(QMediaPlayerResourceSetInterface_iid)) { obj = new QDummyMediaPlayerResourceSet(dummyRoot()); @@ -107,6 +108,7 @@ void QMediaResourcePolicy::destroyResourceSet(QObject* resourceSet) QMediaResourceSetFactoryInterface *factory = qobject_cast(resourcePolicyLoader() ->instance(QLatin1String("default"))); + Q_ASSERT(factory); if (!factory) return; return factory->destroy(resourceSet); diff --git a/src/multimedia/qmediaresourcepolicy_p.h b/src/multimedia/qmediaresourcepolicy_p.h index c21d36f47..7e9dd03d5 100644 --- a/src/multimedia/qmediaresourcepolicy_p.h +++ b/src/multimedia/qmediaresourcepolicy_p.h @@ -55,16 +55,16 @@ class Q_MULTIMEDIA_EXPORT QMediaResourcePolicy public: //a dummy object will always be provided if the interfaceId is not supported template - static T* createResourceSet(const QString& interfaceId); + static T* createResourceSet(); static void destroyResourceSet(QObject* resourceSet); private: static QObject* createResourceSet(const QString& interfaceId); }; template -T* QMediaResourcePolicy::createResourceSet(const QString& interfaceId) +T* QMediaResourcePolicy::createResourceSet() { - return qobject_cast(QMediaResourcePolicy::createResourceSet(interfaceId)); + return qobject_cast(QMediaResourcePolicy::createResourceSet(T::iid())); } QT_END_NAMESPACE diff --git a/src/multimedia/qmediaresourceset_p.cpp b/src/multimedia/qmediaresourceset_p.cpp index 97aa34d6e..a440c82f5 100644 --- a/src/multimedia/qmediaresourceset_p.cpp +++ b/src/multimedia/qmediaresourceset_p.cpp @@ -48,4 +48,9 @@ QMediaPlayerResourceSetInterface::QMediaPlayerResourceSetInterface(QObject *pare { } +QString QMediaPlayerResourceSetInterface::iid() +{ + return QString(QMediaPlayerResourceSetInterface_iid); +} + QT_END_NAMESPACE diff --git a/src/multimedia/qmediaresourceset_p.h b/src/multimedia/qmediaresourceset_p.h index c58320c27..5070b9499 100644 --- a/src/multimedia/qmediaresourceset_p.h +++ b/src/multimedia/qmediaresourceset_p.h @@ -65,6 +65,8 @@ public: virtual void release() = 0; virtual void setVideoEnabled(bool enabled) = 0; + static QString iid(); + Q_SIGNALS: void resourcesGranted(); void resourcesLost(); -- cgit v1.2.1