From: pr.jung Date: Tue, 8 Jan 2019 09:54:36 +0000 (+0900) Subject: Add unlimit operation X-Git-Tag: accepted/tizen/unified/20190130.151732~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=02b9cb54b69adba2204951a67378867b954f3e29;p=platform%2Fcore%2Fsystem%2Ffeedbackd.git Add unlimit operation - Repeats vibration pattern when requested pattern is defined as an unlimit pattern Change-Id: I3eefc7eb73a386987b54d6bbf79848f9c7c66daf Signed-off-by: pr.jung --- diff --git a/src/haptic/standard-vibcore.c b/src/haptic/standard-vibcore.c index 358942b..92bed2f 100644 --- a/src/haptic/standard-vibcore.c +++ b/src/haptic/standard-vibcore.c @@ -421,7 +421,6 @@ int standard_is_supported(const char *pattern) static gboolean haptic_duration_play(void *data) { dd_list *head, *n, *next; - struct haptic_data *h_data; struct duration_data *node; int ret = 0; @@ -431,44 +430,49 @@ static gboolean haptic_duration_play(void *data) } if (!data) { - cur_h_data.handle = INVALID_HANDLE; - cur_h_data.priority = PRIORITY_MIN; - goto out; - } + if (cur_h_data.unlimit) /* In case of unlimit pattern, do not stop */ + head = cur_h_data.vibration_data; + else { + cur_h_data.handle = INVALID_HANDLE; + cur_h_data.priority = PRIORITY_MIN; + goto out; + } + } else + head = (dd_list *)data; - h_data = (struct haptic_data *)data; - if (h_data->stop) { - h_data->stop = false; + if (cur_h_data.stop) { + _I("Stop currunt vibration"); + cur_h_data.stop = false; cur_h_data.handle = INVALID_HANDLE; cur_h_data.priority = PRIORITY_MIN; goto out; } - head = h_data->vibration_data; DD_LIST_FOREACH_SAFE(head, n, next, node) { - _D("Play: %dms and Wait: %dms", node->duration, node->wait); - if (!node->duration) { - cur_h_data.handle = INVALID_HANDLE; - cur_h_data.priority = PRIORITY_MIN; - break; + _D("Handle %d play: %dms and Wait: %dms (with f:%d o:%d) %s type", + cur_h_data.handle, node->duration, node->wait, + node->frequency, node->overdriving, + cur_h_data.unlimit ? "Unlimit" : "Once"); + if ((node->duration + node->wait) <= 0) { + if (!cur_h_data.unlimit) { + cur_h_data.handle = INVALID_HANDLE; + cur_h_data.priority = PRIORITY_MIN; + break; + } else { + next = cur_h_data.vibration_data; + continue; + } } - if (next) { - h_data->vibration_data = next; - duration_timer = g_timeout_add((node->duration + node->wait), haptic_duration_play, (void *)h_data); - } else - duration_timer = g_timeout_add((node->duration + node->wait), haptic_duration_play, NULL); + duration_timer = g_timeout_add((node->duration + node->wait), haptic_duration_play, (void *)next); - ret = real_vibrate_monotone(h_data->handle, node->duration, h_data->level, h_data->priority, NULL); - if (!next) - goto out; + ret = real_vibrate_monotone(cur_h_data.handle, node->duration, cur_h_data.level, cur_h_data.priority, NULL); break; } if (ret != 0) { _D("auto stop vibration"); - if (h_data) - h_data->stop = true; + cur_h_data.stop = true; } out: return G_SOURCE_REMOVE; @@ -487,8 +491,9 @@ int standard_vibrate_effect(int device_handle, const char *requested_pattern, in size_t len; char pattern[PATH_MAX]; int ret; + int unlimit = 0; - if (device_handle < 0) + if (device_handle < 0 || !requested_pattern) return -EINVAL; /* Same or higher priority pattern should be played */ @@ -505,27 +510,36 @@ int standard_vibrate_effect(int device_handle, const char *requested_pattern, in if (strncmp(conf->pattern, pattern, len)) continue; if (conf->standard) { + unlimit = conf->unlimit; snprintf(pattern, sizeof(pattern), "%s", conf->standard); len = strlen(pattern) + 1; continue; } + if (unlimit) + cur_h_data.unlimit = unlimit; + else + cur_h_data.unlimit = conf->unlimit; cur_h_data.vibration_data = conf->data; cur_h_data.handle = device_handle; cur_h_data.level = feedback; cur_h_data.priority = priority; cur_h_data.stop = false; - _D("Play %s", conf->pattern); + _I("Handle %d play %s pri %d %s", cur_h_data.handle, conf->pattern, cur_h_data.priority, + cur_h_data.unlimit ? "Unlimit" : "Once"); if (conf->pattern_duration <= 0) break; - ret = device_power_request_lock(POWER_LOCK_CPU, conf->pattern_duration); - if (ret != DEVICE_ERROR_NONE) - _E("Failed to request power lock"); - haptic_duration_play((void *)&cur_h_data); - break; + if (!cur_h_data.unlimit && conf->pattern_duration > 0) { + ret = device_power_request_lock(POWER_LOCK_CPU, conf->pattern_duration); + if (ret != DEVICE_ERROR_NONE) + _E("Failed to request power lock"); + } + haptic_duration_play((void *)cur_h_data.vibration_data); + return 0; } + _E("Handld %d %s is not supported", device_handle, pattern); return 0; }