aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Schmidt <s.schmidt@samsung.com>2013-04-18 17:35:37 +0100
committerStefan Schmidt <s.schmidt@samsung.com>2013-04-19 09:21:12 +0100
commit27a711b83cd8a8f56c6f4c103087523da374299b (patch)
tree479419c0a51b89d856f605535ab6c07d1f31675a
parentecore: update ecore_test_ecore_main_loop_event test for more coverage code. (diff)
downloadefl-27a711b83cd8a8f56c6f4c103087523da374299b.tar.gz
eeze/sensor: Simplify sensor object handling.
We rely on the app to provide a sensible object pointer and we now longer need to have a copy of the object around to operate on it. Simplifies code, maintenance and reduces mem copies. Win-Win :)
-rw-r--r--src/lib/eeze/eeze_sensor.c6
-rw-r--r--src/lib/eeze/eeze_sensor_private.h2
-rw-r--r--src/modules/eeze/sensor/fake/fake.c17
-rw-r--r--src/modules/eeze/sensor/tizen/tizen.c14
-rw-r--r--src/modules/eeze/sensor/udev/udev.c17
5 files changed, 10 insertions, 46 deletions
diff --git a/src/lib/eeze/eeze_sensor.c b/src/lib/eeze/eeze_sensor.c
index 40861427be..da12a1226e 100644
--- a/src/lib/eeze/eeze_sensor.c
+++ b/src/lib/eeze/eeze_sensor.c
@@ -153,7 +153,7 @@ eeze_sensor_module_unregister(const char *name)
module = eina_hash_find(g_handle->modules, name);
if (!module) return EINA_FALSE;
-
+
if (module->shutdown)
module->shutdown();
@@ -196,7 +196,7 @@ eeze_sensor_new(Eeze_Sensor_Type type)
* the downside that the sensor creation takes longer. But that is only a
*initial cost.
*/
- if (module->read(sens->type, sens))
+ if (module->read(sens))
return sens;
free(sens);
@@ -277,7 +277,7 @@ eeze_sensor_read(Eeze_Sensor_Obj *sens)
if (!module) return EINA_FALSE;
if (module->read)
- return module->read(sens->type, sens);
+ return module->read(sens);
return EINA_FALSE;
}
diff --git a/src/lib/eeze/eeze_sensor_private.h b/src/lib/eeze/eeze_sensor_private.h
index d8f0a28d37..3ba6198d8e 100644
--- a/src/lib/eeze/eeze_sensor_private.h
+++ b/src/lib/eeze/eeze_sensor_private.h
@@ -57,7 +57,7 @@ typedef struct _Eeze_Sensor_Module
Eina_Bool (*init)(void); /**< Pointer to module init function */
Eina_Bool (*shutdown)(void); /**< Pointer to module shutdown function */
Eina_Bool (*async_read)(Eeze_Sensor_Type sensor_type, void *user_data); /**< Pointer to module async_read function */
- Eina_Bool (*read)(Eeze_Sensor_Type sensor_type, Eeze_Sensor_Obj *obj); /**< Pointer to module read function */
+ Eina_Bool (*read)(Eeze_Sensor_Obj *obj); /**< Pointer to module read function */
Eina_List *sensor_list; /**< List of sensor objects attached to the module */
} Eeze_Sensor_Module;
diff --git a/src/modules/eeze/sensor/fake/fake.c b/src/modules/eeze/sensor/fake/fake.c
index ee07b982de..bf9d694eca 100644
--- a/src/modules/eeze/sensor/fake/fake.c
+++ b/src/modules/eeze/sensor/fake/fake.c
@@ -52,18 +52,9 @@ fake_shutdown(void)
}
static Eina_Bool
-fake_read(Eeze_Sensor_Type sensor_type, Eeze_Sensor_Obj *lobj)
+fake_read(Eeze_Sensor_Obj *obj)
{
- Eeze_Sensor_Obj *obj = NULL;
-
- obj = eeze_sensor_obj_get(sensor_type);
- if (obj == NULL)
- {
- ERR("No matching sensor object found in list");
- return EINA_FALSE;
- }
-
- switch (sensor_type)
+ switch (obj->type)
{
case EEZE_SENSOR_TYPE_ACCELEROMETER:
case EEZE_SENSOR_TYPE_GRAVITY:
@@ -91,13 +82,9 @@ fake_read(Eeze_Sensor_Type sensor_type, Eeze_Sensor_Obj *lobj)
default:
ERR("Not possible to read from this sensor type.");
- free(obj);
return EINA_FALSE;
}
- memcpy(lobj, obj, sizeof(Eeze_Sensor_Obj));
- free(obj);
-
return EINA_TRUE;
}
diff --git a/src/modules/eeze/sensor/tizen/tizen.c b/src/modules/eeze/sensor/tizen/tizen.c
index b6f44aa483..7a06baa3c5 100644
--- a/src/modules/eeze/sensor/tizen/tizen.c
+++ b/src/modules/eeze/sensor/tizen/tizen.c
@@ -971,16 +971,15 @@ no_move_read_cb(unsigned long long timestamp, void *user_data)
* the system. Normally it is better to use the asynchronous reading functions.
*/
static Eina_Bool
-eeze_sensor_tizen_read(Eeze_Sensor_Type sensor_type, Eeze_Sensor_Obj *lobj)
+eeze_sensor_tizen_read(Eeze_Sensor_Obj *obj)
{
sensor_data_accuracy_e accuracy;
float x, y, z;
float azimuth, pitch, roll, lux, distance, yaw;
bool supported;
sensor_type_e type;
- Eeze_Sensor_Obj *obj;
- type = eeze_to_tizen(sensor_type);
+ type = eeze_to_tizen(obj->type);
/* Don't attempt to do anything if the sensor is not available on the system
* we are running on.
@@ -993,12 +992,6 @@ eeze_sensor_tizen_read(Eeze_Sensor_Type sensor_type, Eeze_Sensor_Obj *lobj)
}
sensor_start(sensor_handle, type);
- obj = eeze_sensor_obj_get(sensor_type);
- if (obj == NULL)
- {
- ERR("No matching sensor object found in list.");
- return EINA_FALSE;
- }
switch (type)
{
@@ -1083,12 +1076,9 @@ eeze_sensor_tizen_read(Eeze_Sensor_Type sensor_type, Eeze_Sensor_Obj *lobj)
default:
ERR("Not possible to read from this sensor type.");
- free(obj);
return EINA_FALSE;
}
- memcpy(lobj, obj, sizeof(Eeze_Sensor_Obj));
- free(obj);
sensor_stop(sensor_handle, type);
return EINA_TRUE;
}
diff --git a/src/modules/eeze/sensor/udev/udev.c b/src/modules/eeze/sensor/udev/udev.c
index e958b06a6b..a23bf5e84d 100644
--- a/src/modules/eeze/sensor/udev/udev.c
+++ b/src/modules/eeze/sensor/udev/udev.c
@@ -89,18 +89,9 @@ _udev_read(void)
}
static Eina_Bool
-udev_read(Eeze_Sensor_Type sensor_type, Eeze_Sensor_Obj *lobj)
+udev_read(Eeze_Sensor_Obj *obj)
{
- Eeze_Sensor_Obj *obj = NULL;
-
- obj = eeze_sensor_obj_get(sensor_type);
- if (obj == NULL)
- {
- ERR("No matching sensor object found in list");
- return EINA_FALSE;
- }
-
- switch (sensor_type)
+ switch (obj->type)
{
case EEZE_SENSOR_TYPE_TEMPERATURE:
obj->accuracy = -1;
@@ -112,13 +103,9 @@ udev_read(Eeze_Sensor_Type sensor_type, Eeze_Sensor_Obj *lobj)
default:
ERR("Not possible to read from this sensor type.");
- free(obj);
return EINA_FALSE;
}
- memcpy(lobj, obj, sizeof(Eeze_Sensor_Obj));
- free(obj);
-
return EINA_TRUE;
}