mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 18:17:39 -04:00
Fix simulator crashing on MacOS
Event handling must happen on the main thread for MacOS. Not sure if button_queue_wait is the best place for doing the SDL event polling, but seems to work ok. Change-Id: If928282df84bdd74e24a48afd7dbc4c4bfcc49e2
This commit is contained in:
parent
1745b74576
commit
f1010005b0
5 changed files with 44 additions and 0 deletions
|
@ -22,6 +22,9 @@
|
|||
#include "system.h"
|
||||
#include "kernel.h"
|
||||
#include "button.h"
|
||||
#ifdef HAVE_SDL
|
||||
#include "button-sdl.h"
|
||||
#endif
|
||||
|
||||
static struct event_queue button_queue SHAREDBSS_ATTR;
|
||||
static intptr_t button_data; /* data value from last message dequeued */
|
||||
|
@ -92,7 +95,29 @@ static void button_queue_wait(struct queue_event *evp, int timeout)
|
|||
#else /* ndef HAVE_ADJUSTABLE_CPU_FREQ */
|
||||
static inline void button_queue_wait(struct queue_event *evp, int timeout)
|
||||
{
|
||||
#if defined(__APPLE__) && (CONFIG_PLATFORM & PLATFORM_SDL)
|
||||
unsigned long initial_tick = current_tick;
|
||||
unsigned long curr_tick, remaining;
|
||||
while(true)
|
||||
{
|
||||
handle_sdl_events();
|
||||
queue_wait_w_tmo(&button_queue, evp, TIMEOUT_NOBLOCK);
|
||||
if (evp->id != SYS_TIMEOUT || timeout == TIMEOUT_NOBLOCK)
|
||||
return;
|
||||
else if (timeout == TIMEOUT_BLOCK)
|
||||
sleep(HZ/60);
|
||||
else
|
||||
{
|
||||
curr_tick = current_tick;
|
||||
if (!TIME_AFTER(initial_tick + timeout, curr_tick))
|
||||
return;
|
||||
remaining = ((initial_tick + timeout) - curr_tick);
|
||||
sleep(remaining < HZ/60 ? remaining : HZ/60);
|
||||
}
|
||||
}
|
||||
#else
|
||||
queue_wait_w_tmo(&button_queue, evp, timeout);
|
||||
#endif
|
||||
}
|
||||
#endif /* HAVE_ADJUSTABLE_CPU_FREQ */
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue