mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-09-27 14:31:01 +00:00
bus: add GDestroyNotify to set_sync_handler()
This commit is contained in:
parent
d19f4117bc
commit
6efb5c9b6b
8 changed files with 47 additions and 13 deletions
|
@ -500,7 +500,8 @@ gst_bin_init (GstBin * bin)
|
||||||
bin->child_bus = bus;
|
bin->child_bus = bus;
|
||||||
GST_DEBUG_OBJECT (bin, "using bus %" GST_PTR_FORMAT " to listen to children",
|
GST_DEBUG_OBJECT (bin, "using bus %" GST_PTR_FORMAT " to listen to children",
|
||||||
bus);
|
bus);
|
||||||
gst_bus_set_sync_handler (bus, (GstBusSyncHandler) bin_bus_handler, bin);
|
gst_bus_set_sync_handler (bus, (GstBusSyncHandler) bin_bus_handler, bin,
|
||||||
|
NULL);
|
||||||
|
|
||||||
bin->priv = GST_BIN_GET_PRIVATE (bin);
|
bin->priv = GST_BIN_GET_PRIVATE (bin);
|
||||||
bin->priv->asynchandling = DEFAULT_ASYNC_HANDLING;
|
bin->priv->asynchandling = DEFAULT_ASYNC_HANDLING;
|
||||||
|
|
37
gst/gstbus.c
37
gst/gstbus.c
|
@ -100,6 +100,7 @@ enum
|
||||||
};
|
};
|
||||||
|
|
||||||
static void gst_bus_dispose (GObject * object);
|
static void gst_bus_dispose (GObject * object);
|
||||||
|
static void gst_bus_finalize (GObject * object);
|
||||||
|
|
||||||
static guint gst_bus_signals[LAST_SIGNAL] = { 0 };
|
static guint gst_bus_signals[LAST_SIGNAL] = { 0 };
|
||||||
|
|
||||||
|
@ -110,6 +111,7 @@ struct _GstBusPrivate
|
||||||
|
|
||||||
GstBusSyncHandler sync_handler;
|
GstBusSyncHandler sync_handler;
|
||||||
gpointer sync_handler_data;
|
gpointer sync_handler_data;
|
||||||
|
GDestroyNotify sync_handler_notify;
|
||||||
|
|
||||||
guint signal_watch_id;
|
guint signal_watch_id;
|
||||||
guint num_signal_watchers;
|
guint num_signal_watchers;
|
||||||
|
@ -158,6 +160,7 @@ gst_bus_class_init (GstBusClass * klass)
|
||||||
GObjectClass *gobject_class = (GObjectClass *) klass;
|
GObjectClass *gobject_class = (GObjectClass *) klass;
|
||||||
|
|
||||||
gobject_class->dispose = gst_bus_dispose;
|
gobject_class->dispose = gst_bus_dispose;
|
||||||
|
gobject_class->finalize = gst_bus_finalize;
|
||||||
gobject_class->set_property = gst_bus_set_property;
|
gobject_class->set_property = gst_bus_set_property;
|
||||||
gobject_class->constructed = gst_bus_constructed;
|
gobject_class->constructed = gst_bus_constructed;
|
||||||
|
|
||||||
|
@ -255,6 +258,17 @@ gst_bus_dispose (GObject * object)
|
||||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_bus_finalize (GObject * object)
|
||||||
|
{
|
||||||
|
GstBus *bus = GST_BUS (object);
|
||||||
|
|
||||||
|
if (bus->priv->sync_handler_notify)
|
||||||
|
bus->priv->sync_handler_notify (bus->priv->sync_handler_data);
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_bus_new:
|
* gst_bus_new:
|
||||||
*
|
*
|
||||||
|
@ -655,7 +669,8 @@ gst_bus_peek (GstBus * bus)
|
||||||
* gst_bus_set_sync_handler:
|
* gst_bus_set_sync_handler:
|
||||||
* @bus: a #GstBus to install the handler on
|
* @bus: a #GstBus to install the handler on
|
||||||
* @func: The handler function to install
|
* @func: The handler function to install
|
||||||
* @data: User data that will be sent to the handler function.
|
* @user_data: User data that will be sent to the handler function.
|
||||||
|
* @notify: called when @user_data becomes unused
|
||||||
*
|
*
|
||||||
* Sets the synchronous handler on the bus. The function will be called
|
* Sets the synchronous handler on the bus. The function will be called
|
||||||
* every time a new message is posted on the bus. Note that the function
|
* every time a new message is posted on the bus. Note that the function
|
||||||
|
@ -668,19 +683,33 @@ gst_bus_peek (GstBus * bus)
|
||||||
* function, which will clear the existing handler.
|
* function, which will clear the existing handler.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gst_bus_set_sync_handler (GstBus * bus, GstBusSyncHandler func, gpointer data)
|
gst_bus_set_sync_handler (GstBus * bus, GstBusSyncHandler func,
|
||||||
|
gpointer user_data, GDestroyNotify notify)
|
||||||
{
|
{
|
||||||
|
GDestroyNotify old_notify;
|
||||||
|
|
||||||
g_return_if_fail (GST_IS_BUS (bus));
|
g_return_if_fail (GST_IS_BUS (bus));
|
||||||
|
|
||||||
GST_OBJECT_LOCK (bus);
|
GST_OBJECT_LOCK (bus);
|
||||||
|
|
||||||
/* Assert if the user attempts to replace an existing sync_handler,
|
/* Assert if the user attempts to replace an existing sync_handler,
|
||||||
* other than to clear it */
|
* other than to clear it */
|
||||||
if (func != NULL && bus->priv->sync_handler != NULL)
|
if (func != NULL && bus->priv->sync_handler != NULL)
|
||||||
goto no_replace;
|
goto no_replace;
|
||||||
|
|
||||||
|
if ((old_notify = bus->priv->sync_handler_notify)) {
|
||||||
|
gpointer old_data = bus->priv->sync_handler_data;
|
||||||
|
|
||||||
|
bus->priv->sync_handler_data = NULL;
|
||||||
|
bus->priv->sync_handler_notify = NULL;
|
||||||
|
GST_OBJECT_UNLOCK (bus);
|
||||||
|
|
||||||
|
old_notify (old_data);
|
||||||
|
|
||||||
|
GST_OBJECT_LOCK (bus);
|
||||||
|
}
|
||||||
bus->priv->sync_handler = func;
|
bus->priv->sync_handler = func;
|
||||||
bus->priv->sync_handler_data = data;
|
bus->priv->sync_handler_data = user_data;
|
||||||
|
bus->priv->sync_handler_notify = notify;
|
||||||
GST_OBJECT_UNLOCK (bus);
|
GST_OBJECT_UNLOCK (bus);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -148,7 +148,7 @@ void gst_bus_set_flushing (GstBus * bus, gboolean
|
||||||
|
|
||||||
/* synchronous dispatching */
|
/* synchronous dispatching */
|
||||||
void gst_bus_set_sync_handler (GstBus * bus, GstBusSyncHandler func,
|
void gst_bus_set_sync_handler (GstBus * bus, GstBusSyncHandler func,
|
||||||
gpointer data);
|
gpointer user_data, GDestroyNotify notify);
|
||||||
/* GSource based dispatching */
|
/* GSource based dispatching */
|
||||||
GSource * gst_bus_create_watch (GstBus * bus);
|
GSource * gst_bus_create_watch (GstBus * bus);
|
||||||
guint gst_bus_add_watch_full (GstBus * bus,
|
guint gst_bus_add_watch_full (GstBus * bus,
|
||||||
|
|
|
@ -1074,7 +1074,8 @@ GST_START_TEST (test_async_done)
|
||||||
/* set bus on element synchronously listen for ASYNC_DONE */
|
/* set bus on element synchronously listen for ASYNC_DONE */
|
||||||
bus = gst_bus_new ();
|
bus = gst_bus_new ();
|
||||||
gst_element_set_bus (sink, bus);
|
gst_element_set_bus (sink, bus);
|
||||||
gst_bus_set_sync_handler (bus, (GstBusSyncHandler) async_done_func, sink);
|
gst_bus_set_sync_handler (bus, (GstBusSyncHandler) async_done_func, sink,
|
||||||
|
NULL);
|
||||||
|
|
||||||
/* make newsegment, this sets the position to 10sec when the buffer prerolls */
|
/* make newsegment, this sets the position to 10sec when the buffer prerolls */
|
||||||
GST_DEBUG ("sending segment");
|
GST_DEBUG ("sending segment");
|
||||||
|
@ -1183,7 +1184,8 @@ GST_START_TEST (test_async_done_eos)
|
||||||
/* set bus on element synchronously listen for ASYNC_DONE */
|
/* set bus on element synchronously listen for ASYNC_DONE */
|
||||||
bus = gst_bus_new ();
|
bus = gst_bus_new ();
|
||||||
gst_element_set_bus (sink, bus);
|
gst_element_set_bus (sink, bus);
|
||||||
gst_bus_set_sync_handler (bus, (GstBusSyncHandler) async_done_eos_func, sink);
|
gst_bus_set_sync_handler (bus, (GstBusSyncHandler) async_done_eos_func, sink,
|
||||||
|
NULL);
|
||||||
|
|
||||||
/* make newsegment, this sets the position to 10sec when the buffer prerolls */
|
/* make newsegment, this sets the position to 10sec when the buffer prerolls */
|
||||||
GST_DEBUG ("sending segment");
|
GST_DEBUG ("sending segment");
|
||||||
|
|
|
@ -989,7 +989,7 @@ GST_START_TEST (test_link_structure_change)
|
||||||
|
|
||||||
/* use the sync signal handler to link elements while the pipeline is still
|
/* use the sync signal handler to link elements while the pipeline is still
|
||||||
* doing the state change */
|
* doing the state change */
|
||||||
gst_bus_set_sync_handler (bus, gst_bus_sync_signal_handler, pipeline);
|
gst_bus_set_sync_handler (bus, gst_bus_sync_signal_handler, pipeline, NULL);
|
||||||
g_object_connect (bus, "signal::sync-message::state-changed",
|
g_object_connect (bus, "signal::sync-message::state-changed",
|
||||||
G_CALLBACK (test_link_structure_change_state_changed_sync_cb), pipeline,
|
G_CALLBACK (test_link_structure_change_state_changed_sync_cb), pipeline,
|
||||||
NULL);
|
NULL);
|
||||||
|
@ -1061,7 +1061,7 @@ GST_START_TEST (test_state_failure_remove)
|
||||||
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
|
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
|
||||||
fail_unless (bus != NULL, "Could not get bus");
|
fail_unless (bus != NULL, "Could not get bus");
|
||||||
|
|
||||||
gst_bus_set_sync_handler (bus, sync_handler_remove_sink, pipeline);
|
gst_bus_set_sync_handler (bus, sync_handler_remove_sink, pipeline, NULL);
|
||||||
|
|
||||||
ret = gst_element_set_state (pipeline, GST_STATE_READY);
|
ret = gst_element_set_state (pipeline, GST_STATE_READY);
|
||||||
fail_unless (ret == GST_STATE_CHANGE_SUCCESS,
|
fail_unless (ret == GST_STATE_CHANGE_SUCCESS,
|
||||||
|
|
|
@ -154,7 +154,8 @@ main (int argc, char *argv[])
|
||||||
|
|
||||||
/* get the bus, we need to install a sync handler */
|
/* get the bus, we need to install a sync handler */
|
||||||
bus = gst_pipeline_get_bus (GST_PIPELINE (bin));
|
bus = gst_pipeline_get_bus (GST_PIPELINE (bin));
|
||||||
gst_bus_set_sync_handler (bus, (GstBusSyncHandler) sync_bus_handler, bin);
|
gst_bus_set_sync_handler (bus, (GstBusSyncHandler) sync_bus_handler, bin,
|
||||||
|
NULL);
|
||||||
|
|
||||||
/* start playing */
|
/* start playing */
|
||||||
ret = gst_element_set_state (bin, GST_STATE_PLAYING);
|
ret = gst_element_set_state (bin, GST_STATE_PLAYING);
|
||||||
|
|
|
@ -130,7 +130,8 @@ main (int argc, char *argv[])
|
||||||
|
|
||||||
/* get the bus, we need to install a sync handler */
|
/* get the bus, we need to install a sync handler */
|
||||||
bus = gst_pipeline_get_bus (GST_PIPELINE (bin));
|
bus = gst_pipeline_get_bus (GST_PIPELINE (bin));
|
||||||
gst_bus_set_sync_handler (bus, (GstBusSyncHandler) sync_bus_handler, bin);
|
gst_bus_set_sync_handler (bus, (GstBusSyncHandler) sync_bus_handler, bin,
|
||||||
|
NULL);
|
||||||
|
|
||||||
/* start playing */
|
/* start playing */
|
||||||
gst_element_set_state (bin, GST_STATE_PLAYING);
|
gst_element_set_state (bin, GST_STATE_PLAYING);
|
||||||
|
|
|
@ -1041,7 +1041,7 @@ main (int argc, char *argv[])
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bus = gst_element_get_bus (pipeline);
|
bus = gst_element_get_bus (pipeline);
|
||||||
gst_bus_set_sync_handler (bus, bus_sync_handler, (gpointer) pipeline);
|
gst_bus_set_sync_handler (bus, bus_sync_handler, (gpointer) pipeline, NULL);
|
||||||
gst_object_unref (bus);
|
gst_object_unref (bus);
|
||||||
|
|
||||||
PRINT (_("Setting pipeline to PAUSED ...\n"));
|
PRINT (_("Setting pipeline to PAUSED ...\n"));
|
||||||
|
|
Loading…
Reference in a new issue