utils: speed up pad linking utility functions by not trying pads that will never work

In gst_element_get_compatible_pad(), when trying to find a compatible pad on an
element for a given pad, there's no point in checking the element's sink pads
if the pad to link is a sink pad as well, or the element's source pads if the
given pad is a source pad already, since those would never be able to link
anyway. Should speed up linking using the convenience functions a little bit,
or at least reduce debug log output.
This commit is contained in:
Tim-Philipp Müller 2010-08-05 10:04:47 +01:00
parent f547482e7c
commit 18ecca6331

View file

@ -1117,8 +1117,16 @@ gst_element_get_compatible_pad (GstElement * element, GstPad * pad,
g_return_val_if_fail (GST_PAD_PEER (pad) == NULL, NULL);
done = FALSE;
/* try to get an existing unlinked pad */
pads = gst_element_iterate_pads (element);
if (GST_PAD_IS_SRC (pad)) {
pads = gst_element_iterate_sink_pads (element);
} else if (GST_PAD_IS_SINK (pad)) {
pads = gst_element_iterate_src_pads (element);
} else {
pads = gst_element_iterate_pads (element);
}
while (!done) {
gpointer padptr;