From a5e486efe2ad4d541bc82453ffd3448226e61002 Mon Sep 17 00:00:00 2001 From: Jose Luis Marti Date: Tue, 9 Jul 2024 17:35:20 +0200 Subject: [Android] Replace ALooper_pollAll with ALooper_pollOnce --- xbmc/platform/android/activity/EventLoop.cpp | 33 +++++++++++++--------------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/xbmc/platform/android/activity/EventLoop.cpp b/xbmc/platform/android/activity/EventLoop.cpp index ac5fc61565..c8d9989ccc 100644 --- a/xbmc/platform/android/activity/EventLoop.cpp +++ b/xbmc/platform/android/activity/EventLoop.cpp @@ -23,33 +23,30 @@ CEventLoop::CEventLoop(android_app* application) m_application->onInputEvent = inputCallback; } -void CEventLoop::run(IActivityHandler &activityHandler, IInputHandler &inputHandler) +void CEventLoop::run(IActivityHandler& activityHandler, IInputHandler& inputHandler) { - int ident; - int events; - struct android_poll_source* source; - m_activityHandler = &activityHandler; m_inputHandler = &inputHandler; CXBMCApp::android_printf("CEventLoop: starting event loop"); - while (true) + + while (!m_application->destroyRequested) { - // We will block forever waiting for events. - while ((ident = ALooper_pollAll(-1, NULL, &events, (void**)&source)) >= 0) + android_poll_source* source = nullptr; + int result = ALooper_pollOnce(-1, nullptr, nullptr, reinterpret_cast(&source)); + + if (result == ALOOPER_POLL_ERROR) { - // Process this event. - if (source != NULL) - source->process(m_application, source); - - // Check if we are exiting. - if (m_application->destroyRequested) - { - CXBMCApp::android_printf("CEventLoop: we are being destroyed"); - return; - } + CXBMCApp::android_printf("CEventLoop: ALooper_pollOnce returned an error"); + break; } + + // Process this event. + if (source != nullptr) + source->process(m_application, source); } + + CXBMCApp::android_printf("CEventLoop: we are being destroyed"); } void CEventLoop::processActivity(int32_t command) -- cgit v1.2.3