removed acknowledge_guard and substituted queue_guard

This commit is contained in:
William Hubbs 2009-06-25 14:05:36 -05:00
commit b8c7247feb
4 changed files with 4 additions and 15 deletions

View file

@ -42,7 +42,6 @@ espeak_AUDIO_OUTPUT audio_mode;
pthread_cond_t runner_awake = PTHREAD_COND_INITIALIZER;
pthread_cond_t stop_acknowledged = PTHREAD_COND_INITIALIZER;
pthread_mutex_t queue_guard = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t acknowledge_guard = PTHREAD_MUTEX_INITIALIZER;
int espeakup_is_running(void)
{

View file

@ -88,6 +88,5 @@ extern espeak_AUDIO_OUTPUT audio_mode;
extern pthread_cond_t runner_awake;
extern pthread_cond_t stop_acknowledged;
extern pthread_mutex_t queue_guard;
extern pthread_mutex_t acknowledge_guard;
#endif

View file

@ -167,20 +167,11 @@ static void process_buffer(struct synth_t *s, char *buf, ssize_t length)
static void request_espeak_stop(void)
{
pthread_mutex_lock(&acknowledge_guard);
pthread_mutex_lock(&queue_guard);
runner_must_stop = 1;
pthread_mutex_unlock(&queue_guard);
pthread_cond_signal(&runner_awake); /* Wake runner, if necessary. */
/*
* Runner will see runner_must_stop == 1 next time it locks
* queue_guard, or when it awakens.
* It will lock acknowledge_guard, acknowledge the stop, and signal
* the reader, which will awaken.
*/
pthread_cond_wait(&stop_acknowledged, &acknowledge_guard);
pthread_mutex_unlock(&acknowledge_guard);
pthread_cond_wait(&stop_acknowledged, &queue_guard);
pthread_mutex_unlock(&queue_guard);
}
void *softsynth_thread(void *arg)

View file

@ -265,12 +265,12 @@ void *espeak_thread(void *arg)
}
if (runner_must_stop) {
pthread_mutex_lock(&acknowledge_guard);
pthread_mutex_lock(&queue_guard);
queue_clear();
stop_speech();
runner_must_stop = 0;
pthread_mutex_unlock(&acknowledge_guard);
pthread_cond_signal(&stop_acknowledged);
pthread_mutex_unlock(&queue_guard);
}
}
pthread_mutex_unlock(&queue_guard);