bin->child_bus = bus;
GST_DEBUG_OBJECT (bin, "using bus %" GST_PTR_FORMAT " to listen to children",
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->asynchandling = DEFAULT_ASYNC_HANDLING;
};
static void gst_bus_dispose (GObject * object);
+static void gst_bus_finalize (GObject * object);
static guint gst_bus_signals[LAST_SIGNAL] = { 0 };
GstBusSyncHandler sync_handler;
gpointer sync_handler_data;
+ GDestroyNotify sync_handler_notify;
guint signal_watch_id;
guint num_signal_watchers;
GObjectClass *gobject_class = (GObjectClass *) klass;
gobject_class->dispose = gst_bus_dispose;
+ gobject_class->finalize = gst_bus_finalize;
gobject_class->set_property = gst_bus_set_property;
gobject_class->constructed = gst_bus_constructed;
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_set_sync_handler:
* @bus: a #GstBus to install the handler on
* @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
* every time a new message is posted on the bus. Note that the function
* function, which will clear the existing handler.
*/
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));
GST_OBJECT_LOCK (bus);
-
/* Assert if the user attempts to replace an existing sync_handler,
* other than to clear it */
if (func != NULL && bus->priv->sync_handler != NULL)
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_data = data;
+ bus->priv->sync_handler_data = user_data;
+ bus->priv->sync_handler_notify = notify;
GST_OBJECT_UNLOCK (bus);
return;
/* synchronous dispatching */
void gst_bus_set_sync_handler (GstBus * bus, GstBusSyncHandler func,
- gpointer data);
+ gpointer user_data, GDestroyNotify notify);
/* GSource based dispatching */
GSource * gst_bus_create_watch (GstBus * bus);
guint gst_bus_add_watch_full (GstBus * bus,
/* set bus on element synchronously listen for ASYNC_DONE */
bus = gst_bus_new ();
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 */
GST_DEBUG ("sending segment");
/* set bus on element synchronously listen for ASYNC_DONE */
bus = gst_bus_new ();
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 */
GST_DEBUG ("sending segment");
/* use the sync signal handler to link elements while the pipeline is still
* 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_CALLBACK (test_link_structure_change_state_changed_sync_cb), pipeline,
NULL);
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
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);
fail_unless (ret == GST_STATE_CHANGE_SUCCESS,
/* get the bus, we need to install a sync handler */
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 */
ret = gst_element_set_state (bin, GST_STATE_PLAYING);
/* get the bus, we need to install a sync handler */
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 */
gst_element_set_state (bin, GST_STATE_PLAYING);
#endif
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);
PRINT (_("Setting pipeline to PAUSED ...\n"));