exp/sensor: block forever until new events occur on android
The former Reader inspired APIs were designed to timeout if no events occur after an excessive amount of time. As we switch to the app event based model, timing out is not required. We can block on pollAll forever until new events arrive. Change-Id: I086fc908ebfe6ae9bd96ce9199636ad0242bbec5 Reviewed-on: https://go-review.googlesource.com/14223 Reviewed-by: Nigel Tao <nigeltao@golang.org>
This commit is contained in:
parent
5651add1eb
commit
679c68b58d
|
@ -46,11 +46,10 @@ int GoAndroid_readQueue(int looperId, ASensorEventQueue* q, int n, int32_t* type
|
||||||
int events;
|
int events;
|
||||||
ASensorEvent event;
|
ASensorEvent event;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
// Block for 30 secs at most, timeout if nothing happens.
|
|
||||||
// Try n times read from the event queue.
|
// Try n times read from the event queue.
|
||||||
// If anytime timeout occurs, don't retry to read and immediately return.
|
// If anytime timeout occurs, don't retry to read and immediately return.
|
||||||
// Consume the event queue entirely between polls.
|
// Consume the event queue entirely between polls.
|
||||||
while (i < n && (id = ALooper_pollAll(30*1000, NULL, &events, NULL)) >= 0) {
|
while (i < n && (id = ALooper_pollAll(-1, NULL, &events, NULL)) >= 0) {
|
||||||
if (id != looperId) {
|
if (id != looperId) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue