(Android) Better restore state functionality

This commit is contained in:
twinaphex 2012-12-17 17:58:08 +01:00
parent 8692ef204e
commit cd1ddbb9c7
3 changed files with 13 additions and 21 deletions

View File

@ -34,7 +34,6 @@ struct droid
unsigned height;
struct saved_state state;
int32_t last_orient;
unsigned reinit_video;
unsigned activity_paused;
float disp_refresh_rate;
};

View File

@ -145,19 +145,10 @@ void engine_handle_cmd(struct android_app* android_app, int32_t cmd)
/* The window is being shown, get it ready. */
android_app->window = android_app->pendingWindow;
if (g_extern.lifecycle_state & (1ULL << RARCH_REENTRANT))
{
gfx_ctx_init();
g_extern.audio_active = true;
g_extern.video_active = true;
g_android.reinit_video = 1;
}
pthread_cond_broadcast(&android_app->cond);
pthread_mutex_unlock(&android_app->mutex);
if (android_app->window != NULL)
g_extern.lifecycle_state |= (1ULL << RARCH_WINDOW_READY);
break;
case APP_CMD_RESUME:
@ -200,8 +191,6 @@ void engine_handle_cmd(struct android_app* android_app, int32_t cmd)
/* Setting reentrancy */
RARCH_LOG("Setting up RetroArch re-entrancy...\n");
g_extern.lifecycle_state |= (1ULL << RARCH_REENTRANT);
g_extern.audio_active = false;
g_extern.video_active = false;
g_android.activity_paused = true;
}
break;
@ -232,7 +221,10 @@ void engine_handle_cmd(struct android_app* android_app, int32_t cmd)
/* The window is being hidden or closed, clean it up. */
/* terminate display/EGL context here */
if(g_extern.lifecycle_state & (1ULL << RARCH_REENTRANT))
gfx_ctx_destroy();
{
uninit_drivers();
g_extern.lifecycle_state &= ~(1ULL << RARCH_WINDOW_READY);
}
/* POSTEXEC */
android_app->window = NULL;
@ -284,6 +276,15 @@ bool android_run_events(struct android_app* android_app)
cmd = -1;
engine_handle_cmd(android_app, cmd);
if (cmd == APP_CMD_INIT_WINDOW)
{
if(g_extern.lifecycle_state & (1ULL << RARCH_REENTRANT))
init_drivers();
if (android_app->window != NULL)
g_extern.lifecycle_state |= (1ULL << RARCH_WINDOW_READY);
}
}
// Check if we are exiting.

View File

@ -239,14 +239,6 @@ static void gfx_ctx_check_window(bool *quit,
RARCH_PERFORMANCE_STOP(alooper_pollonce);
if (g_android.reinit_video)
{
uninit_drivers();
init_drivers();
g_android.reinit_video = 0;
*resize = true;
}
int32_t new_orient = AConfiguration_getOrientation(g_android.app->config);
if (new_orient != g_android.last_orient)