summaryrefslogtreecommitdiffstats
path: root/apps/voice_thread.c
diff options
context:
space:
mode:
authorSt├ęphane Doyon <s.doyon@videotron.ca>2008-07-15 14:06:11 +0000
committerSt├ęphane Doyon <s.doyon@videotron.ca>2008-07-15 14:06:11 +0000
commitc893affeefa35975c916a222d20a989f31555646 (patch)
tree72db68190ff77e70e0d9ffc0df4753a24b2261e1 /apps/voice_thread.c
parent4aafed43d40d72315ad314b71737b169f8dbdf22 (diff)
downloadrockbox-c893affeefa35975c916a222d20a989f31555646.tar.gz
rockbox-c893affeefa35975c916a222d20a989f31555646.tar.bz2
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.c21
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,
/* Stop current voice clip from playing */
void mp3_play_stop(void)
{
- mutex_lock(&voice_mutex); /* Sync against voice_stop */
+ if(!audio_is_thread_ready())
+ return;
- LOGFQUEUE("mp3 > voice Q_VOICE_STOP: 1");
- queue_remove_from_head(&voice_queue, Q_VOICE_STOP);
- queue_post(&voice_queue, Q_VOICE_STOP, 1);
+ mutex_lock(&voice_mutex); /* Sync against voice_stop */
+ LOGFQUEUE("mp3 >| voice Q_VOICE_STOP: 1");
+ queue_send(&voice_queue, Q_VOICE_STOP, 1);
mutex_unlock(&voice_mutex);
}
@@ -167,8 +168,7 @@ void voice_stop(void)
mutex_lock(&voice_mutex);
/* Stop the output and current clip */
- LOGFQUEUE("mp3 >| voice Q_VOICE_STOP: 1");
- queue_send(&voice_queue, Q_VOICE_STOP, 1);
+ mp3_play_stop();
/* Careful if using sync objects in talk.c - make sure locking order is
* observed with one or the other always granted first */
@@ -298,8 +298,13 @@ static void voice_thread(void)
struct voice_thread_data td;
voice_data_init(&td);
- audio_wait_for_init();
-
+
+ /* audio thread will only set this once after it finished the final
+ * audio hardware init so this little construct is safe - even
+ * cross-core. */
+ while (!audio_is_thread_ready())
+ sleep(0);
+
goto message_wait;
while (1)