Type changes

Only allow properties inside objects, this makes it easier to
iterate the object, which is needed for efficiently processing
control streams.
Add a choice type to mark variable properties.
SPA_TYPE_Enum -> SPA_TYPE_Id to avoid confusion with choice enum
Make it easier to allocate and initialize properties on the stack
Make more efficient methods to make objects.
This commit is contained in:
Wim Taymans 2018-09-05 16:41:07 +02:00
parent 03fdabd155
commit cc842cbdc8
63 changed files with 2253 additions and 1880 deletions

View file

@ -45,7 +45,7 @@ struct spa_pod_builder {
uint32_t size;
uint32_t (*write) (struct spa_pod_builder *builder, const void *data, uint32_t size);
void * (*deref) (struct spa_pod_builder *builder, uint32_t ref);
void * (*deref) (struct spa_pod_builder *builder, uint32_t ref, bool safe);
void (*reset) (struct spa_pod_builder *builder, struct spa_pod_builder_state *state);
struct spa_pod_builder_state state;
@ -75,20 +75,26 @@ static inline void spa_pod_builder_init(struct spa_pod_builder *builder, void *d
}
static inline void *
spa_pod_builder_deref(struct spa_pod_builder *builder, uint32_t ref)
spa_pod_builder_deref_checked(struct spa_pod_builder *builder, uint32_t ref, bool safe)
{
if (ref == SPA_ID_INVALID)
return NULL;
else if (builder->deref)
return builder->deref(builder, ref);
return builder->deref(builder, ref, safe);
else if (ref + 8 <= builder->size) {
struct spa_pod *pod = SPA_MEMBER(builder->data, ref, struct spa_pod);
if (SPA_POD_SIZE(pod) <= builder->size)
if (!safe || SPA_POD_SIZE(pod) <= builder->size)
return (void *) pod;
}
return NULL;
}
static inline void *
spa_pod_builder_deref(struct spa_pod_builder *builder, uint32_t ref)
{
return spa_pod_builder_deref_checked(builder, ref, false);
}
static inline uint32_t
spa_pod_builder_push(struct spa_pod_builder *builder,
const struct spa_pod *pod,
@ -98,7 +104,7 @@ spa_pod_builder_push(struct spa_pod_builder *builder,
frame->pod = *pod;
frame->ref = ref;
builder->state.in_array = builder->state.first =
(pod->type == SPA_TYPE_Array || pod->type == SPA_TYPE_Prop);
(pod->type == SPA_TYPE_Array || pod->type == SPA_TYPE_Choice);
return ref;
}
@ -113,7 +119,7 @@ spa_pod_builder_raw(struct spa_pod_builder *builder, const void *data, uint32_t
} else {
ref = builder->state.offset;
if (ref + size > builder->size)
ref = -1;
ref = SPA_ID_INVALID;
else
memcpy(SPA_MEMBER(builder->data, ref, void), data, size);
}
@ -148,94 +154,130 @@ static inline void *spa_pod_builder_pop(struct spa_pod_builder *builder)
struct spa_pod *pod;
frame = &builder->frame[--builder->state.depth];
if ((pod = (struct spa_pod *) spa_pod_builder_deref(builder, frame->ref)) != NULL)
if ((pod = (struct spa_pod *) spa_pod_builder_deref_checked(builder, frame->ref, true)) != NULL)
*pod = frame->pod;
top = builder->state.depth > 0 ? &builder->frame[builder->state.depth-1] : NULL;
builder->state.in_array = (top &&
(top->pod.type == SPA_TYPE_Array || top->pod.type == SPA_TYPE_Prop));
(top->pod.type == SPA_TYPE_Array || top->pod.type == SPA_TYPE_Choice));
spa_pod_builder_pad(builder, builder->state.offset);
return pod;
}
#define SPA_TYPE_Collect 0x100
struct spa_pod_collect {
struct spa_pod pod;
struct spa_pod child;
const void *value;
};
static inline uint32_t
spa_pod_builder_primitive(struct spa_pod_builder *builder, const struct spa_pod *p)
{
const void *data;
uint32_t size, ref;
const void *head, *body;
uint32_t head_size, body_size, ref;
bool collect = p->type == SPA_TYPE_Collect;
if (collect) {
struct spa_pod_collect *col = (struct spa_pod_collect *)p;
head = &col->child;
head_size = sizeof(struct spa_pod);
body = col->value;
} else {
head = p;
head_size = SPA_POD_SIZE(p);
body = SPA_POD_BODY_CONST(p);
}
body_size = SPA_POD_BODY_SIZE(head);
if (builder->state.in_array && !builder->state.first) {
data = SPA_POD_BODY_CONST(p);
size = SPA_POD_BODY_SIZE(p);
head = body;
head_size = body_size;
collect = false;
} else {
data = p;
size = SPA_POD_SIZE(p);
builder->state.first = false;
}
ref = spa_pod_builder_raw(builder, data, size);
ref = spa_pod_builder_raw(builder, head, head_size);
if (ref != SPA_ID_INVALID && collect) {
ref = spa_pod_builder_raw(builder, body, body_size);
head_size += body_size;
}
if (!builder->state.in_array)
spa_pod_builder_pad(builder, size);
spa_pod_builder_pad(builder, head_size);
return ref;
}
#define SPA_POD_NONE_INIT() (struct spa_pod) { 0, SPA_TYPE_None }
#define SPA_POD_INIT(size,type) (struct spa_pod) { size, type }
#define SPA_POD_None() SPA_POD_INIT(0, SPA_TYPE_None)
static inline uint32_t spa_pod_builder_none(struct spa_pod_builder *builder)
{
const struct spa_pod p = SPA_POD_NONE_INIT();
const struct spa_pod p = SPA_POD_None();
return spa_pod_builder_primitive(builder, &p);
}
#define SPA_POD_BOOL_INIT(val) (struct spa_pod_bool){ { sizeof(uint32_t), SPA_TYPE_Bool }, val ? 1 : 0, 0 }
#define SPA_POD_Bool(val) (struct spa_pod_bool){ { sizeof(uint32_t), SPA_TYPE_Bool }, val ? 1 : 0, 0 }
static inline uint32_t spa_pod_builder_bool(struct spa_pod_builder *builder, bool val)
{
const struct spa_pod_bool p = SPA_POD_BOOL_INIT(val);
const struct spa_pod_bool p = SPA_POD_Bool(val);
return spa_pod_builder_primitive(builder, &p.pod);
}
#define SPA_POD_ENUM_INIT(val) (struct spa_pod_enum){ { sizeof(uint32_t), SPA_TYPE_Enum }, val, 0 }
#define SPA_POD_Id(val) (struct spa_pod_id){ { sizeof(uint32_t), SPA_TYPE_Id }, val, 0 }
static inline uint32_t spa_pod_builder_enum(struct spa_pod_builder *builder, uint32_t val)
static inline uint32_t spa_pod_builder_id(struct spa_pod_builder *builder, uint32_t val)
{
const struct spa_pod_enum p = SPA_POD_ENUM_INIT(val);
const struct spa_pod_id p = SPA_POD_Id(val);
return spa_pod_builder_primitive(builder, &p.pod);
}
#define SPA_POD_INT_INIT(val) (struct spa_pod_int){ { sizeof(uint32_t), SPA_TYPE_Int }, val, 0 }
#define SPA_POD_Int(val) (struct spa_pod_int){ { sizeof(uint32_t), SPA_TYPE_Int }, val, 0 }
static inline uint32_t spa_pod_builder_int(struct spa_pod_builder *builder, int32_t val)
{
const struct spa_pod_int p = SPA_POD_INT_INIT(val);
const struct spa_pod_int p = SPA_POD_Int(val);
return spa_pod_builder_primitive(builder, &p.pod);
}
#define SPA_POD_LONG_INIT(val) (struct spa_pod_long){ { sizeof(uint64_t), SPA_TYPE_Long }, val }
#define SPA_POD_Long(val) (struct spa_pod_long){ { sizeof(uint64_t), SPA_TYPE_Long }, val }
static inline uint32_t spa_pod_builder_long(struct spa_pod_builder *builder, int64_t val)
{
const struct spa_pod_long p = SPA_POD_LONG_INIT(val);
const struct spa_pod_long p = SPA_POD_Long(val);
return spa_pod_builder_primitive(builder, &p.pod);
}
#define SPA_POD_FLOAT_INIT(val) (struct spa_pod_float){ { sizeof(float), SPA_TYPE_Float }, val }
#define SPA_POD_Float(val) (struct spa_pod_float){ { sizeof(float), SPA_TYPE_Float }, val }
static inline uint32_t spa_pod_builder_float(struct spa_pod_builder *builder, float val)
{
const struct spa_pod_float p = SPA_POD_FLOAT_INIT(val);
const struct spa_pod_float p = SPA_POD_Float(val);
return spa_pod_builder_primitive(builder, &p.pod);
}
#define SPA_POD_DOUBLE_INIT(val) (struct spa_pod_double){ { sizeof(double), SPA_TYPE_Double }, val }
#define SPA_POD_Double(val) (struct spa_pod_double){ { sizeof(double), SPA_TYPE_Double }, val }
static inline uint32_t spa_pod_builder_double(struct spa_pod_builder *builder, double val)
{
const struct spa_pod_double p = SPA_POD_DOUBLE_INIT(val);
const struct spa_pod_double p = SPA_POD_Double(val);
return spa_pod_builder_primitive(builder, &p.pod);
}
#define SPA_POD_STRING_INIT(len) (struct spa_pod_string){ { len, SPA_TYPE_String } }
#define SPA_POD_Stringv(str) \
(struct spa_pod_collect) \
{ { 0, SPA_TYPE_Collect }, { strlen(str)+1, SPA_TYPE_String }, str }
#define SPA_POD_String(str, len) \
(struct spa_pod_collect) \
{ { 0, SPA_TYPE_Collect }, { len, SPA_TYPE_String }, str }
#define SPA_POD_Stringc(str) \
(struct { struct spa_pod_string pod; char val[sizeof(str)]; }) \
{ { { sizeof(str), SPA_TYPE_String } }, { str } }
static inline uint32_t
spa_pod_builder_write_string(struct spa_pod_builder *builder, const char *str, uint32_t len)
@ -252,7 +294,7 @@ spa_pod_builder_write_string(struct spa_pod_builder *builder, const char *str, u
static inline uint32_t
spa_pod_builder_string_len(struct spa_pod_builder *builder, const char *str, uint32_t len)
{
const struct spa_pod_string p = SPA_POD_STRING_INIT(len+1);
const struct spa_pod_string p = { { len + 1, SPA_TYPE_String } };
uint32_t ref = spa_pod_builder_raw(builder, &p, sizeof(p));
if (spa_pod_builder_write_string(builder, str, len) == SPA_ID_INVALID)
ref = SPA_ID_INVALID;
@ -265,50 +307,50 @@ static inline uint32_t spa_pod_builder_string(struct spa_pod_builder *builder, c
return spa_pod_builder_string_len(builder, str ? str : "", len);
}
#define SPA_POD_BYTES_INIT(len) (struct spa_pod_bytes){ { len, SPA_TYPE_Bytes } }
#define SPA_POD_Bytes(len) (struct spa_pod_bytes){ { len, SPA_TYPE_Bytes } }
static inline uint32_t
spa_pod_builder_bytes(struct spa_pod_builder *builder, const void *bytes, uint32_t len)
{
const struct spa_pod_bytes p = SPA_POD_BYTES_INIT(len);
const struct spa_pod_bytes p = SPA_POD_Bytes(len);
uint32_t ref = spa_pod_builder_raw(builder, &p, sizeof(p));
if (spa_pod_builder_raw_padded(builder, bytes, len) == SPA_ID_INVALID)
ref = SPA_ID_INVALID;
return ref;
}
#define SPA_POD_POINTER_INIT(type,value) (struct spa_pod_pointer){ { sizeof(struct spa_pod_pointer_body), SPA_TYPE_Pointer }, { type, value } }
#define SPA_POD_Pointer(type,value) (struct spa_pod_pointer){ { sizeof(struct spa_pod_pointer_body), SPA_TYPE_Pointer }, { type, value } }
static inline uint32_t
spa_pod_builder_pointer(struct spa_pod_builder *builder, uint32_t type, void *val)
{
const struct spa_pod_pointer p = SPA_POD_POINTER_INIT(type, val);
const struct spa_pod_pointer p = SPA_POD_Pointer(type, val);
return spa_pod_builder_primitive(builder, &p.pod);
}
#define SPA_POD_FD_INIT(fd) (struct spa_pod_fd){ { sizeof(int), SPA_TYPE_Fd }, fd }
#define SPA_POD_Fd(fd) (struct spa_pod_fd){ { sizeof(int), SPA_TYPE_Fd }, fd }
static inline uint32_t spa_pod_builder_fd(struct spa_pod_builder *builder, int fd)
{
const struct spa_pod_fd p = SPA_POD_FD_INIT(fd);
const struct spa_pod_fd p = SPA_POD_Fd(fd);
return spa_pod_builder_primitive(builder, &p.pod);
}
#define SPA_POD_RECTANGLE_INIT(width,height) (struct spa_pod_rectangle){ { sizeof(struct spa_rectangle), SPA_TYPE_Rectangle }, { width, height } }
#define SPA_POD_Rectangle(val) (struct spa_pod_rectangle){ { sizeof(struct spa_rectangle), SPA_TYPE_Rectangle }, val }
static inline uint32_t
spa_pod_builder_rectangle(struct spa_pod_builder *builder, uint32_t width, uint32_t height)
{
const struct spa_pod_rectangle p = SPA_POD_RECTANGLE_INIT(width, height);
const struct spa_pod_rectangle p = SPA_POD_Rectangle(SPA_RECTANGLE(width, height));
return spa_pod_builder_primitive(builder, &p.pod);
}
#define SPA_POD_FRACTION_INIT(num,denom) (struct spa_pod_fraction){ { sizeof(struct spa_fraction), SPA_TYPE_Fraction }, { num, denom } }
#define SPA_POD_Fraction(val) (struct spa_pod_fraction){ { sizeof(struct spa_fraction), SPA_TYPE_Fraction }, val }
static inline uint32_t
spa_pod_builder_fraction(struct spa_pod_builder *builder, uint32_t num, uint32_t denom)
{
const struct spa_pod_fraction p = SPA_POD_FRACTION_INIT(num, denom);
const struct spa_pod_fraction p = SPA_POD_Fraction(SPA_FRACTION(num, denom));
return spa_pod_builder_primitive(builder, &p.pod);
}
@ -337,48 +379,64 @@ spa_pod_builder_array(struct spa_pod_builder *builder,
return ref;
}
#define SPA_POD_STRUCT_INIT(size) (struct spa_pod_struct){ { size, SPA_TYPE_Struct } }
#define SPA_POD_CHOICE_BODY_INIT(type, flags, child_size, child_type) \
(struct spa_pod_choice_body) { type, flags, { child_size, child_type }}
#define SPA_POD_Choice(type, ctype, child_type, n_vals, ...) \
(struct { struct spa_pod_choice choice; ctype vals[n_vals];}) \
{ { { n_vals * sizeof(ctype) + sizeof(struct spa_pod_choice_body), SPA_TYPE_Choice }, \
{ type, 0, { sizeof(ctype), child_type } } }, { __VA_ARGS__ } }
static inline uint32_t
spa_pod_builder_push_struct(struct spa_pod_builder *builder)
spa_pod_builder_push_choice(struct spa_pod_builder *builder, uint32_t type, uint32_t flags)
{
const struct spa_pod_struct p = SPA_POD_STRUCT_INIT(0);
return spa_pod_builder_push(builder, &p.pod,
spa_pod_builder_raw(builder, &p, sizeof(p)));
}
#define SPA_POD_OBJECT_INIT(size,type,id,...) (struct spa_pod_object){ { size, SPA_TYPE_Object }, { type, id }, ##__VA_ARGS__ }
static inline uint32_t
spa_pod_builder_push_object(struct spa_pod_builder *builder, uint32_t type, uint32_t id)
{
const struct spa_pod_object p =
SPA_POD_OBJECT_INIT(sizeof(struct spa_pod_object_body), type, id);
return spa_pod_builder_push(builder, &p.pod,
spa_pod_builder_raw(builder, &p, sizeof(p)));
}
#define SPA_POD_PROP_INIT(size,key,flags,val_size,val_type) \
(struct spa_pod_prop){ { size, SPA_TYPE_Prop}, {key, flags, { val_size, val_type } } }
static inline uint32_t
spa_pod_builder_push_prop(struct spa_pod_builder *builder, uint32_t key, uint32_t flags)
{
const struct spa_pod_prop p = SPA_POD_PROP_INIT (sizeof(struct spa_pod_prop_body) -
sizeof(struct spa_pod), key, flags, 0, 0);
const struct spa_pod_choice p =
{ {sizeof(struct spa_pod_choice_body) - sizeof(struct spa_pod), SPA_TYPE_Choice},
{ type, flags, {0, 0}} };
return spa_pod_builder_push(builder, &p.pod,
spa_pod_builder_raw(builder, &p,
sizeof(p) - sizeof(struct spa_pod)));
}
#define SPA_POD_SEQUENCE_INIT(size,unit,...) \
#define SPA_POD_Struct(size) (struct spa_pod_struct){ { size, SPA_TYPE_Struct } }
static inline uint32_t
spa_pod_builder_push_struct(struct spa_pod_builder *builder)
{
const struct spa_pod_struct p = SPA_POD_Struct(0);
return spa_pod_builder_push(builder, &p.pod,
spa_pod_builder_raw(builder, &p, sizeof(p)));
}
#define SPA_POD_Object(size,type,id,...) (struct spa_pod_object){ { size, SPA_TYPE_Object }, { type, id }, ##__VA_ARGS__ }
static inline uint32_t
spa_pod_builder_push_object(struct spa_pod_builder *builder, uint32_t type, uint32_t id)
{
const struct spa_pod_object p =
SPA_POD_Object(sizeof(struct spa_pod_object_body), type, id);
return spa_pod_builder_push(builder, &p.pod,
spa_pod_builder_raw(builder, &p, sizeof(p)));
}
#define SPA_POD_Prop(key,flags,size,type) \
(struct spa_pod_prop){ key, flags, { size, type } }
static inline uint32_t
spa_pod_builder_prop(struct spa_pod_builder *builder, uint32_t key, uint32_t flags)
{
const struct { uint32_t key; uint32_t flags; } p = { key, flags };
return spa_pod_builder_raw(builder, &p, sizeof(p));
}
#define SPA_POD_Sequence(size,unit,...) \
(struct spa_pod_sequence){ { size, SPA_TYPE_Sequence}, {unit, 0 }, ##__VA_ARGS__ }
static inline uint32_t
spa_pod_builder_push_sequence(struct spa_pod_builder *builder, uint32_t unit)
{
const struct spa_pod_sequence p =
SPA_POD_SEQUENCE_INIT(sizeof(struct spa_pod_sequence_body), unit);
SPA_POD_Sequence(sizeof(struct spa_pod_sequence_body), unit);
return spa_pod_builder_push(builder, &p.pod,
spa_pod_builder_raw(builder, &p, sizeof(p)));
}
@ -390,27 +448,26 @@ spa_pod_builder_control_header(struct spa_pod_builder *builder, uint32_t offset,
return spa_pod_builder_raw(builder, &p, sizeof(p));
}
static inline uint32_t spa_pod_range_from_id(char id)
static inline uint32_t spa_choice_from_id(char id)
{
switch (id) {
case 'r':
return SPA_POD_PROP_RANGE_MIN_MAX;
return SPA_CHOICE_Range;
case 's':
return SPA_POD_PROP_RANGE_STEP;
return SPA_CHOICE_Step;
case 'e':
return SPA_POD_PROP_RANGE_ENUM;
return SPA_CHOICE_Enum;
case 'f':
return SPA_POD_PROP_RANGE_FLAGS;
return SPA_CHOICE_Flags;
case 'n':
default:
return SPA_POD_PROP_RANGE_NONE;
return SPA_CHOICE_None;
}
}
static inline uint32_t spa_pod_flag_from_id(char id)
{
switch (id) {
case 'u':
return SPA_POD_PROP_FLAG_UNSET;
case 'o':
return SPA_POD_PROP_FLAG_OPTIONAL;
case 'r':
@ -433,7 +490,7 @@ do { \
spa_pod_builder_bool(builder, va_arg(args, int)); \
break; \
case 'I': \
spa_pod_builder_enum(builder, va_arg(args, uint32_t)); \
spa_pod_builder_id(builder, va_arg(args, uint32_t)); \
break; \
case 'i': \
spa_pod_builder_int(builder, va_arg(args, int)); \
@ -523,9 +580,9 @@ spa_pod_builder_addv(struct spa_pod_builder *builder,
const char *format, va_list args)
{
while (format) {
char t = *format;
next:
switch (t) {
int n_values = 1;
bool do_pop = false;
switch (*format) {
case '{':
{
uint32_t type = va_arg(args, uint32_t);
@ -552,46 +609,34 @@ spa_pod_builder_addv(struct spa_pod_builder *builder,
spa_pod_builder_control_header(builder, offset, type);
break;
}
case '?':
{
uint32_t choice, flags = 0;
format++;
choice = spa_choice_from_id(*format);
if (*format != '\0')
format++;
spa_pod_builder_push_choice(builder, choice, flags);
n_values = va_arg(args, int);
do_pop = true;
goto do_collect;
}
case ':':
{
int n_values;
uint32_t key, flags;
uint32_t key, flags = 0;
key = va_arg(args, uint32_t);
format = va_arg(args, const char *);
t = *format;
if (*format != '\0')
format++;
flags = spa_pod_range_from_id(*format);
if (*format != '\0')
format++;
for (;*format;format++)
for (format++;*format;format++)
SPA_FLAG_SET(flags, spa_pod_flag_from_id(*format));
spa_pod_builder_push_prop(builder, key, flags);
if (t == '{' || t == '[' || t == '<')
goto next;
n_values = -1;
while (n_values-- != 0) {
SPA_POD_BUILDER_COLLECT(builder, t, args);
if ((flags & SPA_POD_PROP_RANGE_MASK) == 0)
break;
if (n_values == -2)
n_values = va_arg(args, int);
}
spa_pod_builder_pop(builder);
/* don't advance format */
continue;
spa_pod_builder_prop(builder, key, flags);
break;
}
case ']': case ')': case '>': case '}':
spa_pod_builder_pop(builder);
if (builder->state.depth > 0 &&
builder->frame[builder->state.depth-1].pod.type == SPA_TYPE_Prop)
spa_pod_builder_pop(builder);
break;
case ' ': case '\n': case '\t': case '\r':
break;
@ -599,13 +644,17 @@ spa_pod_builder_addv(struct spa_pod_builder *builder,
format = va_arg(args, const char *);
continue;
default:
SPA_POD_BUILDER_COLLECT(builder, t, args);
do_collect:
while (n_values-- > 0)
SPA_POD_BUILDER_COLLECT(builder, *format, args);
if (do_pop)
spa_pod_builder_pop(builder);
break;;
}
if (*format != '\0')
format++;
}
return spa_pod_builder_deref(builder, builder->frame[builder->state.depth].ref);
return spa_pod_builder_deref_checked(builder, builder->frame[builder->state.depth].ref,true);
}
static inline void *spa_pod_builder_add(struct spa_pod_builder *builder, const char *format, ...)
@ -620,13 +669,44 @@ static inline void *spa_pod_builder_add(struct spa_pod_builder *builder, const c
return res;
}
static inline void spa_pod_builder_propsv(struct spa_pod_builder *builder,
uint32_t key, va_list args)
{
while (key) {
spa_pod_builder_prop(builder, key, 0);
spa_pod_builder_primitive(builder, va_arg(args, struct spa_pod *));
key = va_arg(args, uint32_t);
}
}
static inline void spa_pod_builder_props(struct spa_pod_builder *builder, uint32_t key, ...)
{
va_list args;
va_start(args, key);
spa_pod_builder_propsv(builder, key, args);
va_end(args);
}
static inline void *spa_pod_builder_object(struct spa_pod_builder *builder,
uint32_t type, uint32_t id, uint32_t key, ...)
{
va_list args;
spa_pod_builder_push_object(builder, type, id);
va_start(args, key);
spa_pod_builder_propsv(builder, key, args);
va_end(args);
return spa_pod_builder_pop(builder);
}
#define SPA_POD_OBJECT(type,id,...) \
"{", type, id, ##__VA_ARGS__, "}"
#define SPA_POD_STRUCT(...) \
"[", ##__VA_ARGS__, "]"
#define SPA_POD_PROP(key,spec,type,value,...) \
#define SPA_POD_PROP(key,spec,value,...) \
":", key, spec, value, ##__VA_ARGS__
#define SPA_POD_SEQUENCE(unit,...) \
@ -635,19 +715,73 @@ static inline void *spa_pod_builder_add(struct spa_pod_builder *builder, const c
#define SPA_POD_CONTROL(offset,type,...) \
".", offset, type, ##__VA_ARGS__
#define SPA_POD_PROP_MIN_MAX(min,max) 2,(min),(max)
#define SPA_POD_PROP_STEP(min,max,step) 3,(min),(max),(step)
#define SPA_POD_PROP_ENUM(n_vals,...) (n_vals),__VA_ARGS__
#define spa_pod_builder_object(b,type,id,...) \
#define spa_pod_builder_add_object(b,type,id,...) \
spa_pod_builder_add(b, SPA_POD_OBJECT(type,id,##__VA_ARGS__), NULL)
#define spa_pod_builder_struct(b,...) \
#define spa_pod_builder_add_struct(b,...) \
spa_pod_builder_add(b, SPA_POD_STRUCT(__VA_ARGS__), NULL)
#define spa_pod_builder_sequence(b,unit,...) \
#define spa_pod_builder_add_sequence(b,unit,...) \
spa_pod_builder_add(b, SPA_POD_SEQUENCE(unit,__VA_ARGS__), NULL)
#define SPA_CHOICE_RANGE(def,min,max) 3,(def),(min),(max)
#define SPA_CHOICE_STEP(def,min,max,step) 4,(def),(min),(max),(step)
#define SPA_CHOICE_ENUM(n_vals,...) (n_vals),__VA_ARGS__
#define SPA_CHOICE_BOOL(def) 3,(def),(def),!(def)
#define SPA_POD_CHOICE_Bool(def) \
SPA_POD_Choice(SPA_CHOICE_Enum, int32_t, SPA_TYPE_Bool, 3, (def), (def), !(def))
#define SPA_POD_CHOICE_Int(type, n_vals, ...) \
SPA_POD_Choice(type, uint32_t, SPA_TYPE_Int, n_vals, __VA_ARGS__)
#define SPA_POD_CHOICE_ENUM_Int(n_vals, ...) \
SPA_POD_CHOICE_Int(SPA_CHOICE_Enum, SPA_CHOICE_ENUM(n_vals, __VA_ARGS__))
#define SPA_POD_CHOICE_RANGE_Int(def, min, max) \
SPA_POD_CHOICE_Int(SPA_CHOICE_Range, SPA_CHOICE_RANGE(def, min, max))
#define SPA_POD_CHOICE_STEP_Int(def, min, max, step) \
SPA_POD_CHOICE_Int(SPA_CHOICE_Step, SPA_CHOICE_STEP(def, min, max, step))
#define SPA_POD_CHOICE_Id(type, n_vals, ...) \
SPA_POD_Choice(type, uint32_t, SPA_TYPE_Id, n_vals, __VA_ARGS__)
#define SPA_POD_CHOICE_ENUM_Id(n_vals, ...) \
SPA_POD_CHOICE_Id(SPA_CHOICE_Enum, n_vals, __VA_ARGS__)
#define SPA_POD_CHOICE_Float(type, n_vals, ...) \
SPA_POD_Choice(type, float, SPA_TYPE_Float, n_vals, __VA_ARGS__)
#define SPA_POD_CHOICE_ENUM_Float(n_vals, ...) \
SPA_POD_CHOICE_Float(SPA_CHOICE_Enum, n_vals, __VA_ARGS__)
#define SPA_POD_CHOICE_RANGE_Float(def, min, max) \
SPA_POD_CHOICE_Float(SPA_CHOICE_Range, 3, (def), (min), (max))
#define SPA_POD_CHOICE_STEP_Float(def, min, max, step) \
SPA_POD_CHOICE_Float(SPA_CHOICE_Step, 4, (def), (min), (max), (step))
#define SPA_POD_CHOICE_Double(type, n_vals, ...) \
SPA_POD_Choice(type, double, SPA_TYPE_Double, n_vals, __VA_ARGS__)
#define SPA_POD_CHOICE_ENUM_Double(n_vals, ...) \
SPA_POD_CHOICE_Double(SPA_CHOICE_Enum, n_vals, __VA_ARGS__)
#define SPA_POD_CHOICE_RANGE_Double(def, min, max) \
SPA_POD_CHOICE_Double(SPA_CHOICE_Range, 3, (def), (min), (max))
#define SPA_POD_CHOICE_STEP_Double(def, min, max, step) \
SPA_POD_CHOICE_Double(SPA_CHOICE_Step, 4, (def), (min), (max), (step))
#define SPA_POD_CHOICE_Rectangle(type, n_vals, ...) \
SPA_POD_Choice(type, struct spa_rectangle, SPA_TYPE_Rectangle, n_vals, __VA_ARGS__)
#define SPA_POD_CHOICE_ENUM_Rectangle(n_vals, ...) \
SPA_POD_CHOICE_Rectangle(SPA_CHOICE_Enum, n_vals, __VA_ARGS__)
#define SPA_POD_CHOICE_RANGE_Rectangle(def, min, max) \
SPA_POD_CHOICE_Rectangle(SPA_CHOICE_Range, 3, (def), (min), (max))
#define SPA_POD_CHOICE_STEP_Rectangle(def, min, max, step) \
SPA_POD_CHOICE_Rectangle(SPA_CHOICE_Step, 4, (def), (min), (max), (step))
#define SPA_POD_CHOICE_Fraction(type, n_vals, ...) \
SPA_POD_Choice(type, struct spa_fraction, SPA_TYPE_Fraction, n_vals, __VA_ARGS__)
#define SPA_POD_CHOICE_ENUM_Fraction(n_vals, ...) \
SPA_POD_CHOICE_Fraction(SPA_CHOICE_Enum, n_vals, __VA_ARGS__)
#define SPA_POD_CHOICE_RANGE_Fraction(def, min, max) \
SPA_POD_CHOICE_Fraction(SPA_CHOICE_Range, 3, (def), (min), (max))
#define SPA_POD_CHOICE_STEP_Fraction(def, min, max, step) \
SPA_POD_CHOICE_Fraction(SPA_CHOICE_Step, 4, (def), (min), (max), (step))
#ifdef __cplusplus
} /* extern "C" */
#endif