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 committed by Tim-Philipp Müller
parent e8e0fc54e2
commit 87a3fa5595
2 changed files with 20 additions and 3 deletions

View 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);

View 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;