PipeWire  0.3.33
SPA Buffers

Buffers describe the data and metadata that is exchanged between ports of a node. More...

Data Structures

struct  spa_buffer_alloc_info
 information about the buffer layout More...
 
struct  spa_chunk
 Chunk of memory, can change for each buffer. More...
 
struct  spa_data
 Data for a buffer this stays constant for a buffer. More...
 
struct  spa_buffer
 A Buffer. More...
 
struct  spa_meta
 A metadata element. More...
 
struct  spa_meta_header
 Describes essential buffer header metadata such as flags and timestamps. More...
 
struct  spa_meta_region
 metadata structure for Region or an array of these for RegionArray More...
 
struct  spa_meta_bitmap
 Bitmap information. More...
 
struct  spa_meta_cursor
 Cursor information. More...
 
struct  spa_meta_control
 a timed set of events associated with the buffer More...
 
struct  spa_meta_busy
 a busy counter for the buffer More...
 

Macros

#define spa_meta_first(m)   ((m)->data)
 
#define spa_meta_end(m)   SPA_PTROFF((m)->data,(m)->size,void)
 
#define spa_meta_check(p, m)   (SPA_PTROFF(p,sizeof(*p),void) <= spa_meta_end(m))
 
#define spa_meta_region_is_valid(m)   ((m)->region.size.width != 0 && (m)->region.size.height != 0)
 
#define spa_meta_for_each(pos, meta)
 iterate all the items in a metadata More...
 
#define spa_meta_bitmap_is_valid(m)   ((m)->format != 0)
 
#define spa_meta_cursor_is_valid(m)   ((m)->id != 0)
 
#define SPA_TYPE_INFO_Buffer   SPA_TYPE_INFO_POINTER_BASE "Buffer"
 
#define SPA_TYPE_INFO_BUFFER_BASE   SPA_TYPE_INFO_Buffer ":"
 
#define SPA_TYPE_INFO_Data   SPA_TYPE_INFO_ENUM_BASE "Data"
 Buffers contain data of a certain type. More...
 
#define SPA_TYPE_INFO_DATA_BASE   SPA_TYPE_INFO_Data ":"
 
#define SPA_TYPE_INFO_DATA_Fd   SPA_TYPE_INFO_DATA_BASE "Fd"
 base type for fd based memory More...
 
#define SPA_TYPE_INFO_DATA_FD_BASE   SPA_TYPE_INFO_DATA_Fd ":"
 
#define SPA_TYPE_INFO_Meta   SPA_TYPE_INFO_POINTER_BASE "Meta"
 
#define SPA_TYPE_INFO_META_BASE   SPA_TYPE_INFO_Meta ":"
 
#define SPA_TYPE_INFO_META_Array   SPA_TYPE_INFO_META_BASE "Array"
 
#define SPA_TYPE_INFO_META_ARRAY_BASE   SPA_TYPE_INFO_META_Array ":"
 
#define SPA_TYPE_INFO_META_Region   SPA_TYPE_INFO_META_BASE "Region"
 
#define SPA_TYPE_INFO_META_REGION_BASE   SPA_TYPE_INFO_META_Region ":"
 
#define SPA_TYPE_INFO_META_ARRAY_Region   SPA_TYPE_INFO_META_ARRAY_BASE "Region"
 
#define SPA_TYPE_INFO_META_ARRAY_REGION_BASE   SPA_TYPE_INFO_META_ARRAY_Region ":"
 

Enumerations

enum  spa_data_type {
  SPA_DATA_Invalid, SPA_DATA_MemPtr, SPA_DATA_MemFd, SPA_DATA_DmaBuf,
  SPA_DATA_MemId, _SPA_DATA_LAST
}
 
enum  spa_meta_type {
  SPA_META_Invalid, SPA_META_Header, SPA_META_VideoCrop, SPA_META_VideoDamage,
  SPA_META_Bitmap, SPA_META_Cursor, SPA_META_Control, SPA_META_Busy,
  _SPA_META_LAST
}
 

Functions

int spa_buffer_alloc_fill_info (struct spa_buffer_alloc_info *info, uint32_t n_metas, struct spa_meta metas[], uint32_t n_datas, struct spa_data datas[], uint32_t data_aligns[])
 Fill buffer allocation information. More...
 
struct spa_bufferspa_buffer_alloc_layout (struct spa_buffer_alloc_info *info, void *skel_mem, void *data_mem)
 Fill skeleton and data according to the allocation info. More...
 
int spa_buffer_alloc_layout_array (struct spa_buffer_alloc_info *info, uint32_t n_buffers, struct spa_buffer *buffers[], void *skel_mem, void *data_mem)
 Layout an array of buffers. More...
 
struct spa_buffer ** spa_buffer_alloc_array (uint32_t n_buffers, uint32_t flags, uint32_t n_metas, struct spa_meta metas[], uint32_t n_datas, struct spa_data datas[], uint32_t data_aligns[])
 Allocate an array of buffers. More...
 
struct spa_metaspa_buffer_find_meta (const struct spa_buffer *b, uint32_t type)
 Find metadata in a buffer. More...
 
void * spa_buffer_find_meta_data (const struct spa_buffer *b, uint32_t type, size_t size)
 

Variables

const struct spa_type_info spa_type_data_type []
 
const struct spa_type_info spa_type_meta_type []
 

Detailed Description

Buffers describe the data and metadata that is exchanged between ports of a node.

Macro Definition Documentation

◆ spa_meta_bitmap_is_valid

#define spa_meta_bitmap_is_valid (   m)    ((m)->format != 0)

◆ spa_meta_check

#define spa_meta_check (   p,
 
)    (SPA_PTROFF(p,sizeof(*p),void) <= spa_meta_end(m))

◆ spa_meta_cursor_is_valid

#define spa_meta_cursor_is_valid (   m)    ((m)->id != 0)

◆ spa_meta_end

#define spa_meta_end (   m)    SPA_PTROFF((m)->data,(m)->size,void)

◆ spa_meta_first

#define spa_meta_first (   m)    ((m)->data)

◆ spa_meta_for_each

#define spa_meta_for_each (   pos,
  meta 
)
Value:
for (pos = (__typeof(pos))spa_meta_first(meta); \
spa_meta_check(pos, meta); \
(pos)++)

iterate all the items in a metadata

◆ spa_meta_region_is_valid

#define spa_meta_region_is_valid (   m)    ((m)->region.size.width != 0 && (m)->region.size.height != 0)

◆ SPA_TYPE_INFO_Buffer

#define SPA_TYPE_INFO_Buffer   SPA_TYPE_INFO_POINTER_BASE "Buffer"

◆ SPA_TYPE_INFO_BUFFER_BASE

#define SPA_TYPE_INFO_BUFFER_BASE   SPA_TYPE_INFO_Buffer ":"

◆ SPA_TYPE_INFO_Data

#define SPA_TYPE_INFO_Data   SPA_TYPE_INFO_ENUM_BASE "Data"

Buffers contain data of a certain type.

◆ SPA_TYPE_INFO_DATA_BASE

#define SPA_TYPE_INFO_DATA_BASE   SPA_TYPE_INFO_Data ":"

◆ SPA_TYPE_INFO_DATA_Fd

#define SPA_TYPE_INFO_DATA_Fd   SPA_TYPE_INFO_DATA_BASE "Fd"

base type for fd based memory

◆ SPA_TYPE_INFO_DATA_FD_BASE

#define SPA_TYPE_INFO_DATA_FD_BASE   SPA_TYPE_INFO_DATA_Fd ":"

◆ SPA_TYPE_INFO_Meta

#define SPA_TYPE_INFO_Meta   SPA_TYPE_INFO_POINTER_BASE "Meta"

◆ SPA_TYPE_INFO_META_Array

#define SPA_TYPE_INFO_META_Array   SPA_TYPE_INFO_META_BASE "Array"

◆ SPA_TYPE_INFO_META_ARRAY_BASE

#define SPA_TYPE_INFO_META_ARRAY_BASE   SPA_TYPE_INFO_META_Array ":"

◆ SPA_TYPE_INFO_META_ARRAY_Region

#define SPA_TYPE_INFO_META_ARRAY_Region   SPA_TYPE_INFO_META_ARRAY_BASE "Region"

◆ SPA_TYPE_INFO_META_ARRAY_REGION_BASE

#define SPA_TYPE_INFO_META_ARRAY_REGION_BASE   SPA_TYPE_INFO_META_ARRAY_Region ":"

◆ SPA_TYPE_INFO_META_BASE

#define SPA_TYPE_INFO_META_BASE   SPA_TYPE_INFO_Meta ":"

◆ SPA_TYPE_INFO_META_Region

#define SPA_TYPE_INFO_META_Region   SPA_TYPE_INFO_META_BASE "Region"

◆ SPA_TYPE_INFO_META_REGION_BASE

#define SPA_TYPE_INFO_META_REGION_BASE   SPA_TYPE_INFO_META_Region ":"

Enumeration Type Documentation

◆ spa_data_type

Enumerator
SPA_DATA_Invalid 
SPA_DATA_MemPtr 

pointer to memory, the data field in struct spa_data is set.

SPA_DATA_MemFd 

generic fd, mmap to get to memory

SPA_DATA_DmaBuf 

fd to dmabuf memory

SPA_DATA_MemId 

memory is identified with an id

_SPA_DATA_LAST 

not part of ABI

◆ spa_meta_type

Enumerator
SPA_META_Invalid 
SPA_META_Header 

struct spa_meta_header

SPA_META_VideoCrop 

struct spa_meta_region with cropping data

SPA_META_VideoDamage 

array of struct spa_meta_region with damage

SPA_META_Bitmap 

struct spa_meta_bitmap

SPA_META_Cursor 

struct spa_meta_cursor

SPA_META_Control 

metadata contains a spa_meta_control associated with the data

SPA_META_Busy 

don't write to buffer when count > 0

_SPA_META_LAST 

not part of ABI/API

Function Documentation

◆ spa_buffer_alloc_array()

struct spa_buffer** spa_buffer_alloc_array ( uint32_t  n_buffers,
uint32_t  flags,
uint32_t  n_metas,
struct spa_meta  metas[],
uint32_t  n_datas,
struct spa_data  datas[],
uint32_t  data_aligns[] 
)
inline

Allocate an array of buffers.

Allocate n_buffers with the given metadata, memory and alignment information.

The buffer array, structures, data and metadata will all be allocated in one block of memory with the proper requested alignment.

Parameters
n_buffersthe number of buffers to create
flagsextra flags
n_metasnumber of metadatas
metasn_metas metadata specification
n_datasnumber of datas
datasn_datas memory specification
data_alignsn_datas alignment specifications
Returns
an array of n_buffers pointers to struct SPA Buffers with the given metadata, data and alignment or NULL when allocation failed.

References spa_buffer_alloc_info::data_aligns, spa_buffer_alloc_info::datas, spa_buffer_alloc_info::flags, spa_buffer_alloc_info::max_align, spa_buffer_alloc_info::metas, spa_buffer_alloc_info::n_datas, spa_buffer_alloc_info::n_metas, spa_buffer_alloc_info::skel_size, spa_buffer_alloc_fill_info(), SPA_BUFFER_ALLOC_FLAG_INLINE_ALL, spa_buffer_alloc_layout_array(), SPA_PTR_ALIGN, and SPA_PTROFF.

◆ spa_buffer_alloc_fill_info()

int spa_buffer_alloc_fill_info ( struct spa_buffer_alloc_info info,
uint32_t  n_metas,
struct spa_meta  metas[],
uint32_t  n_datas,
struct spa_data  datas[],
uint32_t  data_aligns[] 
)
inline

Fill buffer allocation information.

Fill info with allocation information needed to allocate buffers with the given number of metadata and data members.

The required size of the skeleton (the struct spa_buffer) information and the memory (for the metadata, chunk and buffer memory) will be calculated.

The flags member in info should be configured before calling this functions.

Parameters
infothe information to fill
n_metasthe number of metadatas for the buffer
metasan array of metadata items
n_datasthe number of datas for the buffer
datasan array of n_datas items
data_alignsn_datas alignments
Returns
0 on success.

References spa_buffer_alloc_info::chunk_size, spa_buffer_alloc_info::data_aligns, spa_buffer_alloc_info::data_size, spa_buffer_alloc_info::datas, spa_buffer_alloc_info::flags, spa_buffer_alloc_info::max_align, spa_data::maxsize, spa_buffer_alloc_info::mem_size, spa_buffer_alloc_info::meta_size, spa_buffer_alloc_info::metas, spa_buffer_alloc_info::n_datas, spa_buffer_alloc_info::n_metas, n_metas, spa_chunk::size, spa_buffer_alloc_info::skel_size, SPA_BUFFER_ALLOC_FLAG_INLINE_CHUNK, SPA_BUFFER_ALLOC_FLAG_INLINE_DATA, SPA_BUFFER_ALLOC_FLAG_INLINE_META, SPA_BUFFER_ALLOC_FLAG_NO_DATA, SPA_FLAG_IS_SET, SPA_MAX, and SPA_ROUND_UP_N.

Referenced by spa_buffer_alloc_array().

◆ spa_buffer_alloc_layout()

struct spa_buffer* spa_buffer_alloc_layout ( struct spa_buffer_alloc_info info,
void *  skel_mem,
void *  data_mem 
)
inline

Fill skeleton and data according to the allocation info.

Use the allocation info to create a struct SPA Buffers into skel_mem and data_mem.

Depending on the flags given when calling spa_buffer_alloc_fill_info(), the buffer meta, chunk and memory will be referenced in either skel_mem or data_mem.

Parameters
infoan allocation info
skel_memmemory to hold the struct SPA Buffers and the pointers to meta, chunk and memory.
data_memmemory to hold the meta, chunk and memory
Returns
a struct SPA Buffers in skel_mem

References spa_data::chunk, spa_data::data, spa_meta::data, spa_buffer_alloc_info::data_aligns, spa_buffer_alloc_info::datas, datas, spa_buffer_alloc_info::flags, spa_data::maxsize, spa_buffer_alloc_info::metas, metas, spa_buffer_alloc_info::n_datas, n_datas, spa_buffer_alloc_info::n_metas, n_metas, spa_chunk::size, spa_meta::size, SPA_BUFFER_ALLOC_FLAG_INLINE_CHUNK, SPA_BUFFER_ALLOC_FLAG_INLINE_DATA, SPA_BUFFER_ALLOC_FLAG_INLINE_META, SPA_BUFFER_ALLOC_FLAG_NO_DATA, SPA_FLAG_IS_SET, SPA_PTR_ALIGN, SPA_PTROFF, and SPA_ROUND_UP_N.

Referenced by spa_buffer_alloc_layout_array().

◆ spa_buffer_alloc_layout_array()

int spa_buffer_alloc_layout_array ( struct spa_buffer_alloc_info info,
uint32_t  n_buffers,
struct spa_buffer buffers[],
void *  skel_mem,
void *  data_mem 
)
inline

Layout an array of buffers.

Use the allocation info to layout the memory of an array of buffers.

skel_mem should point to at least info->skel_size * n_buffers bytes of memory. data_mem should point to at least info->mem_size * n_buffers bytes of memory.

Parameters
infothe allocation info for one buffer
n_buffersthe number of buffers to create
buffersa array with space to hold n_buffers pointers to buffers
skel_memmemory for the struct SPA Buffers
data_memmemory for the meta, chunk, memory of the buffer if not inlined in the skeleton.
Returns
0 on success.

References spa_buffer_alloc_info::mem_size, spa_buffer_alloc_info::skel_size, spa_buffer_alloc_layout(), and SPA_PTROFF.

Referenced by spa_buffer_alloc_array().

◆ spa_buffer_find_meta()

struct spa_meta* spa_buffer_find_meta ( const struct spa_buffer b,
uint32_t  type 
)
inline

Find metadata in a buffer.

References metas, n_metas, and spa_meta::type.

Referenced by spa_buffer_find_meta_data().

◆ spa_buffer_find_meta_data()

void* spa_buffer_find_meta_data ( const struct spa_buffer b,
uint32_t  type,
size_t  size 
)
inline

Variable Documentation

◆ spa_type_data_type

const struct spa_type_info spa_type_data_type[]
Initial value:

Referenced by spa_debug_buffer().

◆ spa_type_meta_type

SPA_META_Cursor
@ SPA_META_Cursor
struct spa_meta_cursor
Definition: meta.h:46
SPA_TYPE_INFO_META_BASE
#define SPA_TYPE_INFO_META_BASE
Definition: buffer/type-info.h:62
SPA_META_Invalid
@ SPA_META_Invalid
Definition: meta.h:41
SPA_TYPE_INFO_DATA_FD_BASE
#define SPA_TYPE_INFO_DATA_FD_BASE
Definition: buffer/type-info.h:50
SPA_TYPE_Int
@ SPA_TYPE_Int
Definition: build-12683127/doc/spa/utils/type.h:48
SPA_META_VideoCrop
@ SPA_META_VideoCrop
struct spa_meta_region with cropping data
Definition: meta.h:43
SPA_DATA_DmaBuf
@ SPA_DATA_DmaBuf
fd to dmabuf memory
Definition: buffer/buffer.h:50
SPA_META_VideoDamage
@ SPA_META_VideoDamage
array of struct spa_meta_region with damage
Definition: meta.h:44
SPA_TYPE_Pointer
@ SPA_TYPE_Pointer
Definition: build-12683127/doc/spa/utils/type.h:61
SPA_META_Busy
@ SPA_META_Busy
don't write to buffer when count > 0
Definition: meta.h:49
SPA_TYPE_INFO_META_REGION_BASE
#define SPA_TYPE_INFO_META_REGION_BASE
Definition: buffer/type-info.h:68
SPA_TYPE_INFO_DATA_BASE
#define SPA_TYPE_INFO_DATA_BASE
Definition: buffer/type-info.h:46
spa_meta_first
#define spa_meta_first(m)
Definition: meta.h:67
SPA_DATA_MemId
@ SPA_DATA_MemId
memory is identified with an id
Definition: buffer/buffer.h:51
SPA_META_Bitmap
@ SPA_META_Bitmap
struct spa_meta_bitmap
Definition: meta.h:45
SPA_DATA_MemFd
@ SPA_DATA_MemFd
generic fd, mmap to get to memory
Definition: buffer/buffer.h:49
SPA_DATA_MemPtr
@ SPA_DATA_MemPtr
pointer to memory, the data field in struct spa_data is set.
Definition: buffer/buffer.h:47
SPA_TYPE_INFO_META_ARRAY_REGION_BASE
#define SPA_TYPE_INFO_META_ARRAY_REGION_BASE
Definition: buffer/type-info.h:71
SPA_META_Header
@ SPA_META_Header
struct spa_meta_header
Definition: meta.h:42
SPA_META_Control
@ SPA_META_Control
metadata contains a spa_meta_control associated with the data
Definition: meta.h:47
SPA_DATA_Invalid
@ SPA_DATA_Invalid
Definition: buffer/buffer.h:46