mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-09 13:30:06 -05:00
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:
parent
03fdabd155
commit
cc842cbdc8
63 changed files with 2253 additions and 1880 deletions
|
|
@ -37,7 +37,7 @@ spa_debug_format_value(const struct spa_type_info *info,
|
|||
case SPA_TYPE_Bool:
|
||||
fprintf(stderr, "%s", *(int32_t *) body ? "true" : "false");
|
||||
break;
|
||||
case SPA_TYPE_Enum:
|
||||
case SPA_TYPE_Id:
|
||||
{
|
||||
const char *str = spa_debug_type_find_name(info, *(int32_t *) body);
|
||||
char tmp[64];
|
||||
|
|
@ -85,6 +85,20 @@ spa_debug_format_value(const struct spa_type_info *info,
|
|||
case SPA_TYPE_Bytes:
|
||||
fprintf(stderr, "Bytes");
|
||||
break;
|
||||
case SPA_TYPE_Array:
|
||||
{
|
||||
void *p;
|
||||
struct spa_pod_array_body *b = body;
|
||||
int i = 0;
|
||||
fprintf(stderr, "< ");
|
||||
SPA_POD_ARRAY_BODY_FOREACH(b, size, p) {
|
||||
if (i++ > 0)
|
||||
fprintf(stderr, ", ");
|
||||
spa_debug_format_value(info, b->child.type, p, b->child.size);
|
||||
}
|
||||
fprintf(stderr, " >");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
fprintf(stderr, "INVALID type %d", type);
|
||||
break;
|
||||
|
|
@ -98,12 +112,12 @@ static inline int spa_debug_format(int indent,
|
|||
int i;
|
||||
const char *media_type;
|
||||
const char *media_subtype;
|
||||
struct spa_pod *pod;
|
||||
struct spa_pod_prop *prop;
|
||||
uint32_t mtype, mstype;
|
||||
const char *pod_type_names[] = {
|
||||
[SPA_TYPE_None] = "none",
|
||||
[SPA_TYPE_Bool] = "bool",
|
||||
[SPA_TYPE_Enum] = "enum",
|
||||
[SPA_TYPE_Id] = "id",
|
||||
[SPA_TYPE_Int] = "int",
|
||||
[SPA_TYPE_Long] = "long",
|
||||
[SPA_TYPE_Float] = "float",
|
||||
|
|
@ -118,7 +132,7 @@ static inline int spa_debug_format(int indent,
|
|||
[SPA_TYPE_Object] = "object",
|
||||
[SPA_TYPE_Pointer] = "pointer",
|
||||
[SPA_TYPE_Fd] = "fd",
|
||||
[SPA_TYPE_Prop] = "prop",
|
||||
[SPA_TYPE_Choice] = "choice",
|
||||
[SPA_TYPE_Pod] = "pod"
|
||||
};
|
||||
|
||||
|
|
@ -138,50 +152,45 @@ static inline int spa_debug_format(int indent,
|
|||
media_type ? rindex(media_type, ':') + 1 : "unknown",
|
||||
media_subtype ? rindex(media_subtype, ':') + 1 : "unknown");
|
||||
|
||||
SPA_POD_OBJECT_FOREACH((struct spa_pod_object*)format, pod) {
|
||||
struct spa_pod_prop *prop;
|
||||
SPA_POD_OBJECT_FOREACH((struct spa_pod_object*)format, prop) {
|
||||
const char *key;
|
||||
const struct spa_type_info *ti;
|
||||
uint32_t type, size, n_vals, choice;
|
||||
const struct spa_pod *val;
|
||||
void *vals;
|
||||
|
||||
if (pod->type != SPA_TYPE_Prop)
|
||||
if (prop->key == SPA_FORMAT_mediaType ||
|
||||
prop->key == SPA_FORMAT_mediaSubtype)
|
||||
continue;
|
||||
|
||||
prop = (struct spa_pod_prop *)pod;
|
||||
val = spa_pod_get_values(&prop->value, &n_vals, &choice);
|
||||
|
||||
if ((prop->body.flags & SPA_POD_PROP_FLAG_UNSET) &&
|
||||
(prop->body.flags & SPA_POD_PROP_FLAG_OPTIONAL))
|
||||
continue;
|
||||
type = val->type;
|
||||
size = val->size;
|
||||
vals = SPA_POD_BODY(val);
|
||||
|
||||
if (prop->body.key == SPA_FORMAT_mediaType ||
|
||||
prop->body.key == SPA_FORMAT_mediaSubtype)
|
||||
continue;
|
||||
|
||||
ti = spa_debug_type_find(info, prop->body.key);
|
||||
ti = spa_debug_type_find(info, prop->key);
|
||||
key = ti ? ti->name : NULL;
|
||||
|
||||
fprintf(stderr, "%*s %16s : (%s) ", indent, "",
|
||||
key ? rindex(key, ':') + 1 : "unknown",
|
||||
pod_type_names[prop->body.value.type]);
|
||||
pod_type_names[type]);
|
||||
|
||||
if (!(prop->body.flags & SPA_POD_PROP_FLAG_UNSET)) {
|
||||
spa_debug_format_value(ti->values,
|
||||
prop->body.value.type,
|
||||
SPA_POD_BODY(&prop->body.value),
|
||||
prop->body.value.size);
|
||||
if (choice == SPA_CHOICE_None) {
|
||||
spa_debug_format_value(ti->values, type, vals, size);
|
||||
} else {
|
||||
const char *ssep, *esep, *sep;
|
||||
void *alt;
|
||||
|
||||
switch (prop->body.flags & SPA_POD_PROP_RANGE_MASK) {
|
||||
case SPA_POD_PROP_RANGE_MIN_MAX:
|
||||
case SPA_POD_PROP_RANGE_STEP:
|
||||
switch (choice) {
|
||||
case SPA_CHOICE_Range:
|
||||
case SPA_CHOICE_Step:
|
||||
ssep = "[ ";
|
||||
sep = ", ";
|
||||
esep = " ]";
|
||||
break;
|
||||
default:
|
||||
case SPA_POD_PROP_RANGE_ENUM:
|
||||
case SPA_POD_PROP_RANGE_FLAGS:
|
||||
case SPA_CHOICE_Enum:
|
||||
case SPA_CHOICE_Flags:
|
||||
ssep = "{ ";
|
||||
sep = ", ";
|
||||
esep = " }";
|
||||
|
|
@ -190,15 +199,11 @@ static inline int spa_debug_format(int indent,
|
|||
|
||||
fprintf(stderr, "%s", ssep);
|
||||
|
||||
i = 0;
|
||||
SPA_POD_PROP_ALTERNATIVE_FOREACH(&prop->body, prop->pod.size, alt) {
|
||||
if (i > 0)
|
||||
for (i = 1; i < n_vals; i++) {
|
||||
vals = SPA_MEMBER(vals, size, void);
|
||||
if (i > 1)
|
||||
fprintf(stderr, "%s", sep);
|
||||
spa_debug_format_value(ti->values,
|
||||
prop->body.value.type,
|
||||
alt,
|
||||
prop->body.value.size);
|
||||
i++;
|
||||
spa_debug_format_value(ti->values, type, vals, size);
|
||||
}
|
||||
fprintf(stderr, "%s", esep);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,73 @@ extern "C" {
|
|||
#define spa_debug(...) ({ fprintf(stderr, __VA_ARGS__);fputc('\n', stderr); })
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
static inline int
|
||||
spa_debug_pod_prop(int indent, const struct spa_type_info *info, struct spa_pod_prop *prop)
|
||||
{
|
||||
void *alt;
|
||||
int i;
|
||||
const struct spa_type_info *ti = spa_debug_type_find(info, prop->key);
|
||||
|
||||
spa_debug("%*s" "Prop: key %s, flags %d", indent, "",
|
||||
ti ? ti->name : "unknown", prop->flags);
|
||||
|
||||
info = ti ? ti->values : info;
|
||||
|
||||
if (prop->flags & SPA_POD_PROP_FLAG_UNSET)
|
||||
spa_debug("%*s" "Unset (Default):", indent + 2, "");
|
||||
else
|
||||
spa_debug("%*s" "Value: size %u", indent + 2, "", prop->value.size);
|
||||
|
||||
spa_debug_pod_value(indent + 4, info, prop->value.type, SPA_POD_BODY(&prop->value),
|
||||
prop->value.size);
|
||||
|
||||
i = 0;
|
||||
switch (prop->flags & SPA_POD_PROP_RANGE_MASK) {
|
||||
case SPA_POD_PROP_RANGE_NONE:
|
||||
break;
|
||||
case SPA_POD_PROP_RANGE_MIN_MAX:
|
||||
SPA_POD_PROP_ALTERNATIVE_FOREACH(b, size, alt) {
|
||||
if (i == 0)
|
||||
spa_debug("%*s" "Min: ", indent + 2, "");
|
||||
else if (i == 1)
|
||||
spa_debug("%*s" "Max: ", indent + 2, "");
|
||||
else
|
||||
break;
|
||||
spa_debug_pod_value(indent + 4, info, prop->value.type, alt, prop->value.size);
|
||||
i++;
|
||||
}
|
||||
break;
|
||||
case SPA_POD_PROP_RANGE_STEP:
|
||||
SPA_POD_PROP_ALTERNATIVE_FOREACH(b, size, alt) {
|
||||
if (i == 0)
|
||||
spa_debug("%*s" "Min: ", indent + 2, "");
|
||||
else if (i == 1)
|
||||
spa_debug("%*s" "Max: ", indent + 2, "");
|
||||
else if (i == 2)
|
||||
spa_debug("%*s" "Step: ", indent + 2, "");
|
||||
else
|
||||
break;
|
||||
spa_debug_pod_value(indent + 4, info, prop->value.type, alt, prop->value.size);
|
||||
i++;
|
||||
}
|
||||
break;
|
||||
case SPA_POD_PROP_RANGE_ENUM:
|
||||
SPA_POD_PROP_ALTERNATIVE_FOREACH(b, size, alt) {
|
||||
if (i == 0) {
|
||||
spa_debug("%*s" "Enum:", indent + 2, "");
|
||||
}
|
||||
spa_debug_pod_value(indent + 4, info, prop->value.type, alt, prop->value.size);
|
||||
i++;
|
||||
}
|
||||
break;
|
||||
case SPA_POD_PROP_RANGE_FLAGS:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline int
|
||||
spa_debug_pod_value(int indent, const struct spa_type_info *info,
|
||||
uint32_t type, void *body, uint32_t size)
|
||||
|
|
@ -41,8 +108,8 @@ spa_debug_pod_value(int indent, const struct spa_type_info *info,
|
|||
case SPA_TYPE_Bool:
|
||||
spa_debug("%*s" "Bool %d", indent, "", *(int32_t *) body);
|
||||
break;
|
||||
case SPA_TYPE_Enum:
|
||||
spa_debug("%*s" "Enum %d (%s)", indent, "", *(int32_t *) body,
|
||||
case SPA_TYPE_Id:
|
||||
spa_debug("%*s" "Id %d (%s)", indent, "", *(int32_t *) body,
|
||||
spa_debug_type_find_name(info, *(int32_t *) body));
|
||||
break;
|
||||
case SPA_TYPE_Int:
|
||||
|
|
@ -89,17 +156,28 @@ spa_debug_pod_value(int indent, const struct spa_type_info *info,
|
|||
{
|
||||
struct spa_pod_array_body *b = body;
|
||||
void *p;
|
||||
const struct spa_type_info *ti = spa_debug_type_find(info, b->child.type);
|
||||
const struct spa_type_info *ti = spa_debug_type_find(SPA_TYPE_ROOT, b->child.type);
|
||||
|
||||
spa_debug("%*s" "Array: child.size %d, child.type %s", indent, "",
|
||||
b->child.size, ti ? ti->name : "unknown");
|
||||
|
||||
info = ti ? ti->values : info;
|
||||
|
||||
SPA_POD_ARRAY_BODY_FOREACH(b, size, p)
|
||||
spa_debug_pod_value(indent + 2, info, b->child.type, p, b->child.size);
|
||||
break;
|
||||
}
|
||||
case SPA_TYPE_Choice:
|
||||
{
|
||||
struct spa_pod_choice_body *b = body;
|
||||
void *p;
|
||||
const struct spa_type_info *ti = spa_debug_type_find(spa_type_choice, b->type);
|
||||
|
||||
spa_debug("%*s" "Choice: type %s, flags %08x %d %d", indent, "",
|
||||
ti ? ti->name : "unknown", b->flags, size, b->child.size);
|
||||
|
||||
SPA_POD_CHOICE_BODY_FOREACH(b, size, p)
|
||||
spa_debug_pod_value(indent + 2, info, b->child.type, p, b->child.size);
|
||||
break;
|
||||
}
|
||||
case SPA_TYPE_Struct:
|
||||
{
|
||||
struct spa_pod *b = body, *p;
|
||||
|
|
@ -111,7 +189,7 @@ spa_debug_pod_value(int indent, const struct spa_type_info *info,
|
|||
case SPA_TYPE_Object:
|
||||
{
|
||||
struct spa_pod_object_body *b = body;
|
||||
struct spa_pod *p;
|
||||
struct spa_pod_prop *p;
|
||||
const struct spa_type_info *ti, *ii;
|
||||
|
||||
ti = spa_debug_type_find(info, b->type);
|
||||
|
|
@ -123,9 +201,17 @@ spa_debug_pod_value(int indent, const struct spa_type_info *info,
|
|||
|
||||
info = ti ? ti->values : info;
|
||||
|
||||
SPA_POD_OBJECT_BODY_FOREACH(b, size, p)
|
||||
spa_debug_pod_value(indent + 2, info,
|
||||
p->type, SPA_POD_BODY(p), p->size);
|
||||
SPA_POD_OBJECT_BODY_FOREACH(b, size, p) {
|
||||
ii = spa_debug_type_find(info, p->key);
|
||||
|
||||
spa_debug("%*s" "Prop: key %s, flags %08x", indent+2, "",
|
||||
ii ? ii->name : "unknown", p->flags);
|
||||
|
||||
spa_debug_pod_value(indent + 4, ii->values,
|
||||
p->value.type,
|
||||
SPA_POD_CONTENTS(struct spa_pod_prop, p),
|
||||
p->value.size);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SPA_TYPE_Sequence:
|
||||
|
|
@ -145,77 +231,13 @@ spa_debug_pod_value(int indent, const struct spa_type_info *info,
|
|||
spa_debug("%*s" "Control: offset %d, type %s", indent+2, "",
|
||||
c->offset, ii ? ii->name : "unknown");
|
||||
|
||||
spa_debug_pod_value(indent + 2, info,
|
||||
spa_debug_pod_value(indent + 4, ii->values,
|
||||
c->value.type,
|
||||
SPA_POD_CONTENTS(struct spa_pod_control, c),
|
||||
c->value.size);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SPA_TYPE_Prop:
|
||||
{
|
||||
struct spa_pod_prop_body *b = body;
|
||||
void *alt;
|
||||
int i;
|
||||
const struct spa_type_info *ti = spa_debug_type_find(info, b->key);
|
||||
|
||||
spa_debug("%*s" "Prop: key %s, flags %d", indent, "",
|
||||
ti ? ti->name : "unknown", b->flags);
|
||||
|
||||
info = ti ? ti->values : info;
|
||||
|
||||
if (b->flags & SPA_POD_PROP_FLAG_UNSET)
|
||||
spa_debug("%*s" "Unset (Default):", indent + 2, "");
|
||||
else
|
||||
spa_debug("%*s" "Value: size %u", indent + 2, "", b->value.size);
|
||||
|
||||
spa_debug_pod_value(indent + 4, info, b->value.type, SPA_POD_BODY(&b->value),
|
||||
b->value.size);
|
||||
|
||||
i = 0;
|
||||
switch (b->flags & SPA_POD_PROP_RANGE_MASK) {
|
||||
case SPA_POD_PROP_RANGE_NONE:
|
||||
break;
|
||||
case SPA_POD_PROP_RANGE_MIN_MAX:
|
||||
SPA_POD_PROP_ALTERNATIVE_FOREACH(b, size, alt) {
|
||||
if (i == 0)
|
||||
spa_debug("%*s" "Min: ", indent + 2, "");
|
||||
else if (i == 1)
|
||||
spa_debug("%*s" "Max: ", indent + 2, "");
|
||||
else
|
||||
break;
|
||||
spa_debug_pod_value(indent + 4, info, b->value.type, alt, b->value.size);
|
||||
i++;
|
||||
}
|
||||
break;
|
||||
case SPA_POD_PROP_RANGE_STEP:
|
||||
SPA_POD_PROP_ALTERNATIVE_FOREACH(b, size, alt) {
|
||||
if (i == 0)
|
||||
spa_debug("%*s" "Min: ", indent + 2, "");
|
||||
else if (i == 1)
|
||||
spa_debug("%*s" "Max: ", indent + 2, "");
|
||||
else if (i == 2)
|
||||
spa_debug("%*s" "Step: ", indent + 2, "");
|
||||
else
|
||||
break;
|
||||
spa_debug_pod_value(indent + 4, info, b->value.type, alt, b->value.size);
|
||||
i++;
|
||||
}
|
||||
break;
|
||||
case SPA_POD_PROP_RANGE_ENUM:
|
||||
SPA_POD_PROP_ALTERNATIVE_FOREACH(b, size, alt) {
|
||||
if (i == 0) {
|
||||
spa_debug("%*s" "Enum:", indent + 2, "");
|
||||
}
|
||||
spa_debug_pod_value(indent + 4, info, b->value.type, alt, b->value.size);
|
||||
i++;
|
||||
}
|
||||
break;
|
||||
case SPA_POD_PROP_RANGE_FLAGS:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SPA_TYPE_Bytes:
|
||||
spa_debug("%*s" "Bytes", indent, "");
|
||||
spa_debug_mem(indent + 2, body, size);
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ static const struct spa_type_info spa_type_monitor_event_id[] = {
|
|||
};
|
||||
|
||||
static const struct spa_type_info spa_type_monitor_event[] = {
|
||||
{ 0, SPA_TYPE_MONITOR_EVENT_BASE, SPA_TYPE_Enum, spa_type_monitor_event_id },
|
||||
{ 0, SPA_TYPE_MONITOR_EVENT_BASE, SPA_TYPE_Id, spa_type_monitor_event_id },
|
||||
{ 0, NULL, },
|
||||
};
|
||||
|
||||
|
|
@ -66,9 +66,9 @@ static const struct spa_type_info spa_type_monitor_item_state[] = {
|
|||
static const struct spa_type_info spa_type_monitor_item[] = {
|
||||
{ SPA_MONITOR_ITEM_START, SPA_TYPE_MONITOR_ITEM_BASE, SPA_TYPE_Int, },
|
||||
{ SPA_MONITOR_ITEM_id, SPA_TYPE_MONITOR_ITEM_BASE "id", SPA_TYPE_String, },
|
||||
{ SPA_MONITOR_ITEM_flags, SPA_TYPE_MONITOR_ITEM_BASE "flags", SPA_TYPE_Enum,
|
||||
{ SPA_MONITOR_ITEM_flags, SPA_TYPE_MONITOR_ITEM_BASE "flags", SPA_TYPE_Id,
|
||||
spa_type_monitor_item_flags },
|
||||
{ SPA_MONITOR_ITEM_state, SPA_TYPE_MONITOR_ITEM_BASE "state", SPA_TYPE_Enum,
|
||||
{ SPA_MONITOR_ITEM_state, SPA_TYPE_MONITOR_ITEM_BASE "state", SPA_TYPE_Id,
|
||||
spa_type_monitor_item_state },
|
||||
{ SPA_MONITOR_ITEM_name, SPA_TYPE_MONITOR_ITEM_BASE "name", SPA_TYPE_String, },
|
||||
{ SPA_MONITOR_ITEM_class, SPA_TYPE_MONITOR_ITEM_BASE "class", SPA_TYPE_String, },
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ static const struct spa_type_info spa_type_node_event_id[] = {
|
|||
};
|
||||
|
||||
static const struct spa_type_info spa_type_node_event[] = {
|
||||
{ 0, SPA_TYPE_NODE_EVENT_BASE, SPA_TYPE_Enum, spa_type_node_event_id },
|
||||
{ 0, SPA_TYPE_NODE_EVENT_BASE, SPA_TYPE_Id, spa_type_node_event_id },
|
||||
{ 0, NULL, },
|
||||
};
|
||||
|
||||
|
|
@ -75,7 +75,7 @@ static const struct spa_type_info spa_type_node_command_id[] = {
|
|||
};
|
||||
|
||||
static const struct spa_type_info spa_type_node_command[] = {
|
||||
{ 0, SPA_TYPE_NODE_COMMAND_BASE, SPA_TYPE_Enum, spa_type_node_command_id },
|
||||
{ 0, SPA_TYPE_NODE_COMMAND_BASE, SPA_TYPE_Id, spa_type_node_command_id },
|
||||
{ 0, NULL, },
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -47,12 +47,13 @@ spa_format_audio_raw_build(struct spa_pod_builder *builder, uint32_t id, struct
|
|||
{
|
||||
return spa_pod_builder_object(builder,
|
||||
SPA_TYPE_OBJECT_Format, id,
|
||||
":", SPA_FORMAT_mediaType, "I", SPA_MEDIA_TYPE_audio,
|
||||
":", SPA_FORMAT_mediaSubtype, "I", SPA_MEDIA_SUBTYPE_raw,
|
||||
":", SPA_FORMAT_AUDIO_format, "I", info->format,
|
||||
":", SPA_FORMAT_AUDIO_layout, "I", info->layout,
|
||||
":", SPA_FORMAT_AUDIO_rate, "i", info->rate,
|
||||
":", SPA_FORMAT_AUDIO_channels, "i", info->channels);
|
||||
SPA_FORMAT_mediaType, &SPA_POD_Id(SPA_MEDIA_TYPE_audio),
|
||||
SPA_FORMAT_mediaSubtype, &SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw),
|
||||
SPA_FORMAT_AUDIO_format, &SPA_POD_Id(info->format),
|
||||
SPA_FORMAT_AUDIO_layout, &SPA_POD_Id(info->layout),
|
||||
SPA_FORMAT_AUDIO_rate, &SPA_POD_Int(info->rate),
|
||||
SPA_FORMAT_AUDIO_channels, &SPA_POD_Int(info->channels),
|
||||
0);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
|
|
@ -56,8 +56,8 @@ static const struct spa_type_info spa_type_param[] = {
|
|||
#define SPA_TYPE_PARAM_LIST_BASE SPA_TYPE_PARAM__List ":"
|
||||
|
||||
static const struct spa_type_info spa_type_param_list[] = {
|
||||
{ SPA_PARAM_LIST_START, SPA_TYPE_PARAM_LIST_BASE, SPA_TYPE_Enum, spa_type_param },
|
||||
{ SPA_PARAM_LIST_id, SPA_TYPE_PARAM_LIST_BASE "id", SPA_TYPE_Enum, spa_type_param },
|
||||
{ SPA_PARAM_LIST_START, SPA_TYPE_PARAM_LIST_BASE, SPA_TYPE_Id, spa_type_param },
|
||||
{ SPA_PARAM_LIST_id, SPA_TYPE_PARAM_LIST_BASE "id", SPA_TYPE_Id, spa_type_param },
|
||||
{ 0, NULL, },
|
||||
};
|
||||
|
||||
|
|
@ -65,7 +65,7 @@ static const struct spa_type_info spa_type_param_list[] = {
|
|||
#define SPA_TYPE_PROPS_BASE SPA_TYPE__Props ":"
|
||||
|
||||
static const struct spa_type_info spa_type_props[] = {
|
||||
{ SPA_PROP_START, SPA_TYPE_PROPS_BASE, SPA_TYPE_Enum, spa_type_param, },
|
||||
{ SPA_PROP_START, SPA_TYPE_PROPS_BASE, SPA_TYPE_Id, spa_type_param, },
|
||||
{ SPA_PROP_unknown, SPA_TYPE_PROPS_BASE "unknown", SPA_TYPE_None, },
|
||||
{ SPA_PROP_device, SPA_TYPE_PROPS_BASE "device", SPA_TYPE_String, },
|
||||
{ SPA_PROP_deviceName, SPA_TYPE_PROPS_BASE "deviceName", SPA_TYPE_String, },
|
||||
|
|
@ -78,12 +78,12 @@ static const struct spa_type_info spa_type_props[] = {
|
|||
{ SPA_PROP_periodSize, SPA_TYPE_PROPS_BASE "periodSize", SPA_TYPE_Int, },
|
||||
{ SPA_PROP_periodEvent, SPA_TYPE_PROPS_BASE "periodEvent", SPA_TYPE_Bool, },
|
||||
{ SPA_PROP_live, SPA_TYPE_PROPS_BASE "live", SPA_TYPE_Bool, },
|
||||
{ SPA_PROP_waveType, SPA_TYPE_PROPS_BASE "waveType", SPA_TYPE_Enum, },
|
||||
{ SPA_PROP_waveType, SPA_TYPE_PROPS_BASE "waveType", SPA_TYPE_Id, },
|
||||
{ SPA_PROP_frequency, SPA_TYPE_PROPS_BASE "frequency", SPA_TYPE_Int, },
|
||||
{ SPA_PROP_volume, SPA_TYPE_PROPS_BASE "volume", SPA_TYPE_Float, },
|
||||
{ SPA_PROP_mute, SPA_TYPE_PROPS_BASE "mute", SPA_TYPE_Bool, },
|
||||
{ SPA_PROP_patternType, SPA_TYPE_PROPS_BASE "patternType", SPA_TYPE_Enum, },
|
||||
{ SPA_PROP_ditherType, SPA_TYPE_PROPS_BASE "ditherType", SPA_TYPE_Enum, },
|
||||
{ SPA_PROP_patternType, SPA_TYPE_PROPS_BASE "patternType", SPA_TYPE_Id, },
|
||||
{ SPA_PROP_ditherType, SPA_TYPE_PROPS_BASE "ditherType", SPA_TYPE_Id, },
|
||||
{ SPA_PROP_truncate, SPA_TYPE_PROPS_BASE "truncate", SPA_TYPE_Bool, },
|
||||
{ SPA_PROP_brightness, SPA_TYPE_PROPS_BASE "brightness", SPA_TYPE_Int, },
|
||||
{ SPA_PROP_contrast, SPA_TYPE_PROPS_BASE "contrast", SPA_TYPE_Int, },
|
||||
|
|
@ -101,10 +101,10 @@ static const struct spa_type_info spa_type_props[] = {
|
|||
#define SPA_TYPE_PROP_INFO_BASE SPA_TYPE__PropInfo ":"
|
||||
|
||||
static const struct spa_type_info spa_type_prop_info[] = {
|
||||
{ SPA_PROP_INFO_START, SPA_TYPE_PROP_INFO_BASE, SPA_TYPE_Enum, spa_type_param, },
|
||||
{ SPA_PROP_INFO_id, SPA_TYPE_PROP_INFO_BASE "id", SPA_TYPE_Enum, spa_type_props },
|
||||
{ SPA_PROP_INFO_START, SPA_TYPE_PROP_INFO_BASE, SPA_TYPE_Id, spa_type_param, },
|
||||
{ SPA_PROP_INFO_id, SPA_TYPE_PROP_INFO_BASE "id", SPA_TYPE_Id, spa_type_props },
|
||||
{ SPA_PROP_INFO_name, SPA_TYPE_PROP_INFO_BASE "name", SPA_TYPE_String, },
|
||||
{ SPA_PROP_INFO_type, SPA_TYPE_PROP_INFO_BASE "type", SPA_TYPE_Prop, },
|
||||
{ SPA_PROP_INFO_type, SPA_TYPE_PROP_INFO_BASE "type", SPA_TYPE_Id, },
|
||||
{ SPA_PROP_INFO_labels, SPA_TYPE_PROP_INFO_BASE "labels", SPA_TYPE_Struct, },
|
||||
{ 0, NULL, },
|
||||
};
|
||||
|
|
@ -113,8 +113,8 @@ static const struct spa_type_info spa_type_prop_info[] = {
|
|||
#define SPA_TYPE_PARAM_META_BASE SPA_TYPE_PARAM__Meta ":"
|
||||
|
||||
static const struct spa_type_info spa_type_param_meta[] = {
|
||||
{ SPA_PARAM_META_START, SPA_TYPE_PARAM_META_BASE, SPA_TYPE_Enum, spa_type_param, },
|
||||
{ SPA_PARAM_META_type, SPA_TYPE_PARAM_META_BASE "type", SPA_TYPE_Enum, },
|
||||
{ SPA_PARAM_META_START, SPA_TYPE_PARAM_META_BASE, SPA_TYPE_Id, spa_type_param, },
|
||||
{ SPA_PARAM_META_type, SPA_TYPE_PARAM_META_BASE "type", SPA_TYPE_Id, },
|
||||
{ SPA_PARAM_META_size, SPA_TYPE_PARAM_META_BASE "size", SPA_TYPE_Int, },
|
||||
{ 0, NULL, },
|
||||
};
|
||||
|
|
@ -126,8 +126,8 @@ static const struct spa_type_info spa_type_param_meta[] = {
|
|||
#define SPA_TYPE_PARAM_IO_BASE SPA_TYPE_PARAM__IO ":"
|
||||
|
||||
static const struct spa_type_info spa_type_param_io[] = {
|
||||
{ SPA_PARAM_IO_START, SPA_TYPE_PARAM_IO_BASE, SPA_TYPE_Enum, spa_type_param, },
|
||||
{ SPA_PARAM_IO_id, SPA_TYPE_PARAM_IO_BASE "id", SPA_TYPE_Enum, spa_type_io },
|
||||
{ SPA_PARAM_IO_START, SPA_TYPE_PARAM_IO_BASE, SPA_TYPE_Id, spa_type_param, },
|
||||
{ SPA_PARAM_IO_id, SPA_TYPE_PARAM_IO_BASE "id", SPA_TYPE_Id, spa_type_io },
|
||||
{ SPA_PARAM_IO_size, SPA_TYPE_PARAM_IO_BASE "size", SPA_TYPE_Int, },
|
||||
{ 0, NULL, },
|
||||
};
|
||||
|
|
@ -198,24 +198,24 @@ static const struct spa_type_info spa_type_media_subtype[] = {
|
|||
#define SPA_TYPE_FORMAT_VIDEO_BASE SPA_TYPE__FormatVideo ":"
|
||||
|
||||
static const struct spa_type_info spa_type_format[] = {
|
||||
{ SPA_FORMAT_START, SPA_TYPE_FORMAT_BASE, SPA_TYPE_Enum, spa_type_param, },
|
||||
{ SPA_FORMAT_START, SPA_TYPE_FORMAT_BASE, SPA_TYPE_Id, spa_type_param, },
|
||||
|
||||
{ SPA_FORMAT_mediaType, SPA_TYPE_FORMAT_BASE "mediaType", SPA_TYPE_Enum,
|
||||
{ SPA_FORMAT_mediaType, SPA_TYPE_FORMAT_BASE "mediaType", SPA_TYPE_Id,
|
||||
spa_type_media_type, },
|
||||
{ SPA_FORMAT_mediaSubtype, SPA_TYPE_FORMAT_BASE "mediaSubtype", SPA_TYPE_Enum,
|
||||
{ SPA_FORMAT_mediaSubtype, SPA_TYPE_FORMAT_BASE "mediaSubtype", SPA_TYPE_Id,
|
||||
spa_type_media_subtype, },
|
||||
|
||||
{ SPA_FORMAT_AUDIO_format, SPA_TYPE_FORMAT_AUDIO_BASE "format", SPA_TYPE_Enum,
|
||||
{ SPA_FORMAT_AUDIO_format, SPA_TYPE_FORMAT_AUDIO_BASE "format", SPA_TYPE_Id,
|
||||
spa_type_audio_format },
|
||||
{ SPA_FORMAT_AUDIO_flags, SPA_TYPE_FORMAT_AUDIO_BASE "flags", SPA_TYPE_Enum,
|
||||
{ SPA_FORMAT_AUDIO_flags, SPA_TYPE_FORMAT_AUDIO_BASE "flags", SPA_TYPE_Id,
|
||||
spa_type_audio_flags },
|
||||
{ SPA_FORMAT_AUDIO_layout, SPA_TYPE_FORMAT_AUDIO_BASE "layout", SPA_TYPE_Enum,
|
||||
{ SPA_FORMAT_AUDIO_layout, SPA_TYPE_FORMAT_AUDIO_BASE "layout", SPA_TYPE_Id,
|
||||
spa_type_audio_layout },
|
||||
{ SPA_FORMAT_AUDIO_rate, SPA_TYPE_FORMAT_AUDIO_BASE "rate", SPA_TYPE_Int, },
|
||||
{ SPA_FORMAT_AUDIO_channels, SPA_TYPE_FORMAT_AUDIO_BASE "channels", SPA_TYPE_Int, },
|
||||
{ SPA_FORMAT_AUDIO_channelMask, SPA_TYPE_FORMAT_AUDIO_BASE "channelMask", SPA_TYPE_Int, },
|
||||
|
||||
{ SPA_FORMAT_VIDEO_format, SPA_TYPE_FORMAT_VIDEO_BASE "format", SPA_TYPE_Enum,
|
||||
{ SPA_FORMAT_VIDEO_format, SPA_TYPE_FORMAT_VIDEO_BASE "format", SPA_TYPE_Id,
|
||||
spa_type_video_format, },
|
||||
{ SPA_FORMAT_VIDEO_size, SPA_TYPE_FORMAT_VIDEO_BASE "size", SPA_TYPE_Rectangle, },
|
||||
{ SPA_FORMAT_VIDEO_framerate, SPA_TYPE_FORMAT_VIDEO_BASE "framerate", SPA_TYPE_Fraction, },
|
||||
|
|
@ -244,7 +244,7 @@ static const struct spa_type_info spa_type_format[] = {
|
|||
#define SPA_TYPE_PARAM_BLOCK_INFO_BASE SPA_TYPE_PARAM__BlockInfo ":"
|
||||
|
||||
static const struct spa_type_info spa_type_param_buffers[] = {
|
||||
{ SPA_PARAM_BUFFERS_START, SPA_TYPE_PARAM_BUFFERS_BASE, SPA_TYPE_Enum, spa_type_param, },
|
||||
{ SPA_PARAM_BUFFERS_START, SPA_TYPE_PARAM_BUFFERS_BASE, SPA_TYPE_Id, spa_type_param, },
|
||||
{ SPA_PARAM_BUFFERS_buffers, SPA_TYPE_PARAM_BUFFERS_BASE "buffers", SPA_TYPE_Int, },
|
||||
{ SPA_PARAM_BUFFERS_blocks, SPA_TYPE_PARAM_BUFFERS_BASE "blocks", SPA_TYPE_Int, },
|
||||
{ SPA_PARAM_BUFFERS_size, SPA_TYPE_PARAM_BLOCK_INFO_BASE "size", SPA_TYPE_Int, },
|
||||
|
|
|
|||
|
|
@ -56,11 +56,12 @@ spa_format_video_raw_build(struct spa_pod_builder *builder, uint32_t id,
|
|||
{
|
||||
return spa_pod_builder_object(builder,
|
||||
SPA_TYPE_OBJECT_Format, id,
|
||||
":", SPA_FORMAT_mediaType, "I", SPA_MEDIA_TYPE_video,
|
||||
":", SPA_FORMAT_mediaSubtype, "I", SPA_MEDIA_SUBTYPE_raw,
|
||||
":", SPA_FORMAT_VIDEO_format, "I", &info->format,
|
||||
":", SPA_FORMAT_VIDEO_size, "R", &info->size,
|
||||
":", SPA_FORMAT_VIDEO_framerate, "F", &info->framerate);
|
||||
SPA_FORMAT_mediaType, &SPA_POD_Id(SPA_MEDIA_TYPE_video),
|
||||
SPA_FORMAT_mediaSubtype, &SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw),
|
||||
SPA_FORMAT_VIDEO_format, &SPA_POD_Id(info->format),
|
||||
SPA_FORMAT_VIDEO_size, &SPA_POD_Rectangle(info->size),
|
||||
SPA_FORMAT_VIDEO_framerate, &SPA_POD_Fraction(info->framerate),
|
||||
0);
|
||||
}
|
||||
|
||||
static inline int
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ static inline int spa_pod_compare_value(uint32_t type, const void *r1, const voi
|
|||
case SPA_TYPE_None:
|
||||
return 0;
|
||||
case SPA_TYPE_Bool:
|
||||
case SPA_TYPE_Enum:
|
||||
case SPA_TYPE_Id:
|
||||
return *(int32_t *) r1 == *(uint32_t *) r2 ? 0 : 1;
|
||||
case SPA_TYPE_Int:
|
||||
return *(int32_t *) r1 - *(int32_t *) r2;
|
||||
|
|
@ -104,31 +104,6 @@ static inline int spa_pod_compare_part(const struct spa_pod *pod1, uint32_t pod1
|
|||
|
||||
do_advance = true;
|
||||
break;
|
||||
case SPA_TYPE_Prop:
|
||||
{
|
||||
struct spa_pod_prop *pr1, *pr2;
|
||||
void *a1, *a2;
|
||||
|
||||
pr1 = (struct spa_pod_prop *) p1;
|
||||
pr2 = spa_pod_contents_find_prop(pod2, pod2_size, pr1->body.key);
|
||||
|
||||
if (pr2 == NULL)
|
||||
return -EINVAL;
|
||||
|
||||
/* incompatible property types */
|
||||
if (pr1->body.value.type != pr2->body.value.type)
|
||||
return -EINVAL;
|
||||
|
||||
if (pr1->body.flags & SPA_POD_PROP_FLAG_UNSET ||
|
||||
pr2->body.flags & SPA_POD_PROP_FLAG_UNSET)
|
||||
return -EINVAL;
|
||||
|
||||
a1 = SPA_MEMBER(pr1, sizeof(struct spa_pod_prop), void);
|
||||
a2 = SPA_MEMBER(pr2, sizeof(struct spa_pod_prop), void);
|
||||
|
||||
res = spa_pod_compare_value(pr1->body.value.type, a1, a2);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
if (SPA_POD_TYPE(p1) != SPA_POD_TYPE(p2))
|
||||
return -EINVAL;
|
||||
|
|
|
|||
|
|
@ -28,49 +28,57 @@
|
|||
#include <spa/pod/builder.h>
|
||||
#include <spa/pod/compare.h>
|
||||
|
||||
static inline void spa_pod_prop_fix_default(struct spa_pod_prop *prop)
|
||||
static inline int spa_pod_choice_fix_default(struct spa_pod_choice *choice)
|
||||
{
|
||||
void *val = SPA_MEMBER(prop, sizeof(struct spa_pod_prop), void),
|
||||
*alt = SPA_MEMBER(val, prop->body.value.size, void);
|
||||
int i, nalt = SPA_POD_PROP_N_VALUES(prop) - 1;
|
||||
void *val, *alt;
|
||||
int i, nvals;
|
||||
uint32_t type, size;
|
||||
|
||||
switch (prop->body.flags & SPA_POD_PROP_RANGE_MASK) {
|
||||
case SPA_POD_PROP_RANGE_NONE:
|
||||
nvals = SPA_POD_CHOICE_N_VALUES(choice);
|
||||
type = SPA_POD_CHOICE_VALUE_TYPE(choice);
|
||||
size = SPA_POD_CHOICE_VALUE_SIZE(choice);
|
||||
alt = val = SPA_POD_CHOICE_VALUES(choice);
|
||||
|
||||
switch (choice->body.type) {
|
||||
case SPA_CHOICE_None:
|
||||
break;
|
||||
case SPA_POD_PROP_RANGE_MIN_MAX:
|
||||
case SPA_POD_PROP_RANGE_STEP:
|
||||
if (spa_pod_compare_value(prop->body.value.type, val, alt) < 0)
|
||||
memcpy(val, alt, prop->body.value.size);
|
||||
alt = SPA_MEMBER(alt, prop->body.value.size, void);
|
||||
if (spa_pod_compare_value(prop->body.value.type, val, alt) > 0)
|
||||
memcpy(val, alt, prop->body.value.size);
|
||||
case SPA_CHOICE_Range:
|
||||
case SPA_CHOICE_Step:
|
||||
if (nvals > 1) {
|
||||
alt = SPA_MEMBER(alt, size, void);
|
||||
if (spa_pod_compare_value(type, val, alt) < 0)
|
||||
memcpy(val, alt, size);
|
||||
}
|
||||
if (nvals > 2) {
|
||||
alt = SPA_MEMBER(alt, size, void);
|
||||
if (spa_pod_compare_value(type, val, alt) > 0)
|
||||
memcpy(val, alt, size);
|
||||
}
|
||||
break;
|
||||
case SPA_POD_PROP_RANGE_ENUM:
|
||||
case SPA_CHOICE_Enum:
|
||||
{
|
||||
void *best = NULL;
|
||||
|
||||
for (i = 0; i < nalt; i++) {
|
||||
if (spa_pod_compare_value(prop->body.value.type, val, alt) == 0) {
|
||||
for (i = 1; i < nvals; i++) {
|
||||
alt = SPA_MEMBER(alt, size, void);
|
||||
if (spa_pod_compare_value(type, val, alt) == 0) {
|
||||
best = alt;
|
||||
break;
|
||||
}
|
||||
if (best == NULL)
|
||||
best = alt;
|
||||
alt = SPA_MEMBER(alt, prop->body.value.size, void);
|
||||
}
|
||||
if (best)
|
||||
memcpy(val, best, prop->body.value.size);
|
||||
memcpy(val, best, size);
|
||||
|
||||
if (nalt <= 1) {
|
||||
prop->body.flags &= ~SPA_POD_PROP_FLAG_UNSET;
|
||||
prop->body.flags &= ~SPA_POD_PROP_RANGE_MASK;
|
||||
prop->body.flags |= SPA_POD_PROP_RANGE_NONE;
|
||||
}
|
||||
if (nvals <= 1)
|
||||
choice->body.type = SPA_CHOICE_None;
|
||||
break;
|
||||
}
|
||||
case SPA_POD_PROP_RANGE_FLAGS:
|
||||
case SPA_CHOICE_Flags:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
|
|
@ -78,159 +86,159 @@ spa_pod_filter_prop(struct spa_pod_builder *b,
|
|||
const struct spa_pod_prop *p1,
|
||||
const struct spa_pod_prop *p2)
|
||||
{
|
||||
struct spa_pod_prop *np;
|
||||
int nalt1, nalt2;
|
||||
const struct spa_pod *v1, *v2;
|
||||
struct spa_pod_choice *nc;
|
||||
uint32_t nalt1, nalt2;
|
||||
void *alt1, *alt2, *a1, *a2;
|
||||
uint32_t rt1, rt2;
|
||||
uint32_t type, size, p1c, p2c;
|
||||
int j, k;
|
||||
|
||||
v1 = spa_pod_get_values(&p1->value, &nalt1, &p1c);
|
||||
alt1 = SPA_POD_BODY(v1);
|
||||
v2 = spa_pod_get_values(&p2->value, &nalt2, &p2c);
|
||||
alt2 = SPA_POD_BODY(v2);
|
||||
|
||||
type = v1->type;
|
||||
size = v1->size;
|
||||
|
||||
/* incompatible property types */
|
||||
if (p1->body.value.type != p2->body.value.type)
|
||||
if (type != v2->type || size != v2->size || p1->key != p2->key)
|
||||
return -EINVAL;
|
||||
|
||||
rt1 = p1->body.flags & SPA_POD_PROP_RANGE_MASK;
|
||||
rt2 = p2->body.flags & SPA_POD_PROP_RANGE_MASK;
|
||||
|
||||
alt1 = SPA_MEMBER(p1, sizeof(struct spa_pod_prop), void);
|
||||
nalt1 = SPA_POD_PROP_N_VALUES(p1);
|
||||
alt2 = SPA_MEMBER(p2, sizeof(struct spa_pod_prop), void);
|
||||
nalt2 = SPA_POD_PROP_N_VALUES(p2);
|
||||
|
||||
if (p1->body.flags & SPA_POD_PROP_FLAG_UNSET) {
|
||||
alt1 = SPA_MEMBER(alt1, p1->body.value.size, void);
|
||||
nalt1--;
|
||||
} else {
|
||||
if (p1c == SPA_CHOICE_None) {
|
||||
nalt1 = 1;
|
||||
rt1 = SPA_POD_PROP_RANGE_NONE;
|
||||
} else {
|
||||
alt1 = SPA_MEMBER(alt1, size, void);
|
||||
nalt1--;
|
||||
}
|
||||
|
||||
if (p2->body.flags & SPA_POD_PROP_FLAG_UNSET) {
|
||||
alt2 = SPA_MEMBER(alt2, p2->body.value.size, void);
|
||||
nalt2--;
|
||||
} else {
|
||||
if (p2c == SPA_CHOICE_None) {
|
||||
nalt2 = 1;
|
||||
rt2 = SPA_POD_PROP_RANGE_NONE;
|
||||
} else {
|
||||
alt2 = SPA_MEMBER(alt2, size, void);
|
||||
nalt2--;
|
||||
}
|
||||
|
||||
/* start with copying the property */
|
||||
np = spa_pod_builder_deref(b, spa_pod_builder_push_prop(b, p1->body.key, 0));
|
||||
spa_pod_builder_prop(b, p1->key, 0);
|
||||
nc = spa_pod_builder_deref(b, spa_pod_builder_push_choice(b, 0, 0));
|
||||
|
||||
/* default value */
|
||||
spa_pod_builder_raw(b, &p1->body.value, sizeof(p1->body.value) + p1->body.value.size);
|
||||
spa_pod_builder_primitive(b, v1);
|
||||
|
||||
if ((rt1 == SPA_POD_PROP_RANGE_NONE && rt2 == SPA_POD_PROP_RANGE_NONE) ||
|
||||
(rt1 == SPA_POD_PROP_RANGE_NONE && rt2 == SPA_POD_PROP_RANGE_ENUM) ||
|
||||
(rt1 == SPA_POD_PROP_RANGE_ENUM && rt2 == SPA_POD_PROP_RANGE_NONE) ||
|
||||
(rt1 == SPA_POD_PROP_RANGE_ENUM && rt2 == SPA_POD_PROP_RANGE_ENUM)) {
|
||||
if ((p1c == SPA_CHOICE_None && p2c == SPA_CHOICE_None) ||
|
||||
(p1c == SPA_CHOICE_None && p2c == SPA_CHOICE_Enum) ||
|
||||
(p1c == SPA_CHOICE_Enum && p2c == SPA_CHOICE_None) ||
|
||||
(p1c == SPA_CHOICE_Enum && p2c == SPA_CHOICE_Enum)) {
|
||||
int n_copied = 0;
|
||||
/* copy all equal values but don't copy the default value again */
|
||||
for (j = 0, a1 = alt1; j < nalt1; j++, a1 += p1->body.value.size) {
|
||||
for (k = 0, a2 = alt2; k < nalt2; k++, a2 += p2->body.value.size) {
|
||||
if (spa_pod_compare_value(p1->body.value.type, a1, a2) == 0) {
|
||||
if (rt1 == SPA_POD_PROP_RANGE_ENUM || j > 0)
|
||||
spa_pod_builder_raw(b, a1, p1->body.value.size);
|
||||
for (j = 0, a1 = alt1; j < nalt1; j++, a1 += size) {
|
||||
for (k = 0, a2 = alt2; k < nalt2; k++, a2 += size) {
|
||||
if (spa_pod_compare_value(type, a1, a2) == 0) {
|
||||
if (p1c == SPA_CHOICE_Enum || j > 0)
|
||||
spa_pod_builder_raw(b, a1, size);
|
||||
n_copied++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (n_copied == 0)
|
||||
return -EINVAL;
|
||||
np->body.flags |= SPA_POD_PROP_RANGE_ENUM | SPA_POD_PROP_FLAG_UNSET;
|
||||
nc->body.type = SPA_CHOICE_Enum;
|
||||
}
|
||||
|
||||
if ((rt1 == SPA_POD_PROP_RANGE_NONE && rt2 == SPA_POD_PROP_RANGE_MIN_MAX) ||
|
||||
(rt1 == SPA_POD_PROP_RANGE_ENUM && rt2 == SPA_POD_PROP_RANGE_MIN_MAX)) {
|
||||
if ((p1c == SPA_CHOICE_None && p2c == SPA_CHOICE_Range) ||
|
||||
(p1c == SPA_CHOICE_Enum && p2c == SPA_CHOICE_Range)) {
|
||||
int n_copied = 0;
|
||||
/* copy all values inside the range */
|
||||
for (j = 0, a1 = alt1, a2 = alt2; j < nalt1; j++, a1 += p1->body.value.size) {
|
||||
if (spa_pod_compare_value(p1->body.value.type, a1, a2) < 0)
|
||||
for (j = 0, a1 = alt1, a2 = alt2; j < nalt1; j++, a1 += size) {
|
||||
if (spa_pod_compare_value(type, a1, a2) < 0)
|
||||
continue;
|
||||
if (spa_pod_compare_value(p1->body.value.type, a1, a2 + p2->body.value.size) > 0)
|
||||
if (spa_pod_compare_value(type, a1, a2 + size) > 0)
|
||||
continue;
|
||||
spa_pod_builder_raw(b, a1, p1->body.value.size);
|
||||
spa_pod_builder_raw(b, a1, size);
|
||||
n_copied++;
|
||||
}
|
||||
if (n_copied == 0)
|
||||
return -EINVAL;
|
||||
np->body.flags |= SPA_POD_PROP_RANGE_ENUM | SPA_POD_PROP_FLAG_UNSET;
|
||||
nc->body.type = SPA_CHOICE_Enum;
|
||||
}
|
||||
|
||||
if ((rt1 == SPA_POD_PROP_RANGE_NONE && rt2 == SPA_POD_PROP_RANGE_STEP) ||
|
||||
(rt1 == SPA_POD_PROP_RANGE_ENUM && rt2 == SPA_POD_PROP_RANGE_STEP)) {
|
||||
if ((p1c == SPA_CHOICE_None && p2c == SPA_CHOICE_Step) ||
|
||||
(p1c == SPA_CHOICE_Enum && p2c == SPA_CHOICE_Step)) {
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
if ((rt1 == SPA_POD_PROP_RANGE_MIN_MAX && rt2 == SPA_POD_PROP_RANGE_NONE) ||
|
||||
(rt1 == SPA_POD_PROP_RANGE_MIN_MAX && rt2 == SPA_POD_PROP_RANGE_ENUM)) {
|
||||
if ((p1c == SPA_CHOICE_Range && p2c == SPA_CHOICE_None) ||
|
||||
(p1c == SPA_CHOICE_Range && p2c == SPA_CHOICE_Enum)) {
|
||||
int n_copied = 0;
|
||||
/* copy all values inside the range */
|
||||
for (k = 0, a1 = alt1, a2 = alt2; k < nalt2; k++, a2 += p2->body.value.size) {
|
||||
if (spa_pod_compare_value(p1->body.value.type, a2, a1) < 0)
|
||||
for (k = 0, a1 = alt1, a2 = alt2; k < nalt2; k++, a2 += size) {
|
||||
if (spa_pod_compare_value(type, a2, a1) < 0)
|
||||
continue;
|
||||
if (spa_pod_compare_value(p1->body.value.type, a2, a1 + p1->body.value.size) > 0)
|
||||
if (spa_pod_compare_value(type, a2, a1 + size) > 0)
|
||||
continue;
|
||||
spa_pod_builder_raw(b, a2, p2->body.value.size);
|
||||
spa_pod_builder_raw(b, a2, size);
|
||||
n_copied++;
|
||||
}
|
||||
if (n_copied == 0)
|
||||
return -EINVAL;
|
||||
np->body.flags |= SPA_POD_PROP_RANGE_ENUM | SPA_POD_PROP_FLAG_UNSET;
|
||||
nc->body.type = SPA_CHOICE_Enum;
|
||||
}
|
||||
|
||||
if (rt1 == SPA_POD_PROP_RANGE_MIN_MAX && rt2 == SPA_POD_PROP_RANGE_MIN_MAX) {
|
||||
if (spa_pod_compare_value(p1->body.value.type, alt1, alt2) < 0)
|
||||
spa_pod_builder_raw(b, alt2, p2->body.value.size);
|
||||
if (p1c == SPA_CHOICE_Range && p2c == SPA_CHOICE_Range) {
|
||||
if (spa_pod_compare_value(type, alt1, alt2) < 0)
|
||||
spa_pod_builder_raw(b, alt2, size);
|
||||
else
|
||||
spa_pod_builder_raw(b, alt1, p1->body.value.size);
|
||||
spa_pod_builder_raw(b, alt1, size);
|
||||
|
||||
alt1 += p1->body.value.size;
|
||||
alt2 += p2->body.value.size;
|
||||
alt1 += size;
|
||||
alt2 += size;
|
||||
|
||||
if (spa_pod_compare_value(p1->body.value.type, alt1, alt2) < 0)
|
||||
spa_pod_builder_raw(b, alt1, p1->body.value.size);
|
||||
if (spa_pod_compare_value(type, alt1, alt2) < 0)
|
||||
spa_pod_builder_raw(b, alt1, size);
|
||||
else
|
||||
spa_pod_builder_raw(b, alt2, p2->body.value.size);
|
||||
spa_pod_builder_raw(b, alt2, size);
|
||||
|
||||
np->body.flags |= SPA_POD_PROP_RANGE_MIN_MAX | SPA_POD_PROP_FLAG_UNSET;
|
||||
nc->body.type = SPA_CHOICE_Range;
|
||||
}
|
||||
|
||||
if (rt1 == SPA_POD_PROP_RANGE_NONE && rt2 == SPA_POD_PROP_RANGE_FLAGS)
|
||||
if (p1c == SPA_CHOICE_None && p2c == SPA_CHOICE_Flags)
|
||||
return -ENOTSUP;
|
||||
|
||||
if (rt1 == SPA_POD_PROP_RANGE_MIN_MAX && rt2 == SPA_POD_PROP_RANGE_STEP)
|
||||
if (p1c == SPA_CHOICE_Range && p2c == SPA_CHOICE_Step)
|
||||
return -ENOTSUP;
|
||||
|
||||
if (rt1 == SPA_POD_PROP_RANGE_MIN_MAX && rt2 == SPA_POD_PROP_RANGE_FLAGS)
|
||||
if (p1c == SPA_CHOICE_Range && p2c == SPA_CHOICE_Flags)
|
||||
return -ENOTSUP;
|
||||
|
||||
if (rt1 == SPA_POD_PROP_RANGE_ENUM && rt2 == SPA_POD_PROP_RANGE_FLAGS)
|
||||
if (p1c == SPA_CHOICE_Enum && p2c == SPA_CHOICE_Flags)
|
||||
return -ENOTSUP;
|
||||
|
||||
if (rt1 == SPA_POD_PROP_RANGE_STEP && rt2 == SPA_POD_PROP_RANGE_NONE)
|
||||
if (p1c == SPA_CHOICE_Step && p2c == SPA_CHOICE_None)
|
||||
return -ENOTSUP;
|
||||
if (rt1 == SPA_POD_PROP_RANGE_STEP && rt2 == SPA_POD_PROP_RANGE_MIN_MAX)
|
||||
if (p1c == SPA_CHOICE_Step && p2c == SPA_CHOICE_Range)
|
||||
return -ENOTSUP;
|
||||
|
||||
if (rt1 == SPA_POD_PROP_RANGE_STEP && rt2 == SPA_POD_PROP_RANGE_STEP)
|
||||
if (p1c == SPA_CHOICE_Step && p2c == SPA_CHOICE_Step)
|
||||
return -ENOTSUP;
|
||||
if (rt1 == SPA_POD_PROP_RANGE_STEP && rt2 == SPA_POD_PROP_RANGE_ENUM)
|
||||
if (p1c == SPA_CHOICE_Step && p2c == SPA_CHOICE_Enum)
|
||||
return -ENOTSUP;
|
||||
if (rt1 == SPA_POD_PROP_RANGE_STEP && rt2 == SPA_POD_PROP_RANGE_FLAGS)
|
||||
if (p1c == SPA_CHOICE_Step && p2c == SPA_CHOICE_Flags)
|
||||
return -ENOTSUP;
|
||||
|
||||
if (rt1 == SPA_POD_PROP_RANGE_FLAGS && rt2 == SPA_POD_PROP_RANGE_NONE)
|
||||
if (p1c == SPA_CHOICE_Flags && p2c == SPA_CHOICE_None)
|
||||
return -ENOTSUP;
|
||||
if (rt1 == SPA_POD_PROP_RANGE_FLAGS && rt2 == SPA_POD_PROP_RANGE_MIN_MAX)
|
||||
if (p1c == SPA_CHOICE_Flags && p2c == SPA_CHOICE_Range)
|
||||
return -ENOTSUP;
|
||||
if (rt1 == SPA_POD_PROP_RANGE_FLAGS && rt2 == SPA_POD_PROP_RANGE_STEP)
|
||||
if (p1c == SPA_CHOICE_Flags && p2c == SPA_CHOICE_Step)
|
||||
return -ENOTSUP;
|
||||
if (rt1 == SPA_POD_PROP_RANGE_FLAGS && rt2 == SPA_POD_PROP_RANGE_ENUM)
|
||||
if (p1c == SPA_CHOICE_Flags && p2c == SPA_CHOICE_Enum)
|
||||
return -ENOTSUP;
|
||||
if (rt1 == SPA_POD_PROP_RANGE_FLAGS && rt2 == SPA_POD_PROP_RANGE_FLAGS)
|
||||
if (p1c == SPA_CHOICE_Flags && p2c == SPA_CHOICE_Flags)
|
||||
return -ENOTSUP;
|
||||
|
||||
spa_pod_builder_pop(b);
|
||||
spa_pod_prop_fix_default(np);
|
||||
spa_pod_choice_fix_default(nc);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -249,39 +257,50 @@ static inline int spa_pod_filter_part(struct spa_pod_builder *b,
|
|||
uint32_t filter_offset = 0;
|
||||
|
||||
switch (SPA_POD_TYPE(pp)) {
|
||||
case SPA_TYPE_Struct:
|
||||
case SPA_TYPE_Object:
|
||||
if (pf != NULL) {
|
||||
struct spa_pod_object *obj = (struct spa_pod_object *) pp;
|
||||
struct spa_pod_prop *p1, *p2;
|
||||
|
||||
if (SPA_POD_TYPE(pf) != SPA_POD_TYPE(pp))
|
||||
return -EINVAL;
|
||||
|
||||
if (SPA_POD_TYPE(pp) == SPA_TYPE_Struct) {
|
||||
filter_offset = sizeof(struct spa_pod_struct);
|
||||
spa_pod_builder_push_struct(b);
|
||||
} else {
|
||||
struct spa_pod_object *p1 = (struct spa_pod_object *) pp;
|
||||
filter_offset = sizeof(struct spa_pod_object);
|
||||
spa_pod_builder_push_object(b, p1->body.type, p1->body.id);
|
||||
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);
|
||||
if (p2 != NULL)
|
||||
res = spa_pod_filter_prop(b, p1, p2);
|
||||
else
|
||||
spa_pod_builder_raw_padded(b, p1, SPA_POD_PROP_SIZE(p1));
|
||||
if (res < 0)
|
||||
break;
|
||||
}
|
||||
spa_pod_builder_pop(b);
|
||||
do_advance = true;
|
||||
}
|
||||
else
|
||||
do_copy = true;
|
||||
break;
|
||||
|
||||
case SPA_TYPE_Prop:
|
||||
{
|
||||
struct spa_pod_prop *p1, *p2;
|
||||
case SPA_TYPE_Struct:
|
||||
if (pf != NULL) {
|
||||
if (SPA_POD_TYPE(pf) != SPA_POD_TYPE(pp))
|
||||
return -EINVAL;
|
||||
|
||||
p1 = (struct spa_pod_prop *) pp;
|
||||
p2 = spa_pod_contents_find_prop(filter, filter_size, p1->body.key);
|
||||
|
||||
if (p2 != NULL)
|
||||
res = spa_pod_filter_prop(b, p1, p2);
|
||||
filter_offset = sizeof(struct spa_pod_struct);
|
||||
spa_pod_builder_push_struct(b);
|
||||
res = spa_pod_filter_part(b,
|
||||
SPA_MEMBER(pp,filter_offset,void),
|
||||
SPA_POD_SIZE(pp) - filter_offset,
|
||||
SPA_MEMBER(pf,filter_offset,void),
|
||||
SPA_POD_SIZE(pf) - filter_offset);
|
||||
spa_pod_builder_pop(b);
|
||||
do_advance = true;
|
||||
}
|
||||
else
|
||||
do_copy = true;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
if (pf != NULL) {
|
||||
if (SPA_POD_SIZE(pp) != SPA_POD_SIZE(pf))
|
||||
|
|
@ -295,14 +314,6 @@ static inline int spa_pod_filter_part(struct spa_pod_builder *b,
|
|||
}
|
||||
if (do_copy)
|
||||
spa_pod_builder_raw_padded(b, pp, SPA_POD_SIZE(pp));
|
||||
else if (filter_offset) {
|
||||
res = spa_pod_filter_part(b,
|
||||
SPA_MEMBER(pp,filter_offset,void),
|
||||
SPA_POD_SIZE(pp) - filter_offset,
|
||||
SPA_MEMBER(pf,filter_offset,void),
|
||||
SPA_POD_SIZE(pf) - filter_offset);
|
||||
spa_pod_builder_pop(b);
|
||||
}
|
||||
if (do_advance) {
|
||||
pf = spa_pod_next(pf);
|
||||
if (!spa_pod_is_inside(filter, filter_size, pf))
|
||||
|
|
|
|||
|
|
@ -69,6 +69,11 @@ static inline void *spa_pod_next(const void *iter)
|
|||
return SPA_MEMBER(iter, SPA_ROUND_UP_N (SPA_POD_SIZE (iter), 8), void);
|
||||
}
|
||||
|
||||
static inline struct spa_pod_prop *spa_pod_prop_next(const struct spa_pod_prop *iter)
|
||||
{
|
||||
return SPA_MEMBER(iter, SPA_ROUND_UP_N (SPA_POD_PROP_SIZE (iter), 8), struct spa_pod_prop);
|
||||
}
|
||||
|
||||
static inline struct spa_pod_control *spa_pod_control_next(const struct spa_pod_control *iter)
|
||||
{
|
||||
return SPA_MEMBER(iter, SPA_ROUND_UP_N (SPA_POD_CONTROL_SIZE (iter), 8), struct spa_pod_control);
|
||||
|
|
@ -79,6 +84,11 @@ static inline struct spa_pod_control *spa_pod_control_next(const struct spa_pod_
|
|||
(iter) < SPA_MEMBER((body), (_size), __typeof__(*(iter))); \
|
||||
(iter) = SPA_MEMBER((iter), (body)->child.size, __typeof__(*(iter))))
|
||||
|
||||
#define SPA_POD_CHOICE_BODY_FOREACH(body, _size, iter) \
|
||||
for ((iter) = SPA_MEMBER((body), sizeof(struct spa_pod_choice_body), __typeof__(*(iter))); \
|
||||
(iter) < SPA_MEMBER((body), (_size), __typeof__(*(iter))); \
|
||||
(iter) = SPA_MEMBER((iter), (body)->child.size, __typeof__(*(iter))))
|
||||
|
||||
#define SPA_POD_FOREACH(pod, size, iter) \
|
||||
for ((iter) = (pod); \
|
||||
spa_pod_is_inside(pod, size, iter); \
|
||||
|
|
@ -88,9 +98,9 @@ static inline struct spa_pod_control *spa_pod_control_next(const struct spa_pod_
|
|||
SPA_POD_FOREACH(SPA_MEMBER((pod), (offset), void),SPA_POD_SIZE (pod)-(offset),iter)
|
||||
|
||||
#define SPA_POD_OBJECT_BODY_FOREACH(body, size, iter) \
|
||||
for ((iter) = SPA_MEMBER((body), sizeof(struct spa_pod_object_body), struct spa_pod); \
|
||||
for ((iter) = SPA_MEMBER((body), sizeof(struct spa_pod_object_body), struct spa_pod_prop); \
|
||||
spa_pod_is_inside(body, size, iter); \
|
||||
(iter) = spa_pod_next(iter))
|
||||
(iter) = spa_pod_prop_next(iter))
|
||||
|
||||
#define SPA_POD_OBJECT_FOREACH(obj, iter) \
|
||||
SPA_POD_OBJECT_BODY_FOREACH(&(obj)->body, SPA_POD_BODY_SIZE(obj), iter)
|
||||
|
|
@ -103,56 +113,38 @@ 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)
|
||||
|
||||
#if 0
|
||||
#define SPA_POD_PROP_ALTERNATIVE_FOREACH(body, _size, iter) \
|
||||
for ((iter) = SPA_MEMBER((body), (body)->value.size + \
|
||||
sizeof(struct spa_pod_prop_body), __typeof__(*iter)); \
|
||||
sizeof(struct spa_pod_prop), __typeof__(*iter)); \
|
||||
(iter) <= SPA_MEMBER((body), (_size)-(body)->value.size, __typeof__(*iter)); \
|
||||
(iter) = SPA_MEMBER((iter), (body)->value.size, __typeof__(*iter)))
|
||||
#endif
|
||||
|
||||
static inline struct spa_pod_prop *spa_pod_contents_find_prop(const struct spa_pod *pod,
|
||||
uint32_t size, uint32_t key)
|
||||
static inline struct spa_pod_prop *spa_pod_find_prop(const struct spa_pod *pod, uint32_t key)
|
||||
{
|
||||
const struct spa_pod *res;
|
||||
SPA_POD_FOREACH(pod, size, res) {
|
||||
if (res->type == SPA_TYPE_Prop
|
||||
&& ((struct spa_pod_prop *) res)->body.key == key)
|
||||
return (struct spa_pod_prop *) res;
|
||||
struct spa_pod_prop *res;
|
||||
if (pod->type != SPA_TYPE_Object)
|
||||
return NULL;
|
||||
SPA_POD_OBJECT_FOREACH((struct spa_pod_object*)pod, res) {
|
||||
if (res->key == key)
|
||||
return res;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline struct spa_pod_prop *spa_pod_find_prop(const struct spa_pod *pod, uint32_t key)
|
||||
{
|
||||
uint32_t offset;
|
||||
|
||||
if (pod->type == SPA_TYPE_Object)
|
||||
offset = sizeof(struct spa_pod_object);
|
||||
else if (pod->type == SPA_TYPE_Struct)
|
||||
offset = sizeof(struct spa_pod_struct);
|
||||
else
|
||||
return NULL;
|
||||
|
||||
return spa_pod_contents_find_prop(SPA_MEMBER(pod, offset, const struct spa_pod),
|
||||
SPA_POD_SIZE(pod) - offset, key);
|
||||
}
|
||||
|
||||
static inline int spa_pod_fixate(struct spa_pod *pod)
|
||||
{
|
||||
struct spa_pod *res;
|
||||
uint32_t offset;
|
||||
struct spa_pod_prop *res;
|
||||
|
||||
if (pod->type == SPA_TYPE_Object)
|
||||
offset = sizeof(struct spa_pod_object);
|
||||
else if (pod->type == SPA_TYPE_Struct)
|
||||
offset = sizeof(struct spa_pod_struct);
|
||||
else
|
||||
if (pod->type != SPA_TYPE_Object)
|
||||
return -EINVAL;
|
||||
|
||||
SPA_POD_CONTENTS_FOREACH(pod, offset, res) {
|
||||
if (res->type == SPA_TYPE_Prop)
|
||||
SPA_FLAG_UNSET (((struct spa_pod_prop *) res)->body.flags,
|
||||
SPA_POD_PROP_FLAG_UNSET);
|
||||
SPA_POD_OBJECT_FOREACH((struct spa_pod_object*)pod, res) {
|
||||
if (res->value.type == SPA_TYPE_Choice)
|
||||
((struct spa_pod_choice*)&res->value)->body.type = SPA_CHOICE_None;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ static inline bool spa_pod_parser_can_collect(struct spa_pod *pod, char type)
|
|||
return type == 'T' || type == 'O' || type == 'V' || type == 's';
|
||||
case SPA_TYPE_Bool:
|
||||
return type == 'b';
|
||||
case SPA_TYPE_Enum:
|
||||
case SPA_TYPE_Id:
|
||||
return type == 'I';
|
||||
case SPA_TYPE_Int:
|
||||
return type == 'i';
|
||||
|
|
@ -87,8 +87,9 @@ static inline bool spa_pod_parser_can_collect(struct spa_pod *pod, char type)
|
|||
return type == 'p';
|
||||
case SPA_TYPE_Fd:
|
||||
return type == 'h';
|
||||
case SPA_TYPE_Prop:
|
||||
return type == 'V';
|
||||
case SPA_TYPE_Choice:
|
||||
return type == 'V' ||
|
||||
spa_pod_parser_can_collect(SPA_POD_CHOICE_CHILD(pod), type);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
|
@ -146,7 +147,7 @@ do { \
|
|||
{ \
|
||||
struct spa_pod_pointer_body *b = \
|
||||
(struct spa_pod_pointer_body *) SPA_POD_BODY(pod); \
|
||||
*(va_arg(args, void **)) = b->value; \
|
||||
*(va_arg(args, const void **)) = b->value; \
|
||||
break; \
|
||||
} \
|
||||
case 'h': \
|
||||
|
|
@ -211,12 +212,7 @@ static inline int spa_pod_parser_getv(struct spa_pod_parser *parser,
|
|||
case '{':
|
||||
if (pod == NULL || SPA_POD_TYPE(pod) != SPA_TYPE_Object)
|
||||
return -EINVAL;
|
||||
if (++parser->depth >= SPA_POD_MAX_DEPTH)
|
||||
return -EINVAL;
|
||||
|
||||
it = &parser->iter[parser->depth];
|
||||
spa_pod_iter_init(it, pod, SPA_POD_SIZE(pod), sizeof(struct spa_pod_object));
|
||||
goto read_pod;
|
||||
break;
|
||||
case '[':
|
||||
if (pod == NULL || SPA_POD_TYPE(pod) != SPA_TYPE_Struct)
|
||||
return -EINVAL;
|
||||
|
|
@ -226,12 +222,13 @@ static inline int spa_pod_parser_getv(struct spa_pod_parser *parser,
|
|||
it = &parser->iter[parser->depth];
|
||||
spa_pod_iter_init(it, pod, SPA_POD_SIZE(pod), sizeof(struct spa_pod_struct));
|
||||
goto read_pod;
|
||||
case ']': case '}':
|
||||
case ']':
|
||||
if (current != NULL)
|
||||
return -EINVAL;
|
||||
if (--parser->depth < 0)
|
||||
return -EINVAL;
|
||||
|
||||
case '}':
|
||||
it = &parser->iter[parser->depth];
|
||||
current = spa_pod_iter_current(it);
|
||||
spa_pod_iter_advance(it, current);
|
||||
|
|
@ -253,8 +250,8 @@ static inline int spa_pod_parser_getv(struct spa_pod_parser *parser,
|
|||
const struct spa_pod *obj = (const struct spa_pod *) parser->iter[parser->depth].data;
|
||||
|
||||
prop = spa_pod_find_prop(obj, key);
|
||||
if (prop != NULL && (prop->body.flags & SPA_POD_PROP_FLAG_UNSET) == 0)
|
||||
pod = &prop->body.value;
|
||||
if (prop != NULL)
|
||||
pod = &prop->value;
|
||||
else
|
||||
pod = NULL;
|
||||
|
||||
|
|
@ -275,6 +272,9 @@ static inline int spa_pod_parser_getv(struct spa_pod_parser *parser,
|
|||
skip = true;
|
||||
}
|
||||
collect:
|
||||
if (pod->type == SPA_TYPE_Choice)
|
||||
pod = SPA_POD_CHOICE_CHILD(pod);
|
||||
|
||||
if (suppress)
|
||||
suppress = false;
|
||||
else if (skip)
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ struct spa_pod_bool {
|
|||
int32_t __padding;
|
||||
};
|
||||
|
||||
struct spa_pod_enum {
|
||||
struct spa_pod_id {
|
||||
struct spa_pod pod;
|
||||
uint32_t value;
|
||||
int32_t __padding;
|
||||
|
|
@ -109,8 +109,10 @@ struct spa_pod_bitmap {
|
|||
/* array of uint8_t follows with the bitmap */
|
||||
};
|
||||
|
||||
#define SPA_POD_ARRAY_TYPE(arr) ((arr)->body.child.type)
|
||||
#define SPA_POD_ARRAY_N_VALUES(arr) (((arr)->pod.size - sizeof(struct spa_pod_array_body)) / (arr)->body.child.size)
|
||||
#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))
|
||||
|
||||
struct spa_pod_array_body {
|
||||
struct spa_pod child;
|
||||
|
|
@ -122,6 +124,33 @@ struct spa_pod_array {
|
|||
struct spa_pod_array_body body;
|
||||
};
|
||||
|
||||
#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_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))
|
||||
#define SPA_POD_CHOICE_VALUES(choice) (SPA_POD_CONTENTS(struct spa_pod_choice, choice))
|
||||
|
||||
enum spa_choice_type {
|
||||
SPA_CHOICE_None, /**< no choice, first value is current */
|
||||
SPA_CHOICE_Range, /**< range: default, min, max */
|
||||
SPA_CHOICE_Step, /**< range with step: default, min, max, step */
|
||||
SPA_CHOICE_Enum, /**< list: default, alternative,... */
|
||||
SPA_CHOICE_Flags, /**< flags: default, possible flags,... */
|
||||
};
|
||||
|
||||
struct spa_pod_choice_body {
|
||||
uint32_t type; /**< type of choice, one of enum spa_choice_type */
|
||||
uint32_t flags; /**< extra flags */
|
||||
struct spa_pod child;
|
||||
/* array with elements of child.size follows */
|
||||
};
|
||||
|
||||
struct spa_pod_choice {
|
||||
struct spa_pod pod;
|
||||
struct spa_pod_choice_body body;
|
||||
};
|
||||
|
||||
struct spa_pod_struct {
|
||||
struct spa_pod pod;
|
||||
/* one or more spa_pod follow */
|
||||
|
|
@ -152,7 +181,7 @@ static inline bool spa_pod_is_object_id(const struct spa_pod *pod, uint32_t id)
|
|||
|
||||
struct spa_pod_pointer_body {
|
||||
uint32_t type; /**< pointer id, one of enum spa_type */
|
||||
void *value;
|
||||
const void *value;
|
||||
};
|
||||
|
||||
struct spa_pod_pointer {
|
||||
|
|
@ -165,33 +194,33 @@ struct spa_pod_fd {
|
|||
int value;
|
||||
};
|
||||
|
||||
#define SPA_POD_PROP_N_VALUES(prop) (((prop)->pod.size - sizeof(struct spa_pod_prop_body)) / (prop)->body.value.size)
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
struct spa_pod_prop_body {
|
||||
uint32_t key; /**< key of property, list of valid keys depends on the
|
||||
* object type */
|
||||
#define SPA_POD_PROP_RANGE_NONE 0 /**< no range */
|
||||
#define SPA_POD_PROP_RANGE_MIN_MAX 1 /**< property has range */
|
||||
#define SPA_POD_PROP_RANGE_STEP 2 /**< property has range with step */
|
||||
#define SPA_POD_PROP_RANGE_ENUM 3 /**< property has enumeration */
|
||||
#define SPA_POD_PROP_RANGE_FLAGS 4 /**< property has flags */
|
||||
#define SPA_POD_PROP_RANGE_MASK 0xf /**< mask to select range type */
|
||||
#define SPA_POD_PROP_FLAG_UNSET (1 << 4) /**< property value is unset */
|
||||
#define SPA_POD_PROP_FLAG_OPTIONAL (1 << 5) /**< property value is optional */
|
||||
#define SPA_POD_PROP_FLAG_READONLY (1 << 6) /**< property is readonly */
|
||||
#define SPA_POD_PROP_FLAG_DEPRECATED (1 << 7) /**< property is deprecated */
|
||||
#define SPA_POD_PROP_FLAG_INFO (1 << 8) /**< property is informational and is not
|
||||
* used when filtering */
|
||||
#define SPA_POD_PROP_FLAG_CONTROLLABLE (1 << 9) /**< property can be controlled */
|
||||
uint32_t flags;
|
||||
struct spa_pod value;
|
||||
/* array with elements of value.size follows,
|
||||
* first element is value/default, rest are alternatives */
|
||||
};
|
||||
#define SPA_POD_PROP_SIZE(prop) (sizeof(struct spa_pod_prop) + (prop)->value.size)
|
||||
|
||||
struct spa_pod_prop {
|
||||
struct spa_pod pod;
|
||||
struct spa_pod_prop_body body;
|
||||
uint32_t key; /**< key of property, list of valid keys depends on the
|
||||
* object type */
|
||||
#define SPA_POD_PROP_FLAG_OPTIONAL (1 << 0) /**< property value is optional */
|
||||
#define SPA_POD_PROP_FLAG_READONLY (1 << 1) /**< property is readonly */
|
||||
#define SPA_POD_PROP_FLAG_DEPRECATED (1 << 2) /**< property is deprecated */
|
||||
#define SPA_POD_PROP_FLAG_INFO (1 << 3) /**< property is informational and is not
|
||||
* used when filtering */
|
||||
#define SPA_POD_PROP_FLAG_CONTROLLABLE (1 << 4) /**< property can be controlled */
|
||||
uint32_t flags;
|
||||
struct spa_pod value;
|
||||
/* value follows */
|
||||
};
|
||||
|
||||
#define SPA_POD_CONTROL_SIZE(ev) (sizeof(struct spa_pod_control) + (ev)->value.size)
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ extern "C" {
|
|||
#define SPA_TYPE_ROOT spa_types
|
||||
#endif
|
||||
|
||||
|
||||
static inline bool spa_type_is_a(const char *type, const char *parent)
|
||||
{
|
||||
return type != NULL && parent != NULL && strncmp(type, parent, strlen(parent)) == 0;
|
||||
|
|
@ -77,12 +76,25 @@ struct spa_type_info {
|
|||
#include <spa/param/type-info.h>
|
||||
#include <spa/control/type-info.h>
|
||||
|
||||
/* base for parameter object enumerations */
|
||||
#define SPA_TYPE__Choice SPA_TYPE_ENUM_BASE "Choice"
|
||||
#define SPA_TYPE_CHOICE_BASE SPA_TYPE__Choice ":"
|
||||
|
||||
static const struct spa_type_info spa_type_choice[] = {
|
||||
{ SPA_CHOICE_None, SPA_TYPE_CHOICE_BASE "None", SPA_TYPE_Int, },
|
||||
{ SPA_CHOICE_Range, SPA_TYPE_CHOICE_BASE "Range", SPA_TYPE_Int, },
|
||||
{ SPA_CHOICE_Step, SPA_TYPE_CHOICE_BASE "Step", SPA_TYPE_Int, },
|
||||
{ SPA_CHOICE_Enum, SPA_TYPE_CHOICE_BASE "Enum", SPA_TYPE_Int, },
|
||||
{ SPA_CHOICE_Flags, SPA_TYPE_CHOICE_BASE "Flags", SPA_TYPE_Int, },
|
||||
{ 0, NULL, }
|
||||
};
|
||||
|
||||
static const struct spa_type_info spa_types[] = {
|
||||
/* Basic types */
|
||||
{ SPA_TYPE_START, SPA_TYPE_BASE, SPA_TYPE_START, },
|
||||
{ SPA_TYPE_None, SPA_TYPE_BASE "None", SPA_TYPE_None, },
|
||||
{ SPA_TYPE_Bool, SPA_TYPE_BASE "Bool", SPA_TYPE_Bool, },
|
||||
{ SPA_TYPE_Enum, SPA_TYPE__Enum, SPA_TYPE_Int, },
|
||||
{ SPA_TYPE_Id, SPA_TYPE_BASE "Id", SPA_TYPE_Int, },
|
||||
{ SPA_TYPE_Int, SPA_TYPE_BASE "Int", SPA_TYPE_Int, },
|
||||
{ SPA_TYPE_Long, SPA_TYPE_BASE "Long", SPA_TYPE_Long, },
|
||||
{ SPA_TYPE_Float, SPA_TYPE_BASE "Float", SPA_TYPE_Float, },
|
||||
|
|
@ -99,7 +111,7 @@ static const struct spa_type_info spa_types[] = {
|
|||
{ SPA_TYPE_Sequence, SPA_TYPE_POD_BASE "Sequence", SPA_TYPE_Pod, },
|
||||
{ SPA_TYPE_Pointer, SPA_TYPE__Pointer, SPA_TYPE_Pointer, },
|
||||
{ SPA_TYPE_Fd, SPA_TYPE_BASE "Fd", SPA_TYPE_Fd, },
|
||||
{ SPA_TYPE_Prop, SPA_TYPE_POD_BASE "Prop", SPA_TYPE_Pod, },
|
||||
{ SPA_TYPE_Choice, SPA_TYPE_POD_BASE "Choice", SPA_TYPE_Pod, },
|
||||
|
||||
{ SPA_TYPE_POINTER_START, SPA_TYPE__Pointer, SPA_TYPE_Pointer, },
|
||||
{ SPA_TYPE_POINTER_Buffer, SPA_TYPE_POINTER_BASE "Buffer", SPA_TYPE_Pointer, },
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ enum {
|
|||
SPA_TYPE_START = 0x00000,
|
||||
SPA_TYPE_None,
|
||||
SPA_TYPE_Bool,
|
||||
SPA_TYPE_Enum,
|
||||
SPA_TYPE_Id,
|
||||
SPA_TYPE_Int,
|
||||
SPA_TYPE_Long,
|
||||
SPA_TYPE_Float,
|
||||
|
|
@ -47,7 +47,7 @@ enum {
|
|||
SPA_TYPE_Sequence,
|
||||
SPA_TYPE_Pointer,
|
||||
SPA_TYPE_Fd,
|
||||
SPA_TYPE_Prop,
|
||||
SPA_TYPE_Choice,
|
||||
SPA_TYPE_Pod,
|
||||
|
||||
/* Pointers */
|
||||
|
|
@ -91,9 +91,9 @@ enum {
|
|||
SPA_TYPE_OBJECT_ParamIO,
|
||||
|
||||
/* vendor extensions */
|
||||
SPA_TYPE_VENDOR_PipeWire = 0x01000000,
|
||||
SPA_TYPE_VENDOR_PipeWire = 0x02000000,
|
||||
|
||||
SPA_TYPE_VENDOR_Other = 0x7f000000,
|
||||
SPA_TYPE_VENDOR_Other = 0x7f000000,
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue