PipeWire 0.3.77
Loading...
Searching...
No Matches
buffer/buffer.h
Go to the documentation of this file.
1/* Simple Plugin API */
2/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */
3/* SPDX-License-Identifier: MIT */
4
5#ifndef SPA_BUFFER_H
6#define SPA_BUFFER_H
7
8#ifdef __cplusplus
9extern "C" {
10#endif
11
12#include <spa/utils/defs.h>
13#include <spa/buffer/meta.h>
14
26enum spa_data_type {
35};
38struct spa_chunk {
39 uint32_t offset;
42 uint32_t size;
44 int32_t stride;
45#define SPA_CHUNK_FLAG_NONE 0
46#define SPA_CHUNK_FLAG_CORRUPTED (1u<<0)
47#define SPA_CHUNK_FLAG_EMPTY (1u<<1)
50 int32_t flags;
51};
52
54struct spa_data {
55 uint32_t type;
63#define SPA_DATA_FLAG_NONE 0
64#define SPA_DATA_FLAG_READABLE (1u<<0)
65#define SPA_DATA_FLAG_WRITABLE (1u<<1)
66#define SPA_DATA_FLAG_DYNAMIC (1u<<2)
67#define SPA_DATA_FLAG_READWRITE (SPA_DATA_FLAG_READABLE|SPA_DATA_FLAG_WRITABLE)
68 uint32_t flags;
69 int64_t fd;
70 uint32_t mapoffset;
71 uint32_t maxsize;
72 void *data;
73 struct spa_chunk *chunk;
74};
75
77struct spa_buffer {
78 uint32_t n_metas;
79 uint32_t n_datas;
80 struct spa_meta *metas;
81 struct spa_data *datas;
82};
85static inline struct spa_meta *spa_buffer_find_meta(const struct spa_buffer *b, uint32_t type)
87 uint32_t i;
88
89 for (i = 0; i < b->n_metas; i++)
90 if (b->metas[i].type == type)
91 return &b->metas[i];
93 return NULL;
95
96static inline void *spa_buffer_find_meta_data(const struct spa_buffer *b, uint32_t type, size_t size)
97{
98 struct spa_meta *m;
99 if ((m = spa_buffer_find_meta(b, type)) && m->size >= size)
100 return m->data;
101 return NULL;
102}
103
108#ifdef __cplusplus
109} /* extern "C" */
110#endif
111
112#endif /* SPA_BUFFER_H */
spa/utils/defs.h
static void * spa_buffer_find_meta_data(const struct spa_buffer *b, uint32_t type, size_t size)
Definition: buffer/buffer.h:109
static struct spa_meta * spa_buffer_find_meta(const struct spa_buffer *b, uint32_t type)
Find metadata in a buffer.
Definition: buffer/buffer.h:98
spa_data_type
Definition: buffer/buffer.h:31
@ _SPA_DATA_LAST
not part of ABI
Definition: buffer/buffer.h:39
@ SPA_DATA_MemFd
generic fd, mmap to get to memory
Definition: buffer/buffer.h:35
@ SPA_DATA_MemPtr
pointer to memory, the data field in struct spa_data is set.
Definition: buffer/buffer.h:33
@ SPA_DATA_Invalid
Definition: buffer/buffer.h:32
@ SPA_DATA_MemId
memory is identified with an id
Definition: buffer/buffer.h:37
@ SPA_DATA_DmaBuf
fd to dmabuf memory
Definition: buffer/buffer.h:36
spa/buffer/meta.h
A Buffer.
Definition: buffer/buffer.h:90
uint32_t n_metas
number of metadata
Definition: buffer/buffer.h:91
struct spa_meta * metas
array of metadata
Definition: buffer/buffer.h:93
struct spa_data * datas
array of data members
Definition: buffer/buffer.h:94
uint32_t n_datas
number of data members
Definition: buffer/buffer.h:92
Chunk of memory, can change for each buffer.
Definition: buffer/buffer.h:43
int32_t stride
stride of valid data
Definition: buffer/buffer.h:49
uint32_t size
size of valid data.
Definition: buffer/buffer.h:47
int32_t flags
chunk flags
Definition: buffer/buffer.h:58
uint32_t offset
offset of valid data.
Definition: buffer/buffer.h:44
Data for a buffer this stays constant for a buffer.
Definition: buffer/buffer.h:62
struct spa_chunk * chunk
valid chunk of memory
Definition: buffer/buffer.h:86
int64_t fd
optional fd for data
Definition: buffer/buffer.h:82
uint32_t mapoffset
offset to map fd at
Definition: buffer/buffer.h:83
uint32_t flags
data flags
Definition: buffer/buffer.h:81
void * data
optional data pointer
Definition: buffer/buffer.h:85
uint32_t maxsize
max size of data
Definition: buffer/buffer.h:84
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:63
A metadata element.
Definition: meta.h:47
uint32_t size
size of metadata
Definition: meta.h:49
uint32_t type
metadata type, one of enum spa_meta_type
Definition: meta.h:48
void * data
pointer to metadata
Definition: meta.h:50