Пример #1
0
void Platform::saveVolume(const QString &outputName, qreal volume)
{
#ifndef QT_NO_PHONON_PLATFORMPLUGIN
    PlatformPlugin *f = Factory::platformPlugin();
    if (f) {
        f->saveVolume(outputName, volume);
    }
#else
    Q_UNUSED(outputName);
    Q_UNUSED(volume);
#endif //QT_NO_PHONON_PLATFORMPLUGIN
}
bool Factory::isMimeTypeAvailable(const QString &mimeType)
{
#ifndef QT_NO_PHONON_PLATFORMPLUGIN
    PlatformPlugin *f = globalFactory->platformPlugin();
    if (f) {
        return f->isMimeTypeAvailable(mimeType);
    }
#else
    Q_UNUSED(mimeType);
#endif //QT_NO_PHONON_PLATFORMPLUGIN
    return true; // the MIME type might be supported, let BackendCapabilities find out
}
Пример #3
0
AbstractMediaStream *Platform::createMediaStream(const QUrl &url, QObject *parent)
{
#ifndef QT_NO_PHONON_PLATFORMPLUGIN
    PlatformPlugin *f = Factory::platformPlugin();
    if (f) {
        return f->createMediaStream(url, parent);
    }
#else
    Q_UNUSED(url);
    Q_UNUSED(parent);
#endif //QT_NO_PHONON_PLATFORMPLUGIN
    return 0;
}
bool FactoryPrivate::createBackend()
{
    Q_ASSERT(m_backendObject == 0);
#ifndef QT_NO_PHONON_PLATFORMPLUGIN
    PlatformPlugin *f = globalFactory->platformPlugin();
    if (f) {
        m_backendObject = f->createBackend();
    }
#endif //QT_NO_PHONON_PLATFORMPLUGIN
    if (!m_backendObject) {
        ensureLibraryPathSet();

        // could not load a backend through the platform plugin. Falling back to the default
        // (finding the first loadable backend).
        const QLatin1String suffix("/phonon_backend/");
        foreach (QString libPath, QCoreApplication::libraryPaths()) {
            libPath += suffix;
            const QDir dir(libPath);
            if (!dir.exists()) {
                pDebug() << Q_FUNC_INFO << dir.absolutePath() << "does not exist";
                continue;
            }
            foreach (const QString &pluginName, dir.entryList(QDir::Files)) {
                QPluginLoader pluginLoader(libPath + pluginName);
                if (!pluginLoader.load()) {
                    pDebug() << Q_FUNC_INFO << "  load failed:"
                             << pluginLoader.errorString();
                    continue;
                }
                pDebug() << pluginLoader.instance();
                m_backendObject = pluginLoader.instance();
                if (m_backendObject) {
                    break;
                }

                // no backend found, don't leave an unused plugin in memory
                pluginLoader.unload();
            }

            if (m_backendObject) {
                break;
            }
        }
Пример #5
0
ObjectDescriptionData *ObjectDescriptionData::fromIndex(ObjectDescriptionType type, int index)
{
    bool is_audio_device = (AudioOutputDeviceType == type || AudioCaptureDeviceType == type);

    PulseSupport *pulse = PulseSupport::getInstance();
    if (is_audio_device && pulse->isActive()) {
        QList<int> indexes = pulse->objectDescriptionIndexes(type);
        if (indexes.contains(index)) {
            QHash<QByteArray, QVariant> properties = pulse->objectDescriptionProperties(type, index);
            return new ObjectDescriptionData(index, properties);
        }
    } else {
        BackendInterface *iface = qobject_cast<BackendInterface *>(Factory::backend());

        // prefer to get the ObjectDescriptionData from the platform plugin for audio devices
#ifndef QT_NO_PHONON_PLATFORMPLUGIN
        if (is_audio_device) {
            PlatformPlugin *platformPlugin = Factory::platformPlugin();
            if (platformPlugin) {
                QList<int> indexes = platformPlugin->objectDescriptionIndexes(type);
                if (indexes.contains(index)) {
                    QHash<QByteArray, QVariant> properties = platformPlugin->objectDescriptionProperties(type, index);
                    return new ObjectDescriptionData(index, properties);
                }
            }
        }
#endif //QT_NO_PHONON_PLATFORMPLUGIN

        if (iface) {
            QList<int> indexes = iface->objectDescriptionIndexes(type);
            if (indexes.contains(index)) {
                QHash<QByteArray, QVariant> properties = iface->objectDescriptionProperties(type, index);
                return new ObjectDescriptionData(index, properties);
            }
        }
    }
    return new ObjectDescriptionData(0); // invalid
}
bool FactoryPrivate::createBackend()
{
#ifndef QT_NO_LIBRARY
    Q_ASSERT(m_backendObject == 0);
#ifndef QT_NO_PHONON_PLATFORMPLUGIN
    PlatformPlugin *f = globalFactory->platformPlugin();
    if (f) {
        m_backendObject = f->createBackend();
    }
#endif //QT_NO_PHONON_PLATFORMPLUGIN
    if (!m_backendObject) {
        ensureLibraryPathSet();

        // could not load a backend through the platform plugin. Falling back to the default
        // (finding the first loadable backend).
        const QLatin1String suffix("/phonon_backend/");
        const QStringList paths = QCoreApplication::libraryPaths();
        for (int i = 0; i < paths.count(); ++i) {
            const QString libPath = paths.at(i) + suffix;
            const QDir dir(libPath);
            if (!dir.exists()) {
                pDebug() << Q_FUNC_INFO << dir.absolutePath() << "does not exist";
                continue;
            }

            QStringList plugins(dir.entryList(QDir::Files));

#ifdef Q_OS_SYMBIAN
            /* On Symbian OS we might have two plugins, one which uses Symbian
             * MMF framework("mmf"), and one which uses Real Networks's
             * Helix("hxphonon"). We prefer the latter because it's more
             * sophisticated, so we make sure the Helix backend is attempted
             * to be loaded first, and the MMF backend is used for backup. */
            {
                const int helix = plugins.indexOf(QLatin1String("hxphonon"));
                if (helix != -1)
                    plugins.move(helix, 0);
            }
#endif

            const QStringList files = dir.entryList(QDir::Files);
            for (int i = 0; i < files.count(); ++i) {
                QPluginLoader pluginLoader(libPath + files.at(i));
                if (!pluginLoader.load()) {
                    pDebug() << Q_FUNC_INFO << "  load failed:"
                             << pluginLoader.errorString();
                    continue;
                }
                pDebug() << pluginLoader.instance();
                m_backendObject = pluginLoader.instance();
                if (m_backendObject) {
                    break;
                }

                // no backend found, don't leave an unused plugin in memory
                pluginLoader.unload();
            }

            if (m_backendObject) {
                break;
            }
        }
        if (!m_backendObject) {
            pWarning() << Q_FUNC_INFO << "phonon backend plugin could not be loaded";
            return false;
        }
    }

    connect(m_backendObject, SIGNAL(objectDescriptionChanged(ObjectDescriptionType)),
            SLOT(objectDescriptionChanged(ObjectDescriptionType)));

    return true;
#else //QT_NO_LIBRARY
    pWarning() << Q_FUNC_INFO << "Trying to use Phonon with QT_NO_LIBRARY defined. "
                                 "That is currently not supported";
    return false;
#endif
}