rhdunn / cainteoir-engine

The Cainteoir Text-to-Speech core engine
http://reecedunn.co.uk/cainteoir/
GNU General Public License v3.0
43 stars 8 forks source link

Using MBROLA voices can cause the engine to hang if stopping playback #26

Closed rhdunn closed 11 years ago

rhdunn commented 12 years ago

There is an issue where the interaction between cainteoir-engine, espeak and mbrola causes the process to hang when:

  1. reading with an mbrola voice through espeak
  2. stopping the current reading instance before it is complete
  3. reading with an mbrola voice again through espeak [NOTE: no sound is generated here]
  4. stopping the current reading instance before it is complete [NOTE: this is where the process hangs]

This can be seen through cainteoir-gtk.

At step [3] the speak_tts_thread thread (in src\libcainteoir\tts\engines.cpp) is actually hung in the speak->engine->speak call. Thus when pthread_join is called in step [4], the process itself hangs (joining on a hung thread).

Changing espeak_tts_callback in src\libcainteoir\tts\espeak.cpp to do:

if (callback->state() == tts::stopped) return 0;

instead of:

if (callback->state() == tts::stopped) return 1;

fixes the issue.

The real issue therefore is with espeak not correctly cleaning up the mbrola instance (which is a forked process) if the callback returns 1 to terminate the synthesis. Returning 0 here is not acceptable as it does not stop espeak and can cause a long delay (e.g. when speaking a large text document or <pre> element).

rhdunn commented 11 years ago

This has disappeared now on my system. Not sure what the original cause was/is. Maybe a bug in one of the system libraries (e.g. libc).