From c14ba1b5d494114c1c987d5436e8db8bea7024d0 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Thu, 29 Sep 2022 18:58:34 +0300 Subject: [PATCH] kutils: check the return values of speech-dispatcher function calls Signed-off-by: Ivailo Monev --- kutils/kspeech/kspeech.cpp | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/kutils/kspeech/kspeech.cpp b/kutils/kspeech/kspeech.cpp index df2a43e0..4972e826 100644 --- a/kutils/kspeech/kspeech.cpp +++ b/kutils/kspeech/kspeech.cpp @@ -214,8 +214,11 @@ bool KSpeech::setVolume(const int volume) return false; } - // TODO: error check - (void)spd_set_volume(d->m_speechd, volume); + const int speechdresult = spd_set_volume(d->m_speechd, volume); + if (speechdresult < 0) { + kWarning() << "Speech-dispatcher set volume failed"; + return false; + } return true; #else return false; @@ -249,8 +252,11 @@ bool KSpeech::setPitch(const int pitch) return false; } - // TODO: error check - (void)spd_set_voice_pitch(d->m_speechd, pitch); + const int speechdresult = spd_set_voice_pitch(d->m_speechd, pitch); + if (speechdresult < 0) { + kWarning() << "Speech-dispatcher set pitch failed"; + return false; + } return true; #else return false; @@ -298,8 +304,11 @@ bool KSpeech::setVoice(const QByteArray &voice) return false; } - // TODO: error check - (void)spd_set_synthesis_voice(d->m_speechd, voice.constData()); + const int speechdresult = spd_set_synthesis_voice(d->m_speechd, voice.constData()); + if (speechdresult < 0) { + kWarning() << "Speech-dispatcher set voice failed"; + return false; + } return true; #else return false; @@ -337,8 +346,10 @@ void KSpeech::removeAllJobs() return; } - // TODO: error check - (void)spd_stop(d->m_speechd); + const int speechdresult = spd_stop(d->m_speechd); + if (speechdresult < 0) { + kWarning() << "Speech-dispatcher stop failed"; + } #endif } @@ -350,8 +361,10 @@ void KSpeech::removeJob(int jobNum) return; } - // TODO: error check - (void)spd_stop_uid(d->m_speechd, jobNum); + const int speechdresult = spd_stop_uid(d->m_speechd, jobNum); + if (speechdresult < 0) { + kWarning() << "Speech-dispatcher stop uid failed"; + } #endif }