bool AbstractMediaStream2::event(QEvent *e) { if (e->type() == QEvent::ThreadChange) { Q_D(AbstractMediaStream2); if (d->eventDispatcher) { pWarning() << "Do not call moveToThread on an AbstractMediaStream2 object when it is in use."; QObject::disconnect(d->eventDispatcher, SIGNAL(awake()), this, SLOT(_k_handleStreamEvent())); d->eventDispatcher = 0; } } return AbstractMediaStream::event(e); }
void MediaObject::setCurrentSource(const MediaSource &newSource) { K_D(MediaObject); if (!k_ptr->backendObject()) { d->mediaSource = newSource; return; } pDebug() << Q_FUNC_INFO << newSource.url(); stop(); // first call stop as that often is the expected state // for setting a new URL MediaSource::Type oldSourceType = d->mediaSource.type(); d->mediaSource = newSource; d->kiofallback = 0; // kiofallback auto-deletes //X if (url.scheme() == "http") { //X d->kiofallback = Platform::createMediaStream(url, this); //X if (d->kiofallback) { //X ... //X return; //X } //X } if (d->mediaSource.type() == MediaSource::Stream) { Q_ASSERT(d->mediaSource.stream()); d->mediaSource.stream()->d_func()->setMediaObjectPrivate(d); } else if (d->mediaSource.type() == MediaSource::Invalid) { pWarning() << "requested invalid MediaSource for the current source of MediaObject"; return; } if (d->mediaSource.type() == MediaSource::Url && oldSourceType != MediaSource::Url) { disconnect(d->m_backendObject, SIGNAL(stateChanged(Phonon::State, Phonon::State)), this, SIGNAL(stateChanged(Phonon::State, Phonon::State))); connect(d->m_backendObject, SIGNAL(stateChanged(Phonon::State, Phonon::State)), this, SLOT(_k_stateChanged(Phonon::State, Phonon::State))); } else if (d->mediaSource.type() != MediaSource::Url && oldSourceType == MediaSource::Url) { disconnect(d->m_backendObject, SIGNAL(stateChanged(Phonon::State, Phonon::State)), this, SLOT(_k_stateChanged(Phonon::State, Phonon::State))); connect(d->m_backendObject, SIGNAL(stateChanged(Phonon::State, Phonon::State)), this, SIGNAL(stateChanged(Phonon::State, Phonon::State))); } INTERFACE_CALL(setSource(d->mediaSource)); }
PlatformPlugin *FactoryPrivate::platformPlugin() { if (m_platformPlugin) { return m_platformPlugin; } if (m_noPlatformPlugin) { return 0; } #ifndef QT_NO_DBUS if (!QCoreApplication::instance() || QCoreApplication::applicationName().isEmpty()) { pWarning() << "Phonon needs QCoreApplication::applicationName to be set to export audio output names through the DBUS interface"; } #endif Q_ASSERT(QCoreApplication::instance()); const QByteArray platform_plugin_env = qgetenv("PHONON_PLATFORMPLUGIN"); if (!platform_plugin_env.isEmpty()) { QPluginLoader pluginLoader(QString::fromLocal8Bit(platform_plugin_env.constData())); if (pluginLoader.load()) { m_platformPlugin = qobject_cast<PlatformPlugin *>(pluginLoader.instance()); if (m_platformPlugin) { return m_platformPlugin; } } } const QString suffix(QLatin1String("/phonon_platform/")); ensureLibraryPathSet(); QDir dir; dir.setNameFilters( !qgetenv("KDE_FULL_SESSION").isEmpty() ? QStringList(QLatin1String("kde.*")) : (!qgetenv("GNOME_DESKTOP_SESSION_ID").isEmpty() ? QStringList(QLatin1String("gnome.*")) : QStringList()) ); dir.setFilter(QDir::Files); const QStringList libPaths = QCoreApplication::libraryPaths(); forever { for (int i = 0; i < libPaths.count(); ++i) { const QString libPath = libPaths.at(i) + suffix; dir.setPath(libPath); if (!dir.exists()) { continue; } 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 << " platform plugin load failed:" << pluginLoader.errorString(); continue; } pDebug() << pluginLoader.instance(); QObject *qobj = pluginLoader.instance(); m_platformPlugin = qobject_cast<PlatformPlugin *>(qobj); pDebug() << m_platformPlugin; if (m_platformPlugin) { connect(qobj, SIGNAL(objectDescriptionChanged(ObjectDescriptionType)), SLOT(objectDescriptionChanged(ObjectDescriptionType))); return m_platformPlugin; } else { delete qobj; pDebug() << Q_FUNC_INFO << dir.absolutePath() << "exists but the platform plugin was not loadable:" << pluginLoader.errorString(); pluginLoader.unload(); } } } if (dir.nameFilters().isEmpty()) { break; } dir.setNameFilters(QStringList()); } pDebug() << Q_FUNC_INFO << "platform plugin could not be loaded"; m_noPlatformPlugin = true; return 0; }
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 }