ret = -EINVAL;
goto exit;
}
+ if (priority < PRIORITY_MIN)
+ priority = PRIORITY_MIN;
+ else if (priority > PRIORITY_TOP)
+ priority = PRIORITY_TOP;
ret = h_ops->vibrate_monotone(handle, duration, level, priority, &e_handle);
if (ret >= 0)
ret = -EINVAL;
goto exit;
}
+ if (priority < PRIORITY_MIN)
+ priority = PRIORITY_MIN;
+ else if (priority > PRIORITY_TOP)
+ priority = PRIORITY_TOP;
vibrate_info = calloc(1, sizeof(struct vibrate_effect_info));
if (!vibrate_info) {
vconf_notify_key_changed(VCONFKEY_RECORDER_STATE, sound_capturing_cb, NULL);
/* Initialize vibration_handle (Use vibration now) */
- vibration_handle = INVALID_HANDLE;
+ cur_h_data.handle = INVALID_HANDLE;
+ cur_h_data.priority = PRIORITY_MIN;
}
void haptic_exit(void)
int wait;
};
-struct haptic_data {
- dd_list *vibration_data;
- unsigned int handle;
- int level;
- int priority;
- bool stop;
-};
-
static dd_list *vib_conf_list;
static Ecore_Timer *duration_timer;
static t_vibrate_monotone real_vibrate_monotone;
+struct haptic_data cur_h_data;
+
static int vibration_load_config(struct parse_result *result, void *user_data)
{
struct vibration_config *conf;
}
if (!data) {
- vibration_handle = INVALID_HANDLE;
+ cur_h_data.handle = INVALID_HANDLE;
+ cur_h_data.priority = PRIORITY_MIN;
goto out;
}
h_data = (struct haptic_data *)data;
if (h_data->stop) {
h_data->stop = false;
- free(h_data);
+ cur_h_data.handle = INVALID_HANDLE;
+ cur_h_data.priority = PRIORITY_MIN;
goto out;
}
DD_LIST_FOREACH_SAFE(head, n, next, node) {
_D("Play: %dms and Wait: %dms", node->duration, node->wait);
if (!node->duration) {
- free(h_data);
+ cur_h_data.handle = INVALID_HANDLE;
+ cur_h_data.priority = PRIORITY_MIN;
break;
}
ret = real_vibrate_monotone(h_data->handle, node->duration, h_data->level, h_data->priority, NULL);
if (!next) {
- free(h_data);
goto out;
}
break;
{
dd_list *elem;
struct vibration_config *conf;
- struct haptic_data *data;
size_t len;
if (device_handle < 0)
return -EINVAL;
+ /* Same or higher priority pattern should be played */
+ if (priority < cur_h_data.priority) {
+ _E("Priority of new request is lower than old request");
+ return -EPERM;
+ }
+
len = strlen(pattern) + 1;
DD_LIST_FOREACH(vib_conf_list, elem, conf) {
if (!conf->pattern)
if (strncmp(conf->pattern, pattern, len))
continue;
- data = (struct haptic_data *)malloc(sizeof(struct haptic_data));
- if (!data) {
- _E("fail to alloc");
- return -ENOMEM;
- }
- data->vibration_data = conf->data;
- data->handle = device_handle;
- data->level = feedback;
- data->priority = priority;
- data->stop = false;
- vibration_handle = device_handle;
+ 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);
- haptic_duration_play((void *)data);
+ haptic_duration_play((void *)&cur_h_data);
break;
}
int standard_vibrate_close()
{
- vibration_handle = INVALID_HANDLE;
+ cur_h_data.handle = INVALID_HANDLE;
+ cur_h_data.priority = PRIORITY_MIN;
if (duration_timer) {
_I("Remove duration_timer");