diff options
author | Jakub Janků <jjanku@redhat.com> | 2021-02-19 11:24:47 +0100 |
---|---|---|
committer | Jakub Janků <jjanku@redhat.com> | 2021-02-19 12:44:23 +0100 |
commit | 0ad07adc3ea3cce66f5551104caabea6a7e5ab6b (patch) | |
tree | b3f5a6d8b3d89f98f69013e4382f7d202cbe0dab | |
parent | 5f65dccb1a11c2901bdc8bf819834a5ffd666eca (diff) |
gstaudio: remove record bus watch to release GstBus
The GSource added by gst_bus_add_watch() apparently holds
a reference to the GstBus. This can be seen by running
GST_DEBUG="GST_TRACER:7" GST_TRACERS="leaks" spicy:
GST_TRACER :0:: object-alive, type-name=(string)GstBus, address=(gpointer)0x1e76db0, description=(string)<bus6>, ref-count=(uint)1, trace=(string);
(note that gst_deinit() must be called for this output to be shown,
which doesn't happen in virt-viewer; see 0381e62)
To fix this, save the source's id returned by gst_bus_add_watch()
and remove the source when the pipe is unreferenced.
Signed-off-by: Jakub Janků <jjanku@redhat.com>
-rw-r--r-- | src/spice-gstaudio.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/spice-gstaudio.c b/src/spice-gstaudio.c index d56e19b..d67727f 100644 --- a/src/spice-gstaudio.c +++ b/src/spice-gstaudio.c @@ -41,6 +41,7 @@ struct _SpiceGstaudioPrivate { struct stream playback; struct stream record; guint mmtime_id; + guint rbus_watch_id; }; G_DEFINE_TYPE_WITH_PRIVATE(SpiceGstaudio, spice_gstaudio, SPICE_TYPE_AUDIO) @@ -77,6 +78,10 @@ static void spice_gstaudio_dispose(GObject *obj) p = gstaudio->priv; stream_dispose(&p->playback); + if (p->rbus_watch_id > 0) { + g_source_remove(p->rbus_watch_id); + p->rbus_watch_id = 0; + } stream_dispose(&p->record); if (p->pchannel) @@ -191,6 +196,10 @@ static void record_start(SpiceRecordChannel *channel, gint format, gint channels (p->record.rate != frequency || p->record.channels != channels)) { gst_element_set_state(p->record.pipe, GST_STATE_NULL); + if (p->rbus_watch_id > 0) { + g_source_remove(p->rbus_watch_id); + p->rbus_watch_id = 0; + } g_clear_pointer(&p->record.pipe, gst_object_unref); } @@ -211,7 +220,7 @@ static void record_start(SpiceRecordChannel *channel, gint format, gint channels } bus = gst_pipeline_get_bus(GST_PIPELINE(p->record.pipe)); - gst_bus_add_watch(bus, record_bus_cb, data); + p->rbus_watch_id = gst_bus_add_watch(bus, record_bus_cb, data); gst_object_unref(GST_OBJECT(bus)); p->record.src = gst_bin_get_by_name(GST_BIN(p->record.pipe), "audiosrc"); |