Remove dependency of main thread in destroy function of player and camera 91/182691/1 accepted/tizen/unified/20180704.074852 submit/tizen/20180703.041538
authorHyunil <hyunil46.park@samsung.com>
Wed, 27 Jun 2018 06:41:48 +0000 (15:41 +0900)
committerHyunil <hyunil46.park@samsung.com>
Wed, 27 Jun 2018 06:45:01 +0000 (15:45 +0900)
Change-Id: I29ddd95f8f1f7c78ab63fb1aa37ec3a5361eb1cd
Signed-off-by: Hyunil <hyunil46.park@samsung.com>
packaging/libmm-evas-renderer.spec
src/include/mm_evas_renderer_private.h
src/mm_evas_renderer.c

index da2dad4..48222d2 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-evas-renderer
 Summary:    Multimedia Framework Evas Renderer Library
-Version:    0.0.20
+Version:    0.0.21
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
index 53603a6..d2716ab 100644 (file)
@@ -51,7 +51,6 @@ typedef enum {
        UPDATE_VISIBILITY,
        UPDATE_TBM_SURF,
        UPDATE_FLUSH_BUFFER,
-       UPDATE_DESTROY,
        UPDATE_INFO_NUM
 } update_info;
 
@@ -91,6 +90,7 @@ typedef struct {
        gboolean rendering_info_changed;
        gboolean video_size_changed;
        gboolean is_set_roi_area;
+       gboolean is_set_resize_cb;
 
        /* properties */
        gboolean update_needed; /* to update geometry information on pause state */
index 6241002..133e299 100644 (file)
                } \
        } while (0)
 
-#define SET_EVAS_OBJECT_EVENT_CALLBACK(evas_image_object, usr_data) \
-       do { \
-               if (evas_image_object) { \
-                       LOGD("object callback add"); \
-                       evas_object_event_callback_add(evas_image_object, EVAS_CALLBACK_RESIZE, _evas_resize_cb, usr_data); \
-               } \
-       } while (0)
-
-#define UNSET_EVAS_OBJECT_EVENT_CALLBACK(evas_image_object) \
-       do { \
-               if (evas_image_object) { \
-                       LOGD("object callback del"); \
-                       evas_object_event_callback_del(evas_image_object, EVAS_CALLBACK_RESIZE, _evas_resize_cb); \
-               } \
-       } while (0)
-
 enum {
        DISP_GEO_METHOD_LETTER_BOX = 0,
        DISP_GEO_METHOD_ORIGIN_SIZE,
@@ -128,6 +112,7 @@ static void _mm_evas_renderer_release_flush_buffer(mm_evas_info *evas_info);
 static void _mm_evas_renderer_set_callback(mm_evas_info *evas_info);
 static void _mm_evas_renderer_unset_callback(mm_evas_info *evas_info);
 static void _mm_evas_renderer_set_evas_object_size(mm_evas_info *evas_info);
+static gboolean _check_rendering_packet(mm_evas_info *evas_info);
 
 /* must be called after the null surface has been set. */
 static int _mm_evas_renderer_update_rendering_info(mm_evas_info *evas_info)
@@ -168,15 +153,23 @@ static int _mm_evas_renderer_update_rendering_info(mm_evas_info *evas_info)
 
 static void _evas_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
 {
-       MMER_FENTER();
-
        /* now evas object size is changed */
-
        mm_evas_info *evas_info = data;
 
+       MMER_FENTER();
+
        MMEVAS_RETURN_IF_FAIL(evas_info);
        MMEVAS_RETURN_IF_FAIL(evas_info->eo);
 
+       g_mutex_lock(&evas_info->idx_lock);
+
+       if (!_check_rendering_packet(evas_info)) {
+               g_mutex_unlock(&evas_info->idx_lock);
+               return;
+       }
+
+       g_mutex_unlock(&evas_info->idx_lock);
+
        if (_mm_evas_renderer_update_rendering_info(evas_info) == MM_ERROR_NONE) {
                Evas_Native_Surface *surf;
                surf = evas_object_image_native_surface_get(evas_info->eo);
@@ -196,11 +189,12 @@ static void _evas_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_i
 
 static gboolean _check_rendering_packet(mm_evas_info *evas_info)
 {
-       MMER_FENTER();
        gint cur_idx = 0;
        tbm_format tbm_fmt = 0;
        gchar *s_fmt = NULL;
 
+       MMER_FENTER();
+
        MMEVAS_RETURN_VAL_IF_FAIL(evas_info, FALSE);
 
        cur_idx = evas_info->cur_idx;
@@ -237,11 +231,11 @@ static gboolean _check_rendering_packet(mm_evas_info *evas_info)
 /* must be called after the null surface has been set. */
 static void _mm_evas_renderer_surface_set(mm_evas_info *evas_info)
 {
-       MMER_FENTER();
-
        gint cur_idx = 0;
        gint prev_idx = 0;
 
+       MMER_FENTER();
+
        MMEVAS_RETURN_IF_FAIL(evas_info);
        MMEVAS_RETURN_IF_FAIL(evas_info->eo);
 
@@ -347,11 +341,6 @@ static void _mm_evas_renderer_select_task(mm_evas_info *evas_info, update_info i
                if (_flush_all_packets(evas_info) != MM_ERROR_NONE)
                        LOGE("flushing packets is failed");
                break;
-       case UPDATE_DESTROY:
-               g_mutex_unlock(&evas_info->mp_lock);
-               if (_mm_evas_renderer_reset(evas_info, TRUE) != MM_ERROR_NONE)
-                       LOGE("_mm_evas_renderer_reset is failed");
-               break;
        default:
                LOGW("invalid info type : %d", info);
                break;
@@ -363,17 +352,21 @@ static void _mm_evas_renderer_select_task(mm_evas_info *evas_info, update_info i
 
 static void _evas_pipe_cb(void *data, void *buffer, update_info info)
 {
-       MMER_FENTER();
        mm_evas_info *evas_info = data;
 
+       MMER_FENTER();
+
        MMEVAS_RETURN_IF_FAIL(evas_info);
        MMEVAS_RETURN_IF_FAIL(evas_info->eo);
 
        LOGD("ecore_pipe is called");
+
+       if (!evas_info->is_set_resize_cb)
+               _mm_evas_renderer_set_callback(evas_info);
+
        g_mutex_lock(&evas_info->mp_lock);
        _mm_evas_renderer_select_task(evas_info, info);
-       if (info != UPDATE_DESTROY)
-               g_mutex_unlock(&evas_info->mp_lock);
+       g_mutex_unlock(&evas_info->mp_lock);
 
        MMER_FLEAVE();
        return;
@@ -479,11 +472,11 @@ static int __dump_surf(tbm_surface_h tbm_surf)
 
 static void _free_previous_packets(mm_evas_info *evas_info)
 {
-       MMER_FENTER();
-
        gint index = evas_info->cur_idx;
        gint prev_idx = evas_info->pkt_info[index].prev_idx;
 
+       MMER_FENTER();
+
        while (prev_idx != -1) {
                LOGD("destroy previous packet [%p] idx %d", evas_info->pkt_info[prev_idx].packet, prev_idx);
                if (evas_info->packet_rendered_cb) {
@@ -510,9 +503,10 @@ static void _free_previous_packets(mm_evas_info *evas_info)
 
 static int _get_video_size(media_packet_h packet, mm_evas_info *evas_info)
 {
+       media_format_h fmt;
+
        MMER_FENTER();
 
-       media_format_h fmt;
        if (media_packet_get_format(packet, &fmt) == MEDIA_PACKET_ERROR_NONE) {
                int w, h;
                if (media_format_get_video_info(fmt, NULL, &w, &h, NULL, NULL) == MEDIA_PACKET_ERROR_NONE) {
@@ -539,10 +533,10 @@ static int _get_video_size(media_packet_h packet, mm_evas_info *evas_info)
 
 static int _find_empty_index(mm_evas_info *evas_info)
 {
-       MMER_FENTER();
-
        int i;
 
+       MMER_FENTER();
+
        for (i = 0; i < MAX_PACKET_NUM; i++) {
                if (!evas_info->pkt_info[i].packet) {
                        LOGD("selected idx %d", i);
@@ -559,12 +553,12 @@ static int _find_empty_index(mm_evas_info *evas_info)
 /* must be called after the null surface has been set. */
 static int _destroy_all_packets(mm_evas_info *evas_info)
 {
-       MMER_FENTER();
-
        int ret = MM_ERROR_NONE;
        int ret_mp = MEDIA_PACKET_ERROR_NONE;
        int i = 0;
 
+       MMER_FENTER();
+
        MMEVAS_RETURN_VAL_IF_FAIL(evas_info, MM_ERROR_EVASRENDER_NOT_INITIALIZED);
 
        g_mutex_lock(&evas_info->idx_lock);
@@ -604,11 +598,11 @@ static int _destroy_all_packets(mm_evas_info *evas_info)
 
 static int _set_flush_buffer(mm_evas_info *evas_info)
 {
-       MMER_FENTER();
-
        int ret = MM_ERROR_NONE;
        Evas_Native_Surface surf = { 0 };
 
+       MMER_FENTER();
+
        MMEVAS_RETURN_VAL_IF_FAIL(evas_info, MM_ERROR_EVASRENDER_NOT_INITIALIZED);
 
        /* set flush buffer surface*/
@@ -631,10 +625,12 @@ static int _set_flush_buffer(mm_evas_info *evas_info)
 /* EVAS API must be called by main thread */
 static int _flush_all_packets(mm_evas_info *evas_info)
 {
+       int ret = MM_ERROR_NONE;
+
        MMER_FENTER();
 
-       int ret = MM_ERROR_NONE;
        MMEVAS_RETURN_VAL_IF_FAIL(evas_info, MM_ERROR_EVASRENDER_NOT_INITIALIZED);
+       MMEVAS_RETURN_VAL_IF_FAIL(evas_info->eo, MM_ERROR_EVASRENDER_NOT_INITIALIZED);
 
        /* update the screen only if visible is true */
        /* if flush buffer is null, we cant keep screen */
@@ -643,9 +639,10 @@ static int _flush_all_packets(mm_evas_info *evas_info)
                ret = _set_flush_buffer(evas_info);
                if (ret != MM_ERROR_NONE) return ret;
        } else {
-               /* unset evas native surface for displaying black screen */
+               /* unset evas native surface for removing rendered video frame */
                evas_object_image_native_surface_set(evas_info->eo, NULL);
                evas_object_image_pixels_dirty_set(evas_info->eo, EINA_TRUE);
+               _mm_evas_renderer_unset_callback(evas_info);
        }
 
        LOGD("sent packet %d", evas_info->sent_buffer_cnt);
@@ -666,8 +663,12 @@ static int _flush_all_packets(mm_evas_info *evas_info)
 static void _mm_evas_renderer_set_callback(mm_evas_info *evas_info)
 {
        MMER_FENTER();
-       if (evas_info->eo)
-               SET_EVAS_OBJECT_EVENT_CALLBACK(evas_info->eo, evas_info);
+
+       if (evas_info->eo) {
+               LOGD("resize callback add");
+               evas_object_event_callback_add(evas_info->eo, EVAS_CALLBACK_RESIZE, _evas_resize_cb, evas_info);
+               evas_info->is_set_resize_cb = TRUE;
+       }
 
        MMER_FLEAVE();
 }
@@ -675,8 +676,12 @@ static void _mm_evas_renderer_set_callback(mm_evas_info *evas_info)
 static void _mm_evas_renderer_unset_callback(mm_evas_info *evas_info)
 {
        MMER_FENTER();
-       if (evas_info->eo)
-               UNSET_EVAS_OBJECT_EVENT_CALLBACK(evas_info->eo);
+
+       if (evas_info->eo) {
+               LOGD("resize callback del");
+               evas_object_event_callback_del(evas_info->eo, EVAS_CALLBACK_RESIZE, _evas_resize_cb);
+               evas_info->is_set_resize_cb = FALSE;
+       }
 
        MMER_FLEAVE();
 }
@@ -684,6 +689,7 @@ static void _mm_evas_renderer_unset_callback(mm_evas_info *evas_info)
 static void _mm_evas_renderer_set_evas_object_size(mm_evas_info *evas_info)
 {
        MMER_FENTER();
+
        MMEVAS_RETURN_IF_FAIL(evas_info);
        MMEVAS_RETURN_IF_FAIL(evas_info->eo);
 
@@ -692,15 +698,17 @@ static void _mm_evas_renderer_set_evas_object_size(mm_evas_info *evas_info)
        evas_object_size_hint_align_set(evas_info->eo, EVAS_HINT_FILL, EVAS_HINT_FILL);
        evas_object_size_hint_weight_set(evas_info->eo, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
 
+       MMER_FLEAVE();
+
        return;
 }
 
 static int _mm_evas_pipe_write(mm_evas_info *evas_info, update_info info)
 {
-       MMER_FENTER();
-
        int ret = MM_ERROR_NONE;
 
+       MMER_FENTER();
+
        MMEVAS_RETURN_VAL_IF_FAIL(evas_info, MM_ERROR_EVASRENDER_NOT_INITIALIZED);
        MMEVAS_RETURN_VAL_IF_FAIL(evas_info->epipe, MM_ERROR_EVASRENDER_NOT_INITIALIZED);
 
@@ -712,14 +720,16 @@ static int _mm_evas_pipe_write(mm_evas_info *evas_info, update_info info)
        g_mutex_unlock(&evas_info->write_lock);
 
        MMER_FLEAVE();
+
        return ret;
 }
 
 static int _mm_evas_renderer_create(mm_evas_info **evas_info)
 {
+       mm_evas_info *ptr = NULL;
+
        MMER_FENTER();
 
-       mm_evas_info *ptr = NULL;
        ptr = g_malloc0(sizeof(mm_evas_info));
 
        if (!ptr) {
@@ -747,32 +757,18 @@ static int _mm_evas_renderer_create(mm_evas_info **evas_info)
 
 static int _mm_evas_renderer_destroy(mm_evas_info **evas_info)
 {
-       MMER_FENTER();
-
        int ret = MM_ERROR_NONE;
-       pid_t pid = getpid();
-       pid_t tid = syscall(SYS_gettid);
        mm_evas_info *ptr = (mm_evas_info *)*evas_info;
+
+       MMER_FENTER();
+
        MMEVAS_RETURN_VAL_IF_FAIL(ptr, MM_ERROR_EVASRENDER_NOT_INITIALIZED);
 
        LOGD("finalize evas_info %p", ptr);
 
-       /* this API can be call by sub thread */
-       LOGD("pid [%d], tid [%d]", pid, tid);
-       if (pid == tid) { /* API call by main thread */
-               ret = _mm_evas_renderer_reset(ptr, FALSE);
-               if (ret != MM_ERROR_NONE)
-                       LOGE("_mm_evas_renderer_reset is failed");
-       } else {
-               g_mutex_lock(&ptr->evas_lock);
-               ret = _mm_evas_pipe_write(ptr, UPDATE_DESTROY);
-               if (ret == MM_ERROR_NONE) {
-                       LOGD("Wait for g_cond_signal...");
-                       g_cond_wait(&ptr->evas_cond[COND_DESTROY], &ptr->evas_lock);
-                       LOGD("get g_cond_signal");
-               }
-               g_mutex_unlock(&ptr->evas_lock);
-       }
+       ret = _mm_evas_renderer_reset(ptr, FALSE);
+       if (ret != MM_ERROR_NONE)
+               LOGE("_mm_evas_renderer_reset is failed");
 
        g_mutex_clear(&ptr->mp_lock);
        g_mutex_clear(&ptr->idx_lock);
@@ -791,14 +787,17 @@ static int _mm_evas_renderer_destroy(mm_evas_info **evas_info)
 
 static int _mm_evas_renderer_set_info(mm_evas_info *evas_info, Evas_Object *eo)
 {
+       int i;
+
        MMER_FENTER();
+
        MMEVAS_RETURN_VAL_IF_FAIL(evas_info, MM_ERROR_EVASRENDER_NOT_INITIALIZED);
        MMEVAS_RETURN_VAL_IF_FAIL(eo, MM_ERROR_EVASRENDER_INVALID_ARGUMENT);
 
        g_mutex_lock(&evas_info->idx_lock);
 
        LOGD("set evas_info");
-       int i;
+
        for (i = 0; i < MAX_PACKET_NUM; i++) {
                evas_info->pkt_info[i].packet = NULL;
                evas_info->pkt_info[i].tbm_surf = NULL;
@@ -812,6 +811,7 @@ static int _mm_evas_renderer_set_info(mm_evas_info *evas_info, Evas_Object *eo)
        evas_info->cur_idx = -1;
        evas_info->dst_roi.x = evas_info->dst_roi.y = evas_info->dst_roi.w = evas_info->dst_roi.h = 0;
        evas_info->is_set_roi_area = FALSE;
+       evas_info->is_set_resize_cb = FALSE;
        evas_info->display_geometry_method = evas_info->pre_display_geometry_method = DISP_GEO_METHOD_LETTER_BOX;
        evas_info->eo = eo;
        evas_info->epipe = ecore_pipe_add((Ecore_Pipe_Cb) _evas_pipe_cb, evas_info);
@@ -821,7 +821,6 @@ static int _mm_evas_renderer_set_info(mm_evas_info *evas_info, Evas_Object *eo)
                return MM_ERROR_EVASRENDER_INTERNAL;
        }
        LOGD("created pipe %p", evas_info->epipe);
-       _mm_evas_renderer_set_callback(evas_info);
 
        evas_object_geometry_get(evas_info->eo, &evas_info->eo_size.x, &evas_info->eo_size.y, &evas_info->eo_size.w, &evas_info->eo_size.h);
        LOGI("evas object %p (%d, %d, %d, %d)", evas_info->eo, evas_info->eo_size.x, evas_info->eo_size.y, evas_info->eo_size.w, evas_info->eo_size.h);
@@ -835,38 +834,24 @@ static int _mm_evas_renderer_set_info(mm_evas_info *evas_info, Evas_Object *eo)
 
 static int _mm_evas_renderer_reset(mm_evas_info *evas_info, gboolean is_sub_thread)
 {
-       MMER_FENTER();
-
        int ret = MM_ERROR_NONE;
 
+       MMER_FENTER();
+
        MMEVAS_RETURN_VAL_IF_FAIL(evas_info, MM_ERROR_EVASRENDER_NOT_INITIALIZED);
        MMEVAS_RETURN_VAL_IF_FAIL(evas_info->eo, MM_ERROR_EVASRENDER_NOT_INITIALIZED);
 
        g_mutex_lock(&evas_info->mp_lock);
 
-       evas_object_image_native_surface_set(evas_info->eo, NULL);
-       evas_object_image_pixels_dirty_set(evas_info->eo, EINA_TRUE);
-
        evas_info->eo_size.x = evas_info->eo_size.y = evas_info->eo_size.w = evas_info->eo_size.h = 0;
        evas_info->dst_roi.x = evas_info->dst_roi.y = evas_info->dst_roi.w = evas_info->dst_roi.h = 0;
        evas_info->w = evas_info->h = 0;
-       evas_info->flush_all_packets = FALSE;
 
        if (evas_info->flush_buffer)
                _mm_evas_renderer_release_flush_buffer(evas_info);
 
-       if (!evas_info->flush_all_packets) {
-               ret = _destroy_all_packets(evas_info);
-               if (ret != MM_ERROR_NONE) {
-                       g_mutex_unlock(&evas_info->mp_lock);
-                       return MM_ERROR_EVASRENDER_INTERNAL;
-               }
-       }
-
-       if (evas_info->eo) {
-               _mm_evas_renderer_unset_callback(evas_info);
+       if (evas_info->eo)
                evas_info->eo = NULL;
-       }
 
        if (evas_info->epipe) {
                LOGD("pipe %p will be deleted", evas_info->epipe);
@@ -890,13 +875,13 @@ static int _mm_evas_renderer_reset(mm_evas_info *evas_info, gboolean is_sub_thre
 
 static void _mm_evas_renderer_update_geometry(mm_evas_info *evas_info)
 {
-       MMER_FENTER();
-
        gint video_width = 0;
        gint video_height = 0;
        rect_info result = { 0 };
        gint disp_mode = -1;
 
+       MMER_FENTER();
+
        MMEVAS_RETURN_IF_FAIL(evas_info);
        MMEVAS_RETURN_IF_FAIL(evas_info->eo); //need to check evas object
 
@@ -1010,13 +995,13 @@ static void _mm_evas_renderer_update_geometry(mm_evas_info *evas_info)
 
 static int _mm_evas_renderer_retrieve_all_packets(mm_evas_info *evas_info, bool keep_screen)
 {
-       MMER_FENTER();
-
        int ret = MM_ERROR_NONE;
        pid_t pid = getpid();
        pid_t tid = syscall(SYS_gettid);
        gint64 end_time = g_get_monotonic_time() + SIGNAL_TIMEOUT * G_TIME_SPAN_SECOND;
 
+       MMER_FENTER();
+
        MMEVAS_RETURN_VAL_IF_FAIL(evas_info, MM_ERROR_EVASRENDER_NOT_INITIALIZED);
 
        /* this API can be call by sub thread */
@@ -1056,6 +1041,7 @@ static int _mm_evas_renderer_retrieve_all_packets(mm_evas_info *evas_info, bool
 static int _mm_evas_renderer_make_flush_buffer(mm_evas_info *evas_info)
 {
        MMER_FENTER();
+
        MMEVAS_RETURN_VAL_IF_FAIL(evas_info, MM_ERROR_EVASRENDER_NOT_INITIALIZED);
 
        if (evas_info->cur_idx == -1) {
@@ -1172,6 +1158,7 @@ ERROR:
 static void _mm_evas_renderer_release_flush_buffer(mm_evas_info *evas_info)
 {
        MMER_FENTER();
+
        MMEVAS_RETURN_IF_FAIL(evas_info);
 
        LOGW("release FLUSH BUFFER start");
@@ -1297,11 +1284,11 @@ INVALID_PARAM:
 
 int mm_evas_renderer_create(MMHandleType *handle, Evas_Object *eo)
 {
-       MMER_FENTER();
-
        int ret = MM_ERROR_NONE;
        mm_evas_info *evas_info = NULL;
 
+       MMER_FENTER();
+
        MMEVAS_RETURN_VAL_IF_FAIL(handle, MM_ERROR_EVASRENDER_INVALID_ARGUMENT);
        MMEVAS_RETURN_VAL_IF_FAIL(eo, MM_ERROR_EVASRENDER_INVALID_ARGUMENT);
 
@@ -1325,10 +1312,11 @@ int mm_evas_renderer_create(MMHandleType *handle, Evas_Object *eo)
 
 int mm_evas_renderer_destroy(MMHandleType *handle)
 {
-       MMER_FENTER();
-
        int ret = MM_ERROR_NONE;
        mm_evas_info *evas_info = (mm_evas_info *)*handle;
+
+       MMER_FENTER();
+
        MMEVAS_RETURN_VAL_IF_FAIL(evas_info, MM_ERROR_EVASRENDER_NOT_INITIALIZED);
 
        ret = _mm_evas_renderer_destroy(&evas_info);
@@ -1345,10 +1333,11 @@ int mm_evas_renderer_destroy(MMHandleType *handle)
 
 int mm_evas_renderer_set_visible(MMHandleType handle, bool visible)
 {
-       MMER_FENTER();
-
        int ret = MM_ERROR_NONE;
        mm_evas_info *evas_info = (mm_evas_info *)handle;
+
+       MMER_FENTER();
+
        MMEVAS_RETURN_VAL_IF_FAIL(evas_info, MM_ERROR_EVASRENDER_NOT_INITIALIZED);
 
        evas_info->visible = visible;
@@ -1361,9 +1350,10 @@ int mm_evas_renderer_set_visible(MMHandleType handle, bool visible)
 
 int mm_evas_renderer_get_visible(MMHandleType handle, bool *visible)
 {
+       mm_evas_info *evas_info = (mm_evas_info *)handle;
+
        MMER_FENTER();
 
-       mm_evas_info *evas_info = (mm_evas_info *)handle;
        MMEVAS_RETURN_VAL_IF_FAIL(evas_info, MM_ERROR_EVASRENDER_NOT_INITIALIZED);
 
        *visible = evas_info->visible;
@@ -1375,11 +1365,12 @@ int mm_evas_renderer_get_visible(MMHandleType handle, bool *visible)
 
 int mm_evas_renderer_set_rotation(MMHandleType handle, int rotate)
 {
-       MMER_FENTER();
-
        int ret = MM_ERROR_NONE;
        mm_evas_info *evas_info = (mm_evas_info *)handle;
        guint value;
+
+       MMER_FENTER();
+
        MMEVAS_RETURN_VAL_IF_FAIL(evas_info, MM_ERROR_EVASRENDER_NOT_INITIALIZED);
 
        switch (rotate) {
@@ -1414,9 +1405,10 @@ int mm_evas_renderer_set_rotation(MMHandleType handle, int rotate)
 
 int mm_evas_renderer_get_rotation(MMHandleType handle, int *rotate)
 {
+       mm_evas_info *evas_info = (mm_evas_info *)handle;
+
        MMER_FENTER();
 
-       mm_evas_info *evas_info = (mm_evas_info *)handle;
        MMEVAS_RETURN_VAL_IF_FAIL(evas_info, MM_ERROR_EVASRENDER_NOT_INITIALIZED);
 
        switch (evas_info->rotate_angle) {
@@ -1443,10 +1435,11 @@ int mm_evas_renderer_get_rotation(MMHandleType handle, int *rotate)
 
 int mm_evas_renderer_set_geometry(MMHandleType handle, int mode)
 {
-       MMER_FENTER();
-
        int ret = MM_ERROR_NONE;
        mm_evas_info *evas_info = (mm_evas_info *)handle;
+
+       MMER_FENTER();
+
        MMEVAS_RETURN_VAL_IF_FAIL(evas_info, MM_ERROR_EVASRENDER_NOT_INITIALIZED);
 
        if (evas_info->display_geometry_method != mode) {
@@ -1467,9 +1460,10 @@ int mm_evas_renderer_set_geometry(MMHandleType handle, int mode)
 
 int mm_evas_renderer_get_geometry(MMHandleType handle, int *mode)
 {
+       mm_evas_info *evas_info = (mm_evas_info *)handle;
+
        MMER_FENTER();
 
-       mm_evas_info *evas_info = (mm_evas_info *)handle;
        MMEVAS_RETURN_VAL_IF_FAIL(evas_info, MM_ERROR_EVASRENDER_NOT_INITIALIZED);
 
        *mode = evas_info->display_geometry_method;
@@ -1481,10 +1475,11 @@ int mm_evas_renderer_get_geometry(MMHandleType handle, int *mode)
 
 int mm_evas_renderer_set_roi_area(MMHandleType handle, int x, int y, int w, int h)
 {
-       MMER_FENTER();
-
        int ret = MM_ERROR_NONE;
        mm_evas_info *evas_info = (mm_evas_info *)handle;
+
+       MMER_FENTER();
+
        MMEVAS_RETURN_VAL_IF_FAIL(evas_info, MM_ERROR_EVASRENDER_NOT_INITIALIZED);
 
        if (w <= 0 || h <= 0) {
@@ -1514,9 +1509,10 @@ int mm_evas_renderer_set_roi_area(MMHandleType handle, int x, int y, int w, int
 
 int mm_evas_renderer_get_roi_area(MMHandleType handle, int *x, int *y, int *w, int *h)
 {
+       mm_evas_info *evas_info = (mm_evas_info *)handle;
+
        MMER_FENTER();
 
-       mm_evas_info *evas_info = (mm_evas_info *)handle;
        MMEVAS_RETURN_VAL_IF_FAIL(evas_info, MM_ERROR_EVASRENDER_NOT_INITIALIZED);
 
        *x = evas_info->dst_roi.x;
@@ -1531,11 +1527,12 @@ int mm_evas_renderer_get_roi_area(MMHandleType handle, int *x, int *y, int *w, i
 
 int mm_evas_renderer_set_flip(MMHandleType handle, int flip)
 {
-       MMER_FENTER();
-
        int ret = MM_ERROR_NONE;
        mm_evas_info *evas_info = (mm_evas_info *)handle;
        guint value;
+
+       MMER_FENTER();
+
        MMEVAS_RETURN_VAL_IF_FAIL(evas_info, MM_ERROR_EVASRENDER_NOT_INITIALIZED);
 
        switch (flip) {
@@ -1569,9 +1566,10 @@ int mm_evas_renderer_set_flip(MMHandleType handle, int flip)
 
 int mm_evas_renderer_get_flip(MMHandleType handle, int *flip)
 {
+       mm_evas_info *evas_info = (mm_evas_info *)handle;
+
        MMER_FENTER();
 
-       mm_evas_info *evas_info = (mm_evas_info *)handle;
        MMEVAS_RETURN_VAL_IF_FAIL(evas_info, MM_ERROR_EVASRENDER_NOT_INITIALIZED);
 
        switch (evas_info->flip) {
@@ -1598,10 +1596,11 @@ int mm_evas_renderer_get_flip(MMHandleType handle, int *flip)
 
 int mm_evas_renderer_retrieve_all_packets(MMHandleType handle, bool keep_screen)
 {
-       MMER_FENTER();
-
        int ret = MM_ERROR_NONE;
        mm_evas_info *evas_info = (mm_evas_info*) handle;
+
+       MMER_FENTER();
+
        MMEVAS_RETURN_VAL_IF_FAIL(evas_info, MM_ERROR_EVASRENDER_NOT_INITIALIZED);
 
        ret = _mm_evas_renderer_retrieve_all_packets(evas_info, keep_screen);
@@ -1613,9 +1612,10 @@ int mm_evas_renderer_retrieve_all_packets(MMHandleType handle, bool keep_screen)
 
 int mm_evas_renderer_set_packet_rendered_callback(MMHandleType handle, mm_evas_renderer_media_packet_rendered_cb callback, void *user_data)
 {
+       mm_evas_info *evas_info = (mm_evas_info*) handle;
+
        MMER_FENTER();
 
-       mm_evas_info *evas_info = (mm_evas_info*) handle;
        MMEVAS_RETURN_VAL_IF_FAIL(evas_info, MM_ERROR_EVASRENDER_NOT_INITIALIZED);
 
        evas_info->packet_rendered_cb = callback;