[gnome-remote-desktop] rdp/pipewire-stream: Use a helper variable for the pending frame



commit 5d0ff6daa642db12c3625834e86652ac5e50e818
Author: Jonas Ådahl <jadahl gmail com>
Date:   Fri Nov 5 16:02:33 2021 +0100

    rdp/pipewire-stream: Use a helper variable for the pending frame

 src/grd-rdp-pipewire-stream.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)
---
diff --git a/src/grd-rdp-pipewire-stream.c b/src/grd-rdp-pipewire-stream.c
index 7a1793f..a70d4fb 100644
--- a/src/grd-rdp-pipewire-stream.c
+++ b/src/grd-rdp-pipewire-stream.c
@@ -437,6 +437,7 @@ on_stream_process (void *user_data)
   struct pw_buffer *next_buffer;
   struct pw_buffer *buffer = NULL;
   GrdRdpFrame *frame;
+  GrdRdpFrame *pending_frame;
 
   next_buffer = pw_stream_dequeue_buffer (stream->pipewire_stream);
   while (next_buffer)
@@ -454,16 +455,17 @@ on_stream_process (void *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)
-        take_frame_data_from (stream->pending_frame, frame);
-      if (!frame->has_pointer_data && stream->pending_frame->has_pointer_data)
-        take_pointer_data_from (stream->pending_frame, frame);
-
-      g_free (stream->pending_frame->data);
-      g_free (stream->pending_frame->pointer_bitmap);
-      g_clear_pointer (&stream->pending_frame, g_free);
+      if (!frame->data && pending_frame->data)
+        take_frame_data_from (pending_frame, frame);
+      if (!frame->has_pointer_data && pending_frame->has_pointer_data)
+        take_pointer_data_from (pending_frame, frame);
+
+      g_free (pending_frame->data);
+      g_free (pending_frame->pointer_bitmap);
+      g_free (pending_frame);
     }
   stream->pending_frame = frame;
   g_mutex_unlock (&stream->frame_mutex);


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