commit f9ab812e00549640ebf7d6f9416e151827ce5294
Author: Reece H. Dunn <msclrhd@gmail.com>
Date:   Sat Dec 24 09:00:55 2016 +0000

    issue 172: fix sluggish speech for stopped speech.
    
    This restores the behaviour removed in commit
    ca831d236a4eed5648254329554affac143a1740.
    
    When using eSpeak for audio and eSpeak in a server, using the async
    speech requests, that code stopped the audio as soon as possible
    from a cancel request. This allows servers like brltty to be more
    responsive.

--- a/src/libespeak-ng/fifo.c
+++ b/src/libespeak-ng/fifo.c
@@ -244,6 +244,10 @@ static espeak_ng_STATUS close_stream()
 			status = a_status;
 
 		if (a_stop_is_required) {
+			// stop the audio early, to be more responsive when using eSpeak NG
+			// for audio.
+			close_audio();
+
 			// acknowledge the stop request
 			a_status = sem_post(&my_sem_stop_is_acknowledged);
 			if (status == ENS_OK)
--- a/src/libespeak-ng/speech.c
+++ b/src/libespeak-ng/speech.c
@@ -81,6 +81,15 @@ int (*phoneme_callback)(const char *) =
 char path_home[N_PATH_HOME]; // this is the espeak-ng-data directory
 extern int saved_parameters[N_SPEECH_PARAM]; // Parameters saved on synthesis start
 
+void close_audio(void)
+{
+#ifdef HAVE_PCAUDIOLIB_AUDIO_H
+	if ((my_mode & ENOUTPUT_MODE_SPEAK_AUDIO) == ENOUTPUT_MODE_SPEAK_AUDIO) {
+		audio_object_close(my_audio);
+	}
+#endif
+}
+
 static int dispatch_audio(short *outbuf, int length, espeak_EVENT *event)
 {
 	int a_wave_can_be_played = 1;
--- a/src/libespeak-ng/speech.h
+++ b/src/libespeak-ng/speech.h
@@ -65,6 +65,8 @@ typedef struct {
 } MNEM_TAB;
 int LookupMnem(MNEM_TAB *table, const char *string);
 
+void close_audio(void);
+
 extern char path_home[N_PATH_HOME];    // this is the espeak-ng-data directory
 
 extern ESPEAK_NG_API void strncpy0(char *to, const char *from, int size);
