Commit a41fb7cf authored by Don Gagne's avatar Don Gagne

Fix UT only shutdown ordering crash

parent d14444a5
...@@ -55,7 +55,6 @@ GAudioOutput::GAudioOutput(QObject *parent) : ...@@ -55,7 +55,6 @@ GAudioOutput::GAudioOutput(QObject *parent) :
worker->moveToThread(thread); worker->moveToThread(thread);
connect(this, &GAudioOutput::textToSpeak, worker, &QGCAudioWorker::say); connect(this, &GAudioOutput::textToSpeak, worker, &QGCAudioWorker::say);
connect(this, &GAudioOutput::beepOnce, worker, &QGCAudioWorker::beep);
connect(thread, &QThread::finished, thread, &QObject::deleteLater); connect(thread, &QThread::finished, thread, &QObject::deleteLater);
connect(thread, &QThread::finished, worker, &QObject::deleteLater); connect(thread, &QThread::finished, worker, &QObject::deleteLater);
thread->start(); thread->start();
...@@ -82,28 +81,10 @@ bool GAudioOutput::isMuted() ...@@ -82,28 +81,10 @@ bool GAudioOutput::isMuted()
return muted; return muted;
} }
bool GAudioOutput::say(QString text, int severity) bool GAudioOutput::say(const QString& text, int severity)
{ {
if (!muted) { if (!muted) {
emit textToSpeak(text, severity); emit textToSpeak(text, severity);
} }
return true; return true;
} }
/**
* @param text This message will be played after the alert beep
*/
bool GAudioOutput::alert(QString text)
{
if (!muted) {
emit textToSpeak(text, 1);
}
return true;
}
void GAudioOutput::beep()
{
if (!muted) {
emit beepOnce();
}
}
...@@ -77,11 +77,7 @@ public: ...@@ -77,11 +77,7 @@ public:
public slots: public slots:
/** @brief Say this text if current output priority matches */ /** @brief Say this text if current output priority matches */
bool say(QString text, int severity = 6); bool say(const QString& text, int severity = 6);
/** @brief Play alert sound and say notification message */
bool alert(QString text);
/** @brief Play emergency sound once */
void beep();
/** @brief Mute/unmute sound */ /** @brief Mute/unmute sound */
void mute(bool mute); void mute(bool mute);
......
...@@ -348,7 +348,7 @@ void UAS::updateState() ...@@ -348,7 +348,7 @@ void UAS::updateState()
connectionLost = true; connectionLost = true;
receivedMode = false; receivedMode = false;
QString audiostring = QString("Link lost to system %1").arg(this->getUASID()); QString audiostring = QString("Link lost to system %1").arg(this->getUASID());
GAudioOutput::instance()->say(audiostring.toLower(), GAudioOutput::AUDIO_SEVERITY_ALERT); _say(audiostring.toLower(), GAudioOutput::AUDIO_SEVERITY_ALERT);
} }
// Update connection loss time on each iteration // Update connection loss time on each iteration
...@@ -362,7 +362,7 @@ void UAS::updateState() ...@@ -362,7 +362,7 @@ void UAS::updateState()
if (connectionLost && (heartbeatInterval < timeoutIntervalHeartbeat)) if (connectionLost && (heartbeatInterval < timeoutIntervalHeartbeat))
{ {
QString audiostring = QString("Link regained to system %1").arg(this->getUASID()); QString audiostring = QString("Link regained to system %1").arg(this->getUASID());
GAudioOutput::instance()->say(audiostring.toLower(), GAudioOutput::AUDIO_SEVERITY_NOTICE); _say(audiostring.toLower(), GAudioOutput::AUDIO_SEVERITY_NOTICE);
connectionLost = false; connectionLost = false;
connectionLossTime = 0; connectionLossTime = 0;
emit heartbeatTimeout(false, 0); emit heartbeatTimeout(false, 0);
...@@ -553,12 +553,12 @@ void UAS::receiveMessage(mavlink_message_t message) ...@@ -553,12 +553,12 @@ void UAS::receiveMessage(mavlink_message_t message)
if (statechanged && ((int)state.system_status == (int)MAV_STATE_CRITICAL || state.system_status == (int)MAV_STATE_EMERGENCY)) if (statechanged && ((int)state.system_status == (int)MAV_STATE_CRITICAL || state.system_status == (int)MAV_STATE_EMERGENCY))
{ {
GAudioOutput::instance()->say(QString("Emergency for system %1").arg(this->getUASID()), GAudioOutput::AUDIO_SEVERITY_EMERGENCY); _say(QString("Emergency for system %1").arg(this->getUASID()), GAudioOutput::AUDIO_SEVERITY_EMERGENCY);
QTimer::singleShot(3000, GAudioOutput::instance(), SLOT(startEmergency())); QTimer::singleShot(3000, GAudioOutput::instance(), SLOT(startEmergency()));
} }
else if (modechanged || statechanged) else if (modechanged || statechanged)
{ {
GAudioOutput::instance()->say(audiostring.toLower()); _say(audiostring.toLower());
} }
} }
...@@ -621,7 +621,7 @@ void UAS::receiveMessage(mavlink_message_t message) ...@@ -621,7 +621,7 @@ void UAS::receiveMessage(mavlink_message_t message)
/* warn only every 12 seconds */ /* warn only every 12 seconds */
&& (QGC::groundTimeUsecs() - lastVoltageWarning) > 12000000) && (QGC::groundTimeUsecs() - lastVoltageWarning) > 12000000)
{ {
GAudioOutput::instance()->say(QString("Voltage warning for system %1: %2 volts").arg(getUASID()).arg(lpVoltage, 0, 'f', 1, QChar(' '))); _say(QString("Voltage warning for system %1: %2 volts").arg(getUASID()).arg(lpVoltage, 0, 'f', 1, QChar(' ')));
lastVoltageWarning = QGC::groundTimeUsecs(); lastVoltageWarning = QGC::groundTimeUsecs();
lastTickVoltageValue = tickLowpassVoltage; lastTickVoltageValue = tickLowpassVoltage;
} }
...@@ -1198,7 +1198,7 @@ void UAS::receiveMessage(mavlink_message_t message) ...@@ -1198,7 +1198,7 @@ void UAS::receiveMessage(mavlink_message_t message)
mavlink_msg_mission_item_reached_decode(&message, &wpr); mavlink_msg_mission_item_reached_decode(&message, &wpr);
waypointManager.handleWaypointReached(message.sysid, message.compid, &wpr); waypointManager.handleWaypointReached(message.sysid, message.compid, &wpr);
QString text = QString("System %1 reached waypoint %2").arg(getUASID()).arg(wpr.seq); QString text = QString("System %1 reached waypoint %2").arg(getUASID()).arg(wpr.seq);
GAudioOutput::instance()->say(text); _say(text);
emit textMessageReceived(message.sysid, message.compid, MAV_SEVERITY_INFO, text); emit textMessageReceived(message.sysid, message.compid, MAV_SEVERITY_INFO, text);
} }
break; break;
...@@ -1247,7 +1247,7 @@ void UAS::receiveMessage(mavlink_message_t message) ...@@ -1247,7 +1247,7 @@ void UAS::receiveMessage(mavlink_message_t message)
{ {
text.remove("#"); text.remove("#");
emit textMessageReceived(uasId, message.compid, severity, text); emit textMessageReceived(uasId, message.compid, severity, text);
GAudioOutput::instance()->say(text.toLower(), severity); _say(text.toLower(), severity);
} }
else else
{ {
...@@ -3393,7 +3393,7 @@ void UAS::startLowBattAlarm() ...@@ -3393,7 +3393,7 @@ void UAS::startLowBattAlarm()
{ {
if (!lowBattAlarm) if (!lowBattAlarm)
{ {
GAudioOutput::instance()->alert(tr("System %1 has low battery").arg(getUASID())); _say(tr("System %1 has low battery").arg(getUASID()));
lowBattAlarm = true; lowBattAlarm = true;
} }
} }
...@@ -3465,3 +3465,13 @@ void UAS::unsetRCToParameterMap() ...@@ -3465,3 +3465,13 @@ void UAS::unsetRCToParameterMap()
_vehicle->sendMessage(message); _vehicle->sendMessage(message);
} }
} }
void UAS::_say(const QString& text, int severity)
{
#ifndef UNITTEST_BUILD
GAudioOutput::instance()->say(text, severity);
#else
Q_UNUSED(text)
Q_UNUSED(severity)
#endif
}
...@@ -981,6 +981,9 @@ protected slots: ...@@ -981,6 +981,9 @@ protected slots:
/** @brief Read settings from disk */ /** @brief Read settings from disk */
void readSettings(); void readSettings();
private:
void _say(const QString& text, int severity = 6);
private: private:
Vehicle* _vehicle; Vehicle* _vehicle;
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment