mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-20 15:27:07 +00:00
Revert "bus: change GstBusSource to hold a weak ref to GstBus"
This reverts commit 894c67e642
.
This commit is contained in:
parent
90b1b1dd96
commit
82e529cea5
2 changed files with 28 additions and 45 deletions
33
gst/gstbus.c
33
gst/gstbus.c
|
@ -741,7 +741,7 @@ no_replace:
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
GSource source;
|
GSource source;
|
||||||
GWeakRef bus_ref;
|
GstBus *bus;
|
||||||
} GstBusSource;
|
} GstBusSource;
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -755,16 +755,8 @@ static gboolean
|
||||||
gst_bus_source_check (GSource * source)
|
gst_bus_source_check (GSource * source)
|
||||||
{
|
{
|
||||||
GstBusSource *bsrc = (GstBusSource *) source;
|
GstBusSource *bsrc = (GstBusSource *) source;
|
||||||
GstBus *bus;
|
|
||||||
gboolean ret = FALSE;
|
|
||||||
|
|
||||||
bus = g_weak_ref_get (&bsrc->bus_ref);
|
return bsrc->bus->priv->pollfd.revents & (G_IO_IN | G_IO_HUP | G_IO_ERR);
|
||||||
if (bus) {
|
|
||||||
ret = bus->priv->pollfd.revents & (G_IO_IN | G_IO_HUP | G_IO_ERR);
|
|
||||||
g_object_unref (bus);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -774,14 +766,13 @@ gst_bus_source_dispatch (GSource * source, GSourceFunc callback,
|
||||||
GstBusFunc handler = (GstBusFunc) callback;
|
GstBusFunc handler = (GstBusFunc) callback;
|
||||||
GstBusSource *bsource = (GstBusSource *) source;
|
GstBusSource *bsource = (GstBusSource *) source;
|
||||||
GstMessage *message;
|
GstMessage *message;
|
||||||
gboolean keep = TRUE;
|
gboolean keep;
|
||||||
GstBus *bus;
|
GstBus *bus;
|
||||||
|
|
||||||
g_return_val_if_fail (bsource != NULL, FALSE);
|
g_return_val_if_fail (bsource != NULL, FALSE);
|
||||||
|
|
||||||
bus = g_weak_ref_get (&bsource->bus_ref);
|
bus = bsource->bus;
|
||||||
|
|
||||||
if (bus) {
|
|
||||||
g_return_val_if_fail (GST_IS_BUS (bus), FALSE);
|
g_return_val_if_fail (GST_IS_BUS (bus), FALSE);
|
||||||
|
|
||||||
message = gst_bus_pop (bus);
|
message = gst_bus_pop (bus);
|
||||||
|
@ -801,12 +792,6 @@ gst_bus_source_dispatch (GSource * source, GSourceFunc callback,
|
||||||
gst_message_unref (message);
|
gst_message_unref (message);
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (bus, "source %p handler returns %d", source, keep);
|
GST_DEBUG_OBJECT (bus, "source %p handler returns %d", source, keep);
|
||||||
g_object_unref (bus);
|
|
||||||
} else {
|
|
||||||
GST_WARNING ("GstBusSource without a bus and still attached to a context."
|
|
||||||
" The application is responsible for removing the GstBus"
|
|
||||||
" watch when it isn't needed anymore.");
|
|
||||||
}
|
|
||||||
|
|
||||||
return keep;
|
return keep;
|
||||||
|
|
||||||
|
@ -825,9 +810,8 @@ gst_bus_source_finalize (GSource * source)
|
||||||
GstBusSource *bsource = (GstBusSource *) source;
|
GstBusSource *bsource = (GstBusSource *) source;
|
||||||
GstBus *bus;
|
GstBus *bus;
|
||||||
|
|
||||||
bus = g_weak_ref_get (&bsource->bus_ref);
|
bus = bsource->bus;
|
||||||
|
|
||||||
if (bus) {
|
|
||||||
GST_DEBUG_OBJECT (bus, "finalize source %p", source);
|
GST_DEBUG_OBJECT (bus, "finalize source %p", source);
|
||||||
|
|
||||||
GST_OBJECT_LOCK (bus);
|
GST_OBJECT_LOCK (bus);
|
||||||
|
@ -835,9 +819,8 @@ gst_bus_source_finalize (GSource * source)
|
||||||
bus->priv->signal_watch = NULL;
|
bus->priv->signal_watch = NULL;
|
||||||
GST_OBJECT_UNLOCK (bus);
|
GST_OBJECT_UNLOCK (bus);
|
||||||
|
|
||||||
g_object_unref (bus);
|
gst_object_unref (bsource->bus);
|
||||||
}
|
bsource->bus = NULL;
|
||||||
g_weak_ref_clear (&bsource->bus_ref);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static GSourceFuncs gst_bus_source_funcs = {
|
static GSourceFuncs gst_bus_source_funcs = {
|
||||||
|
@ -870,7 +853,7 @@ gst_bus_create_watch (GstBus * bus)
|
||||||
|
|
||||||
g_source_set_name ((GSource *) source, "GStreamer message bus watch");
|
g_source_set_name ((GSource *) source, "GStreamer message bus watch");
|
||||||
|
|
||||||
g_weak_ref_init (&source->bus_ref, (GObject *) bus);
|
source->bus = gst_object_ref (bus);
|
||||||
g_source_add_poll ((GSource *) source, &bus->priv->pollfd);
|
g_source_add_poll ((GSource *) source, &bus->priv->pollfd);
|
||||||
|
|
||||||
return (GSource *) source;
|
return (GSource *) source;
|
||||||
|
|
|
@ -200,7 +200,7 @@ GST_START_TEST (test_bus)
|
||||||
|
|
||||||
id = gst_bus_add_watch (bus, message_received, pipeline);
|
id = gst_bus_add_watch (bus, message_received, pipeline);
|
||||||
ASSERT_OBJECT_REFCOUNT (pipeline, "pipeline after add_watch", 1);
|
ASSERT_OBJECT_REFCOUNT (pipeline, "pipeline after add_watch", 1);
|
||||||
ASSERT_OBJECT_REFCOUNT (bus, "bus after add_watch", 2);
|
ASSERT_OBJECT_REFCOUNT (bus, "bus after add_watch", 3);
|
||||||
|
|
||||||
ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
||||||
fail_unless (ret == GST_STATE_CHANGE_ASYNC);
|
fail_unless (ret == GST_STATE_CHANGE_ASYNC);
|
||||||
|
@ -225,7 +225,7 @@ GST_START_TEST (test_bus)
|
||||||
fail_unless (current == GST_STATE_NULL, "state is not NULL but %d", current);
|
fail_unless (current == GST_STATE_NULL, "state is not NULL but %d", current);
|
||||||
|
|
||||||
ASSERT_OBJECT_REFCOUNT (pipeline, "pipeline at start of cleanup", 1);
|
ASSERT_OBJECT_REFCOUNT (pipeline, "pipeline at start of cleanup", 1);
|
||||||
ASSERT_OBJECT_REFCOUNT (bus, "bus at start of cleanup", 2);
|
ASSERT_OBJECT_REFCOUNT (bus, "bus at start of cleanup", 3);
|
||||||
|
|
||||||
fail_unless (g_source_remove (id));
|
fail_unless (g_source_remove (id));
|
||||||
ASSERT_OBJECT_REFCOUNT (bus, "bus after removing source", 2);
|
ASSERT_OBJECT_REFCOUNT (bus, "bus after removing source", 2);
|
||||||
|
|
Loading…
Reference in a new issue