diff options
author | fuzzard <fuzzard@users.noreply.github.com> | 2024-07-13 12:54:25 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-13 12:54:25 +1000 |
commit | 1b23c55b08b6499dba61c2a8c9b1de55c58168f9 (patch) | |
tree | cbabf0d4ba8f02b6cb10f968bc936d63748ae4aa | |
parent | 81ace978634577074c01a2e4f2bc546443299ee5 (diff) | |
parent | a5e486efe2ad4d541bc82453ffd3448226e61002 (diff) |
Merge pull request #25468 from joseluismarti/ALooper
[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) |