diff options
author | Stéphane Doyon <s.doyon@videotron.ca> | 2008-07-15 14:06:11 +0000 |
---|---|---|
committer | Stéphane Doyon <s.doyon@videotron.ca> | 2008-07-15 14:06:11 +0000 |
commit | c893affeefa35975c916a222d20a989f31555646 (patch) | |
tree | 72db68190ff77e70e0d9ffc0df4753a24b2261e1 /apps/voice_thread.c | |
parent | 4aafed43d40d72315ad314b71737b169f8dbdf22 (diff) | |
download | rockbox-c893affeefa35975c916a222d20a989f31555646.tar.gz rockbox-c893affeefa35975c916a222d20a989f31555646.zip |
Accept FS#8918: Voice multiple thumbnails and talk race fixes.
-Allows loading multiple thumbnails back-to-back in the one thumbnail buffer.
-Mutex to prevent race conditions with talk queue indices and
thumbnail buffer state.
-Synchronous shutup.
-Shutup is a noop if no voice is queued.
-mp3_play_stop() does nothing until the audio thread is ready.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18046 a1c6a512-1295-4272-9138-f99709370657
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) |