From 11a2357b8f62692692b51e921f242eedcbcfc0e4 Mon Sep 17 00:00:00 2001 From: bofeng Date: Thu, 12 Dec 2024 16:31:33 +0800 Subject: [PATCH] refine --- .../cocos/platform/android/AndroidPlatform.cpp | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/native/cocos/platform/android/AndroidPlatform.cpp b/native/cocos/platform/android/AndroidPlatform.cpp index 76836cf7634..7a84ace962d 100644 --- a/native/cocos/platform/android/AndroidPlatform.cpp +++ b/native/cocos/platform/android/AndroidPlatform.cpp @@ -852,22 +852,12 @@ int32_t AndroidPlatform::loop() { struct android_poll_source *source; // suspend thread while _loopTimeOut set to -1 - while (true) { - int pollResult = ALooper_pollOnce(_loopTimeOut, nullptr, nullptr, - reinterpret_cast(&source)); - - // Process events if any - if (pollResult == ALOOPER_POLL_ERROR) { - CC_LOG_ERROR("ALooper_pollOnce returned and error"); - break; - } + while (ALooper_pollOnce(_loopTimeOut, nullptr, nullptr, + reinterpret_cast(&source)) >= 0) { + // Process events if (source != nullptr) { source->process(_app, source); } - if (pollResult == ALOOPER_POLL_TIMEOUT) { - break; - } - // Exit the game loop when the Activity is destroyed if (_app->destroyRequested) {