pod: add more helpers

Implement more unit-tests
This commit is contained in:
Wim Taymans 2019-01-17 17:23:47 +01:00
parent 767e7efc0e
commit 2622e085a9
12 changed files with 745 additions and 182 deletions

View file

@ -49,8 +49,8 @@ spa_format_audio_raw_parse(const struct spa_pod *format, struct spa_audio_info_r
SPA_FORMAT_AUDIO_channels, SPA_POD_Int(&info->channels),
SPA_FORMAT_AUDIO_flags, SPA_POD_OPT_Int(&info->flags),
SPA_FORMAT_AUDIO_position, SPA_POD_OPT_Pod(&position));
if (position && position->type == SPA_TYPE_Array &&
SPA_POD_ARRAY_TYPE(position) == SPA_TYPE_Id) {
if (position && spa_pod_is_array(position) &&
SPA_POD_ARRAY_VALUE_TYPE(position) == SPA_TYPE_Id) {
uint32_t *values = (uint32_t*)SPA_POD_ARRAY_VALUES(position);
uint32_t n_values = SPA_MIN(SPA_POD_ARRAY_N_VALUES(position), SPA_AUDIO_MAX_CHANNELS);
memcpy(info->position, values, n_values * sizeof(uint32_t));

View file

@ -327,15 +327,15 @@ spa_pod_builder_bytes(struct spa_pod_builder *builder, const void *bytes, uint32
#define SPA_POD_INIT_Pointer(type,value) (struct spa_pod_pointer){ { sizeof(struct spa_pod_pointer_body), SPA_TYPE_Pointer }, { type, 0, value } }
static inline uint32_t
spa_pod_builder_pointer(struct spa_pod_builder *builder, uint32_t type, void *val)
spa_pod_builder_pointer(struct spa_pod_builder *builder, uint32_t type, const void *val)
{
const struct spa_pod_pointer p = SPA_POD_INIT_Pointer(type, val);
return spa_pod_builder_primitive(builder, &p.pod);
}
#define SPA_POD_INIT_Fd(fd) (struct spa_pod_fd){ { sizeof(int), SPA_TYPE_Fd }, fd }
#define SPA_POD_INIT_Fd(fd) (struct spa_pod_fd){ { sizeof(int64_t), SPA_TYPE_Fd }, fd }
static inline uint32_t spa_pod_builder_fd(struct spa_pod_builder *builder, int fd)
static inline uint32_t spa_pod_builder_fd(struct spa_pod_builder *builder, int64_t fd)
{
const struct spa_pod_fd p = SPA_POD_INIT_Fd(fd);
return spa_pod_builder_primitive(builder, &p.pod);

View file

@ -137,15 +137,19 @@ static inline int spa_pod_compare(const struct spa_pod *pod1,
case SPA_TYPE_Object:
{
const struct spa_pod_prop *p1, *p2;
const struct spa_pod_object *o1, *o2;
SPA_POD_OBJECT_FOREACH((const struct spa_pod_object*)pod1, p1) {
if ((p2 = spa_pod_find_prop(pod2, p1->key)) == NULL)
o1 = (const struct spa_pod_object*)pod1;
o2 = (const struct spa_pod_object*)pod2;
SPA_POD_OBJECT_FOREACH(o1, p1) {
if ((p2 = spa_pod_object_find_prop(o2, p1->key)) == NULL)
return 1;
if ((res = spa_pod_compare(&p1->value, &p2->value)) != 0)
return res;
}
SPA_POD_OBJECT_FOREACH((const struct spa_pod_object*)pod2, p2) {
if ((p1 = spa_pod_find_prop(pod1, p2->key)) == NULL)
SPA_POD_OBJECT_FOREACH(o2, p2) {
if ((p1 = spa_pod_object_find_prop(o1, p2->key)) == NULL)
return -1;
}
break;

View file

@ -263,15 +263,16 @@ static inline int spa_pod_filter_part(struct spa_pod_builder *b,
switch (SPA_POD_TYPE(pp)) {
case SPA_TYPE_Object:
if (pf != NULL) {
struct spa_pod_object *obj = (struct spa_pod_object *) pp;
struct spa_pod_object *op = (struct spa_pod_object *) pp;
struct spa_pod_object *of = (struct spa_pod_object *) pf;
struct spa_pod_prop *p1, *p2;
if (SPA_POD_TYPE(pf) != SPA_POD_TYPE(pp))
return -EINVAL;
spa_pod_builder_push_object(b, obj->body.type, obj->body.id);
SPA_POD_OBJECT_FOREACH(obj, p1) {
p2 = spa_pod_find_prop(pf, p1->key);
spa_pod_builder_push_object(b, op->body.type, op->body.id);
SPA_POD_OBJECT_FOREACH(op, p1) {
p2 = spa_pod_object_find_prop(of, p1->key);
if (p2 != NULL)
res = spa_pod_filter_prop(b, p1, p2);
else
@ -280,9 +281,8 @@ static inline int spa_pod_filter_part(struct spa_pod_builder *b,
break;
}
if (res >= 0) {
obj = (struct spa_pod_object *) pf;
SPA_POD_OBJECT_FOREACH(obj, p2) {
p1 = spa_pod_find_prop(pp, p2->key);
SPA_POD_OBJECT_FOREACH(of, p2) {
p1 = spa_pod_object_find_prop(op, p2->key);
if (p1 != NULL)
continue;

View file

@ -112,11 +112,17 @@ static inline struct spa_pod_control *spa_pod_control_next(const struct spa_pod_
(iter) < (__typeof__(iter))SPA_MEMBER((body), (_size), void); \
(iter) = (__typeof__(iter))SPA_MEMBER((iter), (body)->child.size, void))
#define SPA_POD_ARRAY_FOREACH(obj, iter) \
SPA_POD_ARRAY_BODY_FOREACH(&(obj)->body, SPA_POD_BODY_SIZE(obj), iter)
#define SPA_POD_CHOICE_BODY_FOREACH(body, _size, iter) \
for ((iter) = (__typeof__(iter))SPA_MEMBER((body), sizeof(struct spa_pod_choice_body), void); \
(iter) < (__typeof__(iter))SPA_MEMBER((body), (_size), void); \
(iter) = (__typeof__(iter))SPA_MEMBER((iter), (body)->child.size, void))
#define SPA_POD_CHOICE_FOREACH(obj, iter) \
SPA_POD_CHOICE_BODY_FOREACH(&(obj)->body, SPA_POD_BODY_SIZE(obj), iter)
#define SPA_POD_FOREACH(pod, size, iter) \
for ((iter) = (pod); \
spa_pod_is_inside(pod, size, iter); \
@ -141,34 +147,274 @@ static inline struct spa_pod_control *spa_pod_control_next(const struct spa_pod_
#define SPA_POD_SEQUENCE_FOREACH(seq, iter) \
SPA_POD_SEQUENCE_BODY_FOREACH(&(seq)->body, SPA_POD_BODY_SIZE(seq), iter)
static inline struct spa_pod_prop *spa_pod_find_prop(const struct spa_pod *pod, uint32_t key)
static inline int spa_pod_is_none(const struct spa_pod *pod)
{
return (SPA_POD_TYPE(pod) == SPA_TYPE_None);
}
static inline int spa_pod_is_bool(const struct spa_pod *pod)
{
return (SPA_POD_TYPE(pod) == SPA_TYPE_Bool && SPA_POD_BODY_SIZE(pod) >= sizeof(int32_t));
}
static inline int spa_pod_get_bool(const struct spa_pod *pod, bool *value)
{
if (!spa_pod_is_bool(pod))
return -EINVAL;
*value = SPA_POD_VALUE(struct spa_pod_bool, pod);
return 0;
}
static inline int spa_pod_is_id(const struct spa_pod *pod)
{
return (SPA_POD_TYPE(pod) == SPA_TYPE_Id && SPA_POD_BODY_SIZE(pod) >= sizeof(uint32_t));
}
static inline int spa_pod_get_id(const struct spa_pod *pod, uint32_t *value)
{
if (!spa_pod_is_id(pod))
return -EINVAL;
*value = SPA_POD_VALUE(struct spa_pod_id, pod);
return 0;
}
static inline int spa_pod_is_int(const struct spa_pod *pod)
{
return (SPA_POD_TYPE(pod) == SPA_TYPE_Int && SPA_POD_BODY_SIZE(pod) >= sizeof(int32_t));
}
static inline int spa_pod_get_int(const struct spa_pod *pod, int32_t *value)
{
if (!spa_pod_is_int(pod))
return -EINVAL;
*value = SPA_POD_VALUE(struct spa_pod_int, pod);
return 0;
}
static inline int spa_pod_is_long(const struct spa_pod *pod)
{
return (SPA_POD_TYPE(pod) == SPA_TYPE_Long && SPA_POD_BODY_SIZE(pod) >= sizeof(int64_t));
}
static inline int spa_pod_get_long(const struct spa_pod *pod, int64_t *value)
{
if (!spa_pod_is_long(pod))
return -EINVAL;
*value = SPA_POD_VALUE(struct spa_pod_long, pod);
return 0;
}
static inline int spa_pod_is_float(const struct spa_pod *pod)
{
return (SPA_POD_TYPE(pod) == SPA_TYPE_Float && SPA_POD_BODY_SIZE(pod) >= sizeof(float));
}
static inline int spa_pod_get_float(const struct spa_pod *pod, float *value)
{
if (!spa_pod_is_float(pod))
return -EINVAL;
*value = SPA_POD_VALUE(struct spa_pod_float, pod);
return 0;
}
static inline int spa_pod_is_double(const struct spa_pod *pod)
{
return (SPA_POD_TYPE(pod) == SPA_TYPE_Double && SPA_POD_BODY_SIZE(pod) >= sizeof(double));
}
static inline int spa_pod_get_double(const struct spa_pod *pod, double *value)
{
if (!spa_pod_is_double(pod))
return -EINVAL;
*value = SPA_POD_VALUE(struct spa_pod_double, pod);
return 0;
}
static inline int spa_pod_is_string(const struct spa_pod *pod)
{
const char *s = (const char *)SPA_POD_CONTENTS(struct spa_pod_string, pod);
return (SPA_POD_TYPE(pod) == SPA_TYPE_String &&
SPA_POD_BODY_SIZE(pod) > 0 &&
s[SPA_POD_BODY_SIZE(pod)-1] == '\0');
}
static inline int spa_pod_get_string(const struct spa_pod *pod, const char **value)
{
if (!spa_pod_is_string(pod))
return -EINVAL;
*value = (const char *)SPA_POD_CONTENTS(struct spa_pod_string, pod);
return 0;
}
static inline int spa_pod_copy_string(const struct spa_pod *pod, size_t maxlen, char *dest)
{
const char *s = (const char *)SPA_POD_CONTENTS(struct spa_pod_string, pod);
if (!spa_pod_is_string(pod) || maxlen < 1)
return -EINVAL;
strncpy(dest, s, maxlen-1);
dest[maxlen-1]= '\0';
return 0;
}
static inline int spa_pod_is_bytes(const struct spa_pod *pod)
{
return SPA_POD_TYPE(pod) == SPA_TYPE_Bytes;
}
static inline int spa_pod_get_bytes(const struct spa_pod *pod, const void **value, uint32_t *len)
{
if (!spa_pod_is_bytes(pod))
return -EINVAL;
*value = (const void *)SPA_POD_CONTENTS(struct spa_pod_bytes, pod);
*len = SPA_POD_BODY_SIZE(pod);
return 0;
}
static inline int spa_pod_is_pointer(const struct spa_pod *pod)
{
return (SPA_POD_TYPE(pod) == SPA_TYPE_Pointer &&
SPA_POD_BODY_SIZE(pod) >= sizeof(struct spa_pod_pointer_body));
}
static inline int spa_pod_get_pointer(const struct spa_pod *pod, uint32_t *type, const void **value)
{
if (!spa_pod_is_pointer(pod))
return -EINVAL;
*type = ((struct spa_pod_pointer*)pod)->body.type;
*value = ((struct spa_pod_pointer*)pod)->body.value;
return 0;
}
static inline int spa_pod_is_fd(const struct spa_pod *pod)
{
return (SPA_POD_TYPE(pod) == SPA_TYPE_Fd &&
SPA_POD_BODY_SIZE(pod) >= sizeof(int64_t));
}
static inline int spa_pod_get_fd(const struct spa_pod *pod, int64_t *value)
{
if (!spa_pod_is_fd(pod))
return -EINVAL;
*value = SPA_POD_VALUE(struct spa_pod_fd, pod);
return 0;
}
static inline int spa_pod_is_rectangle(const struct spa_pod *pod)
{
return (SPA_POD_TYPE(pod) == SPA_TYPE_Rectangle &&
SPA_POD_BODY_SIZE(pod) >= sizeof(struct spa_rectangle));
}
static inline int spa_pod_get_rectangle(const struct spa_pod *pod, struct spa_rectangle *value)
{
if (!spa_pod_is_rectangle(pod))
return -EINVAL;
*value = SPA_POD_VALUE(struct spa_pod_rectangle, pod);
return 0;
}
static inline int spa_pod_is_fraction(const struct spa_pod *pod)
{
return (SPA_POD_TYPE(pod) == SPA_TYPE_Fraction &&
SPA_POD_BODY_SIZE(pod) >= sizeof(struct spa_fraction));
}
static inline int spa_pod_get_fraction(const struct spa_pod *pod, struct spa_fraction *value)
{
spa_return_val_if_fail(spa_pod_is_fraction(pod), -EINVAL);
*value = SPA_POD_VALUE(struct spa_pod_fraction, pod);
return 0;
}
static inline int spa_pod_is_array(const struct spa_pod *pod)
{
return (SPA_POD_TYPE(pod) == SPA_TYPE_Array &&
SPA_POD_BODY_SIZE(pod) >= sizeof(struct spa_pod_array_body));
}
static inline int spa_pod_is_choice(const struct spa_pod *pod)
{
return (SPA_POD_TYPE(pod) == SPA_TYPE_Choice &&
SPA_POD_BODY_SIZE(pod) >= sizeof(struct spa_pod_choice_body));
}
static inline struct spa_pod *spa_pod_get_values(const struct spa_pod *pod, uint32_t *n_vals, uint32_t *choice)
{
if (pod->type == SPA_TYPE_Choice) {
*choice = SPA_POD_CHOICE_TYPE(pod);
*n_vals = *choice == SPA_CHOICE_None ? 1 : SPA_POD_CHOICE_N_VALUES(pod);
return (struct spa_pod*)SPA_POD_CHOICE_CHILD(pod);
} else {
*n_vals = 1;
*choice = SPA_CHOICE_None;
return (struct spa_pod*)pod;
}
}
static inline int spa_pod_is_struct(const struct spa_pod *pod)
{
return (SPA_POD_TYPE(pod) == SPA_TYPE_Struct);
}
static inline int spa_pod_is_object(const struct spa_pod *pod)
{
return (SPA_POD_TYPE(pod) == SPA_TYPE_Object &&
SPA_POD_BODY_SIZE(pod) >= sizeof(struct spa_pod_object_body));
}
static inline bool spa_pod_is_object_type(const struct spa_pod *pod, uint32_t type)
{
return (pod && spa_pod_is_object(pod) &&
((const struct spa_pod_object *) pod)->body.type == type);
}
static inline bool spa_pod_is_object_id(const struct spa_pod *pod, uint32_t id)
{
return (pod && spa_pod_is_object(pod) &&
((const struct spa_pod_object *) pod)->body.id == id);
}
static inline int spa_pod_is_sequence(const struct spa_pod *pod)
{
return (SPA_POD_TYPE(pod) == SPA_TYPE_Sequence &&
SPA_POD_BODY_SIZE(pod) >= sizeof(struct spa_pod_sequence_body));
}
static inline struct spa_pod_prop *spa_pod_object_find_prop(const struct spa_pod_object *pod, uint32_t key)
{
struct spa_pod_prop *res;
if (pod->type != SPA_TYPE_Object)
return NULL;
SPA_POD_OBJECT_FOREACH((struct spa_pod_object*)pod, res) {
SPA_POD_OBJECT_FOREACH(pod, res) {
if (res->key == key)
return res;
}
return NULL;
}
static inline int spa_pod_fixate(struct spa_pod *pod)
static inline struct spa_pod_prop *spa_pod_find_prop(const struct spa_pod *pod, uint32_t key)
{
if (!spa_pod_is_object(pod))
return NULL;
return spa_pod_object_find_prop((const struct spa_pod_object *)pod, key);
}
static inline int spa_pod_object_fixate(struct spa_pod_object *pod)
{
struct spa_pod_prop *res;
if (pod->type != SPA_TYPE_Object)
return -EINVAL;
SPA_POD_OBJECT_FOREACH((struct spa_pod_object*)pod, res) {
SPA_POD_OBJECT_FOREACH(pod, res) {
if (res->value.type == SPA_TYPE_Choice)
((struct spa_pod_choice*)&res->value)->body.type = SPA_CHOICE_None;
}
return 0;
}
static inline int spa_pod_fixate(struct spa_pod *pod)
{
if (!spa_pod_is_object(pod))
return -EINVAL;
return spa_pod_object_fixate((struct spa_pod_object *)pod);
}
#ifdef __cplusplus
} /* extern "C" */
#endif

View file

@ -262,14 +262,14 @@ static inline int spa_pod_parser_getv(struct spa_pod_parser *parser, va_list arg
goto read_pod;
case '\0':
if (parser->flags & SPA_POD_PARSER_FLAG_OBJECT) {
const struct spa_pod *obj = (const struct spa_pod *) it->data;
uint32_t key = va_arg(args, uint32_t);
if (key == 0) {
format = NULL;
continue;
}
if (key != SPA_ID_INVALID) {
prop = spa_pod_find_prop(obj, key);
prop = spa_pod_object_find_prop(
(const struct spa_pod_object *) it->data, key);
if (prop != NULL)
pod = &prop->value;
else
@ -358,113 +358,6 @@ static inline int spa_pod_parser_get(struct spa_pod_parser *parser, ...)
spa_pod_parser_get_struct(&_p,##__VA_ARGS__); \
})
static inline int spa_pod_is_bool(struct spa_pod *pod)
{
return (SPA_POD_TYPE(pod) == SPA_TYPE_Bool && SPA_POD_BODY_SIZE(pod) >= sizeof(int32_t));
}
static inline int spa_pod_get_bool(struct spa_pod *pod, bool *value)
{
if (!spa_pod_is_bool(pod))
return -EINVAL;
*value = SPA_POD_VALUE(struct spa_pod_bool, pod);
return 0;
}
static inline int spa_pod_is_float(struct spa_pod *pod)
{
return (SPA_POD_TYPE(pod) == SPA_TYPE_Float && SPA_POD_BODY_SIZE(pod) >= sizeof(float));
}
static inline int spa_pod_get_float(struct spa_pod *pod, float *value)
{
if (!spa_pod_is_float(pod))
return -EINVAL;
*value = SPA_POD_VALUE(struct spa_pod_float, pod);
return 0;
}
static inline int spa_pod_is_double(struct spa_pod *pod)
{
return (SPA_POD_TYPE(pod) == SPA_TYPE_Double && SPA_POD_BODY_SIZE(pod) >= sizeof(double));
}
static inline int spa_pod_get_double(struct spa_pod *pod, double *value)
{
if (!spa_pod_is_double(pod))
return -EINVAL;
*value = SPA_POD_VALUE(struct spa_pod_double, pod);
return 0;
}
static inline int spa_pod_is_id(struct spa_pod *pod)
{
return (SPA_POD_TYPE(pod) == SPA_TYPE_Id && SPA_POD_BODY_SIZE(pod) >= sizeof(uint32_t));
}
static inline int spa_pod_get_id(struct spa_pod *pod, uint32_t *value)
{
if (!spa_pod_is_id(pod))
return -EINVAL;
*value = SPA_POD_VALUE(struct spa_pod_id, pod);
return 0;
}
static inline int spa_pod_is_int(struct spa_pod *pod)
{
return (SPA_POD_TYPE(pod) == SPA_TYPE_Int && SPA_POD_BODY_SIZE(pod) >= sizeof(int32_t));
}
static inline int spa_pod_get_int(struct spa_pod *pod, int32_t *value)
{
if (!spa_pod_is_int(pod))
return -EINVAL;
*value = SPA_POD_VALUE(struct spa_pod_int, pod);
return 0;
}
static inline int spa_pod_is_string(struct spa_pod *pod)
{
return (SPA_POD_TYPE(pod) == SPA_TYPE_String && SPA_POD_BODY_SIZE(pod) >= sizeof(1));
}
static inline int spa_pod_dup_string(struct spa_pod *pod, size_t maxlen, char *dest)
{
if (!spa_pod_is_string(pod) || maxlen < 1)
return -EINVAL;
strncpy(dest, (char *)SPA_POD_CONTENTS(struct spa_pod_string, pod), maxlen-1);
dest[maxlen-1]= '\0';
return 0;
}
static inline int spa_pod_is_rectangle(struct spa_pod *pod)
{
return (SPA_POD_TYPE(pod) == SPA_TYPE_Rectangle &&
SPA_POD_BODY_SIZE(pod) >= sizeof(struct spa_rectangle));
}
static inline int spa_pod_get_rectangle(struct spa_pod *pod, struct spa_rectangle *value)
{
if (!spa_pod_is_rectangle(pod))
return -EINVAL;
*value = SPA_POD_VALUE(struct spa_pod_rectangle, pod);
return 0;
}
static inline int spa_pod_is_fraction(struct spa_pod *pod)
{
return (SPA_POD_TYPE(pod) == SPA_TYPE_Fraction &&
SPA_POD_BODY_SIZE(pod) >= sizeof(struct spa_fraction));
}
static inline int spa_pod_get_fraction(struct spa_pod *pod, struct spa_fraction *value)
{
if (!spa_pod_is_fraction(pod))
return -EINVAL;
*value = SPA_POD_VALUE(struct spa_pod_fraction, pod);
return 0;
}
#ifdef __cplusplus
} /* extern "C" */
#endif

View file

@ -115,9 +115,9 @@ struct spa_pod_bitmap {
};
#define SPA_POD_ARRAY_CHILD(arr) (&((struct spa_pod_array*)(arr))->body.child)
#define SPA_POD_ARRAY_TYPE(arr) (SPA_POD_TYPE(SPA_POD_ARRAY_CHILD(arr)))
#define SPA_POD_ARRAY_SIZE(arr) (SPA_POD_BODY_SIZE(SPA_POD_ARRAY_CHILD(arr)))
#define SPA_POD_ARRAY_N_VALUES(arr) ((SPA_POD_BODY_SIZE(arr) - sizeof(struct spa_pod_array_body)) / SPA_POD_ARRAY_SIZE(arr))
#define SPA_POD_ARRAY_VALUE_TYPE(arr) (SPA_POD_TYPE(SPA_POD_ARRAY_CHILD(arr)))
#define SPA_POD_ARRAY_VALUE_SIZE(arr) (SPA_POD_BODY_SIZE(SPA_POD_ARRAY_CHILD(arr)))
#define SPA_POD_ARRAY_N_VALUES(arr) ((SPA_POD_BODY_SIZE(arr) - sizeof(struct spa_pod_array_body)) / SPA_POD_ARRAY_VALUE_SIZE(arr))
#define SPA_POD_ARRAY_VALUES(arr) SPA_POD_CONTENTS(struct spa_pod_array, arr)
struct spa_pod_array_body {
@ -132,6 +132,7 @@ struct spa_pod_array {
#define SPA_POD_CHOICE_CHILD(choice) (&((struct spa_pod_choice*)(choice))->body.child)
#define SPA_POD_CHOICE_TYPE(choice) (((struct spa_pod_choice*)(choice))->body.type)
#define SPA_POD_CHOICE_FLAGS(choice) (((struct spa_pod_choice*)(choice))->body.flags)
#define SPA_POD_CHOICE_VALUE_TYPE(choice) (SPA_POD_TYPE(SPA_POD_CHOICE_CHILD(choice)))
#define SPA_POD_CHOICE_VALUE_SIZE(choice) (SPA_POD_BODY_SIZE(SPA_POD_CHOICE_CHILD(choice)))
#define SPA_POD_CHOICE_N_VALUES(choice) ((SPA_POD_BODY_SIZE(choice) - sizeof(struct spa_pod_choice_body)) / SPA_POD_CHOICE_VALUE_SIZE(choice))
@ -179,18 +180,6 @@ struct spa_pod_object {
struct spa_pod_object_body body;
};
static inline bool spa_pod_is_object_type(const struct spa_pod *pod, uint32_t type)
{
return (pod && pod->type == SPA_TYPE_Object
&& ((struct spa_pod_object *) pod)->body.type == type);
}
static inline bool spa_pod_is_object_id(const struct spa_pod *pod, uint32_t id)
{
return (pod && pod->type == SPA_TYPE_Object
&& ((struct spa_pod_object *) pod)->body.id == id);
}
struct spa_pod_pointer_body {
uint32_t type; /**< pointer id, one of enum spa_type */
uint32_t _padding;
@ -207,19 +196,6 @@ struct spa_pod_fd {
int64_t value;
};
static inline struct spa_pod *spa_pod_get_values(const struct spa_pod *pod, uint32_t *n_vals, uint32_t *choice)
{
if (pod->type == SPA_TYPE_Choice) {
*choice = SPA_POD_CHOICE_TYPE(pod);
*n_vals = *choice == SPA_CHOICE_None ? 1 : SPA_POD_CHOICE_N_VALUES(pod);
return (struct spa_pod*)SPA_POD_CHOICE_CHILD(pod);
} else {
*n_vals = 1;
*choice = SPA_CHOICE_None;
return (struct spa_pod*)pod;
}
}
#define SPA_POD_PROP_SIZE(prop) (sizeof(struct spa_pod_prop) + (prop)->value.size)
/* props can be inside an object */