From: Srimanta Panda Date: Tue, 8 Dec 2015 07:27:20 +0000 (+0100) Subject: rtsp-stream: fixed valgrind error X-Git-Tag: 1.19.3~495^2~579 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f96947b350857ae41178703b6f45591857ab8ead;p=platform%2Fupstream%2Fgstreamer.git rtsp-stream: fixed valgrind error Fixed the valgrind error in unit test. The UDP source created during gst_rtsp_stream_join_bin() was not released while destroying the rtp bin. https://bugzilla.gnome.org/show_bug.cgi?id=759010 --- diff --git a/gst/rtsp-server/rtsp-stream.c b/gst/rtsp-server/rtsp-stream.c index b775689..f329911 100644 --- a/gst/rtsp-server/rtsp-stream.c +++ b/gst/rtsp-server/rtsp-stream.c @@ -2484,18 +2484,31 @@ gst_rtsp_stream_leave_bin (GstRTSPStream * stream, GstBin * bin, gst_element_set_state (priv->funnel[i], GST_STATE_NULL); if (priv->appsrc[i]) gst_element_set_state (priv->appsrc[i], GST_STATE_NULL); - if (priv->udpsrc_v4[i] && (priv->sinkpad || i == 1)) { - /* and set udpsrc to NULL now before removing */ - gst_element_set_locked_state (priv->udpsrc_v4[i], FALSE); - gst_element_set_state (priv->udpsrc_v4[i], GST_STATE_NULL); - /* removing them should also nicely release the request - * pads when they finalize */ - gst_bin_remove (bin, priv->udpsrc_v4[i]); + + if (priv->udpsrc_v4[i]) { + if (priv->sinkpad || i == 1) { + /* and set udpsrc to NULL now before removing */ + gst_element_set_locked_state (priv->udpsrc_v4[i], FALSE); + gst_element_set_state (priv->udpsrc_v4[i], GST_STATE_NULL); + /* removing them should also nicely release the request + * pads when they finalize */ + gst_bin_remove (bin, priv->udpsrc_v4[i]); + } else { + /* we need to set the state to NULL before unref */ + gst_element_set_state (priv->udpsrc_v4[i], GST_STATE_NULL); + gst_object_unref (priv->udpsrc_v4[i]); + } } - if (priv->udpsrc_v6[i] && (priv->sinkpad || i == 1)) { - gst_element_set_locked_state (priv->udpsrc_v6[i], FALSE); - gst_element_set_state (priv->udpsrc_v6[i], GST_STATE_NULL); - gst_bin_remove (bin, priv->udpsrc_v6[i]); + + if (priv->udpsrc_v6[i]) { + if (priv->sinkpad || i == 1) { + gst_element_set_locked_state (priv->udpsrc_v6[i], FALSE); + gst_element_set_state (priv->udpsrc_v6[i], GST_STATE_NULL); + gst_bin_remove (bin, priv->udpsrc_v6[i]); + } else { + gst_element_set_state (priv->udpsrc_v6[i], GST_STATE_NULL); + gst_object_unref (priv->udpsrc_v6[i]); + } } for (l = priv->transport_sources; l; l = l->next) {