diff options
Diffstat (limited to 'apps/voice_thread.c')
-rw-r--r-- | apps/voice_thread.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/apps/voice_thread.c b/apps/voice_thread.c index 8d08e7744b..aeffa5bd7c 100644 --- a/apps/voice_thread.c +++ b/apps/voice_thread.c | |||
@@ -136,11 +136,12 @@ void mp3_play_data(const unsigned char* start, int size, | |||
136 | /* Stop current voice clip from playing */ | 136 | /* Stop current voice clip from playing */ |
137 | void mp3_play_stop(void) | 137 | void mp3_play_stop(void) |
138 | { | 138 | { |
139 | mutex_lock(&voice_mutex); /* Sync against voice_stop */ | 139 | if(!audio_is_thread_ready()) |
140 | return; | ||
140 | 141 | ||
141 | LOGFQUEUE("mp3 > voice Q_VOICE_STOP: 1"); | 142 | mutex_lock(&voice_mutex); /* Sync against voice_stop */ |
142 | queue_remove_from_head(&voice_queue, Q_VOICE_STOP); | 143 | LOGFQUEUE("mp3 >| voice Q_VOICE_STOP: 1"); |
143 | queue_post(&voice_queue, Q_VOICE_STOP, 1); | 144 | queue_send(&voice_queue, Q_VOICE_STOP, 1); |
144 | 145 | ||
145 | mutex_unlock(&voice_mutex); | 146 | mutex_unlock(&voice_mutex); |
146 | } | 147 | } |
@@ -167,8 +168,7 @@ void voice_stop(void) | |||
167 | mutex_lock(&voice_mutex); | 168 | mutex_lock(&voice_mutex); |
168 | 169 | ||
169 | /* Stop the output and current clip */ | 170 | /* Stop the output and current clip */ |
170 | LOGFQUEUE("mp3 >| voice Q_VOICE_STOP: 1"); | 171 | mp3_play_stop(); |
171 | queue_send(&voice_queue, Q_VOICE_STOP, 1); | ||
172 | 172 | ||
173 | /* Careful if using sync objects in talk.c - make sure locking order is | 173 | /* Careful if using sync objects in talk.c - make sure locking order is |
174 | * observed with one or the other always granted first */ | 174 | * observed with one or the other always granted first */ |
@@ -298,8 +298,13 @@ static void voice_thread(void) | |||
298 | struct voice_thread_data td; | 298 | struct voice_thread_data td; |
299 | 299 | ||
300 | voice_data_init(&td); | 300 | voice_data_init(&td); |
301 | audio_wait_for_init(); | 301 | |
302 | 302 | /* audio thread will only set this once after it finished the final | |
303 | * audio hardware init so this little construct is safe - even | ||
304 | * cross-core. */ | ||
305 | while (!audio_is_thread_ready()) | ||
306 | sleep(0); | ||
307 | |||
303 | goto message_wait; | 308 | goto message_wait; |
304 | 309 | ||
305 | while (1) | 310 | while (1) |