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
This commit is contained in:
Wim Taymans 2012-12-21 16:36:37 +01:00
parent bc54ec2677
commit b163c09104
2 changed files with 20 additions and 3 deletions

View file

@ -1126,6 +1126,7 @@ gst_bin_add_func (GstBin * bin, GstElement * element)
bin->children = g_list_prepend (bin->children, element); bin->children = g_list_prepend (bin->children, element);
bin->numchildren++; bin->numchildren++;
bin->children_cookie++; bin->children_cookie++;
if (!GST_BIN_IS_NO_RESYNC (bin))
bin->priv->structure_cookie++; bin->priv->structure_cookie++;
/* distribute the bus */ /* distribute the bus */
@ -1372,6 +1373,7 @@ gst_bin_remove_func (GstBin * bin, GstElement * element)
* so that others can detect a change in the children list. */ * so that others can detect a change in the children list. */
bin->numchildren--; bin->numchildren--;
bin->children_cookie++; bin->children_cookie++;
if (!GST_BIN_IS_NO_RESYNC (bin))
bin->priv->structure_cookie++; bin->priv->structure_cookie++;
if (is_sink && !othersink) { if (is_sink && !othersink) {
@ -3553,6 +3555,7 @@ gst_bin_handle_message_func (GstBin * bin, GstMessage * message)
* need to resync by updating the structure_cookie. */ * need to resync by updating the structure_cookie. */
bin_remove_messages (bin, GST_MESSAGE_SRC (message), bin_remove_messages (bin, GST_MESSAGE_SRC (message),
GST_MESSAGE_STRUCTURE_CHANGE); GST_MESSAGE_STRUCTURE_CHANGE);
if (!GST_BIN_IS_NO_RESYNC (bin))
bin->priv->structure_cookie++; bin->priv->structure_cookie++;
} }
GST_OBJECT_UNLOCK (bin); GST_OBJECT_UNLOCK (bin);

View file

@ -40,6 +40,8 @@ G_BEGIN_DECLS
/** /**
* GstBinFlags: * 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. * @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. * 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 (). * and (un)set using GST_OBJECT_FLAG_SET () and GST_OBJECT_FLAG_UNSET ().
*/ */
typedef enum { typedef enum {
GST_BIN_FLAG_NO_RESYNC = (GST_ELEMENT_FLAG_LAST << 0),
/* padding */ /* padding */
GST_BIN_FLAG_LAST = (GST_ELEMENT_FLAG_LAST << 5) GST_BIN_FLAG_LAST = (GST_ELEMENT_FLAG_LAST << 5)
} GstBinFlags; } 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 _GstBin GstBin;
typedef struct _GstBinClass GstBinClass; typedef struct _GstBinClass GstBinClass;
typedef struct _GstBinPrivate GstBinPrivate; typedef struct _GstBinPrivate GstBinPrivate;