return change_event_batch(handle, event_type, prev_interval, max_batch_latency);
}
-API bool sensord_change_event_maincontext(int handle, unsigned int event_type, GMainContext *maincontext)
-{
- AUTOLOCK(lock);
-
- if (!sensor_client_info::get_instance().set_event_maincontext(handle, event_type, maincontext)) {
- _E("Failed to get event info with handle = %d, event_type = 0x%x, maincontext = 0x%x", handle, event_type, maincontext);
- return false;
- }
-
- _I("handle = %d, event_type = 0x%x, maincontext = 0x%x", handle, event_type, maincontext);
- return true;
-}
-
API bool sensord_set_option(int handle, int option)
{
sensor_id_t sensor_id;
#ifndef _REG_EVENT_INFO_H_
#define _REG_EVENT_INFO_H_
-#include <glib.h>
#include <sensor_common.h>
typedef enum {
void *m_user_data;
unsigned long long m_previous_event_time;
bool m_fired;
- GMainContext *m_maincontext;
reg_event_info()
: m_id(0), m_handle(-1),
type(0), m_interval(POLL_1HZ_MS), m_latency(0),
m_cb_type(SENSOR_EVENT_CB), m_cb(NULL), m_user_data(NULL),
- m_previous_event_time(0), m_fired(false), m_maincontext(NULL) {}
+ m_previous_event_time(0), m_fired(false) {}
~reg_event_info() {}
};
return true;
}
-bool sensor_client_info::set_event_maincontext(int handle, unsigned int event_type, GMainContext *maincontext)
-{
- AUTOLOCK(m_handle_info_lock);
-
- auto it_handle = m_sensor_handle_infos.find(handle);
-
- if (it_handle == m_sensor_handle_infos.end()) {
- _E("Handle[%d] is not found for client %s", handle, get_client_name());
- return false;
- }
-
- if (!it_handle->second.change_reg_event_maincontext(event_type, maincontext))
- return false;
-
- return true;
-}
-
bool sensor_client_info::set_accuracy(int handle, int accuracy)
{
AUTOLOCK(m_handle_info_lock);
bool set_sensor_state(int handle, int sensor_state);
bool set_sensor_option(int handle, int sensor_option);
bool set_event_batch(int handle, unsigned int event_type, unsigned int interval, unsigned int latency);
- bool set_event_maincontext(int handle, unsigned int event_type, GMainContext *maincontext);
bool set_accuracy(int handle, int accuracy);
bool set_bad_accuracy(int handle, int bad_accuracy);
bool get_event_info(int handle, unsigned int event_type, unsigned int &interval, unsigned int &latency, int &cb_type, void* &cb, void* &user_data);
callback_info->timestamp = 0;
callback_info->accuracy = -1;
callback_info->accuracy_user_data = NULL;
- callback_info->maincontext = event_info->m_maincontext;
callback_info->sensor_data = sensor_data;
callback_info->buffer = buffer;
void sensor_event_listener::post_callback_to_main_loop(client_callback_info* cb_info)
{
- if (cb_info->maincontext) {
- GSource *_source = g_idle_source_new();
-
- g_source_attach(_source, cb_info->maincontext);
- g_source_set_callback(_source, callback_dispatcher, cb_info, NULL);
- } else {
- g_idle_add_full(G_PRIORITY_DEFAULT, callback_dispatcher, cb_info, NULL);
- }
+ g_idle_add_full(G_PRIORITY_DEFAULT, callback_dispatcher, cb_info, NULL);
}
bool sensor_event_listener::is_valid_callback(client_callback_info *cb_info)
unsigned long long timestamp;
int accuracy;
void *accuracy_user_data;
- GMainContext *maincontext;
void *buffer;
} client_callback_info;
return true;
}
-bool sensor_handle_info::change_reg_event_maincontext(unsigned int event_type, GMainContext *maincontext)
-{
- auto it_event = m_reg_event_infos.find(event_type);
-
- if (it_event == m_reg_event_infos.end()) {
- _E("Event %s[0x%x] is not registered for client %s", get_event_name(event_type), event_type, get_client_name());
- return false;
- }
-
- it_event->second.m_maincontext = maincontext;
-
- return true;
-}
-
void sensor_handle_info::get_batch(unsigned int &interval, unsigned int &latency)
{
if (m_reg_event_infos.empty()) {
#include <sensor_log.h>
#include <string.h>
#include <unordered_map>
-#include <glib.h>
typedef std::unordered_map<unsigned int,reg_event_info> event_info_map;
bool delete_reg_event_info(unsigned int event_type);
bool change_reg_event_batch(unsigned int event_type, unsigned int interval, unsigned int latency);
- bool change_reg_event_maincontext(unsigned int event_type, GMainContext *maincontext);
reg_event_info* get_reg_event_info(const unsigned int event_type);
void get_reg_event_types(event_type_vector &event_types);
#include "stdbool.h"
#include <sys/types.h>
-#include <glib.h>
/*header for common sensor type*/
#include <sensor_common.h>
bool sensord_change_event_max_batch_latency(int handle, unsigned int event_type, unsigned int max_batch_latency);
/**
- * @brief Change the maincontext of a specifed event type in a connected sensor.
- *
- * @param[in] handle a handle represensting a connected sensor.
- * @param[in] event_type an event type to change maincontext.
- * @param[in] maincontext an event is passed to default GMainLoop as default. And it can be changed to specific GMainContext.
- * @return true on success, otherwise false.
- */
-bool sensord_change_event_maincontext(int handle, unsigned int event_type, GMainContext *maincontext);
-
-/**
* @brief Change the option of a connected sensor.
*
* @param[in] handle a handle represensting a connected sensor.