summaryrefslogtreecommitdiff
path: root/navit/speech/qt5_espeak/Qt5EspeakAudioOut.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'navit/speech/qt5_espeak/Qt5EspeakAudioOut.cpp')
-rw-r--r--navit/speech/qt5_espeak/Qt5EspeakAudioOut.cpp43
1 files changed, 19 insertions, 24 deletions
diff --git a/navit/speech/qt5_espeak/Qt5EspeakAudioOut.cpp b/navit/speech/qt5_espeak/Qt5EspeakAudioOut.cpp
index da2c6b3e1..a5e488391 100644
--- a/navit/speech/qt5_espeak/Qt5EspeakAudioOut.cpp
+++ b/navit/speech/qt5_espeak/Qt5EspeakAudioOut.cpp
@@ -23,8 +23,7 @@ extern "C" {
#include "debug.h"
}
-Qt5EspeakAudioOut::Qt5EspeakAudioOut(int samplerate, const char* category)
-{
+Qt5EspeakAudioOut::Qt5EspeakAudioOut(int samplerate, const char* category) {
data = new QByteArray();
buffer = new QBuffer(data);
buffer->open(QIODevice::ReadWrite);
@@ -41,31 +40,30 @@ Qt5EspeakAudioOut::Qt5EspeakAudioOut(int samplerate, const char* category)
QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice());
if (!info.isFormatSupported(format)) {
dbg(lvl_error,
- "Raw audio format not supported by backend, cannot play audio.\n");
+ "Raw audio format not supported by backend, cannot play audio.");
return;
}
audio = new QAudioOutput(format, this);
/* try to set a rather huge buffer size in order to avoid chopping due to
- * event loop
- * not getting idle. Drawing may take just too long time. This hopefully
- * removes the
- * need to do multi threading with all its problems. May be a problem on
- * systems with
- * really low memory.*/
+ * event loop
+ * not getting idle. Drawing may take just too long time. This hopefully
+ * removes the
+ * need to do multi threading with all its problems. May be a problem on
+ * systems with
+ * really low memory.*/
audio->setBufferSize((samplerate * 1 /*ch*/ * 2 /*samplezize*/) * 5 /*seconds*/);
- dbg(lvl_debug, "Buffer size is: %d\n", audio->bufferSize());
+ dbg(lvl_debug, "Buffer size is: %d", audio->bufferSize());
if (category != NULL)
audio->setCategory(QString(category));
connect(audio, SIGNAL(stateChanged(QAudio::State)), this,
- SLOT(handleStateChanged(QAudio::State)));
+ SLOT(handleStateChanged(QAudio::State)));
/* to cope with resume coming from other thread (of libespeak)*/
connect(this, SIGNAL(call_resume(int)), this, SLOT(resume(int)));
}
-Qt5EspeakAudioOut::~Qt5EspeakAudioOut()
-{
+Qt5EspeakAudioOut::~Qt5EspeakAudioOut() {
delete (audio);
audio = NULL;
delete (buffer);
@@ -74,9 +72,8 @@ Qt5EspeakAudioOut::~Qt5EspeakAudioOut()
data = NULL;
}
-void Qt5EspeakAudioOut::handleStateChanged(QAudio::State newState)
-{
- dbg(lvl_debug, "Enter %d\n", newState);
+void Qt5EspeakAudioOut::handleStateChanged(QAudio::State newState) {
+ dbg(lvl_debug, "Enter %d", newState);
switch (newState) {
case QAudio::ActiveState:
break;
@@ -88,21 +85,19 @@ void Qt5EspeakAudioOut::handleStateChanged(QAudio::State newState)
/*remove all data that was already read*/
data->remove(0, buffer->pos());
buffer->seek(0);
- dbg(lvl_debug, "Size %d\n", data->size());
+ dbg(lvl_debug, "Size %d", data->size());
break;
}
}
-void Qt5EspeakAudioOut::resume(int state)
-{
- dbg(lvl_debug, "Enter %d\n", state);
+void Qt5EspeakAudioOut::resume(int state) {
+ dbg(lvl_debug, "Enter %d", state);
if (audio->state() != QAudio::ActiveState)
audio->start(buffer);
}
-void Qt5EspeakAudioOut::addSamples(short* wav, int numsamples)
-{
- dbg(lvl_debug, "Enter (%d samples)\n", numsamples);
+void Qt5EspeakAudioOut::addSamples(short* wav, int numsamples) {
+ dbg(lvl_debug, "Enter (%d samples)", numsamples);
/*remove all data that was already read (if any)*/
data->remove(0, buffer->pos());
@@ -110,7 +105,7 @@ void Qt5EspeakAudioOut::addSamples(short* wav, int numsamples)
if (numsamples > 0) {
data->append((const char*)wav, numsamples * sizeof(short));
- dbg(lvl_debug, "%ld samples in buffer\n",
+ dbg(lvl_debug, "%ld samples in buffer",
(long int)(buffer->size() / sizeof(short)));
emit call_resume(numsamples);
}