Commit graph

36 commits

Author SHA1 Message Date
William Hubbs
739e074072 reworked the queue_remove function
Now, when queue_remove is called, it returns the pointer to the data of
the first entry in the queue and removes the entry.
2009-06-30 20:15:20 -05:00
William Hubbs
ccb8cea91e stop speech before clearing the queue
Thanks to Kirk Reiser for pointing out that this makes the cancel
response faster.
2009-06-29 18:12:04 -05:00
Christopher Brannon
31ad5f04ca Completely data-agnostic queue functions.
The functions in queue.c no longer use static variables.  We can now use
them for multiple queues, if necessary.
2009-06-29 18:07:18 -05:00
William Hubbs
04d10d88ec more sound updates
removed the user_data processing code and put the call to snd_pcm_drop
in stop_audio.
2009-06-29 17:48:16 -05:00
William Hubbs
ceaae3640a audio should be stopped in softsynth_thread not espeak_thread 2009-06-29 15:59:55 -05:00
William Hubbs
c9f871f687 see if we need to silence speech before we process the queue 2009-06-29 15:26:48 -05:00
William Hubbs
a82bbd8140 fixed a memory leak
If we processed an entry from the queue successfully, we were removing
the entry itself from the queue but not freeing the memory allocated to
the entry.
2009-06-28 17:56:21 -05:00
William Hubbs
bcd64cb263 created a start_audio function
This moves audio control to the specific files, espeak_sound.c and
alsa.c, which are tied to the sound systems.
2009-06-27 17:49:57 -05:00
William Hubbs
4889572ad1 use user_data to detect old events
When espeak_Cancel is called, change the value of user_data that is
passed to the events, and, in the callback, use this to test to see if
cancel was received.  If the value of user_data has changed, discarde
events that have the old value.  This patch is from Chris Brannon.
2009-06-27 13:20:43 -05:00
William Hubbs
c1d33d6738 Set the espeak audio buffer size to 50 ms
This should help make the cancel command more responsive.
2009-06-26 16:00:08 -05:00
William Hubbs
0471ff47f4 add support for the user_data parameter to espeak_synth
The user_data parameter is just a pointer that is passed into the
espeak_synth call that is passed back to the callback.  In native mode,
we are not using it since there is not a callback.  However, in alsa
mode, it will be used to indicate when a cancel was processed.
2009-06-26 11:34:28 -05:00
William Hubbs
8f3e8f1967 moved the audio_mutex code to alsa
This is not needed for native sound support, so it has been moved into
the alsa specific code.
2009-06-26 09:50:11 -05:00
William Hubbs
24bcdf5666 another termination fix
espeak_thread needs to signal softsynth_thread once more as it is going
town so that softsynth_thread will see that should_run is now 0 and
terminate.
2009-06-25 22:00:25 -05:00
William Hubbs
eb74a3ce17 removed an unnecessary call to espeak_Terminate() 2009-06-25 18:45:37 -05:00
William Hubbs
dd00775695 initialization update
The main function now initializes espeak and opens the softsynth before
starting the threads.  This insures that the resources we need are
active.
2009-06-25 18:30:36 -05:00
William Hubbs
6a15f2cccf fixed first wait in softsynth thread
The thread should wait if there is nothing in the queue and if there is
not a request to stop.
Thanks to Chris Brannon for the patch.
2009-06-25 18:17:14 -05:00
William Hubbs
938e10b66a removed a nested lock/unlock 2009-06-25 14:36:25 -05:00
William Hubbs
b8c7247feb removed acknowledge_guard and substituted queue_guard 2009-06-25 14:05:36 -05:00
William Hubbs
0bf2cae5a6 moved lock/unlock in queue_process_entry
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.
2009-06-25 12:06:51 -05:00
Christopher Brannon
b7f324072f Fix concurrency bugs.
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.
2009-06-25 11:56:20 -05:00
William Hubbs
a8cad20de8 more multithreading work
Rearranged the queue handling code so that queue.c is generic.  Also
rearranged several functions in the threads.
2009-06-25 09:05:21 -05:00
Christopher Brannon
91b8960b6a Protect the stopped variable with a mutex.
An oversight.  Should have done this in the initial commit.
volatile does not imply atomic.
2009-06-21 14:36:13 -05:00
William Hubbs
0ad70b4eaa Revert "fixed stop_speech issue"
This reverts commit 1c440e5a42.
2009-06-20 19:14:42 -05:00
William Hubbs
1c440e5a42 fixed stop_speech issue
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.
2009-06-20 16:17:42 -05:00
Christopher Brannon
d373fb2aa7 An initial stab at ALSA support.
It's very raw right now.
2009-06-19 15:11:51 -05:00
William Hubbs
a1510b5e93 indentation fixes 2009-04-12 16:33:01 -05:00
William Hubbs
36b05aec41 Added support for the punctuation command from speakup 2008-10-18 16:56:47 -05:00
William Hubbs
f76d00f6af removed the callback function
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.
2008-10-04 11:39:01 -05:00
William Hubbs
9b0c6a8224 fixed the volume multiplier
The volume range is actually 0-200 instead of 0-100, so the multiplier
needed to be adjusted.
2008-09-27 12:23:11 -05:00
William Hubbs
527fb136de starting work toward supporting changing voices
This commit adds a set_voice() function which will ultimately allow the
user to switch voices.
2008-09-27 10:52:24 -05:00
William Hubbs
5ddeb1e978 indentation fixes 2008-09-01 12:50:16 -05:00
William Hubbs
ccc9c4aa4e modified rate offset
This commit moves the rate offset to 84 instead of 80 so that the
highest espeak rate can be reached by setting the speakup rate to
the maximum.
2008-08-31 11:30:01 -05:00
William Hubbs
02e72bda39 adjusted the rate multiplier
This gets us closer to espeak's top speed, which is 390 wpm.
2008-08-30 16:54:10 -05:00
William Hubbs
3e7e5be2b7 fixed bug with volume setting
Now the volume setting should be announced again.
2008-08-17 00:49:46 -05:00
William Hubbs
655894ee2a added queueing support
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.
2008-08-16 19:48:40 -05:00
William Hubbs
029dd03251 modularize the code
This commit just re-arranges the source so that it is easier to work with.
2008-08-15 00:11:48 -05:00