From 047fb95badd15bb27bcbb2321d0d3d651f6d1b85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Tue, 8 Jan 2008 20:48:00 +0000 Subject: [PATCH] gst/playback/gstdecodebin.c: Make sure we error out correctly if we can't activate one of the elements we've added. ... Original commit message from CVS: * gst/playback/gstdecodebin.c: (try_to_link_1): Make sure we error out correctly if we can't activate one of the elements we've added. Fixes #508138. --- ChangeLog | 6 ++++++ gst/playback/gstdecodebin.c | 24 ++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index ebaa69b1c8..4e0db436d1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-01-08 Tim-Philipp Müller + + * gst/playback/gstdecodebin.c: (try_to_link_1): + Make sure we error out correctly if we can't activate one of + the elements we've added. Fixes #508138. + 2008-01-07 Tim-Philipp Müller Patch by: Bastien Nocera diff --git a/gst/playback/gstdecodebin.c b/gst/playback/gstdecodebin.c index 792740685c..f4379878b1 100644 --- a/gst/playback/gstdecodebin.c +++ b/gst/playback/gstdecodebin.c @@ -939,7 +939,19 @@ try_to_link_1 (GstDecodeBin * decode_bin, GstElement * srcelement, GstPad * pad, gst_bin_add (GST_BIN (decode_bin), element); /* set to READY first so it is ready, duh. */ - gst_element_set_state (element, GST_STATE_READY); + if (gst_element_set_state (element, + GST_STATE_READY) == GST_STATE_CHANGE_FAILURE) { + GST_WARNING_OBJECT (decode_bin, "Couldn't set %s to READY", + GST_ELEMENT_NAME (element)); + /* get rid of the sinkpad */ + gst_object_unref (sinkpad); + /* this element did not work, remove it again and continue trying + * other elements, the element will be disposed. */ + /* FIXME: shouldn't we do this before adding it to the bin so that no + * error messages get through to the app? (tpm) */ + gst_bin_remove (GST_BIN (decode_bin), element); + continue; + } if ((ret = gst_pad_link (usedsrcpad, sinkpad)) != GST_PAD_LINK_OK) { GST_DEBUG_OBJECT (decode_bin, "link failed on pad %s:%s, reason %d", @@ -974,8 +986,16 @@ try_to_link_1 (GstDecodeBin * decode_bin, GstElement * srcelement, GstPad * pad, /* now that we added the element we can try to continue autoplugging * on it until we have a raw type */ close_link (element, decode_bin); + /* change the state of the element to that of the parent */ - gst_element_set_state (element, GST_STATE_PAUSED); + if ((gst_element_set_state (element, + GST_STATE_PAUSED)) == GST_STATE_CHANGE_FAILURE) { + GST_WARNING_OBJECT (decode_bin, "Couldn't set %s to PAUSED", + GST_ELEMENT_NAME (element)); + gst_element_set_state (element, GST_STATE_NULL); + gst_bin_remove (GST_BIN (decode_bin), element); + continue; + } result = element;