mirror of
https://github.com/libretro/RetroArch
synced 2025-03-28 19:20:35 +00:00
(Apple - No Thread) Fix performance regression.
This commit is contained in:
parent
f069c82417
commit
f3d5a44e76
@ -247,10 +247,14 @@ static void* const associated_core_key = (void*)&associated_core_key;
|
||||
{
|
||||
if (file)
|
||||
[[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL:[NSURL fileURLWithPath:BOXSTRING(file)]];
|
||||
|
||||
apple_start_iteration();
|
||||
}
|
||||
|
||||
- (void)unloadingCore:(const NSString*)core
|
||||
{
|
||||
apple_stop_iteration();
|
||||
|
||||
if (_isTerminating)
|
||||
[[NSApplication sharedApplication] terminate:nil];
|
||||
|
||||
|
@ -186,12 +186,15 @@ static void* const associated_name_tag = (void*)&associated_name_tag;
|
||||
}
|
||||
|
||||
setting_data_load_config_path(setting_data_get_list(), [apple_platform.globalConfigFile UTF8String]);
|
||||
apple_stop_iteration();
|
||||
}
|
||||
|
||||
- (void)windowWillClose:(NSNotification *)notification
|
||||
{
|
||||
setting_data_save_config_path(setting_data_get_list(), [apple_platform.globalConfigFile UTF8String]);
|
||||
[NSApp stopModal];
|
||||
|
||||
apple_start_iteration();
|
||||
}
|
||||
|
||||
#pragma mark Section Table
|
||||
|
@ -54,6 +54,8 @@ extern id<RetroArch_Platform> apple_platform;
|
||||
|
||||
// main.m
|
||||
extern void apple_run_core(NSString* core, const char* file);
|
||||
extern void apple_start_iteration();
|
||||
extern void apple_stop_iteration();
|
||||
|
||||
// utility.m
|
||||
extern void apple_display_alert(NSString* message, NSString* title);
|
||||
|
@ -30,6 +30,44 @@ bool apple_is_running;
|
||||
bool apple_use_tv_mode;
|
||||
NSString* apple_core;
|
||||
|
||||
static CFRunLoopObserverRef iterate_observer;
|
||||
|
||||
static void do_iteration()
|
||||
{
|
||||
if (iterate_observer)
|
||||
{
|
||||
if (apple_rarch_iterate_once())
|
||||
{
|
||||
CFRunLoopObserverInvalidate(iterate_observer);
|
||||
CFRelease(iterate_observer);
|
||||
iterate_observer = 0;
|
||||
|
||||
apple_rarch_exited(false);
|
||||
}
|
||||
else
|
||||
CFRunLoopWakeUp(CFRunLoopGetMain());
|
||||
}
|
||||
}
|
||||
|
||||
void apple_start_iteration()
|
||||
{
|
||||
if (!iterate_observer)
|
||||
{
|
||||
iterate_observer = CFRunLoopObserverCreate(0, kCFRunLoopBeforeWaiting, true, 0, do_iteration, 0);
|
||||
CFRunLoopAddObserver(CFRunLoopGetMain(), iterate_observer, kCFRunLoopCommonModes);
|
||||
}
|
||||
}
|
||||
|
||||
void apple_stop_iteration()
|
||||
{
|
||||
if (iterate_observer)
|
||||
{
|
||||
CFRunLoopObserverInvalidate(iterate_observer);
|
||||
CFRelease(iterate_observer);
|
||||
iterate_observer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void apple_run_core(NSString* core, const char* file)
|
||||
{
|
||||
if (!apple_is_running)
|
||||
|
@ -268,10 +268,12 @@ static void handle_touch_event(NSArray* touches)
|
||||
[[UIApplication sharedApplication] setIdleTimerDisabled:true];
|
||||
[_window setRootViewController:[RAGameView get]];
|
||||
g_extern.is_paused = false;
|
||||
apple_start_iteration();
|
||||
}
|
||||
|
||||
- (IBAction)showPauseMenu:(id)sender
|
||||
{
|
||||
apple_stop_iteration();
|
||||
g_extern.is_paused = true;
|
||||
[[UIApplication sharedApplication] setStatusBarHidden:false withAnimation:UIStatusBarAnimationNone];
|
||||
[[UIApplication sharedApplication] setIdleTimerDisabled:false];
|
||||
|
@ -14,8 +14,6 @@
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
|
||||
#include "../menu/menu_common.h"
|
||||
#include "../../apple/common/rarch_wrapper.h"
|
||||
#include "../../apple/common/apple_export.h"
|
||||
@ -28,7 +26,7 @@
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
static CFRunLoopObserverRef iterate_observer;
|
||||
extern bool apple_is_running;
|
||||
|
||||
void apple_event_basic_command(enum basic_event_t action)
|
||||
{
|
||||
@ -56,7 +54,7 @@ void apple_refresh_config()
|
||||
memset(g_settings.input.overlay, 0, sizeof(g_settings.input.overlay));
|
||||
memset(g_settings.video.shader_path, 0, sizeof(g_settings.video.shader_path));
|
||||
|
||||
if (iterate_observer)
|
||||
if (apple_is_running)
|
||||
{
|
||||
uninit_drivers();
|
||||
config_load();
|
||||
@ -64,31 +62,8 @@ void apple_refresh_config()
|
||||
}
|
||||
}
|
||||
|
||||
static void do_iteration()
|
||||
{
|
||||
if (iterate_observer)
|
||||
{
|
||||
if (apple_rarch_iterate_once())
|
||||
{
|
||||
CFRunLoopObserverInvalidate(iterate_observer);
|
||||
CFRelease(iterate_observer);
|
||||
iterate_observer = 0;
|
||||
|
||||
apple_rarch_exited(false);
|
||||
}
|
||||
else
|
||||
CFRunLoopWakeUp(CFRunLoopGetMain());
|
||||
}
|
||||
}
|
||||
|
||||
int apple_rarch_load_content(int argc, char* argv[])
|
||||
{
|
||||
if (iterate_observer)
|
||||
{
|
||||
RARCH_ERR("apple_rarch_load_content called while content is still running.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
rarch_main_clear_state();
|
||||
rarch_init_msg_queue();
|
||||
|
||||
@ -98,9 +73,6 @@ int apple_rarch_load_content(int argc, char* argv[])
|
||||
menu_init();
|
||||
g_extern.lifecycle_state |= 1ULL << MODE_GAME;
|
||||
g_extern.lifecycle_state |= 1ULL << MODE_GAME_ONESHOT;
|
||||
|
||||
iterate_observer = CFRunLoopObserverCreate(0, kCFRunLoopBeforeWaiting, true, 0, do_iteration, 0);
|
||||
CFRunLoopAddObserver(CFRunLoopGetMain(), iterate_observer, kCFRunLoopCommonModes);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user