Fix the Phonon notification backend not playing any sound
[quassel.git] / src / qtui / phononnotificationbackend.cpp
index bcc7c76..b4adc1c 100644 (file)
@@ -20,8 +20,8 @@
 
 #include <QFileDialog>
 
-#include <Phonon/MediaObject>
-#include <Phonon/BackendCapabilities>
+#include <phonon/mediaobject.h>
+#include <phonon/backendcapabilities.h>
 
 #include "phononnotificationbackend.h"
 
@@ -34,13 +34,14 @@ PhononNotificationBackend::PhononNotificationBackend(QObject *parent)
     : AbstractNotificationBackend(parent),
     _media(0)
 {
-    _audioAvailable = !Phonon::BackendCapabilities::availableAudioOutputDevices().isEmpty();
     NotificationSettings notificationSettings;
-    _enabled = notificationSettings.value("Phonon/Enabled", true).toBool();
-    createMediaObject(notificationSettings.value("Phonon/AudioFile", QString()).toString());
-
     notificationSettings.notify("Phonon/Enabled", this, SLOT(enabledChanged(const QVariant &)));
     notificationSettings.notify("Phonon/AudioFile", this, SLOT(audioFileChanged(const QVariant &)));
+
+    createMediaObject(notificationSettings.value("Phonon/AudioFile", QString()).toString());
+
+    _enabled = notificationSettings.value("Phonon/Enabled", true).toBool();
+    _audioAvailable = !Phonon::BackendCapabilities::availableAudioOutputDevices().isEmpty();
 }
 
 
@@ -54,7 +55,7 @@ PhononNotificationBackend::~PhononNotificationBackend()
 void PhononNotificationBackend::notify(const Notification &notification)
 {
     if (_enabled && (notification.type == Highlight || notification.type == PrivMsg)) {
-        if (_audioAvailable) {
+        if (_audioAvailable && _media) {
             _media->stop();
             _media->play();
         }