2005-03-21 17:34:02 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 2004 Wim Taymans <wim@fluendo.com>
|
|
|
|
*
|
|
|
|
* gstbus.c: GstBus subsystem
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
2012-11-03 20:44:48 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2005-03-21 17:34:02 +00:00
|
|
|
*/
|
2005-10-15 16:01:57 +00:00
|
|
|
|
2005-08-23 14:25:55 +00:00
|
|
|
/**
|
|
|
|
* SECTION:gstbus
|
|
|
|
* @short_description: Asynchronous message bus subsystem
|
2005-08-27 10:57:00 +00:00
|
|
|
* @see_also: #GstMessage, #GstElement
|
|
|
|
*
|
2009-11-25 14:44:05 +00:00
|
|
|
* The #GstBus is an object responsible for delivering #GstMessage packets in
|
2009-12-14 14:22:16 +00:00
|
|
|
* a first-in first-out way from the streaming threads (see #GstTask) to the
|
|
|
|
* application.
|
2005-10-15 15:30:24 +00:00
|
|
|
*
|
2005-08-27 10:57:00 +00:00
|
|
|
* Since the application typically only wants to deal with delivery of these
|
|
|
|
* messages from one thread, the GstBus will marshall the messages between
|
|
|
|
* different threads. This is important since the actual streaming of media
|
|
|
|
* is done in another thread than the application.
|
2005-10-15 15:30:24 +00:00
|
|
|
*
|
2005-08-27 10:57:00 +00:00
|
|
|
* The GstBus provides support for #GSource based notifications. This makes it
|
|
|
|
* possible to handle the delivery in the glib mainloop.
|
2005-10-08 08:00:37 +00:00
|
|
|
*
|
|
|
|
* The #GSource callback function gst_bus_async_signal_func() can be used to
|
|
|
|
* convert all bus messages into signal emissions.
|
2005-10-15 15:30:24 +00:00
|
|
|
*
|
2005-08-27 10:57:00 +00:00
|
|
|
* A message is posted on the bus with the gst_bus_post() method. With the
|
2006-01-20 19:01:59 +00:00
|
|
|
* gst_bus_peek() and gst_bus_pop() methods one can look at or retrieve a
|
|
|
|
* previously posted message.
|
2005-10-15 15:30:24 +00:00
|
|
|
*
|
2005-08-27 10:57:00 +00:00
|
|
|
* The bus can be polled with the gst_bus_poll() method. This methods blocks
|
|
|
|
* up to the specified timeout value until one of the specified messages types
|
2009-11-25 14:44:05 +00:00
|
|
|
* is posted on the bus. The application can then gst_bus_pop() the messages
|
|
|
|
* from the bus to handle them.
|
2005-10-15 16:01:57 +00:00
|
|
|
* Alternatively the application can register an asynchronous bus function
|
|
|
|
* using gst_bus_add_watch_full() or gst_bus_add_watch(). This function will
|
2009-12-11 16:46:42 +00:00
|
|
|
* install a #GSource in the default glib main loop and will deliver messages
|
|
|
|
* a short while after they have been posted. Note that the main loop should
|
Documentation updates.
Original commit message from CVS:
* docs/gst/gstreamer-sections.txt:
* gst/gstbin.c: (bin_bus_handler), (gst_bin_handle_message_func):
* gst/gstbin.h:
* gst/gstbus.c: (gst_bus_class_init):
* gst/gstbus.h:
* gst/gstclock.c:
* gst/gstelement.c: (gst_element_set_locked_state):
* gst/gstsegment.c:
Documentation updates.
* gst/gstpipeline.c: (gst_pipeline_get_type),
(gst_pipeline_class_init), (gst_pipeline_init),
(gst_pipeline_dispose), (gst_pipeline_set_property),
(gst_pipeline_get_property), (do_pipeline_seek),
(gst_pipeline_send_event), (gst_pipeline_change_state),
(gst_pipeline_provide_clock_func), (gst_pipeline_set_delay),
(gst_pipeline_get_delay):
* gst/gstpipeline.h:
Added methods for setting the delay.
API: gst_pipeline_set_delay
API: gst_pipeline_get_delay
Add pipeline debug category
Various cleanups.
Updated docs.
Don't reset stream time when seek failed.
2006-03-13 11:04:38 +00:00
|
|
|
* be running for the asynchronous callbacks.
|
2005-10-15 15:30:24 +00:00
|
|
|
*
|
|
|
|
* It is also possible to get messages from the bus without any thread
|
2005-08-27 10:57:00 +00:00
|
|
|
* marshalling with the gst_bus_set_sync_handler() method. This makes it
|
|
|
|
* possible to react to a message in the same thread that posted the
|
|
|
|
* message on the bus. This should only be used if the application is able
|
|
|
|
* to deal with messages from different threads.
|
2005-08-31 10:00:08 +00:00
|
|
|
*
|
2005-10-08 08:00:37 +00:00
|
|
|
* Every #GstPipeline has one bus.
|
2005-09-23 18:02:18 +00:00
|
|
|
*
|
2005-10-15 16:01:57 +00:00
|
|
|
* Note that a #GstPipeline will set its bus into flushing state when changing
|
|
|
|
* from READY to NULL state.
|
2005-08-23 14:25:55 +00:00
|
|
|
*/
|
2005-03-21 17:34:02 +00:00
|
|
|
|
2006-05-04 15:20:14 +00:00
|
|
|
#include "gst_private.h"
|
2005-03-21 17:34:02 +00:00
|
|
|
#include <errno.h>
|
2005-10-12 22:34:47 +00:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
2005-03-21 17:34:02 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
|
2012-02-27 08:48:06 +00:00
|
|
|
#include "gstatomicqueue.h"
|
2005-03-21 17:34:02 +00:00
|
|
|
#include "gstinfo.h"
|
2010-10-28 12:27:43 +00:00
|
|
|
#include "gstpoll.h"
|
2005-03-21 17:34:02 +00:00
|
|
|
|
|
|
|
#include "gstbus.h"
|
2011-12-04 13:35:38 +00:00
|
|
|
#include "glib-compat-private.h"
|
2005-03-21 17:34:02 +00:00
|
|
|
|
2005-10-06 09:49:42 +00:00
|
|
|
#define GST_CAT_DEFAULT GST_CAT_BUS
|
2005-09-28 16:43:20 +00:00
|
|
|
/* bus signals */
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
SYNC_MESSAGE,
|
|
|
|
ASYNC_MESSAGE,
|
|
|
|
/* add more above */
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
2005-03-21 17:34:02 +00:00
|
|
|
|
2011-04-07 09:19:57 +00:00
|
|
|
#define DEFAULT_ENABLE_ASYNC (TRUE)
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
PROP_ENABLE_ASYNC
|
|
|
|
};
|
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
static void gst_bus_dispose (GObject * object);
|
2012-06-20 10:29:35 +00:00
|
|
|
static void gst_bus_finalize (GObject * object);
|
2005-03-21 17:34:02 +00:00
|
|
|
|
2005-09-28 16:43:20 +00:00
|
|
|
static guint gst_bus_signals[LAST_SIGNAL] = { 0 };
|
2005-03-21 17:34:02 +00:00
|
|
|
|
2006-02-10 16:04:59 +00:00
|
|
|
struct _GstBusPrivate
|
|
|
|
{
|
2012-02-26 15:32:32 +00:00
|
|
|
GstAtomicQueue *queue;
|
|
|
|
GMutex queue_lock;
|
|
|
|
|
|
|
|
GstBusSyncHandler sync_handler;
|
|
|
|
gpointer sync_handler_data;
|
2012-06-20 10:29:35 +00:00
|
|
|
GDestroyNotify sync_handler_notify;
|
2012-02-26 15:32:32 +00:00
|
|
|
|
|
|
|
guint num_signal_watchers;
|
|
|
|
|
2006-02-10 16:04:59 +00:00
|
|
|
guint num_sync_message_emitters;
|
2014-08-13 12:12:00 +00:00
|
|
|
GSource *signal_watch;
|
2010-10-28 12:27:43 +00:00
|
|
|
|
2011-04-07 09:19:57 +00:00
|
|
|
gboolean enable_async;
|
2010-10-28 12:27:43 +00:00
|
|
|
GstPoll *poll;
|
|
|
|
GPollFD pollfd;
|
2006-02-10 16:04:59 +00:00
|
|
|
};
|
|
|
|
|
2011-10-16 12:45:03 +00:00
|
|
|
#define gst_bus_parent_class parent_class
|
2009-04-04 08:18:42 +00:00
|
|
|
G_DEFINE_TYPE (GstBus, gst_bus, GST_TYPE_OBJECT);
|
2005-03-21 17:34:02 +00:00
|
|
|
|
2011-04-07 09:19:57 +00:00
|
|
|
static void
|
|
|
|
gst_bus_set_property (GObject * object,
|
|
|
|
guint prop_id, const GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
|
|
|
GstBus *bus = GST_BUS_CAST (object);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
case PROP_ENABLE_ASYNC:
|
|
|
|
bus->priv->enable_async = g_value_get_boolean (value);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_bus_constructed (GObject * object)
|
|
|
|
{
|
|
|
|
GstBus *bus = GST_BUS_CAST (object);
|
|
|
|
|
|
|
|
if (bus->priv->enable_async) {
|
|
|
|
bus->priv->poll = gst_poll_new_timer ();
|
|
|
|
gst_poll_get_read_gpollfd (bus->priv->poll, &bus->priv->pollfd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
static void
|
|
|
|
gst_bus_class_init (GstBusClass * klass)
|
|
|
|
{
|
2009-04-04 08:18:42 +00:00
|
|
|
GObjectClass *gobject_class = (GObjectClass *) klass;
|
2005-03-21 17:34:02 +00:00
|
|
|
|
2009-10-28 00:29:30 +00:00
|
|
|
gobject_class->dispose = gst_bus_dispose;
|
2012-06-20 10:29:35 +00:00
|
|
|
gobject_class->finalize = gst_bus_finalize;
|
2011-04-07 09:19:57 +00:00
|
|
|
gobject_class->set_property = gst_bus_set_property;
|
|
|
|
gobject_class->constructed = gst_bus_constructed;
|
|
|
|
|
2012-07-10 09:46:41 +00:00
|
|
|
/**
|
|
|
|
* GstBus::enable-async:
|
2011-04-07 09:19:57 +00:00
|
|
|
*
|
|
|
|
* Enable async message delivery support for bus watches,
|
|
|
|
* gst_bus_pop() and similar API. Without this only the
|
|
|
|
* synchronous message handlers are called.
|
|
|
|
*
|
|
|
|
* This property is used to create the child element buses
|
|
|
|
* in #GstBin.
|
|
|
|
*/
|
|
|
|
g_object_class_install_property (gobject_class, PROP_ENABLE_ASYNC,
|
|
|
|
g_param_spec_boolean ("enable-async", "Enable Async",
|
|
|
|
"Enable async message delivery for bus watches and gst_bus_pop()",
|
|
|
|
DEFAULT_ENABLE_ASYNC,
|
|
|
|
G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS));
|
2005-09-28 16:43:20 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* GstBus::sync-message:
|
|
|
|
* @bus: the object which received the signal
|
|
|
|
* @message: the message that has been posted synchronously
|
|
|
|
*
|
2005-11-03 12:16:49 +00:00
|
|
|
* A message has been posted on the bus. This signal is emitted from the
|
2006-06-21 10:01:58 +00:00
|
|
|
* thread that posted the message so one has to be careful with locking.
|
2006-10-03 19:13:36 +00:00
|
|
|
*
|
2013-04-05 19:10:48 +00:00
|
|
|
* This signal will not be emitted by default, you have to call
|
|
|
|
* gst_bus_enable_sync_message_emission() before.
|
2005-09-28 16:43:20 +00:00
|
|
|
*/
|
|
|
|
gst_bus_signals[SYNC_MESSAGE] =
|
|
|
|
g_signal_new ("sync-message", G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
|
|
|
|
G_STRUCT_OFFSET (GstBusClass, sync_message), NULL, NULL,
|
2012-03-02 10:05:48 +00:00
|
|
|
g_cclosure_marshal_generic, G_TYPE_NONE, 1, GST_TYPE_MESSAGE);
|
2005-09-28 16:43:20 +00:00
|
|
|
|
|
|
|
/**
|
check/gst/gstbin.c: Change for new bus API.
Original commit message from CVS:
* check/gst/gstbin.c: (GST_START_TEST):
Change for new bus API.
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
Change for new bus signal API.
* gst/gstbus.c: (gst_bus_class_init), (gst_bus_have_pending),
(gst_bus_source_prepare), (gst_bus_source_check),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (gst_bus_poll), (gst_bus_async_signal_func),
(gst_bus_sync_signal_handler), (gst_bus_add_signal_watch):
* gst/gstbus.h:
Remove support for multiple GSources operating on different
message types as it is too complex and unneeded when using
signals.
Added support for receiving signals from the bus.
2005-09-29 13:07:37 +00:00
|
|
|
* GstBus::message:
|
2005-09-28 16:43:20 +00:00
|
|
|
* @bus: the object which received the signal
|
|
|
|
* @message: the message that has been posted asynchronously
|
|
|
|
*
|
2005-11-03 12:16:49 +00:00
|
|
|
* A message has been posted on the bus. This signal is emitted from a
|
2006-06-21 10:01:58 +00:00
|
|
|
* GSource added to the mainloop. this signal will only be emitted when
|
Documentation updates.
Original commit message from CVS:
* docs/gst/gstreamer-sections.txt:
* gst/gstbin.c: (bin_bus_handler), (gst_bin_handle_message_func):
* gst/gstbin.h:
* gst/gstbus.c: (gst_bus_class_init):
* gst/gstbus.h:
* gst/gstclock.c:
* gst/gstelement.c: (gst_element_set_locked_state):
* gst/gstsegment.c:
Documentation updates.
* gst/gstpipeline.c: (gst_pipeline_get_type),
(gst_pipeline_class_init), (gst_pipeline_init),
(gst_pipeline_dispose), (gst_pipeline_set_property),
(gst_pipeline_get_property), (do_pipeline_seek),
(gst_pipeline_send_event), (gst_pipeline_change_state),
(gst_pipeline_provide_clock_func), (gst_pipeline_set_delay),
(gst_pipeline_get_delay):
* gst/gstpipeline.h:
Added methods for setting the delay.
API: gst_pipeline_set_delay
API: gst_pipeline_get_delay
Add pipeline debug category
Various cleanups.
Updated docs.
Don't reset stream time when seek failed.
2006-03-13 11:04:38 +00:00
|
|
|
* there is a mainloop running.
|
2005-09-28 16:43:20 +00:00
|
|
|
*/
|
|
|
|
gst_bus_signals[ASYNC_MESSAGE] =
|
check/gst/gstbin.c: Change for new bus API.
Original commit message from CVS:
* check/gst/gstbin.c: (GST_START_TEST):
Change for new bus API.
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
Change for new bus signal API.
* gst/gstbus.c: (gst_bus_class_init), (gst_bus_have_pending),
(gst_bus_source_prepare), (gst_bus_source_check),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (gst_bus_poll), (gst_bus_async_signal_func),
(gst_bus_sync_signal_handler), (gst_bus_add_signal_watch):
* gst/gstbus.h:
Remove support for multiple GSources operating on different
message types as it is too complex and unneeded when using
signals.
Added support for receiving signals from the bus.
2005-09-29 13:07:37 +00:00
|
|
|
g_signal_new ("message", G_TYPE_FROM_CLASS (klass),
|
2005-09-28 16:43:20 +00:00
|
|
|
G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
|
check/gst/gstbin.c: Change for new bus API.
Original commit message from CVS:
* check/gst/gstbin.c: (GST_START_TEST):
Change for new bus API.
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
Change for new bus signal API.
* gst/gstbus.c: (gst_bus_class_init), (gst_bus_have_pending),
(gst_bus_source_prepare), (gst_bus_source_check),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (gst_bus_poll), (gst_bus_async_signal_func),
(gst_bus_sync_signal_handler), (gst_bus_add_signal_watch):
* gst/gstbus.h:
Remove support for multiple GSources operating on different
message types as it is too complex and unneeded when using
signals.
Added support for receiving signals from the bus.
2005-09-29 13:07:37 +00:00
|
|
|
G_STRUCT_OFFSET (GstBusClass, message), NULL, NULL,
|
2012-03-02 10:05:48 +00:00
|
|
|
g_cclosure_marshal_generic, G_TYPE_NONE, 1, GST_TYPE_MESSAGE);
|
2005-11-04 11:43:10 +00:00
|
|
|
|
2006-02-10 16:04:59 +00:00
|
|
|
g_type_class_add_private (klass, sizeof (GstBusPrivate));
|
2005-03-21 17:34:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_bus_init (GstBus * bus)
|
|
|
|
{
|
2006-02-10 16:04:59 +00:00
|
|
|
bus->priv = G_TYPE_INSTANCE_GET_PRIVATE (bus, GST_TYPE_BUS, GstBusPrivate);
|
2011-04-07 09:19:57 +00:00
|
|
|
bus->priv->enable_async = DEFAULT_ENABLE_ASYNC;
|
2012-02-26 15:32:32 +00:00
|
|
|
g_mutex_init (&bus->priv->queue_lock);
|
|
|
|
bus->priv->queue = gst_atomic_queue_new (32);
|
2010-10-28 12:27:43 +00:00
|
|
|
|
2012-07-02 23:07:11 +00:00
|
|
|
/* clear floating flag */
|
|
|
|
gst_object_ref_sink (bus);
|
|
|
|
|
2005-07-09 15:18:53 +00:00
|
|
|
GST_DEBUG_OBJECT (bus, "created");
|
2005-03-21 17:34:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_bus_dispose (GObject * object)
|
|
|
|
{
|
2009-04-04 08:18:42 +00:00
|
|
|
GstBus *bus = GST_BUS (object);
|
2005-03-21 17:34:02 +00:00
|
|
|
|
2012-02-26 15:32:32 +00:00
|
|
|
if (bus->priv->queue) {
|
2005-08-26 13:28:01 +00:00
|
|
|
GstMessage *message;
|
|
|
|
|
2012-02-26 15:32:32 +00:00
|
|
|
g_mutex_lock (&bus->priv->queue_lock);
|
2005-08-26 13:28:01 +00:00
|
|
|
do {
|
2012-02-26 15:32:32 +00:00
|
|
|
message = gst_atomic_queue_pop (bus->priv->queue);
|
2005-08-26 13:28:01 +00:00
|
|
|
if (message)
|
|
|
|
gst_message_unref (message);
|
|
|
|
} while (message != NULL);
|
2012-02-26 15:32:32 +00:00
|
|
|
gst_atomic_queue_unref (bus->priv->queue);
|
|
|
|
bus->priv->queue = NULL;
|
|
|
|
g_mutex_unlock (&bus->priv->queue_lock);
|
|
|
|
g_mutex_clear (&bus->priv->queue_lock);
|
2005-03-21 17:34:02 +00:00
|
|
|
|
2011-04-06 12:06:49 +00:00
|
|
|
if (bus->priv->poll)
|
|
|
|
gst_poll_free (bus->priv->poll);
|
|
|
|
bus->priv->poll = NULL;
|
gst/gstbus.c: Make GstBusSource work with non-default main contexts (#562170).
Original commit message from CVS:
* gst/gstbus.c: (gst_bus_dispose), (gst_bus_get_property),
(gst_bus_wakeup_main_context), (gst_bus_set_main_context),
(gst_bus_post), (gst_bus_source_prepare), (gst_bus_source_finalize),
(gst_bus_create_watch):
Make GstBusSource work with non-default main contexts (#562170).
* tests/check/gst/gstbus.c: (message_func_eos), (message_func_app),
(test_watch), (test_watch_with_custom_context), (gst_bus_suite):
Add test case for GstBusSource with a non-default main context.
* tests/check/libs/.cvsignore:
Ignore more.
2008-12-27 17:41:11 +00:00
|
|
|
}
|
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
2012-06-20 10:29:35 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2005-08-23 14:25:55 +00:00
|
|
|
/**
|
|
|
|
* gst_bus_new:
|
|
|
|
*
|
2005-10-28 18:18:23 +00:00
|
|
|
* Creates a new #GstBus instance.
|
2005-08-23 14:25:55 +00:00
|
|
|
*
|
2010-12-07 18:35:04 +00:00
|
|
|
* Returns: (transfer full): a new #GstBus instance
|
2005-08-23 14:25:55 +00:00
|
|
|
*/
|
2005-03-21 17:34:02 +00:00
|
|
|
GstBus *
|
|
|
|
gst_bus_new (void)
|
|
|
|
{
|
|
|
|
GstBus *result;
|
|
|
|
|
2009-10-28 08:26:32 +00:00
|
|
|
result = g_object_newv (gst_bus_get_type (), 0, NULL);
|
2006-01-20 19:01:59 +00:00
|
|
|
GST_DEBUG_OBJECT (result, "created new bus");
|
2005-03-21 17:34:02 +00:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_bus_post:
|
|
|
|
* @bus: a #GstBus to post on
|
2010-12-07 18:35:04 +00:00
|
|
|
* @message: (transfer full): the #GstMessage to post
|
2005-03-21 17:34:02 +00:00
|
|
|
*
|
docs/design/part-events.txt: Small update.
Original commit message from CVS:
* docs/design/part-events.txt:
Small update.
* gst/base/gstbasesink.c: (gst_base_sink_handle_object),
(gst_base_sink_do_sync), (gst_base_sink_activate_push),
(gst_base_sink_activate_pull):
Some more comments.
* gst/elements/gstfakesrc.c: (gst_fake_src_class_init),
(gst_fake_src_create):
Fix handoff marshall.
* gst/elements/gstidentity.c: (gst_identity_class_init),
(gst_identity_transform_ip):
We're a real inplace element.
* gst/gstbus.c: (gst_bus_post):
Added some comments.
* tests/lat.c: (fakesrc), (fakesink), (simple), (queue), (main):
* tests/muxing/case1.c: (main):
* tests/sched/dynamic-pipeline.c: (main):
* tests/sched/interrupt1.c: (main):
* tests/sched/interrupt2.c: (main):
* tests/sched/interrupt3.c: (main):
* tests/sched/runxml.c: (main):
* tests/sched/sched-stress.c: (main):
* tests/seeking/seeking1.c: (event_received), (main):
* tests/threadstate/threadstate2.c: (bus_handler), (timeout_func),
(main):
* tests/threadstate/threadstate3.c: (main):
* tests/threadstate/threadstate4.c: (main):
* tests/threadstate/threadstate5.c: (main):
Fix the tests.
2005-07-22 11:47:10 +00:00
|
|
|
* Post a message on the given bus. Ownership of the message
|
|
|
|
* is taken by the bus.
|
2005-03-21 17:34:02 +00:00
|
|
|
*
|
2014-05-29 21:54:34 +00:00
|
|
|
* Returns: %TRUE if the message could be posted, %FALSE if the bus is flushing.
|
2005-03-21 17:34:02 +00:00
|
|
|
*
|
|
|
|
* MT safe.
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_bus_post (GstBus * bus, GstMessage * message)
|
|
|
|
{
|
|
|
|
GstBusSyncReply reply = GST_BUS_PASS;
|
|
|
|
GstBusSyncHandler handler;
|
2006-02-10 16:04:59 +00:00
|
|
|
gboolean emit_sync_message;
|
2005-03-21 17:34:02 +00:00
|
|
|
gpointer handler_data;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_BUS (bus), FALSE);
|
|
|
|
g_return_val_if_fail (GST_IS_MESSAGE (message), FALSE);
|
|
|
|
|
2011-05-11 13:48:15 +00:00
|
|
|
GST_DEBUG_OBJECT (bus, "[msg %p] posting on bus %" GST_PTR_FORMAT, message,
|
|
|
|
message);
|
2005-03-21 17:34:02 +00:00
|
|
|
|
2015-02-16 22:39:42 +00:00
|
|
|
/* check we didn't accidentally add a public flag that maps to same value */
|
|
|
|
g_assert (!GST_MINI_OBJECT_FLAG_IS_SET (message,
|
|
|
|
GST_MESSAGE_FLAG_ASYNC_DELIVERY));
|
|
|
|
|
2005-11-21 16:34:26 +00:00
|
|
|
GST_OBJECT_LOCK (bus);
|
2005-08-25 13:52:13 +00:00
|
|
|
/* check if the bus is flushing */
|
renamed GST_FLAGS macros to GST_OBJECT_FLAGS moved bitshift from macro to enum definition
Original commit message from CVS:
* check/gst/gstbin.c: (GST_START_TEST):
* docs/gst/gstreamer-sections.txt:
* gst/base/gstbasesink.c: (gst_base_sink_init):
* gst/base/gstbasesrc.c: (gst_base_src_init),
(gst_base_src_get_range), (gst_base_src_check_get_range),
(gst_base_src_start), (gst_base_src_stop):
* gst/base/gstbasesrc.h:
* gst/elements/gstfakesrc.c: (gst_fake_src_set_property):
* gst/gstbin.c: (gst_bin_add_func), (gst_bin_remove_func),
(bin_element_is_sink), (reset_degree), (gst_bin_element_set_state),
(bin_bus_handler):
* gst/gstbin.h:
* gst/gstbuffer.h:
* gst/gstbus.c: (gst_bus_post), (gst_bus_set_flushing):
* gst/gstbus.h:
* gst/gstelement.c: (gst_element_is_locked_state),
(gst_element_set_locked_state), (gst_element_commit_state),
(gst_element_set_state):
* gst/gstelement.h:
* gst/gstindex.c: (gst_index_init):
* gst/gstindex.h:
* gst/gstminiobject.h:
* gst/gstobject.c: (gst_object_init), (gst_object_sink),
(gst_object_set_parent):
* gst/gstobject.h:
* gst/gstpad.c: (gst_pad_set_blocked_async), (gst_pad_is_blocked),
(gst_pad_get_caps_unlocked), (gst_pad_set_caps):
* gst/gstpad.h:
* gst/gstpadtemplate.h:
* gst/gstpipeline.c: (gst_pipeline_provide_clock_func),
(gst_pipeline_use_clock), (gst_pipeline_auto_clock):
* gst/gstpipeline.h:
* gst/indexers/gstfileindex.c: (gst_file_index_load),
(gst_file_index_commit):
* testsuite/bytestream/filepadsink.c: (gst_fp_sink_init):
* testsuite/pad/link.c: (gst_test_src_init),
(gst_test_filter_init), (gst_test_sink_init):
* testsuite/states/locked.c: (main):
renamed GST_FLAGS macros to GST_OBJECT_FLAGS
moved bitshift from macro to enum definition
2005-10-12 14:28:39 +00:00
|
|
|
if (GST_OBJECT_FLAG_IS_SET (bus, GST_BUS_FLUSHING))
|
2005-08-25 13:52:13 +00:00
|
|
|
goto is_flushing;
|
2005-05-11 03:37:10 +00:00
|
|
|
|
2012-02-26 15:32:32 +00:00
|
|
|
handler = bus->priv->sync_handler;
|
|
|
|
handler_data = bus->priv->sync_handler_data;
|
2010-12-26 21:20:31 +00:00
|
|
|
emit_sync_message = bus->priv->num_sync_message_emitters > 0;
|
2005-11-21 16:34:26 +00:00
|
|
|
GST_OBJECT_UNLOCK (bus);
|
2005-03-21 17:34:02 +00:00
|
|
|
|
|
|
|
/* first call the sync handler if it is installed */
|
2005-08-25 13:52:13 +00:00
|
|
|
if (handler)
|
2005-03-21 17:34:02 +00:00
|
|
|
reply = handler (bus, message, handler_data);
|
|
|
|
|
2006-02-10 16:04:59 +00:00
|
|
|
/* emit sync-message if requested to do so via
|
|
|
|
gst_bus_enable_sync_message_emission. terrible but effective */
|
|
|
|
if (emit_sync_message && reply != GST_BUS_DROP
|
|
|
|
&& handler != gst_bus_sync_signal_handler)
|
|
|
|
gst_bus_sync_signal_handler (bus, message, NULL);
|
|
|
|
|
2011-04-07 09:24:35 +00:00
|
|
|
/* If this is a bus without async message delivery
|
|
|
|
* always drop the message */
|
|
|
|
if (!bus->priv->poll)
|
|
|
|
reply = GST_BUS_DROP;
|
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
/* now see what we should do with the message */
|
|
|
|
switch (reply) {
|
|
|
|
case GST_BUS_DROP:
|
|
|
|
/* drop the message */
|
2005-07-09 15:18:53 +00:00
|
|
|
GST_DEBUG_OBJECT (bus, "[msg %p] dropped", message);
|
2005-03-21 17:34:02 +00:00
|
|
|
break;
|
|
|
|
case GST_BUS_PASS:
|
docs/design/part-events.txt: Small update.
Original commit message from CVS:
* docs/design/part-events.txt:
Small update.
* gst/base/gstbasesink.c: (gst_base_sink_handle_object),
(gst_base_sink_do_sync), (gst_base_sink_activate_push),
(gst_base_sink_activate_pull):
Some more comments.
* gst/elements/gstfakesrc.c: (gst_fake_src_class_init),
(gst_fake_src_create):
Fix handoff marshall.
* gst/elements/gstidentity.c: (gst_identity_class_init),
(gst_identity_transform_ip):
We're a real inplace element.
* gst/gstbus.c: (gst_bus_post):
Added some comments.
* tests/lat.c: (fakesrc), (fakesink), (simple), (queue), (main):
* tests/muxing/case1.c: (main):
* tests/sched/dynamic-pipeline.c: (main):
* tests/sched/interrupt1.c: (main):
* tests/sched/interrupt2.c: (main):
* tests/sched/interrupt3.c: (main):
* tests/sched/runxml.c: (main):
* tests/sched/sched-stress.c: (main):
* tests/seeking/seeking1.c: (event_received), (main):
* tests/threadstate/threadstate2.c: (bus_handler), (timeout_func),
(main):
* tests/threadstate/threadstate3.c: (main):
* tests/threadstate/threadstate4.c: (main):
* tests/threadstate/threadstate5.c: (main):
Fix the tests.
2005-07-22 11:47:10 +00:00
|
|
|
/* pass the message to the async queue, refcount passed in the queue */
|
2005-07-09 15:18:53 +00:00
|
|
|
GST_DEBUG_OBJECT (bus, "[msg %p] pushing on async queue", message);
|
2012-02-26 15:32:32 +00:00
|
|
|
gst_atomic_queue_push (bus->priv->queue, message);
|
2011-04-07 09:24:35 +00:00
|
|
|
gst_poll_write_control (bus->priv->poll);
|
2005-07-09 15:18:53 +00:00
|
|
|
GST_DEBUG_OBJECT (bus, "[msg %p] pushed on async queue", message);
|
2005-03-21 17:34:02 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
case GST_BUS_ASYNC:
|
|
|
|
{
|
|
|
|
/* async delivery, we need a mutex and a cond to block
|
|
|
|
* on */
|
2012-01-19 08:27:04 +00:00
|
|
|
GCond *cond = GST_MESSAGE_GET_COND (message);
|
|
|
|
GMutex *lock = GST_MESSAGE_GET_LOCK (message);
|
2005-03-21 17:34:02 +00:00
|
|
|
|
2012-01-19 08:27:04 +00:00
|
|
|
g_cond_init (cond);
|
|
|
|
g_mutex_init (lock);
|
2005-03-21 17:34:02 +00:00
|
|
|
|
2015-02-16 22:39:42 +00:00
|
|
|
GST_MINI_OBJECT_FLAG_SET (message, GST_MESSAGE_FLAG_ASYNC_DELIVERY);
|
|
|
|
|
2005-07-09 15:18:53 +00:00
|
|
|
GST_DEBUG_OBJECT (bus, "[msg %p] waiting for async delivery", message);
|
2005-03-21 17:34:02 +00:00
|
|
|
|
|
|
|
/* now we lock the message mutex, send the message to the async
|
2005-07-09 15:18:53 +00:00
|
|
|
* queue. When the message is handled by the app and destroyed,
|
2005-03-21 17:34:02 +00:00
|
|
|
* the cond will be signalled and we can continue */
|
|
|
|
g_mutex_lock (lock);
|
|
|
|
|
2012-02-26 15:32:32 +00:00
|
|
|
gst_atomic_queue_push (bus->priv->queue, message);
|
2011-04-07 09:24:35 +00:00
|
|
|
gst_poll_write_control (bus->priv->poll);
|
2005-03-21 17:34:02 +00:00
|
|
|
|
|
|
|
/* now block till the message is freed */
|
|
|
|
g_cond_wait (cond, lock);
|
2015-02-16 22:39:42 +00:00
|
|
|
|
|
|
|
/* we acquired a new ref from gst_message_dispose() so we can clean up */
|
2005-03-21 17:34:02 +00:00
|
|
|
g_mutex_unlock (lock);
|
|
|
|
|
2005-07-09 15:18:53 +00:00
|
|
|
GST_DEBUG_OBJECT (bus, "[msg %p] delivered asynchronously", message);
|
2005-03-21 17:34:02 +00:00
|
|
|
|
2015-02-16 22:39:42 +00:00
|
|
|
GST_MINI_OBJECT_FLAG_UNSET (message, GST_MESSAGE_FLAG_ASYNC_DELIVERY);
|
|
|
|
|
2012-01-19 08:27:04 +00:00
|
|
|
g_mutex_clear (lock);
|
|
|
|
g_cond_clear (cond);
|
2015-02-16 22:39:42 +00:00
|
|
|
|
|
|
|
gst_message_unref (message);
|
2005-03-21 17:34:02 +00:00
|
|
|
break;
|
|
|
|
}
|
2005-08-25 13:52:13 +00:00
|
|
|
default:
|
|
|
|
g_warning ("invalid return from bus sync handler");
|
|
|
|
break;
|
2005-03-21 17:34:02 +00:00
|
|
|
}
|
|
|
|
return TRUE;
|
2005-08-25 13:52:13 +00:00
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
is_flushing:
|
|
|
|
{
|
|
|
|
GST_DEBUG_OBJECT (bus, "bus is flushing");
|
2005-11-21 16:34:26 +00:00
|
|
|
GST_OBJECT_UNLOCK (bus);
|
2015-03-13 13:42:46 +00:00
|
|
|
gst_message_unref (message);
|
2005-08-25 13:52:13 +00:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
2005-03-21 17:34:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_bus_have_pending:
|
|
|
|
* @bus: a #GstBus to check
|
|
|
|
*
|
check/gst/gstbin.c: Change for new bus API.
Original commit message from CVS:
* check/gst/gstbin.c: (GST_START_TEST):
Change for new bus API.
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
Change for new bus signal API.
* gst/gstbus.c: (gst_bus_class_init), (gst_bus_have_pending),
(gst_bus_source_prepare), (gst_bus_source_check),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (gst_bus_poll), (gst_bus_async_signal_func),
(gst_bus_sync_signal_handler), (gst_bus_add_signal_watch):
* gst/gstbus.h:
Remove support for multiple GSources operating on different
message types as it is too complex and unneeded when using
signals.
Added support for receiving signals from the bus.
2005-09-29 13:07:37 +00:00
|
|
|
* Check if there are pending messages on the bus that
|
GstBusHandler -> GstBusFunc, return value has the same meaning as any other GSource (FALSE == remove source).
Original commit message from CVS:
* check/gst/gstbin.c: (pop_messages), (GST_START_TEST):
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
* check/gst/gstpipeline.c: (GST_START_TEST):
* check/pipelines/cleanup.c: (run_pipeline):
* check/pipelines/simple_launch_lines.c: (run_pipeline),
(GST_START_TEST):
* gst/gstbus.c: (gst_bus_have_pending), (gst_bus_source_prepare),
(gst_bus_source_check), (gst_bus_source_dispatch),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (poll_func), (poll_timeout), (gst_bus_poll):
* gst/gstbus.h:
* tools/gst-launch.c: (event_loop):
* tools/gst-md5sum.c: (event_loop):
GstBusHandler -> GstBusFunc, return value has the same meaning as
any other GSource (FALSE == remove source).
_add_watch() and _add_watch_full() now take a MessageType mask to
only handle specific types of messages.
_poll() returns the GstMessage instead of the message type to avoid
race conditions.
_have_pending() takes a MessageType mask now too.
Added testsuite for multiple bus watches.
Fix testsuites and applications for new bus API.
2005-09-19 11:18:03 +00:00
|
|
|
* should be handled.
|
2005-03-21 17:34:02 +00:00
|
|
|
*
|
2014-05-29 21:54:34 +00:00
|
|
|
* Returns: %TRUE if there are messages on the bus to be handled, %FALSE
|
2005-10-28 18:18:23 +00:00
|
|
|
* otherwise.
|
2005-03-21 17:34:02 +00:00
|
|
|
*
|
|
|
|
* MT safe.
|
|
|
|
*/
|
|
|
|
gboolean
|
check/gst/gstbin.c: Change for new bus API.
Original commit message from CVS:
* check/gst/gstbin.c: (GST_START_TEST):
Change for new bus API.
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
Change for new bus signal API.
* gst/gstbus.c: (gst_bus_class_init), (gst_bus_have_pending),
(gst_bus_source_prepare), (gst_bus_source_check),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (gst_bus_poll), (gst_bus_async_signal_func),
(gst_bus_sync_signal_handler), (gst_bus_add_signal_watch):
* gst/gstbus.h:
Remove support for multiple GSources operating on different
message types as it is too complex and unneeded when using
signals.
Added support for receiving signals from the bus.
2005-09-29 13:07:37 +00:00
|
|
|
gst_bus_have_pending (GstBus * bus)
|
2005-03-21 17:34:02 +00:00
|
|
|
{
|
GstBusHandler -> GstBusFunc, return value has the same meaning as any other GSource (FALSE == remove source).
Original commit message from CVS:
* check/gst/gstbin.c: (pop_messages), (GST_START_TEST):
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
* check/gst/gstpipeline.c: (GST_START_TEST):
* check/pipelines/cleanup.c: (run_pipeline):
* check/pipelines/simple_launch_lines.c: (run_pipeline),
(GST_START_TEST):
* gst/gstbus.c: (gst_bus_have_pending), (gst_bus_source_prepare),
(gst_bus_source_check), (gst_bus_source_dispatch),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (poll_func), (poll_timeout), (gst_bus_poll):
* gst/gstbus.h:
* tools/gst-launch.c: (event_loop):
* tools/gst-md5sum.c: (event_loop):
GstBusHandler -> GstBusFunc, return value has the same meaning as
any other GSource (FALSE == remove source).
_add_watch() and _add_watch_full() now take a MessageType mask to
only handle specific types of messages.
_poll() returns the GstMessage instead of the message type to avoid
race conditions.
_have_pending() takes a MessageType mask now too.
Added testsuite for multiple bus watches.
Fix testsuites and applications for new bus API.
2005-09-19 11:18:03 +00:00
|
|
|
gboolean result;
|
2005-03-21 17:34:02 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_BUS (bus), FALSE);
|
|
|
|
|
check/gst/gstbin.c: Change for new bus API.
Original commit message from CVS:
* check/gst/gstbin.c: (GST_START_TEST):
Change for new bus API.
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
Change for new bus signal API.
* gst/gstbus.c: (gst_bus_class_init), (gst_bus_have_pending),
(gst_bus_source_prepare), (gst_bus_source_check),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (gst_bus_poll), (gst_bus_async_signal_func),
(gst_bus_sync_signal_handler), (gst_bus_add_signal_watch):
* gst/gstbus.h:
Remove support for multiple GSources operating on different
message types as it is too complex and unneeded when using
signals.
Added support for receiving signals from the bus.
2005-09-29 13:07:37 +00:00
|
|
|
/* see if there is a message on the bus */
|
2012-02-26 15:32:32 +00:00
|
|
|
result = gst_atomic_queue_length (bus->priv->queue) != 0;
|
2005-03-21 17:34:02 +00:00
|
|
|
|
GstBusHandler -> GstBusFunc, return value has the same meaning as any other GSource (FALSE == remove source).
Original commit message from CVS:
* check/gst/gstbin.c: (pop_messages), (GST_START_TEST):
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
* check/gst/gstpipeline.c: (GST_START_TEST):
* check/pipelines/cleanup.c: (run_pipeline):
* check/pipelines/simple_launch_lines.c: (run_pipeline),
(GST_START_TEST):
* gst/gstbus.c: (gst_bus_have_pending), (gst_bus_source_prepare),
(gst_bus_source_check), (gst_bus_source_dispatch),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (poll_func), (poll_timeout), (gst_bus_poll):
* gst/gstbus.h:
* tools/gst-launch.c: (event_loop):
* tools/gst-md5sum.c: (event_loop):
GstBusHandler -> GstBusFunc, return value has the same meaning as
any other GSource (FALSE == remove source).
_add_watch() and _add_watch_full() now take a MessageType mask to
only handle specific types of messages.
_poll() returns the GstMessage instead of the message type to avoid
race conditions.
_have_pending() takes a MessageType mask now too.
Added testsuite for multiple bus watches.
Fix testsuites and applications for new bus API.
2005-09-19 11:18:03 +00:00
|
|
|
return result;
|
2005-03-21 17:34:02 +00:00
|
|
|
}
|
|
|
|
|
2005-05-11 03:37:10 +00:00
|
|
|
/**
|
|
|
|
* gst_bus_set_flushing:
|
|
|
|
* @bus: a #GstBus
|
|
|
|
* @flushing: whether or not to flush the bus
|
|
|
|
*
|
|
|
|
* If @flushing, flush out and unref any messages queued in the bus. Releases
|
|
|
|
* references to the message origin objects. Will flush future messages until
|
2014-05-29 21:54:34 +00:00
|
|
|
* gst_bus_set_flushing() sets @flushing to %FALSE.
|
2005-05-11 03:37:10 +00:00
|
|
|
*
|
|
|
|
* MT safe.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_bus_set_flushing (GstBus * bus, gboolean flushing)
|
|
|
|
{
|
|
|
|
GstMessage *message;
|
2015-03-13 15:31:30 +00:00
|
|
|
GList *message_list = NULL;
|
2005-05-11 03:37:10 +00:00
|
|
|
|
2015-03-27 09:15:16 +00:00
|
|
|
g_return_if_fail (GST_IS_BUS (bus));
|
|
|
|
|
2005-11-21 16:34:26 +00:00
|
|
|
GST_OBJECT_LOCK (bus);
|
2005-05-11 03:37:10 +00:00
|
|
|
|
|
|
|
if (flushing) {
|
renamed GST_FLAGS macros to GST_OBJECT_FLAGS moved bitshift from macro to enum definition
Original commit message from CVS:
* check/gst/gstbin.c: (GST_START_TEST):
* docs/gst/gstreamer-sections.txt:
* gst/base/gstbasesink.c: (gst_base_sink_init):
* gst/base/gstbasesrc.c: (gst_base_src_init),
(gst_base_src_get_range), (gst_base_src_check_get_range),
(gst_base_src_start), (gst_base_src_stop):
* gst/base/gstbasesrc.h:
* gst/elements/gstfakesrc.c: (gst_fake_src_set_property):
* gst/gstbin.c: (gst_bin_add_func), (gst_bin_remove_func),
(bin_element_is_sink), (reset_degree), (gst_bin_element_set_state),
(bin_bus_handler):
* gst/gstbin.h:
* gst/gstbuffer.h:
* gst/gstbus.c: (gst_bus_post), (gst_bus_set_flushing):
* gst/gstbus.h:
* gst/gstelement.c: (gst_element_is_locked_state),
(gst_element_set_locked_state), (gst_element_commit_state),
(gst_element_set_state):
* gst/gstelement.h:
* gst/gstindex.c: (gst_index_init):
* gst/gstindex.h:
* gst/gstminiobject.h:
* gst/gstobject.c: (gst_object_init), (gst_object_sink),
(gst_object_set_parent):
* gst/gstobject.h:
* gst/gstpad.c: (gst_pad_set_blocked_async), (gst_pad_is_blocked),
(gst_pad_get_caps_unlocked), (gst_pad_set_caps):
* gst/gstpad.h:
* gst/gstpadtemplate.h:
* gst/gstpipeline.c: (gst_pipeline_provide_clock_func),
(gst_pipeline_use_clock), (gst_pipeline_auto_clock):
* gst/gstpipeline.h:
* gst/indexers/gstfileindex.c: (gst_file_index_load),
(gst_file_index_commit):
* testsuite/bytestream/filepadsink.c: (gst_fp_sink_init):
* testsuite/pad/link.c: (gst_test_src_init),
(gst_test_filter_init), (gst_test_sink_init):
* testsuite/states/locked.c: (main):
renamed GST_FLAGS macros to GST_OBJECT_FLAGS
moved bitshift from macro to enum definition
2005-10-12 14:28:39 +00:00
|
|
|
GST_OBJECT_FLAG_SET (bus, GST_BUS_FLUSHING);
|
2005-05-11 03:37:10 +00:00
|
|
|
|
2005-07-29 15:34:52 +00:00
|
|
|
GST_DEBUG_OBJECT (bus, "set bus flushing");
|
2005-06-28 19:45:26 +00:00
|
|
|
|
2005-05-11 03:37:10 +00:00
|
|
|
while ((message = gst_bus_pop (bus)))
|
2015-03-13 13:28:42 +00:00
|
|
|
message_list = g_list_prepend (message_list, message);
|
2005-05-11 03:37:10 +00:00
|
|
|
} else {
|
2005-07-29 15:34:52 +00:00
|
|
|
GST_DEBUG_OBJECT (bus, "unset bus flushing");
|
renamed GST_FLAGS macros to GST_OBJECT_FLAGS moved bitshift from macro to enum definition
Original commit message from CVS:
* check/gst/gstbin.c: (GST_START_TEST):
* docs/gst/gstreamer-sections.txt:
* gst/base/gstbasesink.c: (gst_base_sink_init):
* gst/base/gstbasesrc.c: (gst_base_src_init),
(gst_base_src_get_range), (gst_base_src_check_get_range),
(gst_base_src_start), (gst_base_src_stop):
* gst/base/gstbasesrc.h:
* gst/elements/gstfakesrc.c: (gst_fake_src_set_property):
* gst/gstbin.c: (gst_bin_add_func), (gst_bin_remove_func),
(bin_element_is_sink), (reset_degree), (gst_bin_element_set_state),
(bin_bus_handler):
* gst/gstbin.h:
* gst/gstbuffer.h:
* gst/gstbus.c: (gst_bus_post), (gst_bus_set_flushing):
* gst/gstbus.h:
* gst/gstelement.c: (gst_element_is_locked_state),
(gst_element_set_locked_state), (gst_element_commit_state),
(gst_element_set_state):
* gst/gstelement.h:
* gst/gstindex.c: (gst_index_init):
* gst/gstindex.h:
* gst/gstminiobject.h:
* gst/gstobject.c: (gst_object_init), (gst_object_sink),
(gst_object_set_parent):
* gst/gstobject.h:
* gst/gstpad.c: (gst_pad_set_blocked_async), (gst_pad_is_blocked),
(gst_pad_get_caps_unlocked), (gst_pad_set_caps):
* gst/gstpad.h:
* gst/gstpadtemplate.h:
* gst/gstpipeline.c: (gst_pipeline_provide_clock_func),
(gst_pipeline_use_clock), (gst_pipeline_auto_clock):
* gst/gstpipeline.h:
* gst/indexers/gstfileindex.c: (gst_file_index_load),
(gst_file_index_commit):
* testsuite/bytestream/filepadsink.c: (gst_fp_sink_init):
* testsuite/pad/link.c: (gst_test_src_init),
(gst_test_filter_init), (gst_test_sink_init):
* testsuite/states/locked.c: (main):
renamed GST_FLAGS macros to GST_OBJECT_FLAGS
moved bitshift from macro to enum definition
2005-10-12 14:28:39 +00:00
|
|
|
GST_OBJECT_FLAG_UNSET (bus, GST_BUS_FLUSHING);
|
2005-05-11 03:37:10 +00:00
|
|
|
}
|
|
|
|
|
2005-11-21 16:34:26 +00:00
|
|
|
GST_OBJECT_UNLOCK (bus);
|
2015-03-13 13:28:42 +00:00
|
|
|
|
2015-03-13 15:31:30 +00:00
|
|
|
g_list_free_full (message_list, (GDestroyNotify) gst_message_unref);
|
2005-05-11 03:37:10 +00:00
|
|
|
}
|
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
/**
|
2007-10-16 20:30:13 +00:00
|
|
|
* gst_bus_timed_pop_filtered:
|
|
|
|
* @bus: a #GstBus to pop from
|
|
|
|
* @timeout: a timeout in nanoseconds, or GST_CLOCK_TIME_NONE to wait forever
|
|
|
|
* @types: message types to take into account, GST_MESSAGE_ANY for any type
|
2005-03-21 17:34:02 +00:00
|
|
|
*
|
2007-10-16 20:30:13 +00:00
|
|
|
* Get a message from the bus whose type matches the message type mask @types,
|
|
|
|
* waiting up to the specified timeout (and discarding any messages that do not
|
|
|
|
* match the mask provided).
|
2005-03-21 17:34:02 +00:00
|
|
|
*
|
2007-10-16 20:30:13 +00:00
|
|
|
* If @timeout is 0, this function behaves like gst_bus_pop_filtered(). If
|
|
|
|
* @timeout is #GST_CLOCK_TIME_NONE, this function will block forever until a
|
|
|
|
* matching message was posted on the bus.
|
2007-02-27 17:22:07 +00:00
|
|
|
*
|
2014-06-11 22:21:34 +00:00
|
|
|
* Returns: (transfer full) (nullable): a #GstMessage matching the
|
|
|
|
* filter in @types, or %NULL if no matching message was found on
|
|
|
|
* the bus until the timeout expired. The message is taken from
|
|
|
|
* the bus and needs to be unreffed with gst_message_unref() after
|
|
|
|
* usage.
|
2005-03-21 17:34:02 +00:00
|
|
|
*
|
|
|
|
* MT safe.
|
|
|
|
*/
|
|
|
|
GstMessage *
|
2007-10-16 20:30:13 +00:00
|
|
|
gst_bus_timed_pop_filtered (GstBus * bus, GstClockTime timeout,
|
|
|
|
GstMessageType types)
|
2005-03-21 17:34:02 +00:00
|
|
|
{
|
|
|
|
GstMessage *message;
|
2010-10-28 12:27:43 +00:00
|
|
|
GTimeVal now, then;
|
2007-10-16 20:30:13 +00:00
|
|
|
gboolean first_round = TRUE;
|
2011-04-27 16:10:55 +00:00
|
|
|
GstClockTime elapsed = 0;
|
2005-03-21 17:34:02 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_BUS (bus), NULL);
|
2007-10-16 20:30:13 +00:00
|
|
|
g_return_val_if_fail (types != 0, NULL);
|
2011-04-20 13:39:16 +00:00
|
|
|
g_return_val_if_fail (timeout == 0 || bus->priv->poll != NULL, NULL);
|
2005-03-21 17:34:02 +00:00
|
|
|
|
2012-02-26 15:32:32 +00:00
|
|
|
g_mutex_lock (&bus->priv->queue_lock);
|
2007-10-16 20:30:13 +00:00
|
|
|
|
2007-02-27 17:22:07 +00:00
|
|
|
while (TRUE) {
|
2010-10-28 12:27:43 +00:00
|
|
|
gint ret;
|
|
|
|
|
|
|
|
GST_LOG_OBJECT (bus, "have %d messages",
|
2012-02-26 15:32:32 +00:00
|
|
|
gst_atomic_queue_length (bus->priv->queue));
|
2007-10-16 20:30:13 +00:00
|
|
|
|
2012-02-26 15:32:32 +00:00
|
|
|
while ((message = gst_atomic_queue_pop (bus->priv->queue))) {
|
2011-04-20 13:39:16 +00:00
|
|
|
if (bus->priv->poll)
|
|
|
|
gst_poll_read_control (bus->priv->poll);
|
2011-11-23 16:39:43 +00:00
|
|
|
|
2011-10-18 12:08:19 +00:00
|
|
|
GST_DEBUG_OBJECT (bus, "got message %p, %s from %s, type mask is %u",
|
|
|
|
message, GST_MESSAGE_TYPE_NAME (message),
|
2011-12-01 15:25:07 +00:00
|
|
|
GST_MESSAGE_SRC_NAME (message), (guint) types);
|
2007-10-16 20:30:13 +00:00
|
|
|
if ((GST_MESSAGE_TYPE (message) & types) != 0) {
|
2014-03-16 19:29:27 +00:00
|
|
|
/* Extra check to ensure extended types don't get matched unless
|
|
|
|
* asked for */
|
2014-11-28 13:17:54 +00:00
|
|
|
if ((!GST_MESSAGE_TYPE_IS_EXTENDED (message))
|
2014-03-16 19:29:27 +00:00
|
|
|
|| (types & GST_MESSAGE_EXTENDED)) {
|
|
|
|
/* exit the loop, we have a message */
|
|
|
|
goto beach;
|
|
|
|
}
|
2007-10-16 20:30:13 +00:00
|
|
|
}
|
2014-03-16 19:29:27 +00:00
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (bus, "discarding message, does not match mask");
|
|
|
|
gst_message_unref (message);
|
|
|
|
message = NULL;
|
2007-10-16 20:30:13 +00:00
|
|
|
}
|
2007-02-27 17:22:07 +00:00
|
|
|
|
2007-10-16 20:30:13 +00:00
|
|
|
/* no need to wait, exit loop */
|
|
|
|
if (timeout == 0)
|
|
|
|
break;
|
2007-02-27 17:22:07 +00:00
|
|
|
|
2010-10-28 12:27:43 +00:00
|
|
|
else if (timeout != GST_CLOCK_TIME_NONE) {
|
|
|
|
if (first_round) {
|
|
|
|
g_get_current_time (&then);
|
|
|
|
first_round = FALSE;
|
|
|
|
} else {
|
|
|
|
g_get_current_time (&now);
|
|
|
|
|
|
|
|
elapsed = GST_TIMEVAL_TO_TIME (now) - GST_TIMEVAL_TO_TIME (then);
|
2011-04-27 16:10:55 +00:00
|
|
|
|
|
|
|
if (elapsed > timeout)
|
|
|
|
break;
|
2010-10-28 12:27:43 +00:00
|
|
|
}
|
2007-10-16 20:30:13 +00:00
|
|
|
}
|
2010-10-28 12:27:43 +00:00
|
|
|
|
2011-04-20 13:39:16 +00:00
|
|
|
/* only here in timeout case */
|
|
|
|
g_assert (bus->priv->poll);
|
2012-02-26 15:32:32 +00:00
|
|
|
g_mutex_unlock (&bus->priv->queue_lock);
|
2011-04-27 16:10:55 +00:00
|
|
|
ret = gst_poll_wait (bus->priv->poll, timeout - elapsed);
|
2012-02-26 15:32:32 +00:00
|
|
|
g_mutex_lock (&bus->priv->queue_lock);
|
2010-10-28 12:27:43 +00:00
|
|
|
|
|
|
|
if (ret == 0) {
|
2007-10-16 20:30:13 +00:00
|
|
|
GST_INFO_OBJECT (bus, "timed out, breaking loop");
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
GST_INFO_OBJECT (bus, "we got woken up, recheck for message");
|
2007-02-27 17:22:07 +00:00
|
|
|
}
|
|
|
|
}
|
2007-10-16 20:30:13 +00:00
|
|
|
|
|
|
|
beach:
|
|
|
|
|
2012-02-26 15:32:32 +00:00
|
|
|
g_mutex_unlock (&bus->priv->queue_lock);
|
2005-06-28 19:45:26 +00:00
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
return message;
|
|
|
|
}
|
|
|
|
|
2007-10-16 20:30:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_bus_timed_pop:
|
|
|
|
* @bus: a #GstBus to pop
|
|
|
|
* @timeout: a timeout
|
|
|
|
*
|
|
|
|
* Get a message from the bus, waiting up to the specified timeout.
|
|
|
|
*
|
|
|
|
* If @timeout is 0, this function behaves like gst_bus_pop(). If @timeout is
|
|
|
|
* #GST_CLOCK_TIME_NONE, this function will block forever until a message was
|
|
|
|
* posted on the bus.
|
|
|
|
*
|
2014-06-11 22:21:34 +00:00
|
|
|
* Returns: (transfer full) (nullable): the #GstMessage that is on the
|
|
|
|
* bus after the specified timeout or %NULL if the bus is empty
|
|
|
|
* after the timeout expired. The message is taken from the bus
|
|
|
|
* and needs to be unreffed with gst_message_unref() after usage.
|
2007-10-16 20:30:13 +00:00
|
|
|
*
|
|
|
|
* MT safe.
|
|
|
|
*/
|
|
|
|
GstMessage *
|
|
|
|
gst_bus_timed_pop (GstBus * bus, GstClockTime timeout)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GST_IS_BUS (bus), NULL);
|
|
|
|
|
|
|
|
return gst_bus_timed_pop_filtered (bus, timeout, GST_MESSAGE_ANY);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_bus_pop_filtered:
|
|
|
|
* @bus: a #GstBus to pop
|
|
|
|
* @types: message types to take into account
|
|
|
|
*
|
|
|
|
* Get a message matching @type from the bus. Will discard all messages on
|
|
|
|
* the bus that do not match @type and that have been posted before the first
|
|
|
|
* message that does match @type. If there is no message matching @type on
|
2014-03-16 14:08:00 +00:00
|
|
|
* the bus, all messages will be discarded. It is not possible to use message
|
|
|
|
* enums beyond #GST_MESSAGE_EXTENDED in the @events mask.
|
2007-10-16 20:30:13 +00:00
|
|
|
*
|
2014-06-11 22:21:34 +00:00
|
|
|
* Returns: (transfer full) (nullable): the next #GstMessage matching
|
|
|
|
* @type that is on the bus, or %NULL if the bus is empty or there
|
|
|
|
* is no message matching @type. The message is taken from the bus
|
|
|
|
* and needs to be unreffed with gst_message_unref() after usage.
|
2007-10-16 20:30:13 +00:00
|
|
|
*
|
|
|
|
* MT safe.
|
|
|
|
*/
|
|
|
|
GstMessage *
|
|
|
|
gst_bus_pop_filtered (GstBus * bus, GstMessageType types)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GST_IS_BUS (bus), NULL);
|
|
|
|
g_return_val_if_fail (types != 0, NULL);
|
|
|
|
|
|
|
|
return gst_bus_timed_pop_filtered (bus, 0, types);
|
|
|
|
}
|
|
|
|
|
2007-02-27 17:22:07 +00:00
|
|
|
/**
|
|
|
|
* gst_bus_pop:
|
|
|
|
* @bus: a #GstBus to pop
|
|
|
|
*
|
|
|
|
* Get a message from the bus.
|
|
|
|
*
|
2014-06-11 22:21:34 +00:00
|
|
|
* Returns: (transfer full) (nullable): the #GstMessage that is on the
|
|
|
|
* bus, or %NULL if the bus is empty. The message is taken from
|
|
|
|
* the bus and needs to be unreffed with gst_message_unref() after
|
|
|
|
* usage.
|
2007-02-27 17:22:07 +00:00
|
|
|
*
|
|
|
|
* MT safe.
|
|
|
|
*/
|
|
|
|
GstMessage *
|
|
|
|
gst_bus_pop (GstBus * bus)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GST_IS_BUS (bus), NULL);
|
|
|
|
|
2007-10-16 20:30:13 +00:00
|
|
|
return gst_bus_timed_pop_filtered (bus, 0, GST_MESSAGE_ANY);
|
2007-02-27 17:22:07 +00:00
|
|
|
}
|
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
/**
|
|
|
|
* gst_bus_peek:
|
|
|
|
* @bus: a #GstBus
|
|
|
|
*
|
2005-10-15 15:30:24 +00:00
|
|
|
* Peek the message on the top of the bus' queue. The message will remain
|
2005-09-01 18:12:18 +00:00
|
|
|
* on the bus' message queue. A reference is returned, and needs to be unreffed
|
2005-07-29 15:34:52 +00:00
|
|
|
* by the caller.
|
2005-03-21 17:34:02 +00:00
|
|
|
*
|
2014-06-11 22:21:34 +00:00
|
|
|
* Returns: (transfer full) (nullable): the #GstMessage that is on the
|
|
|
|
* bus, or %NULL if the bus is empty.
|
2005-03-21 17:34:02 +00:00
|
|
|
*
|
|
|
|
* MT safe.
|
|
|
|
*/
|
|
|
|
GstMessage *
|
|
|
|
gst_bus_peek (GstBus * bus)
|
|
|
|
{
|
|
|
|
GstMessage *message;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_BUS (bus), NULL);
|
|
|
|
|
2012-02-26 15:32:32 +00:00
|
|
|
g_mutex_lock (&bus->priv->queue_lock);
|
|
|
|
message = gst_atomic_queue_peek (bus->priv->queue);
|
2005-07-29 15:34:52 +00:00
|
|
|
if (message)
|
|
|
|
gst_message_ref (message);
|
2012-02-26 15:32:32 +00:00
|
|
|
g_mutex_unlock (&bus->priv->queue_lock);
|
2005-03-21 17:34:02 +00:00
|
|
|
|
2005-07-29 15:34:52 +00:00
|
|
|
GST_DEBUG_OBJECT (bus, "peek on bus, got message %p", message);
|
2005-06-28 19:45:26 +00:00
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
return message;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_bus_set_sync_handler:
|
|
|
|
* @bus: a #GstBus to install the handler on
|
2012-08-07 08:46:17 +00:00
|
|
|
* @func: (allow-none): The handler function to install
|
2012-06-20 10:29:35 +00:00
|
|
|
* @user_data: User data that will be sent to the handler function.
|
|
|
|
* @notify: called when @user_data becomes unused
|
2005-03-21 17:34:02 +00:00
|
|
|
*
|
2005-08-18 15:31:28 +00:00
|
|
|
* Sets the synchronous handler on the bus. The function will be called
|
2005-03-21 17:34:02 +00:00
|
|
|
* every time a new message is posted on the bus. Note that the function
|
2005-08-18 15:31:28 +00:00
|
|
|
* will be called in the same thread context as the posting object. This
|
|
|
|
* function is usually only called by the creator of the bus. Applications
|
|
|
|
* should handle messages asynchronously using the gst_bus watch and poll
|
|
|
|
* functions.
|
2005-11-04 12:08:19 +00:00
|
|
|
*
|
2014-05-29 21:54:34 +00:00
|
|
|
* You cannot replace an existing sync_handler. You can pass %NULL to this
|
2005-11-04 12:08:19 +00:00
|
|
|
* function, which will clear the existing handler.
|
2005-03-21 17:34:02 +00:00
|
|
|
*/
|
|
|
|
void
|
2012-06-20 10:29:35 +00:00
|
|
|
gst_bus_set_sync_handler (GstBus * bus, GstBusSyncHandler func,
|
|
|
|
gpointer user_data, GDestroyNotify notify)
|
2005-03-21 17:34:02 +00:00
|
|
|
{
|
2012-06-20 10:29:35 +00:00
|
|
|
GDestroyNotify old_notify;
|
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
g_return_if_fail (GST_IS_BUS (bus));
|
|
|
|
|
2005-11-21 16:34:26 +00:00
|
|
|
GST_OBJECT_LOCK (bus);
|
2005-08-18 15:31:28 +00:00
|
|
|
/* Assert if the user attempts to replace an existing sync_handler,
|
|
|
|
* other than to clear it */
|
2012-02-26 15:32:32 +00:00
|
|
|
if (func != NULL && bus->priv->sync_handler != NULL)
|
2005-11-04 12:08:19 +00:00
|
|
|
goto no_replace;
|
2005-08-18 15:31:28 +00:00
|
|
|
|
2012-06-20 10:29:35 +00:00
|
|
|
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);
|
|
|
|
}
|
2012-02-26 15:32:32 +00:00
|
|
|
bus->priv->sync_handler = func;
|
2012-06-20 10:29:35 +00:00
|
|
|
bus->priv->sync_handler_data = user_data;
|
|
|
|
bus->priv->sync_handler_notify = notify;
|
2005-11-21 16:34:26 +00:00
|
|
|
GST_OBJECT_UNLOCK (bus);
|
2005-11-04 12:08:19 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
no_replace:
|
|
|
|
{
|
2005-11-21 16:34:26 +00:00
|
|
|
GST_OBJECT_UNLOCK (bus);
|
2005-11-04 12:08:19 +00:00
|
|
|
g_warning ("cannot replace existing sync handler");
|
|
|
|
return;
|
|
|
|
}
|
2005-03-21 17:34:02 +00:00
|
|
|
}
|
|
|
|
|
2005-05-26 10:48:53 +00:00
|
|
|
/* GSource for the bus
|
2005-03-21 17:34:02 +00:00
|
|
|
*/
|
2005-05-26 10:48:53 +00:00
|
|
|
typedef struct
|
2005-03-21 17:34:02 +00:00
|
|
|
{
|
2005-05-26 10:48:53 +00:00
|
|
|
GSource source;
|
|
|
|
GstBus *bus;
|
|
|
|
} GstBusSource;
|
2005-03-21 17:34:02 +00:00
|
|
|
|
2005-06-28 19:45:26 +00:00
|
|
|
static gboolean
|
2005-05-26 10:48:53 +00:00
|
|
|
gst_bus_source_prepare (GSource * source, gint * timeout)
|
|
|
|
{
|
|
|
|
*timeout = -1;
|
2010-10-28 12:27:43 +00:00
|
|
|
return FALSE;
|
2005-03-21 17:34:02 +00:00
|
|
|
}
|
|
|
|
|
2005-06-28 19:45:26 +00:00
|
|
|
static gboolean
|
2005-05-26 10:48:53 +00:00
|
|
|
gst_bus_source_check (GSource * source)
|
2005-03-21 17:34:02 +00:00
|
|
|
{
|
GstBusHandler -> GstBusFunc, return value has the same meaning as any other GSource (FALSE == remove source).
Original commit message from CVS:
* check/gst/gstbin.c: (pop_messages), (GST_START_TEST):
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
* check/gst/gstpipeline.c: (GST_START_TEST):
* check/pipelines/cleanup.c: (run_pipeline):
* check/pipelines/simple_launch_lines.c: (run_pipeline),
(GST_START_TEST):
* gst/gstbus.c: (gst_bus_have_pending), (gst_bus_source_prepare),
(gst_bus_source_check), (gst_bus_source_dispatch),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (poll_func), (poll_timeout), (gst_bus_poll):
* gst/gstbus.h:
* tools/gst-launch.c: (event_loop):
* tools/gst-md5sum.c: (event_loop):
GstBusHandler -> GstBusFunc, return value has the same meaning as
any other GSource (FALSE == remove source).
_add_watch() and _add_watch_full() now take a MessageType mask to
only handle specific types of messages.
_poll() returns the GstMessage instead of the message type to avoid
race conditions.
_have_pending() takes a MessageType mask now too.
Added testsuite for multiple bus watches.
Fix testsuites and applications for new bus API.
2005-09-19 11:18:03 +00:00
|
|
|
GstBusSource *bsrc = (GstBusSource *) source;
|
|
|
|
|
2010-10-28 12:27:43 +00:00
|
|
|
return bsrc->bus->priv->pollfd.revents & (G_IO_IN | G_IO_HUP | G_IO_ERR);
|
2005-05-26 10:48:53 +00:00
|
|
|
}
|
2005-03-21 17:34:02 +00:00
|
|
|
|
2005-06-28 19:45:26 +00:00
|
|
|
static gboolean
|
2005-05-26 10:48:53 +00:00
|
|
|
gst_bus_source_dispatch (GSource * source, GSourceFunc callback,
|
|
|
|
gpointer user_data)
|
2005-03-21 17:34:02 +00:00
|
|
|
{
|
GstBusHandler -> GstBusFunc, return value has the same meaning as any other GSource (FALSE == remove source).
Original commit message from CVS:
* check/gst/gstbin.c: (pop_messages), (GST_START_TEST):
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
* check/gst/gstpipeline.c: (GST_START_TEST):
* check/pipelines/cleanup.c: (run_pipeline):
* check/pipelines/simple_launch_lines.c: (run_pipeline),
(GST_START_TEST):
* gst/gstbus.c: (gst_bus_have_pending), (gst_bus_source_prepare),
(gst_bus_source_check), (gst_bus_source_dispatch),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (poll_func), (poll_timeout), (gst_bus_poll):
* gst/gstbus.h:
* tools/gst-launch.c: (event_loop):
* tools/gst-md5sum.c: (event_loop):
GstBusHandler -> GstBusFunc, return value has the same meaning as
any other GSource (FALSE == remove source).
_add_watch() and _add_watch_full() now take a MessageType mask to
only handle specific types of messages.
_poll() returns the GstMessage instead of the message type to avoid
race conditions.
_have_pending() takes a MessageType mask now too.
Added testsuite for multiple bus watches.
Fix testsuites and applications for new bus API.
2005-09-19 11:18:03 +00:00
|
|
|
GstBusFunc handler = (GstBusFunc) callback;
|
2005-05-26 10:48:53 +00:00
|
|
|
GstBusSource *bsource = (GstBusSource *) source;
|
2005-03-21 17:34:02 +00:00
|
|
|
GstMessage *message;
|
GstBusHandler -> GstBusFunc, return value has the same meaning as any other GSource (FALSE == remove source).
Original commit message from CVS:
* check/gst/gstbin.c: (pop_messages), (GST_START_TEST):
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
* check/gst/gstpipeline.c: (GST_START_TEST):
* check/pipelines/cleanup.c: (run_pipeline):
* check/pipelines/simple_launch_lines.c: (run_pipeline),
(GST_START_TEST):
* gst/gstbus.c: (gst_bus_have_pending), (gst_bus_source_prepare),
(gst_bus_source_check), (gst_bus_source_dispatch),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (poll_func), (poll_timeout), (gst_bus_poll):
* gst/gstbus.h:
* tools/gst-launch.c: (event_loop):
* tools/gst-md5sum.c: (event_loop):
GstBusHandler -> GstBusFunc, return value has the same meaning as
any other GSource (FALSE == remove source).
_add_watch() and _add_watch_full() now take a MessageType mask to
only handle specific types of messages.
_poll() returns the GstMessage instead of the message type to avoid
race conditions.
_have_pending() takes a MessageType mask now too.
Added testsuite for multiple bus watches.
Fix testsuites and applications for new bus API.
2005-09-19 11:18:03 +00:00
|
|
|
gboolean keep;
|
docs/design/: Some more docs in the works.
Original commit message from CVS:
* docs/design/part-dynamic.txt:
* docs/design/part-events.txt:
* docs/design/part-seeking.txt:
Some more docs in the works.
* gst/base/gstbasetransform.c: (gst_base_transform_transform_caps),
(gst_base_transform_getcaps), (gst_base_transform_configure_caps),
(gst_base_transform_setcaps), (gst_base_transform_get_size),
(gst_base_transform_buffer_alloc), (gst_base_transform_event),
(gst_base_transform_handle_buffer),
(gst_base_transform_sink_activate_push),
(gst_base_transform_src_activate_pull),
(gst_base_transform_set_passthrough),
(gst_base_transform_is_passthrough):
Refcounting fixes.
* gst/gstbus.c: (gst_bus_source_dispatch), (gst_bus_poll):
Cleanups.
* gst/gstevent.c: (gst_event_finalize):
Set SRC to NULL.
* gst/gstutils.c: (gst_element_unlink),
(gst_pad_get_parent_element), (gst_pad_proxy_getcaps),
(gst_pad_proxy_setcaps):
* gst/gstutils.h:
Add _get_parent_element() to get a pads parent as an element.
2005-07-18 08:28:48 +00:00
|
|
|
GstBus *bus;
|
|
|
|
|
|
|
|
g_return_val_if_fail (bsource != NULL, FALSE);
|
2005-03-21 17:34:02 +00:00
|
|
|
|
docs/design/: Some more docs in the works.
Original commit message from CVS:
* docs/design/part-dynamic.txt:
* docs/design/part-events.txt:
* docs/design/part-seeking.txt:
Some more docs in the works.
* gst/base/gstbasetransform.c: (gst_base_transform_transform_caps),
(gst_base_transform_getcaps), (gst_base_transform_configure_caps),
(gst_base_transform_setcaps), (gst_base_transform_get_size),
(gst_base_transform_buffer_alloc), (gst_base_transform_event),
(gst_base_transform_handle_buffer),
(gst_base_transform_sink_activate_push),
(gst_base_transform_src_activate_pull),
(gst_base_transform_set_passthrough),
(gst_base_transform_is_passthrough):
Refcounting fixes.
* gst/gstbus.c: (gst_bus_source_dispatch), (gst_bus_poll):
Cleanups.
* gst/gstevent.c: (gst_event_finalize):
Set SRC to NULL.
* gst/gstutils.c: (gst_element_unlink),
(gst_pad_get_parent_element), (gst_pad_proxy_getcaps),
(gst_pad_proxy_setcaps):
* gst/gstutils.h:
Add _get_parent_element() to get a pads parent as an element.
2005-07-18 08:28:48 +00:00
|
|
|
bus = bsource->bus;
|
2005-03-21 17:34:02 +00:00
|
|
|
|
docs/design/: Some more docs in the works.
Original commit message from CVS:
* docs/design/part-dynamic.txt:
* docs/design/part-events.txt:
* docs/design/part-seeking.txt:
Some more docs in the works.
* gst/base/gstbasetransform.c: (gst_base_transform_transform_caps),
(gst_base_transform_getcaps), (gst_base_transform_configure_caps),
(gst_base_transform_setcaps), (gst_base_transform_get_size),
(gst_base_transform_buffer_alloc), (gst_base_transform_event),
(gst_base_transform_handle_buffer),
(gst_base_transform_sink_activate_push),
(gst_base_transform_src_activate_pull),
(gst_base_transform_set_passthrough),
(gst_base_transform_is_passthrough):
Refcounting fixes.
* gst/gstbus.c: (gst_bus_source_dispatch), (gst_bus_poll):
Cleanups.
* gst/gstevent.c: (gst_event_finalize):
Set SRC to NULL.
* gst/gstutils.c: (gst_element_unlink),
(gst_pad_get_parent_element), (gst_pad_proxy_getcaps),
(gst_pad_proxy_setcaps):
* gst/gstutils.h:
Add _get_parent_element() to get a pads parent as an element.
2005-07-18 08:28:48 +00:00
|
|
|
g_return_val_if_fail (GST_IS_BUS (bus), FALSE);
|
|
|
|
|
GstBusHandler -> GstBusFunc, return value has the same meaning as any other GSource (FALSE == remove source).
Original commit message from CVS:
* check/gst/gstbin.c: (pop_messages), (GST_START_TEST):
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
* check/gst/gstpipeline.c: (GST_START_TEST):
* check/pipelines/cleanup.c: (run_pipeline):
* check/pipelines/simple_launch_lines.c: (run_pipeline),
(GST_START_TEST):
* gst/gstbus.c: (gst_bus_have_pending), (gst_bus_source_prepare),
(gst_bus_source_check), (gst_bus_source_dispatch),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (poll_func), (poll_timeout), (gst_bus_poll):
* gst/gstbus.h:
* tools/gst-launch.c: (event_loop):
* tools/gst-md5sum.c: (event_loop):
GstBusHandler -> GstBusFunc, return value has the same meaning as
any other GSource (FALSE == remove source).
_add_watch() and _add_watch_full() now take a MessageType mask to
only handle specific types of messages.
_poll() returns the GstMessage instead of the message type to avoid
race conditions.
_have_pending() takes a MessageType mask now too.
Added testsuite for multiple bus watches.
Fix testsuites and applications for new bus API.
2005-09-19 11:18:03 +00:00
|
|
|
message = gst_bus_pop (bus);
|
2008-05-05 16:47:29 +00:00
|
|
|
|
|
|
|
/* The message queue might be empty if some other thread or callback set
|
|
|
|
* the bus to flushing between check/prepare and dispatch */
|
|
|
|
if (G_UNLIKELY (message == NULL))
|
|
|
|
return TRUE;
|
2005-03-21 17:34:02 +00:00
|
|
|
|
docs/design/: Some more docs in the works.
Original commit message from CVS:
* docs/design/part-dynamic.txt:
* docs/design/part-events.txt:
* docs/design/part-seeking.txt:
Some more docs in the works.
* gst/base/gstbasetransform.c: (gst_base_transform_transform_caps),
(gst_base_transform_getcaps), (gst_base_transform_configure_caps),
(gst_base_transform_setcaps), (gst_base_transform_get_size),
(gst_base_transform_buffer_alloc), (gst_base_transform_event),
(gst_base_transform_handle_buffer),
(gst_base_transform_sink_activate_push),
(gst_base_transform_src_activate_pull),
(gst_base_transform_set_passthrough),
(gst_base_transform_is_passthrough):
Refcounting fixes.
* gst/gstbus.c: (gst_bus_source_dispatch), (gst_bus_poll):
Cleanups.
* gst/gstevent.c: (gst_event_finalize):
Set SRC to NULL.
* gst/gstutils.c: (gst_element_unlink),
(gst_pad_get_parent_element), (gst_pad_proxy_getcaps),
(gst_pad_proxy_setcaps):
* gst/gstutils.h:
Add _get_parent_element() to get a pads parent as an element.
2005-07-18 08:28:48 +00:00
|
|
|
if (!handler)
|
|
|
|
goto no_handler;
|
2005-05-26 10:48:53 +00:00
|
|
|
|
2011-10-18 12:08:19 +00:00
|
|
|
GST_DEBUG_OBJECT (bus, "source %p calling dispatch with %" GST_PTR_FORMAT,
|
|
|
|
source, message);
|
2005-06-28 19:45:26 +00:00
|
|
|
|
GstBusHandler -> GstBusFunc, return value has the same meaning as any other GSource (FALSE == remove source).
Original commit message from CVS:
* check/gst/gstbin.c: (pop_messages), (GST_START_TEST):
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
* check/gst/gstpipeline.c: (GST_START_TEST):
* check/pipelines/cleanup.c: (run_pipeline):
* check/pipelines/simple_launch_lines.c: (run_pipeline),
(GST_START_TEST):
* gst/gstbus.c: (gst_bus_have_pending), (gst_bus_source_prepare),
(gst_bus_source_check), (gst_bus_source_dispatch),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (poll_func), (poll_timeout), (gst_bus_poll):
* gst/gstbus.h:
* tools/gst-launch.c: (event_loop):
* tools/gst-md5sum.c: (event_loop):
GstBusHandler -> GstBusFunc, return value has the same meaning as
any other GSource (FALSE == remove source).
_add_watch() and _add_watch_full() now take a MessageType mask to
only handle specific types of messages.
_poll() returns the GstMessage instead of the message type to avoid
race conditions.
_have_pending() takes a MessageType mask now too.
Added testsuite for multiple bus watches.
Fix testsuites and applications for new bus API.
2005-09-19 11:18:03 +00:00
|
|
|
keep = handler (bus, message, user_data);
|
2005-07-29 15:34:52 +00:00
|
|
|
gst_message_unref (message);
|
2005-03-21 17:34:02 +00:00
|
|
|
|
GstBusHandler -> GstBusFunc, return value has the same meaning as any other GSource (FALSE == remove source).
Original commit message from CVS:
* check/gst/gstbin.c: (pop_messages), (GST_START_TEST):
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
* check/gst/gstpipeline.c: (GST_START_TEST):
* check/pipelines/cleanup.c: (run_pipeline):
* check/pipelines/simple_launch_lines.c: (run_pipeline),
(GST_START_TEST):
* gst/gstbus.c: (gst_bus_have_pending), (gst_bus_source_prepare),
(gst_bus_source_check), (gst_bus_source_dispatch),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (poll_func), (poll_timeout), (gst_bus_poll):
* gst/gstbus.h:
* tools/gst-launch.c: (event_loop):
* tools/gst-md5sum.c: (event_loop):
GstBusHandler -> GstBusFunc, return value has the same meaning as
any other GSource (FALSE == remove source).
_add_watch() and _add_watch_full() now take a MessageType mask to
only handle specific types of messages.
_poll() returns the GstMessage instead of the message type to avoid
race conditions.
_have_pending() takes a MessageType mask now too.
Added testsuite for multiple bus watches.
Fix testsuites and applications for new bus API.
2005-09-19 11:18:03 +00:00
|
|
|
GST_DEBUG_OBJECT (bus, "source %p handler returns %d", source, keep);
|
|
|
|
|
|
|
|
return keep;
|
docs/design/: Some more docs in the works.
Original commit message from CVS:
* docs/design/part-dynamic.txt:
* docs/design/part-events.txt:
* docs/design/part-seeking.txt:
Some more docs in the works.
* gst/base/gstbasetransform.c: (gst_base_transform_transform_caps),
(gst_base_transform_getcaps), (gst_base_transform_configure_caps),
(gst_base_transform_setcaps), (gst_base_transform_get_size),
(gst_base_transform_buffer_alloc), (gst_base_transform_event),
(gst_base_transform_handle_buffer),
(gst_base_transform_sink_activate_push),
(gst_base_transform_src_activate_pull),
(gst_base_transform_set_passthrough),
(gst_base_transform_is_passthrough):
Refcounting fixes.
* gst/gstbus.c: (gst_bus_source_dispatch), (gst_bus_poll):
Cleanups.
* gst/gstevent.c: (gst_event_finalize):
Set SRC to NULL.
* gst/gstutils.c: (gst_element_unlink),
(gst_pad_get_parent_element), (gst_pad_proxy_getcaps),
(gst_pad_proxy_setcaps):
* gst/gstutils.h:
Add _get_parent_element() to get a pads parent as an element.
2005-07-18 08:28:48 +00:00
|
|
|
|
|
|
|
no_handler:
|
|
|
|
{
|
|
|
|
g_warning ("GstBus watch dispatched without callback\n"
|
2007-10-19 09:48:38 +00:00
|
|
|
"You must call g_source_set_callback().");
|
2005-07-29 15:34:52 +00:00
|
|
|
gst_message_unref (message);
|
docs/design/: Some more docs in the works.
Original commit message from CVS:
* docs/design/part-dynamic.txt:
* docs/design/part-events.txt:
* docs/design/part-seeking.txt:
Some more docs in the works.
* gst/base/gstbasetransform.c: (gst_base_transform_transform_caps),
(gst_base_transform_getcaps), (gst_base_transform_configure_caps),
(gst_base_transform_setcaps), (gst_base_transform_get_size),
(gst_base_transform_buffer_alloc), (gst_base_transform_event),
(gst_base_transform_handle_buffer),
(gst_base_transform_sink_activate_push),
(gst_base_transform_src_activate_pull),
(gst_base_transform_set_passthrough),
(gst_base_transform_is_passthrough):
Refcounting fixes.
* gst/gstbus.c: (gst_bus_source_dispatch), (gst_bus_poll):
Cleanups.
* gst/gstevent.c: (gst_event_finalize):
Set SRC to NULL.
* gst/gstutils.c: (gst_element_unlink),
(gst_pad_get_parent_element), (gst_pad_proxy_getcaps),
(gst_pad_proxy_setcaps):
* gst/gstutils.h:
Add _get_parent_element() to get a pads parent as an element.
2005-07-18 08:28:48 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2005-03-21 17:34:02 +00:00
|
|
|
}
|
|
|
|
|
2005-06-28 19:45:26 +00:00
|
|
|
static void
|
2005-05-26 10:48:53 +00:00
|
|
|
gst_bus_source_finalize (GSource * source)
|
2005-03-21 17:34:02 +00:00
|
|
|
{
|
2005-05-26 10:48:53 +00:00
|
|
|
GstBusSource *bsource = (GstBusSource *) source;
|
2008-10-13 10:50:17 +00:00
|
|
|
GstBus *bus;
|
|
|
|
|
|
|
|
bus = bsource->bus;
|
2005-05-26 10:48:53 +00:00
|
|
|
|
2008-10-13 10:50:17 +00:00
|
|
|
GST_DEBUG_OBJECT (bus, "finalize source %p", source);
|
|
|
|
|
|
|
|
GST_OBJECT_LOCK (bus);
|
2014-08-13 12:12:00 +00:00
|
|
|
if (bus->priv->signal_watch == source)
|
|
|
|
bus->priv->signal_watch = NULL;
|
2008-10-13 10:50:17 +00:00
|
|
|
GST_OBJECT_UNLOCK (bus);
|
2008-10-13 09:22:22 +00:00
|
|
|
|
2005-06-28 09:59:01 +00:00
|
|
|
gst_object_unref (bsource->bus);
|
gst/base/gsttypefindhelper.c (gst_type_find_helper): Unref any remaining buffer.
Original commit message from CVS:
2005-06-27 Andy Wingo <wingo@pobox.com>
* gst/base/gsttypefindhelper.c (gst_type_find_helper): Unref any
remaining buffer.
* gst/gsttrace.c (gst_alloc_trace_list_sorted): New helper,
returns a sorted copy of the trace list.
(gst_alloc_trace_print_live): New API, only prints traces with
live objects. Sort the list.
(gst_alloc_trace_print_all): Sort the list.
(gst_alloc_trace_print): Align columns.
* gst/elements/gstttypefindelement.c:
* gst/elements/gsttee.c:
* gst/base/gstbasesrc.c:
* gst/base/gstbasesink.c:
* gst/base/gstbasetransform.c:
* gst/gstqueue.c: Adapt for pad activation changes.
* gst/gstpipeline.c (gst_pipeline_init): Unref after parenting
sched.
(gst_pipeline_dispose): Drop ref on sched.
* gst/gstpad.c (gst_pad_init): Set the default activate func.
(gst_pad_activate_default): Push mode by default.
(pre_activate_switch, post_activate_switch): New stubs, things to
do before and after switching activation modes on pads.
(gst_pad_set_active): Take a boolean and not a mode, dispatch to
the pad's activate function to choose which mode to activate.
Shortcut on deactivation and call the right function directly.
(gst_pad_activate_pull): New API, (de)activates a pad in pull
mode.
(gst_pad_activate_push): New API, same for push mode.
(gst_pad_set_activate_function)
(gst_pad_set_activatepull_function)
(gst_pad_set_activatepush_function): Setters for new API.
* gst/gstminiobject.c (gst_mini_object_new, gst_mini_object_free):
Trace all miniobjects.
(gst_mini_object_make_writable): Unref the arg if we copy, like
gst_caps_make_writable.
* gst/gstmessage.c (_gst_message_initialize): No trace init.
* gst/gstghostpad.c (gst_proxy_pad_do_activate)
(gst_proxy_pad_do_activatepull, gst_proxy_pad_do_activatepush):
Adapt for new pad API.
* gst/gstevent.c (_gst_event_initialize): Don't initialize trace.
* gst/gstelement.h:
* gst/gstelement.c (gst_element_iterate_src_pads)
(gst_element_iterate_sink_pads): New API functions.
* gst/gstelement.c (iterator_fold_with_resync): New utility,
should fold into gstiterator.c in some form.
(gst_element_pads_activate): Simplified via use of fold and
delegation of decisions to gstpad->activate.
* gst/gstbus.c (gst_bus_source_finalize): Set the bus to NULL,
help in debugging.
* gst/gstbuffer.c (_gst_buffer_initialize): Ref the buffer type
class once in init, like gstmessage. Didn't run into this issue
but it seems correct. Don't initialize a trace, gstminiobject does
that.
* check/pipelines/simple_launch_lines.c (test_stop_from_app): New
test, runs fakesrc ! fakesink, stopping on ::handoff via a message
to the bus.
(assert_live_count): New util function, uses alloc traces to check
cleanup.
* check/gst/gstghostpad.c (test_ghost_pads): More refcount checks.
To be modified when unlink drops the internal pad.
2005-06-27 18:35:05 +00:00
|
|
|
bsource->bus = NULL;
|
2005-05-26 10:48:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GSourceFuncs gst_bus_source_funcs = {
|
|
|
|
gst_bus_source_prepare,
|
|
|
|
gst_bus_source_check,
|
|
|
|
gst_bus_source_dispatch,
|
|
|
|
gst_bus_source_finalize
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2012-06-26 17:22:33 +00:00
|
|
|
* gst_bus_create_watch:
|
2005-05-26 10:48:53 +00:00
|
|
|
* @bus: a #GstBus to create the watch for
|
|
|
|
*
|
check/gst/gstbin.c: Change for new bus API.
Original commit message from CVS:
* check/gst/gstbin.c: (GST_START_TEST):
Change for new bus API.
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
Change for new bus signal API.
* gst/gstbus.c: (gst_bus_class_init), (gst_bus_have_pending),
(gst_bus_source_prepare), (gst_bus_source_check),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (gst_bus_poll), (gst_bus_async_signal_func),
(gst_bus_sync_signal_handler), (gst_bus_add_signal_watch):
* gst/gstbus.h:
Remove support for multiple GSources operating on different
message types as it is too complex and unneeded when using
signals.
Added support for receiving signals from the bus.
2005-09-29 13:07:37 +00:00
|
|
|
* Create watch for this bus. The GSource will be dispatched whenever
|
2005-10-15 15:30:24 +00:00
|
|
|
* a message is on the bus. After the GSource is dispatched, the
|
check/gst/gstbin.c: Change for new bus API.
Original commit message from CVS:
* check/gst/gstbin.c: (GST_START_TEST):
Change for new bus API.
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
Change for new bus signal API.
* gst/gstbus.c: (gst_bus_class_init), (gst_bus_have_pending),
(gst_bus_source_prepare), (gst_bus_source_check),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (gst_bus_poll), (gst_bus_async_signal_func),
(gst_bus_sync_signal_handler), (gst_bus_add_signal_watch):
* gst/gstbus.h:
Remove support for multiple GSources operating on different
message types as it is too complex and unneeded when using
signals.
Added support for receiving signals from the bus.
2005-09-29 13:07:37 +00:00
|
|
|
* message is popped off the bus and unreffed.
|
2005-05-26 10:48:53 +00:00
|
|
|
*
|
2010-12-07 18:35:04 +00:00
|
|
|
* Returns: (transfer full): a #GSource that can be added to a mainloop.
|
2005-05-26 10:48:53 +00:00
|
|
|
*/
|
|
|
|
GSource *
|
check/gst/gstbin.c: Change for new bus API.
Original commit message from CVS:
* check/gst/gstbin.c: (GST_START_TEST):
Change for new bus API.
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
Change for new bus signal API.
* gst/gstbus.c: (gst_bus_class_init), (gst_bus_have_pending),
(gst_bus_source_prepare), (gst_bus_source_check),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (gst_bus_poll), (gst_bus_async_signal_func),
(gst_bus_sync_signal_handler), (gst_bus_add_signal_watch):
* gst/gstbus.h:
Remove support for multiple GSources operating on different
message types as it is too complex and unneeded when using
signals.
Added support for receiving signals from the bus.
2005-09-29 13:07:37 +00:00
|
|
|
gst_bus_create_watch (GstBus * bus)
|
2005-05-26 10:48:53 +00:00
|
|
|
{
|
|
|
|
GstBusSource *source;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_BUS (bus), NULL);
|
2011-04-06 12:06:49 +00:00
|
|
|
g_return_val_if_fail (bus->priv->poll != NULL, NULL);
|
2005-05-26 10:48:53 +00:00
|
|
|
|
|
|
|
source = (GstBusSource *) g_source_new (&gst_bus_source_funcs,
|
|
|
|
sizeof (GstBusSource));
|
2011-10-16 20:12:07 +00:00
|
|
|
|
|
|
|
g_source_set_name ((GSource *) source, "GStreamer message bus watch");
|
|
|
|
|
gst/gstbus.c: Make GstBusSource work with non-default main contexts (#562170).
Original commit message from CVS:
* gst/gstbus.c: (gst_bus_dispose), (gst_bus_get_property),
(gst_bus_wakeup_main_context), (gst_bus_set_main_context),
(gst_bus_post), (gst_bus_source_prepare), (gst_bus_source_finalize),
(gst_bus_create_watch):
Make GstBusSource work with non-default main contexts (#562170).
* tests/check/gst/gstbus.c: (message_func_eos), (message_func_app),
(test_watch), (test_watch_with_custom_context), (gst_bus_suite):
Add test case for GstBusSource with a non-default main context.
* tests/check/libs/.cvsignore:
Ignore more.
2008-12-27 17:41:11 +00:00
|
|
|
source->bus = gst_object_ref (bus);
|
2010-10-28 12:27:43 +00:00
|
|
|
g_source_add_poll ((GSource *) source, &bus->priv->pollfd);
|
2005-05-26 10:48:53 +00:00
|
|
|
|
|
|
|
return (GSource *) source;
|
2005-03-21 17:34:02 +00:00
|
|
|
}
|
|
|
|
|
2008-10-13 10:50:17 +00:00
|
|
|
/* must be called with the bus OBJECT LOCK */
|
|
|
|
static guint
|
|
|
|
gst_bus_add_watch_full_unlocked (GstBus * bus, gint priority,
|
|
|
|
GstBusFunc func, gpointer user_data, GDestroyNotify notify)
|
|
|
|
{
|
2011-01-31 15:58:18 +00:00
|
|
|
GMainContext *ctx;
|
2008-10-13 10:50:17 +00:00
|
|
|
guint id;
|
|
|
|
GSource *source;
|
|
|
|
|
2014-08-13 12:12:00 +00:00
|
|
|
if (bus->priv->signal_watch) {
|
2008-10-13 10:50:17 +00:00
|
|
|
GST_ERROR_OBJECT (bus,
|
|
|
|
"Tried to add new watch while one was already there");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
source = gst_bus_create_watch (bus);
|
|
|
|
|
|
|
|
if (priority != G_PRIORITY_DEFAULT)
|
|
|
|
g_source_set_priority (source, priority);
|
|
|
|
|
|
|
|
g_source_set_callback (source, (GSourceFunc) func, user_data, notify);
|
|
|
|
|
2011-01-31 15:58:18 +00:00
|
|
|
ctx = g_main_context_get_thread_default ();
|
|
|
|
id = g_source_attach (source, ctx);
|
2008-10-13 10:50:17 +00:00
|
|
|
g_source_unref (source);
|
|
|
|
|
|
|
|
if (id) {
|
2014-08-13 12:12:00 +00:00
|
|
|
bus->priv->signal_watch = source;
|
2008-10-13 10:50:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (bus, "New source %p with id %u", source, id);
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
/**
|
2014-11-01 19:56:41 +00:00
|
|
|
* gst_bus_add_watch_full: (rename-to gst_bus_add_watch)
|
2005-03-22 11:32:59 +00:00
|
|
|
* @bus: a #GstBus to create the watch for.
|
|
|
|
* @priority: The priority of the watch.
|
GstBusHandler -> GstBusFunc, return value has the same meaning as any other GSource (FALSE == remove source).
Original commit message from CVS:
* check/gst/gstbin.c: (pop_messages), (GST_START_TEST):
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
* check/gst/gstpipeline.c: (GST_START_TEST):
* check/pipelines/cleanup.c: (run_pipeline):
* check/pipelines/simple_launch_lines.c: (run_pipeline),
(GST_START_TEST):
* gst/gstbus.c: (gst_bus_have_pending), (gst_bus_source_prepare),
(gst_bus_source_check), (gst_bus_source_dispatch),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (poll_func), (poll_timeout), (gst_bus_poll):
* gst/gstbus.h:
* tools/gst-launch.c: (event_loop):
* tools/gst-md5sum.c: (event_loop):
GstBusHandler -> GstBusFunc, return value has the same meaning as
any other GSource (FALSE == remove source).
_add_watch() and _add_watch_full() now take a MessageType mask to
only handle specific types of messages.
_poll() returns the GstMessage instead of the message type to avoid
race conditions.
_have_pending() takes a MessageType mask now too.
Added testsuite for multiple bus watches.
Fix testsuites and applications for new bus API.
2005-09-19 11:18:03 +00:00
|
|
|
* @func: A function to call when a message is received.
|
|
|
|
* @user_data: user data passed to @func.
|
2005-03-22 11:32:59 +00:00
|
|
|
* @notify: the function to call when the source is removed.
|
2005-03-21 17:34:02 +00:00
|
|
|
*
|
2010-05-19 12:57:08 +00:00
|
|
|
* Adds a bus watch to the default main context with the given @priority (e.g.
|
2012-07-10 09:46:41 +00:00
|
|
|
* %G_PRIORITY_DEFAULT). It is also possible to use a non-default main
|
|
|
|
* context set up using g_main_context_push_thread_default() (before
|
2011-01-31 15:58:18 +00:00
|
|
|
* one had to create a bus watch source and attach it to the desired main
|
|
|
|
* context 'manually').
|
|
|
|
*
|
gst/gstbus.c: Small documentation clarification about the signal watch.
Original commit message from CVS:
* gst/gstbus.c:
Small documentation clarification about the signal watch.
* libs/gst/base/gstbasesink.c: (gst_base_sink_get_sync_times),
(gst_base_sink_wait_clock), (gst_base_sink_do_sync),
(gst_base_sink_perform_qos), (gst_base_sink_reset_qos),
(gst_base_sink_do_render_stats), (gst_base_sink_render_object),
(gst_base_sink_get_position_last),
(gst_base_sink_get_position_paused), (gst_base_sink_change_state):
Convert and store timestamps in stream time and running time, the
raw timestamps are not usefull, also document this better.
Use different window sizes for good and bad QoS observations so
we react to badness a little quicker.
Keep track of the amount of rendered and dropped buffers.
Send QoS timestamps in running time.
* libs/gst/base/gstbasetransform.c:
(gst_base_transform_sink_eventfunc),
(gst_base_transform_handle_buffer):
Compare QoS timestamps against running time.
2006-04-07 14:02:12 +00:00
|
|
|
* This function is used to receive asynchronous messages in the main loop.
|
2008-10-13 09:22:22 +00:00
|
|
|
* There can only be a single bus watch per bus, you must remove it before you
|
|
|
|
* can set a new one.
|
GstBusHandler -> GstBusFunc, return value has the same meaning as any other GSource (FALSE == remove source).
Original commit message from CVS:
* check/gst/gstbin.c: (pop_messages), (GST_START_TEST):
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
* check/gst/gstpipeline.c: (GST_START_TEST):
* check/pipelines/cleanup.c: (run_pipeline):
* check/pipelines/simple_launch_lines.c: (run_pipeline),
(GST_START_TEST):
* gst/gstbus.c: (gst_bus_have_pending), (gst_bus_source_prepare),
(gst_bus_source_check), (gst_bus_source_dispatch),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (poll_func), (poll_timeout), (gst_bus_poll):
* gst/gstbus.h:
* tools/gst-launch.c: (event_loop):
* tools/gst-md5sum.c: (event_loop):
GstBusHandler -> GstBusFunc, return value has the same meaning as
any other GSource (FALSE == remove source).
_add_watch() and _add_watch_full() now take a MessageType mask to
only handle specific types of messages.
_poll() returns the GstMessage instead of the message type to avoid
race conditions.
_have_pending() takes a MessageType mask now too.
Added testsuite for multiple bus watches.
Fix testsuites and applications for new bus API.
2005-09-19 11:18:03 +00:00
|
|
|
*
|
Documentation updates.
Original commit message from CVS:
* docs/gst/gstreamer-sections.txt:
* gst/gstbin.c: (bin_bus_handler), (gst_bin_handle_message_func):
* gst/gstbin.h:
* gst/gstbus.c: (gst_bus_class_init):
* gst/gstbus.h:
* gst/gstclock.c:
* gst/gstelement.c: (gst_element_set_locked_state):
* gst/gstsegment.c:
Documentation updates.
* gst/gstpipeline.c: (gst_pipeline_get_type),
(gst_pipeline_class_init), (gst_pipeline_init),
(gst_pipeline_dispose), (gst_pipeline_set_property),
(gst_pipeline_get_property), (do_pipeline_seek),
(gst_pipeline_send_event), (gst_pipeline_change_state),
(gst_pipeline_provide_clock_func), (gst_pipeline_set_delay),
(gst_pipeline_get_delay):
* gst/gstpipeline.h:
Added methods for setting the delay.
API: gst_pipeline_set_delay
API: gst_pipeline_get_delay
Add pipeline debug category
Various cleanups.
Updated docs.
Don't reset stream time when seek failed.
2006-03-13 11:04:38 +00:00
|
|
|
* When @func is called, the message belongs to the caller; if you want to
|
|
|
|
* keep a copy of it, call gst_message_ref() before leaving @func.
|
2005-03-21 17:34:02 +00:00
|
|
|
*
|
2014-08-19 21:28:52 +00:00
|
|
|
* The watch can be removed using gst_bus_remove_watch() or by returning %FALSE
|
|
|
|
* from @func. If the watch was added to the default main context it is also
|
|
|
|
* possible to remove the watch using g_source_remove().
|
2005-09-28 15:45:21 +00:00
|
|
|
*
|
2012-06-15 23:43:30 +00:00
|
|
|
* MT safe.
|
|
|
|
*
|
2014-07-15 14:06:49 +00:00
|
|
|
* Returns: The event source id or 0 if @bus already got an event source.
|
2005-03-21 17:34:02 +00:00
|
|
|
*/
|
|
|
|
guint
|
check/gst/gstbin.c: Change for new bus API.
Original commit message from CVS:
* check/gst/gstbin.c: (GST_START_TEST):
Change for new bus API.
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
Change for new bus signal API.
* gst/gstbus.c: (gst_bus_class_init), (gst_bus_have_pending),
(gst_bus_source_prepare), (gst_bus_source_check),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (gst_bus_poll), (gst_bus_async_signal_func),
(gst_bus_sync_signal_handler), (gst_bus_add_signal_watch):
* gst/gstbus.h:
Remove support for multiple GSources operating on different
message types as it is too complex and unneeded when using
signals.
Added support for receiving signals from the bus.
2005-09-29 13:07:37 +00:00
|
|
|
gst_bus_add_watch_full (GstBus * bus, gint priority,
|
GstBusHandler -> GstBusFunc, return value has the same meaning as any other GSource (FALSE == remove source).
Original commit message from CVS:
* check/gst/gstbin.c: (pop_messages), (GST_START_TEST):
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
* check/gst/gstpipeline.c: (GST_START_TEST):
* check/pipelines/cleanup.c: (run_pipeline):
* check/pipelines/simple_launch_lines.c: (run_pipeline),
(GST_START_TEST):
* gst/gstbus.c: (gst_bus_have_pending), (gst_bus_source_prepare),
(gst_bus_source_check), (gst_bus_source_dispatch),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (poll_func), (poll_timeout), (gst_bus_poll):
* gst/gstbus.h:
* tools/gst-launch.c: (event_loop):
* tools/gst-md5sum.c: (event_loop):
GstBusHandler -> GstBusFunc, return value has the same meaning as
any other GSource (FALSE == remove source).
_add_watch() and _add_watch_full() now take a MessageType mask to
only handle specific types of messages.
_poll() returns the GstMessage instead of the message type to avoid
race conditions.
_have_pending() takes a MessageType mask now too.
Added testsuite for multiple bus watches.
Fix testsuites and applications for new bus API.
2005-09-19 11:18:03 +00:00
|
|
|
GstBusFunc func, gpointer user_data, GDestroyNotify notify)
|
2005-03-21 17:34:02 +00:00
|
|
|
{
|
|
|
|
guint id;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_BUS (bus), 0);
|
|
|
|
|
2008-10-13 10:50:17 +00:00
|
|
|
GST_OBJECT_LOCK (bus);
|
|
|
|
id = gst_bus_add_watch_full_unlocked (bus, priority, func, user_data, notify);
|
|
|
|
GST_OBJECT_UNLOCK (bus);
|
2008-10-13 09:22:22 +00:00
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-08-29 16:52:26 +00:00
|
|
|
* gst_bus_add_watch: (skip)
|
2005-03-21 17:34:02 +00:00
|
|
|
* @bus: a #GstBus to create the watch for
|
GstBusHandler -> GstBusFunc, return value has the same meaning as any other GSource (FALSE == remove source).
Original commit message from CVS:
* check/gst/gstbin.c: (pop_messages), (GST_START_TEST):
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
* check/gst/gstpipeline.c: (GST_START_TEST):
* check/pipelines/cleanup.c: (run_pipeline):
* check/pipelines/simple_launch_lines.c: (run_pipeline),
(GST_START_TEST):
* gst/gstbus.c: (gst_bus_have_pending), (gst_bus_source_prepare),
(gst_bus_source_check), (gst_bus_source_dispatch),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (poll_func), (poll_timeout), (gst_bus_poll):
* gst/gstbus.h:
* tools/gst-launch.c: (event_loop):
* tools/gst-md5sum.c: (event_loop):
GstBusHandler -> GstBusFunc, return value has the same meaning as
any other GSource (FALSE == remove source).
_add_watch() and _add_watch_full() now take a MessageType mask to
only handle specific types of messages.
_poll() returns the GstMessage instead of the message type to avoid
race conditions.
_have_pending() takes a MessageType mask now too.
Added testsuite for multiple bus watches.
Fix testsuites and applications for new bus API.
2005-09-19 11:18:03 +00:00
|
|
|
* @func: A function to call when a message is received.
|
|
|
|
* @user_data: user data passed to @func.
|
2005-03-21 17:34:02 +00:00
|
|
|
*
|
2010-05-19 12:57:08 +00:00
|
|
|
* Adds a bus watch to the default main context with the default priority
|
2012-07-10 09:46:41 +00:00
|
|
|
* (%G_PRIORITY_DEFAULT). It is also possible to use a non-default main
|
|
|
|
* context set up using g_main_context_push_thread_default() (before
|
2011-01-31 15:58:18 +00:00
|
|
|
* one had to create a bus watch source and attach it to the desired main
|
|
|
|
* context 'manually').
|
|
|
|
*
|
gst/gstbus.c: Small documentation clarification about the signal watch.
Original commit message from CVS:
* gst/gstbus.c:
Small documentation clarification about the signal watch.
* libs/gst/base/gstbasesink.c: (gst_base_sink_get_sync_times),
(gst_base_sink_wait_clock), (gst_base_sink_do_sync),
(gst_base_sink_perform_qos), (gst_base_sink_reset_qos),
(gst_base_sink_do_render_stats), (gst_base_sink_render_object),
(gst_base_sink_get_position_last),
(gst_base_sink_get_position_paused), (gst_base_sink_change_state):
Convert and store timestamps in stream time and running time, the
raw timestamps are not usefull, also document this better.
Use different window sizes for good and bad QoS observations so
we react to badness a little quicker.
Keep track of the amount of rendered and dropped buffers.
Send QoS timestamps in running time.
* libs/gst/base/gstbasetransform.c:
(gst_base_transform_sink_eventfunc),
(gst_base_transform_handle_buffer):
Compare QoS timestamps against running time.
2006-04-07 14:02:12 +00:00
|
|
|
* This function is used to receive asynchronous messages in the main loop.
|
2008-10-13 09:22:22 +00:00
|
|
|
* There can only be a single bus watch per bus, you must remove it before you
|
|
|
|
* can set a new one.
|
2005-03-21 17:34:02 +00:00
|
|
|
*
|
2014-08-19 21:28:52 +00:00
|
|
|
* The watch can be removed using gst_bus_remove_watch() or by returning %FALSE
|
|
|
|
* from @func. If the watch was added to the default main context it is also
|
|
|
|
* possible to remove the watch using g_source_remove().
|
2005-09-28 15:45:21 +00:00
|
|
|
*
|
2014-07-15 14:06:49 +00:00
|
|
|
* Returns: The event source id or 0 if @bus already got an event source.
|
2005-03-21 17:34:02 +00:00
|
|
|
*
|
|
|
|
* MT safe.
|
|
|
|
*/
|
|
|
|
guint
|
check/gst/gstbin.c: Change for new bus API.
Original commit message from CVS:
* check/gst/gstbin.c: (GST_START_TEST):
Change for new bus API.
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
Change for new bus signal API.
* gst/gstbus.c: (gst_bus_class_init), (gst_bus_have_pending),
(gst_bus_source_prepare), (gst_bus_source_check),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (gst_bus_poll), (gst_bus_async_signal_func),
(gst_bus_sync_signal_handler), (gst_bus_add_signal_watch):
* gst/gstbus.h:
Remove support for multiple GSources operating on different
message types as it is too complex and unneeded when using
signals.
Added support for receiving signals from the bus.
2005-09-29 13:07:37 +00:00
|
|
|
gst_bus_add_watch (GstBus * bus, GstBusFunc func, gpointer user_data)
|
2005-03-21 17:34:02 +00:00
|
|
|
{
|
check/gst/gstbin.c: Change for new bus API.
Original commit message from CVS:
* check/gst/gstbin.c: (GST_START_TEST):
Change for new bus API.
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
Change for new bus signal API.
* gst/gstbus.c: (gst_bus_class_init), (gst_bus_have_pending),
(gst_bus_source_prepare), (gst_bus_source_check),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (gst_bus_poll), (gst_bus_async_signal_func),
(gst_bus_sync_signal_handler), (gst_bus_add_signal_watch):
* gst/gstbus.h:
Remove support for multiple GSources operating on different
message types as it is too complex and unneeded when using
signals.
Added support for receiving signals from the bus.
2005-09-29 13:07:37 +00:00
|
|
|
return gst_bus_add_watch_full (bus, G_PRIORITY_DEFAULT, func,
|
GstBusHandler -> GstBusFunc, return value has the same meaning as any other GSource (FALSE == remove source).
Original commit message from CVS:
* check/gst/gstbin.c: (pop_messages), (GST_START_TEST):
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
* check/gst/gstpipeline.c: (GST_START_TEST):
* check/pipelines/cleanup.c: (run_pipeline):
* check/pipelines/simple_launch_lines.c: (run_pipeline),
(GST_START_TEST):
* gst/gstbus.c: (gst_bus_have_pending), (gst_bus_source_prepare),
(gst_bus_source_check), (gst_bus_source_dispatch),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (poll_func), (poll_timeout), (gst_bus_poll):
* gst/gstbus.h:
* tools/gst-launch.c: (event_loop):
* tools/gst-md5sum.c: (event_loop):
GstBusHandler -> GstBusFunc, return value has the same meaning as
any other GSource (FALSE == remove source).
_add_watch() and _add_watch_full() now take a MessageType mask to
only handle specific types of messages.
_poll() returns the GstMessage instead of the message type to avoid
race conditions.
_have_pending() takes a MessageType mask now too.
Added testsuite for multiple bus watches.
Fix testsuites and applications for new bus API.
2005-09-19 11:18:03 +00:00
|
|
|
user_data, NULL);
|
2005-03-21 17:34:02 +00:00
|
|
|
}
|
|
|
|
|
2014-08-19 21:28:52 +00:00
|
|
|
/**
|
|
|
|
* gst_bus_remove_watch:
|
|
|
|
* @bus: a #GstBus to remove the watch from.
|
|
|
|
*
|
|
|
|
* Removes an installed bus watch from @bus.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE on success or %FALSE if @bus has no event source.
|
|
|
|
*
|
|
|
|
* Since: 1.6
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_bus_remove_watch (GstBus * bus)
|
|
|
|
{
|
|
|
|
GSource *watch_id;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_BUS (bus), FALSE);
|
|
|
|
|
|
|
|
GST_OBJECT_LOCK (bus);
|
|
|
|
|
|
|
|
if (bus->priv->signal_watch == NULL) {
|
|
|
|
GST_ERROR_OBJECT (bus, "no bus watch was present");
|
|
|
|
goto no_watch;
|
|
|
|
}
|
|
|
|
|
|
|
|
watch_id = bus->priv->signal_watch;
|
|
|
|
|
|
|
|
GST_OBJECT_UNLOCK (bus);
|
|
|
|
|
|
|
|
g_source_destroy (watch_id);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
no_watch:
|
|
|
|
GST_OBJECT_UNLOCK (bus);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GMainLoop *loop;
|
|
|
|
guint timeout_id;
|
2005-07-29 15:34:52 +00:00
|
|
|
gboolean source_running;
|
2005-03-21 17:34:02 +00:00
|
|
|
GstMessageType events;
|
GstBusHandler -> GstBusFunc, return value has the same meaning as any other GSource (FALSE == remove source).
Original commit message from CVS:
* check/gst/gstbin.c: (pop_messages), (GST_START_TEST):
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
* check/gst/gstpipeline.c: (GST_START_TEST):
* check/pipelines/cleanup.c: (run_pipeline):
* check/pipelines/simple_launch_lines.c: (run_pipeline),
(GST_START_TEST):
* gst/gstbus.c: (gst_bus_have_pending), (gst_bus_source_prepare),
(gst_bus_source_check), (gst_bus_source_dispatch),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (poll_func), (poll_timeout), (gst_bus_poll):
* gst/gstbus.h:
* tools/gst-launch.c: (event_loop):
* tools/gst-md5sum.c: (event_loop):
GstBusHandler -> GstBusFunc, return value has the same meaning as
any other GSource (FALSE == remove source).
_add_watch() and _add_watch_full() now take a MessageType mask to
only handle specific types of messages.
_poll() returns the GstMessage instead of the message type to avoid
race conditions.
_have_pending() takes a MessageType mask now too.
Added testsuite for multiple bus watches.
Fix testsuites and applications for new bus API.
2005-09-19 11:18:03 +00:00
|
|
|
GstMessage *message;
|
2005-03-21 17:34:02 +00:00
|
|
|
} GstBusPollData;
|
|
|
|
|
2005-11-10 18:15:24 +00:00
|
|
|
static void
|
GstBusHandler -> GstBusFunc, return value has the same meaning as any other GSource (FALSE == remove source).
Original commit message from CVS:
* check/gst/gstbin.c: (pop_messages), (GST_START_TEST):
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
* check/gst/gstpipeline.c: (GST_START_TEST):
* check/pipelines/cleanup.c: (run_pipeline):
* check/pipelines/simple_launch_lines.c: (run_pipeline),
(GST_START_TEST):
* gst/gstbus.c: (gst_bus_have_pending), (gst_bus_source_prepare),
(gst_bus_source_check), (gst_bus_source_dispatch),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (poll_func), (poll_timeout), (gst_bus_poll):
* gst/gstbus.h:
* tools/gst-launch.c: (event_loop):
* tools/gst-md5sum.c: (event_loop):
GstBusHandler -> GstBusFunc, return value has the same meaning as
any other GSource (FALSE == remove source).
_add_watch() and _add_watch_full() now take a MessageType mask to
only handle specific types of messages.
_poll() returns the GstMessage instead of the message type to avoid
race conditions.
_have_pending() takes a MessageType mask now too.
Added testsuite for multiple bus watches.
Fix testsuites and applications for new bus API.
2005-09-19 11:18:03 +00:00
|
|
|
poll_func (GstBus * bus, GstMessage * message, GstBusPollData * poll_data)
|
2005-03-21 17:34:02 +00:00
|
|
|
{
|
2007-09-26 18:06:42 +00:00
|
|
|
GstMessageType type;
|
|
|
|
|
2005-09-20 17:30:35 +00:00
|
|
|
if (!g_main_loop_is_running (poll_data->loop)) {
|
|
|
|
GST_DEBUG ("mainloop %p not running", poll_data->loop);
|
2005-11-10 18:15:24 +00:00
|
|
|
return;
|
2005-09-20 17:30:35 +00:00
|
|
|
}
|
2005-07-29 15:34:52 +00:00
|
|
|
|
2007-09-26 18:06:42 +00:00
|
|
|
type = GST_MESSAGE_TYPE (message);
|
|
|
|
|
|
|
|
if (type & poll_data->events) {
|
2010-03-04 21:36:50 +00:00
|
|
|
g_assert (poll_data->message == NULL);
|
GstBusHandler -> GstBusFunc, return value has the same meaning as any other GSource (FALSE == remove source).
Original commit message from CVS:
* check/gst/gstbin.c: (pop_messages), (GST_START_TEST):
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
* check/gst/gstpipeline.c: (GST_START_TEST):
* check/pipelines/cleanup.c: (run_pipeline):
* check/pipelines/simple_launch_lines.c: (run_pipeline),
(GST_START_TEST):
* gst/gstbus.c: (gst_bus_have_pending), (gst_bus_source_prepare),
(gst_bus_source_check), (gst_bus_source_dispatch),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (poll_func), (poll_timeout), (gst_bus_poll):
* gst/gstbus.h:
* tools/gst-launch.c: (event_loop):
* tools/gst-md5sum.c: (event_loop):
GstBusHandler -> GstBusFunc, return value has the same meaning as
any other GSource (FALSE == remove source).
_add_watch() and _add_watch_full() now take a MessageType mask to
only handle specific types of messages.
_poll() returns the GstMessage instead of the message type to avoid
race conditions.
_have_pending() takes a MessageType mask now too.
Added testsuite for multiple bus watches.
Fix testsuites and applications for new bus API.
2005-09-19 11:18:03 +00:00
|
|
|
/* keep ref to message */
|
|
|
|
poll_data->message = gst_message_ref (message);
|
2005-09-20 17:30:35 +00:00
|
|
|
GST_DEBUG ("mainloop %p quit", poll_data->loop);
|
2005-07-29 15:34:52 +00:00
|
|
|
g_main_loop_quit (poll_data->loop);
|
2007-09-26 18:06:42 +00:00
|
|
|
} else {
|
|
|
|
GST_DEBUG ("type %08x does not match %08x", type, poll_data->events);
|
2005-03-21 17:34:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
poll_timeout (GstBusPollData * poll_data)
|
|
|
|
{
|
2005-09-20 17:30:35 +00:00
|
|
|
GST_DEBUG ("mainloop %p quit", poll_data->loop);
|
2005-03-21 17:34:02 +00:00
|
|
|
g_main_loop_quit (poll_data->loop);
|
2005-07-29 15:34:52 +00:00
|
|
|
|
GstBusHandler -> GstBusFunc, return value has the same meaning as any other GSource (FALSE == remove source).
Original commit message from CVS:
* check/gst/gstbin.c: (pop_messages), (GST_START_TEST):
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
* check/gst/gstpipeline.c: (GST_START_TEST):
* check/pipelines/cleanup.c: (run_pipeline):
* check/pipelines/simple_launch_lines.c: (run_pipeline),
(GST_START_TEST):
* gst/gstbus.c: (gst_bus_have_pending), (gst_bus_source_prepare),
(gst_bus_source_check), (gst_bus_source_dispatch),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (poll_func), (poll_timeout), (gst_bus_poll):
* gst/gstbus.h:
* tools/gst-launch.c: (event_loop):
* tools/gst-md5sum.c: (event_loop):
GstBusHandler -> GstBusFunc, return value has the same meaning as
any other GSource (FALSE == remove source).
_add_watch() and _add_watch_full() now take a MessageType mask to
only handle specific types of messages.
_poll() returns the GstMessage instead of the message type to avoid
race conditions.
_have_pending() takes a MessageType mask now too.
Added testsuite for multiple bus watches.
Fix testsuites and applications for new bus API.
2005-09-19 11:18:03 +00:00
|
|
|
/* we don't remove the GSource as this would free our poll_data,
|
|
|
|
* which we still need */
|
|
|
|
return TRUE;
|
2005-03-21 17:34:02 +00:00
|
|
|
}
|
|
|
|
|
2005-07-29 15:34:52 +00:00
|
|
|
static void
|
2005-11-10 18:15:24 +00:00
|
|
|
poll_destroy (GstBusPollData * poll_data, gpointer unused)
|
2005-07-29 15:34:52 +00:00
|
|
|
{
|
|
|
|
poll_data->source_running = FALSE;
|
|
|
|
if (!poll_data->timeout_id) {
|
|
|
|
g_main_loop_unref (poll_data->loop);
|
2010-03-28 16:05:36 +00:00
|
|
|
g_slice_free (GstBusPollData, poll_data);
|
2005-07-29 15:34:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
poll_destroy_timeout (GstBusPollData * poll_data)
|
|
|
|
{
|
|
|
|
poll_data->timeout_id = 0;
|
|
|
|
if (!poll_data->source_running) {
|
|
|
|
g_main_loop_unref (poll_data->loop);
|
2010-03-28 16:05:36 +00:00
|
|
|
g_slice_free (GstBusPollData, poll_data);
|
2005-07-29 15:34:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
/**
|
|
|
|
* gst_bus_poll:
|
|
|
|
* @bus: a #GstBus
|
|
|
|
* @events: a mask of #GstMessageType, representing the set of message types to
|
2014-03-16 14:08:00 +00:00
|
|
|
* poll for (note special handling of extended message types below)
|
2012-03-27 10:31:18 +00:00
|
|
|
* @timeout: the poll timeout, as a #GstClockTime, or #GST_CLOCK_TIME_NONE to poll
|
2008-06-20 10:20:08 +00:00
|
|
|
* indefinitely.
|
2005-03-21 17:34:02 +00:00
|
|
|
*
|
2005-10-28 18:18:23 +00:00
|
|
|
* Poll the bus for messages. Will block while waiting for messages to come.
|
|
|
|
* You can specify a maximum time to poll with the @timeout parameter. If
|
|
|
|
* @timeout is negative, this function will block indefinitely.
|
2005-03-21 17:34:02 +00:00
|
|
|
*
|
2005-09-28 16:43:20 +00:00
|
|
|
* All messages not in @events will be popped off the bus and will be ignored.
|
2014-03-16 14:08:00 +00:00
|
|
|
* It is not possible to use message enums beyond #GST_MESSAGE_EXTENDED in the
|
|
|
|
* @events mask
|
2005-09-28 16:43:20 +00:00
|
|
|
*
|
2005-11-10 18:15:24 +00:00
|
|
|
* Because poll is implemented using the "message" signal enabled by
|
|
|
|
* gst_bus_add_signal_watch(), calling gst_bus_poll() will cause the "message"
|
|
|
|
* signal to be emitted for every message that poll sees. Thus a "message"
|
|
|
|
* signal handler will see the same messages that this function sees -- neither
|
|
|
|
* will steal messages from the other.
|
|
|
|
*
|
|
|
|
* This function will run a main loop from the default main context when
|
|
|
|
* polling.
|
docs/design/: Some more docs in the works.
Original commit message from CVS:
* docs/design/part-dynamic.txt:
* docs/design/part-events.txt:
* docs/design/part-seeking.txt:
Some more docs in the works.
* gst/base/gstbasetransform.c: (gst_base_transform_transform_caps),
(gst_base_transform_getcaps), (gst_base_transform_configure_caps),
(gst_base_transform_setcaps), (gst_base_transform_get_size),
(gst_base_transform_buffer_alloc), (gst_base_transform_event),
(gst_base_transform_handle_buffer),
(gst_base_transform_sink_activate_push),
(gst_base_transform_src_activate_pull),
(gst_base_transform_set_passthrough),
(gst_base_transform_is_passthrough):
Refcounting fixes.
* gst/gstbus.c: (gst_bus_source_dispatch), (gst_bus_poll):
Cleanups.
* gst/gstevent.c: (gst_event_finalize):
Set SRC to NULL.
* gst/gstutils.c: (gst_element_unlink),
(gst_pad_get_parent_element), (gst_pad_proxy_getcaps),
(gst_pad_proxy_setcaps):
* gst/gstutils.h:
Add _get_parent_element() to get a pads parent as an element.
2005-07-18 08:28:48 +00:00
|
|
|
*
|
2008-06-20 10:20:08 +00:00
|
|
|
* You should never use this function, since it is pure evil. This is
|
|
|
|
* especially true for GUI applications based on Gtk+ or Qt, but also for any
|
|
|
|
* other non-trivial application that uses the GLib main loop. As this function
|
|
|
|
* runs a GLib main loop, any callback attached to the default GLib main
|
|
|
|
* context may be invoked. This could be timeouts, GUI events, I/O events etc.;
|
|
|
|
* even if gst_bus_poll() is called with a 0 timeout. Any of these callbacks
|
|
|
|
* may do things you do not expect, e.g. destroy the main application window or
|
|
|
|
* some other resource; change other application state; display a dialog and
|
|
|
|
* run another main loop until the user clicks it away. In short, using this
|
|
|
|
* function may add a lot of complexity to your code through unexpected
|
|
|
|
* re-entrancy and unexpected changes to your application's state.
|
|
|
|
*
|
|
|
|
* For 0 timeouts use gst_bus_pop_filtered() instead of this function; for
|
|
|
|
* other short timeouts use gst_bus_timed_pop_filtered(); everything else is
|
|
|
|
* better handled by setting up an asynchronous bus watch and doing things
|
|
|
|
* from there.
|
|
|
|
*
|
2014-06-11 22:21:34 +00:00
|
|
|
* Returns: (transfer full) (nullable): the message that was received,
|
|
|
|
* or %NULL if the poll timed out. The message is taken from the
|
|
|
|
* bus and needs to be unreffed with gst_message_unref() after
|
|
|
|
* usage.
|
2005-03-21 17:34:02 +00:00
|
|
|
*/
|
GstBusHandler -> GstBusFunc, return value has the same meaning as any other GSource (FALSE == remove source).
Original commit message from CVS:
* check/gst/gstbin.c: (pop_messages), (GST_START_TEST):
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
* check/gst/gstpipeline.c: (GST_START_TEST):
* check/pipelines/cleanup.c: (run_pipeline):
* check/pipelines/simple_launch_lines.c: (run_pipeline),
(GST_START_TEST):
* gst/gstbus.c: (gst_bus_have_pending), (gst_bus_source_prepare),
(gst_bus_source_check), (gst_bus_source_dispatch),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (poll_func), (poll_timeout), (gst_bus_poll):
* gst/gstbus.h:
* tools/gst-launch.c: (event_loop):
* tools/gst-md5sum.c: (event_loop):
GstBusHandler -> GstBusFunc, return value has the same meaning as
any other GSource (FALSE == remove source).
_add_watch() and _add_watch_full() now take a MessageType mask to
only handle specific types of messages.
_poll() returns the GstMessage instead of the message type to avoid
race conditions.
_have_pending() takes a MessageType mask now too.
Added testsuite for multiple bus watches.
Fix testsuites and applications for new bus API.
2005-09-19 11:18:03 +00:00
|
|
|
GstMessage *
|
2012-03-27 10:31:18 +00:00
|
|
|
gst_bus_poll (GstBus * bus, GstMessageType events, GstClockTime timeout)
|
2005-03-21 17:34:02 +00:00
|
|
|
{
|
2005-07-29 15:34:52 +00:00
|
|
|
GstBusPollData *poll_data;
|
GstBusHandler -> GstBusFunc, return value has the same meaning as any other GSource (FALSE == remove source).
Original commit message from CVS:
* check/gst/gstbin.c: (pop_messages), (GST_START_TEST):
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
* check/gst/gstpipeline.c: (GST_START_TEST):
* check/pipelines/cleanup.c: (run_pipeline):
* check/pipelines/simple_launch_lines.c: (run_pipeline),
(GST_START_TEST):
* gst/gstbus.c: (gst_bus_have_pending), (gst_bus_source_prepare),
(gst_bus_source_check), (gst_bus_source_dispatch),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (poll_func), (poll_timeout), (gst_bus_poll):
* gst/gstbus.h:
* tools/gst-launch.c: (event_loop):
* tools/gst-md5sum.c: (event_loop):
GstBusHandler -> GstBusFunc, return value has the same meaning as
any other GSource (FALSE == remove source).
_add_watch() and _add_watch_full() now take a MessageType mask to
only handle specific types of messages.
_poll() returns the GstMessage instead of the message type to avoid
race conditions.
_have_pending() takes a MessageType mask now too.
Added testsuite for multiple bus watches.
Fix testsuites and applications for new bus API.
2005-09-19 11:18:03 +00:00
|
|
|
GstMessage *ret;
|
2005-11-10 18:15:24 +00:00
|
|
|
gulong id;
|
2005-03-21 17:34:02 +00:00
|
|
|
|
2015-03-27 09:15:16 +00:00
|
|
|
g_return_val_if_fail (GST_IS_BUS (bus), NULL);
|
|
|
|
|
2010-03-28 16:05:36 +00:00
|
|
|
poll_data = g_slice_new (GstBusPollData);
|
2005-07-29 15:34:52 +00:00
|
|
|
poll_data->source_running = TRUE;
|
|
|
|
poll_data->loop = g_main_loop_new (NULL, FALSE);
|
|
|
|
poll_data->events = events;
|
GstBusHandler -> GstBusFunc, return value has the same meaning as any other GSource (FALSE == remove source).
Original commit message from CVS:
* check/gst/gstbin.c: (pop_messages), (GST_START_TEST):
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
* check/gst/gstpipeline.c: (GST_START_TEST):
* check/pipelines/cleanup.c: (run_pipeline):
* check/pipelines/simple_launch_lines.c: (run_pipeline),
(GST_START_TEST):
* gst/gstbus.c: (gst_bus_have_pending), (gst_bus_source_prepare),
(gst_bus_source_check), (gst_bus_source_dispatch),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (poll_func), (poll_timeout), (gst_bus_poll):
* gst/gstbus.h:
* tools/gst-launch.c: (event_loop):
* tools/gst-md5sum.c: (event_loop):
GstBusHandler -> GstBusFunc, return value has the same meaning as
any other GSource (FALSE == remove source).
_add_watch() and _add_watch_full() now take a MessageType mask to
only handle specific types of messages.
_poll() returns the GstMessage instead of the message type to avoid
race conditions.
_have_pending() takes a MessageType mask now too.
Added testsuite for multiple bus watches.
Fix testsuites and applications for new bus API.
2005-09-19 11:18:03 +00:00
|
|
|
poll_data->message = NULL;
|
2005-07-29 15:34:52 +00:00
|
|
|
|
2012-03-27 10:31:18 +00:00
|
|
|
if (timeout != GST_CLOCK_TIME_NONE)
|
2005-07-29 15:34:52 +00:00
|
|
|
poll_data->timeout_id = g_timeout_add_full (G_PRIORITY_DEFAULT_IDLE,
|
|
|
|
timeout / GST_MSECOND, (GSourceFunc) poll_timeout, poll_data,
|
|
|
|
(GDestroyNotify) poll_destroy_timeout);
|
docs/design/: Some more docs in the works.
Original commit message from CVS:
* docs/design/part-dynamic.txt:
* docs/design/part-events.txt:
* docs/design/part-seeking.txt:
Some more docs in the works.
* gst/base/gstbasetransform.c: (gst_base_transform_transform_caps),
(gst_base_transform_getcaps), (gst_base_transform_configure_caps),
(gst_base_transform_setcaps), (gst_base_transform_get_size),
(gst_base_transform_buffer_alloc), (gst_base_transform_event),
(gst_base_transform_handle_buffer),
(gst_base_transform_sink_activate_push),
(gst_base_transform_src_activate_pull),
(gst_base_transform_set_passthrough),
(gst_base_transform_is_passthrough):
Refcounting fixes.
* gst/gstbus.c: (gst_bus_source_dispatch), (gst_bus_poll):
Cleanups.
* gst/gstevent.c: (gst_event_finalize):
Set SRC to NULL.
* gst/gstutils.c: (gst_element_unlink),
(gst_pad_get_parent_element), (gst_pad_proxy_getcaps),
(gst_pad_proxy_setcaps):
* gst/gstutils.h:
Add _get_parent_element() to get a pads parent as an element.
2005-07-18 08:28:48 +00:00
|
|
|
else
|
2005-07-29 15:34:52 +00:00
|
|
|
poll_data->timeout_id = 0;
|
docs/design/: Some more docs in the works.
Original commit message from CVS:
* docs/design/part-dynamic.txt:
* docs/design/part-events.txt:
* docs/design/part-seeking.txt:
Some more docs in the works.
* gst/base/gstbasetransform.c: (gst_base_transform_transform_caps),
(gst_base_transform_getcaps), (gst_base_transform_configure_caps),
(gst_base_transform_setcaps), (gst_base_transform_get_size),
(gst_base_transform_buffer_alloc), (gst_base_transform_event),
(gst_base_transform_handle_buffer),
(gst_base_transform_sink_activate_push),
(gst_base_transform_src_activate_pull),
(gst_base_transform_set_passthrough),
(gst_base_transform_is_passthrough):
Refcounting fixes.
* gst/gstbus.c: (gst_bus_source_dispatch), (gst_bus_poll):
Cleanups.
* gst/gstevent.c: (gst_event_finalize):
Set SRC to NULL.
* gst/gstutils.c: (gst_element_unlink),
(gst_pad_get_parent_element), (gst_pad_proxy_getcaps),
(gst_pad_proxy_setcaps):
* gst/gstutils.h:
Add _get_parent_element() to get a pads parent as an element.
2005-07-18 08:28:48 +00:00
|
|
|
|
2005-11-10 18:15:24 +00:00
|
|
|
id = g_signal_connect_data (bus, "message", G_CALLBACK (poll_func), poll_data,
|
|
|
|
(GClosureNotify) poll_destroy, 0);
|
|
|
|
|
|
|
|
/* these can be nested, so it's ok */
|
|
|
|
gst_bus_add_signal_watch (bus);
|
GstBusHandler -> GstBusFunc, return value has the same meaning as any other GSource (FALSE == remove source).
Original commit message from CVS:
* check/gst/gstbin.c: (pop_messages), (GST_START_TEST):
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
* check/gst/gstpipeline.c: (GST_START_TEST):
* check/pipelines/cleanup.c: (run_pipeline):
* check/pipelines/simple_launch_lines.c: (run_pipeline),
(GST_START_TEST):
* gst/gstbus.c: (gst_bus_have_pending), (gst_bus_source_prepare),
(gst_bus_source_check), (gst_bus_source_dispatch),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (poll_func), (poll_timeout), (gst_bus_poll):
* gst/gstbus.h:
* tools/gst-launch.c: (event_loop):
* tools/gst-md5sum.c: (event_loop):
GstBusHandler -> GstBusFunc, return value has the same meaning as
any other GSource (FALSE == remove source).
_add_watch() and _add_watch_full() now take a MessageType mask to
only handle specific types of messages.
_poll() returns the GstMessage instead of the message type to avoid
race conditions.
_have_pending() takes a MessageType mask now too.
Added testsuite for multiple bus watches.
Fix testsuites and applications for new bus API.
2005-09-19 11:18:03 +00:00
|
|
|
|
2005-09-20 17:30:35 +00:00
|
|
|
GST_DEBUG ("running mainloop %p", poll_data->loop);
|
2005-07-29 15:34:52 +00:00
|
|
|
g_main_loop_run (poll_data->loop);
|
2005-09-20 17:30:35 +00:00
|
|
|
GST_DEBUG ("mainloop stopped %p", poll_data->loop);
|
2005-11-10 18:15:24 +00:00
|
|
|
|
|
|
|
gst_bus_remove_signal_watch (bus);
|
|
|
|
|
GstBusHandler -> GstBusFunc, return value has the same meaning as any other GSource (FALSE == remove source).
Original commit message from CVS:
* check/gst/gstbin.c: (pop_messages), (GST_START_TEST):
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
* check/gst/gstpipeline.c: (GST_START_TEST):
* check/pipelines/cleanup.c: (run_pipeline):
* check/pipelines/simple_launch_lines.c: (run_pipeline),
(GST_START_TEST):
* gst/gstbus.c: (gst_bus_have_pending), (gst_bus_source_prepare),
(gst_bus_source_check), (gst_bus_source_dispatch),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (poll_func), (poll_timeout), (gst_bus_poll):
* gst/gstbus.h:
* tools/gst-launch.c: (event_loop):
* tools/gst-md5sum.c: (event_loop):
GstBusHandler -> GstBusFunc, return value has the same meaning as
any other GSource (FALSE == remove source).
_add_watch() and _add_watch_full() now take a MessageType mask to
only handle specific types of messages.
_poll() returns the GstMessage instead of the message type to avoid
race conditions.
_have_pending() takes a MessageType mask now too.
Added testsuite for multiple bus watches.
Fix testsuites and applications for new bus API.
2005-09-19 11:18:03 +00:00
|
|
|
/* holds a ref */
|
|
|
|
ret = poll_data->message;
|
docs/design/: Some more docs in the works.
Original commit message from CVS:
* docs/design/part-dynamic.txt:
* docs/design/part-events.txt:
* docs/design/part-seeking.txt:
Some more docs in the works.
* gst/base/gstbasetransform.c: (gst_base_transform_transform_caps),
(gst_base_transform_getcaps), (gst_base_transform_configure_caps),
(gst_base_transform_setcaps), (gst_base_transform_get_size),
(gst_base_transform_buffer_alloc), (gst_base_transform_event),
(gst_base_transform_handle_buffer),
(gst_base_transform_sink_activate_push),
(gst_base_transform_src_activate_pull),
(gst_base_transform_set_passthrough),
(gst_base_transform_is_passthrough):
Refcounting fixes.
* gst/gstbus.c: (gst_bus_source_dispatch), (gst_bus_poll):
Cleanups.
* gst/gstevent.c: (gst_event_finalize):
Set SRC to NULL.
* gst/gstutils.c: (gst_element_unlink),
(gst_pad_get_parent_element), (gst_pad_proxy_getcaps),
(gst_pad_proxy_setcaps):
* gst/gstutils.h:
Add _get_parent_element() to get a pads parent as an element.
2005-07-18 08:28:48 +00:00
|
|
|
|
2005-07-29 15:34:52 +00:00
|
|
|
if (poll_data->timeout_id)
|
|
|
|
g_source_remove (poll_data->timeout_id);
|
2005-03-21 17:34:02 +00:00
|
|
|
|
2005-11-10 18:15:24 +00:00
|
|
|
/* poll_data will be freed now */
|
|
|
|
g_signal_handler_disconnect (bus, id);
|
2005-03-21 17:34:02 +00:00
|
|
|
|
GstBusHandler -> GstBusFunc, return value has the same meaning as any other GSource (FALSE == remove source).
Original commit message from CVS:
* check/gst/gstbin.c: (pop_messages), (GST_START_TEST):
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
* check/gst/gstpipeline.c: (GST_START_TEST):
* check/pipelines/cleanup.c: (run_pipeline):
* check/pipelines/simple_launch_lines.c: (run_pipeline),
(GST_START_TEST):
* gst/gstbus.c: (gst_bus_have_pending), (gst_bus_source_prepare),
(gst_bus_source_check), (gst_bus_source_dispatch),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (poll_func), (poll_timeout), (gst_bus_poll):
* gst/gstbus.h:
* tools/gst-launch.c: (event_loop):
* tools/gst-md5sum.c: (event_loop):
GstBusHandler -> GstBusFunc, return value has the same meaning as
any other GSource (FALSE == remove source).
_add_watch() and _add_watch_full() now take a MessageType mask to
only handle specific types of messages.
_poll() returns the GstMessage instead of the message type to avoid
race conditions.
_have_pending() takes a MessageType mask now too.
Added testsuite for multiple bus watches.
Fix testsuites and applications for new bus API.
2005-09-19 11:18:03 +00:00
|
|
|
GST_DEBUG_OBJECT (bus, "finished poll with message %p", ret);
|
2005-03-21 17:34:02 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2005-09-28 16:43:20 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_bus_async_signal_func:
|
|
|
|
* @bus: a #GstBus
|
2005-10-28 18:18:23 +00:00
|
|
|
* @message: the #GstMessage received
|
2005-09-28 16:43:20 +00:00
|
|
|
* @data: user data
|
|
|
|
*
|
Documentation updates.
Original commit message from CVS:
* docs/gst/gstreamer-sections.txt:
* gst/gstbin.c: (bin_bus_handler), (gst_bin_handle_message_func):
* gst/gstbin.h:
* gst/gstbus.c: (gst_bus_class_init):
* gst/gstbus.h:
* gst/gstclock.c:
* gst/gstelement.c: (gst_element_set_locked_state):
* gst/gstsegment.c:
Documentation updates.
* gst/gstpipeline.c: (gst_pipeline_get_type),
(gst_pipeline_class_init), (gst_pipeline_init),
(gst_pipeline_dispose), (gst_pipeline_set_property),
(gst_pipeline_get_property), (do_pipeline_seek),
(gst_pipeline_send_event), (gst_pipeline_change_state),
(gst_pipeline_provide_clock_func), (gst_pipeline_set_delay),
(gst_pipeline_get_delay):
* gst/gstpipeline.h:
Added methods for setting the delay.
API: gst_pipeline_set_delay
API: gst_pipeline_get_delay
Add pipeline debug category
Various cleanups.
Updated docs.
Don't reset stream time when seek failed.
2006-03-13 11:04:38 +00:00
|
|
|
* A helper #GstBusFunc that can be used to convert all asynchronous messages
|
2005-09-28 16:43:20 +00:00
|
|
|
* into signals.
|
|
|
|
*
|
2014-05-29 21:54:34 +00:00
|
|
|
* Returns: %TRUE
|
2005-09-28 16:43:20 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_bus_async_signal_func (GstBus * bus, GstMessage * message, gpointer data)
|
|
|
|
{
|
|
|
|
GQuark detail = 0;
|
|
|
|
|
check/gst/gstbin.c: Change for new bus API.
Original commit message from CVS:
* check/gst/gstbin.c: (GST_START_TEST):
Change for new bus API.
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
Change for new bus signal API.
* gst/gstbus.c: (gst_bus_class_init), (gst_bus_have_pending),
(gst_bus_source_prepare), (gst_bus_source_check),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (gst_bus_poll), (gst_bus_async_signal_func),
(gst_bus_sync_signal_handler), (gst_bus_add_signal_watch):
* gst/gstbus.h:
Remove support for multiple GSources operating on different
message types as it is too complex and unneeded when using
signals.
Added support for receiving signals from the bus.
2005-09-29 13:07:37 +00:00
|
|
|
g_return_val_if_fail (GST_IS_BUS (bus), TRUE);
|
|
|
|
g_return_val_if_fail (message != NULL, TRUE);
|
|
|
|
|
2005-09-28 16:43:20 +00:00
|
|
|
detail = gst_message_type_to_quark (GST_MESSAGE_TYPE (message));
|
|
|
|
|
|
|
|
g_signal_emit (bus, gst_bus_signals[ASYNC_MESSAGE], detail, message);
|
|
|
|
|
|
|
|
/* we never remove this source based on signal emission return values */
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_bus_sync_signal_handler:
|
|
|
|
* @bus: a #GstBus
|
2005-10-28 18:18:23 +00:00
|
|
|
* @message: the #GstMessage received
|
2005-09-28 16:43:20 +00:00
|
|
|
* @data: user data
|
|
|
|
*
|
|
|
|
* A helper GstBusSyncHandler that can be used to convert all synchronous
|
|
|
|
* messages into signals.
|
|
|
|
*
|
|
|
|
* Returns: GST_BUS_PASS
|
|
|
|
*/
|
|
|
|
GstBusSyncReply
|
|
|
|
gst_bus_sync_signal_handler (GstBus * bus, GstMessage * message, gpointer data)
|
|
|
|
{
|
|
|
|
GQuark detail = 0;
|
|
|
|
|
check/gst/gstbin.c: Change for new bus API.
Original commit message from CVS:
* check/gst/gstbin.c: (GST_START_TEST):
Change for new bus API.
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
Change for new bus signal API.
* gst/gstbus.c: (gst_bus_class_init), (gst_bus_have_pending),
(gst_bus_source_prepare), (gst_bus_source_check),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (gst_bus_poll), (gst_bus_async_signal_func),
(gst_bus_sync_signal_handler), (gst_bus_add_signal_watch):
* gst/gstbus.h:
Remove support for multiple GSources operating on different
message types as it is too complex and unneeded when using
signals.
Added support for receiving signals from the bus.
2005-09-29 13:07:37 +00:00
|
|
|
g_return_val_if_fail (GST_IS_BUS (bus), GST_BUS_DROP);
|
|
|
|
g_return_val_if_fail (message != NULL, GST_BUS_DROP);
|
|
|
|
|
2005-09-28 16:43:20 +00:00
|
|
|
detail = gst_message_type_to_quark (GST_MESSAGE_TYPE (message));
|
|
|
|
|
|
|
|
g_signal_emit (bus, gst_bus_signals[SYNC_MESSAGE], detail, message);
|
|
|
|
|
|
|
|
return GST_BUS_PASS;
|
|
|
|
}
|
check/gst/gstbin.c: Change for new bus API.
Original commit message from CVS:
* check/gst/gstbin.c: (GST_START_TEST):
Change for new bus API.
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
Change for new bus signal API.
* gst/gstbus.c: (gst_bus_class_init), (gst_bus_have_pending),
(gst_bus_source_prepare), (gst_bus_source_check),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (gst_bus_poll), (gst_bus_async_signal_func),
(gst_bus_sync_signal_handler), (gst_bus_add_signal_watch):
* gst/gstbus.h:
Remove support for multiple GSources operating on different
message types as it is too complex and unneeded when using
signals.
Added support for receiving signals from the bus.
2005-09-29 13:07:37 +00:00
|
|
|
|
2006-02-10 16:04:59 +00:00
|
|
|
/**
|
|
|
|
* gst_bus_enable_sync_message_emission:
|
|
|
|
* @bus: a #GstBus on which you want to receive the "sync-message" signal
|
|
|
|
*
|
Documentation updates.
Original commit message from CVS:
* docs/gst/gstreamer-sections.txt:
* gst/gstbin.c: (bin_bus_handler), (gst_bin_handle_message_func):
* gst/gstbin.h:
* gst/gstbus.c: (gst_bus_class_init):
* gst/gstbus.h:
* gst/gstclock.c:
* gst/gstelement.c: (gst_element_set_locked_state):
* gst/gstsegment.c:
Documentation updates.
* gst/gstpipeline.c: (gst_pipeline_get_type),
(gst_pipeline_class_init), (gst_pipeline_init),
(gst_pipeline_dispose), (gst_pipeline_set_property),
(gst_pipeline_get_property), (do_pipeline_seek),
(gst_pipeline_send_event), (gst_pipeline_change_state),
(gst_pipeline_provide_clock_func), (gst_pipeline_set_delay),
(gst_pipeline_get_delay):
* gst/gstpipeline.h:
Added methods for setting the delay.
API: gst_pipeline_set_delay
API: gst_pipeline_get_delay
Add pipeline debug category
Various cleanups.
Updated docs.
Don't reset stream time when seek failed.
2006-03-13 11:04:38 +00:00
|
|
|
* Instructs GStreamer to emit the "sync-message" signal after running the bus's
|
2006-02-10 16:04:59 +00:00
|
|
|
* sync handler. This function is here so that code can ensure that they can
|
|
|
|
* synchronously receive messages without having to affect what the bin's sync
|
2009-12-11 16:46:42 +00:00
|
|
|
* handler is.
|
2006-02-10 16:04:59 +00:00
|
|
|
*
|
|
|
|
* This function may be called multiple times. To clean up, the caller is
|
|
|
|
* responsible for calling gst_bus_disable_sync_message_emission() as many times
|
|
|
|
* as this function is called.
|
|
|
|
*
|
|
|
|
* While this function looks similar to gst_bus_add_signal_watch(), it is not
|
2006-02-13 13:57:29 +00:00
|
|
|
* exactly the same -- this function enables <emphasis>synchronous</emphasis> emission of
|
Documentation updates.
Original commit message from CVS:
* docs/gst/gstreamer-sections.txt:
* gst/gstbin.c: (bin_bus_handler), (gst_bin_handle_message_func):
* gst/gstbin.h:
* gst/gstbus.c: (gst_bus_class_init):
* gst/gstbus.h:
* gst/gstclock.c:
* gst/gstelement.c: (gst_element_set_locked_state):
* gst/gstsegment.c:
Documentation updates.
* gst/gstpipeline.c: (gst_pipeline_get_type),
(gst_pipeline_class_init), (gst_pipeline_init),
(gst_pipeline_dispose), (gst_pipeline_set_property),
(gst_pipeline_get_property), (do_pipeline_seek),
(gst_pipeline_send_event), (gst_pipeline_change_state),
(gst_pipeline_provide_clock_func), (gst_pipeline_set_delay),
(gst_pipeline_get_delay):
* gst/gstpipeline.h:
Added methods for setting the delay.
API: gst_pipeline_set_delay
API: gst_pipeline_get_delay
Add pipeline debug category
Various cleanups.
Updated docs.
Don't reset stream time when seek failed.
2006-03-13 11:04:38 +00:00
|
|
|
* signals when messages arrive; gst_bus_add_signal_watch() adds an idle callback
|
2006-02-13 13:57:29 +00:00
|
|
|
* to pop messages off the bus <emphasis>asynchronously</emphasis>. The sync-message signal
|
Documentation updates.
Original commit message from CVS:
* docs/gst/gstreamer-sections.txt:
* gst/gstbin.c: (bin_bus_handler), (gst_bin_handle_message_func):
* gst/gstbin.h:
* gst/gstbus.c: (gst_bus_class_init):
* gst/gstbus.h:
* gst/gstclock.c:
* gst/gstelement.c: (gst_element_set_locked_state):
* gst/gstsegment.c:
Documentation updates.
* gst/gstpipeline.c: (gst_pipeline_get_type),
(gst_pipeline_class_init), (gst_pipeline_init),
(gst_pipeline_dispose), (gst_pipeline_set_property),
(gst_pipeline_get_property), (do_pipeline_seek),
(gst_pipeline_send_event), (gst_pipeline_change_state),
(gst_pipeline_provide_clock_func), (gst_pipeline_set_delay),
(gst_pipeline_get_delay):
* gst/gstpipeline.h:
Added methods for setting the delay.
API: gst_pipeline_set_delay
API: gst_pipeline_get_delay
Add pipeline debug category
Various cleanups.
Updated docs.
Don't reset stream time when seek failed.
2006-03-13 11:04:38 +00:00
|
|
|
* comes from the thread of whatever object posted the message; the "message"
|
2006-02-10 16:04:59 +00:00
|
|
|
* signal is marshalled to the main thread via the main loop.
|
|
|
|
*
|
|
|
|
* MT safe.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_bus_enable_sync_message_emission (GstBus * bus)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GST_IS_BUS (bus));
|
|
|
|
|
|
|
|
GST_OBJECT_LOCK (bus);
|
|
|
|
bus->priv->num_sync_message_emitters++;
|
|
|
|
GST_OBJECT_UNLOCK (bus);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_bus_disable_sync_message_emission:
|
|
|
|
* @bus: a #GstBus on which you previously called
|
|
|
|
* gst_bus_enable_sync_message_emission()
|
|
|
|
*
|
Documentation updates.
Original commit message from CVS:
* docs/gst/gstreamer-sections.txt:
* gst/gstbin.c: (bin_bus_handler), (gst_bin_handle_message_func):
* gst/gstbin.h:
* gst/gstbus.c: (gst_bus_class_init):
* gst/gstbus.h:
* gst/gstclock.c:
* gst/gstelement.c: (gst_element_set_locked_state):
* gst/gstsegment.c:
Documentation updates.
* gst/gstpipeline.c: (gst_pipeline_get_type),
(gst_pipeline_class_init), (gst_pipeline_init),
(gst_pipeline_dispose), (gst_pipeline_set_property),
(gst_pipeline_get_property), (do_pipeline_seek),
(gst_pipeline_send_event), (gst_pipeline_change_state),
(gst_pipeline_provide_clock_func), (gst_pipeline_set_delay),
(gst_pipeline_get_delay):
* gst/gstpipeline.h:
Added methods for setting the delay.
API: gst_pipeline_set_delay
API: gst_pipeline_get_delay
Add pipeline debug category
Various cleanups.
Updated docs.
Don't reset stream time when seek failed.
2006-03-13 11:04:38 +00:00
|
|
|
* Instructs GStreamer to stop emitting the "sync-message" signal for this bus.
|
2006-02-10 16:04:59 +00:00
|
|
|
* See gst_bus_enable_sync_message_emission() for more information.
|
|
|
|
*
|
|
|
|
* In the event that multiple pieces of code have called
|
|
|
|
* gst_bus_enable_sync_message_emission(), the sync-message emissions will only
|
|
|
|
* be stopped after all calls to gst_bus_enable_sync_message_emission() were
|
|
|
|
* "cancelled" by calling this function. In this way the semantics are exactly
|
Documentation updates.
Original commit message from CVS:
* docs/gst/gstreamer-sections.txt:
* gst/gstbin.c: (bin_bus_handler), (gst_bin_handle_message_func):
* gst/gstbin.h:
* gst/gstbus.c: (gst_bus_class_init):
* gst/gstbus.h:
* gst/gstclock.c:
* gst/gstelement.c: (gst_element_set_locked_state):
* gst/gstsegment.c:
Documentation updates.
* gst/gstpipeline.c: (gst_pipeline_get_type),
(gst_pipeline_class_init), (gst_pipeline_init),
(gst_pipeline_dispose), (gst_pipeline_set_property),
(gst_pipeline_get_property), (do_pipeline_seek),
(gst_pipeline_send_event), (gst_pipeline_change_state),
(gst_pipeline_provide_clock_func), (gst_pipeline_set_delay),
(gst_pipeline_get_delay):
* gst/gstpipeline.h:
Added methods for setting the delay.
API: gst_pipeline_set_delay
API: gst_pipeline_get_delay
Add pipeline debug category
Various cleanups.
Updated docs.
Don't reset stream time when seek failed.
2006-03-13 11:04:38 +00:00
|
|
|
* the same as gst_object_ref() that which calls enable should also call
|
2006-02-10 16:04:59 +00:00
|
|
|
* disable.
|
|
|
|
*
|
|
|
|
* MT safe.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_bus_disable_sync_message_emission (GstBus * bus)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GST_IS_BUS (bus));
|
2013-04-10 19:24:38 +00:00
|
|
|
g_return_if_fail (bus->priv->num_sync_message_emitters > 0);
|
2006-02-10 16:04:59 +00:00
|
|
|
|
|
|
|
GST_OBJECT_LOCK (bus);
|
|
|
|
bus->priv->num_sync_message_emitters--;
|
|
|
|
GST_OBJECT_UNLOCK (bus);
|
|
|
|
}
|
|
|
|
|
check/gst/gstbin.c: Change for new bus API.
Original commit message from CVS:
* check/gst/gstbin.c: (GST_START_TEST):
Change for new bus API.
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
Change for new bus signal API.
* gst/gstbus.c: (gst_bus_class_init), (gst_bus_have_pending),
(gst_bus_source_prepare), (gst_bus_source_check),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (gst_bus_poll), (gst_bus_async_signal_func),
(gst_bus_sync_signal_handler), (gst_bus_add_signal_watch):
* gst/gstbus.h:
Remove support for multiple GSources operating on different
message types as it is too complex and unneeded when using
signals.
Added support for receiving signals from the bus.
2005-09-29 13:07:37 +00:00
|
|
|
/**
|
2005-11-22 11:25:01 +00:00
|
|
|
* gst_bus_add_signal_watch_full:
|
2006-01-20 19:01:59 +00:00
|
|
|
* @bus: a #GstBus on which you want to receive the "message" signal
|
2005-11-22 11:25:01 +00:00
|
|
|
* @priority: The priority of the watch.
|
check/gst/gstbin.c: Change for new bus API.
Original commit message from CVS:
* check/gst/gstbin.c: (GST_START_TEST):
Change for new bus API.
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
Change for new bus signal API.
* gst/gstbus.c: (gst_bus_class_init), (gst_bus_have_pending),
(gst_bus_source_prepare), (gst_bus_source_check),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (gst_bus_poll), (gst_bus_async_signal_func),
(gst_bus_sync_signal_handler), (gst_bus_add_signal_watch):
* gst/gstbus.h:
Remove support for multiple GSources operating on different
message types as it is too complex and unneeded when using
signals.
Added support for receiving signals from the bus.
2005-09-29 13:07:37 +00:00
|
|
|
*
|
2010-05-19 12:57:08 +00:00
|
|
|
* Adds a bus signal watch to the default main context with the given @priority
|
2012-07-10 09:46:41 +00:00
|
|
|
* (e.g. %G_PRIORITY_DEFAULT). It is also possible to use a non-default main
|
|
|
|
* context set up using g_main_context_push_thread_default()
|
2011-01-31 15:58:18 +00:00
|
|
|
* (before one had to create a bus watch source and attach it to the desired
|
|
|
|
* main context 'manually').
|
|
|
|
*
|
Documentation updates.
Original commit message from CVS:
* docs/gst/gstreamer-sections.txt:
* gst/gstbin.c: (bin_bus_handler), (gst_bin_handle_message_func):
* gst/gstbin.h:
* gst/gstbus.c: (gst_bus_class_init):
* gst/gstbus.h:
* gst/gstclock.c:
* gst/gstelement.c: (gst_element_set_locked_state):
* gst/gstsegment.c:
Documentation updates.
* gst/gstpipeline.c: (gst_pipeline_get_type),
(gst_pipeline_class_init), (gst_pipeline_init),
(gst_pipeline_dispose), (gst_pipeline_set_property),
(gst_pipeline_get_property), (do_pipeline_seek),
(gst_pipeline_send_event), (gst_pipeline_change_state),
(gst_pipeline_provide_clock_func), (gst_pipeline_set_delay),
(gst_pipeline_get_delay):
* gst/gstpipeline.h:
Added methods for setting the delay.
API: gst_pipeline_set_delay
API: gst_pipeline_get_delay
Add pipeline debug category
Various cleanups.
Updated docs.
Don't reset stream time when seek failed.
2006-03-13 11:04:38 +00:00
|
|
|
* After calling this statement, the bus will emit the "message" signal for each
|
|
|
|
* message posted on the bus when the main loop is running.
|
check/gst/gstbin.c: Change for new bus API.
Original commit message from CVS:
* check/gst/gstbin.c: (GST_START_TEST):
Change for new bus API.
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
Change for new bus signal API.
* gst/gstbus.c: (gst_bus_class_init), (gst_bus_have_pending),
(gst_bus_source_prepare), (gst_bus_source_check),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (gst_bus_poll), (gst_bus_async_signal_func),
(gst_bus_sync_signal_handler), (gst_bus_add_signal_watch):
* gst/gstbus.h:
Remove support for multiple GSources operating on different
message types as it is too complex and unneeded when using
signals.
Added support for receiving signals from the bus.
2005-09-29 13:07:37 +00:00
|
|
|
*
|
2005-09-29 16:04:31 +00:00
|
|
|
* This function may be called multiple times. To clean up, the caller is
|
|
|
|
* responsible for calling gst_bus_remove_signal_watch() as many times as this
|
|
|
|
* function is called.
|
check/gst/gstbin.c: Change for new bus API.
Original commit message from CVS:
* check/gst/gstbin.c: (GST_START_TEST):
Change for new bus API.
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
Change for new bus signal API.
* gst/gstbus.c: (gst_bus_class_init), (gst_bus_have_pending),
(gst_bus_source_prepare), (gst_bus_source_check),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (gst_bus_poll), (gst_bus_async_signal_func),
(gst_bus_sync_signal_handler), (gst_bus_add_signal_watch):
* gst/gstbus.h:
Remove support for multiple GSources operating on different
message types as it is too complex and unneeded when using
signals.
Added support for receiving signals from the bus.
2005-09-29 13:07:37 +00:00
|
|
|
*
|
2011-10-13 15:33:06 +00:00
|
|
|
* There can only be a single bus watch per bus, you must remove any signal
|
|
|
|
* watch before you can set another type of watch.
|
2008-10-13 09:22:22 +00:00
|
|
|
*
|
check/gst/gstbin.c: Change for new bus API.
Original commit message from CVS:
* check/gst/gstbin.c: (GST_START_TEST):
Change for new bus API.
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
Change for new bus signal API.
* gst/gstbus.c: (gst_bus_class_init), (gst_bus_have_pending),
(gst_bus_source_prepare), (gst_bus_source_check),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (gst_bus_poll), (gst_bus_async_signal_func),
(gst_bus_sync_signal_handler), (gst_bus_add_signal_watch):
* gst/gstbus.h:
Remove support for multiple GSources operating on different
message types as it is too complex and unneeded when using
signals.
Added support for receiving signals from the bus.
2005-09-29 13:07:37 +00:00
|
|
|
* MT safe.
|
|
|
|
*/
|
2005-09-29 16:04:31 +00:00
|
|
|
void
|
2005-11-22 11:25:01 +00:00
|
|
|
gst_bus_add_signal_watch_full (GstBus * bus, gint priority)
|
check/gst/gstbin.c: Change for new bus API.
Original commit message from CVS:
* check/gst/gstbin.c: (GST_START_TEST):
Change for new bus API.
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
Change for new bus signal API.
* gst/gstbus.c: (gst_bus_class_init), (gst_bus_have_pending),
(gst_bus_source_prepare), (gst_bus_source_check),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (gst_bus_poll), (gst_bus_async_signal_func),
(gst_bus_sync_signal_handler), (gst_bus_add_signal_watch):
* gst/gstbus.h:
Remove support for multiple GSources operating on different
message types as it is too complex and unneeded when using
signals.
Added support for receiving signals from the bus.
2005-09-29 13:07:37 +00:00
|
|
|
{
|
2005-09-29 16:04:31 +00:00
|
|
|
g_return_if_fail (GST_IS_BUS (bus));
|
|
|
|
|
|
|
|
/* I know the callees don't take this lock, so go ahead and abuse it */
|
2005-11-21 16:34:26 +00:00
|
|
|
GST_OBJECT_LOCK (bus);
|
check/gst/gstbin.c: Change for new bus API.
Original commit message from CVS:
* check/gst/gstbin.c: (GST_START_TEST):
Change for new bus API.
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
Change for new bus signal API.
* gst/gstbus.c: (gst_bus_class_init), (gst_bus_have_pending),
(gst_bus_source_prepare), (gst_bus_source_check),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (gst_bus_poll), (gst_bus_async_signal_func),
(gst_bus_sync_signal_handler), (gst_bus_add_signal_watch):
* gst/gstbus.h:
Remove support for multiple GSources operating on different
message types as it is too complex and unneeded when using
signals.
Added support for receiving signals from the bus.
2005-09-29 13:07:37 +00:00
|
|
|
|
2012-02-26 15:32:32 +00:00
|
|
|
if (bus->priv->num_signal_watchers > 0)
|
2005-09-29 16:04:31 +00:00
|
|
|
goto done;
|
|
|
|
|
2008-10-13 10:50:17 +00:00
|
|
|
/* this should not fail because the counter above takes care of it */
|
2014-08-13 12:12:00 +00:00
|
|
|
g_assert (!bus->priv->signal_watch);
|
2005-09-29 16:04:31 +00:00
|
|
|
|
2014-08-13 12:12:00 +00:00
|
|
|
gst_bus_add_watch_full_unlocked (bus, priority, gst_bus_async_signal_func,
|
2008-10-13 10:50:17 +00:00
|
|
|
NULL, NULL);
|
2005-09-29 16:04:31 +00:00
|
|
|
|
2014-08-13 12:12:00 +00:00
|
|
|
if (G_UNLIKELY (!bus->priv->signal_watch))
|
2008-10-13 10:50:17 +00:00
|
|
|
goto add_failed;
|
2008-10-13 09:22:22 +00:00
|
|
|
|
2005-09-29 16:04:31 +00:00
|
|
|
done:
|
|
|
|
|
2012-02-26 15:32:32 +00:00
|
|
|
bus->priv->num_signal_watchers++;
|
2005-09-29 16:04:31 +00:00
|
|
|
|
2005-11-21 16:34:26 +00:00
|
|
|
GST_OBJECT_UNLOCK (bus);
|
2008-10-13 10:50:17 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
add_failed:
|
|
|
|
{
|
|
|
|
g_critical ("Could not add signal watch to bus %s", GST_OBJECT_NAME (bus));
|
|
|
|
GST_OBJECT_UNLOCK (bus);
|
|
|
|
return;
|
|
|
|
}
|
2005-09-29 16:04:31 +00:00
|
|
|
}
|
|
|
|
|
2005-11-22 11:25:01 +00:00
|
|
|
/**
|
|
|
|
* gst_bus_add_signal_watch:
|
2006-01-20 19:01:59 +00:00
|
|
|
* @bus: a #GstBus on which you want to receive the "message" signal
|
2005-11-22 11:25:01 +00:00
|
|
|
*
|
2010-05-19 12:57:08 +00:00
|
|
|
* Adds a bus signal watch to the default main context with the default priority
|
2012-07-10 09:46:41 +00:00
|
|
|
* (%G_PRIORITY_DEFAULT). It is also possible to use a non-default
|
2011-01-31 15:58:18 +00:00
|
|
|
* main context set up using g_main_context_push_thread_default() (before
|
|
|
|
* one had to create a bus watch source and attach it to the desired main
|
|
|
|
* context 'manually').
|
|
|
|
*
|
Documentation updates.
Original commit message from CVS:
* docs/gst/gstreamer-sections.txt:
* gst/gstbin.c: (bin_bus_handler), (gst_bin_handle_message_func):
* gst/gstbin.h:
* gst/gstbus.c: (gst_bus_class_init):
* gst/gstbus.h:
* gst/gstclock.c:
* gst/gstelement.c: (gst_element_set_locked_state):
* gst/gstsegment.c:
Documentation updates.
* gst/gstpipeline.c: (gst_pipeline_get_type),
(gst_pipeline_class_init), (gst_pipeline_init),
(gst_pipeline_dispose), (gst_pipeline_set_property),
(gst_pipeline_get_property), (do_pipeline_seek),
(gst_pipeline_send_event), (gst_pipeline_change_state),
(gst_pipeline_provide_clock_func), (gst_pipeline_set_delay),
(gst_pipeline_get_delay):
* gst/gstpipeline.h:
Added methods for setting the delay.
API: gst_pipeline_set_delay
API: gst_pipeline_get_delay
Add pipeline debug category
Various cleanups.
Updated docs.
Don't reset stream time when seek failed.
2006-03-13 11:04:38 +00:00
|
|
|
* After calling this statement, the bus will emit the "message" signal for each
|
2005-11-22 11:25:01 +00:00
|
|
|
* message posted on the bus.
|
|
|
|
*
|
|
|
|
* This function may be called multiple times. To clean up, the caller is
|
|
|
|
* responsible for calling gst_bus_remove_signal_watch() as many times as this
|
|
|
|
* function is called.
|
|
|
|
*
|
|
|
|
* MT safe.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_bus_add_signal_watch (GstBus * bus)
|
|
|
|
{
|
|
|
|
gst_bus_add_signal_watch_full (bus, G_PRIORITY_DEFAULT);
|
|
|
|
}
|
|
|
|
|
2005-09-29 16:04:31 +00:00
|
|
|
/**
|
|
|
|
* gst_bus_remove_signal_watch:
|
|
|
|
* @bus: a #GstBus you previously added a signal watch to
|
|
|
|
*
|
|
|
|
* Removes a signal watch previously added with gst_bus_add_signal_watch().
|
|
|
|
*
|
|
|
|
* MT safe.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_bus_remove_signal_watch (GstBus * bus)
|
|
|
|
{
|
2014-08-13 12:12:00 +00:00
|
|
|
GSource *source = NULL;
|
2008-10-13 10:50:17 +00:00
|
|
|
|
2005-09-29 16:04:31 +00:00
|
|
|
g_return_if_fail (GST_IS_BUS (bus));
|
|
|
|
|
|
|
|
/* I know the callees don't take this lock, so go ahead and abuse it */
|
2005-11-21 16:34:26 +00:00
|
|
|
GST_OBJECT_LOCK (bus);
|
2005-09-29 16:04:31 +00:00
|
|
|
|
2012-02-26 15:32:32 +00:00
|
|
|
if (bus->priv->num_signal_watchers == 0)
|
2005-09-29 16:04:31 +00:00
|
|
|
goto error;
|
|
|
|
|
2012-02-26 15:32:32 +00:00
|
|
|
bus->priv->num_signal_watchers--;
|
2005-09-29 16:04:31 +00:00
|
|
|
|
2012-02-26 15:32:32 +00:00
|
|
|
if (bus->priv->num_signal_watchers > 0)
|
2005-09-29 16:04:31 +00:00
|
|
|
goto done;
|
|
|
|
|
2014-08-13 12:12:00 +00:00
|
|
|
GST_DEBUG_OBJECT (bus, "removing signal watch %u",
|
|
|
|
g_source_get_id (bus->priv->signal_watch));
|
2005-09-29 16:04:31 +00:00
|
|
|
|
2014-08-13 12:12:00 +00:00
|
|
|
source = bus->priv->signal_watch;
|
2008-10-13 10:50:17 +00:00
|
|
|
|
2005-09-29 16:04:31 +00:00
|
|
|
done:
|
2005-11-21 16:34:26 +00:00
|
|
|
GST_OBJECT_UNLOCK (bus);
|
2008-10-13 10:50:17 +00:00
|
|
|
|
2014-08-13 12:12:00 +00:00
|
|
|
if (source)
|
|
|
|
g_source_destroy (source);
|
2008-10-13 10:50:17 +00:00
|
|
|
|
2005-09-29 16:04:31 +00:00
|
|
|
return;
|
|
|
|
|
2008-10-13 10:50:17 +00:00
|
|
|
/* ERRORS */
|
2005-09-29 16:04:31 +00:00
|
|
|
error:
|
|
|
|
{
|
|
|
|
g_critical ("Bus %s has no signal watches attached", GST_OBJECT_NAME (bus));
|
2005-11-21 16:34:26 +00:00
|
|
|
GST_OBJECT_UNLOCK (bus);
|
2005-09-29 16:04:31 +00:00
|
|
|
return;
|
|
|
|
}
|
check/gst/gstbin.c: Change for new bus API.
Original commit message from CVS:
* check/gst/gstbin.c: (GST_START_TEST):
Change for new bus API.
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
Change for new bus signal API.
* gst/gstbus.c: (gst_bus_class_init), (gst_bus_have_pending),
(gst_bus_source_prepare), (gst_bus_source_check),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (gst_bus_poll), (gst_bus_async_signal_func),
(gst_bus_sync_signal_handler), (gst_bus_add_signal_watch):
* gst/gstbus.h:
Remove support for multiple GSources operating on different
message types as it is too complex and unneeded when using
signals.
Added support for receiving signals from the bus.
2005-09-29 13:07:37 +00:00
|
|
|
}
|