speechd-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 5/7] remove spd_audio_stop from modules


From: Andrei Kholodnyi
Subject: [PATCH 5/7] remove spd_audio_stop from modules
Date: Sun, 28 Nov 2010 19:51:26 +0100

it is not the task of the synth module to stop audio.
now we stop audio before we call module_stop or module_pause
---
 src/modules/espeak.c       |   15 ++-------------
 src/modules/festival.c     |    3 ---
 src/modules/flite.c        |    7 -------
 src/modules/ibmtts.c       |   10 ----------
 src/modules/ivona.c        |    7 -------
 src/modules/module_utils.c |    8 +++++++-
 6 files changed, 9 insertions(+), 41 deletions(-)

diff --git a/src/modules/espeak.c b/src/modules/espeak.c
index 4bb1be9..6c62fb8 100644
--- a/src/modules/espeak.c
+++ b/src/modules/espeak.c
@@ -547,19 +547,8 @@ _espeak_stop_or_pause(void* nothing)
                pthread_cond_broadcast(&playback_queue_condition);
                pthread_mutex_unlock(&playback_queue_mutex);
        
-               if (module_audio_id) {
-                       DBG("Espeak: Stopping audio.");
-                       ret = spd_audio_stop(module_audio_id);
-                       DBG_WARN(ret == 0, "spd_audio_stop returned non-zero 
value.");
-                       while (is_thread_busy(&espeak_play_suspended_mutex))  {
-                               ret = spd_audio_stop(module_audio_id);
-                               DBG_WARN(ret == 0, "spd_audio_stop returned 
non-zero value.");
-                               g_usleep(5000);
-                       }
-               } else {
-                       while (is_thread_busy(&espeak_play_suspended_mutex)) {
-                               g_usleep(5000);
-                       }
+               while (is_thread_busy(&espeak_play_suspended_mutex)) {
+                       g_usleep(5000);
                }
        
                DBG("Espeak: Waiting for synthesis to stop.");
diff --git a/src/modules/festival.c b/src/modules/festival.c
index c9c7035..7651200 100644
--- a/src/modules/festival.c
+++ b/src/modules/festival.c
@@ -421,9 +421,6 @@ module_stop(void)
        if (!festival_stop){
            pthread_mutex_lock(&sound_output_mutex);       
            festival_stop = 1;
-           if (festival_speaking && module_audio_id){
-               spd_audio_stop(module_audio_id);
-           }
            pthread_mutex_unlock(&sound_output_mutex);
        }
     }
diff --git a/src/modules/flite.c b/src/modules/flite.c
index 07762ab..23fdd25 100644
--- a/src/modules/flite.c
+++ b/src/modules/flite.c
@@ -190,16 +190,9 @@ module_speak(gchar *data, size_t bytes, SPDMessageType 
msgtype)
 int
 module_stop(void) 
 {
-    int ret;
     DBG("flite: stop()\n");
 
     flite_stop = 1;
-    if (module_audio_id){
-       DBG("Stopping audio");
-       ret = spd_audio_stop(module_audio_id);
-       if (ret != 0) DBG("WARNING: Non 0 value from spd_audio_stop: %d", ret);
-    }
-
     return 0;
 }
 
diff --git a/src/modules/ibmtts.c b/src/modules/ibmtts.c
index c560f4f..6678589 100644
--- a/src/modules/ibmtts.c
+++ b/src/modules/ibmtts.c
@@ -779,16 +779,6 @@ _ibmtts_stop_or_pause(void* nothing)
                 DBG("Ibmtts: Stopping synthesis.");
                 eciStop(eciHandle);
             }
-
-            /* Stop any audio playback (if in progress). */
-            if (module_audio_id)
-            {
-                pthread_mutex_lock(&sound_stop_mutex);
-                DBG("Ibmtts: Stopping audio.");
-                int ret = spd_audio_stop(module_audio_id);
-                if (0 != ret) DBG("Ibmtts: WARNING: Non 0 value from 
spd_audio_stop: %d", ret);
-                pthread_mutex_unlock(&sound_stop_mutex);
-            }
         }
 
         DBG("Ibmtts: Waiting for synthesis thread to suspend.");
diff --git a/src/modules/ivona.c b/src/modules/ivona.c
index 6baf687..44aee43 100644
--- a/src/modules/ivona.c
+++ b/src/modules/ivona.c
@@ -213,16 +213,9 @@ module_speak(gchar *data, size_t bytes, SPDMessageType 
msgtype)
 int
 module_stop(void) 
 {
-    int ret;
     DBG("ivona: stop()\n");
 
     ivona_stop = 1;
-    if (module_audio_id){
-       DBG("Stopping audio");
-       ret = spd_audio_stop(module_audio_id);
-       if (ret != 0) DBG("WARNING: Non 0 value from spd_audio_stop: %d", ret);
-    }
-
     return 0;
 }
 
diff --git a/src/modules/module_utils.c b/src/modules/module_utils.c
index a39a85b..c6522c5 100644
--- a/src/modules/module_utils.c
+++ b/src/modules/module_utils.c
@@ -134,6 +134,9 @@ do_key(void)
 void
 do_stop(void)
 {
+    if(module_audio_id)
+        spd_audio_stop(module_audio_id);
+
     module_stop();
     return;
 }
@@ -142,7 +145,10 @@ void
 do_pause(void)
 {
     int ret;
-   
+
+    if(module_audio_id)
+        spd_audio_stop(module_audio_id);
+
     ret = module_pause(); 
     if (ret){
        DBG("WARNING: Can't pause");
-- 
1.6.0.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]