[mutter] screen-cast-stream: Use flag to signal failed recording



commit 82fd5cbdbd9875c63332ad45a2be1da4bfb270a8
Author: columbarius <co1umbarius protonmail com>
Date:   Sun Mar 6 22:03:21 2022 +0100

    screen-cast-stream: Use flag to signal failed recording
    
    PipeWire supports flags to signal a corrupted buffer. We should use the
    flag SPA_CHUNK_FLAG_CORRUPTED for `chunk->flags` instead of setting
    `chunk->size = 0` since the size isn't well defined for arbitrary dmabufs
    and should be set to 0.
    Sadly clients like obs are using a chunk size of 0 to decide if a buffer
    should be imported. Thus we should offer both until clients are using
    the flag.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2323>

 src/backends/meta-screen-cast-stream-src.c | 3 +++
 1 file changed, 3 insertions(+)
---
diff --git a/src/backends/meta-screen-cast-stream-src.c b/src/backends/meta-screen-cast-stream-src.c
index 806fa806c1..d25d0c4277 100644
--- a/src/backends/meta-screen-cast-stream-src.c
+++ b/src/backends/meta-screen-cast-stream-src.c
@@ -657,6 +657,7 @@ meta_screen_cast_stream_src_maybe_record_frame (MetaScreenCastStreamSrc  *src,
           spa_data->chunk->size = spa_data->maxsize;
           spa_data->chunk->stride =
             meta_screen_cast_stream_src_calculate_stride (src, spa_data);
+          spa_data->chunk->flags = SPA_CHUNK_FLAG_NONE;
 
           /* Update VideoCrop if needed */
           spa_meta_video_crop =
@@ -686,11 +687,13 @@ meta_screen_cast_stream_src_maybe_record_frame (MetaScreenCastStreamSrc  *src,
         {
           g_warning ("Failed to record screen cast frame: %s", error->message);
           spa_buffer->datas[0].chunk->size = 0;
+          spa_buffer->datas[0].chunk->flags = SPA_CHUNK_FLAG_CORRUPTED;
         }
     }
   else
     {
       spa_buffer->datas[0].chunk->size = 0;
+      spa_buffer->datas[0].chunk->flags = SPA_CHUNK_FLAG_CORRUPTED;
     }
 
   maybe_record_cursor (src, spa_buffer);


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