summaryrefslogtreecommitdiffstats
path: root/libsensors
diff options
context:
space:
mode:
authorWon Hyoung Lee <whlee@sta.samsung.com>2011-10-18 16:35:50 -0700
committerMathias Agopian <mathias@google.com>2011-10-19 13:05:05 -0700
commit6ec7182aaba13d3ee7070acab47be74aad461e40 (patch)
tree88d5f049f7779f40f38fd853add1f05889791535 /libsensors
parent9c654edd7ef645ff4c2303c7822d609c3e63d33a (diff)
downloaddevice_samsung_tuna-6ec7182aaba13d3ee7070acab47be74aad461e40.zip
device_samsung_tuna-6ec7182aaba13d3ee7070acab47be74aad461e40.tar.gz
device_samsung_tuna-6ec7182aaba13d3ee7070acab47be74aad461e40.tar.bz2
SensorHAL: solve the issue that sensors get slow
Solving the bug where residual events in input queue from one sensor that was disabled causes events from other sensors to not be returned until num events = count. The bug has the symptom that events from all sensors seem to be delayed. The bug was in readEvents() in SamsungSensorBase.cpp. Solution is to discard the residual events if sensor has been disabled already. Change-Id: I8c9e1ff741c8f2864d6bc7513c1163c41a178852 Signed-off-by: Won Hyoung Lee <whlee@sta.samsung.com>
Diffstat (limited to 'libsensors')
-rw-r--r--libsensors/SamsungSensorBase.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/libsensors/SamsungSensorBase.cpp b/libsensors/SamsungSensorBase.cpp
index ab8f9d6..0ec4915 100644
--- a/libsensors/SamsungSensorBase.cpp
+++ b/libsensors/SamsungSensorBase.cpp
@@ -146,14 +146,13 @@ int SamsungSensorBase::readEvents(sensors_event_t* data, int count)
pthread_mutex_lock(&mLock);
int numEventReceived = 0;
- if (!mEnabled)
- goto done;
-
if (mHasPendingEvent) {
mHasPendingEvent = false;
- mPendingEvent.timestamp = getTimestamp();
- *data = mPendingEvent;
- numEventReceived++;
+ if (mEnabled) {
+ mPendingEvent.timestamp = getTimestamp();
+ *data = mPendingEvent;
+ numEventReceived++;
+ }
goto done;
}
@@ -161,7 +160,7 @@ int SamsungSensorBase::readEvents(sensors_event_t* data, int count)
while (count && mInputReader.readEvent(data_fd, &event)) {
if (event->type == EV_ABS) {
if (event->code == mSensorCode) {
- if (handleEvent(event)) {
+ if (mEnabled && handleEvent(event)) {
mPendingEvent.timestamp = timevalToNano(event->time);
*data++ = mPendingEvent;
count--;