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)
114 if (offset < 0 || offset > (int64_t)UINT32_MAX)
116 if (size <
sizeof(
struct spa_pod) ||
118 maxsize - size < (uint32_t)offset)
139#define SPA_POD_BODY_LOAD_ONCE(a, b) (*(a) = SPA_LOAD_ONCE((__typeof__(a))(b)))
140#define SPA_POD_BODY_LOAD_FIELD_ONCE(a, b, field) ((a)->field = SPA_LOAD_ONCE(&((__typeof__(a))(b))->field))
146 *value = !!__atomic_load_n((
const int32_t *)body, __ATOMIC_RELAXED);
187 memcpy(value, body,
sizeof *value);
202 memcpy(value, body,
sizeof *value);
217 memcpy(value, body,
sizeof *value);
228 const void *body,
const char **value)
233 s = (
const char *)body;
234 if (((
const volatile char *)s)[pod->
size-1] !=
'\0')
241 char *dest,
size_t maxlen)
247 strncpy(dest, s, maxlen-1);
249 dest[maxlen-1]=
'\0';
259 const void **value, uint32_t *len)
263 *value = (
const void *)body;
274 uint32_t *
type,
const void **value)
336 const uint8_t **
value)
360 const void *body, uint32_t *n_values, uint32_t *val_size, uint32_t *val_type)
363 *n_values = child_size ? (arr->
pod.
size -
sizeof(arr->
body)) / child_size : 0;
364 *val_size = child_size;
372 const void *body, uint32_t *n_values, uint32_t *val_size, uint32_t *val_type)
398 const void *
body, uint32_t *n_values, uint32_t *choice,
399 uint32_t *val_size, uint32_t *val_type)
401 uint32_t child_size =
pod->body.child.
size, min, max;
402 *val_size = child_size;
403 *val_type =
pod->body.child.
type;
404 *n_values = child_size ? (
pod->pod.
size -
sizeof(
pod->body)) / child_size : 0;
409 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:444
SPA_API_POD_BODY int spa_pod_is_pointer(const struct spa_pod *pod)
Definition body.h:277
SPA_API_POD_BODY int spa_pod_is_bitmap(const struct spa_pod *pod)
Definition body.h:340
#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:326
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:282
SPA_API_POD_BODY int spa_pod_is_double(const struct spa_pod *pod)
Definition body.h:216
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:380
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:448
SPA_API_POD_BODY int spa_pod_body_get_string(const struct spa_pod *pod, const void *body, const char **value)
Definition body.h:236
SPA_API_POD_BODY int spa_pod_is_array(const struct spa_pod *pod)
Definition body.h:353
SPA_API_POD_BODY int spa_pod_is_rectangle(const struct spa_pod *pod)
Definition body.h:311
SPA_API_POD_BODY int spa_pod_is_struct(const struct spa_pod *pod)
Definition body.h:423
SPA_API_POD_BODY int spa_pod_is_int(const struct spa_pod *pod)
Definition body.h:172
SPA_API_POD_BODY int spa_pod_is_fd(const struct spa_pod *pod)
Definition body.h:295
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:330
SPA_API_POD_BODY int spa_pod_is_none(const struct spa_pod *pod)
Definition body.h:136
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:428
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:368
SPA_API_POD_BODY int spa_pod_is_bool(const struct spa_pod *pod)
Definition body.h:141
#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:159
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:149
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:357
SPA_API_POD_BODY int spa_pod_body_get_double(const struct spa_pod *pod, const void *body, double *value)
Definition body.h:221
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:249
SPA_API_POD_BODY int spa_pod_body_get_long(const struct spa_pod *pod, const void *body, int64_t *value)
Definition body.h:190
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:432
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:406
SPA_API_POD_BODY int spa_pod_is_bytes(const struct spa_pod *pod)
Definition body.h:262
SPA_API_POD_BODY int spa_pod_body_get_int(const struct spa_pod *pod, const void *body, int32_t *value)
Definition body.h:177
SPA_API_POD_BODY int spa_pod_is_string(const struct spa_pod *pod)
Definition body.h:231
#define SPA_POD_BODY_LOAD_ONCE(a, b)
Definition body.h:147
SPA_API_POD_BODY int spa_pod_body_get_float(const struct spa_pod *pod, const void *body, float *value)
Definition body.h:206
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:316
SPA_API_POD_BODY int spa_pod_body_get_bool(const struct spa_pod *pod, const void *body, bool *value)
Definition body.h:151
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:344
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:393
SPA_API_POD_BODY int spa_pod_body_get_fd(const struct spa_pod *pod, const void *body, int64_t *value)
Definition body.h:300
SPA_API_POD_BODY int spa_pod_is_choice(const struct spa_pod *pod)
Definition body.h:389
SPA_API_POD_BODY int spa_pod_body_get_id(const struct spa_pod *pod, const void *body, uint32_t *value)
Definition body.h:164
SPA_API_POD_BODY int spa_pod_is_float(const struct spa_pod *pod)
Definition body.h:201
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:267
#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:185
@ 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