aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xbmc/platform/android/activity/EventLoop.cpp33
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)