diff --git a/apple/common/main.m b/apple/common/main.m index 49dacbe5e9..9acdb2fe45 100644 --- a/apple/common/main.m +++ b/apple/common/main.m @@ -31,8 +31,6 @@ bool apple_is_running; bool apple_use_tv_mode; NSString* apple_core; -static CFRunLoopObserverRef iterate_observer; - static void apple_rarch_exited(void) { NSString* used_core = (NSString*)apple_core; @@ -52,41 +50,6 @@ static void apple_rarch_exited(void) apple_run_core(nil, 0); } -static void do_iteration(void) -{ - bool iterate = iterate_observer && apple_is_running && !g_extern.is_paused; - - if (!iterate) - return; - - if (main_entry_iterate(0, NULL, NULL)) - { - main_exit(NULL); - apple_rarch_exited(); - } - else - CFRunLoopWakeUp(CFRunLoopGetMain()); -} - -void apple_start_iteration(void) -{ - if (iterate_observer) - return; - - iterate_observer = CFRunLoopObserverCreate(0, kCFRunLoopBeforeWaiting, true, 0, (CFRunLoopObserverCallBack)do_iteration, 0); - CFRunLoopAddObserver(CFRunLoopGetMain(), iterate_observer, kCFRunLoopCommonModes); -} - -void apple_stop_iteration(void) -{ - if (!iterate_observer) - return; - - CFRunLoopObserverInvalidate(iterate_observer); - CFRelease(iterate_observer); - iterate_observer = 0; -} - void apple_run_core(NSString* core, const char* file) { if (apple_is_running) diff --git a/frontend/platform/platform_apple.c b/frontend/platform/platform_apple.c index 8bc7e115e2..b5e4320fc8 100644 --- a/frontend/platform/platform_apple.c +++ b/frontend/platform/platform_apple.c @@ -26,8 +26,45 @@ #include #include +static CFRunLoopObserverRef iterate_observer; + extern bool apple_is_running; +static void do_iteration(void) +{ + bool iterate = iterate_observer && apple_is_running && !g_extern.is_paused; + + if (!iterate) + return; + + if (main_entry_iterate(0, NULL, NULL)) + { + main_exit(NULL); + apple_rarch_exited(); + } + else + CFRunLoopWakeUp(CFRunLoopGetMain()); +} + +void apple_start_iteration(void) +{ + if (iterate_observer) + return; + + iterate_observer = CFRunLoopObserverCreate(0, kCFRunLoopBeforeWaiting, true, 0, (CFRunLoopObserverCallBack)do_iteration, 0); + CFRunLoopAddObserver(CFRunLoopGetMain(), iterate_observer, kCFRunLoopCommonModes); +} + +void apple_stop_iteration(void) +{ + if (!iterate_observer) + return; + + CFRunLoopObserverInvalidate(iterate_observer); + CFRelease(iterate_observer); + iterate_observer = 0; +} + void apple_event_basic_command(enum basic_event_t action) { switch (action)