[Spice-commits] 3 commits - src/spice-gstaudio.c tools/spicy.c tools/spicy-connect.c

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Feb 19 13:45:58 UTC 2021


 src/spice-gstaudio.c  |   11 ++++++++++-
 tools/spicy-connect.c |    1 +
 tools/spicy.c         |    3 +++
 3 files changed, 14 insertions(+), 1 deletion(-)

New commits:
commit 0ad07adc3ea3cce66f5551104caabea6a7e5ab6b
Author: Jakub Janků <jjanku at redhat.com>
Date:   Fri Feb 19 11:24:47 2021 +0100

    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 at redhat.com>

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");
commit 5f65dccb1a11c2901bdc8bf819834a5ffd666eca
Author: Jakub Janků <jjanku at redhat.com>
Date:   Wed Feb 17 18:55:36 2021 +0100

    spicy: destroy all windows on disconnection
    
    SpiceWidget holds a strong reference on the SpiceSession.
    If the windows are not destroyed, the session isn't freed either.
    
    session_disconnect() does destroy all the channels, but other
    objects aren't released until the session's dispose
    (audio manager, usb manager, webdav).
    
    Signed-off-by: Jakub Janků <jjanku at redhat.com>

diff --git a/tools/spicy.c b/tools/spicy.c
index b786aa0..5add733 100644
--- a/tools/spicy.c
+++ b/tools/spicy.c
@@ -1899,6 +1899,9 @@ static void connection_disconnect(spice_connection *conn)
 static void connection_destroy(SpiceSession *session,
                                spice_connection *conn)
 {
+    for (int i = 0; i < SPICE_N_ELEMENTS(conn->wins); i++) {
+        destroy_spice_window(conn->wins[i]);
+    }
     g_object_unref(conn->session);
     g_hash_table_unref(conn->transfers);
     g_free(conn);
commit 09580733f3e1719df5d6bacfa7ce82fced4d00d4
Author: Jakub Janků <jjanku at redhat.com>
Date:   Wed Feb 17 15:07:47 2021 +0100

    spicy-connect: unref GMainLoop
    
    Signed-off-by: Jakub Janků <jjanku at redhat.com>

diff --git a/tools/spicy-connect.c b/tools/spicy-connect.c
index 39555a6..c4c5a1d 100644
--- a/tools/spicy-connect.c
+++ b/tools/spicy-connect.c
@@ -241,6 +241,7 @@ gboolean spicy_connect_dialog(SpiceSession *session)
 
     info.loop = g_main_loop_new(NULL, FALSE);
     g_main_loop_run(info.loop);
+    g_clear_pointer(&info.loop, g_main_loop_unref);
 
     gtk_widget_destroy(GTK_WIDGET(window));
 


More information about the Spice-commits mailing list