[0.6.259] remove invalid object unref 06/264606/2 submit/tizen/20210928.034031
authorEunhye Choi <eunhae1.choi@samsung.com>
Mon, 27 Sep 2021 06:20:14 +0000 (15:20 +0900)
committerEunhye Choi <eunhae1.choi@samsung.com>
Mon, 27 Sep 2021 08:39:34 +0000 (17:39 +0900)
- after calling gst_bin_remove, the element is removed
  and the reference is cleard too.

Change-Id: Iffb267d092160c0b467f32a9aafbc72837ddb2d3

packaging/libmm-player.spec
src/mm_player_gst.c
src/mm_player_priv.c

index 25de64a..bb7160b 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-player
 Summary:    Multimedia Framework Player Library
-Version:    0.6.258
+Version:    0.6.259
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
index e5e3aa4..fb1e493 100644 (file)
@@ -2400,9 +2400,6 @@ __mmplayer_gst_create_es_decoder(mmplayer_t *player, mmplayer_stream_type_e type
                return FALSE;
        }
 
-       mainbin[elem_id].id = elem_id;
-       mainbin[elem_id].gst = decodebin;
-
        /* raw pad handling signal */
        _mmplayer_add_signal_connection(player, G_OBJECT(decodebin), MM_PLAYER_SIGNAL_TYPE_AUTOPLUG, "pad-added",
                                                                                G_CALLBACK(_mmplayer_gst_decode_pad_added), (gpointer)player);
@@ -2443,6 +2440,10 @@ __mmplayer_gst_create_es_decoder(mmplayer_t *player, mmplayer_stream_type_e type
        gst_object_unref(GST_OBJECT(sinkpad));
 
        gst_element_sync_state_with_parent(decodebin);
+
+       mainbin[elem_id].id = elem_id;
+       mainbin[elem_id].gst = decodebin;
+
        MMPLAYER_FLEAVE();
        return TRUE;
 
@@ -2450,11 +2451,10 @@ ERROR:
        if (sinkpad)
                gst_object_unref(GST_OBJECT(sinkpad));
 
-       if (mainbin[elem_id].gst) {
-               gst_element_set_state(mainbin[elem_id].gst, GST_STATE_NULL);
-               gst_bin_remove(GST_BIN(mainbin[MMPLAYER_M_PIPE].gst), mainbin[elem_id].gst);
-               gst_object_unref(mainbin[elem_id].gst);
-               mainbin[elem_id].gst = NULL;
+       if (decodebin) {
+               gst_element_set_state(decodebin, GST_STATE_NULL);
+               if (!gst_bin_remove(GST_BIN(mainbin[MMPLAYER_M_PIPE].gst), decodebin))
+                       gst_object_unref(decodebin);
        }
 
        MMPLAYER_FLEAVE();
@@ -2588,15 +2588,15 @@ __mmplayer_gst_create_es_path(mmplayer_t *player, mmplayer_stream_type_e type, G
 ERROR:
        if (mainbin[src_id].gst) {
                gst_element_set_state(mainbin[src_id].gst, GST_STATE_NULL);
-               gst_bin_remove(GST_BIN(mainbin[MMPLAYER_M_PIPE].gst), mainbin[src_id].gst);
-               gst_object_unref(mainbin[src_id].gst);
+               if (!gst_bin_remove(GST_BIN(mainbin[MMPLAYER_M_PIPE].gst), mainbin[src_id].gst))
+                       gst_object_unref(mainbin[src_id].gst);
                mainbin[src_id].gst = NULL;
        }
 
        if (mainbin[queue_id].gst) {
                gst_element_set_state(mainbin[queue_id].gst, GST_STATE_NULL);
-               gst_bin_remove(GST_BIN(mainbin[MMPLAYER_M_PIPE].gst), mainbin[queue_id].gst);
-               gst_object_unref(mainbin[queue_id].gst);
+               if (!gst_bin_remove(GST_BIN(mainbin[MMPLAYER_M_PIPE].gst), mainbin[queue_id].gst))
+                       gst_object_unref(mainbin[queue_id].gst);
                mainbin[queue_id].gst = NULL;
        }
 
index d75a7d8..89c47fc 100644 (file)
@@ -6311,8 +6311,10 @@ ERROR:
                /* And, it still has a parent "player".
                 * You need to let the parent manage the object instead of unreffing the object directly.
                 */
-               gst_bin_remove(GST_BIN(mainbin[MMPLAYER_M_PIPE].gst), queue2);
-               gst_object_unref(queue2);
+               if (!gst_bin_remove(GST_BIN(mainbin[MMPLAYER_M_PIPE].gst), queue2)) {
+                       LOGE("failed to remove queue2");
+                       gst_object_unref(queue2);
+               }
                queue2 = NULL;
        }
 
@@ -6327,8 +6329,10 @@ ERROR:
                 * You need to let the parent manage the object instead of unreffing the object directly.
                 */
 
-               gst_bin_remove(GST_BIN(mainbin[MMPLAYER_M_PIPE].gst), decodebin);
-               gst_object_unref(decodebin);
+               if (!gst_bin_remove(GST_BIN(mainbin[MMPLAYER_M_PIPE].gst), decodebin)) {
+                       LOGE("failed to remove decodebin");
+                       gst_object_unref(decodebin);
+               }
                decodebin = NULL;
        }
 
@@ -6744,7 +6748,11 @@ __mmplayer_deactivate_selector(mmplayer_t *player, mmplayer_track_type_e type)
                g_ptr_array_set_size(selector->streams, 0);
 
                gst_element_set_state(player->pipeline->mainbin[selectorId].gst, GST_STATE_NULL);
-               gst_bin_remove(GST_BIN_CAST(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst), player->pipeline->mainbin[selectorId].gst);
+               if (!gst_bin_remove(GST_BIN_CAST(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst),
+                                                       player->pipeline->mainbin[selectorId].gst)) {
+                       LOGE("failed to remove selector");
+                       gst_object_unref(player->pipeline->mainbin[selectorId].gst);
+               }
 
                player->pipeline->mainbin[selectorId].gst = NULL;
                selector = NULL;
@@ -7540,7 +7548,6 @@ _mmplayer_gst_decode_pad_removed(GstElement *elem, GstPad *pad,
        mmplayer_t *player = (mmplayer_t *)data;
        mmplayer_gst_element_t *mainbin = player->pipeline->mainbin;
        mmplayer_gst_element_t *videobin = player->pipeline->videobin;
-       gint timeout = MMPLAYER_STATE_CHANGE_TIMEOUT(player);
 
        MMPLAYER_FENTER();
        MMPLAYER_RETURN_IF_FAIL(player && player->pipeline && mainbin);
@@ -7557,29 +7564,16 @@ _mmplayer_gst_decode_pad_removed(GstElement *elem, GstPad *pad,
 
        if (!gst_bin_remove(GST_BIN_CAST(mainbin[MMPLAYER_M_PIPE].gst), videobin[MMPLAYER_V_BIN].gst)) {
                LOGE("failed to remove videobin");
+               gst_object_unref(GST_OBJECT(videobin[MMPLAYER_V_BIN].gst));
        }
 
        if (!gst_bin_remove(GST_BIN_CAST(mainbin[MMPLAYER_M_PIPE].gst), mainbin[MMPLAYER_M_V_CONCAT].gst)) {
                LOGE("failed to remove video concat");
+               gst_object_unref(GST_OBJECT(mainbin[MMPLAYER_M_V_CONCAT].gst));
        }
 
-       ret = _mmplayer_gst_set_state(player, videobin[MMPLAYER_V_BIN].gst, GST_STATE_NULL, FALSE, timeout);
-       if (ret != MM_ERROR_NONE) {
-               LOGE("fail to change state to NULL");
-               return;
-       }
-
-       ret = _mmplayer_gst_set_state(player, mainbin[MMPLAYER_M_V_CONCAT].gst, GST_STATE_NULL, FALSE, timeout);
-       if (ret != MM_ERROR_NONE) {
-               LOGE("fail to change state to NULL");
-               return;
-       }
-
-       gst_object_unref(GST_OBJECT(mainbin[MMPLAYER_M_V_CONCAT].gst));
        mainbin[MMPLAYER_M_V_CONCAT].gst = NULL;
        mainbin[MMPLAYER_M_V_CONCAT].id = 0;
-
-       gst_object_unref(GST_OBJECT(videobin[MMPLAYER_V_BIN].gst));
        MMPLAYER_FREEIF(player->pipeline->videobin);
 
        ret = __mmplayer_release_hw_resource(player, MMPLAYER_RESOURCE_TYPE_VIDEO_OVERLAY);