#include <stdbool.h>
#include <mm_types.h>
#include <mm_attrs.h>
+#include <pthread.h>
#ifdef __cplusplus
extern "C" {
(t) == MMF_VALUE_SPEC_DOUBLE_ARRAY || \
(t) == MMF_VALUE_SPEC_DOUBLE_RANGE)
+#define MM_ATTRS_WRITE_LOCK(attrs) do { pthread_mutex_lock(&attrs->write_lock); } while (0)
+#define MM_ATTRS_WRITE_UNLOCK(attrs) do { pthread_mutex_unlock(&attrs->write_lock); } while (0)
+
enum mmf_value_type {
MMF_VALUE_TYPE_INT = MM_ATTRS_TYPE_INT,
MMF_VALUE_TYPE_DOUBLE=MM_ATTRS_TYPE_DOUBLE,
mmf_attribute_t *items;
mmf_attrs_commit_func_t commit_func;
void *commit_param;
+ pthread_mutex_t write_lock;
};
struct mmf_attrs_list {
*/
-
+
#ifndef __MM_ERROR_H__
#define __MM_ERROR_H__
#define MM_ERROR_PLAYER_DRM_EXPIRED (MM_ERROR_PLAYER_CLASS | 0x1a) /**< Expired license */
#define MM_ERROR_PLAYER_DRM_FUTURE_USE (MM_ERROR_PLAYER_CLASS | 0x1b) /**< License for future use */
#define MM_ERROR_PLAYER_DRM_NOT_AUTHORIZED (MM_ERROR_PLAYER_CLASS | 0x1c) /**< Not authorized */
+#define MM_ERROR_PLAYER_DRM_OUTPUT_PROTECTION (MM_ERROR_PLAYER_CLASS | 0x1d) /**< Output protected */
#define MM_ERROR_PLAYER_STREAMING_UNSUPPORTED_AUDIO (MM_ERROR_PLAYER_CLASS | 0x22) /**< Unsupported audio */
#define MM_ERROR_PLAYER_STREAMING_UNSUPPORTED_VIDEO (MM_ERROR_PLAYER_CLASS | 0x23) /**< Unsupported video */
return_val_if_fail(item, MM_ERROR_COMMON_INVALID_ARGUMENT);
+ MM_ATTRS_WRITE_LOCK(attrs);
if (mmf_attribute_check_flags(item, MM_ATTRS_FLAG_WRITABLE))
{
int ret = 0;
ret = mmf_attribute_set_string(item, string, size);
+ MM_ATTRS_WRITE_UNLOCK(attrs);
+
if (ret == 0)
return MM_ERROR_NONE;
else
return MM_ERROR_COMMON_INVALID_ARGUMENT;
}
+ MM_ATTRS_WRITE_UNLOCK(attrs);
+
return MM_ERROR_COMMON_INVALID_PERMISSION;
}
mmf_attrs_t *attrs = (mmf_attrs_t *) h;
return_val_if_fail(attrs && idx >= 0 && idx < attrs->count && sval, MM_ERROR_COMMON_INVALID_ARGUMENT);
+ MM_ATTRS_WRITE_LOCK(attrs);
+
if (!(attrs->items[idx].flags & MM_ATTRS_FLAG_READABLE)) {
mmf_debug(MMF_DEBUG_LOG, "Access denied.\n");
+ MM_ATTRS_WRITE_UNLOCK(attrs);
return MM_ERROR_COMMON_INVALID_PERMISSION;
}
*sval = mmf_value_get_string(&attrs->items[idx].value,size);
+
+ MM_ATTRS_WRITE_UNLOCK(attrs);
+
return MM_ERROR_NONE;
}
attrs->count = count;
attrs->items = (mmf_attribute_t *) malloc (sizeof(mmf_attribute_t) * count);
memset(attrs->items, 0, sizeof(mmf_attribute_t) * count);
+
+ if (pthread_mutex_init(&attrs->write_lock, NULL) != 0) {
+ mmf_debug(MMF_DEBUG_ERROR, "mutex init failed");
+ return 0;
+ }
+
return (MMHandleType) attrs;
}
free(attrs->items);
attrs->items = NULL;
}
+ pthread_mutex_destroy(&attrs->write_lock);
free(attrs);
}
}
int i;
int ret = 0;
+ MM_ATTRS_WRITE_LOCK(attrs);
+
for (i = 0; i < attrs->count; ++i) {
if (mmf_attribute_is_modified(&attrs->items[i])) {
if (attrs->commit_func) {
}
}
}
+
+ MM_ATTRS_WRITE_UNLOCK(attrs);
+
return ret;
}
return_val_if_fail(h, -1);
+ MM_ATTRS_WRITE_LOCK(attrs);
+
for (i = 0; i < attrs->count; ++i) {
if (mmf_attribute_is_modified(&attrs->items[i])) {
if (attrs->commit_func) {
}
}
}
+
+ MM_ATTRS_WRITE_UNLOCK(attrs);
+
return ret;
}
Name: libmm-common
Summary: Multimedia Framework Common Lib
Version: 0.2.53
-Release: 1
+Release: 2
Group: TO_BE/FILLED_IN
License: Apache-2.0
Source0: %{name}-%{version}.tar.gz