mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
inputselector: Use the first created pad by default
This guarantees a bit more consistency in which input stream will be selected by default. It would previously be the first pad on which an event/buffer/query was received ... which was racy and non-predictable.
This commit is contained in:
parent
7a89e5d046
commit
ea761a24b4
1 changed files with 18 additions and 6 deletions
|
@ -1586,12 +1586,24 @@ gst_input_selector_activate_sinkpad (GstInputSelector * sel, GstPad * pad)
|
|||
|
||||
selpad->active = TRUE;
|
||||
active_sinkpad = sel->active_sinkpad;
|
||||
if (active_sinkpad == NULL) {
|
||||
/* first pad we get activity on becomes the activated pad by default */
|
||||
if (sel->active_sinkpad)
|
||||
gst_object_unref (sel->active_sinkpad);
|
||||
active_sinkpad = sel->active_sinkpad = gst_object_ref (pad);
|
||||
GST_DEBUG_OBJECT (sel, "Activating pad %s:%s", GST_DEBUG_PAD_NAME (pad));
|
||||
if (sel->active_sinkpad == NULL) {
|
||||
GValue item = G_VALUE_INIT;
|
||||
GstIterator *iter = gst_element_iterate_sink_pads (GST_ELEMENT_CAST (sel));
|
||||
GstIteratorResult ires;
|
||||
|
||||
while ((ires = gst_iterator_next (iter, &item)) == GST_ITERATOR_RESYNC)
|
||||
gst_iterator_resync (iter);
|
||||
if (ires == GST_ITERATOR_OK) {
|
||||
/* If no pad is currently selected, we return the first usable pad to
|
||||
* guarantee consistency */
|
||||
|
||||
active_sinkpad = sel->active_sinkpad = g_value_dup_object (&item);
|
||||
g_value_reset (&item);
|
||||
GST_DEBUG_OBJECT (sel, "Activating pad %s:%s",
|
||||
GST_DEBUG_PAD_NAME (active_sinkpad));
|
||||
} else
|
||||
GST_WARNING_OBJECT (sel, "Couldn't find a default sink pad");
|
||||
gst_iterator_free (iter);
|
||||
}
|
||||
|
||||
return active_sinkpad;
|
||||
|
|
Loading…
Reference in a new issue