summaryrefslogtreecommitdiff
path: root/gst
diff options
context:
space:
mode:
authorStian Selnes <stian@pexip.com>2017-08-18 14:30:32 +0200
committerTim-Philipp Müller <tim@centricular.com>2017-11-24 13:40:31 +0100
commit512cec3deace3e50b3be7a24a29d9e6940675c18 (patch)
tree2c94c023ca399c4e637d71d0bd2f58280c17cfe8 /gst
parentdf27ec3e67a929b3d57ee791e5a8574812a498d9 (diff)
pad: gst_pad_activate_mode() always succeed if same mode
Checking that the pad is in the correct mode before the parent is checked makes the call always succeed if the mode is ok. This fixes a race with ghostpad where gst_pad_activate_mode() could trigger a g_critical() if the ghostpad is unparented while the proxypad is deactivating, for instance if the ghostpad is released. More specifically, gst_ghost_pad_internal_activate_push_default()'s call to gst_pad_activate_mode() would fail if ghostpad doesn't have a parent. With this patch it will return true of mode is already correct.
Diffstat (limited to 'gst')
-rw-r--r--gst/gstpad.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/gst/gstpad.c b/gst/gstpad.c
index 5cb3d1b9a..48dde245a 100644
--- a/gst/gstpad.c
+++ b/gst/gstpad.c
@@ -1303,11 +1303,19 @@ gst_pad_activate_mode (GstPad * pad, GstPadMode mode, gboolean active)
{
GstObject *parent;
gboolean res;
+ GstPadMode old, new;
g_return_val_if_fail (GST_IS_PAD (pad), FALSE);
GST_OBJECT_LOCK (pad);
+
+ old = GST_PAD_MODE (pad);
+ new = active ? mode : GST_PAD_MODE_NONE;
+ if (old == new)
+ goto was_ok;
+
ACQUIRE_PARENT (pad, parent, no_parent);
+
GST_OBJECT_UNLOCK (pad);
res = activate_mode_internal (pad, parent, mode, active);
@@ -1316,6 +1324,13 @@ gst_pad_activate_mode (GstPad * pad, GstPadMode mode, gboolean active)
return res;
+was_ok:
+ {
+ GST_OBJECT_UNLOCK (pad);
+ GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad, "already %s in %s mode",
+ active ? "activated" : "deactivated", gst_pad_mode_get_name (mode));
+ return TRUE;
+ }
no_parent:
{
GST_WARNING_OBJECT (pad, "no parent");