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);
83 switch (choice_type) {
112 struct spa_pod *pod,
const void **body)
119#if __SIZEOF_POINTER__ > 4
120 if (offset > (int64_t)UINT32_MAX)
123 if (size <
sizeof(
struct spa_pod) ||
125 maxsize - size < (uint32_t)offset)
146#define SPA_POD_BODY_LOAD_ONCE(a, b) (*(a) = SPA_LOAD_ONCE((__typeof__(a))(b)))
147#define SPA_POD_BODY_LOAD_FIELD_ONCE(a, b, field) ((a)->field = SPA_LOAD_ONCE(&((__typeof__(a))(b))->field))
153 *value = !!__atomic_load_n((
const int32_t *)body, __ATOMIC_RELAXED);
194 memcpy(value, body,
sizeof *value);
209 memcpy(value, body,
sizeof *value);
224 memcpy(value, body,
sizeof *value);
235 const void *body,
const char **value)
240 s = (
const char *)body;
241 if (((
const volatile char *)s)[pod->
size-1] !=
'\0')
248 char *dest,
size_t maxlen)
254 strncpy(dest, s, maxlen-1);
256 dest[maxlen-1]=
'\0';
266 const void **value, uint32_t *len)
270 *value = (
const void *)body;
281 uint32_t *
type,
const void **value)
343 const uint8_t **
value)
367 const void *body, uint32_t *n_values, uint32_t *val_size, uint32_t *val_type)
370 *n_values = child_size ? (arr->
pod.
size -
sizeof(arr->
body)) / child_size : 0;
371 *val_size = child_size;
379 const void *body, uint32_t *n_values, uint32_t *val_size, uint32_t *val_type)
405 const void *
body, uint32_t *n_values, uint32_t *choice,
406 uint32_t *val_size, uint32_t *val_type)
408 uint32_t child_size =
pod->body.child.
size, min, max;
409 *val_size = child_size;
410 *val_type =
pod->body.child.
type;
411 *n_values = child_size ? (
pod->pod.
size -
sizeof(
pod->body)) / child_size : 0;
416 else if (*n_values > max)
#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:451
SPA_API_POD_BODY int spa_pod_is_pointer(const struct spa_pod *pod)
Definition body.h:284
SPA_API_POD_BODY int spa_pod_is_bitmap(const struct spa_pod *pod)
Definition body.h:347
#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:333
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:289
SPA_API_POD_BODY int spa_pod_is_double(const struct spa_pod *pod)
Definition body.h:223
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:387
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:455
SPA_API_POD_BODY int spa_pod_body_get_string(const struct spa_pod *pod, const void *body, const char **value)
Definition body.h:243
SPA_API_POD_BODY int spa_pod_is_array(const struct spa_pod *pod)
Definition body.h:360
SPA_API_POD_BODY int spa_pod_is_rectangle(const struct spa_pod *pod)
Definition body.h:318
SPA_API_POD_BODY int spa_pod_is_struct(const struct spa_pod *pod)
Definition body.h:430
SPA_API_POD_BODY int spa_pod_is_int(const struct spa_pod *pod)
Definition body.h:179
SPA_API_POD_BODY int spa_pod_is_fd(const struct spa_pod *pod)
Definition body.h:302
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:337
SPA_API_POD_BODY int spa_pod_is_none(const struct spa_pod *pod)
Definition body.h:143
SPA_API_POD_BODY int spa_pod_choice_n_values(uint32_t choice_type, uint32_t *min, uint32_t *max)
Definition body.h:88
SPA_API_POD_BODY int spa_pod_is_object(const struct spa_pod *pod)
Definition body.h:435
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:375
SPA_API_POD_BODY int spa_pod_is_bool(const struct spa_pod *pod)
Definition body.h:148
#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:166
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:156
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:364
SPA_API_POD_BODY int spa_pod_body_get_double(const struct spa_pod *pod, const void *body, double *value)
Definition body.h:228
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:256
SPA_API_POD_BODY int spa_pod_body_get_long(const struct spa_pod *pod, const void *body, int64_t *value)
Definition body.h:197
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:439
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:413
SPA_API_POD_BODY int spa_pod_is_bytes(const struct spa_pod *pod)
Definition body.h:269
SPA_API_POD_BODY int spa_pod_body_get_int(const struct spa_pod *pod, const void *body, int32_t *value)
Definition body.h:184
SPA_API_POD_BODY int spa_pod_is_string(const struct spa_pod *pod)
Definition body.h:238
#define SPA_POD_BODY_LOAD_ONCE(a, b)
Definition body.h:154
SPA_API_POD_BODY int spa_pod_body_get_float(const struct spa_pod *pod, const void *body, float *value)
Definition body.h:213
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:323
SPA_API_POD_BODY int spa_pod_body_get_bool(const struct spa_pod *pod, const void *body, bool *value)
Definition body.h:158
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:351
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:118
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:400
SPA_API_POD_BODY int spa_pod_body_get_fd(const struct spa_pod *pod, const void *body, int64_t *value)
Definition body.h:307
SPA_API_POD_BODY int spa_pod_is_choice(const struct spa_pod *pod)
Definition body.h:396
SPA_API_POD_BODY int spa_pod_body_get_id(const struct spa_pod *pod, const void *body, uint32_t *value)
Definition body.h:171
SPA_API_POD_BODY int spa_pod_is_float(const struct spa_pod *pod)
Definition body.h:208
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:274
#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:192
@ SPA_CHOICE_Step
range with step: default, min, max, step
Definition pod.h:163
@ SPA_CHOICE_None
no choice, first value is current
Definition pod.h:161
@ SPA_CHOICE_Flags
flags: first value is flags
Definition pod.h:165
@ SPA_CHOICE_Range
range: default, min, max
Definition pod.h:162
@ SPA_CHOICE_Enum
list: default, alternative,...
Definition pod.h:164
@ 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_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