[mutter] screen-cast/src: Only allocate DMA buffers if other end supports it
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] screen-cast/src: Only allocate DMA buffers if other end supports it
- Date: Tue, 2 Feb 2021 10:46:49 +0000 (UTC)
commit ca22622517c381a687e311b5eb8bf97c31140f5d
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Mon Feb 1 18:33:35 2021 +0100
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>
src/backends/meta-screen-cast-stream-src.c | 22 ++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
---
diff --git a/src/backends/meta-screen-cast-stream-src.c b/src/backends/meta-screen-cast-stream-src.c
index 5d3440e5db..39c688d78e 100644
--- a/src/backends/meta-screen-cast-stream-src.c
+++ b/src/backends/meta-screen-cast-stream-src.c
@@ -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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]