From d962e54294f2b9e952cd013ba5fb12764d0ac0dc Mon Sep 17 00:00:00 2001 From: Christian Esken Date: Mon, 4 Feb 2013 23:20:57 +0100 Subject: [PATCH 1/8] MPRIS2 backend now does a asynchonous DBUS instrospection CCBUGS: 311189 --- backends/mixer_mpris2.cpp | 51 +++++++++++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 17 deletions(-) diff --git a/backends/mixer_mpris2.cpp b/backends/mixer_mpris2.cpp index 9b2adca..88e0a86 100644 --- a/backends/mixer_mpris2.cpp +++ b/backends/mixer_mpris2.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include @@ -241,18 +242,34 @@ int Mixer_MPRIS2::addAllRunningPlayersAndInitHotplug() * There is no simple solution (reversing could have the problem of not-adding), so we live for now with it. */ - QDBusReply repl = dbusConn.interface()->registeredServiceNames(); + /* + * Bug 311189: Introspecting via "dbusConn.interface()->registeredServiceNames()" does not work too well in + * specific scenarios. Thus I now do a hand crafted 3-line asynchronous version of registeredServiceNames(). + */ + QDBusInterface dbusIfc("org.freedesktop.DBus", "/org/freedesktop/DBus", + "org.freedesktop.DBus", dbusConn); + QDBusPendingReply repl = dbusIfc.asyncCall("ListNames"); + repl.waitForFinished(); + if ( repl.isValid() ) { + qDebug() << "Attaching Media Players"; QStringList result = repl.value(); QString s; foreach ( s , result ) { if ( s.startsWith("org.mpris.MediaPlayer2") ) + { addMprisControl(dbusConn, s); + kDebug() << "Attached " << s; + } } } + else + { + kError() << "Invalid reply while listing Media Players" << repl.error(); + } return 0; @@ -275,19 +292,19 @@ void Mixer_MPRIS2::addMprisControl(QDBusConnection& conn, QString busDestination int lastDot = busDestination.lastIndexOf('.'); QString id = ( lastDot == -1 ) ? busDestination : busDestination.mid(lastDot+1); kDebug(67100) << "Get control of " << busDestination << "id=" << id; - if (id.startsWith("clementine")) - { - // Bug 311189: Clementine hangs - QString text; - text = - i18n( - "Media player '%1' is not compatible with KMix. Integration skipped.", - id); - // We cannot do GUI stuff in the backend, so lets only log it for now -// KMixToolBox::notification("Unsupported Media Player", text); - kWarning() << text; - return; - } +// if (id.startsWith("clementine")) +// { +// // Bug 311189: Clementine hangs +// QString text; +// text = +// i18n( +// "Media player '%1' is not compatible with KMix. Integration skipped.", +// id); +// // We cannot do GUI stuff in the backend, so lets only log it for now +//// KMixToolBox::notification("Unsupported Media Player", text); +// kWarning() << text; +// return; +// } QDBusInterface *qdbiProps = new QDBusInterface(QString(busDestination), QString("/org/mpris/MediaPlayer2"), "org.freedesktop.DBus.Properties", conn, this); @@ -302,8 +319,8 @@ void Mixer_MPRIS2::addMprisControl(QDBusConnection& conn, QString busDestination QString readableName = id; - if (id != "clementine") - { +// if (id != "clementine") +// { QList arg; arg.append(QString("org.mpris.MediaPlayer2")); arg.append(QString("Identity")); @@ -328,7 +345,7 @@ void Mixer_MPRIS2::addMprisControl(QDBusConnection& conn, QString busDestination { qWarning() << "Error (" << msg.type() << "): " << msg.errorName() << " " << msg.errorMessage(); } - } +// } // TODO This hardcoded application list is a quick hack. It should be generalized. MixDevice::ChannelType ct = MixDevice::APPLICATION_STREAM; -- 1.8.1.4