mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-23 19:24:46 +00:00
(iOS) Use the nuclear option for life-cycle management.
This should fix hangs caused by incoming calls or launching siri, but will cause more driver reinits than before
This commit is contained in:
parent
8656b04492
commit
fe08806aa5
@ -189,17 +189,6 @@ static float g_screen_scale = 1.0f;
|
||||
];
|
||||
}
|
||||
|
||||
- (void)suspend
|
||||
{
|
||||
g_view.context = nil;
|
||||
[EAGLContext setCurrentContext:nil];
|
||||
}
|
||||
|
||||
- (void)resume
|
||||
{
|
||||
g_view.context = g_context;
|
||||
[EAGLContext setCurrentContext:g_context];
|
||||
}
|
||||
#endif
|
||||
|
||||
@end
|
||||
@ -215,7 +204,7 @@ bool apple_init_game_view()
|
||||
g_context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
|
||||
[EAGLContext setCurrentContext:g_context];
|
||||
g_view.context = g_context;
|
||||
|
||||
|
||||
// Show pause button for a few seconds, so people know it's there
|
||||
g_pause_indicator_view.alpha = 1.0f;
|
||||
[NSObject cancelPreviousPerformRequestsWithTarget:g_instance];
|
||||
@ -232,13 +221,6 @@ bool apple_init_game_view()
|
||||
void apple_destroy_game_view()
|
||||
{
|
||||
dispatch_sync(dispatch_get_main_queue(), ^{
|
||||
// Clear the view, otherwise the last frame from this game will be displayed
|
||||
// briefly on the next game.
|
||||
[g_view bindDrawable];
|
||||
glClearColor(0, 0, 0, 1);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
[g_view display];
|
||||
|
||||
glFinish();
|
||||
|
||||
#ifdef IOS
|
||||
|
@ -39,9 +39,6 @@ extern id<RetroArch_Platform> apple_platform;
|
||||
+ (RAGameView*)get;
|
||||
- (void)openPauseMenu;
|
||||
- (void)closePauseMenu;
|
||||
|
||||
- (void)suspend;
|
||||
- (void)resume;
|
||||
@end
|
||||
|
||||
@interface RetroArch_iOS : UINavigationController<UIApplicationDelegate, UINavigationControllerDelegate, RetroArch_Platform>
|
||||
|
@ -83,6 +83,18 @@ static void event_reload_config(void* userdata)
|
||||
init_drivers();
|
||||
}
|
||||
|
||||
static pthread_mutex_t stasis_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
static void event_stasis(void* userdata)
|
||||
{
|
||||
// HACK: uninit_drivers is the nuclear option; uninit_audio would be better but will
|
||||
// crash when resuming.
|
||||
uninit_drivers();
|
||||
pthread_mutex_lock(&stasis_mutex);
|
||||
pthread_mutex_unlock(&stasis_mutex);
|
||||
init_drivers();
|
||||
}
|
||||
|
||||
#pragma mark EMULATION
|
||||
static pthread_t apple_retro_thread;
|
||||
static bool apple_is_paused;
|
||||
@ -258,14 +270,19 @@ int main(int argc, char *argv[])
|
||||
apple_display_alert(@"No libretro cores were found. You will not be able to play any games.", 0);
|
||||
}
|
||||
|
||||
- (void)applicationWillEnterForeground:(UIApplication *)application
|
||||
- (void)applicationDidBecomeActive:(UIApplication *)application
|
||||
{
|
||||
[RAGameView.get resume];
|
||||
if (apple_is_running)
|
||||
pthread_mutex_unlock(&stasis_mutex);
|
||||
}
|
||||
|
||||
- (void)applicationDidEnterBackground:(UIApplication *)application
|
||||
- (void)applicationWillResignActive:(UIApplication *)application
|
||||
{
|
||||
[RAGameView.get suspend];
|
||||
if (apple_is_running)
|
||||
{
|
||||
pthread_mutex_lock(&stasis_mutex);
|
||||
apple_frontend_post_event(event_stasis, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// UINavigationControllerDelegate
|
||||
|
Loading…
Reference in New Issue
Block a user