outputselector: Improve get and set caps functions

Improve sink pad getcaps and setcaps by handling the case where
no src pads exist yet
This commit is contained in:
Thiago Santos 2011-01-10 14:19:17 -03:00
parent 39b0ba827a
commit f552659504

View file

@ -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;
}