[gnome-remote-desktop] vnc-pipewire-stream: Simplify buffer merging



commit cf3082697d58229321f37b73cfdeb624d8506e76
Author: Jonas Ådahl <jadahl gmail com>
Date:   Fri Nov 5 12:25:12 2021 +0100

    vnc-pipewire-stream: Simplify buffer merging
    
    Adds a variable to the pending frame, that will be removed. Makes for
    slightly shorter code, and will help with future changes.

 src/grd-vnc-pipewire-stream.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)
---
diff --git a/src/grd-vnc-pipewire-stream.c b/src/grd-vnc-pipewire-stream.c
index c5601b2..8efe616 100644
--- a/src/grd-vnc-pipewire-stream.c
+++ b/src/grd-vnc-pipewire-stream.c
@@ -424,25 +424,29 @@ on_frame_ready (GrdVncPipeWireStream *stream,
                 GrdVncFrame          *frame,
                 gpointer              user_data)
 {
+  GrdVncFrame *pending_frame;
   struct pw_buffer *buffer = user_data;
 
   g_assert (frame);
+
   g_mutex_lock (&stream->frame_mutex);
-  if (stream->pending_frame)
+
+  pending_frame = g_steal_pointer (&stream->pending_frame);
+  if (pending_frame)
     {
-      if (!frame->data && stream->pending_frame->data)
-        frame->data = g_steal_pointer (&stream->pending_frame->data);
-      if (!frame->rfb_cursor && stream->pending_frame->rfb_cursor)
-        frame->rfb_cursor = g_steal_pointer (&stream->pending_frame->rfb_cursor);
-      if (!frame->cursor_moved && stream->pending_frame->cursor_moved)
+      if (!frame->data && pending_frame->data)
+        frame->data = g_steal_pointer (&pending_frame->data);
+      if (!frame->rfb_cursor && pending_frame->rfb_cursor)
+        frame->rfb_cursor = g_steal_pointer (&pending_frame->rfb_cursor);
+      if (!frame->cursor_moved && pending_frame->cursor_moved)
         {
-          frame->cursor_x = stream->pending_frame->cursor_x;
-          frame->cursor_y = stream->pending_frame->cursor_y;
+          frame->cursor_x = pending_frame->cursor_x;
+          frame->cursor_y = pending_frame->cursor_y;
           frame->cursor_moved = TRUE;
         }
 
       g_free (stream->pending_frame->data);
-      g_clear_pointer (&stream->pending_frame, g_free);
+      g_free (pending_frame);
     }
   if (!stream->pending_frame_source)
     {


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