12#include <spa/utils/atomic.h>
18#ifndef SPA_API_POD_BODY
20 #define SPA_API_POD_BODY SPA_API_IMPL
22 #define SPA_API_POD_BODY static inline
50 return sizeof(int32_t);
52 return sizeof(uint32_t);
54 return sizeof(int64_t);
58 return sizeof(double);
64 return sizeof(uint8_t);
74 return sizeof(int64_t);
82 struct spa_pod *pod,
const void **body)
84 if (offset < 0 || offset > (int64_t)UINT32_MAX)
86 if (size <
sizeof(
struct spa_pod) ||
88 maxsize - size < (uint32_t)offset)
109#define SPA_POD_BODY_LOAD_ONCE(a, b) (*(a) = SPA_LOAD_ONCE((__typeof__(a))(b)))
110#define SPA_POD_BODY_LOAD_FIELD_ONCE(a, b, field) ((a)->field = SPA_LOAD_ONCE(&((__typeof__(a))(b))->field))
116 *value = !!__atomic_load_n((
const int32_t *)body, __ATOMIC_RELAXED);
157 memcpy(value, body,
sizeof *value);
172 memcpy(value, body,
sizeof *value);
187 memcpy(value, body,
sizeof *value);
198 const void *body,
const char **value)
203 s = (
const char *)body;
204 if (((
const volatile char *)s)[pod->
size-1] !=
'\0')
211 char *dest,
size_t maxlen)
217 strncpy(dest, s, maxlen-1);
219 dest[maxlen-1]=
'\0';
229 const void **value, uint32_t *len)
233 *value = (
const void *)body;
244 uint32_t *
type,
const void **value)
306 const uint8_t **
value)
330 const void *body, uint32_t *n_values, uint32_t *val_size, uint32_t *val_type)
333 *n_values = child_size ? (arr->
pod.
size -
sizeof(arr->
body)) / child_size : 0;
334 *val_size = child_size;
340 const void *body, uint32_t *n_values, uint32_t *val_size, uint32_t *val_type)
366 const void *
body, uint32_t *n_values, uint32_t *choice,
367 uint32_t *val_size, uint32_t *val_type)
369 uint32_t child_size =
pod->body.child.
size;
370 *val_size = child_size;
371 *val_type =
pod->body.child.
type;
372 *n_values = child_size ? (
pod->pod.
size -
sizeof(
pod->body)) / child_size : 0;
375 *n_values =
SPA_MIN(1u, *n_values);
#define SPA_API_POD_BODY
Definition body.h:29
uint32_t int seq
Definition core.h:432
SPA_API_POD_BODY int spa_pod_is_sequence(const struct spa_pod *pod)
Definition body.h:409
SPA_API_POD_BODY int spa_pod_is_pointer(const struct spa_pod *pod)
Definition body.h:247
SPA_API_POD_BODY int spa_pod_is_bitmap(const struct spa_pod *pod)
Definition body.h:310
#define SPA_POD_IS_VALID(pod)
Definition pod.h:48
SPA_API_POD_BODY int spa_pod_is_fraction(const struct spa_pod *pod)
Definition body.h:296
SPA_API_POD_BODY int spa_pod_body_get_pointer(const struct spa_pod *pod, const void *body, uint32_t *type, const void **value)
Definition body.h:252
SPA_API_POD_BODY int spa_pod_is_double(const struct spa_pod *pod)
Definition body.h:186
SPA_API_POD_BODY const void * spa_pod_body_get_array_values(const struct spa_pod *pod, const void *body, uint32_t *n_values, uint32_t *val_size, uint32_t *val_type)
Definition body.h:348
SPA_API_POD_BODY int spa_pod_body_get_sequence(const struct spa_pod *pod, const void *body, struct spa_pod_sequence *seq, const void **seq_body)
Definition body.h:413
SPA_API_POD_BODY int spa_pod_body_get_string(const struct spa_pod *pod, const void *body, const char **value)
Definition body.h:206
SPA_API_POD_BODY int spa_pod_is_array(const struct spa_pod *pod)
Definition body.h:323
SPA_API_POD_BODY int spa_pod_is_rectangle(const struct spa_pod *pod)
Definition body.h:281
SPA_API_POD_BODY int spa_pod_is_struct(const struct spa_pod *pod)
Definition body.h:388
SPA_API_POD_BODY int spa_pod_is_int(const struct spa_pod *pod)
Definition body.h:142
SPA_API_POD_BODY int spa_pod_is_fd(const struct spa_pod *pod)
Definition body.h:265
SPA_API_POD_BODY int spa_pod_body_get_fraction(const struct spa_pod *pod, const void *body, struct spa_fraction *value)
Definition body.h:300
SPA_API_POD_BODY int spa_pod_is_none(const struct spa_pod *pod)
Definition body.h:106
SPA_API_POD_BODY int spa_pod_is_object(const struct spa_pod *pod)
Definition body.h:393
SPA_API_POD_BODY const void * spa_pod_array_body_get_values(const struct spa_pod_array *arr, const void *body, uint32_t *n_values, uint32_t *val_size, uint32_t *val_type)
Definition body.h:338
SPA_API_POD_BODY int spa_pod_is_bool(const struct spa_pod *pod)
Definition body.h:111
#define SPA_POD_CHECK_TYPE(pod, _type)
Definition pod.h:50
SPA_API_POD_BODY int spa_pod_is_id(const struct spa_pod *pod)
Definition body.h:129
SPA_API_POD_BODY uint32_t spa_pod_type_size(uint32_t type)
Definition body.h:45
#define SPA_POD_BODY_LOAD_FIELD_ONCE(a, b, field)
Definition body.h:119
SPA_API_POD_BODY int spa_pod_body_get_array(const struct spa_pod *pod, const void *body, struct spa_pod_array *arr, const void **arr_body)
Definition body.h:327
SPA_API_POD_BODY int spa_pod_body_get_double(const struct spa_pod *pod, const void *body, double *value)
Definition body.h:191
SPA_API_POD_BODY int spa_pod_body_copy_string(const struct spa_pod *pod, const void *body, char *dest, size_t maxlen)
Definition body.h:219
SPA_API_POD_BODY int spa_pod_body_get_long(const struct spa_pod *pod, const void *body, int64_t *value)
Definition body.h:160
SPA_API_POD_BODY int spa_pod_body_get_object(const struct spa_pod *pod, const void *body, struct spa_pod_object *object, const void **object_body)
Definition body.h:397
SPA_API_POD_BODY const void * spa_pod_choice_body_get_values(const struct spa_pod_choice *pod, const void *body, uint32_t *n_values, uint32_t *choice, uint32_t *val_size, uint32_t *val_type)
Definition body.h:374
SPA_API_POD_BODY int spa_pod_is_bytes(const struct spa_pod *pod)
Definition body.h:232
SPA_API_POD_BODY int spa_pod_body_get_int(const struct spa_pod *pod, const void *body, int32_t *value)
Definition body.h:147
SPA_API_POD_BODY int spa_pod_is_string(const struct spa_pod *pod)
Definition body.h:201
#define SPA_POD_BODY_LOAD_ONCE(a, b)
Definition body.h:117
SPA_API_POD_BODY int spa_pod_body_get_float(const struct spa_pod *pod, const void *body, float *value)
Definition body.h:176
SPA_API_POD_BODY int spa_pod_body_get_rectangle(const struct spa_pod *pod, const void *body, struct spa_rectangle *value)
Definition body.h:286
SPA_API_POD_BODY int spa_pod_body_get_bool(const struct spa_pod *pod, const void *body, bool *value)
Definition body.h:121
SPA_API_POD_BODY int spa_pod_body_get_bitmap(const struct spa_pod *pod, const void *body, const uint8_t **value)
Definition body.h:314
SPA_API_POD_BODY int spa_pod_body_from_data(void *data, size_t maxsize, off_t offset, size_t size, struct spa_pod *pod, const void **body)
Definition body.h:88
SPA_API_POD_BODY int spa_pod_body_get_choice(const struct spa_pod *pod, const void *body, struct spa_pod_choice *choice, const void **choice_body)
Definition body.h:361
SPA_API_POD_BODY int spa_pod_body_get_fd(const struct spa_pod *pod, const void *body, int64_t *value)
Definition body.h:270
SPA_API_POD_BODY int spa_pod_is_choice(const struct spa_pod *pod)
Definition body.h:357
SPA_API_POD_BODY int spa_pod_body_get_id(const struct spa_pod *pod, const void *body, uint32_t *value)
Definition body.h:134
SPA_API_POD_BODY int spa_pod_is_float(const struct spa_pod *pod)
Definition body.h:171
SPA_API_POD_BODY int spa_pod_body_get_bytes(const struct spa_pod *pod, const void *body, const void **value, uint32_t *len)
Definition body.h:237
#define SPA_POD_CHECK(pod, _type, _size)
Definition pod.h:53
SPA_API_POD_BODY int spa_pod_is_long(const struct spa_pod *pod)
Definition body.h:155
@ SPA_CHOICE_None
no choice, first value is current
Definition pod.h:161
@ SPA_TYPE_Int
Definition type.h:45
@ SPA_TYPE_Rectangle
Definition type.h:51
@ SPA_TYPE_Long
Definition type.h:46
@ SPA_TYPE_Bool
Definition type.h:43
@ SPA_TYPE_Bytes
Definition type.h:50
@ SPA_TYPE_Pod
Definition type.h:61
@ SPA_TYPE_Bitmap
Definition type.h:53
@ SPA_TYPE_Object
Definition type.h:56
@ SPA_TYPE_Float
Definition type.h:47
@ SPA_TYPE_Fraction
Definition type.h:52
@ SPA_TYPE_None
Definition type.h:42
@ SPA_TYPE_Sequence
Definition type.h:57
@ SPA_TYPE_Double
Definition type.h:48
@ SPA_TYPE_Id
Definition type.h:44
@ SPA_TYPE_Choice
Definition type.h:60
@ SPA_TYPE_Pointer
Definition type.h:58
@ SPA_TYPE_Array
Definition type.h:54
@ SPA_TYPE_String
Definition type.h:49
@ SPA_TYPE_Fd
Definition type.h:59
@ SPA_TYPE_Struct
Definition type.h:55
#define SPA_MIN(a, b)
Definition defs.h:165
#define SPA_BARRIER
Definition defs.h:315
#define SPA_PTROFF(ptr_, offset_, type_)
Return the address (buffer + offset) as pointer of type.
Definition defs.h:222
struct spa_pod child
Definition pod.h:136
struct spa_pod pod
Definition pod.h:141
struct spa_pod_array_body body
Definition pod.h:142
uint32_t type
type of choice, one of enum spa_choice_type
Definition pod.h:169
struct spa_pod_choice_body body
Definition pod.h:178
struct spa_pod pod
Definition pod.h:177
struct spa_pod pod
Definition body.h:39
uint32_t offset
Definition body.h:41
struct spa_pod_frame * parent
Definition body.h:40
uint32_t flags
Definition body.h:42
const void * value
Definition pod.h:210
uint32_t type
pointer id, one of enum spa_type
Definition pod.h:208
a sequence of timed controls
Definition pod.h:271
uint32_t type
Definition pod.h:59
uint32_t size
Definition pod.h:58