From: Thiago Santos Date: Mon, 10 Jan 2011 17:19:17 +0000 (-0300) Subject: outputselector: Improve get and set caps functions X-Git-Tag: RELEASE-0.10.32~19 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f5526595044467b72e5b360bc3752fe3be69a0a0;p=platform%2Fupstream%2Fgstreamer.git outputselector: Improve get and set caps functions Improve sink pad getcaps and setcaps by handling the case where no src pads exist yet --- diff --git a/plugins/elements/gstoutputselector.c b/plugins/elements/gstoutputselector.c index 9d2fbfe..9a4db2a 100644 --- a/plugins/elements/gstoutputselector.c +++ b/plugins/elements/gstoutputselector.c @@ -295,18 +295,20 @@ static GstCaps * gst_output_selector_sink_getcaps (GstPad * pad) { GstOutputSelector *sel = GST_OUTPUT_SELECTOR (GST_PAD_PARENT (pad)); - GstPad *active; - GstCaps *caps; + GstPad *active = NULL; + GstCaps *caps = NULL; GST_OBJECT_LOCK (sel); if (sel->pending_srcpad) active = gst_object_ref (sel->pending_srcpad); - else + else if (sel->active_srcpad) active = gst_object_ref (sel->active_srcpad); GST_OBJECT_UNLOCK (sel); - caps = gst_pad_peer_get_caps_reffed (active); - gst_object_unref (active); + if (active) { + caps = gst_pad_peer_get_caps_reffed (active); + gst_object_unref (active); + } if (caps == NULL) { caps = gst_caps_new_any (); } @@ -317,18 +319,20 @@ static gboolean gst_output_selector_sink_setcaps (GstPad * pad, GstCaps * caps) { GstOutputSelector *sel = GST_OUTPUT_SELECTOR (GST_PAD_PARENT (pad)); - GstPad *active; - gboolean ret; + GstPad *active = NULL; + gboolean ret = TRUE; GST_OBJECT_LOCK (sel); if (sel->pending_srcpad) active = gst_object_ref (sel->pending_srcpad); - else + else if (sel->active_srcpad) active = gst_object_ref (sel->active_srcpad); GST_OBJECT_UNLOCK (sel); - ret = gst_pad_set_caps (active, caps); - gst_object_unref (active); + if (active) { + ret = gst_pad_set_caps (active, caps); + gst_object_unref (active); + } return ret; }