From 35e17e5017ec6fce9a7e195e014fd4c56d34db2a Mon Sep 17 00:00:00 2001 From: Themaister Date: Sun, 30 Dec 2012 16:53:29 +0100 Subject: [PATCH] Fix CPU hogging issue on Android when paused. --- android/native/jni/android_general.h | 2 -- android/native/jni/main.c | 6 +++--- gfx/context/androidegl_ctx.c | 5 +---- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/android/native/jni/android_general.h b/android/native/jni/android_general.h index 7a771a2502..e11b727cd9 100644 --- a/android/native/jni/android_general.h +++ b/android/native/jni/android_general.h @@ -41,6 +41,4 @@ struct droid extern struct droid g_android; -bool android_run_events(struct android_app* android_app); - #endif diff --git a/android/native/jni/main.c b/android/native/jni/main.c index 2363b4d3a0..3b3a9998c8 100644 --- a/android/native/jni/main.c +++ b/android/native/jni/main.c @@ -222,9 +222,9 @@ void engine_handle_cmd(struct android_app* android_app, int32_t cmd) #define MAX_ARGS 32 -bool android_run_events(struct android_app* android_app) +static bool android_run_events(struct android_app* android_app) { - int id = ALooper_pollOnce(0, NULL, 0, NULL); + int id = ALooper_pollOnce(-1, NULL, NULL, NULL); if (id == LOOPER_ID_MAIN) { @@ -242,7 +242,7 @@ bool android_run_events(struct android_app* android_app) if (cmd == APP_CMD_INIT_WINDOW) { - if(g_extern.lifecycle_state & (1ULL << RARCH_REENTRANT)) + if (g_extern.lifecycle_state & (1ULL << RARCH_REENTRANT)) init_drivers(); if (android_app->window != NULL) diff --git a/gfx/context/androidegl_ctx.c b/gfx/context/androidegl_ctx.c index 7ea8c293c2..baaf82cb80 100644 --- a/gfx/context/androidegl_ctx.c +++ b/gfx/context/androidegl_ctx.c @@ -166,7 +166,6 @@ static void gfx_ctx_check_window(bool *quit, { (void)frame_count; - int id; struct android_app* android_app = g_android.app; *quit = false; @@ -183,9 +182,7 @@ static void gfx_ctx_check_window(bool *quit, RARCH_PERFORMANCE_INIT(alooper_pollonce); RARCH_PERFORMANCE_START(alooper_pollonce); - id = ALooper_pollOnce(0, NULL, 0, NULL); - - if(id == LOOPER_ID_MAIN) + while (ALooper_pollOnce(0, NULL, NULL, NULL) == LOOPER_ID_MAIN) { int8_t cmd;