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>
This commit is contained in:
columbarius 2022-03-06 22:03:21 +01:00
parent 9dd6268d13
commit 82fd5cbdbd

View File

@ -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);