GESTimelinePipeline: unref all pads

This commit is contained in:
Edward Hervey 2010-06-21 11:54:01 +02:00
parent 575c4865a0
commit be8cbdb4a1

View file

@ -363,10 +363,12 @@ pad_added_cb (GstElement * timeline, GstPad * pad, GESTimelinePipeline * self)
/* Linking pad to tee */ /* Linking pad to tee */
sinkpad = gst_element_get_static_pad (chain->tee, "sink"); sinkpad = gst_element_get_static_pad (chain->tee, "sink");
gst_pad_link (pad, sinkpad); gst_pad_link (pad, sinkpad);
gst_object_unref (sinkpad);
/* Connect playsink */ /* Connect playsink */
if (self->mode & TIMELINE_MODE_PREVIEW) { if (self->mode & TIMELINE_MODE_PREVIEW) {
const gchar *sinkpad_name; const gchar *sinkpad_name;
GstPad *tmppad;
GST_DEBUG_OBJECT (self, "Connecting to playsink"); GST_DEBUG_OBJECT (self, "Connecting to playsink");
@ -393,11 +395,13 @@ pad_added_cb (GstElement * timeline, GstPad * pad, GESTimelinePipeline * self)
goto error; goto error;
} }
if (G_UNLIKELY (gst_pad_link (gst_element_get_request_pad (chain->tee, tmppad = gst_element_get_request_pad (chain->tee, "src%d");
"src%d"), sinkpad) != GST_PAD_LINK_OK)) { if (G_UNLIKELY (gst_pad_link (tmppad, sinkpad) != GST_PAD_LINK_OK)) {
GST_ERROR_OBJECT (self, "Couldn't link track pad to playsink"); GST_ERROR_OBJECT (self, "Couldn't link track pad to playsink");
gst_object_unref (tmppad);
goto error; goto error;
} }
gst_object_unref (tmppad);
GST_DEBUG ("Reconfiguring playsink"); GST_DEBUG ("Reconfiguring playsink");
@ -405,11 +409,13 @@ pad_added_cb (GstElement * timeline, GstPad * pad, GESTimelinePipeline * self)
g_signal_emit_by_name (self->playsink, "reconfigure", &reconfigured); g_signal_emit_by_name (self->playsink, "reconfigure", &reconfigured);
GST_DEBUG ("'reconfigure' returned %d", reconfigured); GST_DEBUG ("'reconfigure' returned %d", reconfigured);
/* We still hold a reference on the sinkpad */
chain->playsinkpad = sinkpad; chain->playsinkpad = sinkpad;
} }
/* Connect to encodebin */ /* Connect to encodebin */
if (self->mode & (TIMELINE_MODE_RENDER | TIMELINE_MODE_SMART_RENDER)) { if (self->mode & (TIMELINE_MODE_RENDER | TIMELINE_MODE_SMART_RENDER)) {
GstPad *tmppad;
GST_DEBUG_OBJECT (self, "Connecting to encodebin"); GST_DEBUG_OBJECT (self, "Connecting to encodebin");
if (!chain->encodebinpad) { if (!chain->encodebinpad) {
@ -428,11 +434,13 @@ pad_added_cb (GstElement * timeline, GstPad * pad, GESTimelinePipeline * self)
chain->encodebinpad = sinkpad; chain->encodebinpad = sinkpad;
} }
if (G_UNLIKELY (gst_pad_link (gst_element_get_request_pad (chain->tee, tmppad = gst_element_get_request_pad (chain->tee, "src%d");
"src%d"), chain->encodebinpad) != GST_PAD_LINK_OK)) { if (G_UNLIKELY (gst_pad_link (tmppad,
chain->encodebinpad) != GST_PAD_LINK_OK)) {
GST_WARNING_OBJECT (self, "Couldn't link track pad to playsink"); GST_WARNING_OBJECT (self, "Couldn't link track pad to playsink");
goto error; goto error;
} }
gst_object_unref (tmppad);
} }
@ -478,6 +486,7 @@ pad_removed_cb (GstElement * timeline, GstPad * pad, GESTimelinePipeline * self)
if (chain->encodebinpad) { if (chain->encodebinpad) {
peer = gst_pad_get_peer (chain->encodebinpad); peer = gst_pad_get_peer (chain->encodebinpad);
gst_pad_unlink (peer, chain->encodebinpad); gst_pad_unlink (peer, chain->encodebinpad);
gst_object_unref (peer);
gst_element_release_request_pad (self->encodebin, chain->encodebinpad); gst_element_release_request_pad (self->encodebin, chain->encodebinpad);
} }
@ -485,12 +494,15 @@ pad_removed_cb (GstElement * timeline, GstPad * pad, GESTimelinePipeline * self)
if (chain->playsinkpad) { if (chain->playsinkpad) {
peer = gst_pad_get_peer (chain->playsinkpad); peer = gst_pad_get_peer (chain->playsinkpad);
gst_pad_unlink (peer, chain->playsinkpad); gst_pad_unlink (peer, chain->playsinkpad);
gst_object_unref (peer);
gst_element_release_request_pad (self->playsink, chain->playsinkpad); gst_element_release_request_pad (self->playsink, chain->playsinkpad);
gst_object_unref (chain->playsinkpad);
} }
/* Unlike/remove tee */ /* Unlike/remove tee */
peer = gst_element_get_static_pad (chain->tee, "sink"); peer = gst_element_get_static_pad (chain->tee, "sink");
gst_pad_unlink (pad, peer); gst_pad_unlink (pad, peer);
gst_object_unref (peer);
gst_element_set_state (chain->tee, GST_STATE_NULL); gst_element_set_state (chain->tee, GST_STATE_NULL);
gst_bin_remove (GST_BIN (self), chain->tee); gst_bin_remove (GST_BIN (self), chain->tee);