The only time queue_process_entry should lock the queue gard is when it
is removing the item from the queue. This happens only when the item
was successfully processed.
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.
This adds retry processing back to the queue functions. queue_remove
should only be called after the head entry on the queue is processed
successfully.
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.
This commit updates the makefile and the documentation to explain how to
build alsa support. It has not been fully tested, so it is not built by
default. Also, I was able to remove the conditional compile directives
from the source.
The stop_speech function needs to test the return code from
espeak_Cancel() to be sure the operation was successful before
signaling the callback to stop the audio.
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.