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
commit2e736c57a596ad4f6f71c21941a4e1f901e1ff53 (patch)
treec92adfdd77348798678c2269672566d618b66551 /libsensors
parent13c42375e0eff345ec72b7111f811e3b089508de (diff)
downloaddevice_samsung_tuna-2e736c57a596ad4f6f71c21941a4e1f901e1ff53.zip
device_samsung_tuna-2e736c57a596ad4f6f71c21941a4e1f901e1ff53.tar.gz
device_samsung_tuna-2e736c57a596ad4f6f71c21941a4e1f901e1ff53.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--;