From: Jeongmo Yang Date: Fri, 5 Jul 2024 07:35:02 +0000 (+0900) Subject: [0.3.155] Clean up buffers when receive pipeline removed event X-Git-Tag: accepted/tizen/7.0/unified/20240711.165644^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7764962349bcce812d519cb1b315c2d70f93f7d4;p=platform%2Fcore%2Fapi%2Fplayer.git [0.3.155] Clean up buffers when receive pipeline removed event Change-Id: I08a3d56a4d81872c3102ab4cb56e0e86b9eb91a3 Signed-off-by: Jeongmo Yang --- diff --git a/include/player_private.h b/include/player_private.h index 5b54dc2..f2029b0 100644 --- a/include/player_private.h +++ b/include/player_private.h @@ -180,6 +180,7 @@ typedef struct _callback_cb_info { int video_frame_pool_size; bool use_tsurf_pool; player_display_info_s dp_info; + void *pc; } callback_cb_info_s; typedef struct { diff --git a/packaging/capi-media-player.spec b/packaging/capi-media-player.spec index fb55b42..d3b0a1e 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.154 +Version: 0.3.155 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/player.c b/src/player.c index 9863db8..ba90f96 100644 --- a/src/player.c +++ b/src/player.c @@ -1599,29 +1599,87 @@ static void _player_event_queue_add(player_event_queue *ev, _player_cb_data *dat } } +static void _player_internal_buffer_release(player_cli_s *pc) +{ + mm_display_type_e display_type = MM_DISPLAY_TYPE_NONE; + + if (!pc || !pc->cb_info) { + LOGE("NULL handle[%p]", pc); + return; + } + + LOGI("ENTER"); + + if (!DP_INTERFACE(pc)) { + LOGW("display port interface is NULL"); + goto RELEASE_INTERNAL_MOMORY; + } + + if (mm_display_interface_get_type(DP_INTERFACE(pc), &display_type) != MM_ERROR_NONE) { + LOGE("get display type failed"); + return; + } + + if (display_type != MM_DISPLAY_TYPE_EVAS) + goto RELEASE_INTERNAL_MOMORY; + + if (CALLBACK_INFO(pc)->dp_info.visible != PLAYER_VISIBLE_INFO_FALSE) { + if (mm_display_interface_evas_set_visible(DP_INTERFACE(pc), false) != MM_ERROR_NONE) { + LOGE("mm_display_interface_evas_set_visible failed"); + return; + } + } + + if (mm_display_interface_evas_flush(DP_INTERFACE(pc), false) != MM_ERROR_NONE) { + LOGE("mm_display_interface_evas_flush failed"); + return; + } + +RELEASE_INTERNAL_MOMORY: + _player_release_internal_memory(pc, false); + pc->cb_info->video_frame_pool_size = 0; + __player_remove_tsurf_list(pc); + + LOGI("LEAVE"); +} + static bool _user_callback_handler(callback_cb_info_s *cb_info, muse_player_event_e event, _player_recv_data *recv_data) +{ + if (!cb_info->user_cb[event] || !_user_callbacks[event]) { + LOGE("failed to get callback for event %d", event); + return false; + } + + _player_cb_data *data = NULL; + data = g_new(_player_cb_data, 1); + data->int_data = (int)event; + data->cb_info = cb_info; + data->recv_data = recv_data; + _player_event_queue_add(&cb_info->event_queue, data); + + return true; +} + +static bool _event_callback_handler(callback_cb_info_s *cb_info, muse_player_event_e event, _player_recv_data *recv_data) { /* LOGD("get event %d", event); */ - if (event < MUSE_PLAYER_EVENT_TYPE_NUM) { - if (cb_info->user_cb[event] && _user_callbacks[event]) { - _player_cb_data *data = NULL; - data = g_new(_player_cb_data, 1); - if (!data) { - LOGE("fail to alloc mem"); - return false; - } - data->int_data = (int)event; - data->cb_info = cb_info; - data->recv_data = recv_data; - _player_event_queue_add(&cb_info->event_queue, data); + if (event >= MUSE_PLAYER_EVENT_TYPE_NUM) { + LOGE("invalid event %d", event); + return false; + } + if (event == MUSE_PLAYER_EVENT_TYPE_STATE_CHANGED || + event == MUSE_PLAYER_EVENT_TYPE_INTERRUPT) { + _player_internal_buffer_release((player_cli_s *)cb_info->pc); + if (event == MUSE_PLAYER_EVENT_TYPE_STATE_CHANGED) { + g_free(recv_data->buffer); + g_free(recv_data); return true; } } - LOGE("failed to add event to queue %d", event); - return false; + return _user_callback_handler(cb_info, event, recv_data); } static void _add_ret_msg(muse_player_api_e api, callback_cb_info_s *cb_info, int offset, int parse_len) @@ -1641,8 +1699,9 @@ static void _add_ret_msg(muse_player_api_e api, callback_cb_info_s *cb_info, int last = last->next; last->next = msg; } - } else + } else { LOGE("g_new failure"); + } } static ret_msg_s *_get_ret_msg(muse_player_api_e api, callback_cb_info_s *cb_info) @@ -1757,7 +1816,7 @@ static void *client_cb_handler(gpointer data) } g_mutex_unlock(&cb_info->player_mutex); if (!muse_core_msg_object_get_value("event", jobj, MUSE_TYPE_INT, &event) || - !_user_callback_handler(cb_info, event, recv_data)) { + !_event_callback_handler(cb_info, event, recv_data)) { LOGE("failed to get value or add event to the queue."); if (recv_data) { g_free(recv_data->buffer); @@ -1805,6 +1864,7 @@ static callback_cb_info_s *callback_new(gint sockfd) cb_info = g_new(callback_cb_info_s, 1); if (!cb_info) return NULL; + memset(cb_info, 0, sizeof(callback_cb_info_s)); g_mutex_init(&cb_info->player_mutex); @@ -2027,6 +2087,8 @@ int player_create(player_h *player) goto ERROR; } + pc->cb_info->pc = pc; + ret = client_wait_for_server_ack(api, pc->cb_info, CREATE_CB_TIME_OUT); if (ret == PLAYER_ERROR_INVALID_OPERATION) goto ERROR_RETRY; @@ -2216,12 +2278,10 @@ int player_prepare(player_h player) int player_unprepare(player_h player) { int ret = PLAYER_ERROR_NONE; - int mm_ret = MM_ERROR_NONE; muse_player_api_e api = MUSE_PLAYER_API_UNPREPARE; player_cli_s *pc = (player_cli_s *)player; char *ret_buf = NULL; player_state_e state = PLAYER_STATE_NONE; - mm_display_type_e display_type = MM_DISPLAY_TYPE_NONE; PLAYER_INSTANCE_CHECK(player); @@ -2244,36 +2304,7 @@ int player_unprepare(player_h player) set_null_user_cb_lock(pc->cb_info, MUSE_PLAYER_EVENT_TYPE_SEEK); set_null_user_cb_lock(pc->cb_info, MUSE_PLAYER_EVENT_TYPE_PREPARE); - if (!DP_INTERFACE(pc)) - goto _PLAYER_UNPREPARE; - - - PLAYER_GET_DISPLAY_TYPE(pc, display_type); - - if (display_type != MM_DISPLAY_TYPE_EVAS) - goto _PLAYER_UNPREPARE; - - if (CALLBACK_INFO(pc)->dp_info.visible != PLAYER_VISIBLE_INFO_FALSE) { - mm_ret = mm_display_interface_evas_set_visible(DP_INTERFACE(pc), false); - if (mm_ret != MM_ERROR_NONE) { - LOGE("mm_display_interface_evas_set_visible failed 0x%x", mm_ret); - return PLAYER_ERROR_INVALID_OPERATION; - } - } - - mm_ret = mm_display_interface_evas_flush(DP_INTERFACE(pc), false); - if (mm_ret != MM_ERROR_NONE) { - LOGE("mm_display_interface_evas_flush failed 0x%x", mm_ret); - return PLAYER_ERROR_INVALID_OPERATION; - } - -_PLAYER_UNPREPARE: PLAYER_SEND_MSG(api, pc, ret_buf, ret); - - _player_release_internal_memory(pc, false); - pc->cb_info->video_frame_pool_size = 0; - __player_remove_tsurf_list(pc); - g_free(ret_buf); EXIT: