speechd-discuss
[Top][All Lists]
Advanced

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

[PATCH] pico.c: module_close now exits; fixed threading issues.


From: Christopher Brannon
Subject: [PATCH] pico.c: module_close now exits; fixed threading issues.
Date: Wed, 17 Nov 2010 01:29:36 +0000

The module_close function in pico.c was not calling exit().
Now it does.
Also, there was a small threading issue.  The "play" thread
could be sending audio to the audio device while we are trying to close
it.  Now, we close the audio device after joining the "play" thread.

For good measure, all pointer variables are set to NULL,
once we are done with them.
---
 src/modules/pico.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/modules/pico.c b/src/modules/pico.c
index 8b50eb1..e5a812a 100644
--- a/src/modules/pico.c
+++ b/src/modules/pico.c
@@ -607,9 +607,6 @@ size_t module_pause(void)
 
 void module_close(int status)
 {
-       if (module_audio_id) {
-               spd_audio_close(module_audio_id);
-       }
 
        g_atomic_int_set(&pico_state, STATE_CLOSE);
        sem_post(pico_play_semaphore);
@@ -621,6 +618,14 @@ void module_close(int status)
                picoSystem = NULL;
        }
 
+       if (module_audio_id) {
+               spd_audio_close(module_audio_id);
+       }
+       module_audio_id = NULL;
+
        g_free(pico_idle_semaphore);
        g_free(pico_play_semaphore);
+       pico_idle_semaphore = NULL;
+       pico_play_semaphore = NULL;
+       exit(status);
 }
-- 
1.7.3.2




reply via email to

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