Minor improvements on resource-policy interfaces

Change-Id: I3e9c7c4d1fca90e0fb97b0058e9b5a5e34940025
Reviewed-by: Michael Goddard <michael.goddard@nokia.com>
Reviewed-by: Dmytro Poplavskiy <dmytro.poplavskiy@nokia.com>
Reviewed-by: Jonas Rabbe <jonas.rabbe@nokia.com>
This commit is contained in:
Ling Hu
2012-03-26 10:51:14 +10:00
committed by Qt by Nokia
parent 45bd0d938e
commit 6e177b4dce
5 changed files with 16 additions and 7 deletions

View File

@@ -86,9 +86,10 @@ QObject* QMediaResourcePolicy::createResourceSet(const QString& interfaceId)
QMediaResourceSetFactoryInterface *factory =
qobject_cast<QMediaResourceSetFactoryInterface*>(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<QMediaResourceSetFactoryInterface*>(resourcePolicyLoader()
->instance(QLatin1String("default")));
Q_ASSERT(factory);
if (!factory)
return;
return factory->destroy(resourceSet);

View File

@@ -55,16 +55,16 @@ class Q_MULTIMEDIA_EXPORT QMediaResourcePolicy
public:
//a dummy object will always be provided if the interfaceId is not supported
template<typename T>
static T* createResourceSet(const QString& interfaceId);
static T* createResourceSet();
static void destroyResourceSet(QObject* resourceSet);
private:
static QObject* createResourceSet(const QString& interfaceId);
};
template<typename T>
T* QMediaResourcePolicy::createResourceSet(const QString& interfaceId)
T* QMediaResourcePolicy::createResourceSet()
{
return qobject_cast<T*>(QMediaResourcePolicy::createResourceSet(interfaceId));
return qobject_cast<T*>(QMediaResourcePolicy::createResourceSet(T::iid()));
}
QT_END_NAMESPACE

View File

@@ -48,4 +48,9 @@ QMediaPlayerResourceSetInterface::QMediaPlayerResourceSetInterface(QObject *pare
{
}
QString QMediaPlayerResourceSetInterface::iid()
{
return QString(QMediaPlayerResourceSetInterface_iid);
}
QT_END_NAMESPACE

View File

@@ -65,6 +65,8 @@ public:
virtual void release() = 0;
virtual void setVideoEnabled(bool enabled) = 0;
static QString iid();
Q_SIGNALS:
void resourcesGranted();
void resourcesLost();