Add new API: gst_pipeline_set_auto_flush_bus() and gst_pipeline_get_auto_flush_bus() to disable automatic flushing of...

Original commit message from CVS:
* docs/gst/gstreamer-sections.txt:
* gst/gstpipeline.c: (gst_pipeline_class_init),
(gst_pipeline_init), (gst_pipeline_set_property),
(gst_pipeline_get_property), (gst_pipeline_change_state),
(gst_pipeline_set_auto_flush_bus),
(gst_pipeline_get_auto_flush_bus):
* gst/gstpipeline.h:
Add new API: gst_pipeline_set_auto_flush_bus() and
gst_pipeline_get_auto_flush_bus() to disable automatic
flushing of the pipeline's GstBus when going from READY
to NULL state (#332045).
This commit is contained in:
Tim-Philipp Müller 2006-03-09 16:53:05 +00:00
parent 09bc0d93af
commit 3bced21cea
4 changed files with 120 additions and 4 deletions

View file

@ -1,3 +1,17 @@
2006-03-09 Tim-Philipp Müller <tim at centricular dot net>
* docs/gst/gstreamer-sections.txt:
* gst/gstpipeline.c: (gst_pipeline_class_init),
(gst_pipeline_init), (gst_pipeline_set_property),
(gst_pipeline_get_property), (gst_pipeline_change_state),
(gst_pipeline_set_auto_flush_bus),
(gst_pipeline_get_auto_flush_bus):
* gst/gstpipeline.h:
Add new API: gst_pipeline_set_auto_flush_bus() and
gst_pipeline_get_auto_flush_bus() to disable automatic
flushing of the pipeline's GstBus when going from READY
to NULL state (#332045).
2006-03-09 Tim-Philipp Müller <tim at centricular dot net>
* docs/gst/gstreamer-sections.txt:

View file

@ -1412,6 +1412,8 @@ gst_pipeline_set_clock
gst_pipeline_set_new_stream_time
gst_pipeline_use_clock
gst_pipeline_get_auto_flush_bus
gst_pipeline_set_auto_flush_bus
<SUBSECTION Standard>
GstPipelineClass
GST_PIPELINE
@ -1422,6 +1424,7 @@ GST_PIPELINE_GET_CLASS
GST_TYPE_PIPELINE
GST_TYPE_PIPELINE_FLAGS
<SUBSECTION Private>
GstPipelinePrivate
gst_pipeline_get_type
gst_pipeline_flags_get_type
</SECTION>

View file

@ -64,13 +64,23 @@ enum
LAST_SIGNAL
};
#define DEFAULT_DELAY 0
#define DEFAULT_DELAY 0
#define DEFAULT_AUTO_FLUSH_BUS TRUE
enum
{
PROP_0,
PROP_DELAY,
/* FILL ME */
PROP_AUTO_FLUSH_BUS
/* FILL ME */
};
#define GST_PIPELINE_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), GST_TYPE_PIPELINE, GstPipelinePrivate))
struct _GstPipelinePrivate
{
gboolean auto_flush_bus;
};
@ -137,6 +147,8 @@ gst_pipeline_class_init (gpointer g_class, gpointer class_data)
parent_class = g_type_class_peek_parent (klass);
g_type_class_add_private (klass, sizeof (GstPipelinePrivate));
gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_pipeline_set_property);
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_pipeline_get_property);
@ -146,6 +158,21 @@ gst_pipeline_class_init (gpointer g_class, gpointer class_data)
"to spin up to PLAYING in nanoseconds", 0, G_MAXUINT64, DEFAULT_DELAY,
G_PARAM_READWRITE));
/**
* GstPipeline:auto-flush-bus:
*
* Whether or not to automatically flush all messages on the
* pipeline's bus when going from READY to NULL state. Please see
* gst_pipeline_set_auto_flush_bus() for more information on this option.
*
* Since: 0.10.4
**/
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_AUTO_FLUSH_BUS,
g_param_spec_boolean ("auto-flush-bus", "Auto Flush Bus",
"Whether to automatically flush the pipeline's bus when going "
"from READY into NULL state", DEFAULT_AUTO_FLUSH_BUS,
G_PARAM_READWRITE));
gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_pipeline_dispose);
gstelement_class->send_event = GST_DEBUG_FUNCPTR (gst_pipeline_send_event);
@ -161,6 +188,9 @@ gst_pipeline_init (GTypeInstance * instance, gpointer g_class)
GstPipeline *pipeline = GST_PIPELINE (instance);
GstBus *bus;
pipeline->priv = GST_PIPELINE_GET_PRIVATE (pipeline);
pipeline->priv->auto_flush_bus = DEFAULT_AUTO_FLUSH_BUS;
pipeline->delay = DEFAULT_DELAY;
bus = gst_bus_new ();
@ -193,6 +223,9 @@ gst_pipeline_set_property (GObject * object, guint prop_id,
case PROP_DELAY:
pipeline->delay = g_value_get_uint64 (value);
break;
case PROP_AUTO_FLUSH_BUS:
pipeline->priv->auto_flush_bus = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -211,6 +244,9 @@ gst_pipeline_get_property (GObject * object, guint prop_id,
case PROP_DELAY:
g_value_set_uint64 (value, pipeline->delay);
break;
case PROP_AUTO_FLUSH_BUS:
g_value_set_boolean (value, pipeline->priv->auto_flush_bus);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -420,7 +456,11 @@ gst_pipeline_change_state (GstElement * element, GstStateChange transition)
case GST_STATE_CHANGE_READY_TO_NULL:
GST_OBJECT_LOCK (element);
if (element->bus) {
gst_bus_set_flushing (element->bus, TRUE);
if (pipeline->priv->auto_flush_bus) {
gst_bus_set_flushing (element->bus, TRUE);
} else {
GST_INFO_OBJECT (element, "not flushing bus, auto-flushing disabled");
}
}
GST_OBJECT_UNLOCK (element);
break;
@ -636,3 +676,57 @@ gst_pipeline_auto_clock (GstPipeline * pipeline)
GST_CAT_DEBUG (GST_CAT_CLOCK, "pipeline using automatic clock");
}
/**
* gst_pipeline_set_auto_flush_bus:
* @pipeline: a #GstPipeline
* @auto_flush: whether or not to automatically flush the bus when
* the pipeline goes from READY to NULL state
*
* Usually, when a pipeline goes from READY to NULL state, it automatically
* flushes all pending messages on the bus, which is done for refcounting
* purposes, to break circular references. This means that applications
* that update state using (async) bus messages (e.g. do certain things when a
* pipeline goes from PAUSED to READY) might not get to see messages when the
* pipeline is shut down, because they might be flushed before they can be
* dispatched in the main thread. This behaviour can be disabled using this
* function.
*
* MT safe.
*
* Since: 0.10.4
*/
void
gst_pipeline_set_auto_flush_bus (GstPipeline * pipeline, gboolean auto_flush)
{
g_return_if_fail (GST_IS_PIPELINE (pipeline));
GST_OBJECT_LOCK (pipeline);
pipeline->priv->auto_flush_bus = auto_flush;
GST_OBJECT_UNLOCK (pipeline);
}
/**
* gst_pipeline_get_auto_flush_bus:
* @pipeline: a #GstPipeline
*
* Returns: whether the pipeline will automatically flush its bus when
* going from READY to NULL state or not.
*
* MT safe.
*
* Since: 0.10.4
*/
gboolean
gst_pipeline_get_auto_flush_bus (GstPipeline * pipeline)
{
gboolean res;
g_return_val_if_fail (GST_IS_PIPELINE (pipeline), FALSE);
GST_OBJECT_LOCK (pipeline);
res = pipeline->priv->auto_flush_bus;
GST_OBJECT_UNLOCK (pipeline);
return res;
}

View file

@ -37,6 +37,7 @@ G_BEGIN_DECLS
typedef struct _GstPipeline GstPipeline;
typedef struct _GstPipelineClass GstPipelineClass;
typedef struct _GstPipelinePrivate GstPipelinePrivate;
/**
* GstPipelineFlags:
@ -70,7 +71,8 @@ struct _GstPipeline {
GstClockTime delay;
/*< private >*/
gpointer _gst_reserved[GST_PADDING];
GstPipelinePrivate *priv;
gpointer _gst_reserved[GST_PADDING-1];
};
struct _GstPipelineClass {
@ -93,6 +95,9 @@ gboolean gst_pipeline_set_clock (GstPipeline *pipeline, GstClock
GstClock* gst_pipeline_get_clock (GstPipeline *pipeline);
void gst_pipeline_auto_clock (GstPipeline *pipeline);
void gst_pipeline_set_auto_flush_bus (GstPipeline *pipeline, gboolean auto_flush);
gboolean gst_pipeline_get_auto_flush_bus (GstPipeline *pipeline);
G_END_DECLS
#endif /* __GST_PIPELINE_H__ */