screen-cast/src: Only allocate DMA buffers if other end supports it

The other end of the PipeWire stream can set the buffer data type to a
bitmask of supported buffer types. We should respect this, and not
attempt to allocate a DMA buffer if it isn't asked for.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1697>
This commit is contained in:
Jonas Ådahl 2021-02-01 18:33:35 +01:00 committed by Marge Bot
parent ca95ccdef0
commit ca22622517

View File

@ -747,10 +747,17 @@ on_stream_add_buffer (void *data,
spa_data[0].maxsize = stride * priv->video_format.size.height;
spa_data[0].data = NULL;
dmabuf_handle =
meta_screen_cast_create_dma_buf_handle (screen_cast,
priv->video_format.size.width,
priv->video_format.size.height);
if (spa_data[0].type & (1 << SPA_DATA_DmaBuf))
{
dmabuf_handle =
meta_screen_cast_create_dma_buf_handle (screen_cast,
priv->video_format.size.width,
priv->video_format.size.height);
}
else
{
dmabuf_handle = NULL;
}
if (dmabuf_handle)
{
@ -766,6 +773,13 @@ on_stream_add_buffer (void *data,
{
unsigned int seals;
if (!(spa_data[0].type & (1 << SPA_DATA_MemFd)))
{
g_critical ("No supported PipeWire stream buffer data type could "
"be negotiated");
return;
}
/* Fallback to a memfd buffer */
spa_data[0].type = SPA_DATA_MemFd;
spa_data[0].flags = SPA_DATA_FLAG_READWRITE;