mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 18:17:39 -04:00
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
This commit is contained in:
parent
c9133db4b1
commit
28a7c5d369
1 changed files with 11 additions and 26 deletions
|
@ -75,17 +75,6 @@ void sys_poweroff(void)
|
||||||
* Button read loop */
|
* Button read loop */
|
||||||
void gui_message_loop(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
|
* This thread will read the buttons in an interrupt like fashion, and
|
||||||
* also initializes SDL_INIT_VIDEO and the surfaces
|
* also initializes SDL_INIT_VIDEO and the surfaces
|
||||||
|
@ -143,9 +132,9 @@ static int sdl_event_thread(void * param)
|
||||||
if (background && picture_surface != NULL)
|
if (background && picture_surface != NULL)
|
||||||
SDL_BlitSurface(picture_surface, NULL, gui_surface, NULL);
|
SDL_BlitSurface(picture_surface, NULL, gui_surface, NULL);
|
||||||
|
|
||||||
/* calling SDL_CondSignal() right away here doesn't work reliably so
|
/* let system_init proceed */
|
||||||
* post-pone it a bit */
|
SDL_SemPost((SDL_sem *)param);
|
||||||
SDL_AddTimer(100, cond_signal, param);
|
|
||||||
/*
|
/*
|
||||||
* finally enter the button loop */
|
* finally enter the button loop */
|
||||||
while(1)
|
while(1)
|
||||||
|
@ -157,26 +146,22 @@ static int sdl_event_thread(void * param)
|
||||||
|
|
||||||
void system_init(void)
|
void system_init(void)
|
||||||
{
|
{
|
||||||
SDL_cond *c;
|
SDL_sem *s;
|
||||||
SDL_mutex *m;
|
|
||||||
if (SDL_Init(SDL_INIT_TIMER))
|
if (SDL_Init(SDL_INIT_TIMER))
|
||||||
panicf("%s", SDL_GetError());
|
panicf("%s", SDL_GetError());
|
||||||
atexit(sys_poweroff);
|
atexit(sys_poweroff);
|
||||||
|
|
||||||
c = SDL_CreateCond();
|
s = SDL_CreateSemaphore(0); /* 0-count so it blocks */
|
||||||
m = SDL_CreateMutex();
|
|
||||||
|
|
||||||
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
|
/* wait for sdl_event_thread to run so that it can initialize the surfaces
|
||||||
* initialize the surfaces and video subsystem needed for SDL events */
|
* and video subsystem needed for SDL events */
|
||||||
SDL_LockMutex(m);
|
SDL_SemWait(s);
|
||||||
SDL_CondWait(c, m);
|
|
||||||
SDL_UnlockMutex(m);
|
|
||||||
|
|
||||||
/* cleanup */
|
/* cleanup */
|
||||||
SDL_DestroyCond(c);
|
SDL_DestroySemaphore(s);
|
||||||
SDL_DestroyMutex(m);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void system_exception_wait(void)
|
void system_exception_wait(void)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue