diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2010-05-26 21:11:40 +0000 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2010-05-26 21:11:40 +0000 |
commit | 28a7c5d3692e59b5c80a9f713cf931b6453cb1ca (patch) | |
tree | 57e6ef65ec40ae191570222030e998cdd2cab1f4 /firmware/target | |
parent | c9133db4b1bd584146578589f8616a873553f66b (diff) | |
download | rockbox-28a7c5d3692e59b5c80a9f713cf931b6453cb1ca.tar.gz 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/target')
-rw-r--r-- | firmware/target/hosted/sdl/system-sdl.c | 37 |
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) | |||
76 | void gui_message_loop(void); | 76 | void gui_message_loop(void); |
77 | 77 | ||
78 | /* | 78 | /* |
79 | * This callback let's the main thread run again after SDL has been initialized | ||
80 | **/ | ||
81 | static uint32_t cond_signal(uint32_t interval, void *param) | ||
82 | { | ||
83 | (void)interval; | ||
84 | SDL_cond *c = (SDL_cond*)param; | ||
85 | /* remove timer, CondSignal returns 0 on success */ | ||
86 | return SDL_CondSignal(c); | ||
87 | } | ||
88 | |||
89 | /* | ||
90 | * This thread will read the buttons in an interrupt like fashion, and | 79 | * This thread will read the buttons in an interrupt like fashion, and |
91 | * also initializes SDL_INIT_VIDEO and the surfaces | 80 | * also initializes SDL_INIT_VIDEO and the surfaces |
92 | * | 81 | * |
@@ -143,9 +132,9 @@ static int sdl_event_thread(void * param) | |||
143 | if (background && picture_surface != NULL) | 132 | if (background && picture_surface != NULL) |
144 | SDL_BlitSurface(picture_surface, NULL, gui_surface, NULL); | 133 | SDL_BlitSurface(picture_surface, NULL, gui_surface, NULL); |
145 | 134 | ||
146 | /* calling SDL_CondSignal() right away here doesn't work reliably so | 135 | /* let system_init proceed */ |
147 | * post-pone it a bit */ | 136 | SDL_SemPost((SDL_sem *)param); |
148 | SDL_AddTimer(100, cond_signal, param); | 137 | |
149 | /* | 138 | /* |
150 | * finally enter the button loop */ | 139 | * finally enter the button loop */ |
151 | while(1) | 140 | while(1) |
@@ -157,26 +146,22 @@ static int sdl_event_thread(void * param) | |||
157 | 146 | ||
158 | void system_init(void) | 147 | void system_init(void) |
159 | { | 148 | { |
160 | SDL_cond *c; | 149 | SDL_sem *s; |
161 | SDL_mutex *m; | 150 | |
162 | if (SDL_Init(SDL_INIT_TIMER)) | 151 | if (SDL_Init(SDL_INIT_TIMER)) |
163 | panicf("%s", SDL_GetError()); | 152 | panicf("%s", SDL_GetError()); |
164 | atexit(sys_poweroff); | 153 | atexit(sys_poweroff); |
165 | 154 | ||
166 | c = SDL_CreateCond(); | 155 | s = SDL_CreateSemaphore(0); /* 0-count so it blocks */ |
167 | m = SDL_CreateMutex(); | ||
168 | 156 | ||
169 | SDL_CreateThread(sdl_event_thread, c); | 157 | SDL_CreateThread(sdl_event_thread, s); |
170 | 158 | ||
171 | /* Lock mutex and wait for sdl_event_thread to run so that it can | 159 | /* wait for sdl_event_thread to run so that it can initialize the surfaces |
172 | * initialize the surfaces and video subsystem needed for SDL events */ | 160 | * and video subsystem needed for SDL events */ |
173 | SDL_LockMutex(m); | 161 | SDL_SemWait(s); |
174 | SDL_CondWait(c, m); | ||
175 | SDL_UnlockMutex(m); | ||
176 | 162 | ||
177 | /* cleanup */ | 163 | /* cleanup */ |
178 | SDL_DestroyCond(c); | 164 | SDL_DestroySemaphore(s); |
179 | SDL_DestroyMutex(m); | ||
180 | } | 165 | } |
181 | 166 | ||
182 | void system_exception_wait(void) | 167 | void system_exception_wait(void) |