From 76c3bb20ba6321270673e9b476f1a81912567cef Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Thu, 17 Jul 2025 16:45:47 +0300 Subject: pw_utils: Add clarifying comments on maxsize and size --- src/pw_utils.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/pw_utils.rs b/src/pw_utils.rs index 7afacc45..24773b82 100644 --- a/src/pw_utils.rs +++ b/src/pw_utils.rs @@ -600,6 +600,10 @@ impl PipeWire { assert!((*spa_data).type_ & (1 << DataType::DmaBuf.as_raw()) > 0); (*spa_data).type_ = DataType::DmaBuf.as_raw(); + // With DMA-BUFs, consumers should ignore the maxsize field, and + // producers are allowed to set it to 0. + // + // https://docs.pipewire.org/page_dma_buf.html (*spa_data).maxsize = 1; (*spa_data).fd = fd.as_raw_fd() as i64; (*spa_data).flags = SPA_DATA_FLAG_READWRITE; @@ -880,6 +884,13 @@ impl Cast { zip(buffer.datas_mut(), zip(dmabuf.strides(), dmabuf.offsets())) { let chunk = data.chunk_mut(); + // With DMA-BUFs, consumers should ignore the size field, and producers are allowed to + // set it to 0. + // + // https://docs.pipewire.org/page_dma_buf.html + // + // However, OBS checks for size != 0 as a workaround for old compositor versions, + // so we set it to 1. *chunk.size_mut() = 1; *chunk.stride_mut() = stride as i32; *chunk.offset_mut() = offset; @@ -931,6 +942,13 @@ impl Cast { zip(buffer.datas_mut(), zip(dmabuf.strides(), dmabuf.offsets())) { let chunk = data.chunk_mut(); + // With DMA-BUFs, consumers should ignore the size field, and producers are allowed to + // set it to 0. + // + // https://docs.pipewire.org/page_dma_buf.html + // + // However, OBS checks for size != 0 as a workaround for old compositor versions, + // so we set it to 1. *chunk.size_mut() = 1; *chunk.stride_mut() = stride as i32; *chunk.offset_mut() = offset; -- cgit