[0.6.253] Fix wrong memory free, when the pipeline is destroyed
[platform/core/multimedia/libmm-player.git] / src / mm_player_priv.c
index 77743ac..6e3f150 100644 (file)
@@ -4373,9 +4373,6 @@ __mmplayer_gst_destroy_pipeline(mmplayer_t *player)
                __mmplayer_release_signal_connection(player, MM_PLAYER_SIGNAL_TYPE_ALL);
 
                if (mainbin) {
-                       mmplayer_gst_element_t *audiobin = player->pipeline->audiobin;
-                       mmplayer_gst_element_t *videobin = player->pipeline->videobin;
-                       mmplayer_gst_element_t *textbin = player->pipeline->textbin;
                        GstBus *bus = gst_pipeline_get_bus(GST_PIPELINE(mainbin[MMPLAYER_M_PIPE].gst));
                        gst_bus_set_sync_handler(bus, NULL, NULL, NULL);
                        gst_object_unref(bus);
@@ -4395,9 +4392,9 @@ __mmplayer_gst_destroy_pipeline(mmplayer_t *player)
                        if (mainbin[MMPLAYER_M_SRC_FAKESINK].gst)
                                gst_object_unref(GST_OBJECT(mainbin[MMPLAYER_M_SRC_FAKESINK].gst));
 
-                       MMPLAYER_FREEIF(audiobin);
-                       MMPLAYER_FREEIF(videobin);
-                       MMPLAYER_FREEIF(textbin);
+                       MMPLAYER_FREEIF(player->pipeline->audiobin);
+                       MMPLAYER_FREEIF(player->pipeline->videobin);
+                       MMPLAYER_FREEIF(player->pipeline->textbin);
                        MMPLAYER_FREEIF(mainbin);
                }
 
@@ -7519,10 +7516,12 @@ _mmplayer_gst_decode_pad_removed(GstElement *elem, GstPad *pad,
 
        __mmplayer_release_signal_connection(player, MM_PLAYER_SIGNAL_TYPE_VIDEOBIN);
 
-       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;
+       if (!gst_bin_remove(GST_BIN_CAST(mainbin[MMPLAYER_M_PIPE].gst), videobin[MMPLAYER_V_BIN].gst)) {
+               LOGE("failed to remove videobin");
+       }
+
+       if (!gst_bin_remove(GST_BIN_CAST(mainbin[MMPLAYER_M_PIPE].gst), mainbin[MMPLAYER_M_V_CONCAT].gst)) {
+               LOGE("failed to remove video concat");
        }
 
        ret = _mmplayer_gst_set_state(player, videobin[MMPLAYER_V_BIN].gst, GST_STATE_NULL, FALSE, timeout);
@@ -7531,12 +7530,10 @@ _mmplayer_gst_decode_pad_removed(GstElement *elem, GstPad *pad,
                return;
        }
 
-       if (!gst_bin_remove(GST_BIN_CAST(mainbin[MMPLAYER_M_PIPE].gst), mainbin[MMPLAYER_M_V_CONCAT].gst)) {
-               LOGE("failed to remove video concat");
-       }
-
-       if (!gst_bin_remove(GST_BIN_CAST(mainbin[MMPLAYER_M_PIPE].gst), videobin[MMPLAYER_V_BIN].gst)) {
-               LOGE("failed to remove videobin");
+       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));