@@ -404,25 +404,21 @@ void android_main(android_app* state) {
404
404
engine.state = *(SavedState*)state->savedState ;
405
405
}
406
406
407
- while (true ) {
408
- // Read all pending events.
409
- int events;
410
- android_poll_source* source;
411
-
407
+ while (!state->destroyRequested ) {
412
408
// Our input, sensor, and update/render logic is all driven by callbacks, so
413
409
// we don't need to use the non-blocking poll.
414
- while ((ALooper_pollAll (-1 , nullptr , &events, (void **)&source)) >= 0 ) {
415
- // Process this event.
416
- if (source != nullptr ) {
417
- source->process (state, source);
418
- }
410
+ android_poll_source* source = nullptr ;
411
+ auto result = ALooper_pollOnce (-1 , nullptr , nullptr ,
412
+ reinterpret_cast <void **>(&source));
413
+ if (result == ALOOPER_POLL_ERROR) {
414
+ fatal (" ALooper_pollOnce returned an error" );
415
+ }
419
416
420
- // Check if we are exiting.
421
- if (state->destroyRequested != 0 ) {
422
- engine_term_display (&engine);
423
- return ;
424
- }
417
+ if (source != nullptr ) {
418
+ source->process (state, source);
425
419
}
426
420
}
421
+
422
+ engine_term_display (&engine);
427
423
}
428
424
// END_INCLUDE(all)
0 commit comments