From 4abafb4648827a978d1ee30c7131f26feb612d70 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Tue, 9 Dec 2014 19:49:55 +0100 Subject: [PATCH] Disable tunes, allow to re-enable them with a simple define --- qgroundcontrol.pro | 7 +++++-- src/audio/QGCAudioWorker.cpp | 17 ++++++++++++----- src/audio/QGCAudioWorker.h | 14 ++++++-------- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index 84d06a46d..c6063f2b2 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -111,8 +111,11 @@ QT += network \ serialport \ sql \ printsupport \ - quick \ - multimedia + quick + +contains(DEFINES, QGC_NOTIFY_TUNES_ENABLED) { + QT += multimedia +} !contains(DEFINES, DISABLE_GOOGLE_EARTH) { QT += webkit webkitwidgets diff --git a/src/audio/QGCAudioWorker.cpp b/src/audio/QGCAudioWorker.cpp index 43e570f8d..e0a202f37 100644 --- a/src/audio/QGCAudioWorker.cpp +++ b/src/audio/QGCAudioWorker.cpp @@ -2,7 +2,6 @@ #include #include #include -#include #include "QGC.h" #include "QGCAudioWorker.h" @@ -28,12 +27,14 @@ QGCAudioWorker::QGCAudioWorker(QObject *parent) : QObject(parent), voiceIndex(0), - emergency(false), - muted(false), #if defined _MSC_VER && defined QGC_SPEECH_ENABLED pVoice(NULL), #endif - sound(NULL) + #ifdef QGC_NOTIFY_TUNES_ENABLED + sound(NULL), + #endif + emergency(false), + muted(false) { // Load settings QSettings settings; @@ -42,7 +43,9 @@ QGCAudioWorker::QGCAudioWorker(QObject *parent) : void QGCAudioWorker::init() { - sound = new QSound(""); +#ifdef QGC_NOTIFY_TUNES_ENABLED + sound = new QSound(":/files/audio/alert.wav"); +#endif #if defined Q_OS_LINUX && defined QGC_SPEECH_ENABLED espeak_Initialize(AUDIO_OUTPUT_SYNCH_PLAYBACK, 500, NULL, 0); // initialize for playback with 500ms buffer and no options (see speak_lib.h) @@ -98,10 +101,12 @@ void QGCAudioWorker::say(QString text, int severity) beep(); } +#ifdef QGC_NOTIFY_TUNES_ENABLED // Wait for the last sound to finish while (!sound->isFinished()) { QGC::SLEEP::msleep(100); } +#endif #if defined _MSC_VER && defined QGC_SPEECH_ENABLED pVoice->Speak(text.toStdWString().c_str(), SPF_DEFAULT, NULL); @@ -150,7 +155,9 @@ void QGCAudioWorker::beep() if (!muted) { +#ifdef QGC_NOTIFY_TUNES_ENABLED sound->play(":/files/audio/alert.wav"); +#endif } } diff --git a/src/audio/QGCAudioWorker.h b/src/audio/QGCAudioWorker.h index 062d9b306..7e06023e5 100644 --- a/src/audio/QGCAudioWorker.h +++ b/src/audio/QGCAudioWorker.h @@ -3,7 +3,9 @@ #include #include +#ifdef QGC_NOTIFY_TUNES_ENABLED #include +#endif /* For Snow leopard and later #if defined Q_OS_MAC & defined QGC_SPEECH_ENABLED @@ -38,20 +40,16 @@ public slots: void beep(); protected: -#if defined Q_OS_MAC && defined QGC_SPEECH_ENABLED - //NSSpeechSynthesizer -#endif -#if defined Q_OS_LINUX && defined QGC_SPEECH_ENABLED - //cst_voice* voice; ///< The flite voice object -#endif + int voiceIndex; ///< The index of the flite voice to use (awb, slt, rms) #if defined _MSC_VER && defined QGC_SPEECH_ENABLED ISpVoice *pVoice; #endif - int voiceIndex; ///< The index of the flite voice to use (awb, slt, rms) +#ifdef QGC_NOTIFY_TUNES_ENABLED + QSound *sound; +#endif bool emergency; ///< Emergency status flag QTimer *emergencyTimer; bool muted; - QSound *sound; }; #endif // QGCAUDIOWORKER_H -- 2.22.0