From 87a3fa5595ae52504e350daa6fda01d4a252a7c4 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 21 Dec 2012 16:36:37 +0100 Subject: [PATCH] bin: add flag to disable resync state change Add a GST_BIN_FLAG_NO_RESYNC that disables a resync when an element is added, removed or linked in the bin. This is interesting for complex bins that dynamically add elements to themselves and want to manage the state of those elements without interference from resyncs. See https://bugzilla.gnome.org/show_bug.cgi?id=690420 --- gst/gstbin.c | 9 ++++++--- gst/gstbin.h | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/gst/gstbin.c b/gst/gstbin.c index 550b7d68fb..d53232c827 100644 --- a/gst/gstbin.c +++ b/gst/gstbin.c @@ -1126,7 +1126,8 @@ gst_bin_add_func (GstBin * bin, GstElement * element) bin->children = g_list_prepend (bin->children, element); bin->numchildren++; bin->children_cookie++; - bin->priv->structure_cookie++; + if (!GST_BIN_IS_NO_RESYNC (bin)) + bin->priv->structure_cookie++; /* distribute the bus */ gst_element_set_bus (element, bin->child_bus); @@ -1372,7 +1373,8 @@ gst_bin_remove_func (GstBin * bin, GstElement * element) * so that others can detect a change in the children list. */ bin->numchildren--; bin->children_cookie++; - bin->priv->structure_cookie++; + if (!GST_BIN_IS_NO_RESYNC (bin)) + bin->priv->structure_cookie++; if (is_sink && !othersink) { /* we're not a sink anymore */ @@ -3553,7 +3555,8 @@ gst_bin_handle_message_func (GstBin * bin, GstMessage * message) * need to resync by updating the structure_cookie. */ bin_remove_messages (bin, GST_MESSAGE_SRC (message), GST_MESSAGE_STRUCTURE_CHANGE); - bin->priv->structure_cookie++; + if (!GST_BIN_IS_NO_RESYNC (bin)) + bin->priv->structure_cookie++; } GST_OBJECT_UNLOCK (bin); diff --git a/gst/gstbin.h b/gst/gstbin.h index 6ae740407e..6f7f8c9fd1 100644 --- a/gst/gstbin.h +++ b/gst/gstbin.h @@ -40,6 +40,8 @@ G_BEGIN_DECLS /** * GstBinFlags: + * @GST_BIN_FLAG_NO_RESYNC: don't resync a state change when elements are + * added or linked in the bin. * @GST_BIN_FLAG_LAST: the last enum in the series of flags for bins. * Derived classes can use this as first value in a list of flags. * @@ -48,10 +50,22 @@ G_BEGIN_DECLS * and (un)set using GST_OBJECT_FLAG_SET () and GST_OBJECT_FLAG_UNSET (). */ typedef enum { + GST_BIN_FLAG_NO_RESYNC = (GST_ELEMENT_FLAG_LAST << 0), /* padding */ GST_BIN_FLAG_LAST = (GST_ELEMENT_FLAG_LAST << 5) } GstBinFlags; +/** + * GST_BIN_IS_NO_RESYNC: + * @bin: A #GstBin + * + * Check if @bin will resync its state change when elements are added and + * removed. + * + * Since: 1.1.1 + */ +#define GST_BIN_IS_NO_RESYNC(bin) (GST_OBJECT_FLAG_IS_SET(bin,GST_BIN_FLAG_NO_RESYNC)) + typedef struct _GstBin GstBin; typedef struct _GstBinClass GstBinClass; typedef struct _GstBinPrivate GstBinPrivate;