diff options
-rw-r--r-- | rbutil/rbutilqt/base/talkgenerator.cpp | 75 | ||||
-rw-r--r-- | rbutil/rbutilqt/base/talkgenerator.h | 1 |
2 files changed, 49 insertions, 27 deletions
diff --git a/rbutil/rbutilqt/base/talkgenerator.cpp b/rbutil/rbutilqt/base/talkgenerator.cpp index f1aa783281..9b0cbf4066 100644 --- a/rbutil/rbutilqt/base/talkgenerator.cpp +++ b/rbutil/rbutilqt/base/talkgenerator.cpp | |||
@@ -24,7 +24,7 @@ | |||
24 | 24 | ||
25 | TalkGenerator::TalkGenerator(QObject* parent): QObject(parent), encFutureWatcher(this), ttsFutureWatcher(this) | 25 | TalkGenerator::TalkGenerator(QObject* parent): QObject(parent), encFutureWatcher(this), ttsFutureWatcher(this) |
26 | { | 26 | { |
27 | 27 | m_userAborted = false; | |
28 | } | 28 | } |
29 | 29 | ||
30 | //! \brief Creates Talkfiles. | 30 | //! \brief Creates Talkfiles. |
@@ -126,32 +126,52 @@ TalkGenerator::Status TalkGenerator::voiceList(QList<TalkEntry>* list,int wavtri | |||
126 | } | 126 | } |
127 | 127 | ||
128 | /* If the engine can't be parallelized, we use only 1 thread */ | 128 | /* If the engine can't be parallelized, we use only 1 thread */ |
129 | int maxThreadCount = QThreadPool::globalInstance()->maxThreadCount(); | 129 | // NOTE: setting the number of maximum threads to use to 1 doesn't seem to |
130 | if ((m_tts->capabilities() & TTSBase::RunInParallel) == 0) | 130 | // work as expected -- it causes sporadically output files missing (see |
131 | QThreadPool::globalInstance()->setMaxThreadCount(1); | 131 | // FS#11994). As a stop-gap solution use a separate implementation in that |
132 | qDebug() << "[TalkGenerator] Maximum number of threads used:" | 132 | // case for running the TTS. |
133 | << QThreadPool::globalInstance()->maxThreadCount(); | 133 | if((m_tts->capabilities() & TTSBase::RunInParallel) != 0) |
134 | 134 | { | |
135 | connect(&ttsFutureWatcher, SIGNAL(progressValueChanged(int)), | 135 | int maxThreadCount = QThreadPool::globalInstance()->maxThreadCount(); |
136 | this, SLOT(ttsProgress(int))); | 136 | qDebug() << "[TalkGenerator] Maximum number of threads used:" |
137 | ttsFutureWatcher.setFuture(QtConcurrent::map(*list, &TalkGenerator::ttsEntryPoint)); | 137 | << QThreadPool::globalInstance()->maxThreadCount(); |
138 | 138 | ||
139 | /* We use this loop as an equivalent to ttsFutureWatcher.waitForFinished() | 139 | connect(&ttsFutureWatcher, SIGNAL(progressValueChanged(int)), |
140 | * since the latter blocks all events */ | 140 | this, SLOT(ttsProgress(int))); |
141 | while(ttsFutureWatcher.isRunning()) | 141 | ttsFutureWatcher.setFuture(QtConcurrent::map(*list, &TalkGenerator::ttsEntryPoint)); |
142 | QCoreApplication::processEvents(); | 142 | |
143 | 143 | /* We use this loop as an equivalent to ttsFutureWatcher.waitForFinished() | |
144 | /* Restore global settings, if we changed them */ | 144 | * since the latter blocks all events */ |
145 | if ((m_tts->capabilities() & TTSBase::RunInParallel) == 0) | 145 | while(ttsFutureWatcher.isRunning()) |
146 | QThreadPool::globalInstance()->setMaxThreadCount(maxThreadCount); | 146 | QCoreApplication::processEvents(); |
147 | 147 | ||
148 | if(ttsFutureWatcher.isCanceled()) | 148 | /* Restore global settings, if we changed them */ |
149 | return eERROR; | 149 | if ((m_tts->capabilities() & TTSBase::RunInParallel) == 0) |
150 | else if(m_ttsWarnings) | 150 | QThreadPool::globalInstance()->setMaxThreadCount(maxThreadCount); |
151 | return eWARNING; | 151 | |
152 | else | 152 | if(ttsFutureWatcher.isCanceled()) |
153 | return eOK; | 153 | return eERROR; |
154 | } | 154 | else if(m_ttsWarnings) |
155 | return eWARNING; | ||
156 | else | ||
157 | return eOK; | ||
158 | } | ||
159 | else { | ||
160 | qDebug() << "[TalkGenerator] Using single thread TTS workaround"; | ||
161 | int items = list->size(); | ||
162 | for(int i = 0; i < items; i++) { | ||
163 | if(m_userAborted) { | ||
164 | emit logItem(tr("Voicing aborted"), LOGERROR); | ||
165 | return eERROR; | ||
166 | } | ||
167 | TalkEntry entry = list->at(i); | ||
168 | TalkGenerator::ttsEntryPoint(entry); | ||
169 | (*list)[i] = entry; | ||
170 | emit logProgress(i, items); | ||
171 | } | ||
172 | return m_ttsWarnings ? eWARNING : eOK; | ||
173 | } | ||
174 | } | ||
155 | 175 | ||
156 | void TalkGenerator::ttsEntryPoint(TalkEntry& entry) | 176 | void TalkGenerator::ttsEntryPoint(TalkEntry& entry) |
157 | { | 177 | { |
@@ -279,5 +299,6 @@ void TalkGenerator::abort() | |||
279 | encFutureWatcher.cancel(); | 299 | encFutureWatcher.cancel(); |
280 | emit logItem(tr("Encoding aborted"), LOGERROR); | 300 | emit logItem(tr("Encoding aborted"), LOGERROR); |
281 | } | 301 | } |
302 | m_userAborted = true; | ||
282 | } | 303 | } |
283 | 304 | ||
diff --git a/rbutil/rbutilqt/base/talkgenerator.h b/rbutil/rbutilqt/base/talkgenerator.h index cca196bc2e..d0cbcd0af3 100644 --- a/rbutil/rbutilqt/base/talkgenerator.h +++ b/rbutil/rbutilqt/base/talkgenerator.h | |||
@@ -94,6 +94,7 @@ private: | |||
94 | EncBase* m_enc; | 94 | EncBase* m_enc; |
95 | 95 | ||
96 | bool m_ttsWarnings; | 96 | bool m_ttsWarnings; |
97 | bool m_userAborted; | ||
97 | }; | 98 | }; |
98 | 99 | ||
99 | 100 | ||