(Android) Use DetachCurrentThread - first stab at setting up clean

deiniting
This commit is contained in:
twinaphex 2012-10-21 17:30:02 +02:00
parent 6d44198f8a
commit 9b6425c1da
4 changed files with 18 additions and 5 deletions

View File

@ -20,6 +20,7 @@ struct droid
const ASensor* accelerometerSensor;
ASensorEventQueue* sensorEventQueue;
bool init_quit;
bool window_inited;
unsigned animating;
unsigned width;

View File

@ -52,6 +52,7 @@ static int16_t android_input_state(void *data, const struct retro_keybind **retr
(void)index;
(void)id;
return 0;
}
@ -60,6 +61,18 @@ static bool android_input_key_pressed(void *data, int key)
(void)data;
(void)key;
switch (key)
{
case RARCH_QUIT_KEY:
if(g_android.init_quit)
return true;
else
return false;
break;
default:
(void)0;
}
return false;
}

View File

@ -48,9 +48,7 @@ static void engine_handle_cmd(struct android_app* app, int32_t cmd)
break;
case APP_CMD_TERM_WINDOW:
// The window is being hidden or closed, clean it up.
rarch_main_deinit();
rarch_deinit_msg_queue();
rarch_main_clear_state();
g_android.init_quit = true;
break;
case APP_CMD_GAINED_FOCUS:
// When our app gains focus, we start monitoring the accelerometer.
@ -106,6 +104,8 @@ static void android_get_char_argv(char *argv, size_t sizeof_argv, const char *ar
strncpy(argv, test_argv, sizeof_argv);
(*env)->ReleaseStringUTFChars(env, jsParam1, test_argv);
(*rarch_vm)->DetachCurrentThread(rarch_vm);
}
#define MAX_ARGS 32

View File

@ -192,11 +192,10 @@ static void gfx_ctx_check_window(bool *quit,
*/
// Check if we are exiting.
if (state->destroyRequested != 0)
if (state->destroyRequested != 0 || g_android.init_quit)
{
gl->quitting = true;
*quit = true;
gfx_ctx_destroy();
return;
}