Blame SOURCES/mutter-pipewire-0_2-API.patch

776610
diff --git a/src/backends/meta-screen-cast-stream-src.c b/src/backends/meta-screen-cast-stream-src.c
776610
index 457c058..0c4f33b 100644
776610
--- a/src/backends/meta-screen-cast-stream-src.c
776610
+++ b/src/backends/meta-screen-cast-stream-src.c
776610
@@ -132,8 +132,8 @@ meta_screen_cast_stream_src_maybe_record_frame (MetaScreenCastStreamSrc *src)
776610
 {
776610
   MetaScreenCastStreamSrcPrivate *priv =
776610
     meta_screen_cast_stream_src_get_instance_private (src);
776610
-  uint32_t buffer_id;
776610
-  struct spa_buffer *buffer;
776610
+  struct pw_buffer *buffer;
776610
+  struct spa_buffer *spa_buffer;
776610
   uint8_t *map = NULL;
776610
   uint8_t *data;
776610
   uint64_t now_us;
776610
@@ -148,22 +148,24 @@ meta_screen_cast_stream_src_maybe_record_frame (MetaScreenCastStreamSrc *src)
776610
   if (!priv->pipewire_stream)
776610
     return;
776610
 
776610
-  buffer_id = pw_stream_get_empty_buffer (priv->pipewire_stream);
776610
-  if (buffer_id == SPA_ID_INVALID)
776610
-    return;
776610
-
776610
-  buffer = pw_stream_peek_buffer (priv->pipewire_stream, buffer_id);
776610
+  buffer = pw_stream_dequeue_buffer (priv->pipewire_stream);
776610
   if (!buffer)
776610
     {
776610
-      g_warning ("Failed to peek at PipeWire buffer");
776610
+      g_warning ("Failed to dequeue at PipeWire buffer");
776610
       return;
776610
     }
776610
 
776610
-  if (buffer->datas[0].type == priv->pipewire_type->data.MemFd)
776610
+  spa_buffer = buffer->buffer;
776610
+
776610
+  if (spa_buffer->datas[0].data)
776610
+    {
776610
+      data = spa_buffer->datas[0].data;
776610
+    }
776610
+  else if (spa_buffer->datas[0].type == priv->pipewire_type->data.MemFd)
776610
     {
776610
-      map = mmap (NULL, buffer->datas[0].maxsize + buffer->datas[0].mapoffset,
776610
+      map = mmap (NULL, spa_buffer->datas[0].maxsize + spa_buffer->datas[0].mapoffset,
776610
                   PROT_READ | PROT_WRITE, MAP_SHARED,
776610
-                  buffer->datas[0].fd, 0);
776610
+                  spa_buffer->datas[0].fd, 0);
776610
       if (map == MAP_FAILED)
776610
         {
776610
           g_warning ("Failed to mmap pipewire stream buffer: %s\n",
776610
@@ -171,14 +173,11 @@ meta_screen_cast_stream_src_maybe_record_frame (MetaScreenCastStreamSrc *src)
776610
           return;
776610
         }
776610
 
776610
-      data = SPA_MEMBER (map, buffer->datas[0].mapoffset, uint8_t);
776610
-    }
776610
-  else if (buffer->datas[0].type == priv->pipewire_type->data.MemPtr)
776610
-    {
776610
-      data = buffer->datas[0].data;
776610
+      data = SPA_MEMBER (map, spa_buffer->datas[0].mapoffset, uint8_t);
776610
     }
776610
   else
776610
     {
776610
+      g_warning ("Unhandled spa buffer type: %d", spa_buffer->datas[0].type);
776610
       return;
776610
     }
776610
 
776610
@@ -186,11 +185,11 @@ meta_screen_cast_stream_src_maybe_record_frame (MetaScreenCastStreamSrc *src)
776610
   priv->last_frame_timestamp_us = now_us;
776610
 
776610
   if (map)
776610
-    munmap (map, buffer->datas[0].maxsize + buffer->datas[0].mapoffset);
776610
+    munmap (map, spa_buffer->datas[0].maxsize + spa_buffer->datas[0].mapoffset);
776610
 
776610
-  buffer->datas[0].chunk->size = buffer->datas[0].maxsize;
776610
+  spa_buffer->datas[0].chunk->size = spa_buffer->datas[0].maxsize;
776610
 
776610
-  pw_stream_send_buffer (priv->pipewire_stream, buffer_id);
776610
+  pw_stream_queue_buffer (priv->pipewire_stream, buffer);
776610
 }
776610
 
776610
 static gboolean
776610
@@ -266,8 +265,8 @@ on_stream_state_changed (void                 *data,
776610
 }
776610
 
776610
 static void
776610
-on_stream_format_changed (void           *data,
776610
-                          struct spa_pod *format)
776610
+on_stream_format_changed (void                 *data,
776610
+                          const struct spa_pod *format)
776610
 {
776610
   MetaScreenCastStreamSrc *src = data;
776610
   MetaScreenCastStreamSrcPrivate *priv =
776610
@@ -276,7 +275,7 @@ on_stream_format_changed (void           *data,
776610
   uint8_t params_buffer[1024];
776610
   int32_t width, height, stride, size;
776610
   struct spa_pod_builder pod_builder;
776610
-  struct spa_pod *params[1];
776610
+  const struct spa_pod *params[1];
776610
   const int bpp = 4;
776610
 
776610
   if (!format)
776610
@@ -372,7 +371,8 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
776610
   result = pw_stream_connect (pipewire_stream,
776610
                               PW_DIRECTION_OUTPUT,
776610
                               NULL,
776610
-                              PW_STREAM_FLAG_NONE,
776610
+                              (PW_STREAM_FLAG_DRIVER |
776610
+                               PW_STREAM_FLAG_MAP_BUFFERS),
776610
                               params, G_N_ELEMENTS (params));
776610
   if (result != 0)
776610
     {