Fixed bug #9792 - Android: build failure with ndk 27-beta1 due to use of deprecated ALooper_pollAll

replace ALooper_pollAll by ALooper_pollOnce
This commit is contained in:
Sylvain 2024-05-16 10:10:17 +02:00 committed by Sam Lantinga
parent 027856b9fa
commit ee16d2f705
1 changed files with 20 additions and 10 deletions

View File

@ -69,20 +69,30 @@ static int SDLCALL SDL_ANDROID_SensorThread(void *data)
while (SDL_AtomicGet(&ctx->running)) { while (SDL_AtomicGet(&ctx->running)) {
Uint64 timestamp = SDL_GetTicksNS(); Uint64 timestamp = SDL_GetTicksNS();
SDL_bool done = SDL_FALSE;
if (ALooper_pollAll(-1, NULL, &events, (void **)&source) == LOOPER_ID_USER) { while (!done) {
SDL_LockSensors(); int result;
for (i = 0; i < SDL_sensors_count; ++i) {
if (!SDL_sensors[i].event_queue) {
continue;
}
SDL_zero(event); result = ALooper_pollOnce(-1, NULL, &events, (void **)&source);
while (ASensorEventQueue_getEvents(SDL_sensors[i].event_queue, &event, 1) > 0) { if (result == LOOPER_ID_USER) {
SDL_SendSensorUpdate(timestamp, SDL_sensors[i].sensor, timestamp, event.data, SDL_arraysize(event.data)); SDL_LockSensors();
for (i = 0; i < SDL_sensors_count; ++i) {
if (!SDL_sensors[i].event_queue) {
continue;
}
SDL_zero(event);
while (ASensorEventQueue_getEvents(SDL_sensors[i].event_queue, &event, 1) > 0) {
SDL_SendSensorUpdate(timestamp, SDL_sensors[i].sensor, timestamp, event.data, SDL_arraysize(event.data));
}
} }
SDL_UnlockSensors();
}
if (result < 0) {
done = SDL_TRUE;
} }
SDL_UnlockSensors();
} }
} }