return FEEDBACK_ERROR_NONE;
}
+static feedback_pattern_e check_pattern(feedback_type_e type, feedback_pattern_e pattern, const char *func)
+{
+ feedback_pattern_e switched = pattern;
+ bool result = false;
+
+ if (type < FEEDBACK_TYPE_NONE || type >= FEEDBACK_TYPE_END)
+ type = FEEDBACK_TYPE_NONE;
+
+ /* if you need to switch pattern */
+ if (profile->get_switched_pattern)
+ result = profile->get_switched_pattern(pattern, &switched);
+
+ if (pattern != switched && result)
+ _W("pattern is changed : %s %s(%d) -> %s(%d) by %s", //LCOV_EXCL_LINE
+ profile->str_type[type],
+ profile->str_pattern(pattern), pattern , profile->str_pattern(switched), switched, func);
+ else
+ _W("pattern is : %s %s(%d) by %s", //LCOV_EXCL_LINE
+ profile->str_type[type],
+ profile->str_pattern(pattern), pattern, func);
+ return switched;
+}
+
API int feedback_play(feedback_pattern_e pattern)
{
int err;
- bool result;
- int switched;
/* check initialize */
pthread_mutex_lock(&fmutex);
return FEEDBACK_ERROR_INVALID_PARAMETER;
}
- /* if you need to switch pattern */
- if (profile->get_switched_pattern) {
- result = profile->get_switched_pattern(pattern, &switched);
- if (result) {
- _W("pattern is changed : (%s) -> (%s)", //LCOV_EXCL_LINE
- profile->str_pattern(pattern), profile->str_pattern(switched));
- pattern = switched;
- }
- }
-
+ _D("request all type with pattern %s(%d)", profile->str_pattern(pattern), pattern);
/* play all device */
- err = devices_play(pattern);
+ err = devices_play(check_pattern(FEEDBACK_TYPE_NONE, pattern, __func__), false);
/**
* devices_play() returns error even if all devices are failed.
* It means if to play anything is successful,
{
const struct device_ops *dev;
int err;
- bool result;
- int switched;
/* check initialize */
pthread_mutex_lock(&fmutex);
return FEEDBACK_ERROR_INVALID_PARAMETER;
}
- /* if you need to switch pattern */
- if (profile->get_switched_pattern) {
- result = profile->get_switched_pattern(pattern, &switched);
- if (result) {
- _W("pattern is changed : (%s) -> (%s)", //LCOV_EXCL_LINE
- profile->str_pattern(pattern), profile->str_pattern(switched));
- pattern = switched;
- }
- }
-
/* play proper device */
dev = find_device(type);
if (!dev) {
return FEEDBACK_ERROR_NOT_SUPPORTED;
}
- err = dev->play(pattern);
+ err = dev->play(check_pattern(type, pattern, __func__), false);
if (err == -ENOTSUP)
return FEEDBACK_ERROR_NOT_SUPPORTED;
else if (err == -ECOMM || err == -EACCES)
const struct device_ops *dev;
bool supported;
int err;
- bool result;
- int switched;
/* check initialize */
pthread_mutex_lock(&fmutex);
return FEEDBACK_ERROR_INVALID_PARAMETER;
}
- /* if you need to switch pattern */
- if (profile->get_switched_pattern) {
- result = profile->get_switched_pattern(pattern, &switched);
- if (result) {
- _W("pattern is changed : (%s) -> (%s)", //LCOV_EXCL_LINE
- profile->str_pattern(pattern), profile->str_pattern(switched));
- pattern = switched;
- }
- }
-
/* play proper device */
dev = find_device(type);
if (!dev) {
return FEEDBACK_ERROR_NOT_SUPPORTED;
}
- err = dev->is_supported(pattern, &supported);
+ err = dev->is_supported(check_pattern(type, pattern, __func__), &supported);
if (err == -ENOTSUP)
return FEEDBACK_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE System Error
else if (err == -ECOMM || err == -EACCES)
API int feedback_play_internal(feedback_pattern_internal_e pattern)
{
int err;
- bool result;
- int switched;
/* check initialize */
pthread_mutex_lock(&fmutex);
return FEEDBACK_ERROR_INVALID_PARAMETER;
}
- /* if you need to switch pattern */
- if (profile->get_switched_pattern) {
- result = profile->get_switched_pattern(pattern, &switched);
- if (result) {
- _W("pattern is changed : (%s) -> (%s)", //LCOV_EXCL_LINE
- profile->str_pattern(pattern), profile->str_pattern(switched));
- pattern = switched;
- }
- }
-
+ _D("request all type with pattern %s(%d)", profile->str_pattern(pattern), pattern);
/* play all device */
- err = devices_play(pattern);
+ err = devices_play(check_pattern(FEEDBACK_TYPE_NONE, pattern, __func__), true);
/**
* devices_play() returns error even if all devices are failed.
* It means if to play anything is successful,
{
const struct device_ops *dev;
int err;
- bool result;
- int switched;
/* check initialize */
pthread_mutex_lock(&fmutex);
return FEEDBACK_ERROR_INVALID_PARAMETER;
}
- /* if you need to switch pattern */
- if (profile->get_switched_pattern) {
- result = profile->get_switched_pattern(pattern, &switched);
- if (result) {
- _W("pattern is changed : (%s) -> (%s)", //LCOV_EXCL_LINE
- profile->str_pattern(pattern), profile->str_pattern(switched));
- pattern = switched;
- }
+ /* play proper device */
+ dev = find_device(type);
+ if (!dev) {
+ _E("Not supported device : type(%s)", profile->str_type[type]); //LCOV_EXCL_LINE
+ return FEEDBACK_ERROR_NOT_SUPPORTED;
+ }
+ _D("request type %s with pattern %s(%d)", profile->str_type[type], profile->str_pattern(pattern), pattern);
+ err = dev->play(check_pattern(type, pattern, __func__), true);
+ if (err == -ENOTSUP)
+ return FEEDBACK_ERROR_NOT_SUPPORTED;
+ else if (err == -ECOMM || err == -EACCES)
+ return FEEDBACK_ERROR_PERMISSION_DENIED;
+ else if (err < 0)
+ return FEEDBACK_ERROR_OPERATION_FAILED;
+
+ return FEEDBACK_ERROR_NONE;
+}
+
+API int feedback_play_soundpath_internal(feedback_pattern_internal_e internal_pattern, const char *soundpath)
+{
+ int err;
+ feedback_pattern_e pattern = (feedback_pattern_e)internal_pattern;
+
+ /* check initialize */
+ pthread_mutex_lock(&fmutex);
+ if (!init_cnt) {
+ _E("Not initialized"); //LCOV_EXCL_LINE
+ pthread_mutex_unlock(&fmutex);
+ return FEEDBACK_ERROR_NOT_INITIALIZED;
+ }
+ pthread_mutex_unlock(&fmutex);
+
+ if (pattern <= FEEDBACK_PATTERN_NONE ||
+ pattern >= profile->max_pattern) {
+ _E("Invalid parameter : pattern(%d)", pattern);
+ return FEEDBACK_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!soundpath) {
+ _E("Invalid parameter : pattern path(NULL)");
+ return FEEDBACK_ERROR_INVALID_PARAMETER;
+ }
+
+ _D("request all type with pattern %s(%d), soundpath %s", profile->str_pattern(pattern), pattern, soundpath);
+ /* play all device */
+ err = devices_play_soundpath(check_pattern(FEEDBACK_TYPE_NONE, pattern, __func__), soundpath, true);
+ /**
+ * devices_play() returns error even if all devices are failed.
+ * It means if to play anything is successful,
+ * this function regards as success.
+ */
+ if (err == -ENOTSUP)
+ return FEEDBACK_ERROR_NOT_SUPPORTED;
+ else if (err < 0)
+ return FEEDBACK_ERROR_OPERATION_FAILED;
+
+ return FEEDBACK_ERROR_NONE;
+}
+
+API int feedback_play_type_soundpath_internal(feedback_type_e type, feedback_pattern_internal_e internal_pattern, const char *soundpath)
+{
+ const struct device_ops *dev;
+ int err;
+ feedback_pattern_e pattern = (feedback_pattern_e)internal_pattern;
+
+ /* check initialize */
+ pthread_mutex_lock(&fmutex);
+ if (!init_cnt) {
+ _E("Not initialized"); //LCOV_EXCL_LINE
+ pthread_mutex_unlock(&fmutex);
+ return FEEDBACK_ERROR_NOT_INITIALIZED;
+ }
+ pthread_mutex_unlock(&fmutex);
+
+ if (type <= FEEDBACK_TYPE_NONE ||
+ type >= profile->max_type) {
+ _E("Invalid parameter : type(%d)", type);
+ return FEEDBACK_ERROR_INVALID_PARAMETER;
+ }
+
+ if (pattern <= FEEDBACK_PATTERN_NONE ||
+ pattern >= profile->max_pattern) {
+ _E("Invalid parameter : pattern(%d)", pattern);
+ return FEEDBACK_ERROR_INVALID_PARAMETER;
+ }
+
+ if ((type == FEEDBACK_TYPE_SOUND) && (soundpath == NULL)) {
+ _E("Invalid parameter : sound path(NULL)");
+ return FEEDBACK_ERROR_INVALID_PARAMETER;
}
/* play proper device */
_E("Not supported device : type(%s)", profile->str_type[type]); //LCOV_EXCL_LINE
return FEEDBACK_ERROR_NOT_SUPPORTED;
}
+ _D("request type %s with pattern(%s), soundpath(%s)", profile->str_type[type], profile->str_pattern(pattern), soundpath?soundpath:"NULL");
+ if (type == FEEDBACK_TYPE_SOUND) {
+ if (dev->play_path)
+ err = dev->play_path(check_pattern(type, pattern, __func__), soundpath, true);
+ else
+ err = -ENOTSUP; //LCOV_EXCL_LINE
+ } else {
+ if (dev->play)
+ err = dev->play(check_pattern(type, pattern, __func__), true);
+ else
+ err = -ENOTSUP; //LCOV_EXCL_LINE
+ }
- err = dev->play(pattern);
if (err == -ENOTSUP)
return FEEDBACK_ERROR_NOT_SUPPORTED;
else if (err == -ECOMM || err == -EACCES)