bin: iterate_sorted: Ensure sources are always returned last
authorEdward Hervey <edward@centricular.com>
Mon, 2 Oct 2017 15:59:17 +0000 (17:59 +0200)
committerEdward Hervey <bilboed@bilboed.com>
Tue, 3 Oct 2017 05:56:39 +0000 (07:56 +0200)
commitebad8c0094597c98447d8afb4ba73a757621359f
tree115d02669f4f53bb28e6a07a3b39f629a9feb746
parentbeab4c8e509f6b25f93cd870eac13d36565c35c2
bin: iterate_sorted: Ensure sources are always returned last

For linked elements, the resulting gst_bin_iterate_sorted() will
properly return elements from sink to sources.

If we have some elements that are not linked, we *still* want to
ensure that we return:
* In priority any sinks
* Last of all any sources
* And in between any element which is neither source nor sink

For this to work, when looking for the next candidate element,
not only check the degree order, but if there are two candidates
with the same degree order, prefer the non-source one.

Amongst other things, this fixes the case where we activating a
bin containing unlinked sources and other elements. Without this
we could end up activating sources (which might start adding pads
to be linked) before other (to which those new source element pads
might be linked) are not activated

https://bugzilla.gnome.org/show_bug.cgi?id=788434
gst/gstbin.c
tests/check/gst/gstbin.c