From b8c7247feb05a07bab653cab2a6be50a4a17fd5d Mon Sep 17 00:00:00 2001 From: William Hubbs Date: Thu, 25 Jun 2009 14:05:36 -0500 Subject: [PATCH] removed acknowledge_guard and substituted queue_guard --- espeakup.c | 1 - espeakup.h | 1 - softsynth.c | 13 ++----------- synth.c | 4 ++-- 4 files changed, 4 insertions(+), 15 deletions(-) diff --git a/espeakup.c b/espeakup.c index 0cf3d0b..65570f0 100644 --- a/espeakup.c +++ b/espeakup.c @@ -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) { diff --git a/espeakup.h b/espeakup.h index d5d3f18..ffe375b 100644 --- a/espeakup.h +++ b/espeakup.h @@ -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 diff --git a/softsynth.c b/softsynth.c index 094eab0..258d6e0 100644 --- a/softsynth.c +++ b/softsynth.c @@ -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) diff --git a/synth.c b/synth.c index f61d529..9fbdf07 100644 --- a/synth.c +++ b/synth.c @@ -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);