summaryrefslogtreecommitdiff
path: root/firmware/target/hosted/sdl/system-sdl.c
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2011-02-28 03:24:48 +0000
committerThomas Martitz <kugel@rockbox.org>2011-02-28 03:24:48 +0000
commitd8f6c75ab94ee97e9a49ce669d74dc252225586a (patch)
treef2eee157a098402ed5ae05866505bfa0e0a20d2b /firmware/target/hosted/sdl/system-sdl.c
parentd69d406e096d9df587e9b263cc16553d17b63162 (diff)
downloadrockbox-d8f6c75ab94ee97e9a49ce669d74dc252225586a.tar.gz
rockbox-d8f6c75ab94ee97e9a49ce669d74dc252225586a.zip
Hopefully get shutdown/exit handling on SDL/maemo right.
Make shutdown_hw() not return as it's supposed to, ensure sim_do_exit() is called from main thread and move sim_kernel_shutdown() into it to simplify things. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29455 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/hosted/sdl/system-sdl.c')
-rw-r--r--firmware/target/hosted/sdl/system-sdl.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/firmware/target/hosted/sdl/system-sdl.c b/firmware/target/hosted/sdl/system-sdl.c
index 4dc5509397..7ddc5f8699 100644
--- a/firmware/target/hosted/sdl/system-sdl.c
+++ b/firmware/target/hosted/sdl/system-sdl.c
@@ -71,9 +71,10 @@ bool debug_audio = false;
71bool debug_wps = false; 71bool debug_wps = false;
72int wps_verbose_level = 3; 72int wps_verbose_level = 3;
73 73
74
75void sys_poweroff(void) 74void sys_poweroff(void)
76{ 75{
76 /* Post SYS_POWEROFF event. Will post SDL_USEREVENT in shutdown_hw() if successful. */
77 queue_broadcast(SYS_POWEROFF, 0);
77} 78}
78 79
79/* 80/*
@@ -187,16 +188,39 @@ static int sdl_event_thread(void * param)
187#ifdef HAVE_SDL_THREADS 188#ifdef HAVE_SDL_THREADS
188 sim_thread_shutdown(); /* not needed for native threads */ 189 sim_thread_shutdown(); /* not needed for native threads */
189#endif 190#endif
190 sim_kernel_shutdown();
191
192 return 0; 191 return 0;
193} 192}
194 193
195void sim_do_exit(void) 194void shutdown_hw(void)
196{ 195{
196 /* Shut down SDL event loop */
197 SDL_Event event;
198 memset(&event, 0, sizeof(SDL_Event));
199 event.type = SDL_USEREVENT;
200 SDL_PushEvent(&event);
201#ifdef HAVE_SDL_THREADS
202 /* since sim_thread_shutdown() grabs the mutex we need to let it free,
203 * otherwise SDL_WaitThread will deadlock */
204 struct thread_entry* t = sim_thread_unlock();
205#endif
197 /* wait for event thread to finish */ 206 /* wait for event thread to finish */
198 SDL_WaitThread(evt_thread, NULL); 207 SDL_WaitThread(evt_thread, NULL);
199 208
209#ifdef HAVE_SDL_THREADS
210 /* lock again before entering the scheduler */
211 sim_thread_lock(t);
212 /* sim_thread_shutdown() will cause sim_do_exit() to be called via longjmp,
213 * but only if we let the sdl thread scheduler exit the other threads */
214 while(1) yield();
215#else
216 sim_do_exit();
217#endif
218}
219
220void sim_do_exit()
221{
222 sim_kernel_shutdown();
223
200 SDL_Quit(); 224 SDL_Quit();
201 exit(EXIT_SUCCESS); 225 exit(EXIT_SUCCESS);
202} 226}