mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-31 03:29:50 +00:00
inputselector, outputselector: add guards for wrong pads being set as active pads
Catch users wrongly setting foreign pads or wrong pads as the selector's active pad, which leads to all kinds of other issues. It's a programming error so handle it just like we would if we had direct API. https://bugzilla.gnome.org/show_bug.cgi?id=795309
This commit is contained in:
parent
b27ee943c2
commit
65e0907798
2 changed files with 14 additions and 0 deletions
|
@ -1365,6 +1365,14 @@ gst_input_selector_set_active_pad (GstInputSelector * self, GstPad * pad)
|
||||||
if (pad == self->active_sinkpad)
|
if (pad == self->active_sinkpad)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
/* guard against users setting a src pad or foreign pad as active pad */
|
||||||
|
if (pad != NULL) {
|
||||||
|
g_return_val_if_fail (GST_PAD_IS_SINK (pad), FALSE);
|
||||||
|
g_return_val_if_fail (GST_IS_SELECTOR_PAD (pad), FALSE);
|
||||||
|
g_return_val_if_fail (GST_PAD_PARENT (pad) == GST_ELEMENT_CAST (self),
|
||||||
|
FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
old = GST_SELECTOR_PAD_CAST (self->active_sinkpad);
|
old = GST_SELECTOR_PAD_CAST (self->active_sinkpad);
|
||||||
new = GST_SELECTOR_PAD_CAST (pad);
|
new = GST_SELECTOR_PAD_CAST (pad);
|
||||||
|
|
||||||
|
|
|
@ -219,6 +219,12 @@ gst_output_selector_set_property (GObject * object, guint prop_id,
|
||||||
GST_INFO_OBJECT (sel, "Activating pad %s:%s",
|
GST_INFO_OBJECT (sel, "Activating pad %s:%s",
|
||||||
GST_DEBUG_PAD_NAME (next_pad));
|
GST_DEBUG_PAD_NAME (next_pad));
|
||||||
|
|
||||||
|
/* guard against users setting a sink pad or foreign pad as active pad */
|
||||||
|
if (next_pad != NULL) {
|
||||||
|
g_return_if_fail (GST_PAD_IS_SRC (next_pad));
|
||||||
|
g_return_if_fail (GST_PAD_PARENT (next_pad) == GST_ELEMENT_CAST (sel));
|
||||||
|
}
|
||||||
|
|
||||||
GST_OBJECT_LOCK (object);
|
GST_OBJECT_LOCK (object);
|
||||||
if (next_pad != sel->active_srcpad) {
|
if (next_pad != sel->active_srcpad) {
|
||||||
/* switch to new srcpad in next chain run */
|
/* switch to new srcpad in next chain run */
|
||||||
|
|
Loading…
Reference in a new issue