aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2025-07-17 16:45:47 +0300
committerIvan Molodetskikh <yalterz@gmail.com>2025-08-04 14:36:34 +0200
commit76c3bb20ba6321270673e9b476f1a81912567cef (patch)
tree5658d8c4cde7c144f639cf14caebed613426f69c /src
parent91b6a111cf228fadaabba706d8f4d155efc63b3a (diff)
downloadniri-76c3bb20ba6321270673e9b476f1a81912567cef.tar.gz
niri-76c3bb20ba6321270673e9b476f1a81912567cef.tar.bz2
niri-76c3bb20ba6321270673e9b476f1a81912567cef.zip
pw_utils: Add clarifying comments on maxsize and size
Diffstat (limited to 'src')
-rw-r--r--src/pw_utils.rs18
1 files changed, 18 insertions, 0 deletions
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;