From c76639faf3ee2ece96eae893b45a5a17e8c556f3 Mon Sep 17 00:00:00 2001 From: Eunhae Choi Date: Tue, 10 Apr 2018 16:06:40 +0900 Subject: [PATCH] [0.6.103] integrate duplicated struct Change-Id: Iaf6d2bb0d5d1a53c387b6f8e9d20c976f7d45cf3 --- packaging/libmm-player.spec | 2 +- src/include/mm_player_priv.h | 9 ++------ src/mm_player_priv.c | 49 ++++++++++++++++++++------------------------ 3 files changed, 25 insertions(+), 35 deletions(-) diff --git a/packaging/libmm-player.spec b/packaging/libmm-player.spec index 08bab75..bccb4d4 100644 --- a/packaging/libmm-player.spec +++ b/packaging/libmm-player.spec @@ -1,6 +1,6 @@ Name: libmm-player Summary: Multimedia Framework Player Library -Version: 0.6.102 +Version: 0.6.103 Release: 0 Group: Multimedia/Libraries License: Apache-2.0 diff --git a/src/include/mm_player_priv.h b/src/include/mm_player_priv.h index c602cbb..d167a57 100644 --- a/src/include/mm_player_priv.h +++ b/src/include/mm_player_priv.h @@ -412,14 +412,12 @@ typedef struct { char *buf; int len; int offset; - -} tBuffer; /* FIXIT : choose better name */ +} MMPlayerInputBuffer; typedef struct { int uri_type; int play_mode; - void *mem; - int mem_size; + MMPlayerInputBuffer input_mem; char uri[MM_MAX_URL_LEN]; char urgent[MM_MAX_FILENAME_LEN]; } MMPlayerParseProfile; @@ -666,9 +664,6 @@ typedef struct { gulong audio_cb_probe_id; - /* for appsrc */ - tBuffer mem_buf; - /* content profile */ MMPlayerParseProfile profile; MMPlayerStorageInfo storage_info[MMPLAYER_PATH_MAX]; diff --git a/src/mm_player_priv.c b/src/mm_player_priv.c index debf1b5..a4eb8b0 100755 --- a/src/mm_player_priv.c +++ b/src/mm_player_priv.c @@ -5994,7 +5994,6 @@ __mmplayer_update_subtitle(GstElement* object, GstBuffer *buffer, GstPad *pad, g static GstPadProbeReturn __mmplayer_subtitle_adjust_position_probe(GstPad *pad, GstPadProbeInfo *info, gpointer u_data) - { mm_player_t *player = (mm_player_t *) u_data; GstClockTime cur_timestamp = 0; @@ -6103,7 +6102,7 @@ static void __gst_appsrc_feed_data_mem(GstElement *element, guint size, gpointer user_data) { GstElement *appsrc = element; - tBuffer *buf = (tBuffer *)user_data; + MMPlayerInputBuffer *buf = (MMPlayerInputBuffer *)user_data; GstBuffer *buffer = NULL; GstFlowReturn ret = GST_FLOW_OK; gint len = size; @@ -6135,7 +6134,7 @@ __gst_appsrc_feed_data_mem(GstElement *element, guint size, gpointer user_data) static gboolean __gst_appsrc_seek_data_mem(GstElement *element, guint64 size, gpointer user_data) { - tBuffer *buf = (tBuffer *)user_data; + MMPlayerInputBuffer *buf = (MMPlayerInputBuffer *)user_data; MMPLAYER_RETURN_VAL_IF_FAIL(buf, FALSE); @@ -6675,13 +6674,13 @@ __mmplayer_gst_create_pipeline(mm_player_t* player) } g_object_set(element, "stream-type", stream_type, NULL); - g_object_set(element, "size", player->mem_buf.len, NULL); + g_object_set(element, "size", player->profile.input_mem.len, NULL); g_object_set(element, "blocksize", (guint64)20480, NULL); MMPLAYER_SIGNAL_CONNECT(player, element, MM_PLAYER_SIGNAL_TYPE_OTHERS, "seek-data", - G_CALLBACK(__gst_appsrc_seek_data_mem), &player->mem_buf); + G_CALLBACK(__gst_appsrc_seek_data_mem), &player->profile.input_mem); MMPLAYER_SIGNAL_CONNECT(player, element, MM_PLAYER_SIGNAL_TYPE_OTHERS, "need-data", - G_CALLBACK(__gst_appsrc_feed_data_mem), &player->mem_buf); + G_CALLBACK(__gst_appsrc_feed_data_mem), &player->profile.input_mem); } break; case MM_PLAYER_URI_TYPE_URL: @@ -8043,20 +8042,21 @@ static int __mmfplayer_parse_profile(const char *uri, void *param, MMPlayerParse LOGD("ext: %s, mem_size: %d, mmap(param): %p\n", ext, mem_size, param); if (mem_size && param) { - if (data->mem) - free(data->mem); - - data->mem = malloc(mem_size); - - if (data->mem) { - memcpy(data->mem, param, mem_size); - data->mem_size = mem_size; + if (data->input_mem.buf) + free(data->input_mem.buf); + data->input_mem.buf = malloc(mem_size); + + if (data->input_mem.buf) { + memcpy(data->input_mem.buf, param, mem_size); + data->input_mem.len = mem_size; + ret = MM_ERROR_NONE; } else { LOGE("failed to alloc mem %d", mem_size); + ret = MM_ERROR_PLAYER_INTERNAL; } + data->input_mem.offset = 0; data->uri_type = MM_PLAYER_URI_TYPE_MEM; - ret = MM_ERROR_NONE; } } } else { @@ -8116,7 +8116,7 @@ exit: /* dump parse result */ SECURE_LOGW("incomming uri : %s\n", uri); LOGD("uri_type : %d, mem : %p, mem_size : %d, urgent : %s\n", - data->uri_type, data->mem, data->mem_size, data->urgent); + data->uri_type, data->input_mem.buf, data->input_mem.len, data->urgent); MMPLAYER_FLEAVE(); @@ -8731,13 +8731,6 @@ _mmplayer_realize(MMHandleType hplayer) } } - /* profile.mem or mem_buf.buf have to be free when player is destroyed */ - if (player->profile.uri_type == MM_PLAYER_URI_TYPE_MEM) { - player->mem_buf.buf = (char *)player->profile.mem; - player->mem_buf.len = player->profile.mem_size; - player->mem_buf.offset = 0; - } - if (uri && (strstr(uri, "es_buff://"))) { if (strstr(uri, "es_buff://push_mode")) player->es_player_push_mode = TRUE; @@ -11648,11 +11641,13 @@ __mmplayer_release_misc_post(mm_player_t* player) __mmplayer_video_stream_destroy_bo_list(player); __mmplayer_initialize_storage_info(player, MMPLAYER_PATH_MAX); - if (player->profile.mem) { - free(player->profile.mem); - player->profile.mem = NULL; - player->mem_buf.buf = NULL; + if (player->profile.input_mem.buf) { + free(player->profile.input_mem.buf); + player->profile.input_mem.buf = NULL; } + player->profile.input_mem.len = 0; + player->profile.input_mem.offset = 0; + player->uri_info.uri_idx = 0; MMPLAYER_FLEAVE(); } -- 2.7.4