Commit 560f679f authored by Don Gagne's avatar Don Gagne

Move init to correct thread

parent 4abafb46
......@@ -64,8 +64,6 @@ GAudioOutput::GAudioOutput(QObject *parent) : QObject(parent),
worker(new QGCAudioWorker())
{
worker->moveToThread(thread);
// Initialize within right thread context
worker->init();
connect(this, SIGNAL(textToSpeak(QString,int)), worker, SLOT(say(QString,int)));
connect(this, SIGNAL(beepOnce()), worker, SLOT(beep()));
thread->start();
......
......@@ -94,6 +94,12 @@ QGCAudioWorker::~QGCAudioWorker()
void QGCAudioWorker::say(QString text, int severity)
{
static bool threadInit = false;
if (!threadInit) {
threadInit = true;
init();
}
if (!muted)
{
// Prepend high priority text with alert beep
......@@ -109,8 +115,10 @@ void QGCAudioWorker::say(QString text, int severity)
#endif
#if defined _MSC_VER && defined QGC_SPEECH_ENABLED
pVoice->Speak(text.toStdWString().c_str(), SPF_DEFAULT, NULL);
HRESULT hr = pVoice->Speak(text.toStdWString().c_str(), SPF_DEFAULT, NULL);
if (FAILED(hr)) {
qDebug() << "Speak failed, HR:" << QString("%1").arg(hr, 0, 16);
}
#elif defined Q_OS_LINUX && defined QGC_SPEECH_ENABLED
// Set size of string for espeak: +1 for the null-character
unsigned int espeak_size = strlen(text.toStdString().c_str()) + 1;
......
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