Properly set audio_is_initialized flag for swcodec devices ad use it when initializing crossfade.  This should fix the problems with resuming playback at startup.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9853 a1c6a512-1295-4272-9138-f99709370657
diff --git a/apps/playback.c b/apps/playback.c
index a2f1672..6f5084e 100644
--- a/apps/playback.c
+++ b/apps/playback.c
@@ -146,7 +146,11 @@
 #endif
 #define CODEC_IRAM_SIZE     0xc000
 
+#ifndef SIMULATOR
 extern bool audio_is_initialized;
+#else
+static bool audio_is_initialized = false;
+#endif
 
 /* Buffer control thread. */
 static struct event_queue audio_queue;
@@ -2726,7 +2730,7 @@
 void audio_set_crossfade(int enable)
 {
     size_t size;
-    bool was_playing = playing;
+    bool was_playing = (playing && audio_is_initialized);
     size_t offset = 0;
     int seconds = 1;
 
@@ -2885,11 +2889,10 @@
 
     filebuf = (char *)&audiobuf[MALLOC_BUFSIZE];
 
-    /* FIXME: This call will infinite loop if called on the audio thread
-     * while playing, fortunately this is an init call so that should be
-     * impossible. */
     audio_set_crossfade(global_settings.crossfade);
 
+    audio_is_initialized = true;
+
     sound_settings_apply();
 }
 
diff --git a/firmware/mp3_playback.c b/firmware/mp3_playback.c
index 58dc3f7..a5a2511 100644
--- a/firmware/mp3_playback.c
+++ b/firmware/mp3_playback.c
@@ -624,7 +624,6 @@
     playstart_tick = 0;
     cumulative_ticks = 0;
     callback_for_more = 0;
-    audio_is_initialized = true;
 #endif
 }