From 32d848cb76de9853564d7e2ea37725c1f9af1ae4 Mon Sep 17 00:00:00 2001 From: William Hubbs Date: Wed, 1 Jul 2009 12:22:14 -0500 Subject: [PATCH] make callback honor should_run The callback should return and abort synthesis if should_run is 0. This fixes slow shutdown times in alsa mode. --- alsa.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/alsa.c b/alsa.c index 9885319..b15489c 100644 --- a/alsa.c +++ b/alsa.c @@ -74,12 +74,12 @@ static int alsa_callback(short *audio, int numsamples, espeak_EVENT * events) int rc = 0; lock_audio_mutex(); - if (stop_requested) { + if (stop_requested || !should_run) { unlock_audio_mutex(); return 1; } - while (numsamples > 0 && ! stop_requested) { + while (numsamples > 0 && (! stop_requested && should_run)) { avail = snd_pcm_avail_update(handle); if (avail <= 0) { if (avail < 0) @@ -95,7 +95,7 @@ static int alsa_callback(short *audio, int numsamples, espeak_EVENT * events) audio += samples_written; } } - rc = stop_requested; + rc = (stop_requested || !should_run); unlock_audio_mutex(); return rc; }