From: Gilbok Lee Date: Mon, 11 Jan 2021 05:28:39 +0000 (+0900) Subject: [0.3.140] Fix memory leak when set player_set_media_packet_video_frame_decoded_cb() X-Git-Tag: accepted/tizen/unified/20210113.121054^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=18464c25151b636db6ac8a8fa9970d2a734baf50;p=platform%2Fcore%2Fapi%2Fplayer.git [0.3.140] Fix memory leak when set player_set_media_packet_video_frame_decoded_cb() - When tsurf_pool was not used, tsurf_data was not released Change-Id: Ibd9f8b0cbb20eaf7e2b96663a4e695b53a1e5781 --- diff --git a/packaging/capi-media-player.spec b/packaging/capi-media-player.spec index 92c7b6e..f67fb1d 100644 --- a/packaging/capi-media-player.spec +++ b/packaging/capi-media-player.spec @@ -1,6 +1,6 @@ Name: capi-media-player Summary: A Media Player API -Version: 0.3.139 +Version: 0.3.140 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/player.c b/src/player.c index edcd82b..70a2c00 100644 --- a/src/player.c +++ b/src/player.c @@ -920,22 +920,23 @@ static void __media_packet_video_frame_cb_handler(callback_cb_info_s *cb_info, _ bo[i] = tbm_bo_import_fd(cb_info->bufmgr, recv_data->tfd[i]); } - tsurf_data = g_new(player_tsurf_info_s, 1); - if (!tsurf_data) { - LOGE("failed to alloc tsurf info"); - goto ERROR; - } - memset(tsurf_data->key, INVALID_DEFAULT_VALUE, sizeof(tsurf_data->key)); - tsurf = tbm_surface_internal_create_with_bos(&sinfo, bo, bo_num); if (!tsurf) { LOGE("failed to create tbm surface"); - g_free(tsurf_data); goto ERROR; } - memcpy(tsurf_data->key, key, sizeof(tsurf_data->key)); - tsurf_data->tsurf = tsurf; + if (cb_info->use_tsurf_pool) { + tsurf_data = g_try_new(player_tsurf_info_s, 1); + if (!tsurf_data) { + LOGE("failed to alloc tsurf info"); + goto ERROR; + } + memset(tsurf_data->key, INVALID_DEFAULT_VALUE, sizeof(tsurf_data->key)); + + memcpy(tsurf_data->key, key, sizeof(tsurf_data->key)); + tsurf_data->tsurf = tsurf; + g_mutex_lock(&cb_info->data_mutex); cb_info->tsurf_list = g_list_append(cb_info->tsurf_list, tsurf_data); LOGD("key %d is added to the pool", key[0]); @@ -982,7 +983,7 @@ static void __media_packet_video_frame_cb_handler(callback_cb_info_s *cb_info, _ } } - fin_data = g_new0(_media_pkt_video_fin_data, 1); + fin_data = g_try_new0(_media_pkt_video_fin_data, 1); if (!fin_data) { LOGE("failed to alloc fin_data"); goto ERROR; @@ -1033,6 +1034,8 @@ static void __media_packet_video_frame_cb_handler(callback_cb_info_s *cb_info, _ ERROR: if (pkt) media_packet_destroy(pkt); + else if (!tsurf_data && tsurf) + tbm_surface_destroy(tsurf); if (fin_data) g_free(fin_data);