From 4f2473db6cecbb80323c5eee576b2e8e0901274f Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Mon, 19 Nov 2007 13:26:46 +0000 Subject: Do the wait for the audio thread init in such a way to avoid an unlikely but possible roundabout deadlock. Not pretty but will suffice for the moment. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15686 a1c6a512-1295-4272-9138-f99709370657 --- apps/playback.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/apps/playback.c b/apps/playback.c index 20f8d4f..e2ef260 100644 --- a/apps/playback.c +++ b/apps/playback.c @@ -174,6 +174,7 @@ enum { #endif bool audio_is_initialized = false; +static bool audio_thread_ready NOCACHEBSS_ATTR = false; /* Variables are commented with the threads that use them: * * A=audio, C=codec, V=voice. A suffix of - indicates that * @@ -2393,6 +2394,8 @@ static void audio_thread(void) pcm_postinit(); + audio_thread_ready = true; + while (1) { queue_wait_w_tmo(&audio_queue, &ev, HZ/2); @@ -2625,10 +2628,13 @@ void audio_init(void) } /* audio_init */ -/* Wait until audio thread can respond to messages - this implies - * it has finished initialization */ void audio_wait_for_init(void) { - LOGFQUEUE("audio >| Q_NULL"); - queue_send(&audio_queue, Q_NULL, 0); + /* 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_thread_ready) + { + sleep(0); + } } -- cgit v1.1