From 62634a323ebaff42328f7b6ca21c614e222d4c58 Mon Sep 17 00:00:00 2001 From: Magnus Holmgren Date: Sun, 16 Oct 2005 08:01:02 +0000 Subject: [PATCH] iriver: audio_init really needs to be called after playlist and tree init; delay initial application of buffer margin and crossfade to solve the settings dependency. This should fix the problem with large values in 'Max files in dir browser'. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7633 a1c6a512-1295-4272-9138-f99709370657 --- apps/main.c | 10 ++-------- apps/playback.c | 10 ++++++++++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/apps/main.c b/apps/main.c index 73bf614cb3..296b3fc351 100644 --- a/apps/main.c +++ b/apps/main.c @@ -135,7 +135,6 @@ void init(void) font_init(); show_logo(); lang_init(); - audio_init(); settings_reset(); settings_calc_config_sector(); settings_load(SETTINGS_ALL); @@ -158,6 +157,7 @@ void init(void) global_settings.mdb_shape, global_settings.mdb_enable, global_settings.superbass); + audio_init(); button_clear_queue(); /* Empty the keyboard buffer */ #if CONFIG_CODEC == SWCODEC talk_init(); @@ -296,11 +296,6 @@ void init(void) settings_load(SETTINGS_ALL); init_dircache(); - /* On software codec platforms we have to init audio before - calling audio_set_buffer_margin(). */ -#if (CONFIG_CODEC == SWCODEC) - audio_init(); -#endif settings_apply(); status_init(); @@ -323,10 +318,9 @@ void init(void) global_settings.mdb_shape, global_settings.mdb_enable, global_settings.superbass); + audio_init(); #if (CONFIG_CODEC == SWCODEC) sound_settings_apply(); -#else - audio_init(); #endif #if defined(IRIVER_H100_SERIES) && !defined(SIMULATOR) pcm_init_recording(); diff --git a/apps/playback.c b/apps/playback.c index 4d73c35132..7c8339f3d3 100644 --- a/apps/playback.c +++ b/apps/playback.c @@ -686,6 +686,9 @@ static void set_filebuf_watermark(int seconds) if (current_codec == CODEC_IDX_VOICE) return ; + + if (!filebuf) + return; /* Audio buffers not yet set up */ bytes = MAX((int)cur_ti->id3.bitrate * seconds * (1000/8), conf_watermark); bytes = MIN(bytes, filebuflen / 2); @@ -2168,6 +2171,9 @@ void audio_set_crossfade(int type) static const int lookup[] = {1, 2, 4, 6, 8, 10, 12, 14}; int seconds = lookup[global_settings.crossfade_duration]; + if (!filebuf) + return; /* Audio buffers not yet set up */ + /* Store the track resume position */ if (playing) offset = cur_ti->id3.offset; @@ -2285,6 +2291,10 @@ void audio_init(void) queue_init(&codec_queue); queue_init(&voice_codec_queue); + /* Apply relevant settings */ + audio_set_buffer_margin(global_settings.buffer_margin); + audio_set_crossfade(global_settings.crossfade); + create_thread(codec_thread, codec_stack, sizeof(codec_stack), codec_thread_name); create_thread(voice_codec_thread, voice_codec_stack,