From 52abe353009beda9dbbe52123a00d90292d6d7a8 Mon Sep 17 00:00:00 2001 From: "Reece H. Dunn" Date: Wed, 21 Dec 2016 16:00:51 +0000 Subject: [PATCH] Revert "Stop audio output before fifo_stop is called" This reverts commit 1b5ea47ea44f1e456c5a3a756481c829f49e29b5. This patch is causing lockups when using this with servers like brltty. --- src/libespeak-ng/fifo.c | 7 ++++--- src/libespeak-ng/speech.c | 9 ++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/libespeak-ng/fifo.c b/src/libespeak-ng/fifo.c index 1c8cc59b..33177434 100644 --- a/src/libespeak-ng/fifo.c +++ b/src/libespeak-ng/fifo.c @@ -236,10 +236,8 @@ static espeak_ng_STATUS close_stream() return status; int a_stop_is_required = my_stop_is_required; - if (!a_stop_is_required) { + if (!a_stop_is_required) my_command_is_running = 1; - pthread_cond_broadcast(&my_cond_command_is_running); - } status = pthread_mutex_unlock(&my_mutex); @@ -309,8 +307,11 @@ static void *say_thread(void *p) my_command_is_running = 1; assert(-1 != pthread_cond_broadcast(&my_cond_command_is_running)); + assert(-1 != pthread_mutex_unlock(&my_mutex)); while (my_command_is_running) { + int a_status = pthread_mutex_lock(&my_mutex); + assert(!a_status); t_espeak_command *a_command = (t_espeak_command *)pop(); if (a_command == NULL) { diff --git a/src/libespeak-ng/speech.c b/src/libespeak-ng/speech.c index 069d228e..a021bfc5 100644 --- a/src/libespeak-ng/speech.c +++ b/src/libespeak-ng/speech.c @@ -801,16 +801,15 @@ ESPEAK_API const char *espeak_TextToPhonemes(const void **textptr, int textmode, ESPEAK_NG_API espeak_ng_STATUS espeak_ng_Cancel(void) { -#ifdef HAVE_PCAUDIOLIB_AUDIO_H - if ((my_mode & ENOUTPUT_MODE_SPEAK_AUDIO) == ENOUTPUT_MODE_SPEAK_AUDIO) - audio_object_flush(my_audio); -#endif - #ifdef USE_ASYNC fifo_stop(); event_clear_all(); #endif +#ifdef HAVE_PCAUDIOLIB_AUDIO_H + if ((my_mode & ENOUTPUT_MODE_SPEAK_AUDIO) == ENOUTPUT_MODE_SPEAK_AUDIO) + audio_object_flush(my_audio); +#endif embedded_value[EMBED_T] = 0; // reset echo for pronunciation announcements for (int i = 0; i < N_SPEECH_PARAM; i++)