Replace deprecated Android function ALooper_pollAll with ALooper_pollOnce (#4275)

This commit is contained in:
Menno van der Graaf 2024-08-23 22:32:20 +02:00 committed by GitHub
parent ecf863969c
commit 3079c69725
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -281,14 +281,15 @@ void android_main(struct android_app *app)
// Request to end the native activity
ANativeActivity_finish(app->activity);
// Android ALooper_pollAll() variables
// Android ALooper_pollOnce() variables
int pollResult = 0;
int pollEvents = 0;
// Waiting for application events before complete finishing
while (!app->destroyRequested)
{
while ((pollResult = ALooper_pollAll(0, NULL, &pollEvents, (void **)&platform.source)) >= 0)
// Poll all events until we reach return value TIMEOUT, meaning no events left to process
while ((pollResult = ALooper_pollOnce(0, NULL, &pollEvents, (void **)&platform.source)) > ALOOPER_POLL_TIMEOUT)
{
if (platform.source != NULL) platform.source->process(app, platform.source);
}
@ -682,13 +683,13 @@ void PollInputEvents(void)
CORE.Input.Keyboard.keyRepeatInFrame[i] = 0;
}
// Android ALooper_pollAll() variables
// Android ALooper_pollOnce() variables
int pollResult = 0;
int pollEvents = 0;
// Poll Events (registered events)
// Poll Events (registered events) until we reach TIMEOUT which indicates there are no events left to poll
// NOTE: Activity is paused if not enabled (platform.appEnabled)
while ((pollResult = ALooper_pollAll(platform.appEnabled? 0 : -1, NULL, &pollEvents, (void**)&platform.source)) >= 0)
while ((pollResult = ALooper_pollOnce(platform.appEnabled? 0 : -1, NULL, &pollEvents, (void**)&platform.source)) > ALOOPER_POLL_TIMEOUT)
{
// Process this event
if (platform.source != NULL) platform.source->process(platform.app, platform.source);
@ -767,15 +768,15 @@ int InitPlatform(void)
TRACELOG(LOG_INFO, "PLATFORM: ANDROID: Initialized successfully");
// Android ALooper_pollAll() variables
// Android ALooper_pollOnce() variables
int pollResult = 0;
int pollEvents = 0;
// Wait for window to be initialized (display and context)
while (!CORE.Window.ready)
{
// Process events loop
while ((pollResult = ALooper_pollAll(0, NULL, &pollEvents, (void**)&platform.source)) >= 0)
// Process events until we reach TIMEOUT, which indicates no more events queued.
while ((pollResult = ALooper_pollOnce(0, NULL, &pollEvents, (void**)&platform.source)) > ALOOPER_POLL_TIMEOUT)
{
// Process this event
if (platform.source != NULL) platform.source->process(platform.app, platform.source);