forked from len0rd/rockbox
Implement simple run for non-multithreaded TTS.
Since setting the maximum number of threads to use to 1 causes sporadically files missing add a simple alternative implementation that doesn't use futures. This is a stop-gap solution to fix voice files not creating (reported on Windows with SAPI voices, see FS#11994). Encoding doesn't seem to be affected by the problem and is unchanged. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29762 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
afa6afc3bc
commit
c6a8efb8af
2 changed files with 45 additions and 23 deletions
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
TalkGenerator::TalkGenerator(QObject* parent): QObject(parent), encFutureWatcher(this), ttsFutureWatcher(this)
|
TalkGenerator::TalkGenerator(QObject* parent): QObject(parent), encFutureWatcher(this), ttsFutureWatcher(this)
|
||||||
{
|
{
|
||||||
|
m_userAborted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! \brief Creates Talkfiles.
|
//! \brief Creates Talkfiles.
|
||||||
|
@ -126,31 +126,51 @@ TalkGenerator::Status TalkGenerator::voiceList(QList<TalkEntry>* list,int wavtri
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If the engine can't be parallelized, we use only 1 thread */
|
/* If the engine can't be parallelized, we use only 1 thread */
|
||||||
int maxThreadCount = QThreadPool::globalInstance()->maxThreadCount();
|
// NOTE: setting the number of maximum threads to use to 1 doesn't seem to
|
||||||
if ((m_tts->capabilities() & TTSBase::RunInParallel) == 0)
|
// work as expected -- it causes sporadically output files missing (see
|
||||||
QThreadPool::globalInstance()->setMaxThreadCount(1);
|
// FS#11994). As a stop-gap solution use a separate implementation in that
|
||||||
qDebug() << "[TalkGenerator] Maximum number of threads used:"
|
// case for running the TTS.
|
||||||
<< QThreadPool::globalInstance()->maxThreadCount();
|
if((m_tts->capabilities() & TTSBase::RunInParallel) != 0)
|
||||||
|
{
|
||||||
|
int maxThreadCount = QThreadPool::globalInstance()->maxThreadCount();
|
||||||
|
qDebug() << "[TalkGenerator] Maximum number of threads used:"
|
||||||
|
<< QThreadPool::globalInstance()->maxThreadCount();
|
||||||
|
|
||||||
connect(&ttsFutureWatcher, SIGNAL(progressValueChanged(int)),
|
connect(&ttsFutureWatcher, SIGNAL(progressValueChanged(int)),
|
||||||
this, SLOT(ttsProgress(int)));
|
this, SLOT(ttsProgress(int)));
|
||||||
ttsFutureWatcher.setFuture(QtConcurrent::map(*list, &TalkGenerator::ttsEntryPoint));
|
ttsFutureWatcher.setFuture(QtConcurrent::map(*list, &TalkGenerator::ttsEntryPoint));
|
||||||
|
|
||||||
/* We use this loop as an equivalent to ttsFutureWatcher.waitForFinished()
|
/* We use this loop as an equivalent to ttsFutureWatcher.waitForFinished()
|
||||||
* since the latter blocks all events */
|
* since the latter blocks all events */
|
||||||
while(ttsFutureWatcher.isRunning())
|
while(ttsFutureWatcher.isRunning())
|
||||||
QCoreApplication::processEvents();
|
QCoreApplication::processEvents();
|
||||||
|
|
||||||
/* Restore global settings, if we changed them */
|
/* Restore global settings, if we changed them */
|
||||||
if ((m_tts->capabilities() & TTSBase::RunInParallel) == 0)
|
if ((m_tts->capabilities() & TTSBase::RunInParallel) == 0)
|
||||||
QThreadPool::globalInstance()->setMaxThreadCount(maxThreadCount);
|
QThreadPool::globalInstance()->setMaxThreadCount(maxThreadCount);
|
||||||
|
|
||||||
if(ttsFutureWatcher.isCanceled())
|
if(ttsFutureWatcher.isCanceled())
|
||||||
return eERROR;
|
return eERROR;
|
||||||
else if(m_ttsWarnings)
|
else if(m_ttsWarnings)
|
||||||
return eWARNING;
|
return eWARNING;
|
||||||
else
|
else
|
||||||
return eOK;
|
return eOK;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
qDebug() << "[TalkGenerator] Using single thread TTS workaround";
|
||||||
|
int items = list->size();
|
||||||
|
for(int i = 0; i < items; i++) {
|
||||||
|
if(m_userAborted) {
|
||||||
|
emit logItem(tr("Voicing aborted"), LOGERROR);
|
||||||
|
return eERROR;
|
||||||
|
}
|
||||||
|
TalkEntry entry = list->at(i);
|
||||||
|
TalkGenerator::ttsEntryPoint(entry);
|
||||||
|
(*list)[i] = entry;
|
||||||
|
emit logProgress(i, items);
|
||||||
|
}
|
||||||
|
return m_ttsWarnings ? eWARNING : eOK;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TalkGenerator::ttsEntryPoint(TalkEntry& entry)
|
void TalkGenerator::ttsEntryPoint(TalkEntry& entry)
|
||||||
|
@ -279,5 +299,6 @@ void TalkGenerator::abort()
|
||||||
encFutureWatcher.cancel();
|
encFutureWatcher.cancel();
|
||||||
emit logItem(tr("Encoding aborted"), LOGERROR);
|
emit logItem(tr("Encoding aborted"), LOGERROR);
|
||||||
}
|
}
|
||||||
|
m_userAborted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -94,6 +94,7 @@ private:
|
||||||
EncBase* m_enc;
|
EncBase* m_enc;
|
||||||
|
|
||||||
bool m_ttsWarnings;
|
bool m_ttsWarnings;
|
||||||
|
bool m_userAborted;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue