diff options
author | Thomas Jarosch <tomj@simonv.com> | 2014-12-20 02:06:24 +0100 |
---|---|---|
committer | Thomas Jarosch <tomj@simonv.com> | 2014-12-20 02:23:15 +0100 |
commit | c55be3b83ae2e23754a93ee8676d76604c0a5f8e (patch) | |
tree | cf8d481a4533094ea24a3c84352931e0bd96be40 /firmware/target/hosted | |
parent | 55a5aab97cf4d487688a958c65a4851c8e3e0405 (diff) | |
download | rockbox-c55be3b83ae2e23754a93ee8676d76604c0a5f8e.tar.gz 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')
-rw-r--r-- | firmware/target/hosted/sdl/system-sdl.c | 18 |
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) | |||
159 | if (background && picture_surface != NULL) | 159 | if (background && picture_surface != NULL) |
160 | SDL_BlitSurface(picture_surface, NULL, gui_surface, NULL); | 160 | SDL_BlitSurface(picture_surface, NULL, gui_surface, NULL); |
161 | 161 | ||
162 | /* let system_init proceed */ | ||
163 | SDL_SemPost((SDL_sem *)param); | ||
164 | |||
165 | #if (CONFIG_PLATFORM & PLATFORM_MAEMO) | 162 | #if (CONFIG_PLATFORM & PLATFORM_MAEMO) |
166 | /* Start maemo thread: Listen to display on/off events and battery monitoring */ | 163 | /* start maemo thread: Listen to display on/off events and battery monitoring */ |
167 | wait_for_maemo_startup = SDL_CreateSemaphore(0); /* 0-count so it blocks */ | 164 | wait_for_maemo_startup = SDL_CreateSemaphore(0); /* 0-count so it blocks */ |
168 | SDL_Thread *maemo_thread = SDL_CreateThread(maemo_thread_func, wait_for_maemo_startup); | 165 | SDL_Thread *maemo_thread = SDL_CreateThread(maemo_thread_func, wait_for_maemo_startup); |
166 | |||
167 | SDL_SemWait(wait_for_maemo_startup); | ||
168 | SDL_DestroySemaphore(wait_for_maemo_startup); | ||
169 | #endif | 169 | #endif |
170 | 170 | ||
171 | /* let system_init proceed */ | ||
172 | SDL_SemPost((SDL_sem *)param); | ||
173 | |||
171 | /* | 174 | /* |
172 | * finally enter the button loop */ | 175 | * finally enter the button loop */ |
173 | gui_message_loop(); | 176 | gui_message_loop(); |
174 | 177 | ||
175 | #if (CONFIG_PLATFORM & PLATFORM_MAEMO) | ||
176 | /* Ensure maemo thread is up and running */ | ||
177 | SDL_SemWait(wait_for_maemo_startup); | ||
178 | SDL_DestroySemaphore(wait_for_maemo_startup); | ||
179 | |||
180 | #if (CONFIG_PLATFORM & PLATFORM_MAEMO5) | 178 | #if (CONFIG_PLATFORM & PLATFORM_MAEMO5) |
181 | pcm_shutdown_gstreamer(); | 179 | pcm_shutdown_gstreamer(); |
182 | #endif | 180 | #endif |
183 | 181 | #if (CONFIG_PLATFORM & PLATFORM_MAEMO) | |
184 | g_main_loop_quit (maemo_main_loop); | 182 | g_main_loop_quit (maemo_main_loop); |
185 | g_main_loop_unref(maemo_main_loop); | 183 | g_main_loop_unref(maemo_main_loop); |
186 | SDL_WaitThread(maemo_thread, NULL); | 184 | SDL_WaitThread(maemo_thread, NULL); |