fix a few problems with BitTube
BitTube used to send objects one at a time and didn't
handle errors properly.
We now send all the objects in one call, which means they
have to be read as a single batch as well. This changes the
BitTube API.
Update SensorService to the new API.
Also added an API to set the size of the send buffer.
Bug: 10641596
Change-Id: I77c70d35e351fdba0416fae4b7ca3b1d56272251
diff --git a/services/sensorservice/SensorService.cpp b/services/sensorservice/SensorService.cpp
index 7bb6e86..cb99531 100644
--- a/services/sensorservice/SensorService.cpp
+++ b/services/sensorservice/SensorService.cpp
@@ -292,8 +292,12 @@
{
ALOGD("nuSensorService thread starting...");
- const size_t numEventMax = 16;
- const size_t minBufferSize = numEventMax + numEventMax * mVirtualSensorList.size();
+ // each virtual sensor could generate an event per "real" event, that's why we need
+ // to size numEventMax much smaller than MAX_RECEIVE_BUFFER_EVENT_COUNT.
+ // in practice, this is too aggressive, but guaranteed to be enough.
+ const size_t minBufferSize = SensorEventQueue::MAX_RECEIVE_BUFFER_EVENT_COUNT;
+ const size_t numEventMax = minBufferSize / (1 + mVirtualSensorList.size());
+
sensors_event_t buffer[minBufferSize];
sensors_event_t scratch[minBufferSize];
SensorDevice& device(SensorDevice::getInstance());