Don't rely on g_source_remove() because it operates on the main
context. If a signal watch was added to a new thread-default context
g_source_remove() would have no effect. So simply use
g_source_destroy() to avoid this problem.
Additionally the source_id was removed from GstBusPrivate because it
was redundant with the signal watch GSource also stored in that
structure.
https://bugzilla.gnome.org/show_bug.cgi?id=734716
gpointer sync_handler_data;
GDestroyNotify sync_handler_notify;
gpointer sync_handler_data;
GDestroyNotify sync_handler_notify;
guint num_signal_watchers;
guint num_sync_message_emitters;
guint num_signal_watchers;
guint num_sync_message_emitters;
gboolean enable_async;
GstPoll *poll;
gboolean enable_async;
GstPoll *poll;
GST_DEBUG_OBJECT (bus, "finalize source %p", source);
GST_OBJECT_LOCK (bus);
GST_DEBUG_OBJECT (bus, "finalize source %p", source);
GST_OBJECT_LOCK (bus);
- if (bus->priv->watch_id == source)
- bus->priv->watch_id = NULL;
+ if (bus->priv->signal_watch == source)
+ bus->priv->signal_watch = NULL;
GST_OBJECT_UNLOCK (bus);
gst_object_unref (bsource->bus);
GST_OBJECT_UNLOCK (bus);
gst_object_unref (bsource->bus);
guint id;
GSource *source;
guint id;
GSource *source;
- if (bus->priv->watch_id) {
+ if (bus->priv->signal_watch) {
GST_ERROR_OBJECT (bus,
"Tried to add new watch while one was already there");
return 0;
GST_ERROR_OBJECT (bus,
"Tried to add new watch while one was already there");
return 0;
g_source_unref (source);
if (id) {
g_source_unref (source);
if (id) {
- bus->priv->watch_id = source;
+ bus->priv->signal_watch = source;
}
GST_DEBUG_OBJECT (bus, "New source %p with id %u", source, id);
}
GST_DEBUG_OBJECT (bus, "New source %p with id %u", source, id);
goto done;
/* this should not fail because the counter above takes care of it */
goto done;
/* this should not fail because the counter above takes care of it */
- g_assert (bus->priv->signal_watch_id == 0);
+ g_assert (!bus->priv->signal_watch);
- bus->priv->signal_watch_id =
- gst_bus_add_watch_full_unlocked (bus, priority, gst_bus_async_signal_func,
+ gst_bus_add_watch_full_unlocked (bus, priority, gst_bus_async_signal_func,
- if (G_UNLIKELY (bus->priv->signal_watch_id == 0))
+ if (G_UNLIKELY (!bus->priv->signal_watch))
void
gst_bus_remove_signal_watch (GstBus * bus)
{
void
gst_bus_remove_signal_watch (GstBus * bus)
{
+ GSource *source = NULL;
g_return_if_fail (GST_IS_BUS (bus));
g_return_if_fail (GST_IS_BUS (bus));
if (bus->priv->num_signal_watchers > 0)
goto done;
if (bus->priv->num_signal_watchers > 0)
goto done;
- id = bus->priv->signal_watch_id;
- bus->priv->signal_watch_id = 0;
+ GST_DEBUG_OBJECT (bus, "removing signal watch %u",
+ g_source_get_id (bus->priv->signal_watch));
- GST_DEBUG_OBJECT (bus, "removing signal watch %u", id);
+ source = bus->priv->signal_watch;
done:
GST_OBJECT_UNLOCK (bus);
done:
GST_OBJECT_UNLOCK (bus);
- if (id)
- g_source_remove (id);
+ if (source)
+ g_source_destroy (source);