media_editor: Replace some duplicated code with macro 20/277720/7 accepted/tizen_7.0_unified accepted/tizen_7.0_unified_hotfix tizen_7.0 tizen_7.0_hotfix accepted/tizen/7.0/unified/20221110.061711 accepted/tizen/7.0/unified/hotfix/20221116.104722 accepted/tizen/unified/20220718.140429 submit/fix_dc/20220714.060533 submit/tizen/20220714.060807 tizen_7.0_m2_release
authorheechul.jeon <heechul.jeon@samsung.com>
Tue, 12 Jul 2022 08:08:23 +0000 (17:08 +0900)
committerheechul.jeon <heechul.jeon@samsung.com>
Thu, 14 Jul 2022 05:38:25 +0000 (14:38 +0900)
[Version] 0.0.16
[Issue Type] Code cleanup

Change-Id: Idc7cddc9870a6c3a4968b400b3a26de0a6110650
Signed-off-by: heechul.jeon <heechul.jeon@samsung.com>
include/media_editor_private.h
packaging/capi-media-editor.spec
src/media_editor.c
src/media_editor_clip.c
src/media_editor_display.c
src/media_editor_effect.c
src/media_editor_ini.c
src/media_editor_layer.c
src/media_editor_private.c
src/media_editor_project.c
src/media_editor_resource.c

index 0481f7cbe8beaf9de1c0fb131cc28fc4be0ace23..cb6f66e80a7855574623026ce24efee8b9330f11 100644 (file)
@@ -86,6 +86,14 @@ do { \
         LOG_WARNING("previous callback[%p] user_data[%p]", x_callback.callback, x_callback.user_data); \
 } while (0)
 
+#define NULL_PARAM_CHECK(ptr) \
+do { \
+    if (!(ptr)) { \
+        LOG_ERROR("%s is NULL", #ptr); \
+        return MEDIAEDITOR_ERROR_INVALID_PARAMETER; \
+    } \
+} while (0)
+
 #define RET_IF(expr, fmt, arg...) \
 do { \
     if ((expr)) { \
@@ -181,6 +189,8 @@ do { \
 #define MEDIAEDITOR_CLIP(x) (((mediaeditor_clip_s *)((x)->data))->clip)
 #define MEDIAEDITOR_GROUP(x) (((mediaeditor_group_s *)((x)->data))->group)
 
+#define AUTOCLEAN_LOCKER(x) g_autoptr(GMutexLocker) locker = g_mutex_locker_new(x);
+
 #ifndef TIZEN_TV
 #define RESOURCE_TYPE_MAX MM_RESOURCE_MANAGER_RES_TYPE_VIDEO_ENCODER + 1
 
index 5638bf525eb6c6755474c2ea452dc6f26dee00e5..b7965854efbcda49c89b8fd435eeb7267a95b376 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-editor
 Summary:    A Tizen Media Editor API
-Version:    0.0.15
+Version:    0.0.16
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index fb0f47289e1824c5621ba2f6153c9d49ffe3235f..7324cb1333f3abc891f6aaad7ca1e56a4eb85b75 100644 (file)
@@ -27,14 +27,13 @@ int mediaeditor_create(mediaeditor_h *editor)
 {
     int ret = MEDIAEDITOR_ERROR_NONE;
     mediaeditor_s *_editor = NULL;
-    g_autoptr(GMutexLocker) locker = NULL;
 
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(editor);
 
     _editor = g_new0(mediaeditor_s, 1);
 
     g_mutex_init(&_editor->mutex);
-    locker = g_mutex_locker_new(&_editor->mutex);
+    AUTOCLEAN_LOCKER(&_editor->mutex);
 
     g_mutex_init(&_editor->event_src_mutex);
     g_cond_init(&_editor->cond);
@@ -78,12 +77,11 @@ error:
 int mediaeditor_destroy(mediaeditor_h editor)
 {
     int ret = MEDIAEDITOR_ERROR_NONE;
-    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
-    RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(_editor);
 
-    locker = g_mutex_locker_new(&_editor->mutex);
+    AUTOCLEAN_LOCKER(&_editor->mutex);
 
     _remove_remained_event_sources(_editor);
 
@@ -121,16 +119,16 @@ int mediaeditor_destroy(mediaeditor_h editor)
 
 int mediaeditor_set_display(mediaeditor_h editor, mediaeditor_display_type_e type, mediaeditor_display_h display)
 {
-    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
     RET_ERR_IF_FEATURE_IS_NOT_SUPPORTED(_MEDIAEDITOR_FEATURE_DISPLAY);
-    RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
-    RET_VAL_IF(display == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "display is NULL");
+    NULL_PARAM_CHECK(_editor);
+    NULL_PARAM_CHECK(display);
+
     RET_VAL_IF(type < MEDIAEDITOR_DISPLAY_TYPE_OVERLAY || type > MEDIAEDITOR_DISPLAY_TYPE_NONE,
         MEDIAEDITOR_ERROR_INVALID_PARAMETER, "invalid display type");
 
-    locker = g_mutex_locker_new(&_editor->mutex);
+    AUTOCLEAN_LOCKER(&_editor->mutex);
 
     LOG_DEBUG("editor[%p], type[%d], display[%p]", editor, type, display);
 
@@ -142,13 +140,12 @@ int mediaeditor_set_display(mediaeditor_h editor, mediaeditor_display_type_e typ
 
 int mediaeditor_get_state(mediaeditor_h editor, mediaeditor_state_e *state)
 {
-    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
-    RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
-    RET_VAL_IF(state == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "state is NULL");
+    NULL_PARAM_CHECK(_editor);
+    NULL_PARAM_CHECK(state);
 
-    locker = g_mutex_locker_new(&_editor->mutex);
+    AUTOCLEAN_LOCKER(&_editor->mutex);
 
     *state = _editor->state;
 
@@ -160,16 +157,15 @@ int mediaeditor_get_state(mediaeditor_h editor, mediaeditor_state_e *state)
 int mediaeditor_start_render(mediaeditor_h editor, const char* path, mediaeditor_render_completed_cb callback, void *user_data)
 {
     int ret = MEDIAEDITOR_ERROR_NONE;
-    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
-    RET_VAL_IF(path == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "path is NULL");
+    NULL_PARAM_CHECK(_editor);
+    NULL_PARAM_CHECK(path);
+    NULL_PARAM_CHECK(callback);
     ret = _check_privilege(path, false, R_OK | W_OK);
     RET_VAL_IF(ret != MEDIAEDITOR_ERROR_NONE, ret, "failed to check privilege");
-    RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
-    RET_VAL_IF(callback == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "callback is NULL");
 
-    locker = g_mutex_locker_new(&_editor->mutex);
+    AUTOCLEAN_LOCKER(&_editor->mutex);
 
     RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
         "the state should be IDLE");
@@ -182,12 +178,11 @@ int mediaeditor_start_render(mediaeditor_h editor, const char* path, mediaeditor
 
 int mediaeditor_cancel_render(mediaeditor_h editor)
 {
-    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
-    RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(_editor);
 
-    locker = g_mutex_locker_new(&_editor->mutex);
+    AUTOCLEAN_LOCKER(&_editor->mutex);
 
     RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_RENDERING, MEDIAEDITOR_ERROR_INVALID_STATE,
         "the state should be RENDERING");
@@ -197,13 +192,12 @@ int mediaeditor_cancel_render(mediaeditor_h editor)
 
 int mediaeditor_start_preview(mediaeditor_h editor)
 {
-    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
     RET_ERR_IF_FEATURE_IS_NOT_SUPPORTED(_MEDIAEDITOR_FEATURE_DISPLAY);
-    RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(_editor);
 
-    locker = g_mutex_locker_new(&_editor->mutex);
+    AUTOCLEAN_LOCKER(&_editor->mutex);
 
     RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
         "the state should be IDLE");
@@ -213,13 +207,12 @@ int mediaeditor_start_preview(mediaeditor_h editor)
 
 int mediaeditor_stop_preview(mediaeditor_h editor)
 {
-    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
     RET_ERR_IF_FEATURE_IS_NOT_SUPPORTED(_MEDIAEDITOR_FEATURE_DISPLAY);
-    RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(_editor);
 
-    locker = g_mutex_locker_new(&_editor->mutex);
+    AUTOCLEAN_LOCKER(&_editor->mutex);
 
     RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_PREVIEW, MEDIAEDITOR_ERROR_INVALID_STATE,
         "the state should be PREVIEW");
@@ -229,14 +222,13 @@ int mediaeditor_stop_preview(mediaeditor_h editor)
 
 int mediaeditor_add_layer(mediaeditor_h editor, unsigned int *layer_id, unsigned int *layer_priority)
 {
-    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
-    RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
-    RET_VAL_IF(layer_id == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "layer_id is NULL");
-    RET_VAL_IF(layer_priority == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "layer_priority is NULL");
+    NULL_PARAM_CHECK(_editor);
+    NULL_PARAM_CHECK(layer_id);
+    NULL_PARAM_CHECK(layer_priority);
 
-    locker = g_mutex_locker_new(&_editor->mutex);
+    AUTOCLEAN_LOCKER(&_editor->mutex);
 
     RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
         "the state should be IDLE");
@@ -246,12 +238,11 @@ int mediaeditor_add_layer(mediaeditor_h editor, unsigned int *layer_id, unsigned
 
 int mediaeditor_remove_layer(mediaeditor_h editor, unsigned int layer_id)
 {
-    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
-    RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(_editor);
 
-    locker = g_mutex_locker_new(&_editor->mutex);
+    AUTOCLEAN_LOCKER(&_editor->mutex);
 
     RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
         "the state should be IDLE");
@@ -261,12 +252,11 @@ int mediaeditor_remove_layer(mediaeditor_h editor, unsigned int layer_id)
 
 int mediaeditor_move_layer(mediaeditor_h editor, unsigned int layer_id, unsigned int layer_priority)
 {
-    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
-    RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(_editor);
 
-    locker = g_mutex_locker_new(&_editor->mutex);
+    AUTOCLEAN_LOCKER(&_editor->mutex);
 
     RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
         "the state should be IDLE");
@@ -276,12 +266,11 @@ int mediaeditor_move_layer(mediaeditor_h editor, unsigned int layer_id, unsigned
 
 int mediaeditor_activate_layer(mediaeditor_h editor, unsigned int layer_id)
 {
-    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
-    RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(_editor);
 
-    locker = g_mutex_locker_new(&_editor->mutex);
+    AUTOCLEAN_LOCKER(&_editor->mutex);
 
     RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
         "the state should be IDLE");
@@ -291,12 +280,11 @@ int mediaeditor_activate_layer(mediaeditor_h editor, unsigned int layer_id)
 
 int mediaeditor_deactivate_layer(mediaeditor_h editor, unsigned int layer_id)
 {
-    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
-    RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(_editor);
 
-    locker = g_mutex_locker_new(&_editor->mutex);
+    AUTOCLEAN_LOCKER(&_editor->mutex);
 
     RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
         "the state should be IDLE");
@@ -307,13 +295,12 @@ int mediaeditor_deactivate_layer(mediaeditor_h editor, unsigned int layer_id)
 int mediaeditor_get_layer_priority(mediaeditor_h editor, unsigned int layer_id, unsigned int *layer_priority)
 {
     int ret = MEDIAEDITOR_ERROR_NONE;
-    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
-    RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
-    RET_VAL_IF(layer_priority == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "layer_priority is NULL");
+    NULL_PARAM_CHECK(_editor);
+    NULL_PARAM_CHECK(layer_priority);
 
-    locker = g_mutex_locker_new(&_editor->mutex);
+    AUTOCLEAN_LOCKER(&_editor->mutex);
 
     ret = _mediaeditor_get_layer_priority(_editor, layer_id, layer_priority);
 
@@ -325,13 +312,12 @@ int mediaeditor_get_layer_priority(mediaeditor_h editor, unsigned int layer_id,
 int mediaeditor_get_layer_lowest_priority(mediaeditor_h editor, unsigned int *layer_priority)
 {
     int ret = MEDIAEDITOR_ERROR_NONE;
-    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
-    RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
-    RET_VAL_IF(layer_priority == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "layer_priority is NULL");
+    NULL_PARAM_CHECK(_editor);
+    NULL_PARAM_CHECK(layer_priority);
 
-    locker = g_mutex_locker_new(&_editor->mutex);
+    AUTOCLEAN_LOCKER(&_editor->mutex);
 
     ret = _mediaeditor_get_layer_lowest_priority(_editor, layer_priority);
 
@@ -343,13 +329,12 @@ int mediaeditor_get_layer_lowest_priority(mediaeditor_h editor, unsigned int *la
 int mediaeditor_get_layer_id(mediaeditor_h editor, unsigned int layer_priority, unsigned int *layer_id)
 {
     int ret = MEDIAEDITOR_ERROR_NONE;
-    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
-    RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
-    RET_VAL_IF(layer_id == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "layer_id is NULL");
+    NULL_PARAM_CHECK(_editor);
+    NULL_PARAM_CHECK(layer_id);
 
-    locker = g_mutex_locker_new(&_editor->mutex);
+    AUTOCLEAN_LOCKER(&_editor->mutex);
 
     ret = _mediaeditor_get_layer_id(_editor, layer_priority, layer_id);
 
@@ -362,15 +347,15 @@ int mediaeditor_add_clip(mediaeditor_h editor, const char *path, unsigned int la
     int start, unsigned int duration, unsigned int in_point, unsigned int *clip_id)
 {
     int ret = MEDIAEDITOR_ERROR_NONE;
-    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
-    RET_VAL_IF(path == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "path is NULL");
+    NULL_PARAM_CHECK(_editor);
+    NULL_PARAM_CHECK(path);
+
     ret = _check_privilege(path, true, R_OK);
     RET_VAL_IF(ret != MEDIAEDITOR_ERROR_NONE, ret, "failed to check privilege");
-    RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
 
-    locker = g_mutex_locker_new(&_editor->mutex);
+    AUTOCLEAN_LOCKER(&_editor->mutex);
 
     RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
         "the state should be IDLE");
@@ -380,12 +365,11 @@ int mediaeditor_add_clip(mediaeditor_h editor, const char *path, unsigned int la
 
 int mediaeditor_remove_clip(mediaeditor_h editor, unsigned int clip_id)
 {
-    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
-    RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(_editor);
 
-    locker = g_mutex_locker_new(&_editor->mutex);
+    AUTOCLEAN_LOCKER(&_editor->mutex);
 
     RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
         "the state should be IDLE");
@@ -396,12 +380,11 @@ int mediaeditor_remove_clip(mediaeditor_h editor, unsigned int clip_id)
 int mediaeditor_split_clip(mediaeditor_h editor, unsigned int src_clip_id, unsigned int position,
   unsigned int *new_clip_id)
 {
-    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
-    RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(_editor);
 
-    locker = g_mutex_locker_new(&_editor->mutex);
+    AUTOCLEAN_LOCKER(&_editor->mutex);
 
     RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
         "the state should be IDLE");
@@ -411,12 +394,11 @@ int mediaeditor_split_clip(mediaeditor_h editor, unsigned int src_clip_id, unsig
 
 int mediaeditor_group_clip(mediaeditor_h editor, unsigned int *clip_ids, unsigned int size, unsigned int *group_id)
 {
-    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
-    RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(_editor);
 
-    locker = g_mutex_locker_new(&_editor->mutex);
+    AUTOCLEAN_LOCKER(&_editor->mutex);
 
     RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
         "the state should be IDLE");
@@ -426,12 +408,11 @@ int mediaeditor_group_clip(mediaeditor_h editor, unsigned int *clip_ids, unsigne
 
 int mediaeditor_ungroup_clip(mediaeditor_h editor, unsigned int group_id, unsigned int **clip_ids, unsigned int *size)
 {
-    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
-    RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(_editor);
 
-    locker = g_mutex_locker_new(&_editor->mutex);
+    AUTOCLEAN_LOCKER(&_editor->mutex);
 
     RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
         "the state should be IDLE");
@@ -441,12 +422,11 @@ int mediaeditor_ungroup_clip(mediaeditor_h editor, unsigned int group_id, unsign
 
 int mediaeditor_move_clip_layer(mediaeditor_h editor, unsigned int clip_id, unsigned int layer_priority)
 {
-    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
-    RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(_editor);
 
-    locker = g_mutex_locker_new(&_editor->mutex);
+    AUTOCLEAN_LOCKER(&_editor->mutex);
 
     RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
         "the state should be IDLE");
@@ -457,13 +437,12 @@ int mediaeditor_move_clip_layer(mediaeditor_h editor, unsigned int clip_id, unsi
 int mediaeditor_get_clip_start(mediaeditor_h editor, unsigned int clip_id, unsigned int *start)
 {
     int ret = MEDIAEDITOR_ERROR_NONE;
-    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
-    RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
-    RET_VAL_IF(start == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "start is NULL");
+    NULL_PARAM_CHECK(_editor);
+    NULL_PARAM_CHECK(start);
 
-    locker = g_mutex_locker_new(&_editor->mutex);
+    AUTOCLEAN_LOCKER(&_editor->mutex);
 
     ret = _mediaeditor_get_clip_start(_editor, clip_id, start);
 
@@ -474,12 +453,11 @@ int mediaeditor_get_clip_start(mediaeditor_h editor, unsigned int clip_id, unsig
 
 int mediaeditor_set_clip_start(mediaeditor_h editor, unsigned int clip_id, unsigned int start)
 {
-    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
-    RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(_editor);
 
-    locker = g_mutex_locker_new(&_editor->mutex);
+    AUTOCLEAN_LOCKER(&_editor->mutex);
 
     LOG_DEBUG("editor[%p], clip_id[%d], start[%d]", editor, clip_id, start);
 
@@ -492,13 +470,12 @@ int mediaeditor_set_clip_start(mediaeditor_h editor, unsigned int clip_id, unsig
 int mediaeditor_get_clip_duration(mediaeditor_h editor, unsigned int clip_id, unsigned int *duration)
 {
     int ret = MEDIAEDITOR_ERROR_NONE;
-    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
-    RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
-    RET_VAL_IF(duration == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "duration is NULL");
+    NULL_PARAM_CHECK(_editor);
+    NULL_PARAM_CHECK(duration);
 
-    locker = g_mutex_locker_new(&_editor->mutex);
+    AUTOCLEAN_LOCKER(&_editor->mutex);
 
     ret = _mediaeditor_get_clip_duration(_editor, clip_id, duration);
 
@@ -509,12 +486,11 @@ int mediaeditor_get_clip_duration(mediaeditor_h editor, unsigned int clip_id, un
 
 int mediaeditor_set_clip_duration(mediaeditor_h editor, unsigned int clip_id, unsigned int duration)
 {
-    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
-    RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(_editor);
 
-    locker = g_mutex_locker_new(&_editor->mutex);
+    AUTOCLEAN_LOCKER(&_editor->mutex);
 
     LOG_DEBUG("editor[%p], clip_id[%d], duration[%d]", editor, clip_id, duration);
 
@@ -527,13 +503,12 @@ int mediaeditor_set_clip_duration(mediaeditor_h editor, unsigned int clip_id, un
 int mediaeditor_get_clip_in_point(mediaeditor_h editor, unsigned int clip_id, unsigned int *in_point)
 {
     int ret = MEDIAEDITOR_ERROR_NONE;
-    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
-    RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
-    RET_VAL_IF(in_point == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "in_point is NULL");
+    NULL_PARAM_CHECK(_editor);
+    NULL_PARAM_CHECK(in_point);
 
-    locker = g_mutex_locker_new(&_editor->mutex);
+    AUTOCLEAN_LOCKER(&_editor->mutex);
 
     ret = _mediaeditor_get_clip_in_point(_editor, clip_id, in_point);
 
@@ -544,12 +519,11 @@ int mediaeditor_get_clip_in_point(mediaeditor_h editor, unsigned int clip_id, un
 
 int mediaeditor_set_clip_in_point(mediaeditor_h editor, unsigned int clip_id, unsigned int in_point)
 {
-    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
-    RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(_editor);
 
-    locker = g_mutex_locker_new(&_editor->mutex);
+    AUTOCLEAN_LOCKER(&_editor->mutex);
 
     LOG_DEBUG("editor[%p], clip_id[%d], in_point[%d]", editor, clip_id, in_point);
 
@@ -562,14 +536,13 @@ int mediaeditor_set_clip_in_point(mediaeditor_h editor, unsigned int clip_id, un
 int mediaeditor_get_clip_resolution(mediaeditor_h editor, unsigned int clip_id, unsigned int *width, unsigned int *height)
 {
     int ret = MEDIAEDITOR_ERROR_NONE;
-    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
-    RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
-    RET_VAL_IF(width == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "width is NULL");
-    RET_VAL_IF(height == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "height is NULL");
+    NULL_PARAM_CHECK(_editor);
+    NULL_PARAM_CHECK(width);
+    NULL_PARAM_CHECK(height);
 
-    locker = g_mutex_locker_new(&_editor->mutex);
+    AUTOCLEAN_LOCKER(&_editor->mutex);
 
     ret = _mediaeditor_get_clip_resolution(_editor, clip_id, width, height);
 
@@ -580,12 +553,11 @@ int mediaeditor_get_clip_resolution(mediaeditor_h editor, unsigned int clip_id,
 
 int mediaeditor_set_clip_resolution(mediaeditor_h editor, unsigned int clip_id, unsigned int width, unsigned int height)
 {
-    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
-    RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(_editor);
 
-    locker = g_mutex_locker_new(&_editor->mutex);
+    AUTOCLEAN_LOCKER(&_editor->mutex);
 
     LOG_DEBUG("editor[%p], clip_id[%d], width[%d], height[%d]", editor, clip_id, width, height);
 
@@ -598,14 +570,13 @@ int mediaeditor_set_clip_resolution(mediaeditor_h editor, unsigned int clip_id,
 int mediaeditor_get_clip_position(mediaeditor_h editor, unsigned int clip_id, unsigned int *pos_x, unsigned int *pos_y)
 {
     int ret = MEDIAEDITOR_ERROR_NONE;
-    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
-    RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
-    RET_VAL_IF(pos_x == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "pos_x is NULL");
-    RET_VAL_IF(pos_y == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "pos_y is NULL");
+    NULL_PARAM_CHECK(_editor);
+    NULL_PARAM_CHECK(pos_x);
+    NULL_PARAM_CHECK(pos_y);
 
-    locker = g_mutex_locker_new(&_editor->mutex);
+    AUTOCLEAN_LOCKER(&_editor->mutex);
 
     ret = _mediaeditor_get_clip_position(_editor, clip_id, pos_x, pos_y);
 
@@ -616,12 +587,11 @@ int mediaeditor_get_clip_position(mediaeditor_h editor, unsigned int clip_id, un
 
 int mediaeditor_set_clip_position(mediaeditor_h editor, unsigned int clip_id, unsigned int pos_x, unsigned int pos_y)
 {
-    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
-    RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(_editor);
 
-    locker = g_mutex_locker_new(&_editor->mutex);
+    AUTOCLEAN_LOCKER(&_editor->mutex);
 
     LOG_DEBUG("editor[%p], clip_id[%d], pos_x[%d], pos_y[%d]", editor, clip_id, pos_x, pos_y);
 
@@ -634,13 +604,12 @@ int mediaeditor_set_clip_position(mediaeditor_h editor, unsigned int clip_id, un
 int mediaeditor_get_clip_volume(mediaeditor_h editor, unsigned int clip_id, double *volume)
 {
     int ret = MEDIAEDITOR_ERROR_NONE;
-    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
-    RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
-    RET_VAL_IF(volume == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "volume is NULL");
+    NULL_PARAM_CHECK(_editor);
+    NULL_PARAM_CHECK(volume);
 
-    locker = g_mutex_locker_new(&_editor->mutex);
+    AUTOCLEAN_LOCKER(&_editor->mutex);
 
     ret = _mediaeditor_get_clip_volume(_editor, clip_id, volume);
 
@@ -651,13 +620,12 @@ int mediaeditor_get_clip_volume(mediaeditor_h editor, unsigned int clip_id, doub
 
 int mediaeditor_set_clip_volume(mediaeditor_h editor, unsigned int clip_id, double volume)
 {
-    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
-    RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(_editor);
     RET_VAL_IF(volume < 0.0 || volume > 10.0, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "volume is out of range");
 
-    locker = g_mutex_locker_new(&_editor->mutex);
+    AUTOCLEAN_LOCKER(&_editor->mutex);
 
     LOG_DEBUG("editor[%p], clip_id[%d], volume[%f]", editor, clip_id, volume);
 
@@ -670,14 +638,13 @@ int mediaeditor_set_clip_volume(mediaeditor_h editor, unsigned int clip_id, doub
 int mediaeditor_add_transition(mediaeditor_h editor, mediaeditor_transition_type_e type, unsigned int layer_id,
     unsigned int start, unsigned int duration)
 {
-    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
-    RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(_editor);
     RET_VAL_IF(type < MEDIAEDITOR_TRANSITION_TYPE_NONE || type > MEDIAEDITOR_TRANSITION_TYPE_CROSSFADE,
         MEDIAEDITOR_ERROR_INVALID_PARAMETER, "invalid transition type");
 
-    locker = g_mutex_locker_new(&_editor->mutex);
+    AUTOCLEAN_LOCKER(&_editor->mutex);
 
     RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
         "the state should be IDLE");
@@ -688,14 +655,13 @@ int mediaeditor_add_transition(mediaeditor_h editor, mediaeditor_transition_type
 int mediaeditor_add_effect(mediaeditor_h editor, mediaeditor_effect_type_e type, unsigned int layer_id,
     unsigned int start, unsigned int duration, unsigned int *effect_id)
 {
-    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
-    RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(_editor);
     RET_VAL_IF(type <= MEDIAEDITOR_EFFECT_TYPE_NONE || type > MEDIAEDITOR_EFFECT_AUDIO_TYPE_ECHO,
         MEDIAEDITOR_ERROR_INVALID_PARAMETER, "invalid effect type");
 
-    locker = g_mutex_locker_new(&_editor->mutex);
+    AUTOCLEAN_LOCKER(&_editor->mutex);
 
     RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
         "the state should be IDLE");
@@ -705,12 +671,11 @@ int mediaeditor_add_effect(mediaeditor_h editor, mediaeditor_effect_type_e type,
 
 int mediaeditor_remove_effect(mediaeditor_h editor, unsigned int effect_id)
 {
-    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
-    RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(_editor);
 
-    locker = g_mutex_locker_new(&_editor->mutex);
+    AUTOCLEAN_LOCKER(&_editor->mutex);
 
     RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
         "the state should be IDLE");
@@ -721,15 +686,15 @@ int mediaeditor_remove_effect(mediaeditor_h editor, unsigned int effect_id)
 int mediaeditor_create_project(mediaeditor_h editor, const char *path)
 {
     int ret = MEDIAEDITOR_ERROR_NONE;
-    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
-    RET_VAL_IF(path == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "path is NULL");
+    NULL_PARAM_CHECK(_editor);
+    NULL_PARAM_CHECK(path);
+
     ret = _check_privilege(path, false, R_OK | W_OK);
     RET_VAL_IF(ret != MEDIAEDITOR_ERROR_NONE, ret, "failed to check privilege");
-    RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
 
-    locker = g_mutex_locker_new(&_editor->mutex);
+    AUTOCLEAN_LOCKER(&_editor->mutex);
 
     RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
         "the state should be IDLE");
@@ -740,16 +705,16 @@ int mediaeditor_create_project(mediaeditor_h editor, const char *path)
 int mediaeditor_load_project(mediaeditor_h editor, const char *path, mediaeditor_project_loaded_cb callback, void *user_data)
 {
     int ret = MEDIAEDITOR_ERROR_NONE;
-    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
-    RET_VAL_IF(path == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "path is NULL");
+    NULL_PARAM_CHECK(_editor);
+    NULL_PARAM_CHECK(path);
+    NULL_PARAM_CHECK(callback);
+
     ret = _check_privilege(path, true, R_OK);
     RET_VAL_IF(ret != MEDIAEDITOR_ERROR_NONE, ret, "failed to check privilege");
-    RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
-    RET_VAL_IF(callback == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "callback is NULL");
 
-    locker = g_mutex_locker_new(&_editor->mutex);
+    AUTOCLEAN_LOCKER(&_editor->mutex);
 
     RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
         "the state should be IDLE");
@@ -763,11 +728,10 @@ int mediaeditor_load_project(mediaeditor_h editor, const char *path, mediaeditor
 int mediaeditor_save_project(mediaeditor_h editor)
 {
     int ret = MEDIAEDITOR_ERROR_NONE;
-    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
     g_autofree gchar *uri = NULL;
 
-    RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(_editor);
     RET_VAL_IF(_editor->gst.project == NULL, MEDIAEDITOR_ERROR_INVALID_OPERATION, "project is not loaded or created");
 
     uri = ges_project_get_uri(_editor->gst.project);
@@ -775,7 +739,7 @@ int mediaeditor_save_project(mediaeditor_h editor)
     ret = _check_privilege(uri + URI_TO_PATH_OFFSET, false, W_OK);
     RET_VAL_IF(ret != MEDIAEDITOR_ERROR_NONE, ret, "failed to check privilege");
 
-    locker = g_mutex_locker_new(&_editor->mutex);
+    AUTOCLEAN_LOCKER(&_editor->mutex);
 
     RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
         "the state should be IDLE");
@@ -785,13 +749,12 @@ int mediaeditor_save_project(mediaeditor_h editor)
 
 int mediaeditor_set_error_cb(mediaeditor_h editor, mediaeditor_error_cb callback, void *user_data)
 {
-    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
-    RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
-    RET_VAL_IF(callback == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "callback is NULL");
+    NULL_PARAM_CHECK(_editor);
+    NULL_PARAM_CHECK(callback);
 
-    locker = g_mutex_locker_new(&_editor->mutex);
+    AUTOCLEAN_LOCKER(&_editor->mutex);
 
     RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
         "the state should be IDLE");
@@ -806,12 +769,11 @@ int mediaeditor_set_error_cb(mediaeditor_h editor, mediaeditor_error_cb callback
 
 int mediaeditor_unset_error_cb(mediaeditor_h editor)
 {
-    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
-    RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(_editor);
 
-    locker = g_mutex_locker_new(&_editor->mutex);
+    AUTOCLEAN_LOCKER(&_editor->mutex);
 
     RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
         "the state should be IDLE");
@@ -826,13 +788,12 @@ int mediaeditor_unset_error_cb(mediaeditor_h editor)
 
 int mediaeditor_set_state_changed_cb(mediaeditor_h editor, mediaeditor_state_changed_cb callback, void *user_data)
 {
-    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
-    RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
-    RET_VAL_IF(callback == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "callback is NULL");
+    NULL_PARAM_CHECK(_editor);
+    NULL_PARAM_CHECK(callback);
 
-    locker = g_mutex_locker_new(&_editor->mutex);
+    AUTOCLEAN_LOCKER(&_editor->mutex);
 
     RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
         "the state should be IDLE");
@@ -847,12 +808,11 @@ int mediaeditor_set_state_changed_cb(mediaeditor_h editor, mediaeditor_state_cha
 
 int mediaeditor_unset_state_changed_cb(mediaeditor_h editor)
 {
-    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
-    RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(_editor);
 
-    locker = g_mutex_locker_new(&_editor->mutex);
+    AUTOCLEAN_LOCKER(&_editor->mutex);
 
     RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
         "the state should be IDLE");
@@ -867,13 +827,12 @@ int mediaeditor_unset_state_changed_cb(mediaeditor_h editor)
 
 int mediaeditor_set_layer_priority_changed_cb(mediaeditor_h editor, mediaeditor_layer_priority_changed_cb callback, void *user_data)
 {
-    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
-    RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
-    RET_VAL_IF(callback == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "callback is NULL");
+    NULL_PARAM_CHECK(_editor);
+    NULL_PARAM_CHECK(callback);
 
-    locker = g_mutex_locker_new(&_editor->mutex);
+    AUTOCLEAN_LOCKER(&_editor->mutex);
 
     RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
         "the state should be IDLE");
@@ -888,12 +847,11 @@ int mediaeditor_set_layer_priority_changed_cb(mediaeditor_h editor, mediaeditor_
 
 int mediaeditor_unset_layer_priority_changed_cb(mediaeditor_h editor)
 {
-    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
-    RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(_editor);
 
-    locker = g_mutex_locker_new(&_editor->mutex);
+    AUTOCLEAN_LOCKER(&_editor->mutex);
 
     RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
         "the state should be IDLE");
index 13d4a5474bb06404edaa771d5ffae90fb9fdaab2..65e7d11320fd34152ffa84ba63ca1a4100b50502 100644 (file)
@@ -232,9 +232,9 @@ int _mediaeditor_add_clip(mediaeditor_s *editor, const char *path, unsigned int
     guint64 in_point_nsec = 0;
     g_autofree gchar *uri = NULL;
 
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
-    RET_VAL_IF(path == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "path is NULL");
-    RET_VAL_IF(clip_id == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "clip_id is NULL");
+    NULL_PARAM_CHECK(editor);
+    NULL_PARAM_CHECK(path);
+    NULL_PARAM_CHECK(clip_id);
 
     uri = gst_filename_to_uri(path, NULL);
     RET_VAL_IF(uri == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "failed to get uri");
@@ -287,7 +287,7 @@ int _mediaeditor_remove_clip(mediaeditor_s *editor, unsigned int clip_id)
     GESLayer *layer = NULL;
     g_autofree mediaeditor_clip_s *clip_data = NULL;
 
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(editor);
     RET_VAL_IF(clip_id >= editor->clip_id, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "invalid clip id");
 
     clip_data = _mediaeditor_find_clip_data(editor->clips, clip_id);
@@ -315,7 +315,7 @@ int _mediaeditor_split_clip(mediaeditor_s *editor, unsigned int src_clip_id, uns
     mediaeditor_clip_s *clip_data_new = NULL;
     guint64 position_nsec = 0;
 
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(editor);
     RET_VAL_IF(src_clip_id >= editor->clip_id, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "invalid clip id");
 
     clip = __mediaeditor_find_clip(editor->clips, src_clip_id);
@@ -344,7 +344,7 @@ int _mediaeditor_group_clip(mediaeditor_s *editor, unsigned int *clip_ids, unsig
     GESGroup *group = NULL;
     mediaeditor_group_s *group_data = NULL;
 
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(editor);
     for (unsigned int i = 0 ; i < size ; i++)
         RET_VAL_IF(clip_ids[i] <= 0 || clip_ids[i] >= editor->clip_id, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "invalid clip id");
 
@@ -369,7 +369,8 @@ int _mediaeditor_ungroup_clip(mediaeditor_s *editor, unsigned int group_id, unsi
     int number_of_clips = 0;
     unsigned int *ids  = NULL;
 
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(editor);
+    NULL_PARAM_CHECK(clip_ids);
     RET_VAL_IF(group_id <= 0 || group_id >= editor->group_id, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "invalid group id");
 
     group = __mediaeditor_find_group(editor->groups, group_id);
@@ -397,7 +398,7 @@ int _mediaeditor_move_clip_layer(mediaeditor_s *editor, unsigned int clip_id, un
     GESLayer *layer = NULL;
     GESClip *clip = NULL;
 
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(editor);
     RET_VAL_IF(clip_id >= editor->clip_id, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "invalid clip id");
 
     layer = ges_timeline_get_layer(editor->gst.timeline, layer_priority);
@@ -418,7 +419,7 @@ int _mediaeditor_get_clip_start(mediaeditor_s *editor, unsigned int clip_id, uns
 {
     GESClip *clip = NULL;
 
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(editor);
     RET_VAL_IF(clip_id >= editor->clip_id, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "invalid clip id");
 
     clip = __mediaeditor_find_clip(editor->clips, clip_id);
@@ -434,7 +435,7 @@ int _mediaeditor_set_clip_start(mediaeditor_s *editor, unsigned int clip_id, uns
     GESClip *clip = NULL;
     guint64 start_nsec = 0;
 
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(editor);
     RET_VAL_IF(clip_id >= editor->clip_id, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "invalid clip id");
 
     clip = __mediaeditor_find_clip(editor->clips, clip_id);
@@ -454,7 +455,7 @@ int _mediaeditor_get_clip_duration(mediaeditor_s *editor, unsigned int clip_id,
 {
     GESClip *clip = NULL;
 
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(editor);
     RET_VAL_IF(clip_id >= editor->clip_id, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "invalid clip id");
 
     clip = __mediaeditor_find_clip(editor->clips, clip_id);
@@ -470,7 +471,7 @@ int _mediaeditor_set_clip_duration(mediaeditor_s *editor, unsigned int clip_id,
     GESClip *clip = NULL;
     guint64 duration_nsec = 0;
 
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(editor);
     RET_VAL_IF(clip_id >= editor->clip_id, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "invalid clip id");
 
     clip = __mediaeditor_find_clip(editor->clips, clip_id);
@@ -490,7 +491,7 @@ int _mediaeditor_get_clip_in_point(mediaeditor_s *editor, unsigned int clip_id,
 {
     GESClip *clip = NULL;
 
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(editor);
     RET_VAL_IF(clip_id >= editor->clip_id, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "invalid clip id");
 
     clip = __mediaeditor_find_clip(editor->clips, clip_id);
@@ -506,7 +507,7 @@ int _mediaeditor_set_clip_in_point(mediaeditor_s *editor, unsigned int clip_id,
     GESClip *clip = NULL;
     guint64 in_point_nsec = 0;
 
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(editor);
     RET_VAL_IF(clip_id >= editor->clip_id, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "invalid clip id");
 
     clip = __mediaeditor_find_clip(editor->clips, clip_id);
@@ -527,7 +528,7 @@ int _mediaeditor_get_clip_resolution(mediaeditor_s *editor, unsigned int clip_id
 {
     GESClip *clip = NULL;
 
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(editor);
     RET_VAL_IF(clip_id >= editor->clip_id, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "invalid id");
 
     clip = __mediaeditor_find_clip(editor->clips, clip_id);
@@ -545,7 +546,7 @@ int _mediaeditor_set_clip_resolution(mediaeditor_s *editor, unsigned int clip_id
     mediaeditor_clip_s *clip_data = NULL;
     GESClip *clip = NULL;
 
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(editor);
     RET_VAL_IF(clip_id >= editor->clip_id, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "invalid id");
 
     clip_data = _mediaeditor_find_clip_data(editor->clips, clip_id);
@@ -565,7 +566,7 @@ int _mediaeditor_get_clip_position(mediaeditor_s *editor, unsigned int clip_id,
 {
     GESClip *clip = NULL;
 
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(editor);
     RET_VAL_IF(clip_id >= editor->clip_id, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "invalid id");
 
     clip = __mediaeditor_find_clip(editor->clips, clip_id);
@@ -582,7 +583,7 @@ int _mediaeditor_set_clip_position(mediaeditor_s *editor, unsigned int clip_id,
 {
     GESClip *clip = NULL;
 
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(editor);
     RET_VAL_IF(clip_id >= editor->clip_id, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "invalid id");
 
     clip = __mediaeditor_find_clip(editor->clips, clip_id);
@@ -599,7 +600,7 @@ int _mediaeditor_get_clip_volume(mediaeditor_s *editor, unsigned int clip_id, do
     GESClip *clip = NULL;
     GValue val = { 0 };
 
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(editor);
 
     clip = __mediaeditor_find_clip(editor->clips, clip_id);
     RET_VAL_IF(clip == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "invalid clip id");
@@ -621,7 +622,7 @@ int _mediaeditor_set_clip_volume(mediaeditor_s *editor, unsigned int clip_id, do
     GESClip *clip = NULL;
     GValue val = { 0 };
 
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(editor);
 
     clip = __mediaeditor_find_clip(editor->clips, clip_id);
     RET_VAL_IF(clip == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "invalid clip id");
index a9f5267230baa755f80518e27baba103b10e0f52..e8708a9a999b58bcc7b928038a304338546a2763 100644 (file)
@@ -22,8 +22,7 @@
 static int __set_evas_display(mediaeditor_display_s *display)
 {
     int ret = MEDIAEDITOR_ERROR_NONE;
-
-    RET_VAL_IF(display == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "display is NULL");
+    NULL_PARAM_CHECK(display);
 
     ret = mm_display_interface_set_display_mainloop_sync(display->mm_display, MM_DISPLAY_TYPE_EVAS, display->object, NULL);
     RET_VAL_IF(ret != MM_ERROR_NONE, MEDIAEDITOR_ERROR_INVALID_OPERATION,
@@ -45,29 +44,28 @@ static int __set_evas_display(mediaeditor_display_s *display)
 }
 
 //LCOV_EXCL_START
-static int __set_wl_sink(mediaeditor_s *_editor)
+static int __set_wl_sink(mediaeditor_s *editor)
 {
     GstElement *videosink = NULL;
-
-    RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
-    RET_VAL_IF(_editor->gst.pipeline == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "pipeline is NULL");
+    NULL_PARAM_CHECK(editor);
+    RET_VAL_IF(editor->gst.pipeline == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "pipeline is NULL");
 
     videosink = gst_element_factory_make("tizenwlsink", NULL);
     RET_VAL_IF(videosink == NULL, MEDIAEDITOR_ERROR_INVALID_OPERATION, "failed to create element");
 
-    ges_pipeline_preview_set_video_sink(_editor->gst.pipeline, videosink);
+    ges_pipeline_preview_set_video_sink(editor->gst.pipeline, videosink);
 
-    gst_video_overlay_set_wl_window_wl_surface_id(GST_VIDEO_OVERLAY(videosink), _editor->display->overlay_surface_id);
+    gst_video_overlay_set_wl_window_wl_surface_id(GST_VIDEO_OVERLAY(videosink), editor->display->overlay_surface_id);
 
     return MEDIAEDITOR_ERROR_NONE;
 }
 
-static int __set_overlay_display(mediaeditor_s *_editor, mediaeditor_display_s *display)
+static int __set_overlay_display(mediaeditor_s *editor, mediaeditor_display_s *display)
 {
     int ret = MEDIAEDITOR_ERROR_NONE;
     mm_display_type_e type = MM_DISPLAY_TYPE_OVERLAY;
 
-    RET_VAL_IF(display == NULL, MEDIAEDITOR_ERROR_INVALID_OPERATION, "display is NULL");
+    NULL_PARAM_CHECK(display);
 
     if (display->type == MEDIAEDITOR_DISPLAY_TYPE_ECORE)
         type = MM_DISPLAY_TYPE_OVERLAY_EXT;
@@ -76,7 +74,7 @@ static int __set_overlay_display(mediaeditor_s *_editor, mediaeditor_display_s *
     RET_VAL_IF(ret != MM_ERROR_NONE, MEDIAEDITOR_ERROR_INVALID_OPERATION,
         "failed to mm_display_interface_set_display_mainloop_sync()");
 
-    ret = __set_wl_sink(_editor);
+    ret = __set_wl_sink(editor);
     RET_VAL_IF(ret != MM_ERROR_NONE, ret, "failed to set wayland sink");
 
     LOG_INFO("overlay_surface_id[%d]", display->overlay_surface_id);
@@ -117,7 +115,7 @@ int _mediaeditor_set_display(mediaeditor_h editor, mediaeditor_display_type_e ty
     mediaeditor_s *_editor = (mediaeditor_s*)editor;
     mediaeditor_display_s *_display = NULL;
 
-    RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(_editor);
 
     if (_editor->display == NULL) {
         if ((ret = __init_display(&_editor->display)) != MEDIAEDITOR_ERROR_NONE) {
index 1f9f46be93176b7d6617bfa643b69686255ab878..0c17aeecf8b0f5f56ff473a724f963f0d66b7581 100644 (file)
@@ -66,7 +66,7 @@ static GstTimedValue *__new_timed_value(GstClockTime time, gdouble val)
 
 static int __keep_audio_fade_effect(mediaeditor_s *editor, unsigned int start, unsigned int duration, bool is_fade_in)
 {
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(editor);
 
     if (is_fade_in) {
         LOG_DEBUG("FADE IN, start[%"G_GUINT64_FORMAT"], end[%"G_GUINT64_FORMAT"]",
@@ -97,7 +97,7 @@ int _mediaeditor_add_transition(mediaeditor_s *editor, mediaeditor_transition_ty
     guint64 start_nsec = 0;
     guint64 duration_nsec = 0;
 
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(editor);
 
     if (!(transition_clip = ges_transition_clip_new((GESVideoStandardTransitionType)type))) {
         LOGE("Failed to create transition clip :%d", type);
@@ -205,7 +205,7 @@ int _mediaeditor_add_effect(mediaeditor_s *editor, mediaeditor_effect_type_e typ
 {
     int ret = MEDIAEDITOR_ERROR_NONE;
 
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(editor);
 
     switch (type) {
     case MEDIAEDITOR_EFFECT_AUDIO_TYPE_FADE_IN:
@@ -226,7 +226,7 @@ int _mediaeditor_remove_effect(mediaeditor_s *editor, unsigned int effect_id)
     int ret = MEDIAEDITOR_ERROR_NONE;
     mediaeditor_clip_s *clip_data = NULL;
 
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(editor);
 
     clip_data = _mediaeditor_find_clip_data(editor->clips, effect_id);
     RET_VAL_IF(clip_data == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "invalid clip id");
index 7938a85dcfb0e49f1548a26ed702c39acd6f81cb..3f3bc16755d80a9a107ff69363b3ebc4f493dd9e 100644 (file)
@@ -185,7 +185,7 @@ int _load_ini(mediaeditor_s *editor)
 {
     mediaeditor_ini_s *ini = NULL;
 
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(editor);
 
     memset(&editor->ini, 0, sizeof(mediaeditor_ini_s));
     ini = &editor->ini;
index 92b6bdcf4e8afa7738b826d1bea442cd1555552b..c61eb3b9dbbe22e0c6c2dd011be6a5aac1465365 100644 (file)
@@ -124,8 +124,9 @@ static int __resync_layers(mediaeditor_s *editor, unsigned int layer_priority, b
     GESLayer *layer = NULL;
     unsigned int layer_id = 0;
 
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
-    RET_VAL_IF(is_resynced == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "is_resynced is NULL");
+    NULL_PARAM_CHECK(editor);
+    NULL_PARAM_CHECK(is_resynced);
+
     *is_resynced = false;
 
     LOG_DEBUG("layer_priority[%d]", layer_priority);
@@ -221,8 +222,8 @@ static int __mediaeditor_create_layer_common(mediaeditor_s *editor, GESLayer *la
 
 int _mediaeditor_get_layer(mediaeditor_s *editor, unsigned int layer_id, GESLayer **layer)
 {
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
-    RET_VAL_IF(layer == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "layer is NULL");
+    NULL_PARAM_CHECK(editor);
+    NULL_PARAM_CHECK(layer);
 
     *layer = __mediaeditor_find_layer(editor->layers, layer_id);
     RET_VAL_IF(*layer == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "invalid layer id");
@@ -237,9 +238,9 @@ int _mediaeditor_add_layer(mediaeditor_s *editor, unsigned int *layer_id, unsign
     int ret = MEDIAEDITOR_ERROR_NONE;
     GESLayer *layer = NULL;
 
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
-    RET_VAL_IF(layer_id == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "layer_id is NULL");
-    RET_VAL_IF(layer_priority == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "layer_priority is NULL");
+    NULL_PARAM_CHECK(editor);
+    NULL_PARAM_CHECK(layer_id);
+    NULL_PARAM_CHECK(layer_priority);
 
     layer = ges_timeline_append_layer(editor->gst.timeline);
     RET_VAL_IF(layer == NULL, MEDIAEDITOR_ERROR_INVALID_OPERATION, "failed to append layer");
@@ -264,7 +265,7 @@ int _mediaeditor_remove_layer(mediaeditor_s *editor, unsigned int layer_id)
     mediaeditor_layer_info_s *layer_info = NULL;
     bool is_resynced = false;
 
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(editor);
 
     layer_data = __mediaeditor_find_layer_data(editor->layers, layer_id);
     RET_VAL_IF(layer_data == NULL || layer_data->layer == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "invalid layer id");
@@ -309,7 +310,7 @@ int _mediaeditor_move_layer(mediaeditor_s *editor, unsigned int layer_id, unsign
     unsigned int number_of_layer = 0;
     mediaeditor_layer_info_s *layer_info = NULL;
 
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(editor);
 
     ret = _mediaeditor_get_layer(editor, layer_id, &layer);
     RET_VAL_IF(ret != MEDIAEDITOR_ERROR_NONE, ret, "failed to get layer");
@@ -346,7 +347,7 @@ int _mediaeditor_set_layer_activation(mediaeditor_s *editor, unsigned int layer_
     GList *tracks = NULL;
     gboolean result = FALSE;
 
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is null");
+    NULL_PARAM_CHECK(editor);
 
     tracks = ges_timeline_get_tracks(editor->gst.timeline);
     RET_VAL_IF(tracks == NULL, MEDIAEDITOR_ERROR_INVALID_OPERATION, "tracks is NULL");
@@ -364,8 +365,8 @@ int _mediaeditor_get_layer_priority(mediaeditor_s *editor, unsigned int layer_id
 {
     GESLayer *layer = NULL;
 
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is null");
-    RET_VAL_IF(layer_priority == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "layer_priority is null");
+    NULL_PARAM_CHECK(editor);
+    NULL_PARAM_CHECK(layer_priority);
 
     layer = __mediaeditor_find_layer(editor->layers, layer_id);
     RET_VAL_IF(layer == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "failed to get layer");
@@ -380,8 +381,8 @@ int _mediaeditor_get_layer_lowest_priority(mediaeditor_s *editor, unsigned int *
     unsigned int priority_max = 0;
     unsigned int priority_tmp = 0;
 
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is null");
-    RET_VAL_IF(layer_priority == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "layer_priority is null");
+    NULL_PARAM_CHECK(editor);
+    NULL_PARAM_CHECK(layer_priority);
     RET_VAL_IF(editor->layers == NULL, MEDIAEDITOR_ERROR_INVALID_OPERATION, "there's no layer");
 
     for (GList *layer_iter = editor->layers; layer_iter; layer_iter = layer_iter->next) {
@@ -402,8 +403,8 @@ int _mediaeditor_get_layer_id(mediaeditor_s *editor, unsigned int layer_priority
 {
     GESLayer *layer = NULL;
 
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is null");
-    RET_VAL_IF(layer_id == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "layer_id is null");
+    NULL_PARAM_CHECK(editor);
+    NULL_PARAM_CHECK(layer_id);
 
     LOG_DEBUG("layer priority[%d]", layer_priority);
 
index 1de2066c4e5fe024ea7d42bf23d1c29ca54f1391..699db5f62a01314e94665ea97bad66b3c68813c9 100644 (file)
@@ -434,7 +434,7 @@ int _gst_init(mediaeditor_s *editor)
     gchar **gst_args;
     GError *err = NULL;
 
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(editor);
 
     if (initialized) {
         LOG_ERROR("gstreamer is already initialized.");
@@ -485,7 +485,7 @@ int _gst_pipeline_set_state(mediaeditor_s *editor, GstState state)
 {
     GstStateChangeReturn ret = GST_STATE_CHANGE_FAILURE;
 
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(editor);
     RET_VAL_IF(editor->gst.pipeline == NULL, MEDIAEDITOR_ERROR_INVALID_OPERATION, "pipeline is NULL");
 
     ret = gst_element_set_state(GST_ELEMENT(editor->gst.pipeline), state);
@@ -515,7 +515,7 @@ void _gst_pipeline_destroy(mediaeditor_s *editor)
 
 static int __mediaeditor_set_bus_cb(mediaeditor_s *editor)
 {
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(editor);
 
     editor->gst.bus = gst_pipeline_get_bus(GST_PIPELINE(editor->gst.pipeline));
     RET_VAL_IF(editor->gst.bus == NULL, MEDIAEDITOR_ERROR_INVALID_OPERATION, "failed to get bus from pipeline");
@@ -527,7 +527,7 @@ static int __mediaeditor_set_bus_cb(mediaeditor_s *editor)
 
 static bool __check_clip_added(mediaeditor_s *editor)
 {
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(editor);
 
     return editor->clips != NULL;
 }
@@ -537,7 +537,7 @@ int _mediaeditor_stop(mediaeditor_s *editor)
     int ret = MEDIAEDITOR_ERROR_NONE;
     g_autoptr(GMutexLocker) locker = NULL;
 
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(editor);
 
     locker = g_mutex_locker_new(&editor->mutex);
 
@@ -563,7 +563,7 @@ int _mediaeditor_create_pipeline(mediaeditor_s *editor)
 {
     int ret = MEDIAEDITOR_ERROR_NONE;
 
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(editor);
 
     editor->gst.pipeline = ges_pipeline_new();
     RET_VAL_IF(editor->gst.pipeline == NULL, MEDIAEDITOR_ERROR_INVALID_OPERATION, "failed to create ges pipeline");
@@ -612,8 +612,8 @@ int _mediaeditor_start_render(mediaeditor_s *editor, const char* path)
 {
     int ret = MEDIAEDITOR_ERROR_NONE;
 
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
-    RET_VAL_IF(path == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "path is NULL");
+    NULL_PARAM_CHECK(editor);
+    NULL_PARAM_CHECK(path);
     RET_VAL_IF(!__check_clip_added(editor), MEDIAEDITOR_ERROR_INVALID_OPERATION, "There's no clip to render");
 
 #ifndef TIZEN_TV
@@ -654,11 +654,11 @@ int _mediaeditor_start_render(mediaeditor_s *editor, const char* path)
     return MEDIAEDITOR_ERROR_NONE;
 }
 
-int _mediaeditor_cancel_render(mediaeditor_s *editor)
+static int __stop_pipeline(mediaeditor_s *editor)
 {
     int ret = MEDIAEDITOR_ERROR_NONE;
 
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(editor);
 
     ret = _gst_pipeline_set_state(editor, GST_STATE_READY);
     RET_VAL_IF(ret != MEDIAEDITOR_ERROR_NONE, ret, "failed to set GST_STATE_READY");
@@ -668,11 +668,16 @@ int _mediaeditor_cancel_render(mediaeditor_s *editor)
     return MEDIAEDITOR_ERROR_NONE;
 }
 
+int _mediaeditor_cancel_render(mediaeditor_s *editor)
+{
+    return __stop_pipeline(editor);
+}
+
 int _mediaeditor_start_preview(mediaeditor_s *editor)
 {
     int ret = MEDIAEDITOR_ERROR_NONE;
 
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(editor);
     RET_VAL_IF(!__check_clip_added(editor), MEDIAEDITOR_ERROR_INVALID_OPERATION, "There's no clip to render");
 
     if (!ges_timeline_commit_sync(editor->gst.timeline)) {
@@ -699,23 +704,14 @@ int _mediaeditor_start_preview(mediaeditor_s *editor)
 
 int _mediaeditor_stop_preview(mediaeditor_s *editor)
 {
-    int ret = MEDIAEDITOR_ERROR_NONE;
-
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
-
-    ret = _gst_pipeline_set_state(editor, GST_STATE_READY);
-    RET_VAL_IF(ret != MEDIAEDITOR_ERROR_NONE, ret, "failed to set GST_STATE_READY");
-
-    __post_state_cb_in_idle(editor, MEDIAEDITOR_STATE_IDLE);
-
-    return MEDIAEDITOR_ERROR_NONE;
+    return __stop_pipeline(editor);
 }
 
 int _check_privilege(const char *path, bool file_exist, int mode)
 {
     int ret = 0;
 
-    RET_VAL_IF(!path, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "path is null");
+    NULL_PARAM_CHECK(path);
 
     if (file_exist) {
         ret = access(path, mode);
@@ -736,18 +732,22 @@ int _check_privilege(const char *path, bool file_exist, int mode)
         }
     }
 
-        return MEDIAEDITOR_ERROR_NONE;
-    }
+    return MEDIAEDITOR_ERROR_NONE;
+}
 
 int _check_feature(const char *feature)
 {
-    bool supported = false;
+    static bool supported = false;
+    static bool cached = false;
 
-    RET_VAL_IF(feature == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "feature is NULL");
+    NULL_PARAM_CHECK(feature);
 
-    if (system_info_get_platform_bool(feature, &supported) != SYSTEM_INFO_ERROR_NONE) {
-        LOG_ERROR("failed to system_info_get_platform_bool(), feature[%s]", feature);
-        return MEDIAEDITOR_ERROR_INVALID_OPERATION;
+    if (!cached){
+        if (system_info_get_platform_bool(feature, &supported) != SYSTEM_INFO_ERROR_NONE) {
+            LOG_ERROR("failed to system_info_get_platform_bool(), feature[%s]", feature);
+            return MEDIAEDITOR_ERROR_INVALID_OPERATION;
+        }
+        cached = true;
     }
 
     if (!supported) {
index af4ba70c3f1c27fdc31ed0462700102baf3cd3ba..f89b7defceb8b4519ff3c08d80c6e6f700c19f12 100644 (file)
@@ -40,7 +40,7 @@ static void __project_loaded_cb(GESProject *project, GESTimeline *timeline, medi
 
 static int __connect_project_loaded_signal(mediaeditor_s *editor)
 {
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(editor);
 
     g_signal_connect(editor->gst.project, "loaded", (GCallback)__project_loaded_cb, editor);
 
@@ -51,7 +51,7 @@ static int __extract_timeline(mediaeditor_s *editor)
 {
     GESTimeline *timeline = NULL;
 
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(editor);
 
     timeline = GES_TIMELINE(ges_asset_extract(GES_ASSET(editor->gst.project), NULL));
     RET_VAL_IF(timeline == NULL, MEDIAEDITOR_ERROR_INVALID_OPERATION, "failed to extract timeline from project");
@@ -66,7 +66,7 @@ static int __mediaeditor_create_ges_project(mediaeditor_s *editor, gchar *uri)
     int ret = MEDIAEDITOR_ERROR_NONE;
     GESProject *project = NULL;
 
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(editor);
 
     project = ges_project_new(uri);
     RET_VAL_IF(project == NULL, MEDIAEDITOR_ERROR_INVALID_OPERATION, "failed to create project");
@@ -84,8 +84,8 @@ int _mediaeditor_create_project(mediaeditor_s *editor, const char *path)
     int ret = MEDIAEDITOR_ERROR_NONE;
     g_autofree gchar *uri = NULL;
 
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
-    RET_VAL_IF(path == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "path is NULL");
+    NULL_PARAM_CHECK(editor);
+    NULL_PARAM_CHECK(path);
 
     uri = gst_filename_to_uri(path, NULL);
     RET_VAL_IF(uri == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "failed to get uri");
@@ -111,8 +111,8 @@ int _mediaeditor_load_project(mediaeditor_s *editor, const char *path)
     int ret = MEDIAEDITOR_ERROR_NONE;
     g_autofree gchar *uri = NULL;
 
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
-    RET_VAL_IF(path == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "path is NULL");
+    NULL_PARAM_CHECK(editor);
+    NULL_PARAM_CHECK(path);
 
     uri = gst_filename_to_uri(path, NULL);
     RET_VAL_IF(uri == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "failed to get uri");
@@ -137,8 +137,8 @@ int _mediaeditor_save_project(mediaeditor_s *editor, const gchar *uri)
 {
     GESAsset *formatter_asset = NULL;
 
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
-    RET_VAL_IF(uri == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "uri is NULL");
+    NULL_PARAM_CHECK(editor);
+    NULL_PARAM_CHECK(uri);
 
     formatter_asset = ges_asset_request(GES_TYPE_FORMATTER, "ges", NULL);
     RET_VAL_IF(formatter_asset == NULL, MEDIAEDITOR_ERROR_INVALID_OPERATION, "failed to request formatter");
index fd5595ca19a659825c2f688056a6820dea00147d..c09ac3554665045e780cf924ed90252a7167524f 100644 (file)
@@ -58,7 +58,7 @@ static bool __is_valid_resource_type(mm_resource_manager_res_type_e type)
 
 int _create_resource_manager(mediaeditor_s *editor)
 {
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(editor);
 
     if (mm_resource_manager_create(MM_RESOURCE_MANAGER_APP_CLASS_MEDIA,
                 __resource_release_cb, editor,
@@ -74,7 +74,7 @@ int _acquire_resource_for_type(mediaeditor_s *editor, mm_resource_manager_res_ty
 {
     int ret = MM_RESOURCE_MANAGER_ERROR_NONE;
 
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(editor);
 
     if (!editor->resource.mgr) {
         LOG_DEBUG("There's no acquired hw encoder, decoder resources");
@@ -111,7 +111,7 @@ int _release_all_resources(mediaeditor_s *editor)
 {
     int ret = MM_RESOURCE_MANAGER_ERROR_NONE;
 
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(editor);
 
     if (!editor->resource.mgr) {
         LOG_DEBUG("There's no acquired hw encoder, decoder resources");
@@ -148,7 +148,7 @@ int _destroy_resource_manager(mediaeditor_s *editor)
 {
     int ret = MM_RESOURCE_MANAGER_ERROR_NONE;
 
-    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    NULL_PARAM_CHECK(editor);
 
     if (!editor->resource.mgr) {
         LOG_DEBUG("There's no acquired hw encoder, decoder resources");