From 30d8fcd2b066dec7e38f18f5f28e98921f3c4e11 Mon Sep 17 00:00:00 2001 From: edouard Date: Tue, 18 Jan 2011 18:05:51 +0000 Subject: [PATCH] OP-279 Checked in a fix for sound issue on Windows: should now be OK on both Windows and Linux. Someone either send me a mac, or test on their own to confirm it's ok on that platform too! git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2477 ebee16cc-31ac-478f-84a7-5cbb03baadba --- ground/src/plugins/notify/notifyplugin.cpp | 7 ++-- .../notify/notifypluginconfiguration.cpp | 32 +++++++++---------- .../notify/notifypluginconfiguration.h | 2 +- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/ground/src/plugins/notify/notifyplugin.cpp b/ground/src/plugins/notify/notifyplugin.cpp index 3e01c43d2..cd4cc1e66 100644 --- a/ground/src/plugins/notify/notifyplugin.cpp +++ b/ground/src/plugins/notify/notifyplugin.cpp @@ -404,11 +404,14 @@ void SoundNotifyPlugin::stateChanged(Phonon::State newstate, Phonon::State oldst qDebug() << "New State: " << newstate; #endif +#ifndef Q_OS_WIN // This is a hack to force Linux to wait until the end of the - // wav file before moving to the next in the queue + // wav file before moving to the next in the queue. + // I wish I did not have to go through a #define, but I did not + // manage to make this work on both platforms any other way! if (phonon.mo->totalTime()>0) phonon.mo->setTransitionTime(phonon.mo->totalTime()); - +#endif if((newstate == Phonon::PausedState) || (newstate == Phonon::StoppedState)) { diff --git a/ground/src/plugins/notify/notifypluginconfiguration.cpp b/ground/src/plugins/notify/notifypluginconfiguration.cpp index a123975ee..c9c838f9c 100644 --- a/ground/src/plugins/notify/notifypluginconfiguration.cpp +++ b/ground/src/plugins/notify/notifypluginconfiguration.cpp @@ -101,28 +101,28 @@ QString NotifyPluginConfiguration::parseNotifyMessage() // generate queue of sound files to play notifyMessageList.clear(); - if(QFile::exists(QDir::toNativeSeparators(getSoundCollectionPath()+ getCurrentLanguage()+"/"+getSound1()+".wav"))) - notifyMessageList.append(QDir::toNativeSeparators(getSoundCollectionPath() + getCurrentLanguage()+"/"+getSound1()+".wav")); + if(QFile::exists(QDir::toNativeSeparators(getSoundCollectionPath() + "/" + getCurrentLanguage()+"/"+getSound1()+".wav"))) + notifyMessageList.append(QDir::toNativeSeparators(getSoundCollectionPath() + "/" + getCurrentLanguage()+"/"+getSound1()+".wav")); else - if(QFile::exists(QDir::toNativeSeparators(getSoundCollectionPath() + "default/"+getSound2()+".wav"))) - notifyMessageList.append(QDir::toNativeSeparators(getSoundCollectionPath() + "default/"+getSound1()+".wav")); + if(QFile::exists(QDir::toNativeSeparators(getSoundCollectionPath() + "/default/"+getSound1()+".wav"))) + notifyMessageList.append(QDir::toNativeSeparators(getSoundCollectionPath() + "/default/"+getSound1()+".wav")); if(getSound2()!="") { - if(QFile::exists(QDir::toNativeSeparators(getSoundCollectionPath() + getCurrentLanguage()+"/"+getSound2()+".wav"))) - notifyMessageList.append(QDir::toNativeSeparators(getSoundCollectionPath() + getCurrentLanguage()+"/"+getSound2()+".wav")); + if(QFile::exists(QDir::toNativeSeparators(getSoundCollectionPath() + "/" + getCurrentLanguage()+"/"+getSound2()+".wav"))) + notifyMessageList.append(QDir::toNativeSeparators(getSoundCollectionPath() + "/" + getCurrentLanguage()+"/"+getSound2()+".wav")); else - if(QFile::exists(QDir::toNativeSeparators(getSoundCollectionPath() + "default/"+getSound2()+".wav"))) - notifyMessageList.append(QDir::toNativeSeparators(getSoundCollectionPath() + "default/"+getSound2()+".wav")); + if(QFile::exists(QDir::toNativeSeparators(getSoundCollectionPath() + "/default/"+getSound2()+".wav"))) + notifyMessageList.append(QDir::toNativeSeparators(getSoundCollectionPath() + "/default/"+getSound2()+".wav")); } if(getSound3()!="") { - if(QFile::exists(QDir::toNativeSeparators(getSoundCollectionPath()+getCurrentLanguage()+"/"+getSound3()+".wav"))) - notifyMessageList.append(QDir::toNativeSeparators(getSoundCollectionPath()+getCurrentLanguage()+"/"+getSound3()+".wav")); + if(QFile::exists(QDir::toNativeSeparators(getSoundCollectionPath()+ "/" + getCurrentLanguage()+"/"+getSound3()+".wav"))) + notifyMessageList.append(QDir::toNativeSeparators(getSoundCollectionPath()+ "/" + getCurrentLanguage()+"/"+getSound3()+".wav")); else - if(QFile::exists(QDir::toNativeSeparators(getSoundCollectionPath()+"default/"+getSound3()+".wav"))) - notifyMessageList.append(QDir::toNativeSeparators(getSoundCollectionPath()+"default/"+getSound3()+".wav")); + if(QFile::exists(QDir::toNativeSeparators(getSoundCollectionPath()+"/default/"+getSound3()+".wav"))) + notifyMessageList.append(QDir::toNativeSeparators(getSoundCollectionPath()+"/default/"+getSound3()+".wav")); } switch(str1.at(0).toAscii()) @@ -204,12 +204,12 @@ QString NotifyPluginConfiguration::parseNotifyMessage() } foreach(QString fileName,numberFiles) { fileName+=".wav"; - QString filePath = getSoundCollectionPath()+ QDir::toNativeSeparators(getCurrentLanguage()+"/"+fileName); + QString filePath = QDir::toNativeSeparators(getSoundCollectionPath()+"/"+ getCurrentLanguage()+"/"+fileName); if(QFile::exists(filePath)) - notifyMessageList.insert(position++,getSoundCollectionPath()+ QDir::toNativeSeparators(getCurrentLanguage()+"/"+fileName)); + notifyMessageList.insert(position++,QDir::toNativeSeparators(getSoundCollectionPath()+ "/"+getCurrentLanguage()+"/"+fileName)); else { - if(QFile::exists(getSoundCollectionPath()+QDir::toNativeSeparators("default/"+fileName))) - notifyMessageList.insert(position++,getSoundCollectionPath()+QDir::toNativeSeparators("default/"+fileName)); + if(QFile::exists(QDir::toNativeSeparators(getSoundCollectionPath()+"/default/"+fileName))) + notifyMessageList.insert(position++,QDir::toNativeSeparators(getSoundCollectionPath()+"/default/"+fileName)); else { notifyMessageList.clear(); break; // if no some of *.wav files, then don't play number! diff --git a/ground/src/plugins/notify/notifypluginconfiguration.h b/ground/src/plugins/notify/notifypluginconfiguration.h index df33f0b34..54edab66a 100644 --- a/ground/src/plugins/notify/notifypluginconfiguration.h +++ b/ground/src/plugins/notify/notifypluginconfiguration.h @@ -71,7 +71,7 @@ public: QString getObjectField() const { return objectField; } void setObjectField(QString text) { objectField = text; } - QString getSoundCollectionPath() const { return soundCollectionPath; } + QString getSoundCollectionPath() const { return soundCollectionPath; } void setSoundCollectionPath(QString text) { soundCollectionPath = text; } QString getCurrentLanguage() const { return currentLanguage; }