summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2024-03-05 16:51:37 +0100
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2024-03-05 16:59:26 +0100
commit037fcecfaa40645994038f28f5d8ca98b80d6afd (patch)
tree9cd90170c15af65d0623439f3d6847f715981e5c /src
parent6b3aea3898a8c4e066d3fe423a6308c14608d9f6 (diff)
Enqueue new text if added while the engine is busy
Calling enqueue() should be equivalent to say() when the engine is Ready, otherwise it should enqueue the text. The old implementation only enqueued the text when the engine was in Speaking state, overriding the current utterance when the engine was already synthesizing, or paused. Adjust test to enqueue the next text chunk as soon as the engine transitions away from the Ready state. Pick-to: 6.7 6.6 Fixes: QTBUG-122884 Change-Id: I19518a92d1ae73b01dc3de1d9ae6178f5f55b3ad Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/tts/qtexttospeech.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/tts/qtexttospeech.cpp b/src/tts/qtexttospeech.cpp
index c938771..8018a8f 100644
--- a/src/tts/qtexttospeech.cpp
+++ b/src/tts/qtexttospeech.cpp
@@ -826,11 +826,18 @@ qsizetype QTextToSpeech::enqueue(const QString &utterance)
if (!d->m_engine || utterance.isEmpty())
return -1;
- if (d->m_engine->state() == QTextToSpeech::Speaking) {
- d->m_pendingUtterances.enqueue(utterance);
- } else {
+ switch (d->m_engine->state()) {
+ case QTextToSpeech::Error:
+ return -1;
+ case QTextToSpeech::Ready:
emit aboutToSynthesize(0);
d->m_engine->say(utterance);
+ break;
+ case QTextToSpeech::Speaking:
+ case QTextToSpeech::Synthesizing:
+ case QTextToSpeech::Paused:
+ d->m_pendingUtterances.enqueue(utterance);
+ break;
}
return d->m_utteranceCounter++;