Initialize current vibration handle and priority when vibration is done 02/200302/2
authorpr.jung <pr.jung@samsung.com>
Thu, 21 Feb 2019 08:47:42 +0000 (17:47 +0900)
committerHyotaek Shim <hyotaek.shim@samsung.com>
Mon, 25 Feb 2019 09:13:56 +0000 (09:13 +0000)
Change-Id: I26221add67c70cab7dc0e09948f03903d6060a4c
Signed-off-by: pr.jung <pr.jung@samsung.com>
src/haptic/haptic.c

index d253225..fa030ea 100644 (file)
@@ -751,6 +751,19 @@ exit:
        return g_variant_new("(i)", ret);
 }
 
+static gboolean _cb(void *data)
+{
+       if (duration_timer) {
+               g_source_remove(duration_timer);
+               duration_timer = 0;
+       }
+
+       cur_h_data.handle = INVALID_HANDLE;
+       cur_h_data.priority = PRIORITY_MIN;
+
+       return G_SOURCE_REMOVE;
+}
+
 static void vibrate_monotone_idler_cb(void *data)
 {
        struct vibrate_monotone_info *vibrate_info;
@@ -767,6 +780,11 @@ static void vibrate_monotone_idler_cb(void *data)
                return;
        }
 
+       if (duration_timer) {
+               g_source_remove(duration_timer);
+               duration_timer = 0;
+       }
+
        cur_h_data.vibration_data = NULL;
        cur_h_data.handle = vibrate_info->handle;
        cur_h_data.level = vibrate_info->level;
@@ -777,6 +795,8 @@ static void vibrate_monotone_idler_cb(void *data)
        ret = device_power_request_lock(POWER_LOCK_CPU, vibrate_info->duration);
        if (ret != DEVICE_ERROR_NONE)
                _E("Failed to request power lock");
+
+       duration_timer = g_timeout_add(vibrate_info->duration, _cb, NULL);
        h_ops->vibrate_monotone(cur_h_data.handle, vibrate_info->duration, cur_h_data.level, cur_h_data.priority);
 
        free(vibrate_info);