Check device_handle is the same with current vibration handle on close_device() 33/196933/3
authorpr.jung <pr.jung@samsung.com>
Tue, 8 Jan 2019 05:05:15 +0000 (14:05 +0900)
committerpr.jung <pr.jung@samsung.com>
Tue, 8 Jan 2019 05:13:12 +0000 (14:13 +0900)
- Check device_handle
- Remove redundant operations

Change-Id: If7597c20ace9b43d1bcbfb5017b983c15da00c7d
Signed-off-by: pr.jung <pr.jung@samsung.com>
src/haptic/circle.c
src/haptic/gpio_haptic.c
src/haptic/standard.c

index 9c756e7..aa1b7a5 100644 (file)
@@ -158,17 +158,6 @@ static int close_device(int device_handle)
        if (r < 0)
                _I("already stopped or failed to stop effect : %d", r);
 
-       /* unregister existing timer */
-       if (r >= 0) {
-               _D("device handle %d is closed and timer deleted", device_handle);
-               if (stop_timer) {
-                       g_source_remove(stop_timer);
-                       stop_timer = 0;
-               }
-       }
-
-       standard_vibrate_close();
-
        DD_LIST_REMOVE(handle_list, (gpointer)(long)device_handle);
 
        /* if it is the last element */
index 3d91b5a..c495d6c 100644 (file)
@@ -188,17 +188,6 @@ static int gpio_haptic_close_device(int handle)
        if (r < 0)
                _I("already stopped or failed to stop effect : %d", r);
 
-       /* unregister existing timer */
-       if (r >= 0) {
-               if (stop_timer) {
-                       //ecore_timer_del(stop_timer);
-                       g_source_remove(stop_timer);
-                       stop_timer = 0;
-               }
-       }
-
-       standard_vibrate_close();
-
        _D("handle %d is closed and timer deleted", handle);
        DD_LIST_REMOVE(handle_list, (gpointer)(long)handle);
 
index c0436fe..dd162b2 100644 (file)
@@ -75,6 +75,7 @@ static dd_list *handle_list;
 static char ff_path[PATH_MAX];
 static int unique_number;
 
+static int stop_device(int device_handle);
 struct ff_info *read_from_list(int handle)
 {
        struct ff_info *temp;
@@ -358,7 +359,7 @@ static int open_device(int device_index, int *device_handle)
 static int close_device(int device_handle)
 {
        struct ff_info *info;
-       int r, n;
+       int n;
 
        info = read_from_list(device_handle);
        if (!info)
@@ -371,18 +372,7 @@ static int close_device(int device_handle)
                return -ENODEV;
 
        /* stop vibration */
-       r = ff_stop(ff_fd, &info->effect);
-       if (r < 0)
-               _I("already stopped or failed to stop effect : %d", r);
-
-       /* unregister existing timer */
-       if (r >= 0 && info->timer) {
-               _D("device handle %d is closed and timer deleted", device_handle);
-               g_source_remove(info->timer);
-               info->timer = 0;
-       }
-
-       standard_vibrate_close();
+       stop_device(device_handle);
 
        DD_LIST_REMOVE(handle_list, (gpointer)(long)info->handle);