From: Jeongmo Yang Date: Fri, 21 Aug 2020 01:25:09 +0000 (+0900) Subject: Update attribute commit function X-Git-Tag: accepted/tizen/6.0/unified/20201030.114356^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F20%2F241920%2F1;p=platform%2Fcore%2Fmultimedia%2Flibmm-common.git Update attribute commit function - Previously, mm_attrs_commit() did not call commit function of each attribute. - In this patch, mm_attrs_commit() will invoke commit function of each attribute if existed, and remove duplicated code. [Version] 0.2.122 [Issue Type] Update Change-Id: Idf21a3750a65375651456256558c6761d969cf75 Signed-off-by: Jeongmo Yang --- diff --git a/include/mm_attrs_private.h b/include/mm_attrs_private.h index e3a81a5..14f257c 100644 --- a/include/mm_attrs_private.h +++ b/include/mm_attrs_private.h @@ -233,7 +233,9 @@ MMHandleType mmf_attrs_new_from_data(const char *name, void mmf_attrs_free(MMHandleType h); -int mmf_attrs_commit(MMHandleType h); +int mmf_attrs_commit(MMHandleType h, int idx, char **err_attr_name); + +int mmf_attrs_commit_all(MMHandleType h); int mmf_attrs_set_valid_type(MMHandleType h, int idx, int v_type); diff --git a/mm_attrs.c b/mm_attrs.c index aba8394..fe149b2 100644 --- a/mm_attrs.c +++ b/mm_attrs.c @@ -54,26 +54,12 @@ void mm_attrs_free(MMHandleType attrs) int mm_attrs_commit_all(MMHandleType attrs) { - return mmf_attrs_commit(attrs); + return mmf_attrs_commit_all(attrs); } int mm_attrs_commit(MMHandleType attrs, int index) { - mmf_attrs_t *h = (mmf_attrs_t *) attrs; - mmf_attribute_t *item; - - return_val_if_fail(attrs, MM_ERROR_COMMON_INVALID_ARGUMENT); - return_val_if_fail(index >= 0, MM_ERROR_COMMON_INVALID_ARGUMENT); - - item = &h->items[index]; - - MM_ATTR_ITEM_WRITE_LOCK(item); - - mmf_attribute_commit(item); - - MM_ATTR_ITEM_WRITE_UNLOCK(item); - - return MM_ERROR_NONE; + return mmf_attrs_commit(attrs, index, NULL); } int mm_attrs_get_type(MMHandleType attrs, int index, MMAttrsType *attrtype) diff --git a/mm_attrs_private.c b/mm_attrs_private.c index 1e2ddd9..ed0c096 100644 --- a/mm_attrs_private.c +++ b/mm_attrs_private.c @@ -663,85 +663,74 @@ int mmf_attrs_init(MMHandleType h, mmf_attrs_construct_info_t *info, int count) return 0; } -int mmf_attrs_commit(MMHandleType h) +int mmf_attrs_commit(MMHandleType h, int idx, char **err_attr_name) { mmf_attrs_t *attrs = (mmf_attrs_t *)h; mmf_attribute_t *item = NULL; - int i; int ret = 0; return_val_if_fail(h, -1); - for (i = 0; i < attrs->count; ++i) { - item = &attrs->items[i]; + item = &attrs->items[idx]; - MM_ATTR_ITEM_WRITE_LOCK(item); - - if (mmf_attribute_is_modified(item)) { - if (attrs->commit_func) { - if (attrs->commit_func(i, item->name, - &item->tmpval, - attrs->commit_param)) { - mmf_attribute_commit(item); - } else { - /* without this, there is no way to solve modify when commit_func failed. */ - if (item->flags & MM_ATTRS_FLAG_MODIFIED) - item->flags ^= MM_ATTRS_FLAG_MODIFIED; - ret = -1; - } - } else { + MM_ATTR_ITEM_WRITE_LOCK(item); + + if (mmf_attribute_is_modified(item)) { + if (attrs->commit_func) { + if (attrs->commit_func(idx, + item->name, + &item->tmpval, + attrs->commit_param)) { mmf_attribute_commit(item); + } else { + /* without this, there is no way to solve modify when commit_func failed. */ + if (item->flags & MM_ATTRS_FLAG_MODIFIED) + item->flags ^= MM_ATTRS_FLAG_MODIFIED; + ret = -1; + + /* Set Error information */ + if (err_attr_name) + *err_attr_name = strdup(item->name); } + } else { + mmf_attribute_commit(item); } - - MM_ATTR_ITEM_WRITE_UNLOCK(item); } + MM_ATTR_ITEM_WRITE_UNLOCK(item); + return ret; } -int mmf_attrs_commit_err(MMHandleType h, char **err_attr_name) +int mmf_attrs_commit_all(MMHandleType h) { mmf_attrs_t *attrs = (mmf_attrs_t *)h; - mmf_attribute_t *item = NULL; int i; int ret = 0; return_val_if_fail(h, -1); for (i = 0; i < attrs->count; ++i) { - item = &attrs->items[i]; + if (mmf_attrs_commit(h, i, NULL) != 0) + ret = -1; + } - MM_ATTR_ITEM_WRITE_LOCK(item); - - if (mmf_attribute_is_modified(item)) { - if (attrs->commit_func) { - if (attrs->commit_func(i, item->name, - &item->tmpval, - attrs->commit_param)) { - mmf_attribute_commit(item); - } else { - /* without this, there is no way to solve modify when commit_func failed. */ - if (item->flags & MM_ATTRS_FLAG_MODIFIED) - item->flags ^= MM_ATTRS_FLAG_MODIFIED; - ret = -1; - - /* Set Error information */ - if (err_attr_name) - *err_attr_name = strdup(item->name); - - MM_ATTR_ITEM_WRITE_UNLOCK(item); - break; - } - } else { - mmf_attribute_commit(item); - } - } + return ret; +} + +int mmf_attrs_commit_err(MMHandleType h, char **err_attr_name) +{ + mmf_attrs_t *attrs = (mmf_attrs_t *)h; + int i; + + return_val_if_fail(h, -1); - MM_ATTR_ITEM_WRITE_UNLOCK(item); + for (i = 0; i < attrs->count; ++i) { + if (mmf_attrs_commit(h, i, err_attr_name) != 0) + return -1; } - return ret; + return 0; } int mmf_attrs_set_valid_type(MMHandleType h, int idx, int v_type) diff --git a/packaging/libmm-common.spec b/packaging/libmm-common.spec index a186e4e..33d2ef4 100644 --- a/packaging/libmm-common.spec +++ b/packaging/libmm-common.spec @@ -1,7 +1,7 @@ Name: libmm-common Summary: Multimedia Framework Common Lib -Version: 0.2.121 -Release: 1 +Version: 0.2.122 +Release: 0 Group: Multimedia/Libraries License: Apache-2.0 Source0: %{name}-%{version}.tar.gz