mirror of
https://github.com/linux-speakup/espeakup.git
synced 2026-08-21 07:14:18 +02:00
removed acknowledge_guard and substituted queue_guard
This commit is contained in:
parent
1091182f88
commit
b8c7247feb
4 changed files with 4 additions and 15 deletions
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
13
softsynth.c
13
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)
|
||||
|
|
|
|||
4
synth.c
4
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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue