Delay reinit, gets rid of the remaining concurrency errors
This commit is contained in:
parent
94e1148d51
commit
23c13c0043
|
@ -529,7 +529,7 @@ char ext_dir[PATH_MAX_LENGTH];
|
|||
/* forward declaration */
|
||||
bool android_run_events(void *data);
|
||||
|
||||
static INLINE void android_app_write_cmd(struct android_app *android_app, int8_t cmd)
|
||||
void android_app_write_cmd(struct android_app *android_app, int8_t cmd)
|
||||
{
|
||||
if (!android_app)
|
||||
return;
|
||||
|
|
|
@ -143,6 +143,8 @@ struct android_app
|
|||
* APP_CMD_RESUME, APP_CMD_PAUSE, or APP_CMD_STOP; see below. */
|
||||
int activityState;
|
||||
|
||||
int reinitRequested;
|
||||
|
||||
/* This is non-zero when the application's NativeActivity is being
|
||||
* destroyed and waiting for the app thread to complete. */
|
||||
int destroyRequested;
|
||||
|
@ -290,7 +292,9 @@ enum
|
|||
* Command from main thread: the app's activity is being destroyed,
|
||||
* and waiting for the app thread to clean up and exit before proceeding.
|
||||
*/
|
||||
APP_CMD_DESTROY
|
||||
APP_CMD_DESTROY,
|
||||
|
||||
APP_CMD_REINIT_DONE
|
||||
};
|
||||
|
||||
#define JNI_EXCEPTION(env) \
|
||||
|
@ -358,6 +362,8 @@ enum
|
|||
|
||||
extern JNIEnv *jni_thread_getenv(void);
|
||||
|
||||
void android_app_write_cmd(struct android_app *android_app, int8_t cmd);
|
||||
|
||||
extern struct android_app *g_android;
|
||||
#else
|
||||
#endif
|
||||
|
|
|
@ -254,6 +254,15 @@ static void android_input_poll_main_cmd(void)
|
|||
|
||||
switch (cmd)
|
||||
{
|
||||
case APP_CMD_REINIT_DONE:
|
||||
slock_lock(android_app->mutex);
|
||||
|
||||
android_app->reinitRequested = 0;
|
||||
|
||||
scond_broadcast(android_app->cond);
|
||||
slock_unlock(android_app->mutex);
|
||||
break;
|
||||
|
||||
case APP_CMD_INPUT_CHANGED:
|
||||
slock_lock(android_app->mutex);
|
||||
|
||||
|
@ -278,11 +287,10 @@ static void android_input_poll_main_cmd(void)
|
|||
case APP_CMD_INIT_WINDOW:
|
||||
slock_lock(android_app->mutex);
|
||||
android_app->window = android_app->pendingWindow;
|
||||
android_app->reinitRequested = 1;
|
||||
scond_broadcast(android_app->cond);
|
||||
slock_unlock(android_app->mutex);
|
||||
|
||||
if (runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL))
|
||||
event_command(EVENT_CMD_REINIT);
|
||||
break;
|
||||
|
||||
case APP_CMD_SAVE_STATE:
|
||||
|
@ -923,12 +931,20 @@ static void android_input_poll(void *data)
|
|||
android_input_poll_main_cmd();
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (android_app->destroyRequested != 0)
|
||||
{
|
||||
runloop_ctl(RUNLOOP_CTL_SET_SHUTDOWN, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
if (android_app->reinitRequested != 0)
|
||||
{
|
||||
if (runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL))
|
||||
event_command(EVENT_CMD_REINIT);
|
||||
android_app_write_cmd(android_app, APP_CMD_REINIT_DONE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (android_app->input_alive)
|
||||
|
@ -949,6 +965,13 @@ bool android_run_events(void *data)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (android_app->reinitRequested != 0)
|
||||
{
|
||||
if (runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL))
|
||||
event_command(EVENT_CMD_REINIT);
|
||||
android_app_write_cmd(android_app, APP_CMD_REINIT_DONE);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue