summaryrefslogtreecommitdiff
path: root/gst/gstbus.c
diff options
context:
space:
mode:
authorPhilippe Normand <philn@igalia.com>2014-08-13 14:12:00 +0200
committerSebastian Dröge <sebastian@centricular.com>2014-08-13 18:44:39 +0300
commitb1f23598099da82835df60bc2fb09501233f9118 (patch)
tree0609f3124964af64d8f1bb793d6336d333717b3d /gst/gstbus.c
parent78e22645444fa3784e0bcf4e2b1d0858be3af4fb (diff)
bus: destroy signal watch from the context it was mapped to
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
Diffstat (limited to 'gst/gstbus.c')
-rw-r--r--gst/gstbus.c30
1 files changed, 14 insertions, 16 deletions
diff --git a/gst/gstbus.c b/gst/gstbus.c
index 0d784e19d..2550a286d 100644
--- a/gst/gstbus.c
+++ b/gst/gstbus.c
@@ -111,11 +111,10 @@ struct _GstBusPrivate
gpointer sync_handler_data;
GDestroyNotify sync_handler_notify;
- guint signal_watch_id;
guint num_signal_watchers;
guint num_sync_message_emitters;
- GSource *watch_id;
+ GSource *signal_watch;
gboolean enable_async;
GstPoll *poll;
@@ -799,8 +798,8 @@ gst_bus_source_finalize (GSource * source)
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);
@@ -852,7 +851,7 @@ gst_bus_add_watch_full_unlocked (GstBus * bus, gint priority,
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;
@@ -870,7 +869,7 @@ gst_bus_add_watch_full_unlocked (GstBus * bus, gint priority,
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);
@@ -1255,13 +1254,12 @@ gst_bus_add_signal_watch_full (GstBus * bus, gint priority)
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,
NULL, NULL);
- if (G_UNLIKELY (bus->priv->signal_watch_id == 0))
+ if (G_UNLIKELY (!bus->priv->signal_watch))
goto add_failed;
done:
@@ -1316,7 +1314,7 @@ gst_bus_add_signal_watch (GstBus * bus)
void
gst_bus_remove_signal_watch (GstBus * bus)
{
- guint id = 0;
+ GSource *source = NULL;
g_return_if_fail (GST_IS_BUS (bus));
@@ -1331,16 +1329,16 @@ gst_bus_remove_signal_watch (GstBus * bus)
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);
- if (id)
- g_source_remove (id);
+ if (source)
+ g_source_destroy (source);
return;