Snoozable 00:00:00 alerts
[kitchenalert] / src / alertsound.cpp
index 54decb8..b53541f 100644 (file)
@@ -33,7 +33,9 @@ AlertSound::AlertSound(QObject *parent) :
     QObject(parent)
 {
 
-    defaultsound_ = "/opt/KitchenAlert/06capemaycloser_modifiedlouder.mp3";
+    //THIS NEEDS TESTING: DOES IT REALLY CHANGE TUNE WHEN RESTARTING THE APPLICATION?
+
+    defaultsound_ = "/home/opt/KitchenAlert/Doorbell-old-tring-modified-multiplied-low-quality.mp3";
     QString filename;
 
     QSettings settings("KitchenAlert","KitchenAlert");
@@ -41,7 +43,7 @@ AlertSound::AlertSound(QObject *parent) :
    // settings.clear(); //REMOVE THIS AFTER TESTING!!!!!!
 
     bool useDefaultSound = settings.value("UseDefaultSound",true).toBool();
-    qDebug() << "In AlertSound constructor UseDefaultSound is " << useDefaultSound;
+//    qDebug() << "In AlertSound constructor UseDefaultSound is " << useDefaultSound;
     if (useDefaultSound == true)
     {
         filename = defaultsound_;
@@ -53,9 +55,18 @@ AlertSound::AlertSound(QObject *parent) :
     pSound_ = Phonon::createPlayer(Phonon::MusicCategory, Phonon::MediaSource(filename));
 }
 
+AlertSound::~AlertSound()
+{
+
+    if (pSound_ != NULL)
+    {
+        delete pSound_;
+    }
+}
+
 void AlertSound::play()
 {
-    pSound_->stop(); //Just testing if stopping the previous alert will prevent the jammming of the sound
+    pSound_->stop(); //Just testing if stopping the previous alert will prevent the jammming of the sound (only partially, but since it helped some, keeping it even if the problem was solved otherwise)
     pSound_->play();
     qDebug() << "Sound should be played now";
 }
@@ -64,6 +75,8 @@ void AlertSound::stop()
 {
 
     pSound_->stop();
+    qDebug() << pSound_->state();
+    qDebug() << "Sound stopped by AlertSound.";
 }