From 6fa7c9a97a70ffe327779729ef18f00bc33352ba Mon Sep 17 00:00:00 2001 From: "bofeng.song" Date: Tue, 14 Jun 2022 11:21:29 +0800 Subject: [PATCH] refine --- .../native_app_glue/android_native_app_glue.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/sources/android-gamesdk/GameActivity/game-activity/include/game-activity/native_app_glue/android_native_app_glue.c b/sources/android-gamesdk/GameActivity/game-activity/include/game-activity/native_app_glue/android_native_app_glue.c index 54b7cc1d..86288d2e 100644 --- a/sources/android-gamesdk/GameActivity/game-activity/include/game-activity/native_app_glue/android_native_app_glue.c +++ b/sources/android-gamesdk/GameActivity/game-activity/include/game-activity/native_app_glue/android_native_app_glue.c @@ -105,11 +105,7 @@ void android_app_pre_exec_cmd(struct android_app* android_app, int8_t cmd) { case APP_CMD_TERM_WINDOW: LOGV("APP_CMD_TERM_WINDOW"); -/** pthread_cond_broadcast called here maybe increase the occurrence probability of anr. - * It may cause the APP_CMD_TERM_WINDOW processing in android_app_post_exec_cmd to complete - * before __futex_wait_ex(called from pthread_cond_wait) - */ -// pthread_cond_broadcast(&android_app->cond); + pthread_cond_broadcast(&android_app->cond); break; case APP_CMD_RESUME: @@ -302,11 +298,12 @@ static void android_app_write_cmd(struct android_app* android_app, int8_t cmd) { } static void android_app_timed_wait(struct android_app* android_app) { - struct timeval now; + struct timespec now; struct timespec destTime; - gettimeofday(&now, NULL); - destTime.tv_sec = now.tv_sec; - destTime.tv_nsec = now.tv_usec * 1000 + HANDLE_APP_CMD_WAIT_TIMEOUT_IN_NANOSECOND; + clock_gettime(CLOCK_REALTIME, &now); + long tmpVal = now.tv_nsec + HANDLE_APP_CMD_WAIT_TIMEOUT_IN_NANOSECOND; + destTime.tv_sec = now.tv_sec + tmpVal / 1000000000; + destTime.tv_nsec = tmpVal % 1000000000; pthread_cond_timedwait(&android_app->cond, &android_app->mutex, &destTime); }