Removing mutex lock that was affecting performance 01/36001/1
authorRamasamy <ram.kannan@samsung.com>
Fri, 27 Feb 2015 09:33:57 +0000 (15:03 +0530)
committerRamasamy <ram.kannan@samsung.com>
Fri, 27 Feb 2015 09:34:04 +0000 (15:04 +0530)
- Removing mutex lock used during entry into orientation_filter
- lock is not needed as each virtual sensor has a separate
orientation_filter object
- separate objects in virtual sensor for both event driven and
polling based modes.

Change-Id: Ie2d2aa41a664c858fc1305213c3f9bb2309a7e67

src/orientation/orientation_sensor.cpp
src/orientation/orientation_sensor.h
src/rotation_vector/gaming_rv/gaming_rv_sensor.cpp
src/rotation_vector/gaming_rv/gaming_rv_sensor.h
src/rotation_vector/geomagnetic_rv/geomagnetic_rv_sensor.cpp
src/rotation_vector/geomagnetic_rv/geomagnetic_rv_sensor.h
src/rotation_vector/rv/rv_sensor.cpp
src/rotation_vector/rv/rv_sensor.h
src/shared/virtual_sensor.h

index 500217a..0c8bed3 100755 (executable)
@@ -334,15 +334,12 @@ void orientation_sensor::synthesize(const sensor_event_t &event, vector<sensor_e
        if (m_enable_orientation == ORIENTATION_ENABLED) {
                m_enable_orientation = 0;
 
-               m_orientation.m_pitch_phase_compensation = m_pitch_rotation_compensation;
-               m_orientation.m_roll_phase_compensation = m_roll_rotation_compensation;
-               m_orientation.m_azimuth_phase_compensation = m_azimuth_rotation_compensation;
-               m_orientation.m_magnetic_alignment_factor = m_magnetic_alignment_factor;
-
-               {
-                       AUTOLOCK(m_fusion_mutex);
-                       euler_orientation = m_orientation.get_orientation(m_accel, m_gyro, m_magnetic);
-               }
+               m_orientation_filter.m_pitch_phase_compensation = m_pitch_rotation_compensation;
+               m_orientation_filter.m_roll_phase_compensation = m_roll_rotation_compensation;
+               m_orientation_filter.m_azimuth_phase_compensation = m_azimuth_rotation_compensation;
+               m_orientation_filter.m_magnetic_alignment_factor = m_magnetic_alignment_factor;
+
+               euler_orientation = m_orientation_filter.get_orientation(m_accel, m_gyro, m_magnetic);
 
                if(m_raw_data_unit == "DEGREES") {
                        euler_orientation = rad2deg(euler_orientation);
@@ -398,15 +395,12 @@ int orientation_sensor::get_sensor_data(const unsigned int event_type, sensor_da
        gyro.m_time_stamp = gyro_data.timestamp;
        magnetic.m_time_stamp = magnetic_data.timestamp;
 
-       m_orientation.m_pitch_phase_compensation = m_pitch_rotation_compensation;
-       m_orientation.m_roll_phase_compensation = m_roll_rotation_compensation;
-       m_orientation.m_azimuth_phase_compensation = m_azimuth_rotation_compensation;
-       m_orientation.m_magnetic_alignment_factor = m_magnetic_alignment_factor;
+       m_orientation_filter_poll.m_pitch_phase_compensation = m_pitch_rotation_compensation;
+       m_orientation_filter_poll.m_roll_phase_compensation = m_roll_rotation_compensation;
+       m_orientation_filter_poll.m_azimuth_phase_compensation = m_azimuth_rotation_compensation;
+       m_orientation_filter_poll.m_magnetic_alignment_factor = m_magnetic_alignment_factor;
 
-       {
-               AUTOLOCK(m_fusion_mutex);
-               euler_orientation = m_orientation.get_orientation(m_accel, m_gyro, m_magnetic);
-       }
+       euler_orientation = m_orientation_filter_poll.get_orientation(m_accel, m_gyro, m_magnetic);
 
        if(m_raw_data_unit == "DEGREES") {
                euler_orientation = rad2deg(euler_orientation);
index 03755cc..baa783b 100755 (executable)
@@ -51,7 +51,8 @@ private:
 
        cmutex m_value_mutex;
 
-       orientation_filter<float> m_orientation;
+       orientation_filter<float> m_orientation_filter;
+       orientation_filter<float> m_orientation_filter_poll;
 
        unsigned int m_enable_orientation;
 
index 51a0a4b..fb44e0c 100755 (executable)
@@ -244,10 +244,7 @@ void gaming_rv_sensor::synthesize(const sensor_event_t& event, vector<sensor_eve
        if (m_enable_gaming_rv == GAMING_RV_ENABLED) {
                m_enable_gaming_rv = 0;
 
-               {
-                       AUTOLOCK(m_fusion_mutex);
-                       quaternion_gaming_rv = m_orientation_filter.get_gaming_quaternion(m_accel, m_gyro);
-               }
+               quaternion_gaming_rv = m_orientation_filter.get_gaming_quaternion(m_accel, m_gyro);
 
                m_time = get_timestamp();
                rv_event.sensor_id = get_id();
@@ -287,10 +284,7 @@ int gaming_rv_sensor::get_sensor_data(unsigned int event_type, sensor_data_t &da
        accel.m_time_stamp = accel_data.timestamp;
        gyro.m_time_stamp = gyro_data.timestamp;
 
-       {
-               AUTOLOCK(m_fusion_mutex);
-               quaternion_gaming_rv = m_orientation_filter.get_gaming_quaternion(m_accel, m_gyro);
-       }
+       quaternion_gaming_rv = m_orientation_filter_poll.get_gaming_quaternion(m_accel, m_gyro);
 
        data.accuracy = SENSOR_ACCURACY_GOOD;
        data.timestamp = get_timestamp();
index c54d2b9..6fe4d28 100755 (executable)
@@ -50,6 +50,7 @@ private:
        cmutex m_value_mutex;
 
        orientation_filter<float> m_orientation_filter;
+       orientation_filter<float> m_orientation_filter_poll;
 
        unsigned int m_enable_gaming_rv;
 
index ae0348f..6649333 100755 (executable)
@@ -255,10 +255,7 @@ void geomagnetic_rv_sensor::synthesize(const sensor_event_t& event, vector<senso
 
                m_orientation_filter.m_magnetic_alignment_factor = m_magnetic_alignment_factor;
 
-               {
-                       AUTOLOCK(m_fusion_mutex);
-                       quaternion_geo_rv = m_orientation_filter.get_geomagnetic_quaternion(m_accel, m_magnetic);
-               }
+               quaternion_geo_rv = m_orientation_filter.get_geomagnetic_quaternion(m_accel, m_magnetic);
 
                m_time = get_timestamp();
                rv_event.sensor_id = get_id();
@@ -298,12 +295,9 @@ int geomagnetic_rv_sensor::get_sensor_data(unsigned int event_type, sensor_data_
        accel.m_time_stamp = accel_data.timestamp;
        magnetic.m_time_stamp = magnetic_data.timestamp;
 
-       m_orientation_filter.m_magnetic_alignment_factor = m_magnetic_alignment_factor;
+       m_orientation_filter_poll.m_magnetic_alignment_factor = m_magnetic_alignment_factor;
 
-       {
-               AUTOLOCK(m_fusion_mutex);
-               quaternion_geo_rv = m_orientation_filter.get_geomagnetic_quaternion(m_accel, m_magnetic);
-       }
+       quaternion_geo_rv = m_orientation_filter_poll.get_geomagnetic_quaternion(m_accel, m_magnetic);
 
        data.accuracy = SENSOR_ACCURACY_GOOD;
        data.timestamp = get_timestamp();
index 9f3bdb1..8b54705 100755 (executable)
@@ -50,6 +50,7 @@ private:
        cmutex m_value_mutex;
 
        orientation_filter<float> m_orientation_filter;
+       orientation_filter<float> m_orientation_filter_poll;
 
        unsigned int m_enable_geomagnetic_rv;
 
index 958042e..48c48de 100755 (executable)
@@ -300,15 +300,12 @@ void rv_sensor::synthesize(const sensor_event_t& event, vector<sensor_event_t> &
        if (m_enable_orientation == ORIENTATION_ENABLED) {
                m_enable_orientation = 0;
 
-               m_orientation.m_pitch_phase_compensation = m_pitch_rotation_compensation;
-               m_orientation.m_roll_phase_compensation = m_roll_rotation_compensation;
-               m_orientation.m_azimuth_phase_compensation = m_azimuth_rotation_compensation;
-               m_orientation.m_magnetic_alignment_factor = m_magnetic_alignment_factor;
+               m_orientation_filter.m_pitch_phase_compensation = m_pitch_rotation_compensation;
+               m_orientation_filter.m_roll_phase_compensation = m_roll_rotation_compensation;
+               m_orientation_filter.m_azimuth_phase_compensation = m_azimuth_rotation_compensation;
+               m_orientation_filter.m_magnetic_alignment_factor = m_magnetic_alignment_factor;
 
-               {
-                       AUTOLOCK(m_fusion_mutex);
-                       quaternion_orientation = m_orientation.get_9axis_quaternion(m_accel, m_gyro, m_magnetic);
-               }
+               quaternion_orientation = m_orientation_filter.get_9axis_quaternion(m_accel, m_gyro, m_magnetic);
 
                m_time = get_timestamp();
                rv_event.sensor_id = get_id();
@@ -353,15 +350,12 @@ int rv_sensor::get_sensor_data(unsigned int event_type, sensor_data_t &data)
        gyro.m_time_stamp = gyro_data.timestamp;
        magnetic.m_time_stamp = magnetic_data.timestamp;
 
-       m_orientation.m_pitch_phase_compensation = m_pitch_rotation_compensation;
-       m_orientation.m_roll_phase_compensation = m_roll_rotation_compensation;
-       m_orientation.m_azimuth_phase_compensation = m_azimuth_rotation_compensation;
-       m_orientation.m_magnetic_alignment_factor = m_magnetic_alignment_factor;
+       m_orientation_filter_poll.m_pitch_phase_compensation = m_pitch_rotation_compensation;
+       m_orientation_filter_poll.m_roll_phase_compensation = m_roll_rotation_compensation;
+       m_orientation_filter_poll.m_azimuth_phase_compensation = m_azimuth_rotation_compensation;
+       m_orientation_filter_poll.m_magnetic_alignment_factor = m_magnetic_alignment_factor;
 
-       {
-               AUTOLOCK(m_fusion_mutex);
-               quaternion_orientation = m_orientation.get_9axis_quaternion(m_accel, m_gyro, m_magnetic);
-       }
+       quaternion_orientation = m_orientation_filter_poll.get_9axis_quaternion(m_accel, m_gyro, m_magnetic);
 
        data.accuracy = SENSOR_ACCURACY_GOOD;
        data.timestamp = get_timestamp();
index 003c3fa..e3d2158 100755 (executable)
@@ -51,7 +51,8 @@ private:
 
        cmutex m_value_mutex;
 
-       orientation_filter<float> m_orientation;
+       orientation_filter<float> m_orientation_filter;
+       orientation_filter<float> m_orientation_filter_poll;
 
        unsigned int m_enable_orientation;
 
index 3cb79fb..7a3b70c 100755 (executable)
@@ -33,7 +33,6 @@ public:
        bool is_virtual(void);
 
 protected:
-       cmutex m_fusion_mutex;
 
        bool activate(void);
        bool deactivate(void);