bin: add flag to disable resync state change
authorWim Taymans <wim.taymans@collabora.co.uk>
Fri, 21 Dec 2012 15:36:37 +0000 (16:36 +0100)
committerTim-Philipp Müller <tim.muller@collabora.co.uk>
Fri, 4 Jan 2013 12:24:01 +0000 (12:24 +0000)
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
gst/gstbin.h

index 550b7d68fbe8f859ecf2b5736c7ed8dcfc424718..d53232c827060635b7d52be429a987af48f66b61 100644 (file)
@@ -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);
 
index 6ae740407e68fd2e46ddbac769f4b35867f6b818..6f7f8c9fd155f07c069a2f1c0b85bcebe46a0271 100644 (file)
@@ -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;