diff --git a/exp/sensor/android.c b/exp/sensor/android.c index dfe4bbf..6f505be 100644 --- a/exp/sensor/android.c +++ b/exp/sensor/android.c @@ -11,6 +11,8 @@ #define GO_ANDROID_SENSOR_LOOPER_ID 100 +#define GO_ANDROID_READ_TIMEOUT_MS 1000 + ASensorEventQueue* queue = NULL; ALooper* looper = NULL; @@ -48,7 +50,7 @@ int GoAndroid_readQueue(int n, int32_t* types, int64_t* timestamps, float* vecto // Try n times read from the event queue. // If anytime timeout occurs, don't retry to read and immediately return. // Consume the event queue entirely between polls. - while (i < n && (id = ALooper_pollAll(-1, NULL, &events, NULL)) >= 0) { + while (i < n && (id = ALooper_pollAll(GO_ANDROID_READ_TIMEOUT_MS, NULL, &events, NULL)) >= 0) { if (id != GO_ANDROID_SENSOR_LOOPER_ID) { continue; }