Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
d53d5f88
Commit
d53d5f88
authored
Dec 09, 2014
by
Lorenz Meier
Browse files
Improve audio output logic and consistency
parent
daefb0bd
Changes
4
Show whitespace changes
Inline
Side-by-side
src/GAudioOutput.cc
View file @
d53d5f88
...
...
@@ -107,7 +107,7 @@ bool GAudioOutput::say(QString text, int severity)
*/
bool
GAudioOutput
::
alert
(
QString
text
)
{
emit
textToSpeak
(
text
,
2
);
emit
textToSpeak
(
text
,
1
);
return
true
;
}
...
...
src/GAudioOutput.h
View file @
d53d5f88
...
...
@@ -58,12 +58,24 @@ public:
VOICE_FEMALE
}
QGVoice
;
enum
AUDIO_SEVERITY
{
AUDIO_SEVERITY_EMERGENCY
=
0
,
AUDIO_SEVERITY_ALERT
=
1
,
AUDIO_SEVERITY_CRITICAL
=
2
,
AUDIO_SEVERITY_ERROR
=
3
,
AUDIO_SEVERITY_WARNING
=
4
,
AUDIO_SEVERITY_NOTICE
=
5
,
AUDIO_SEVERITY_INFO
=
6
,
AUDIO_SEVERITY_DEBUG
=
7
};
/** @brief Get the mute state */
bool
isMuted
();
public
slots
:
/** @brief Say this text if current output priority matches */
bool
say
(
QString
text
,
int
severity
=
1
);
bool
say
(
QString
text
,
int
severity
=
6
);
/** @brief Play alert sound and say notification message */
bool
alert
(
QString
text
);
/** @brief Start emergency sound */
...
...
src/audio/QGCAudioWorker.cpp
View file @
d53d5f88
...
...
@@ -6,6 +6,7 @@
#include
"QGC.h"
#include
"QGCAudioWorker.h"
#include
"GAudioOutput.h"
#if defined Q_OS_MAC && defined QGC_SPEECH_ENABLED
#include
<ApplicationServices/ApplicationServices.h>
...
...
@@ -89,11 +90,12 @@ QGCAudioWorker::~QGCAudioWorker()
void
QGCAudioWorker
::
say
(
QString
text
,
int
severity
)
{
qDebug
()
<<
"TEXT"
<<
text
;
if
(
!
muted
)
{
// TODO Add severity filter
Q_UNUSED
(
severity
);
// Prepend high priority text with alert beep
if
(
severity
<
GAudioOutput
::
AUDIO_SEVERITY_CRITICAL
)
{
beep
();
}
// Wait for the last sound to finish
while
(
!
sound
->
isFinished
())
{
...
...
@@ -149,7 +151,6 @@ void QGCAudioWorker::beep()
{
// Use QFile to transform path for all OS
QFile
f
(
QCoreApplication
::
applicationDirPath
()
+
QString
(
"/files/audio/alert.wav"
));
qDebug
()
<<
"SOUND FILE:"
<<
f
.
fileName
();
sound
->
play
(
f
.
fileName
());
}
}
...
...
src/uas/UAS.cc
View file @
d53d5f88
...
...
@@ -333,7 +333,7 @@ void UAS::updateState()
connectionLost
=
true
;
receivedMode
=
false
;
QString
audiostring
=
QString
(
"Link lost to system %1"
).
arg
(
this
->
getUASID
());
GAudioOutput
::
instance
()
->
say
(
audiostring
.
toLower
());
GAudioOutput
::
instance
()
->
say
(
audiostring
.
toLower
()
,
GAudioOutput
::
AUDIO_SEVERITY_ALERT
);
}
// Update connection loss time on each iteration
...
...
@@ -347,7 +347,7 @@ void UAS::updateState()
if
(
connectionLost
&&
(
heartbeatInterval
<
timeoutIntervalHeartbeat
))
{
QString
audiostring
=
QString
(
"Link regained to system %1"
).
arg
(
this
->
getUASID
());
GAudioOutput
::
instance
()
->
say
(
audiostring
.
toLower
());
GAudioOutput
::
instance
()
->
say
(
audiostring
.
toLower
()
,
GAudioOutput
::
AUDIO_SEVERITY_NOTICE
);
connectionLost
=
false
;
connectionLossTime
=
0
;
emit
heartbeatTimeout
(
false
,
0
);
...
...
@@ -574,7 +574,7 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message)
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
::
instance
()
->
say
(
QString
(
"emergency for system %1"
).
arg
(
this
->
getUASID
())
,
GAudioOutput
::
AUDIO_SEVERITY_EMERGENCY
);
QTimer
::
singleShot
(
3000
,
GAudioOutput
::
instance
(),
SLOT
(
startEmergency
()));
}
else
if
(
modechanged
||
statechanged
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment