[phonon] phonon: Remove runtime backend switching

Harald Sitter sitter at kde.org
Mon Apr 25 18:43:27 CEST 2011


Git commit ee124b2d6566b75197b7f2124a9ffcd20cc152e9 by Harald Sitter.
Committed on 25/04/2011 at 18:31.
Pushed by sitter into branch 'master'.

Remove runtime backend switching

This was causing super horrible issues as it gets somewhat ugly when
phonon does not destruct the backend objects completely.
In the past this caused various problems (e.g. in gst callbacks to
objects that were not existing anymore) as well as recreatable
crashes on switching itself, not just of the KCM but *all*
currently running Phonon applications.
Generally speaking it required the backends to implement object
tracking as to destroy the whole backend graph upon backend switch,
which was only implemented in Xine and even there was insanely
complicated given the use.

Talking about use... it was agreed that the benefit of runtime
switching does not justify the work involved to implement and
support across multiple backends. Additionally switching the backend
ought not be something you do every day, but ultimately not ever as
the default backend installed by the user or the distributor should
be of sufficient stability and use. Should this not be the case it
*must* be considered a bug and treated as such. Working around by
switching to another backend does not contribute to the long-term
user experience in any way.

The implementation at hand replaces the backend switching logic with
a QMessageBox informing the user that she will have to restart the
application in order to apply the backend change.
In KDE 4.7's Phonon KCM we will introduce a more visually compelling
way of feedback. Unfortunately, as to maintain support for older
releases both the DBus interface and the handler function must remain
present to provide the silly messagebox feedback :S

BUG: 210427
FIXED-IN: 4.6.0
CCMAIL: kde-multimedia at kde.org
CCMAIL: phonon-backends at kde.org
CCMAIL: kde-devel at kde.org

M  +11   -23   phonon/factory.cpp     

http://commits.kde.org/phonon/ee124b2d6566b75197b7f2124a9ffcd20cc152e9

diff --git a/phonon/factory.cpp b/phonon/factory.cpp
index c83b6ec..38acce7 100644
--- a/phonon/factory.cpp
+++ b/phonon/factory.cpp
@@ -39,6 +39,8 @@
 #ifndef QT_NO_DBUS
 #include <QtDBus/QtDBus>
 #endif
+#include <QtGui/QApplication>
+#include <QtGui/QMessageBox>
 
 QT_BEGIN_NAMESPACE
 
@@ -289,29 +291,15 @@ void Factory::deregisterFrontendObject(MediaNodePrivate *bp)
 #ifndef QT_NO_DBUS
 void FactoryPrivate::phononBackendChanged()
 {
-    if (m_backendObject) {
-        for (int i = 0; i < mediaNodePrivateList.count(); ++i) {
-            mediaNodePrivateList.at(i)->deleteBackendObject();
-        }
-        if (objects.size() > 0) {
-            pDebug() << "WARNING: we were asked to change the backend but the application did\n"
-                "not free all references to objects created by the factory. Therefore we can not\n"
-                "change the backend without crashing. Now we have to wait for a restart to make\n"
-                "backendswitching possible.";
-            // in case there were objects deleted give 'em a chance to recreate
-            // them now
-            for (int i = 0; i < mediaNodePrivateList.count(); ++i) {
-                mediaNodePrivateList.at(i)->createBackendObject();
-            }
-            return;
-        }
-        delete m_backendObject;
-        m_backendObject = 0;
-    }
-    createBackend();
-    for (int i = 0; i < mediaNodePrivateList.count(); ++i) {
-        mediaNodePrivateList.at(i)->createBackendObject();
-    }
+#ifdef __GNUC__
+#warning TODO hyperspeed: the message box only ought to be shown once and not for \
+    every backend switch
+#endif
+    QMessageBox::information(qApp->activeWindow(),
+                             tr("Restart Application"),
+                             tr("You changed the backend of the Phonon multimedia system.\n\n"
+                                "To apply this change you will need to"
+                                " restart '%1'.").arg(qAppName()));
     emit backendChanged();
 }
 #endif //QT_NO_DBUS


More information about the Phonon-backends mailing list