PipeWire  0.3.33
buffers.h
Go to the documentation of this file.
1 /* PipeWire
2  *
3  * Copyright © 2019 Wim Taymans
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice (including the next
13  * paragraph) shall be included in all copies or substantial portions of the
14  * Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  * DEALINGS IN THE SOFTWARE.
23  */
24 
25 #ifndef PIPEWIRE_BUFFERS_H
26 #define PIPEWIRE_BUFFERS_H
27 
28 #include <spa/node/node.h>
29 
30 #include <pipewire/context.h>
31 #include <pipewire/mem.h>
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 #define PW_BUFFERS_FLAG_NONE 0
38 #define PW_BUFFERS_FLAG_NO_MEM (1<<0)
39 #define PW_BUFFERS_FLAG_SHARED (1<<1)
40 #define PW_BUFFERS_FLAG_DYNAMIC (1<<2)
42 struct pw_buffers {
43  struct pw_memblock *mem;
44  struct spa_buffer **buffers;
45  uint32_t n_buffers;
46  uint32_t flags;
47 };
48 
49 int pw_buffers_negotiate(struct pw_context *context, uint32_t flags,
50  struct spa_node *outnode, uint32_t out_port_id,
51  struct spa_node *innode, uint32_t in_port_id,
52  struct pw_buffers *result);
53 
54 void pw_buffers_clear(struct pw_buffers *buffers);
55 
56 #ifdef __cplusplus
57 }
58 #endif
59 
60 #endif /* PIPEWIRE_BUFFERS_H */
SPA_MAX
#define SPA_MAX(a, b)
Definition: defs.h:129
pw_mempool
A memory pool is a collection of pw_memblocks.
Definition: src/pipewire/mem.h:72
pw_properties_get
int int const char * pw_properties_get(const struct pw_properties *properties, const char *key)
Get a property.
Definition: properties.c:487
spa_data::maxsize
uint32_t maxsize
max size of data
Definition: buffer/buffer.h:87
pw_buffers::mem
struct pw_memblock * mem
allocated buffer memory
Definition: buffers.h:43
spa_direction
spa_direction
Definition: defs.h:78
SPA_DATA_FLAG_READWRITE
#define SPA_DATA_FLAG_READWRITE
Definition: buffer/buffer.h:83
SPA_TYPE_OBJECT_ParamBuffers
@ SPA_TYPE_OBJECT_ParamBuffers
Definition: build-12683127/doc/spa/utils/type.h:91
SPA_PARAM_BUFFERS_blocks
@ SPA_PARAM_BUFFERS_blocks
number of data blocks per buffer (Int)
Definition: param.h:83
pw_buffers
Definition: buffers.h:42
SPA_PARAM_META_size
@ SPA_PARAM_META_size
the expected maximum size the meta (Int)
Definition: param.h:94
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[])
Fill buffer allocation information.
Definition: alloc.h:79
SPA_POD_Int
#define SPA_POD_Int(val)
Definition: vararg.h:59
PW_MEMBLOCK_FLAG_READWRITE
@ PW_MEMBLOCK_FLAG_READWRITE
Definition: src/pipewire/mem.h:53
spa_zero
#define spa_zero(x)
Definition: defs.h:303
port::params
struct spa_param_info params[N_PORT_PARAMS]
Definition: filter.c:110
SPA_PARAM_BUFFERS_dataType
@ SPA_PARAM_BUFFERS_dataType
possible memory types (Int, mask of enum spa_data_type)
Definition: param.h:87
MAX_ALIGN
#define MAX_ALIGN
Definition: buffers.c:41
spa_pod_builder_raw_padded
int spa_pod_builder_raw_padded(struct spa_pod_builder *builder, const void *data, uint32_t size)
Definition: builder.h:167
node.h
MAX_BLOCKS
#define MAX_BLOCKS
Definition: buffers.c:42
data
user data to add to an object
Definition: filter.c:75
mem.h
SPA_PARAM_BUFFERS_buffers
@ SPA_PARAM_BUFFERS_buffers
number of buffers (Int)
Definition: param.h:82
SPA_CLAMP
#define SPA_CLAMP(v, low, high)
Definition: defs.h:135
pw_mempool_alloc
struct pw_memblock * pw_mempool_alloc(struct pw_mempool *pool, enum pw_memblock_flags flags, uint32_t type, size_t size)
Allocate a memory block from the pool.
Definition: mem.c:464
SPA_BUFFER_ALLOC_FLAG_INLINE_ALL
#define SPA_BUFFER_ALLOC_FLAG_INLINE_ALL
Definition: alloc.h:42
spa_buffer_alloc_info::datas
struct spa_data * datas
Definition: alloc.h:49
PW_BUFFERS_FLAG_DYNAMIC
#define PW_BUFFERS_FLAG_DYNAMIC
buffers have dynamic data
Definition: buffers.h:40
SPA_EXPORT
#define SPA_EXPORT
Definition: defs.h:208
SPA_DIRECTION_INPUT
@ SPA_DIRECTION_INPUT
Definition: defs.h:79
spa_buffer_alloc_info::n_metas
uint32_t n_metas
Definition: alloc.h:46
SPA_ROUND_UP_N
#define SPA_ROUND_UP_N(num, align)
Definition: defs.h:223
spa_node_port_enum_params_sync
int spa_node_port_enum_params_sync(struct spa_node *node, enum spa_direction direction, uint32_t port_id, uint32_t id, uint32_t *index, const struct spa_pod *filter, struct spa_pod **param, struct spa_pod_builder *builder)
Definition: build-12683127/doc/spa/node/utils.h:92
pw_buffers_negotiate
int pw_buffers_negotiate(struct pw_context *context, uint32_t flags, struct spa_node *outnode, uint32_t out_port_id, struct spa_node *innode, uint32_t in_port_id, struct pw_buffers *result)
Definition: buffers.c:238
pw_memmap::ptr
void * ptr
mapped pointer
Definition: src/pipewire/mem.h:92
SPA_PTROFF
#define SPA_PTROFF(ptr_, offset_, type_)
Return the address (buffer + offset) as pointer of type.
Definition: defs.h:159
port::node
struct spa_node * node
Definition: buffers.c:45
NAME
#define NAME
Definition: buffers.c:39
SPA_POD_OPT_Int
#define SPA_POD_OPT_Int(val)
Definition: parser.h:521
SPA_POD_BUILDER_INIT
#define SPA_POD_BUILDER_INIT(buffer, size)
Definition: builder.h:71
pod.h
spa_data::flags
uint32_t flags
data flags
Definition: buffer/buffer.h:84
pw_context_debug_port_params
int pw_context_debug_port_params(struct pw_context *this, struct spa_node *node, enum spa_direction direction, uint32_t port_id, uint32_t id, int err, const char *debug,...)
Definition: context.c:745
spa_pod
Definition: pod/pod.h:50
SPA_DATA_FLAG_DYNAMIC
#define SPA_DATA_FLAG_DYNAMIC
data pointer can be changed
Definition: buffer/buffer.h:82
SPA_PARAM_BUFFERS_size
@ SPA_PARAM_BUFFERS_size
size of a data block memory (Int)
Definition: param.h:84
spa_pod_is_object_type
bool spa_pod_is_object_type(const struct spa_pod *pod, uint32_t type)
Definition: iter.h:387
spa_pod_fixate
int spa_pod_fixate(struct spa_pod *pod)
Definition: iter.h:442
spa_buffer_alloc_info::flags
uint32_t flags
Definition: alloc.h:44
port
Definition: buffers.c:44
SPA_FLAG_SET
#define SPA_FLAG_SET(field, flag)
Definition: defs.h:74
spa_buffer::n_metas
uint32_t n_metas
number of metadata
Definition: buffer/buffer.h:94
PW_MEMBLOCK_FLAG_SEAL
@ PW_MEMBLOCK_FLAG_SEAL
seal the fd
Definition: src/pipewire/mem.h:48
spa_buffer
A Buffer.
Definition: buffer/buffer.h:93
spa_node
Definition: build-12683127/doc/spa/node/node.h:53
SPA_PARAM_META_type
@ SPA_PARAM_META_type
the metadata, one of enum spa_meta_type (Id enum spa_meta_type)
Definition: param.h:93
pw_buffers::n_buffers
uint32_t n_buffers
number of port buffers
Definition: buffers.h:45
pw_buffers_negotiate
int pw_buffers_negotiate(struct pw_context *context, uint32_t flags, struct spa_node *outnode, uint32_t out_port_id, struct spa_node *innode, uint32_t in_port_id, struct pw_buffers *result)
Definition: buffers.c:238
spa_data::type
uint32_t type
memory type, one of enum spa_data_type, when allocating memory, the type contains a bitmask of allowe...
Definition: buffer/buffer.h:71
param.h
PW_BUFFERS_FLAG_SHARED
#define PW_BUFFERS_FLAG_SHARED
buffers can be shared
Definition: buffers.h:39
format.h
PW_MEMBLOCK_FLAG_MAP
@ PW_MEMBLOCK_FLAG_MAP
mmap the fd
Definition: src/pipewire/mem.h:49
SPA_LOG_LEVEL_DEBUG
@ SPA_LOG_LEVEL_DEBUG
Definition: build-12683127/doc/spa/support/log.h:51
SPA_FLAG_IS_SET
#define SPA_FLAG_IS_SET(field, flag)
Definition: defs.h:73
buffer
Definition: filter.c:59
buffers.h
pw_memblock::map
struct pw_memmap * map
optional map when PW_MEMBLOCK_FLAG_MAP was given
Definition: src/pipewire/mem.h:86
spa_meta
A metadata element.
Definition: meta.h:61
spa_pod_builder_init
void spa_pod_builder_init(struct spa_pod_builder *builder, void *data, uint32_t size)
Definition: builder.h:96
spa_buffer_alloc_info::mem_size
size_t mem_size
size of the total memory if not inlined
Definition: alloc.h:55
param_filter
Definition: impl-port.c:1240
spa_meta::type
uint32_t type
metadata type, one of enum spa_meta_type
Definition: meta.h:62
SPA_DIRECTION_OUTPUT
@ SPA_DIRECTION_OUTPUT
Definition: defs.h:80
alloc.h
pw_buffers::flags
uint32_t flags
flags
Definition: buffers.h:46
keys.h
port::port_id
uint32_t port_id
Definition: buffers.c:47
pw_buffers_clear
void pw_buffers_clear(struct pw_buffers *buffers)
Definition: buffers.c:356
port::flags
uint32_t flags
Definition: filter.c:95
node.h
spa_pod_parse_object
#define spa_pod_parse_object(pod, type, id,...)
Definition: parser.h:560
spa_strerror
#define spa_strerror(err)
Definition: result.h:51
utils.h
SPA_PARAM_Meta
@ SPA_PARAM_Meta
allowed metadata for buffers as SPA_TYPE_OBJECT_ParamMeta
Definition: param.h:50
pw_memblock
Memory block structure.
Definition: src/pipewire/mem.h:78
param
Definition: filter.c:80
pw_log_debug
#define pw_log_debug(...)
Definition: src/pipewire/log.h:89
spa_buffer_alloc_info::max_align
uint32_t max_align
max of all alignments
Definition: alloc.h:45
SPA_MIN
#define SPA_MIN(a, b)
Definition: defs.h:123
SPA_ID_INVALID
#define SPA_ID_INVALID
Definition: defs.h:182
parser.h
SPA_TYPE_OBJECT_ParamMeta
@ SPA_TYPE_OBJECT_ParamMeta
Definition: build-12683127/doc/spa/utils/type.h:92
spa_pod::type
uint32_t type
Definition: pod/pod.h:52
SPA_DATA_MemFd
@ SPA_DATA_MemFd
generic fd, mmap to get to memory
Definition: buffer/buffer.h:49
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)
Layout an array of buffers.
Definition: alloc.h:278
pw_buffers_clear
void pw_buffers_clear(struct pw_buffers *buffers)
Definition: buffers.c:356
SPA_DATA_MemPtr
@ SPA_DATA_MemPtr
pointer to memory, the data field in struct spa_data is set.
Definition: buffer/buffer.h:47
SPA_PARAM_BUFFERS_stride
@ SPA_PARAM_BUFFERS_stride
stride of data block memory (Int)
Definition: param.h:85
pw_log_warn
#define pw_log_warn(...)
Definition: src/pipewire/log.h:87
PW_BUFFERS_FLAG_NO_MEM
#define PW_BUFFERS_FLAG_NO_MEM
don't allocate buffer memory
Definition: buffers.h:38
spa_data
Data for a buffer this stays constant for a buffer.
Definition: buffer/buffer.h:70
context.h
spa_meta::size
uint32_t size
size of metadata
Definition: meta.h:63
SPA_POD_SIZE
#define SPA_POD_SIZE(pod)
Definition: pod/pod.h:42
SPA_PTR_ALIGN
#define SPA_PTR_ALIGN(p, align, type)
Definition: defs.h:227
spa_buffer_alloc_info::skel_size
size_t skel_size
size of the struct spa_buffer and inlined meta/chunk/data
Definition: alloc.h:51
pw_buffers::buffers
struct spa_buffer ** buffers
port buffers
Definition: buffers.h:44
SPA_POD_Id
#define SPA_POD_Id(val)
Definition: vararg.h:56
SPA_PARAM_BUFFERS_align
@ SPA_PARAM_BUFFERS_align
alignment of data block memory (Int)
Definition: param.h:86
port::buffers
struct buffer buffers[MAX_BUFFERS]
Definition: filter.c:114
spa_buffer_alloc_info
information about the buffer layout
Definition: alloc.h:38
spa_pod_builder
Definition: builder.h:63
port::direction
enum spa_direction direction
Definition: buffers.c:46
spa_buffer_alloc_info::n_datas
uint32_t n_datas
Definition: alloc.h:47
SPA_PARAM_Buffers
@ SPA_PARAM_Buffers
buffer configurations as SPA_TYPE_OBJECT_ParamBuffers
Definition: param.h:49
spa_buffer_alloc_info::metas
struct spa_meta * metas
Definition: alloc.h:48
pw_log_error
#define pw_log_error(...)
Definition: src/pipewire/log.h:86
PW_KEY_CPU_MAX_ALIGN
#define PW_KEY_CPU_MAX_ALIGN
maximum alignment needed to support all CPU optimizations
Definition: src/pipewire/keys.h:92