summaryrefslogtreecommitdiffstats
path: root/firmware/target/hosted/sdl
diff options
context:
space:
mode:
authorThomas Jarosch <tomj@simonv.com>2014-12-20 02:06:24 +0100
committerThomas Jarosch <tomj@simonv.com>2014-12-20 02:23:15 +0100
commitc55be3b83ae2e23754a93ee8676d76604c0a5f8e (patch)
treecf8d481a4533094ea24a3c84352931e0bd96be40 /firmware/target/hosted/sdl
parent55a5aab97cf4d487688a958c65a4851c8e3e0405 (diff)
downloadrockbox-c55be3b83ae2e23754a93ee8676d76604c0a5f8e.tar.gz
rockbox-c55be3b83ae2e23754a93ee8676d76604c0a5f8e.tar.bz2
rockbox-c55be3b83ae2e23754a93ee8676d76604c0a5f8e.zip
maemo port: Fix startup crash exposed by audio thread refactoring
The refactoring of the audio thread in this commit ----------------------------------------------- commit 5857c44017a1641fce7f00da7f16c143daacbaf6 Author: Michael Sevakis <jethead71@rockbox.org> Date: Fri May 31 02:41:02 2013 -0400 Refactor audio thread to run both recording and playback. ----------------------------------------------- moved pcm_init() next to dsp_init() in apps/main.c:init(). Before that pcm_init() was called by audio_init(). Unfortunately the maemo init code didn't properly wait until the maemo thread was fully initialized, leading to dangling pointers when the code called by pcm_init() tried to access maemo's variables. Fix it by refactoring the "very fast shutdown" semaphore to wait until maemo is initialized in any case. This should also fix very rare rockbox crashes on startup that I got once a year or so. The new code has been tested by a script that starts and kills rockbox after one second. Change-Id: I464efce5f2b71ca869c72a5bc578555b8022e459
Diffstat (limited to 'firmware/target/hosted/sdl')
-rw-r--r--firmware/target/hosted/sdl/system-sdl.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/firmware/target/hosted/sdl/system-sdl.c b/firmware/target/hosted/sdl/system-sdl.c
index aa322ddf3a..37580ede7d 100644
--- a/firmware/target/hosted/sdl/system-sdl.c
+++ b/firmware/target/hosted/sdl/system-sdl.c
@@ -159,28 +159,26 @@ static int sdl_event_thread(void * param)
if (background && picture_surface != NULL)
SDL_BlitSurface(picture_surface, NULL, gui_surface, NULL);
- /* let system_init proceed */
- SDL_SemPost((SDL_sem *)param);
-
#if (CONFIG_PLATFORM & PLATFORM_MAEMO)
- /* Start maemo thread: Listen to display on/off events and battery monitoring */
+ /* start maemo thread: Listen to display on/off events and battery monitoring */
wait_for_maemo_startup = SDL_CreateSemaphore(0); /* 0-count so it blocks */
SDL_Thread *maemo_thread = SDL_CreateThread(maemo_thread_func, wait_for_maemo_startup);
+
+ SDL_SemWait(wait_for_maemo_startup);
+ SDL_DestroySemaphore(wait_for_maemo_startup);
#endif
+ /* let system_init proceed */
+ SDL_SemPost((SDL_sem *)param);
+
/*
* finally enter the button loop */
gui_message_loop();
-#if (CONFIG_PLATFORM & PLATFORM_MAEMO)
- /* Ensure maemo thread is up and running */
- SDL_SemWait(wait_for_maemo_startup);
- SDL_DestroySemaphore(wait_for_maemo_startup);
-
#if (CONFIG_PLATFORM & PLATFORM_MAEMO5)
pcm_shutdown_gstreamer();
#endif
-
+#if (CONFIG_PLATFORM & PLATFORM_MAEMO)
g_main_loop_quit (maemo_main_loop);
g_main_loop_unref(maemo_main_loop);
SDL_WaitThread(maemo_thread, NULL);