[0.6.260] fix coverity issue 45/264745/1 accepted/tizen/unified/20211001.001328 submit/tizen/20210929.063733
authorEunhye Choi <eunhae1.choi@samsung.com>
Wed, 29 Sep 2021 05:51:33 +0000 (14:51 +0900)
committerEunhye Choi <eunhae1.choi@samsung.com>
Wed, 29 Sep 2021 05:51:36 +0000 (14:51 +0900)
Change-Id: I4ee953eb5004575612675b0ecebbe6cd99fef5ee

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

index bb7160b..3565d7e 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-player
 Summary:    Multimedia Framework Player Library
-Version:    0.6.259
+Version:    0.6.260
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
index 89c47fc..42743ae 100644 (file)
@@ -1144,13 +1144,13 @@ __mmplayer_gst_make_fakesink(mmplayer_t *player, GstPad *pad, const gchar *name)
        fakesink = gst_element_factory_make("fakesink", NULL);
        if (fakesink == NULL) {
                LOGE("failed to create fakesink");
-               goto EXIT;
+               return;
        }
 
-       /* store it as it's sink element */
-       __mmplayer_add_sink(player, fakesink, FALSE);
-
-       gst_bin_add(GST_BIN(pipeline), fakesink);
+       if (!gst_bin_add(GST_BIN(pipeline), fakesink)) {
+               LOGE("failed to add fakesink to pipeline");
+               goto ERROR;
+       }
 
        /* link */
        sinkpad = gst_element_get_static_pad(fakesink, "sink");
@@ -1159,8 +1159,7 @@ __mmplayer_gst_make_fakesink(mmplayer_t *player, GstPad *pad, const gchar *name)
 
        if (gst_pad_link(pad, sinkpad) != GST_PAD_LINK_OK) {
                LOGE("failed to link fakesink");
-               gst_object_unref(GST_OBJECT(fakesink));
-               goto EXIT;
+               goto ERROR;
        }
 
        if (strstr(name, "video")) {
@@ -1175,12 +1174,28 @@ __mmplayer_gst_make_fakesink(mmplayer_t *player, GstPad *pad, const gchar *name)
        g_object_set(G_OBJECT(fakesink), "sync", TRUE, NULL);
        gst_element_set_state(fakesink, GST_STATE_PAUSED);
 
-EXIT:
+       /* store it as it's sink element */
+       __mmplayer_add_sink(player, fakesink, FALSE);
+
        if (sinkpad)
                gst_object_unref(GST_OBJECT(sinkpad));
 
        MMPLAYER_FLEAVE();
        return;
+
+ERROR:
+
+       if (sinkpad)
+               gst_object_unref(GST_OBJECT(sinkpad));
+
+       if (fakesink) {
+               gst_element_set_state(fakesink, GST_STATE_NULL);
+
+               if (!gst_bin_remove(GST_BIN(pipeline), fakesink))
+                       gst_object_unref(GST_OBJECT(fakesink));
+       }
+
+       return;
 }
 
 static GstElement *
@@ -1198,16 +1213,21 @@ __mmplayer_gst_make_concat(mmplayer_t *player, main_element_id_e elem_idx)
                return NULL;
        }
 
+       gst_element_set_state(concat, GST_STATE_PAUSED);
+
+       pipeline = player->pipeline->mainbin[MMPLAYER_M_PIPE].gst;
+       if (!gst_bin_add(GST_BIN(pipeline), concat)) {
+               LOGE("failed to add concat to pipeline");
+               gst_element_set_state(concat, GST_STATE_NULL);
+               gst_object_unref(GST_OBJECT(concat));
+               return NULL;
+       }
+
        LOGD("Create concat [%d] element", elem_idx);
 
        player->pipeline->mainbin[elem_idx].id = elem_idx;
        player->pipeline->mainbin[elem_idx].gst = concat;
 
-       gst_element_set_state(concat, GST_STATE_PAUSED);
-
-       pipeline = player->pipeline->mainbin[MMPLAYER_M_PIPE].gst;
-       gst_bin_add(GST_BIN(pipeline), concat);
-
        MMPLAYER_FLEAVE();
        return concat;
 }
@@ -1229,11 +1249,6 @@ __mmplayer_gst_make_selector(mmplayer_t *player, main_element_id_e elem_idx, mmp
        }
        g_object_set(selector, "sync-streams", TRUE, NULL);
 
-       player->pipeline->mainbin[elem_idx].id = elem_idx;
-       player->pipeline->mainbin[elem_idx].gst = selector;
-
-       /* player->track[stream_type].active_track_index = DEFAULT_TRACK; */
-
        srcpad = gst_element_get_static_pad(selector, "src");
 
        LOGD("blocking %s:%s", GST_DEBUG_PAD_NAME(srcpad));
@@ -1245,10 +1260,29 @@ __mmplayer_gst_make_selector(mmplayer_t *player, main_element_id_e elem_idx, mmp
        gst_element_set_state(selector, GST_STATE_PAUSED);
 
        pipeline = player->pipeline->mainbin[MMPLAYER_M_PIPE].gst;
-       gst_bin_add(GST_BIN(pipeline), selector);
+       if (!gst_bin_add(GST_BIN(pipeline), selector)) {
+               LOGE("failed to add selector to pipeline");
+
+               if (player->track[stream_type].block_id != 0)
+                 gst_pad_remove_probe (srcpad, player->track[stream_type].block_id);
+               player->track[stream_type].block_id = 0;
+
+               if (player->track[stream_type].event_probe_id != 0)
+                 gst_pad_remove_probe (srcpad, player->track[stream_type].event_probe_id);
+               player->track[stream_type].event_probe_id = 0;
+
+               gst_object_unref(GST_OBJECT(srcpad));
+
+               gst_element_set_state(selector, GST_STATE_NULL);
+               gst_object_unref(GST_OBJECT(selector));
+               return NULL;
+       }
 
        gst_object_unref(GST_OBJECT(srcpad));
 
+       player->pipeline->mainbin[elem_idx].id = elem_idx;
+       player->pipeline->mainbin[elem_idx].gst = selector;
+
        MMPLAYER_FLEAVE();
        return selector;
 }