(Android) Better deinit - will now deinit RetroArch and save game

RAM if you forcibly stop RetroArch
This commit is contained in:
twinaphex 2012-12-17 18:45:26 +01:00
parent cd1ddbb9c7
commit 74ae6ecf57
5 changed files with 6 additions and 15 deletions

View File

@ -49,7 +49,6 @@ struct android_app
ANativeWindow* window;
ARect contentRect;
int activityState;
int destroyRequested;
pthread_mutex_t mutex;
pthread_cond_t cond;

View File

@ -371,9 +371,7 @@ static bool android_input_key_pressed(void *data, int key)
{
(void)data;
if(key == RARCH_QUIT_KEY && (g_extern.lifecycle_state & (1ULL << RARCH_KILL)))
return true;
else if(g_extern.lifecycle_state & (1ULL << key))
if(g_extern.lifecycle_state & (1ULL << key))
return true;
return false;

View File

@ -245,7 +245,7 @@ void engine_handle_cmd(struct android_app* android_app, int32_t cmd)
RARCH_LOG("engine_handle_cmd: APP_CMD_DESTROY\n");
/* PREEXEC */
android_app->destroyRequested = 1;
g_extern.lifecycle_state |= (1ULL << RARCH_QUIT_KEY);
break;
}
}
@ -288,7 +288,7 @@ bool android_run_events(struct android_app* android_app)
}
// Check if we are exiting.
if (android_app->destroyRequested != 0)
if (g_extern.lifecycle_state & (1ULL << RARCH_QUIT_KEY))
return false;
}
@ -435,7 +435,6 @@ static void* android_app_entry(void* param)
{
RARCH_LOG("Initialization failed.\n");
g_extern.lifecycle_state |= (1ULL << RARCH_QUIT_KEY);
g_extern.lifecycle_state |= (1ULL << RARCH_KILL);
}
else
RARCH_LOG("Initializing succeeded.\n");
@ -460,12 +459,7 @@ exit:
#endif
rarch_main_clear_state();
/* Make sure to quit RetroArch later on too */
g_extern.lifecycle_state |= (1ULL << RARCH_KILL);
}
if(g_extern.lifecycle_state & (1ULL << RARCH_KILL))
{
/* Quit RetroArch */
RARCH_LOG("android_app_destroy!");
free_saved_state(android_app);
pthread_mutex_lock(&android_app->mutex);
@ -480,6 +474,7 @@ exit:
// Can't touch android_app object after this.
exit(0);
}
return NULL;
}

View File

@ -104,7 +104,6 @@ enum // RetroArch specific bind IDs.
RARCH_SRAM_WRITE_PROTECT,
#endif
#ifdef ANDROID
RARCH_KILL,
RARCH_WINDOW_READY,
#endif
#ifdef HAVE_RMENU

View File

@ -251,7 +251,7 @@ static void gfx_ctx_check_window(bool *quit,
}
// Check if we are exiting.
if (g_android.app->destroyRequested != 0 || (g_extern.lifecycle_state & (1ULL << RARCH_KILL)))
if (g_extern.lifecycle_state & (1ULL << RARCH_QUIT_KEY))
*quit = true;
}