From 0fbf1d3eb7feaa753cf1d0ec03546f854dd1f037 Mon Sep 17 00:00:00 2001 From: Stian Selnes Date: Mon, 21 Sep 2015 15:22:19 +0200 Subject: [PATCH] bin: element: Ignore activate result for removed pads on state change This fixes a race where a state change may return failure if it has request pads that are deactivated and removed (and thus have no parent) at the same time as the element changes state and (de)activates its pads. https://bugzilla.gnome.org/show_bug.cgi?id=755342 --- gst/gstbin.c | 11 ++++++++--- gst/gstelement.c | 11 ++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/gst/gstbin.c b/gst/gstbin.c index 3f684bc4fb..9cea0b30e3 100644 --- a/gst/gstbin.c +++ b/gst/gstbin.c @@ -2371,15 +2371,20 @@ was_busy: } /* gst_iterator_fold functions for pads_activate - * Stop the iterator if activating one pad failed. */ + * Stop the iterator if activating one pad failed, but only if that pad + * has not been removed from the element. */ static gboolean activate_pads (const GValue * vpad, GValue * ret, gboolean * active) { GstPad *pad = g_value_get_object (vpad); gboolean cont = TRUE; - if (!(cont = gst_pad_set_active (pad, *active))) - g_value_set_boolean (ret, FALSE); + if (!gst_pad_set_active (pad, *active)) { + if (GST_PAD_PARENT (pad) != NULL) { + cont = FALSE; + g_value_set_boolean (ret, FALSE); + } + } return cont; } diff --git a/gst/gstelement.c b/gst/gstelement.c index c681194d5b..ccb3734088 100644 --- a/gst/gstelement.c +++ b/gst/gstelement.c @@ -2679,15 +2679,20 @@ invalid_return: } /* gst_iterator_fold functions for pads_activate - * Stop the iterator if activating one pad failed. */ + * Stop the iterator if activating one pad failed, but only if that pad + * has not been removed from the element. */ static gboolean activate_pads (const GValue * vpad, GValue * ret, gboolean * active) { GstPad *pad = g_value_get_object (vpad); gboolean cont = TRUE; - if (!(cont = gst_pad_set_active (pad, *active))) - g_value_set_boolean (ret, FALSE); + if (!gst_pad_set_active (pad, *active)) { + if (GST_PAD_PARENT (pad) != NULL) { + cont = FALSE; + g_value_set_boolean (ret, FALSE); + } + } return cont; }