PipeWire 1.2.6
Loading...
Searching...
No Matches
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 {
48 uint32_t size;
50 int32_t stride;
51#define SPA_CHUNK_FLAG_NONE 0
52#define SPA_CHUNK_FLAG_CORRUPTED (1u<<0)
53#define SPA_CHUNK_FLAG_EMPTY (1u<<1)
56 int32_t flags;
57};
58
60struct spa_data {
61 uint32_t type;
69#define SPA_DATA_FLAG_NONE 0
70#define SPA_DATA_FLAG_READABLE (1u<<0)
71#define SPA_DATA_FLAG_WRITABLE (1u<<1)
72#define SPA_DATA_FLAG_DYNAMIC (1u<<2)
73#define SPA_DATA_FLAG_READWRITE (SPA_DATA_FLAG_READABLE|SPA_DATA_FLAG_WRITABLE)
74#define SPA_DATA_FLAG_MAPPABLE (1u<<3)
77 uint32_t flags;
78 int64_t fd;
79 uint32_t mapoffset;
80 uint32_t maxsize;
81 void *data;
82 struct spa_chunk *chunk;
83};
86struct spa_buffer {
87 uint32_t n_metas;
88 uint32_t n_datas;
89 struct spa_meta *metas;
90 struct spa_data *datas;
91};
94static inline struct spa_meta *spa_buffer_find_meta(const struct spa_buffer *b, uint32_t type)
96 uint32_t i;
97
98 for (i = 0; i < b->n_metas; i++)
99 if (b->metas[i].type == type)
100 return &b->metas[i];
102 return NULL;
105static inline void *spa_buffer_find_meta_data(const struct spa_buffer *b, uint32_t type, size_t size)
106{
107 struct spa_meta *m;
108 if ((m = spa_buffer_find_meta(b, type)) && m->size >= size)
109 return m->data;
110 return NULL;
111}
112
117#ifdef __cplusplus
118} /* extern "C" */
119#endif
120
121#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.h:119
static struct spa_meta * spa_buffer_find_meta(const struct spa_buffer *b, uint32_t type)
Find metadata in a buffer.
Definition buffer.h:108
spa_data_type
Definition buffer.h:31
@ _SPA_DATA_LAST
not part of ABI
Definition buffer.h:45
@ SPA_DATA_MemFd
memfd, mmap to get to memory.
Definition buffer.h:35
@ SPA_DATA_MemPtr
pointer to memory, the data field in struct spa_data is set.
Definition buffer.h:33
@ SPA_DATA_SyncObj
a syncobj, usually requires a spa_meta_sync_timeline metadata with timeline points.
Definition buffer.h:42
@ SPA_DATA_Invalid
Definition buffer.h:32
@ SPA_DATA_MemId
memory is identified with an id.
Definition buffer.h:39
@ SPA_DATA_DmaBuf
fd to dmabuf memory.
Definition buffer.h:36
spa/buffer/meta.h
A Buffer.
Definition buffer.h:100
uint32_t n_metas
number of metadata
Definition buffer.h:101
struct spa_meta * metas
array of metadata
Definition buffer.h:103
struct spa_data * datas
array of data members
Definition buffer.h:104
uint32_t n_datas
number of data members
Definition buffer.h:102
Chunk of memory, can change for each buffer.
Definition buffer.h:49
int32_t stride
stride of valid data
Definition buffer.h:55
uint32_t size
size of valid data.
Definition buffer.h:53
int32_t flags
chunk flags
Definition buffer.h:64
uint32_t offset
offset of valid data.
Definition buffer.h:50
Data for a buffer this stays constant for a buffer.
Definition buffer.h:68
struct spa_chunk * chunk
valid chunk of memory
Definition buffer.h:96
int64_t fd
optional fd for data
Definition buffer.h:92
uint32_t mapoffset
offset to map fd at, this is page aligned
Definition buffer.h:93
uint32_t flags
data flags
Definition buffer.h:91
void * data
optional data pointer
Definition buffer.h:95
uint32_t maxsize
max size of data
Definition buffer.h:94
uint32_t type
memory type, one of enum spa_data_type, when allocating memory, the type contains a bitmask of allowe...
Definition buffer.h:69
A metadata element.
Definition meta.h:48
uint32_t size
size of metadata
Definition meta.h:50
uint32_t type
metadata type, one of enum spa_meta_type
Definition meta.h:49
void * data
pointer to metadata
Definition meta.h:51