#include <command_worker.h>
#include <sensor_plugin_loader.h>
#include <sensor_info.h>
+#include <sensor_accel.h>
+#include <sensor_gyro.h>
+#include <sensor_geomag.h>
+#include <sensor_orientation.h>
+#include <sensor_linear_accel.h>
+#include <sensor_gravity.h>
#include <thread>
#include <string>
#include <utility>
#include <dlfcn.h>
+#include <set>
+using namespace std;
using std::string;
+using std::set;
using std::make_pair;
#define SECURITY_LIB "/usr/lib/libsecurity-server-client.so.1"
+set<unsigned int> priority_list;
+
void *command_worker::m_security_handle = NULL;
command_worker::security_server_check_privilege_by_sockfd_t command_worker::security_server_check_privilege_by_sockfd = NULL;
command_worker::cmd_handler_t command_worker::m_cmd_handlers[];
ret_value = OP_ERROR;
goto out;
}
+ if (cmd->event_type == GRAVITY_EVENT_RAW_DATA_REPORT_ON_TIME || cmd->event_type == LINEAR_ACCEL_EVENT_RAW_DATA_REPORT_ON_TIME || cmd->event_type == ORIENTATION_EVENT_RAW_DATA_REPORT_ON_TIME) {
+ priority_list.insert(ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME);
+ priority_list.insert(GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME);
+ priority_list.insert(GEOMAGNETIC_EVENT_RAW_DATA_REPORT_ON_TIME);
+ }
m_module->add_client(cmd->event_type);
#include <queue>
#include <mutex>
#include <condition_variable>
+#include <set>
+using namespace std;
using std::queue;
using std::mutex;
using std::lock_guard;
using std::unique_lock;
using std::condition_variable;
+using std::set;
+
+extern set<unsigned int> priority_list;
class csensor_event_queue
{
private:
static const unsigned int QUEUE_FULL_SIZE = 1000;
- queue<void* > m_queue;
+ class compare {
+ public:
+ bool operator() (void* &v1,void *&v2) {
+ sensor_event_t *e1 = (sensor_event_t *)v1;
+ sensor_event_t *e2 = (sensor_event_t *)v2;
+ bool prioritize_e1 = true;
+ bool prioritize_e2 = true;
+
+ if (priority_list.empty())
+ return (e2->data.timestamp < e1->data.timestamp);
+
+ set<unsigned int>::iterator iter_e1 = priority_list.find(e1->event_type);
+ set<unsigned int>::iterator iter_e2 = priority_list.find(e2->event_type);
+
+ if (iter_e1 == priority_list.end())
+ prioritize_e1 = false;
+
+ if (iter_e2 == priority_list.end())
+ prioritize_e2 = false;
+
+ if (prioritize_e2) {
+ if (!prioritize_e1)
+ return true;
+ else {
+ if (e2->data.timestamp <= e1->data.timestamp)
+ return true;
+ return false;
+ }
+ }
+ else {
+ if (prioritize_e1)
+ return false;
+ else if (e2->data.timestamp <= e1->data.timestamp)
+ return true;
+ else
+ return false;
+ }
+ }
+ };
+
+ std::priority_queue<void*, std::vector<void*>, compare> m_queue;
+
mutex m_mutex;
condition_variable m_cond_var;