diff --git a/runloop_data.c b/runloop_data.c index 1de14df61d..5487d13000 100644 --- a/runloop_data.c +++ b/runloop_data.c @@ -24,7 +24,6 @@ #include "tasks/tasks.h" #include "input/input_overlay.h" - #ifdef HAVE_MENU #include "menu/menu.h" #include "menu/menu_entries.h" @@ -38,12 +37,27 @@ enum THREAD_CODE_ALIVE } thread_code_enum; +typedef struct data_runloop +{ + bool inited; + +#ifdef HAVE_THREADS + bool thread_inited; + unsigned thread_code; + bool alive; + + slock_t *lock; + slock_t *cond_lock; + scond_t *cond; + sthread_t *thread; +#endif +} data_runloop_t; static char data_runloop_msg[PATH_MAX_LENGTH]; static struct data_runloop *g_data_runloop; -data_runloop_t *rarch_main_data_get_ptr(void) +static data_runloop_t *rarch_main_data_get_ptr(void) { return g_data_runloop; } @@ -122,7 +136,7 @@ static void data_runloop_iterate(bool is_thread) } -bool rarch_main_data_active(data_runloop_t *runloop) +bool rarch_main_data_active(void) { bool active = false; driver_t *driver = driver_get_ptr(); @@ -174,7 +188,7 @@ static void data_thread_loop(void *data) data_runloop_iterate(true); - if (!rarch_main_data_active(runloop)) + if (!rarch_main_data_active()) rarch_sleep(10); slock_unlock(runloop->lock); diff --git a/runloop_data.h b/runloop_data.h index 0c3b4aa7be..efc3c4384c 100644 --- a/runloop_data.h +++ b/runloop_data.h @@ -17,9 +17,6 @@ #define __RETROARCH_DATA_RUNLOOP_H #include -#ifdef HAVE_THREADS -#include -#endif #ifdef __cplusplus extern "C" { @@ -37,22 +34,6 @@ enum runloop_data_type DATA_TYPE_DB }; -typedef struct data_runloop -{ - bool inited; - -#ifdef HAVE_THREADS - bool thread_inited; - unsigned thread_code; - bool alive; - - slock_t *lock; - slock_t *cond_lock; - scond_t *cond; - sthread_t *thread; -#endif -} data_runloop_t; - void rarch_main_data_msg_queue_push(unsigned type, const char *msg, const char *msg2, unsigned prio, unsigned duration, bool flush); @@ -69,9 +50,7 @@ void rarch_main_data_init_queues(void); void rarch_main_data_init(void); -bool rarch_main_data_active(data_runloop_t *runloop); - -data_runloop_t *rarch_main_data_get_ptr(void); +bool rarch_main_data_active(void); #ifdef __cplusplus } diff --git a/ui/drivers/ui_cocoatouch.m b/ui/drivers/ui_cocoatouch.m index 82c8e428b4..9d7bd48380 100644 --- a/ui/drivers/ui_cocoatouch.m +++ b/ui/drivers/ui_cocoatouch.m @@ -42,37 +42,37 @@ static CFRunLoopTimerRef iterate_timer; /* forward declaration */ void apple_rarch_exited(void); -static void rarch_draw() +static void rarch_draw(void) { - data_runloop_t *data_runloop = rarch_main_data_get_ptr(); - runloop_t *runloop = rarch_main_get_ptr(); - int ret = 0; - bool iterate = iterate_observer && !runloop->is_paused; - - if (iterate) - { + runloop_t *runloop = rarch_main_get_ptr(); + int ret = 0; + bool iterate = iterate_observer && !runloop->is_paused; + + if (iterate) + { ret = rarch_main_iterate(); - } - - rarch_main_data_iterate(); - if (iterate_timer) { - if (rarch_main_data_active(data_runloop)) { - CFRunLoopAddTimer(CFRunLoopGetMain(), iterate_timer, kCFRunLoopCommonModes); - } else { - CFRunLoopRemoveTimer(CFRunLoopGetMain(), iterate_timer, kCFRunLoopCommonModes); - } - } - - if (ret == -1) - { - main_exit_save_config(); - main_exit(NULL); - return; - } - - if (runloop->is_idle) - return; - CFRunLoopWakeUp(CFRunLoopGetMain()); + } + + rarch_main_data_iterate(); + + if (iterate_timer) + { + if (rarch_main_data_active()) + CFRunLoopAddTimer(CFRunLoopGetMain(), iterate_timer, kCFRunLoopCommonModes); + else + CFRunLoopRemoveTimer(CFRunLoopGetMain(), iterate_timer, kCFRunLoopCommonModes); + } + + if (ret == -1) + { + main_exit_save_config(); + main_exit(NULL); + return; + } + + if (runloop->is_idle) + return; + CFRunLoopWakeUp(CFRunLoopGetMain()); } static void rarch_draw_observer(CFRunLoopObserverRef observer,