From 5d63776a24cb3de9f5ddbfbfb13ce03e50264c03 Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Sun, 11 Mar 2007 05:04:48 +0000 Subject: Reenable aynchronous audio init stage. Really just single stage with aynchronous enabling of outputs. Keeps audio_init last so prior init steps can use the audiobuffer in any desired way. Audio will be fully initialized by the time the UI is entered. Playback of voice or audio will be delayed properly until audio hardware is ready. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12714 a1c6a512-1295-4272-9138-f99709370657 --- apps/playback.c | 14 ++++++++++++-- apps/playback.h | 1 - 2 files changed, 12 insertions(+), 3 deletions(-) (limited to 'apps') diff --git a/apps/playback.c b/apps/playback.c index 2ea6e2f004..c3d28110dd 100644 --- a/apps/playback.c +++ b/apps/playback.c @@ -3443,6 +3443,11 @@ static bool ata_fillbuffer_callback(void) static void audio_thread(void) { struct event ev; + + audiohw_postinit(); + + /* Unlock mutex that init stage locks before creating this thread */ + mutex_unlock(&mutex_codecthread); while (1) { @@ -3604,6 +3609,10 @@ void audio_init(void) starts running until ready if something yields such as talk_init. */ #ifdef PLAYBACK_VOICE mutex_init(&mutex_codecthread); + /* Take ownership of lock to prevent playback of anything before audio + hardware is initialized - audio thread unlocks it after final init + stage */ + mutex_lock(&mutex_codecthread); #endif queue_init(&audio_queue, true); queue_enable_queue_send(&audio_queue, &audio_queue_sender_list); @@ -3656,6 +3665,7 @@ void audio_init(void) /* initialize the buffer */ filebuf = audiobuf; /* must be non-NULL for audio_set_crossfade */ + /* audio_reset_buffer must to know the size of voice buffer so init voice first */ talk_init(); @@ -3670,9 +3680,9 @@ void audio_init(void) IF_COP(, CPU, false)); audio_set_crossfade(global_settings.crossfade); - + audio_is_initialized = true; - + sound_settings_apply(); audio_set_buffer_margin(global_settings.buffer_margin); } /* audio_init */ diff --git a/apps/playback.h b/apps/playback.h index ccf8b58472..82179f1ee2 100644 --- a/apps/playback.h +++ b/apps/playback.h @@ -74,7 +74,6 @@ extern void audio_prev_dir(void); #define audio_next_dir() #define audio_prev_dir() #endif -void audio_preinit(void); #endif -- cgit v1.2.3