[gnome-remote-desktop] rdp-pipewire-stream: Use common helper for PipeWire source creation



commit a8458c7b081519fba6bc54ddf457b05882cfec06
Author: Pascal Nowack <Pascal Nowack gmx de>
Date:   Tue Jul 12 08:30:40 2022 +0200

    rdp-pipewire-stream: Use common helper for PipeWire source creation

 src/grd-rdp-pipewire-stream.c | 75 ++-----------------------------------------
 1 file changed, 3 insertions(+), 72 deletions(-)
---
diff --git a/src/grd-rdp-pipewire-stream.c b/src/grd-rdp-pipewire-stream.c
index f9b6220b..88a465da 100644
--- a/src/grd-rdp-pipewire-stream.c
+++ b/src/grd-rdp-pipewire-stream.c
@@ -27,7 +27,6 @@
 #include <spa/param/props.h>
 #include <spa/param/format-utils.h>
 #include <spa/param/video/format-utils.h>
-#include <spa/utils/result.h>
 #include <sys/mman.h>
 
 #include "grd-context.h"
@@ -273,71 +272,6 @@ create_render_source (GrdRdpPipeWireStream *stream,
   g_source_attach (stream->render_source, render_context);
 }
 
-static gboolean
-pipewire_loop_source_prepare (GSource *base,
-                              int     *timeout)
-{
-  *timeout = -1;
-  return FALSE;
-}
-
-static gboolean
-pipewire_loop_source_dispatch (GSource     *source,
-                               GSourceFunc  callback,
-                               gpointer     user_data)
-{
-  GrdPipeWireSource *pipewire_source = (GrdPipeWireSource *) source;
-  int result;
-
-  result = pw_loop_iterate (pipewire_source->pipewire_loop, 0);
-  if (result < 0)
-    g_warning ("pipewire_loop_iterate failed: %s", spa_strerror (result));
-
-  return TRUE;
-}
-
-static void
-pipewire_loop_source_finalize (GSource *source)
-{
-  GrdPipeWireSource *pipewire_source = (GrdPipeWireSource *) source;
-
-  pw_loop_leave (pipewire_source->pipewire_loop);
-  pw_loop_destroy (pipewire_source->pipewire_loop);
-}
-
-static GSourceFuncs pipewire_source_funcs =
-{
-  pipewire_loop_source_prepare,
-  NULL,
-  pipewire_loop_source_dispatch,
-  pipewire_loop_source_finalize
-};
-
-static GrdPipeWireSource *
-create_pipewire_source (void)
-{
-  GrdPipeWireSource *pipewire_source;
-
-  pipewire_source =
-    (GrdPipeWireSource *) g_source_new (&pipewire_source_funcs,
-                                        sizeof (GrdPipeWireSource));
-  pipewire_source->pipewire_loop = pw_loop_new (NULL);
-  if (!pipewire_source->pipewire_loop)
-    {
-      g_source_destroy ((GSource *) pipewire_source);
-      return NULL;
-    }
-
-  g_source_add_unix_fd (&pipewire_source->base,
-                        pw_loop_get_fd (pipewire_source->pipewire_loop),
-                        G_IO_IN | G_IO_ERR);
-
-  pw_loop_enter (pipewire_source->pipewire_loop);
-  g_source_attach (&pipewire_source->base, NULL);
-
-  return pipewire_source;
-}
-
 static void
 on_stream_state_changed (void                 *user_data,
                          enum pw_stream_state  old,
@@ -1163,13 +1097,10 @@ grd_rdp_pipewire_stream_new (GrdSessionRdp               *session_rdp,
 
   create_render_source (stream, render_context);
 
-  pipewire_source = create_pipewire_source ();
+  pipewire_source = grd_attached_pipewire_source_new ("RDP", error);
   if (!pipewire_source)
-    {
-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
-                   "Failed to create PipeWire source");
-      return NULL;
-    }
+    return NULL;
+
   stream->pipewire_source = (GSource *) pipewire_source;
 
   stream->pipewire_context = pw_context_new (pipewire_source->pipewire_loop,


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