[0.2.77] fix mem leak 26/175426/1
authorEunhae Choi <eunhae1.choi@samsung.com>
Tue, 10 Apr 2018 07:16:36 +0000 (16:16 +0900)
committerEunhae Choi <eunhae1.choi@samsung.com>
Tue, 10 Apr 2018 07:16:36 +0000 (16:16 +0900)
Change-Id: Ia4940823e3ca26b46fd0b7da033ef7a30fb2435f

legacy/src/legacy_player.c
muse/src/muse_player.c
packaging/mmsvc-player.spec

index 81d3106..221e8a0 100644 (file)
@@ -281,8 +281,8 @@ static player_state_e __convert_player_state(MMPlayerStateType state)
 bool __player_state_validate(player_s *handle, player_state_e threshold)
 {
        if (handle->state < threshold)
-               return FALSE;
-       return TRUE;
+               return false;
+       return true;
 }
 
 static int __set_callback(muse_player_event_e type, player_h player, void *callback, void *user_data)
@@ -462,7 +462,6 @@ static int __msg_callback(int message, void *param, void *user_data)
                if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_INTERRUPT]) {
                        int code = 0;
                        if (msg->union_type == MM_MSG_UNION_STATE) {
-
                                handle->state = __convert_player_state(msg->state.current);
                                LOGD("update player state to %d", handle->state);
 
@@ -787,6 +786,8 @@ int legacy_player_prepare_async(player_h player, player_prepared_cb callback, vo
                if (ret != MM_ERROR_NONE)
                        LOGW("[%s] Failed to set display surface type 'MM_DISPLAY_SURFACE_NULL' (0x%x)", __FUNCTION__, ret);
        } else {
+
+               /* FIXME : new funct path is needed to update video instead of set attr again */
                ret = mm_player_get_attribute(handle->mm_handle, NULL, "display_visible", &visible, (char *)NULL);
                if (ret != MM_ERROR_NONE) goto ERROR;
 
@@ -969,10 +970,10 @@ int legacy_player_set_memory_buffer(player_h player, const void *data, int size)
        PLAYER_CHECK_CONDITION(size >= 0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
        player_s *handle = (player_s *)player;
        PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
-
        char uri[PATH_MAX];
 
        handle->is_media_stream = FALSE;
+
        snprintf(uri, sizeof(uri), "mem:///ext=%s,size=%d", "", size);
        int ret = mm_player_set_attribute(handle->mm_handle, NULL, MM_PLAYER_CONTENT_URI, uri, strlen(uri), MM_PLAYER_MEMORY_SRC, data, size, (char *)NULL);
        if (ret != MM_ERROR_NONE)
@@ -2024,12 +2025,8 @@ int legacy_player_set_media_packet_video_frame_decoded_cb(player_h player, legac
 {
        PLAYER_INSTANCE_CHECK(player);
        PLAYER_NULL_ARG_CHECK(callback);
-
        player_s *handle = (player_s *)player;
-       if (handle->state != PLAYER_STATE_IDLE) {
-               LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d", __FUNCTION__, PLAYER_ERROR_INVALID_STATE, handle->state);
-               return PLAYER_ERROR_INVALID_STATE;
-       }
+       PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
 
        int ret = mm_player_set_video_stream_callback(handle->mm_handle, (mm_player_video_stream_callback)callback, user_data);
        if (ret != MM_ERROR_NONE)
@@ -2087,11 +2084,7 @@ int legacy_player_set_video_stream_changed_cb(player_h player, player_video_stre
        PLAYER_INSTANCE_CHECK(player);
        PLAYER_NULL_ARG_CHECK(callback);
        player_s *handle = (player_s *)player;
-
-       if (handle->state != PLAYER_STATE_IDLE) {
-               LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d", __FUNCTION__, PLAYER_ERROR_INVALID_STATE, handle->state);
-               return PLAYER_ERROR_INVALID_STATE;
-       }
+       PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
 
        ret = mm_player_set_video_stream_changed_callback(handle->mm_handle, (mm_player_stream_changed_callback)__video_stream_changed_callback, (void *)handle);
 
@@ -2170,11 +2163,8 @@ int legacy_player_set_media_stream_buffer_status_cb(player_h player, player_stre
        PLAYER_INSTANCE_CHECK(player);
        PLAYER_NULL_ARG_CHECK(callback);
        player_s *handle = (player_s *)player;
+       PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
 
-       if (handle->state != PLAYER_STATE_IDLE) {
-               LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d", __FUNCTION__, PLAYER_ERROR_INVALID_STATE, handle->state);
-               return PLAYER_ERROR_INVALID_STATE;
-       }
        /* the type can be expaned with default and text. */
        if ((type != PLAYER_STREAM_TYPE_VIDEO) && (type != PLAYER_STREAM_TYPE_AUDIO)) {
                LOGE("[%s] PLAYER_ERROR_INVALID_PARAMETER(type : %d)", __FUNCTION__, type);
@@ -2218,11 +2208,8 @@ int legacy_player_set_media_stream_seek_cb(player_h player, player_stream_type_e
        PLAYER_INSTANCE_CHECK(player);
        PLAYER_NULL_ARG_CHECK(callback);
        player_s *handle = (player_s *)player;
+       PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
 
-       if (handle->state != PLAYER_STATE_IDLE) {
-               LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d", __FUNCTION__, PLAYER_ERROR_INVALID_STATE, handle->state);
-               return PLAYER_ERROR_INVALID_STATE;
-       }
        /* the type can be expaned with default and text. */
        if ((type != PLAYER_STREAM_TYPE_VIDEO) && (type != PLAYER_STREAM_TYPE_AUDIO)) {
                LOGE("[%s] PLAYER_ERROR_INVALID_PARAMETER(type : %d)", __FUNCTION__, type);
@@ -2776,11 +2763,7 @@ int legacy_player_set_streaming_buffering_time(player_h player, int buffer_ms, i
        PLAYER_INSTANCE_CHECK(player);
        player_s *handle = (player_s *)player;
        int ret = MM_ERROR_NONE;
-
-       if (handle->state != PLAYER_STATE_IDLE) {
-               LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d", __FUNCTION__, PLAYER_ERROR_INVALID_STATE, handle->state);
-               return PLAYER_ERROR_INVALID_STATE;
-       }
+       PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
 
        ret = mm_player_set_streaming_buffering_time(handle->mm_handle, buffer_ms, rebuffer_ms);
        if (ret != MM_ERROR_NONE)
index b3540a6..6d60793 100644 (file)
@@ -1512,10 +1512,15 @@ int player_disp_set_memory_buffer(muse_module_h module)
 
        bo_addr = (intptr_t)bo;
        ret = legacy_player_set_memory_buffer(muse_player->player_handle, thandle.ptr, size);
+       if (ret != PLAYER_ERROR_NONE) {
+               tbm_bo_unmap(bo);
+               goto ERROR;
+       }
+
        player_msg_return1(api, ret, module, INT, bo_addr);
 
        /* don't call bo unmap/unref here *
-        * it will be released at player_disp_deinit_memory_buffer() */
+        * it will be released at player_disp_deinit_memory_buffer() during _destroy */
 
        close(tfd);
        return ret;
index 29f9dc3..245a682 100644 (file)
@@ -1,6 +1,6 @@
 Name:       mmsvc-player
 Summary:    A Media Player module for muse server
-Version:    0.2.76
+Version:    0.2.77
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0