summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2010-05-26 21:11:40 +0000
committerMichael Sevakis <jethead71@rockbox.org>2010-05-26 21:11:40 +0000
commit28a7c5d3692e59b5c80a9f713cf931b6453cb1ca (patch)
tree57e6ef65ec40ae191570222030e998cdd2cab1f4 /firmware
parentc9133db4b1bd584146578589f8616a873553f66b (diff)
downloadrockbox-28a7c5d3692e59b5c80a9f713cf931b6453cb1ca.tar.gz
rockbox-28a7c5d3692e59b5c80a9f713cf931b6453cb1ca.tar.bz2
rockbox-28a7c5d3692e59b5c80a9f713cf931b6453cb1ca.zip
UISimulator: cleaner startup using semaphore only to tell when event_thread is done initializing.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26317 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/target/hosted/sdl/system-sdl.c37
1 files changed, 11 insertions, 26 deletions
diff --git a/firmware/target/hosted/sdl/system-sdl.c b/firmware/target/hosted/sdl/system-sdl.c
index 7ab6fd2c34..d6c0dfa345 100644
--- a/firmware/target/hosted/sdl/system-sdl.c
+++ b/firmware/target/hosted/sdl/system-sdl.c
@@ -76,17 +76,6 @@ void sys_poweroff(void)
void gui_message_loop(void);
/*
- * This callback let's the main thread run again after SDL has been initialized
- **/
-static uint32_t cond_signal(uint32_t interval, void *param)
-{
- (void)interval;
- SDL_cond *c = (SDL_cond*)param;
- /* remove timer, CondSignal returns 0 on success */
- return SDL_CondSignal(c);
-}
-
-/*
* This thread will read the buttons in an interrupt like fashion, and
* also initializes SDL_INIT_VIDEO and the surfaces
*
@@ -143,9 +132,9 @@ static int sdl_event_thread(void * param)
if (background && picture_surface != NULL)
SDL_BlitSurface(picture_surface, NULL, gui_surface, NULL);
- /* calling SDL_CondSignal() right away here doesn't work reliably so
- * post-pone it a bit */
- SDL_AddTimer(100, cond_signal, param);
+ /* let system_init proceed */
+ SDL_SemPost((SDL_sem *)param);
+
/*
* finally enter the button loop */
while(1)
@@ -157,26 +146,22 @@ static int sdl_event_thread(void * param)
void system_init(void)
{
- SDL_cond *c;
- SDL_mutex *m;
+ SDL_sem *s;
+
if (SDL_Init(SDL_INIT_TIMER))
panicf("%s", SDL_GetError());
atexit(sys_poweroff);
- c = SDL_CreateCond();
- m = SDL_CreateMutex();
+ s = SDL_CreateSemaphore(0); /* 0-count so it blocks */
- SDL_CreateThread(sdl_event_thread, c);
+ SDL_CreateThread(sdl_event_thread, s);
- /* Lock mutex and wait for sdl_event_thread to run so that it can
- * initialize the surfaces and video subsystem needed for SDL events */
- SDL_LockMutex(m);
- SDL_CondWait(c, m);
- SDL_UnlockMutex(m);
+ /* wait for sdl_event_thread to run so that it can initialize the surfaces
+ * and video subsystem needed for SDL events */
+ SDL_SemWait(s);
/* cleanup */
- SDL_DestroyCond(c);
- SDL_DestroyMutex(m);
+ SDL_DestroySemaphore(s);
}
void system_exception_wait(void)