(Android) Fix - restore state functionality broke again due to

'refactor' in driver.c - this does not work for re-entrancy - please
consult with me
This commit is contained in:
twinaphex 2012-12-24 18:06:51 +01:00
parent 70b5007a1e
commit e8a57f21cd
2 changed files with 26 additions and 34 deletions

View File

@ -139,7 +139,6 @@ void engine_handle_cmd(struct android_app* android_app, int32_t cmd)
/* POSTEXEC */ /* POSTEXEC */
free_saved_state(android_app); free_saved_state(android_app);
g_extern.lifecycle_state &= ~(1ULL << RARCH_PAUSE_TOGGLE);
break; break;
case APP_CMD_START: case APP_CMD_START:
RARCH_LOG("engine_handle_cmd: APP_CMD_START.\n"); RARCH_LOG("engine_handle_cmd: APP_CMD_START.\n");
@ -209,6 +208,7 @@ void engine_handle_cmd(struct android_app* android_app, int32_t cmd)
case APP_CMD_GAINED_FOCUS: case APP_CMD_GAINED_FOCUS:
RARCH_LOG("engine_handle_cmd: APP_CMD_GAINED_FOCUS.\n"); RARCH_LOG("engine_handle_cmd: APP_CMD_GAINED_FOCUS.\n");
g_extern.lifecycle_state &= ~(1ULL << RARCH_PAUSE_TOGGLE);
/* EXEC */ /* EXEC */
break; break;
case APP_CMD_LOST_FOCUS: case APP_CMD_LOST_FOCUS:
@ -229,46 +229,36 @@ void engine_handle_cmd(struct android_app* android_app, int32_t cmd)
bool android_run_events(struct android_app* android_app) bool android_run_events(struct android_app* android_app)
{ {
// Read all pending events. int id = ALooper_pollOnce(0, NULL, 0, NULL);
int id;
RARCH_LOG("RetroArch Android paused.\n"); if (id == LOOPER_ID_MAIN)
// Block forever waiting for events.
while ((id = ALooper_pollOnce(input_key_pressed_func(RARCH_PAUSE_TOGGLE) ? -1 : 100, NULL, 0, NULL)) >= 0)
{ {
// Process this event. int8_t cmd;
if (id)
if (read(android_app->msgread, &cmd, sizeof(cmd)) == sizeof(cmd))
{ {
int8_t cmd; if(cmd == APP_CMD_SAVE_STATE)
free_saved_state(android_app);
if (read(android_app->msgread, &cmd, sizeof(cmd)) == sizeof(cmd))
{
if(cmd == APP_CMD_SAVE_STATE)
free_saved_state(android_app);
}
else
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_android.window_ready = true;
}
} }
else
cmd = -1;
// Check if we are exiting. engine_handle_cmd(android_app, cmd);
if (g_extern.lifecycle_state & (1ULL << RARCH_QUIT_KEY))
return false; if (cmd == APP_CMD_INIT_WINDOW)
{
if(g_extern.lifecycle_state & (1ULL << RARCH_REENTRANT))
init_drivers();
if (android_app->window != NULL)
g_android.window_ready = true;
}
} }
RARCH_LOG("RetroArch Android unpaused.\n"); // Check if we are exiting.
if (g_extern.lifecycle_state & (1ULL << RARCH_QUIT_KEY))
return false;
return true; return true;
} }

View File

@ -238,8 +238,10 @@ static void adjust_system_rates(void)
RARCH_LOG("Set audio input rate to: %.2f Hz.\n", g_settings.audio.in_rate); RARCH_LOG("Set audio input rate to: %.2f Hz.\n", g_settings.audio.in_rate);
#ifndef ANDROID
if (driver.video_data) if (driver.video_data)
video_set_nonblock_state_func(!g_settings.video.vsync || g_extern.system.force_nonblock); video_set_nonblock_state_func(!g_settings.video.vsync || g_extern.system.force_nonblock);
#endif
} }
void driver_set_monitor_refresh_rate(float hz) void driver_set_monitor_refresh_rate(float hz)