[gnome-remote-desktop] vnc-pipewire-stream: Properly deinitialize PipeWire upon destruction



commit 230dbf370315c12ef2f6d288784a19e741c18621
Author: Pascal Nowack <Pascal Nowack gmx de>
Date:   Thu May 5 07:36:16 2022 +0200

    vnc-pipewire-stream: Properly deinitialize PipeWire upon destruction
    
    Currently, gnome-remote-desktop never calls pw_deinit(), resulting in
    leaking resources.
    With the current implementation, simply calling pw_deinit() is not
    possible, since multiple remote desktop sessions can run at the same
    time and therefore multiple PipeWire streams too.
    Since PipeWire 0.3.49 pw_init() and pw_deinit() can be called multiple
    times, removing the need of a global variable.
    PipeWire now internally tracks the reference count, which is increased
    by calling pw_init() and decreased by calling pw_deinit().
    
    So, replace the grd_maybe_initialize_pipewire() call with pw_init() and
    also call pw_deinit(), when destructing the PipeWire class instance.

 src/grd-vnc-pipewire-stream.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/src/grd-vnc-pipewire-stream.c b/src/grd-vnc-pipewire-stream.c
index ffcbad2b..677b8a02 100644
--- a/src/grd-vnc-pipewire-stream.c
+++ b/src/grd-vnc-pipewire-stream.c
@@ -849,12 +849,12 @@ grd_vnc_pipewire_stream_new (GrdSessionVnc  *session_vnc,
   GrdPipeWireSource *pipewire_source;
   GSource *source;
 
-  grd_maybe_initialize_pipewire ();
-
   stream = g_object_new (GRD_TYPE_VNC_PIPEWIRE_STREAM, NULL);
   stream->session = session_vnc;
   stream->src_node_id = src_node_id;
 
+  pw_init (NULL, NULL);
+
   pipewire_source = create_pipewire_source ();
   if (!pipewire_source)
     {
@@ -969,6 +969,8 @@ grd_vnc_pipewire_stream_finalize (GObject *object)
 
   g_mutex_clear (&stream->frame_mutex);
 
+  pw_deinit ();
+
   G_OBJECT_CLASS (grd_vnc_pipewire_stream_parent_class)->finalize (object);
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]