mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 19:51:11 +00:00
remove the "iterate_started" signal and replace it with pre_iterate and post_iterate callbacks.
Original commit message from CVS: remove the "iterate_started" signal and replace it with pre_iterate and post_iterate callbacks. Apps can now put a lock around an iterate so they can do stuff on the bin from another thread. much nicer than the signal approach.
This commit is contained in:
parent
0ce34c4a17
commit
a415cdd34e
2 changed files with 54 additions and 7 deletions
51
gst/gstbin.c
51
gst/gstbin.c
|
@ -59,7 +59,6 @@ static void gst_bin_restore_thyself (GstObject * object, xmlNodePtr self);
|
|||
enum
|
||||
{
|
||||
OBJECT_ADDED,
|
||||
ITERATE_STARTED,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
|
@ -114,10 +113,6 @@ gst_bin_class_init (GstBinClass * klass)
|
|||
g_signal_new ("object_added", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GstBinClass, object_added), NULL, NULL,
|
||||
gst_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER);
|
||||
gst_bin_signals[ITERATE_STARTED] =
|
||||
g_signal_new ("iterate_started", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GstBinClass, iterate_started), NULL, NULL,
|
||||
gst_marshal_VOID__VOID, G_TYPE_NONE, 0);
|
||||
|
||||
gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_bin_dispose);
|
||||
|
||||
|
@ -140,6 +135,11 @@ gst_bin_init (GstBin * bin)
|
|||
|
||||
bin->numchildren = 0;
|
||||
bin->children = NULL;
|
||||
|
||||
bin->pre_iterate_func = NULL;
|
||||
bin->post_iterate_func = NULL;
|
||||
bin->pre_iterate_private = NULL;
|
||||
bin->post_iterate_private = NULL;
|
||||
|
||||
bin->iterate_mutex = g_mutex_new ();
|
||||
bin->iterate_cond = g_cond_new ();
|
||||
|
@ -850,11 +850,15 @@ gst_bin_iterate (GstBin * bin)
|
|||
|
||||
oclass = GST_BIN_CLASS (G_OBJECT_GET_CLASS (bin));
|
||||
|
||||
g_signal_emit (G_OBJECT (bin), gst_bin_signals[ITERATE_STARTED], 0);
|
||||
if (bin->pre_iterate_func)
|
||||
(bin->pre_iterate_func) (bin, bin->pre_iterate_private);
|
||||
|
||||
if (oclass->iterate)
|
||||
running = (oclass->iterate) (bin);
|
||||
|
||||
if (bin->post_iterate_func)
|
||||
(bin->post_iterate_func) (bin, bin->post_iterate_private);
|
||||
|
||||
GST_DEBUG_LEAVE ("(\"%s\") %d", GST_ELEMENT_NAME (bin), running);
|
||||
|
||||
if (!running) {
|
||||
|
@ -869,3 +873,38 @@ gst_bin_iterate (GstBin * bin)
|
|||
|
||||
return running;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_bin_set_pre_iterate_function:
|
||||
* @bin: #Gstbin to attach to
|
||||
* @func: callback function to call
|
||||
* @func_data: private data to put in the function call
|
||||
*
|
||||
* Attaches a callback which will be run before every iteration of the bin
|
||||
*
|
||||
*/
|
||||
void
|
||||
gst_bin_set_pre_iterate_function (GstBin *bin, GstBinPrePostIterateFunction func, gpointer func_data)
|
||||
{
|
||||
g_return_if_fail (GST_IS_BIN (bin));
|
||||
bin->pre_iterate_func = func;
|
||||
bin->pre_iterate_private = func_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_bin_set_post_iterate_function:
|
||||
* @bin: #Gstbin to attach to
|
||||
* @func: callback function to call
|
||||
* @func_data: private data to put in the function call
|
||||
*
|
||||
* Attaches a callback which will be run after every iteration of the bin
|
||||
*
|
||||
*/
|
||||
void
|
||||
gst_bin_set_post_iterate_function (GstBin *bin, GstBinPrePostIterateFunction func, gpointer func_data)
|
||||
{
|
||||
g_return_if_fail (GST_IS_BIN (bin));
|
||||
bin->post_iterate_func = func;
|
||||
bin->post_iterate_private = func_data;
|
||||
}
|
||||
|
||||
|
|
10
gst/gstbin.h
10
gst/gstbin.h
|
@ -48,6 +48,8 @@ extern GType _gst_bin_type;
|
|||
# define GST_BIN_CLASS GST_BIN_CLASS_CAST
|
||||
#endif
|
||||
|
||||
typedef void (*GstBinPrePostIterateFunction) (GstBin *bin, gpointer data);
|
||||
|
||||
typedef enum {
|
||||
/* this bin is a manager of child elements, i.e. a pipeline or thread */
|
||||
GST_BIN_FLAG_MANAGER = GST_ELEMENT_FLAG_LAST,
|
||||
|
@ -80,6 +82,11 @@ struct _GstBin {
|
|||
GstElementState child_states[GST_NUM_STATES];
|
||||
|
||||
gpointer sched_private;
|
||||
|
||||
GstBinPrePostIterateFunction pre_iterate_func;
|
||||
GstBinPrePostIterateFunction post_iterate_func;
|
||||
gpointer pre_iterate_private;
|
||||
gpointer post_iterate_private;
|
||||
};
|
||||
|
||||
struct _GstBinClass {
|
||||
|
@ -88,7 +95,6 @@ struct _GstBinClass {
|
|||
/* signals */
|
||||
void (*object_added) (GstObject *object, GstObject *child);
|
||||
void (*object_removed) (GstObject *object, GstObject *child);
|
||||
void (*iterate_started) (GstObject *object);
|
||||
|
||||
/* change the state of elements of the given type */
|
||||
gboolean (*change_state_type) (GstBin *bin,
|
||||
|
@ -125,6 +131,8 @@ void gst_bin_auto_clock (GstBin *bin);
|
|||
void gst_bin_child_state_change (GstBin *bin, GstElementState oldstate,
|
||||
GstElementState newstate, GstElement *child);
|
||||
|
||||
void gst_bin_set_pre_iterate_function (GstBin *bin, GstBinPrePostIterateFunction func, gpointer func_data);
|
||||
void gst_bin_set_post_iterate_function (GstBin *bin, GstBinPrePostIterateFunction func, gpointer func_data);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
|
Loading…
Reference in a new issue