(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; ANativeWindow* window;
ARect contentRect; ARect contentRect;
int activityState; int activityState;
int destroyRequested;
pthread_mutex_t mutex; pthread_mutex_t mutex;
pthread_cond_t cond; pthread_cond_t cond;

View File

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

View File

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

View File

@ -251,7 +251,7 @@ static void gfx_ctx_check_window(bool *quit,
} }
// Check if we are exiting. // 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; *quit = true;
} }