summaryrefslogtreecommitdiff
path: root/src/modules/eeze
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 /src/modules/eeze
parentd601c15302277010725d2cdd34fa40eaf5be801d (diff)
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 :)
Diffstat (limited to 'src/modules/eeze')
-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
3 files changed, 6 insertions, 42 deletions
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)
52} 52}
53 53
54static Eina_Bool 54static Eina_Bool
55fake_read(Eeze_Sensor_Type sensor_type, Eeze_Sensor_Obj *lobj) 55fake_read(Eeze_Sensor_Obj *obj)
56{ 56{
57 Eeze_Sensor_Obj *obj = NULL; 57 switch (obj->type)
58
59 obj = eeze_sensor_obj_get(sensor_type);
60 if (obj == NULL)
61 {
62 ERR("No matching sensor object found in list");
63 return EINA_FALSE;
64 }
65
66 switch (sensor_type)
67 { 58 {
68 case EEZE_SENSOR_TYPE_ACCELEROMETER: 59 case EEZE_SENSOR_TYPE_ACCELEROMETER:
69 case EEZE_SENSOR_TYPE_GRAVITY: 60 case EEZE_SENSOR_TYPE_GRAVITY:
@@ -91,13 +82,9 @@ fake_read(Eeze_Sensor_Type sensor_type, Eeze_Sensor_Obj *lobj)
91 82
92 default: 83 default:
93 ERR("Not possible to read from this sensor type."); 84 ERR("Not possible to read from this sensor type.");
94 free(obj);
95 return EINA_FALSE; 85 return EINA_FALSE;
96 } 86 }
97 87
98 memcpy(lobj, obj, sizeof(Eeze_Sensor_Obj));
99 free(obj);
100
101 return EINA_TRUE; 88 return EINA_TRUE;
102} 89}
103 90
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)
971 * the system. Normally it is better to use the asynchronous reading functions. 971 * the system. Normally it is better to use the asynchronous reading functions.
972 */ 972 */
973static Eina_Bool 973static Eina_Bool
974eeze_sensor_tizen_read(Eeze_Sensor_Type sensor_type, Eeze_Sensor_Obj *lobj) 974eeze_sensor_tizen_read(Eeze_Sensor_Obj *obj)
975{ 975{
976 sensor_data_accuracy_e accuracy; 976 sensor_data_accuracy_e accuracy;
977 float x, y, z; 977 float x, y, z;
978 float azimuth, pitch, roll, lux, distance, yaw; 978 float azimuth, pitch, roll, lux, distance, yaw;
979 bool supported; 979 bool supported;
980 sensor_type_e type; 980 sensor_type_e type;
981 Eeze_Sensor_Obj *obj;
982 981
983 type = eeze_to_tizen(sensor_type); 982 type = eeze_to_tizen(obj->type);
984 983
985 /* Don't attempt to do anything if the sensor is not available on the system 984 /* Don't attempt to do anything if the sensor is not available on the system
986 * we are running on. 985 * we are running on.
@@ -993,12 +992,6 @@ eeze_sensor_tizen_read(Eeze_Sensor_Type sensor_type, Eeze_Sensor_Obj *lobj)
993 } 992 }
994 993
995 sensor_start(sensor_handle, type); 994 sensor_start(sensor_handle, type);
996 obj = eeze_sensor_obj_get(sensor_type);
997 if (obj == NULL)
998 {
999 ERR("No matching sensor object found in list.");
1000 return EINA_FALSE;
1001 }
1002 995
1003 switch (type) 996 switch (type)
1004 { 997 {
@@ -1083,12 +1076,9 @@ eeze_sensor_tizen_read(Eeze_Sensor_Type sensor_type, Eeze_Sensor_Obj *lobj)
1083 1076
1084 default: 1077 default:
1085 ERR("Not possible to read from this sensor type."); 1078 ERR("Not possible to read from this sensor type.");
1086 free(obj);
1087 return EINA_FALSE; 1079 return EINA_FALSE;
1088 } 1080 }
1089 1081
1090 memcpy(lobj, obj, sizeof(Eeze_Sensor_Obj));
1091 free(obj);
1092 sensor_stop(sensor_handle, type); 1082 sensor_stop(sensor_handle, type);
1093 return EINA_TRUE; 1083 return EINA_TRUE;
1094} 1084}
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)
89} 89}
90 90
91static Eina_Bool 91static Eina_Bool
92udev_read(Eeze_Sensor_Type sensor_type, Eeze_Sensor_Obj *lobj) 92udev_read(Eeze_Sensor_Obj *obj)
93{ 93{
94 Eeze_Sensor_Obj *obj = NULL; 94 switch (obj->type)
95
96 obj = eeze_sensor_obj_get(sensor_type);
97 if (obj == NULL)
98 {
99 ERR("No matching sensor object found in list");
100 return EINA_FALSE;
101 }
102
103 switch (sensor_type)
104 { 95 {
105 case EEZE_SENSOR_TYPE_TEMPERATURE: 96 case EEZE_SENSOR_TYPE_TEMPERATURE:
106 obj->accuracy = -1; 97 obj->accuracy = -1;
@@ -112,13 +103,9 @@ udev_read(Eeze_Sensor_Type sensor_type, Eeze_Sensor_Obj *lobj)
112 103
113 default: 104 default:
114 ERR("Not possible to read from this sensor type."); 105 ERR("Not possible to read from this sensor type.");
115 free(obj);
116 return EINA_FALSE; 106 return EINA_FALSE;
117 } 107 }
118 108
119 memcpy(lobj, obj, sizeof(Eeze_Sensor_Obj));
120 free(obj);
121
122 return EINA_TRUE; 109 return EINA_TRUE;
123} 110}
124 111