1. Don't lock or unlock queue_guard during queue_clear.
It is locked when queue_clear is called, and it should remain so.
2. Protect runner_must_stop with queue_guard in
the request_espeak_stop function.
The following condition should always hold: queue_guard is locked while
testing or modifying runner_must_stop.
3. Rename stop_guard to acknowledge_guard. This is a more
descriptive name. This mutex simply protects the acknowledgement of
the stop request from being lost.
4. Remove the pthread_mutex_lock from the top of queue_process_entry,
because queue_guard is already locked when the function is called.
Most of the idea for this change came from William:
Renamed queue_runner to espeak_thread. Moved espeak initialization
and termination to espeak_thread. The while loops that process
the queue now use the variable should_run.
The goal is to create threads for the reader, que runner/espeak
processing and signal handling.
As of this commit, this code is still being worked on, so it is broken.
espeak uses a sample rate of 22050 HZ, but let's not rely on that knowledge.
espeak_Initialize returns the sample rate on success,
so rely on that value when selecting a rate.
Make espeakup a multi-threaded program. One thread reads from the softsynth
device, queuing text and synthesis commands. The other thread processes
items from the queue.
This adds support for a --default-voice or -V (upper case) command line
option which will set the default voice espeakup uses. This takes a
name of an espeak voice -- for example:
espeakup --default-voice=en-us
or
espeakup -V en-us
This commit removes the synthcallback function since it wasn't doing
anything. Also, it has been reported that this may be causing the
sluggishness when espeakup is asked to shut up.
Thanks to Chris Brannon for finding this.
I have added queueing support so that when we read from the softsynth we
can put the text and commands we have read into a queue. This will
allow us to retry calling espeak_synth() if we fill espeak's internal
buffer.
This commit removes the softsynth file descriptor and the debug flag
from the synth structure. These will need to be accessed from a signal
handler and there is no way to pass the structure to it.
Also, the process_data function now works with local variables and assigns
them to the synth structure, avoiding allocating a buffer with malloc/free.