diff options
author | Jose Luis Marti <joseluis.marti@gmail.com> | 2024-07-09 17:35:20 +0200 |
---|---|---|
committer | Jose Luis Marti <joseluis.marti@gmail.com> | 2024-07-09 21:59:13 +0200 |
commit | a5e486efe2ad4d541bc82453ffd3448226e61002 (patch) | |
tree | a18a4022bb3699fbe9546203b67cfc089ebb402b | |
parent | d7876de3e6d9045941cc12eb4150248e01c1ea64 (diff) |
[Android] Replace ALooper_pollAll with ALooper_pollOnce
-rw-r--r-- | xbmc/platform/android/activity/EventLoop.cpp | 33 |
1 files 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<void**>(&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) |