summaryrefslogtreecommitdiff
path: root/libsensors_iio/src/SensorBase.cpp
diff options
context:
space:
mode:
authorSaadi Maalem <saadi.maalem@intel.com>2015-11-11 17:44:51 +0100
committerZhengyin Qian <qianzy@google.com>2015-11-11 14:00:13 -0800
commitb219170d10f1c119ae79f39271239399cb373760 (patch)
treefc1bbef9f52e3ad787f3f17a53109376998c190f /libsensors_iio/src/SensorBase.cpp
parent4d9b8f68d6614c957803247f5f2970f0d91930c6 (diff)
downloadsensors-b219170d10f1c119ae79f39271239399cb373760.tar.gz
sensor: generate flush_complete event when data timestamps matches
Generating a flush_complete event right after receiving a flush_request from the sensor services breaks the flow as the client stops acquiring data. Solution is to store the timestamp of the flush request and issue the flush_complete event when the timestamp of the sensor data matches Change-Id: Idb273db3e69e6e2593c00298d3d458fc7c965830 Signed-off-by: Fei Li <feix.f.li@intel.com> Signed-off-by: Guillaume Ranquet <guillaumex.ranquet@intel.com>
Diffstat (limited to 'libsensors_iio/src/SensorBase.cpp')
-rw-r--r--libsensors_iio/src/SensorBase.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/libsensors_iio/src/SensorBase.cpp b/libsensors_iio/src/SensorBase.cpp
index e6904e4..992d3d4 100644
--- a/libsensors_iio/src/SensorBase.cpp
+++ b/libsensors_iio/src/SensorBase.cpp
@@ -11,10 +11,24 @@
#include <assert.h>
#include <string.h>
#include <signal.h>
+#include <time.h>
#include "SensorBase.h"
-#define ST_SENSOR_BASE_WAIT_US_BEFORE_SEND_FLUSH (200000)
+int64_t get_monotonic_time(void)
+{
+ int err;
+ struct timespec tm;
+
+ err = clock_gettime(CLOCK_BOOTTIME, &tm);
+ if (err < 0) {
+ ALOGE("get_monotonic_time failed, err=%d", err);
+ return err;
+ }
+
+ ALOGD("get_monotonic_time %ld, %ld", tm.tv_sec, tm.tv_nsec);
+ return (int64_t) tm.tv_sec * 1000000000 + (int64_t) tm.tv_nsec;
+}
SensorBase::SensorBase(const char *name, int handle, int type, int pipe_data_fd)
{
@@ -355,7 +369,7 @@ bool SensorBase::FillSensor_tData(struct sensor_t *data)
return true;
}
-int SensorBase::FlushData(int)
+int SensorBase::FlushData(bool)
{
int err;
sensors_event_t flush_event_data;
@@ -373,6 +387,7 @@ int SensorBase::FlushData(int)
return err;
}
+ ALOGD("SensorBase::FlushData completed.");
return 0;
}