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

@ -37,7 +37,7 @@ spa_debug_format_value(const struct spa_type_info *info,
case SPA_TYPE_Bool: case SPA_TYPE_Bool:
fprintf(stderr, "%s", *(int32_t *) body ? "true" : "false"); fprintf(stderr, "%s", *(int32_t *) body ? "true" : "false");
break; break;
case SPA_TYPE_Enum: case SPA_TYPE_Id:
{ {
const char *str = spa_debug_type_find_name(info, *(int32_t *) body); const char *str = spa_debug_type_find_name(info, *(int32_t *) body);
char tmp[64]; char tmp[64];
@ -85,6 +85,20 @@ spa_debug_format_value(const struct spa_type_info *info,
case SPA_TYPE_Bytes: case SPA_TYPE_Bytes:
fprintf(stderr, "Bytes"); fprintf(stderr, "Bytes");
break; 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: default:
fprintf(stderr, "INVALID type %d", type); fprintf(stderr, "INVALID type %d", type);
break; break;
@ -98,12 +112,12 @@ static inline int spa_debug_format(int indent,
int i; int i;
const char *media_type; const char *media_type;
const char *media_subtype; const char *media_subtype;
struct spa_pod *pod; struct spa_pod_prop *prop;
uint32_t mtype, mstype; uint32_t mtype, mstype;
const char *pod_type_names[] = { const char *pod_type_names[] = {
[SPA_TYPE_None] = "none", [SPA_TYPE_None] = "none",
[SPA_TYPE_Bool] = "bool", [SPA_TYPE_Bool] = "bool",
[SPA_TYPE_Enum] = "enum", [SPA_TYPE_Id] = "id",
[SPA_TYPE_Int] = "int", [SPA_TYPE_Int] = "int",
[SPA_TYPE_Long] = "long", [SPA_TYPE_Long] = "long",
[SPA_TYPE_Float] = "float", [SPA_TYPE_Float] = "float",
@ -118,7 +132,7 @@ static inline int spa_debug_format(int indent,
[SPA_TYPE_Object] = "object", [SPA_TYPE_Object] = "object",
[SPA_TYPE_Pointer] = "pointer", [SPA_TYPE_Pointer] = "pointer",
[SPA_TYPE_Fd] = "fd", [SPA_TYPE_Fd] = "fd",
[SPA_TYPE_Prop] = "prop", [SPA_TYPE_Choice] = "choice",
[SPA_TYPE_Pod] = "pod" [SPA_TYPE_Pod] = "pod"
}; };
@ -138,50 +152,45 @@ static inline int spa_debug_format(int indent,
media_type ? rindex(media_type, ':') + 1 : "unknown", media_type ? rindex(media_type, ':') + 1 : "unknown",
media_subtype ? rindex(media_subtype, ':') + 1 : "unknown"); media_subtype ? rindex(media_subtype, ':') + 1 : "unknown");
SPA_POD_OBJECT_FOREACH((struct spa_pod_object*)format, pod) { SPA_POD_OBJECT_FOREACH((struct spa_pod_object*)format, prop) {
struct spa_pod_prop *prop;
const char *key; const char *key;
const struct spa_type_info *ti; 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; 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) && type = val->type;
(prop->body.flags & SPA_POD_PROP_FLAG_OPTIONAL)) size = val->size;
continue; vals = SPA_POD_BODY(val);
if (prop->body.key == SPA_FORMAT_mediaType || ti = spa_debug_type_find(info, prop->key);
prop->body.key == SPA_FORMAT_mediaSubtype)
continue;
ti = spa_debug_type_find(info, prop->body.key);
key = ti ? ti->name : NULL; key = ti ? ti->name : NULL;
fprintf(stderr, "%*s %16s : (%s) ", indent, "", fprintf(stderr, "%*s %16s : (%s) ", indent, "",
key ? rindex(key, ':') + 1 : "unknown", 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)) { if (choice == SPA_CHOICE_None) {
spa_debug_format_value(ti->values, spa_debug_format_value(ti->values, type, vals, size);
prop->body.value.type,
SPA_POD_BODY(&prop->body.value),
prop->body.value.size);
} else { } else {
const char *ssep, *esep, *sep; const char *ssep, *esep, *sep;
void *alt;
switch (prop->body.flags & SPA_POD_PROP_RANGE_MASK) { switch (choice) {
case SPA_POD_PROP_RANGE_MIN_MAX: case SPA_CHOICE_Range:
case SPA_POD_PROP_RANGE_STEP: case SPA_CHOICE_Step:
ssep = "[ "; ssep = "[ ";
sep = ", "; sep = ", ";
esep = " ]"; esep = " ]";
break; break;
default: default:
case SPA_POD_PROP_RANGE_ENUM: case SPA_CHOICE_Enum:
case SPA_POD_PROP_RANGE_FLAGS: case SPA_CHOICE_Flags:
ssep = "{ "; ssep = "{ ";
sep = ", "; sep = ", ";
esep = " }"; esep = " }";
@ -190,15 +199,11 @@ static inline int spa_debug_format(int indent,
fprintf(stderr, "%s", ssep); fprintf(stderr, "%s", ssep);
i = 0; for (i = 1; i < n_vals; i++) {
SPA_POD_PROP_ALTERNATIVE_FOREACH(&prop->body, prop->pod.size, alt) { vals = SPA_MEMBER(vals, size, void);
if (i > 0) if (i > 1)
fprintf(stderr, "%s", sep); fprintf(stderr, "%s", sep);
spa_debug_format_value(ti->values, spa_debug_format_value(ti->values, type, vals, size);
prop->body.value.type,
alt,
prop->body.value.size);
i++;
} }
fprintf(stderr, "%s", esep); fprintf(stderr, "%s", esep);
} }

View file

@ -33,6 +33,73 @@ extern "C" {
#define spa_debug(...) ({ fprintf(stderr, __VA_ARGS__);fputc('\n', stderr); }) #define spa_debug(...) ({ fprintf(stderr, __VA_ARGS__);fputc('\n', stderr); })
#endif #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 static inline int
spa_debug_pod_value(int indent, const struct spa_type_info *info, spa_debug_pod_value(int indent, const struct spa_type_info *info,
uint32_t type, void *body, uint32_t size) 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: case SPA_TYPE_Bool:
spa_debug("%*s" "Bool %d", indent, "", *(int32_t *) body); spa_debug("%*s" "Bool %d", indent, "", *(int32_t *) body);
break; break;
case SPA_TYPE_Enum: case SPA_TYPE_Id:
spa_debug("%*s" "Enum %d (%s)", indent, "", *(int32_t *) body, spa_debug("%*s" "Id %d (%s)", indent, "", *(int32_t *) body,
spa_debug_type_find_name(info, *(int32_t *) body)); spa_debug_type_find_name(info, *(int32_t *) body));
break; break;
case SPA_TYPE_Int: 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; struct spa_pod_array_body *b = body;
void *p; 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, "", spa_debug("%*s" "Array: child.size %d, child.type %s", indent, "",
b->child.size, ti ? ti->name : "unknown"); b->child.size, ti ? ti->name : "unknown");
info = ti ? ti->values : info;
SPA_POD_ARRAY_BODY_FOREACH(b, size, p) SPA_POD_ARRAY_BODY_FOREACH(b, size, p)
spa_debug_pod_value(indent + 2, info, b->child.type, p, b->child.size); spa_debug_pod_value(indent + 2, info, b->child.type, p, b->child.size);
break; 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: case SPA_TYPE_Struct:
{ {
struct spa_pod *b = body, *p; 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: case SPA_TYPE_Object:
{ {
struct spa_pod_object_body *b = body; struct spa_pod_object_body *b = body;
struct spa_pod *p; struct spa_pod_prop *p;
const struct spa_type_info *ti, *ii; const struct spa_type_info *ti, *ii;
ti = spa_debug_type_find(info, b->type); 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; info = ti ? ti->values : info;
SPA_POD_OBJECT_BODY_FOREACH(b, size, p) SPA_POD_OBJECT_BODY_FOREACH(b, size, p) {
spa_debug_pod_value(indent + 2, info, ii = spa_debug_type_find(info, p->key);
p->type, SPA_POD_BODY(p), p->size);
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; break;
} }
case SPA_TYPE_Sequence: 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, "", spa_debug("%*s" "Control: offset %d, type %s", indent+2, "",
c->offset, ii ? ii->name : "unknown"); c->offset, ii ? ii->name : "unknown");
spa_debug_pod_value(indent + 2, info, spa_debug_pod_value(indent + 4, ii->values,
c->value.type, c->value.type,
SPA_POD_CONTENTS(struct spa_pod_control, c), SPA_POD_CONTENTS(struct spa_pod_control, c),
c->value.size); c->value.size);
} }
break; 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: case SPA_TYPE_Bytes:
spa_debug("%*s" "Bytes", indent, ""); spa_debug("%*s" "Bytes", indent, "");
spa_debug_mem(indent + 2, body, size); spa_debug_mem(indent + 2, body, size);

View file

@ -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[] = { 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, }, { 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[] = { 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_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_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_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_type_monitor_item_state },
{ SPA_MONITOR_ITEM_name, SPA_TYPE_MONITOR_ITEM_BASE "name", SPA_TYPE_String, }, { 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, }, { SPA_MONITOR_ITEM_class, SPA_TYPE_MONITOR_ITEM_BASE "class", SPA_TYPE_String, },

View file

@ -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[] = { 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, }, { 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[] = { 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, }, { 0, NULL, },
}; };

View file

@ -47,12 +47,13 @@ spa_format_audio_raw_build(struct spa_pod_builder *builder, uint32_t id, struct
{ {
return spa_pod_builder_object(builder, return spa_pod_builder_object(builder,
SPA_TYPE_OBJECT_Format, id, SPA_TYPE_OBJECT_Format, id,
":", SPA_FORMAT_mediaType, "I", SPA_MEDIA_TYPE_audio, SPA_FORMAT_mediaType, &SPA_POD_Id(SPA_MEDIA_TYPE_audio),
":", SPA_FORMAT_mediaSubtype, "I", SPA_MEDIA_SUBTYPE_raw, SPA_FORMAT_mediaSubtype, &SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw),
":", SPA_FORMAT_AUDIO_format, "I", info->format, SPA_FORMAT_AUDIO_format, &SPA_POD_Id(info->format),
":", SPA_FORMAT_AUDIO_layout, "I", info->layout, SPA_FORMAT_AUDIO_layout, &SPA_POD_Id(info->layout),
":", SPA_FORMAT_AUDIO_rate, "i", info->rate, SPA_FORMAT_AUDIO_rate, &SPA_POD_Int(info->rate),
":", SPA_FORMAT_AUDIO_channels, "i", info->channels); SPA_FORMAT_AUDIO_channels, &SPA_POD_Int(info->channels),
0);
} }
#ifdef __cplusplus #ifdef __cplusplus

View file

@ -56,8 +56,8 @@ static const struct spa_type_info spa_type_param[] = {
#define SPA_TYPE_PARAM_LIST_BASE SPA_TYPE_PARAM__List ":" #define SPA_TYPE_PARAM_LIST_BASE SPA_TYPE_PARAM__List ":"
static const struct spa_type_info 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_START, SPA_TYPE_PARAM_LIST_BASE, SPA_TYPE_Id, spa_type_param },
{ SPA_PARAM_LIST_id, SPA_TYPE_PARAM_LIST_BASE "id", SPA_TYPE_Enum, spa_type_param }, { SPA_PARAM_LIST_id, SPA_TYPE_PARAM_LIST_BASE "id", SPA_TYPE_Id, spa_type_param },
{ 0, NULL, }, { 0, NULL, },
}; };
@ -65,7 +65,7 @@ static const struct spa_type_info spa_type_param_list[] = {
#define SPA_TYPE_PROPS_BASE SPA_TYPE__Props ":" #define SPA_TYPE_PROPS_BASE SPA_TYPE__Props ":"
static const struct spa_type_info 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_unknown, SPA_TYPE_PROPS_BASE "unknown", SPA_TYPE_None, },
{ SPA_PROP_device, SPA_TYPE_PROPS_BASE "device", SPA_TYPE_String, }, { SPA_PROP_device, SPA_TYPE_PROPS_BASE "device", SPA_TYPE_String, },
{ SPA_PROP_deviceName, SPA_TYPE_PROPS_BASE "deviceName", 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_periodSize, SPA_TYPE_PROPS_BASE "periodSize", SPA_TYPE_Int, },
{ SPA_PROP_periodEvent, SPA_TYPE_PROPS_BASE "periodEvent", SPA_TYPE_Bool, }, { SPA_PROP_periodEvent, SPA_TYPE_PROPS_BASE "periodEvent", SPA_TYPE_Bool, },
{ SPA_PROP_live, SPA_TYPE_PROPS_BASE "live", 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_frequency, SPA_TYPE_PROPS_BASE "frequency", SPA_TYPE_Int, },
{ SPA_PROP_volume, SPA_TYPE_PROPS_BASE "volume", SPA_TYPE_Float, }, { SPA_PROP_volume, SPA_TYPE_PROPS_BASE "volume", SPA_TYPE_Float, },
{ SPA_PROP_mute, SPA_TYPE_PROPS_BASE "mute", SPA_TYPE_Bool, }, { SPA_PROP_mute, SPA_TYPE_PROPS_BASE "mute", SPA_TYPE_Bool, },
{ SPA_PROP_patternType, SPA_TYPE_PROPS_BASE "patternType", SPA_TYPE_Enum, }, { SPA_PROP_patternType, SPA_TYPE_PROPS_BASE "patternType", SPA_TYPE_Id, },
{ SPA_PROP_ditherType, SPA_TYPE_PROPS_BASE "ditherType", SPA_TYPE_Enum, }, { SPA_PROP_ditherType, SPA_TYPE_PROPS_BASE "ditherType", SPA_TYPE_Id, },
{ SPA_PROP_truncate, SPA_TYPE_PROPS_BASE "truncate", SPA_TYPE_Bool, }, { SPA_PROP_truncate, SPA_TYPE_PROPS_BASE "truncate", SPA_TYPE_Bool, },
{ SPA_PROP_brightness, SPA_TYPE_PROPS_BASE "brightness", SPA_TYPE_Int, }, { SPA_PROP_brightness, SPA_TYPE_PROPS_BASE "brightness", SPA_TYPE_Int, },
{ SPA_PROP_contrast, SPA_TYPE_PROPS_BASE "contrast", 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 ":" #define SPA_TYPE_PROP_INFO_BASE SPA_TYPE__PropInfo ":"
static const struct spa_type_info spa_type_prop_info[] = { 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_START, SPA_TYPE_PROP_INFO_BASE, SPA_TYPE_Id, spa_type_param, },
{ SPA_PROP_INFO_id, SPA_TYPE_PROP_INFO_BASE "id", SPA_TYPE_Enum, spa_type_props }, { 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_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, }, { SPA_PROP_INFO_labels, SPA_TYPE_PROP_INFO_BASE "labels", SPA_TYPE_Struct, },
{ 0, NULL, }, { 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 ":" #define SPA_TYPE_PARAM_META_BASE SPA_TYPE_PARAM__Meta ":"
static const struct spa_type_info 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_START, SPA_TYPE_PARAM_META_BASE, SPA_TYPE_Id, spa_type_param, },
{ SPA_PARAM_META_type, SPA_TYPE_PARAM_META_BASE "type", SPA_TYPE_Enum, }, { 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, }, { SPA_PARAM_META_size, SPA_TYPE_PARAM_META_BASE "size", SPA_TYPE_Int, },
{ 0, NULL, }, { 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 ":" #define SPA_TYPE_PARAM_IO_BASE SPA_TYPE_PARAM__IO ":"
static const struct spa_type_info 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_START, SPA_TYPE_PARAM_IO_BASE, SPA_TYPE_Id, spa_type_param, },
{ SPA_PARAM_IO_id, SPA_TYPE_PARAM_IO_BASE "id", SPA_TYPE_Enum, spa_type_io }, { 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, }, { SPA_PARAM_IO_size, SPA_TYPE_PARAM_IO_BASE "size", SPA_TYPE_Int, },
{ 0, NULL, }, { 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 ":" #define SPA_TYPE_FORMAT_VIDEO_BASE SPA_TYPE__FormatVideo ":"
static const struct spa_type_info spa_type_format[] = { 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_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_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_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_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_type_audio_layout },
{ SPA_FORMAT_AUDIO_rate, SPA_TYPE_FORMAT_AUDIO_BASE "rate", SPA_TYPE_Int, }, { 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_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_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_type_video_format, },
{ SPA_FORMAT_VIDEO_size, SPA_TYPE_FORMAT_VIDEO_BASE "size", SPA_TYPE_Rectangle, }, { 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, }, { 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 ":" #define SPA_TYPE_PARAM_BLOCK_INFO_BASE SPA_TYPE_PARAM__BlockInfo ":"
static const struct spa_type_info spa_type_param_buffers[] = { 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_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_blocks, SPA_TYPE_PARAM_BUFFERS_BASE "blocks", SPA_TYPE_Int, },
{ SPA_PARAM_BUFFERS_size, SPA_TYPE_PARAM_BLOCK_INFO_BASE "size", SPA_TYPE_Int, }, { SPA_PARAM_BUFFERS_size, SPA_TYPE_PARAM_BLOCK_INFO_BASE "size", SPA_TYPE_Int, },

View file

@ -56,11 +56,12 @@ spa_format_video_raw_build(struct spa_pod_builder *builder, uint32_t id,
{ {
return spa_pod_builder_object(builder, return spa_pod_builder_object(builder,
SPA_TYPE_OBJECT_Format, id, SPA_TYPE_OBJECT_Format, id,
":", SPA_FORMAT_mediaType, "I", SPA_MEDIA_TYPE_video, SPA_FORMAT_mediaType, &SPA_POD_Id(SPA_MEDIA_TYPE_video),
":", SPA_FORMAT_mediaSubtype, "I", SPA_MEDIA_SUBTYPE_raw, SPA_FORMAT_mediaSubtype, &SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw),
":", SPA_FORMAT_VIDEO_format, "I", &info->format, SPA_FORMAT_VIDEO_format, &SPA_POD_Id(info->format),
":", SPA_FORMAT_VIDEO_size, "R", &info->size, SPA_FORMAT_VIDEO_size, &SPA_POD_Rectangle(info->size),
":", SPA_FORMAT_VIDEO_framerate, "F", &info->framerate); SPA_FORMAT_VIDEO_framerate, &SPA_POD_Fraction(info->framerate),
0);
} }
static inline int static inline int

View file

@ -45,7 +45,7 @@ struct spa_pod_builder {
uint32_t size; uint32_t size;
uint32_t (*write) (struct spa_pod_builder *builder, const void *data, 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); void (*reset) (struct spa_pod_builder *builder, struct spa_pod_builder_state *state);
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 * 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) if (ref == SPA_ID_INVALID)
return NULL; return NULL;
else if (builder->deref) else if (builder->deref)
return builder->deref(builder, ref); return builder->deref(builder, ref, safe);
else if (ref + 8 <= builder->size) { else if (ref + 8 <= builder->size) {
struct spa_pod *pod = SPA_MEMBER(builder->data, ref, struct spa_pod); 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 (void *) pod;
} }
return NULL; 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 static inline uint32_t
spa_pod_builder_push(struct spa_pod_builder *builder, spa_pod_builder_push(struct spa_pod_builder *builder,
const struct spa_pod *pod, const struct spa_pod *pod,
@ -98,7 +104,7 @@ spa_pod_builder_push(struct spa_pod_builder *builder,
frame->pod = *pod; frame->pod = *pod;
frame->ref = ref; frame->ref = ref;
builder->state.in_array = builder->state.first = 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; return ref;
} }
@ -113,7 +119,7 @@ spa_pod_builder_raw(struct spa_pod_builder *builder, const void *data, uint32_t
} else { } else {
ref = builder->state.offset; ref = builder->state.offset;
if (ref + size > builder->size) if (ref + size > builder->size)
ref = -1; ref = SPA_ID_INVALID;
else else
memcpy(SPA_MEMBER(builder->data, ref, void), data, size); 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; struct spa_pod *pod;
frame = &builder->frame[--builder->state.depth]; 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; *pod = frame->pod;
top = builder->state.depth > 0 ? &builder->frame[builder->state.depth-1] : NULL; top = builder->state.depth > 0 ? &builder->frame[builder->state.depth-1] : NULL;
builder->state.in_array = (top && 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); spa_pod_builder_pad(builder, builder->state.offset);
return pod; 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 static inline uint32_t
spa_pod_builder_primitive(struct spa_pod_builder *builder, const struct spa_pod *p) spa_pod_builder_primitive(struct spa_pod_builder *builder, const struct spa_pod *p)
{ {
const void *data; const void *head, *body;
uint32_t size, ref; 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) { if (builder->state.in_array && !builder->state.first) {
data = SPA_POD_BODY_CONST(p); head = body;
size = SPA_POD_BODY_SIZE(p); head_size = body_size;
collect = false;
} else { } else {
data = p;
size = SPA_POD_SIZE(p);
builder->state.first = false; 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) if (!builder->state.in_array)
spa_pod_builder_pad(builder, size); spa_pod_builder_pad(builder, head_size);
return ref; 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) 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); 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) 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); 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); 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) 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); 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) 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); 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) 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); 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) 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); 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 static inline uint32_t
spa_pod_builder_write_string(struct spa_pod_builder *builder, const char *str, uint32_t len) 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 static inline uint32_t
spa_pod_builder_string_len(struct spa_pod_builder *builder, const char *str, uint32_t len) 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)); uint32_t ref = spa_pod_builder_raw(builder, &p, sizeof(p));
if (spa_pod_builder_write_string(builder, str, len) == SPA_ID_INVALID) if (spa_pod_builder_write_string(builder, str, len) == SPA_ID_INVALID)
ref = 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); 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 static inline uint32_t
spa_pod_builder_bytes(struct spa_pod_builder *builder, const void *bytes, uint32_t len) 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)); uint32_t ref = spa_pod_builder_raw(builder, &p, sizeof(p));
if (spa_pod_builder_raw_padded(builder, bytes, len) == SPA_ID_INVALID) if (spa_pod_builder_raw_padded(builder, bytes, len) == SPA_ID_INVALID)
ref = SPA_ID_INVALID; ref = SPA_ID_INVALID;
return ref; 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 static inline uint32_t
spa_pod_builder_pointer(struct spa_pod_builder *builder, uint32_t type, void *val) spa_pod_builder_pointer(struct spa_pod_builder *builder, uint32_t type, 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); 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) 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); 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 static inline uint32_t
spa_pod_builder_rectangle(struct spa_pod_builder *builder, uint32_t width, uint32_t height) 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); 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 static inline uint32_t
spa_pod_builder_fraction(struct spa_pod_builder *builder, uint32_t num, uint32_t denom) 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); return spa_pod_builder_primitive(builder, &p.pod);
} }
@ -337,48 +379,64 @@ spa_pod_builder_array(struct spa_pod_builder *builder,
return ref; 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 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); const struct spa_pod_choice p =
return spa_pod_builder_push(builder, &p.pod, { {sizeof(struct spa_pod_choice_body) - sizeof(struct spa_pod), SPA_TYPE_Choice},
spa_pod_builder_raw(builder, &p, sizeof(p))); { type, flags, {0, 0}} };
}
#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);
return spa_pod_builder_push(builder, &p.pod, return spa_pod_builder_push(builder, &p.pod,
spa_pod_builder_raw(builder, &p, spa_pod_builder_raw(builder, &p,
sizeof(p) - sizeof(struct spa_pod))); 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__ } (struct spa_pod_sequence){ { size, SPA_TYPE_Sequence}, {unit, 0 }, ##__VA_ARGS__ }
static inline uint32_t static inline uint32_t
spa_pod_builder_push_sequence(struct spa_pod_builder *builder, uint32_t unit) spa_pod_builder_push_sequence(struct spa_pod_builder *builder, uint32_t unit)
{ {
const struct spa_pod_sequence p = 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, return spa_pod_builder_push(builder, &p.pod,
spa_pod_builder_raw(builder, &p, sizeof(p))); 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)); 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) { switch (id) {
case 'r': case 'r':
return SPA_POD_PROP_RANGE_MIN_MAX; return SPA_CHOICE_Range;
case 's': case 's':
return SPA_POD_PROP_RANGE_STEP; return SPA_CHOICE_Step;
case 'e': case 'e':
return SPA_POD_PROP_RANGE_ENUM; return SPA_CHOICE_Enum;
case 'f': case 'f':
return SPA_POD_PROP_RANGE_FLAGS; return SPA_CHOICE_Flags;
case 'n':
default: default:
return SPA_POD_PROP_RANGE_NONE; return SPA_CHOICE_None;
} }
} }
static inline uint32_t spa_pod_flag_from_id(char id) static inline uint32_t spa_pod_flag_from_id(char id)
{ {
switch (id) { switch (id) {
case 'u':
return SPA_POD_PROP_FLAG_UNSET;
case 'o': case 'o':
return SPA_POD_PROP_FLAG_OPTIONAL; return SPA_POD_PROP_FLAG_OPTIONAL;
case 'r': case 'r':
@ -433,7 +490,7 @@ do { \
spa_pod_builder_bool(builder, va_arg(args, int)); \ spa_pod_builder_bool(builder, va_arg(args, int)); \
break; \ break; \
case 'I': \ case 'I': \
spa_pod_builder_enum(builder, va_arg(args, uint32_t)); \ spa_pod_builder_id(builder, va_arg(args, uint32_t)); \
break; \ break; \
case 'i': \ case 'i': \
spa_pod_builder_int(builder, va_arg(args, int)); \ 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) const char *format, va_list args)
{ {
while (format) { while (format) {
char t = *format; int n_values = 1;
next: bool do_pop = false;
switch (t) { switch (*format) {
case '{': case '{':
{ {
uint32_t type = va_arg(args, uint32_t); 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); spa_pod_builder_control_header(builder, offset, type);
break; 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 ':': case ':':
{ {
int n_values; uint32_t key, flags = 0;
uint32_t key, flags;
key = va_arg(args, uint32_t); key = va_arg(args, uint32_t);
format = va_arg(args, const char *); for (format++;*format;format++)
t = *format;
if (*format != '\0')
format++;
flags = spa_pod_range_from_id(*format);
if (*format != '\0')
format++;
for (;*format;format++)
SPA_FLAG_SET(flags, spa_pod_flag_from_id(*format)); SPA_FLAG_SET(flags, spa_pod_flag_from_id(*format));
spa_pod_builder_push_prop(builder, key, flags); spa_pod_builder_prop(builder, key, flags);
break;
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;
} }
case ']': case ')': case '>': case '}': case ']': case ')': case '>': case '}':
spa_pod_builder_pop(builder); 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; break;
case ' ': case '\n': case '\t': case '\r': case ' ': case '\n': case '\t': case '\r':
break; break;
@ -599,13 +644,17 @@ spa_pod_builder_addv(struct spa_pod_builder *builder,
format = va_arg(args, const char *); format = va_arg(args, const char *);
continue; continue;
default: 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;; break;;
} }
if (*format != '\0') if (*format != '\0')
format++; 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, ...) 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; 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,...) \ #define SPA_POD_OBJECT(type,id,...) \
"{", type, id, ##__VA_ARGS__, "}" "{", type, id, ##__VA_ARGS__, "}"
#define SPA_POD_STRUCT(...) \ #define SPA_POD_STRUCT(...) \
"[", ##__VA_ARGS__, "]" "[", ##__VA_ARGS__, "]"
#define SPA_POD_PROP(key,spec,type,value,...) \ #define SPA_POD_PROP(key,spec,value,...) \
":", key, spec, value, ##__VA_ARGS__ ":", key, spec, value, ##__VA_ARGS__
#define SPA_POD_SEQUENCE(unit,...) \ #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,...) \ #define SPA_POD_CONTROL(offset,type,...) \
".", offset, type, ##__VA_ARGS__ ".", offset, type, ##__VA_ARGS__
#define SPA_POD_PROP_MIN_MAX(min,max) 2,(min),(max) #define spa_pod_builder_add_object(b,type,id,...) \
#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,...) \
spa_pod_builder_add(b, SPA_POD_OBJECT(type,id,##__VA_ARGS__), NULL) 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) 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) 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 #ifdef __cplusplus
} /* extern "C" */ } /* extern "C" */
#endif #endif

View file

@ -33,7 +33,7 @@ static inline int spa_pod_compare_value(uint32_t type, const void *r1, const voi
case SPA_TYPE_None: case SPA_TYPE_None:
return 0; return 0;
case SPA_TYPE_Bool: case SPA_TYPE_Bool:
case SPA_TYPE_Enum: case SPA_TYPE_Id:
return *(int32_t *) r1 == *(uint32_t *) r2 ? 0 : 1; return *(int32_t *) r1 == *(uint32_t *) r2 ? 0 : 1;
case SPA_TYPE_Int: case SPA_TYPE_Int:
return *(int32_t *) r1 - *(int32_t *) r2; 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; do_advance = true;
break; 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: default:
if (SPA_POD_TYPE(p1) != SPA_POD_TYPE(p2)) if (SPA_POD_TYPE(p1) != SPA_POD_TYPE(p2))
return -EINVAL; return -EINVAL;

View file

@ -28,49 +28,57 @@
#include <spa/pod/builder.h> #include <spa/pod/builder.h>
#include <spa/pod/compare.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), void *val, *alt;
*alt = SPA_MEMBER(val, prop->body.value.size, void); int i, nvals;
int i, nalt = SPA_POD_PROP_N_VALUES(prop) - 1; uint32_t type, size;
switch (prop->body.flags & SPA_POD_PROP_RANGE_MASK) { nvals = SPA_POD_CHOICE_N_VALUES(choice);
case SPA_POD_PROP_RANGE_NONE: 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; break;
case SPA_POD_PROP_RANGE_MIN_MAX: case SPA_CHOICE_Range:
case SPA_POD_PROP_RANGE_STEP: case SPA_CHOICE_Step:
if (spa_pod_compare_value(prop->body.value.type, val, alt) < 0) if (nvals > 1) {
memcpy(val, alt, prop->body.value.size); alt = SPA_MEMBER(alt, size, void);
alt = SPA_MEMBER(alt, prop->body.value.size, void); if (spa_pod_compare_value(type, val, alt) < 0)
if (spa_pod_compare_value(prop->body.value.type, val, alt) > 0) memcpy(val, alt, size);
memcpy(val, alt, prop->body.value.size); }
if (nvals > 2) {
alt = SPA_MEMBER(alt, size, void);
if (spa_pod_compare_value(type, val, alt) > 0)
memcpy(val, alt, size);
}
break; break;
case SPA_POD_PROP_RANGE_ENUM: case SPA_CHOICE_Enum:
{ {
void *best = NULL; void *best = NULL;
for (i = 0; i < nalt; i++) { for (i = 1; i < nvals; i++) {
if (spa_pod_compare_value(prop->body.value.type, val, alt) == 0) { alt = SPA_MEMBER(alt, size, void);
if (spa_pod_compare_value(type, val, alt) == 0) {
best = alt; best = alt;
break; break;
} }
if (best == NULL) if (best == NULL)
best = alt; best = alt;
alt = SPA_MEMBER(alt, prop->body.value.size, void);
} }
if (best) if (best)
memcpy(val, best, prop->body.value.size); memcpy(val, best, size);
if (nalt <= 1) { if (nvals <= 1)
prop->body.flags &= ~SPA_POD_PROP_FLAG_UNSET; choice->body.type = SPA_CHOICE_None;
prop->body.flags &= ~SPA_POD_PROP_RANGE_MASK;
prop->body.flags |= SPA_POD_PROP_RANGE_NONE;
}
break; break;
} }
case SPA_POD_PROP_RANGE_FLAGS: case SPA_CHOICE_Flags:
break; break;
} }
return 0;
} }
static inline int 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 *p1,
const struct spa_pod_prop *p2) const struct spa_pod_prop *p2)
{ {
struct spa_pod_prop *np; const struct spa_pod *v1, *v2;
int nalt1, nalt2; struct spa_pod_choice *nc;
uint32_t nalt1, nalt2;
void *alt1, *alt2, *a1, *a2; void *alt1, *alt2, *a1, *a2;
uint32_t rt1, rt2; uint32_t type, size, p1c, p2c;
int j, k; 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 */ /* 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; return -EINVAL;
rt1 = p1->body.flags & SPA_POD_PROP_RANGE_MASK; if (p1c == SPA_CHOICE_None) {
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 {
nalt1 = 1; 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) { if (p2c == SPA_CHOICE_None) {
alt2 = SPA_MEMBER(alt2, p2->body.value.size, void);
nalt2--;
} else {
nalt2 = 1; nalt2 = 1;
rt2 = SPA_POD_PROP_RANGE_NONE; } else {
alt2 = SPA_MEMBER(alt2, size, void);
nalt2--;
} }
/* start with copying the property */ /* 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 */ /* 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) || if ((p1c == SPA_CHOICE_None && p2c == SPA_CHOICE_None) ||
(rt1 == SPA_POD_PROP_RANGE_NONE && rt2 == SPA_POD_PROP_RANGE_ENUM) || (p1c == SPA_CHOICE_None && p2c == SPA_CHOICE_Enum) ||
(rt1 == SPA_POD_PROP_RANGE_ENUM && rt2 == SPA_POD_PROP_RANGE_NONE) || (p1c == SPA_CHOICE_Enum && p2c == SPA_CHOICE_None) ||
(rt1 == SPA_POD_PROP_RANGE_ENUM && rt2 == SPA_POD_PROP_RANGE_ENUM)) { (p1c == SPA_CHOICE_Enum && p2c == SPA_CHOICE_Enum)) {
int n_copied = 0; int n_copied = 0;
/* copy all equal values but don't copy the default value again */ /* 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 (j = 0, a1 = alt1; j < nalt1; j++, a1 += size) {
for (k = 0, a2 = alt2; k < nalt2; k++, a2 += p2->body.value.size) { for (k = 0, a2 = alt2; k < nalt2; k++, a2 += size) {
if (spa_pod_compare_value(p1->body.value.type, a1, a2) == 0) { if (spa_pod_compare_value(type, a1, a2) == 0) {
if (rt1 == SPA_POD_PROP_RANGE_ENUM || j > 0) if (p1c == SPA_CHOICE_Enum || j > 0)
spa_pod_builder_raw(b, a1, p1->body.value.size); spa_pod_builder_raw(b, a1, size);
n_copied++; n_copied++;
} }
} }
} }
if (n_copied == 0) if (n_copied == 0)
return -EINVAL; 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) || if ((p1c == SPA_CHOICE_None && p2c == SPA_CHOICE_Range) ||
(rt1 == SPA_POD_PROP_RANGE_ENUM && rt2 == SPA_POD_PROP_RANGE_MIN_MAX)) { (p1c == SPA_CHOICE_Enum && p2c == SPA_CHOICE_Range)) {
int n_copied = 0; int n_copied = 0;
/* copy all values inside the range */ /* copy all values inside the range */
for (j = 0, a1 = alt1, a2 = alt2; j < nalt1; j++, a1 += p1->body.value.size) { for (j = 0, a1 = alt1, a2 = alt2; j < nalt1; j++, a1 += size) {
if (spa_pod_compare_value(p1->body.value.type, a1, a2) < 0) if (spa_pod_compare_value(type, a1, a2) < 0)
continue; 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; continue;
spa_pod_builder_raw(b, a1, p1->body.value.size); spa_pod_builder_raw(b, a1, size);
n_copied++; n_copied++;
} }
if (n_copied == 0) if (n_copied == 0)
return -EINVAL; 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) || if ((p1c == SPA_CHOICE_None && p2c == SPA_CHOICE_Step) ||
(rt1 == SPA_POD_PROP_RANGE_ENUM && rt2 == SPA_POD_PROP_RANGE_STEP)) { (p1c == SPA_CHOICE_Enum && p2c == SPA_CHOICE_Step)) {
return -ENOTSUP; return -ENOTSUP;
} }
if ((rt1 == SPA_POD_PROP_RANGE_MIN_MAX && rt2 == SPA_POD_PROP_RANGE_NONE) || if ((p1c == SPA_CHOICE_Range && p2c == SPA_CHOICE_None) ||
(rt1 == SPA_POD_PROP_RANGE_MIN_MAX && rt2 == SPA_POD_PROP_RANGE_ENUM)) { (p1c == SPA_CHOICE_Range && p2c == SPA_CHOICE_Enum)) {
int n_copied = 0; int n_copied = 0;
/* copy all values inside the range */ /* copy all values inside the range */
for (k = 0, a1 = alt1, a2 = alt2; k < nalt2; k++, a2 += p2->body.value.size) { for (k = 0, a1 = alt1, a2 = alt2; k < nalt2; k++, a2 += size) {
if (spa_pod_compare_value(p1->body.value.type, a2, a1) < 0) if (spa_pod_compare_value(type, a2, a1) < 0)
continue; 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; continue;
spa_pod_builder_raw(b, a2, p2->body.value.size); spa_pod_builder_raw(b, a2, size);
n_copied++; n_copied++;
} }
if (n_copied == 0) if (n_copied == 0)
return -EINVAL; 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 (p1c == SPA_CHOICE_Range && p2c == SPA_CHOICE_Range) {
if (spa_pod_compare_value(p1->body.value.type, alt1, alt2) < 0) if (spa_pod_compare_value(type, alt1, alt2) < 0)
spa_pod_builder_raw(b, alt2, p2->body.value.size); spa_pod_builder_raw(b, alt2, size);
else else
spa_pod_builder_raw(b, alt1, p1->body.value.size); spa_pod_builder_raw(b, alt1, size);
alt1 += p1->body.value.size; alt1 += size;
alt2 += p2->body.value.size; alt2 += size;
if (spa_pod_compare_value(p1->body.value.type, alt1, alt2) < 0) if (spa_pod_compare_value(type, alt1, alt2) < 0)
spa_pod_builder_raw(b, alt1, p1->body.value.size); spa_pod_builder_raw(b, alt1, size);
else 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; return -ENOTSUP;
spa_pod_builder_pop(b); spa_pod_builder_pop(b);
spa_pod_prop_fix_default(np); spa_pod_choice_fix_default(nc);
return 0; return 0;
} }
@ -249,39 +257,50 @@ static inline int spa_pod_filter_part(struct spa_pod_builder *b,
uint32_t filter_offset = 0; uint32_t filter_offset = 0;
switch (SPA_POD_TYPE(pp)) { switch (SPA_POD_TYPE(pp)) {
case SPA_TYPE_Struct:
case SPA_TYPE_Object: case SPA_TYPE_Object:
if (pf != NULL) { 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)) if (SPA_POD_TYPE(pf) != SPA_POD_TYPE(pp))
return -EINVAL; return -EINVAL;
if (SPA_POD_TYPE(pp) == SPA_TYPE_Struct) { spa_pod_builder_push_object(b, obj->body.type, obj->body.id);
filter_offset = sizeof(struct spa_pod_struct); SPA_POD_OBJECT_FOREACH(obj, p1) {
spa_pod_builder_push_struct(b); p2 = spa_pod_find_prop(pf, p1->key);
} else { if (p2 != NULL)
struct spa_pod_object *p1 = (struct spa_pod_object *) pp; res = spa_pod_filter_prop(b, p1, p2);
filter_offset = sizeof(struct spa_pod_object); else
spa_pod_builder_push_object(b, p1->body.type, p1->body.id); spa_pod_builder_raw_padded(b, p1, SPA_POD_PROP_SIZE(p1));
if (res < 0)
break;
} }
spa_pod_builder_pop(b);
do_advance = true; do_advance = true;
} }
else else
do_copy = true; do_copy = true;
break; break;
case SPA_TYPE_Prop: case SPA_TYPE_Struct:
{ if (pf != NULL) {
struct spa_pod_prop *p1, *p2; if (SPA_POD_TYPE(pf) != SPA_POD_TYPE(pp))
return -EINVAL;
p1 = (struct spa_pod_prop *) pp; filter_offset = sizeof(struct spa_pod_struct);
p2 = spa_pod_contents_find_prop(filter, filter_size, p1->body.key); spa_pod_builder_push_struct(b);
res = spa_pod_filter_part(b,
if (p2 != NULL) SPA_MEMBER(pp,filter_offset,void),
res = spa_pod_filter_prop(b, p1, p2); 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 else
do_copy = true; do_copy = true;
break; break;
}
default: default:
if (pf != NULL) { if (pf != NULL) {
if (SPA_POD_SIZE(pp) != SPA_POD_SIZE(pf)) 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) if (do_copy)
spa_pod_builder_raw_padded(b, pp, SPA_POD_SIZE(pp)); 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) { if (do_advance) {
pf = spa_pod_next(pf); pf = spa_pod_next(pf);
if (!spa_pod_is_inside(filter, filter_size, pf)) if (!spa_pod_is_inside(filter, filter_size, pf))

View file

@ -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); 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) 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); 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((body), (_size), __typeof__(*(iter))); \
(iter) = SPA_MEMBER((iter), (body)->child.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) \ #define SPA_POD_FOREACH(pod, size, iter) \
for ((iter) = (pod); \ for ((iter) = (pod); \
spa_pod_is_inside(pod, size, iter); \ 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) SPA_POD_FOREACH(SPA_MEMBER((pod), (offset), void),SPA_POD_SIZE (pod)-(offset),iter)
#define SPA_POD_OBJECT_BODY_FOREACH(body, size, 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); \ 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) \ #define SPA_POD_OBJECT_FOREACH(obj, iter) \
SPA_POD_OBJECT_BODY_FOREACH(&(obj)->body, SPA_POD_BODY_SIZE(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) \ #define SPA_POD_SEQUENCE_FOREACH(seq, iter) \
SPA_POD_SEQUENCE_BODY_FOREACH(&(seq)->body, SPA_POD_BODY_SIZE(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) \ #define SPA_POD_PROP_ALTERNATIVE_FOREACH(body, _size, iter) \
for ((iter) = SPA_MEMBER((body), (body)->value.size + \ 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((body), (_size)-(body)->value.size, __typeof__(*iter)); \
(iter) = SPA_MEMBER((iter), (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, static inline struct spa_pod_prop *spa_pod_find_prop(const struct spa_pod *pod, uint32_t key)
uint32_t size, uint32_t key)
{ {
const struct spa_pod *res; struct spa_pod_prop *res;
SPA_POD_FOREACH(pod, size, res) { if (pod->type != SPA_TYPE_Object)
if (res->type == SPA_TYPE_Prop return NULL;
&& ((struct spa_pod_prop *) res)->body.key == key) SPA_POD_OBJECT_FOREACH((struct spa_pod_object*)pod, res) {
return (struct spa_pod_prop *) res; if (res->key == key)
return res;
} }
return NULL; 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) static inline int spa_pod_fixate(struct spa_pod *pod)
{ {
struct spa_pod *res; struct spa_pod_prop *res;
uint32_t offset;
if (pod->type == SPA_TYPE_Object) 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 -EINVAL; return -EINVAL;
SPA_POD_CONTENTS_FOREACH(pod, offset, res) { SPA_POD_OBJECT_FOREACH((struct spa_pod_object*)pod, res) {
if (res->type == SPA_TYPE_Prop) if (res->value.type == SPA_TYPE_Choice)
SPA_FLAG_UNSET (((struct spa_pod_prop *) res)->body.flags, ((struct spa_pod_choice*)&res->value)->body.type = SPA_CHOICE_None;
SPA_POD_PROP_FLAG_UNSET);
} }
return 0; return 0;
} }

View file

@ -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'; return type == 'T' || type == 'O' || type == 'V' || type == 's';
case SPA_TYPE_Bool: case SPA_TYPE_Bool:
return type == 'b'; return type == 'b';
case SPA_TYPE_Enum: case SPA_TYPE_Id:
return type == 'I'; return type == 'I';
case SPA_TYPE_Int: case SPA_TYPE_Int:
return type == 'i'; return type == 'i';
@ -87,8 +87,9 @@ static inline bool spa_pod_parser_can_collect(struct spa_pod *pod, char type)
return type == 'p'; return type == 'p';
case SPA_TYPE_Fd: case SPA_TYPE_Fd:
return type == 'h'; return type == 'h';
case SPA_TYPE_Prop: case SPA_TYPE_Choice:
return type == 'V'; return type == 'V' ||
spa_pod_parser_can_collect(SPA_POD_CHOICE_CHILD(pod), type);
default: default:
return false; return false;
} }
@ -146,7 +147,7 @@ do { \
{ \ { \
struct spa_pod_pointer_body *b = \ struct spa_pod_pointer_body *b = \
(struct spa_pod_pointer_body *) SPA_POD_BODY(pod); \ (struct spa_pod_pointer_body *) SPA_POD_BODY(pod); \
*(va_arg(args, void **)) = b->value; \ *(va_arg(args, const void **)) = b->value; \
break; \ break; \
} \ } \
case 'h': \ case 'h': \
@ -211,12 +212,7 @@ static inline int spa_pod_parser_getv(struct spa_pod_parser *parser,
case '{': case '{':
if (pod == NULL || SPA_POD_TYPE(pod) != SPA_TYPE_Object) if (pod == NULL || SPA_POD_TYPE(pod) != SPA_TYPE_Object)
return -EINVAL; return -EINVAL;
if (++parser->depth >= SPA_POD_MAX_DEPTH) break;
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;
case '[': case '[':
if (pod == NULL || SPA_POD_TYPE(pod) != SPA_TYPE_Struct) if (pod == NULL || SPA_POD_TYPE(pod) != SPA_TYPE_Struct)
return -EINVAL; return -EINVAL;
@ -226,12 +222,13 @@ static inline int spa_pod_parser_getv(struct spa_pod_parser *parser,
it = &parser->iter[parser->depth]; it = &parser->iter[parser->depth];
spa_pod_iter_init(it, pod, SPA_POD_SIZE(pod), sizeof(struct spa_pod_struct)); spa_pod_iter_init(it, pod, SPA_POD_SIZE(pod), sizeof(struct spa_pod_struct));
goto read_pod; goto read_pod;
case ']': case '}': case ']':
if (current != NULL) if (current != NULL)
return -EINVAL; return -EINVAL;
if (--parser->depth < 0) if (--parser->depth < 0)
return -EINVAL; return -EINVAL;
case '}':
it = &parser->iter[parser->depth]; it = &parser->iter[parser->depth];
current = spa_pod_iter_current(it); current = spa_pod_iter_current(it);
spa_pod_iter_advance(it, current); 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; const struct spa_pod *obj = (const struct spa_pod *) parser->iter[parser->depth].data;
prop = spa_pod_find_prop(obj, key); prop = spa_pod_find_prop(obj, key);
if (prop != NULL && (prop->body.flags & SPA_POD_PROP_FLAG_UNSET) == 0) if (prop != NULL)
pod = &prop->body.value; pod = &prop->value;
else else
pod = NULL; pod = NULL;
@ -275,6 +272,9 @@ static inline int spa_pod_parser_getv(struct spa_pod_parser *parser,
skip = true; skip = true;
} }
collect: collect:
if (pod->type == SPA_TYPE_Choice)
pod = SPA_POD_CHOICE_CHILD(pod);
if (suppress) if (suppress)
suppress = false; suppress = false;
else if (skip) else if (skip)

View file

@ -56,7 +56,7 @@ struct spa_pod_bool {
int32_t __padding; int32_t __padding;
}; };
struct spa_pod_enum { struct spa_pod_id {
struct spa_pod pod; struct spa_pod pod;
uint32_t value; uint32_t value;
int32_t __padding; int32_t __padding;
@ -109,8 +109,10 @@ struct spa_pod_bitmap {
/* array of uint8_t follows with the bitmap */ /* array of uint8_t follows with the bitmap */
}; };
#define SPA_POD_ARRAY_TYPE(arr) ((arr)->body.child.type) #define SPA_POD_ARRAY_CHILD(arr) (&((struct spa_pod_array*)(arr))->body.child)
#define SPA_POD_ARRAY_N_VALUES(arr) (((arr)->pod.size - sizeof(struct spa_pod_array_body)) / (arr)->body.child.size) #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_array_body {
struct spa_pod child; struct spa_pod child;
@ -122,6 +124,33 @@ struct spa_pod_array {
struct spa_pod_array_body body; 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_struct {
struct spa_pod pod; struct spa_pod pod;
/* one or more spa_pod follow */ /* 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 { struct spa_pod_pointer_body {
uint32_t type; /**< pointer id, one of enum spa_type */ uint32_t type; /**< pointer id, one of enum spa_type */
void *value; const void *value;
}; };
struct spa_pod_pointer { struct spa_pod_pointer {
@ -165,33 +194,33 @@ struct spa_pod_fd {
int value; 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 { #define SPA_POD_PROP_SIZE(prop) (sizeof(struct spa_pod_prop) + (prop)->value.size)
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 */
};
struct spa_pod_prop { struct spa_pod_prop {
struct spa_pod pod; uint32_t key; /**< key of property, list of valid keys depends on the
struct spa_pod_prop_body body; * 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) #define SPA_POD_CONTROL_SIZE(ev) (sizeof(struct spa_pod_control) + (ev)->value.size)

View file

@ -30,7 +30,6 @@ extern "C" {
#define SPA_TYPE_ROOT spa_types #define SPA_TYPE_ROOT spa_types
#endif #endif
static inline bool spa_type_is_a(const char *type, const char *parent) static inline bool spa_type_is_a(const char *type, const char *parent)
{ {
return type != NULL && parent != NULL && strncmp(type, parent, strlen(parent)) == 0; 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/param/type-info.h>
#include <spa/control/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[] = { static const struct spa_type_info spa_types[] = {
/* Basic types */ /* Basic types */
{ SPA_TYPE_START, SPA_TYPE_BASE, SPA_TYPE_START, }, { SPA_TYPE_START, SPA_TYPE_BASE, SPA_TYPE_START, },
{ SPA_TYPE_None, SPA_TYPE_BASE "None", SPA_TYPE_None, }, { SPA_TYPE_None, SPA_TYPE_BASE "None", SPA_TYPE_None, },
{ SPA_TYPE_Bool, SPA_TYPE_BASE "Bool", SPA_TYPE_Bool, }, { 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_Int, SPA_TYPE_BASE "Int", SPA_TYPE_Int, },
{ SPA_TYPE_Long, SPA_TYPE_BASE "Long", SPA_TYPE_Long, }, { SPA_TYPE_Long, SPA_TYPE_BASE "Long", SPA_TYPE_Long, },
{ SPA_TYPE_Float, SPA_TYPE_BASE "Float", SPA_TYPE_Float, }, { 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_Sequence, SPA_TYPE_POD_BASE "Sequence", SPA_TYPE_Pod, },
{ SPA_TYPE_Pointer, SPA_TYPE__Pointer, SPA_TYPE_Pointer, }, { SPA_TYPE_Pointer, SPA_TYPE__Pointer, SPA_TYPE_Pointer, },
{ SPA_TYPE_Fd, SPA_TYPE_BASE "Fd", SPA_TYPE_Fd, }, { 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_START, SPA_TYPE__Pointer, SPA_TYPE_Pointer, },
{ SPA_TYPE_POINTER_Buffer, SPA_TYPE_POINTER_BASE "Buffer", SPA_TYPE_Pointer, }, { SPA_TYPE_POINTER_Buffer, SPA_TYPE_POINTER_BASE "Buffer", SPA_TYPE_Pointer, },

View file

@ -31,7 +31,7 @@ enum {
SPA_TYPE_START = 0x00000, SPA_TYPE_START = 0x00000,
SPA_TYPE_None, SPA_TYPE_None,
SPA_TYPE_Bool, SPA_TYPE_Bool,
SPA_TYPE_Enum, SPA_TYPE_Id,
SPA_TYPE_Int, SPA_TYPE_Int,
SPA_TYPE_Long, SPA_TYPE_Long,
SPA_TYPE_Float, SPA_TYPE_Float,
@ -47,7 +47,7 @@ enum {
SPA_TYPE_Sequence, SPA_TYPE_Sequence,
SPA_TYPE_Pointer, SPA_TYPE_Pointer,
SPA_TYPE_Fd, SPA_TYPE_Fd,
SPA_TYPE_Prop, SPA_TYPE_Choice,
SPA_TYPE_Pod, SPA_TYPE_Pod,
/* Pointers */ /* Pointers */
@ -91,9 +91,9 @@ enum {
SPA_TYPE_OBJECT_ParamIO, SPA_TYPE_OBJECT_ParamIO,
/* vendor extensions */ /* vendor extensions */
SPA_TYPE_VENDOR_PipeWire = 0x01000000, SPA_TYPE_VENDOR_PipeWire = 0x02000000,
SPA_TYPE_VENDOR_Other = 0x7f000000, SPA_TYPE_VENDOR_Other = 0x7f000000,
}; };

View file

@ -32,6 +32,7 @@
#include <spa/support/loop.h> #include <spa/support/loop.h>
#include <spa/support/plugin.h> #include <spa/support/plugin.h>
#include <spa/monitor/monitor.h> #include <spa/monitor/monitor.h>
#include <spa/debug/pod.h>
#define NAME "alsa-monitor" #define NAME "alsa-monitor"
@ -112,6 +113,19 @@ static const char *path_get_card_id(const char *path)
return e + 5; return e + 5;
} }
static inline void add_dict(struct spa_pod_builder *builder, const char *key, ...)
{
va_list args;
va_start(args, key);
while (key) {
spa_pod_builder_string(builder, key);
spa_pod_builder_string(builder, va_arg(args, const char*));
key = va_arg(args, const char *);
}
va_end(args);
}
static int static int
fill_item(struct impl *this, snd_ctl_card_info_t *card_info, fill_item(struct impl *this, snd_ctl_card_info_t *card_info,
snd_pcm_info_t *dev_info, struct card *card, snd_pcm_info_t *dev_info, struct card *card,
@ -160,57 +174,59 @@ fill_item(struct impl *this, snd_ctl_card_info_t *card_info,
if (!(name && *name)) if (!(name && *name))
name = "Unknown"; name = "Unknown";
spa_pod_builder_add(builder, spa_pod_builder_push_object(builder, SPA_TYPE_OBJECT_MonitorItem, 0);
"{", SPA_TYPE_OBJECT_MonitorItem, 0, spa_pod_builder_props(builder,
":", SPA_MONITOR_ITEM_id, "s", id, SPA_MONITOR_ITEM_id, &SPA_POD_String(id, sizeof(id)),
":", SPA_MONITOR_ITEM_flags, "I", SPA_MONITOR_ITEM_FLAG_NONE, SPA_MONITOR_ITEM_flags, &SPA_POD_Id(SPA_MONITOR_ITEM_FLAG_NONE),
":", SPA_MONITOR_ITEM_state, "I", SPA_MONITOR_ITEM_STATE_Available, SPA_MONITOR_ITEM_state, &SPA_POD_Id(SPA_MONITOR_ITEM_STATE_Available),
":", SPA_MONITOR_ITEM_name, "s", name, SPA_MONITOR_ITEM_name, &SPA_POD_Stringv(name),
":", SPA_MONITOR_ITEM_class, "s", klass, SPA_MONITOR_ITEM_class, &SPA_POD_Stringv(klass),
":", SPA_MONITOR_ITEM_factory, "p", SPA_TYPE_INTERFACE_HandleFactory, factory, SPA_MONITOR_ITEM_factory, &SPA_POD_Pointer(SPA_TYPE_INTERFACE_HandleFactory, factory),
":", SPA_MONITOR_ITEM_info, "[", NULL); 0);
spa_pod_builder_add(builder, spa_pod_builder_prop(builder, SPA_MONITOR_ITEM_info, 0);
"s", "alsa.card", "s", card->name, spa_pod_builder_push_struct(builder),
"s", "alsa.device", "s", device_name, add_dict(builder,
"s", "alsa.card.id", "s", snd_ctl_card_info_get_id(card_info), "alsa.card", card->name,
"s", "alsa.card.components", "s", snd_ctl_card_info_get_components(card_info), "alsa.device", device_name,
"s", "alsa.card.driver", "s", snd_ctl_card_info_get_driver(card_info), "alsa.card.id", snd_ctl_card_info_get_id(card_info),
"s", "alsa.card.name", "s", snd_ctl_card_info_get_name(card_info), "alsa.card.components", snd_ctl_card_info_get_components(card_info),
"s", "alsa.card.longname", "s", snd_ctl_card_info_get_longname(card_info), "alsa.card.driver", snd_ctl_card_info_get_driver(card_info),
"s", "alsa.card.mixername", "s", snd_ctl_card_info_get_mixername(card_info), "alsa.card.name", snd_ctl_card_info_get_name(card_info),
"s", "udev-probed", "s", "1", "alsa.card.longname", snd_ctl_card_info_get_longname(card_info),
"s", "device.api", "s", "alsa", "alsa.card.mixername", snd_ctl_card_info_get_mixername(card_info),
"s", "device.name", "s", snd_ctl_card_info_get_id(card_info), "udev-probed", "1",
"s", "alsa.pcm.id", "s", snd_pcm_info_get_id(dev_info), "device.api", "alsa",
"s", "alsa.pcm.name", "s", snd_pcm_info_get_name(dev_info), "device.name", snd_ctl_card_info_get_id(card_info),
"s", "alsa.pcm.subname", "s", snd_pcm_info_get_subdevice_name(dev_info), "alsa.pcm.id", snd_pcm_info_get_id(dev_info),
"alsa.pcm.name", snd_pcm_info_get_name(dev_info),
"alsa.pcm.subname", snd_pcm_info_get_subdevice_name(dev_info),
NULL); NULL);
if ((str = udev_device_get_property_value(dev, "SOUND_CLASS")) && *str) { if ((str = udev_device_get_property_value(dev, "SOUND_CLASS")) && *str) {
spa_pod_builder_add(builder, "s", "device.class", "s", str, NULL); add_dict(builder, "device.class", str, NULL);
} }
str = udev_device_get_property_value(dev, "ID_PATH"); str = udev_device_get_property_value(dev, "ID_PATH");
if (!(str && *str)) if (!(str && *str))
str = udev_device_get_syspath(dev); str = udev_device_get_syspath(dev);
if (str && *str) { if (str && *str) {
spa_pod_builder_add(builder, "s", "device.bus_path", "s", str, 0); add_dict(builder, "device.bus_path", str, 0);
} }
if ((str = udev_device_get_syspath(dev)) && *str) { if ((str = udev_device_get_syspath(dev)) && *str) {
spa_pod_builder_add(builder, "s", "sysfs.path", "s", str, 0); add_dict(builder, "sysfs.path", str, 0);
} }
if ((str = udev_device_get_property_value(dev, "ID_ID")) && *str) { if ((str = udev_device_get_property_value(dev, "ID_ID")) && *str) {
spa_pod_builder_add(builder, "s", "udev.id", "s", str, 0); add_dict(builder, "udev.id", str, 0);
} }
if ((str = udev_device_get_property_value(dev, "ID_BUS")) && *str) { if ((str = udev_device_get_property_value(dev, "ID_BUS")) && *str) {
spa_pod_builder_add(builder, "s", "device.bus", "s", str, 0); add_dict(builder, "device.bus", str, 0);
} }
if ((str = udev_device_get_property_value(dev, "SUBSYSTEM")) && *str) { if ((str = udev_device_get_property_value(dev, "SUBSYSTEM")) && *str) {
spa_pod_builder_add(builder, "s", "device.subsystem", "s", str, 0); add_dict(builder, "device.subsystem", str, 0);
} }
if ((str = udev_device_get_property_value(dev, "ID_VENDOR_ID")) && *str) { if ((str = udev_device_get_property_value(dev, "ID_VENDOR_ID")) && *str) {
spa_pod_builder_add(builder, "s", "device.vendor.id", "s", str, 0); add_dict(builder, "device.vendor.id", str, 0);
} }
str = udev_device_get_property_value(dev, "ID_VENDOR_FROM_DATABASE"); str = udev_device_get_property_value(dev, "ID_VENDOR_FROM_DATABASE");
if (!(str && *str)) { if (!(str && *str)) {
@ -220,20 +236,23 @@ fill_item(struct impl *this, snd_ctl_card_info_t *card_info,
} }
} }
if (str && *str) { if (str && *str) {
spa_pod_builder_add(builder, "s", "device.vendor.name", "s", str, 0); add_dict(builder, "device.vendor.name", str, 0);
} }
if ((str = udev_device_get_property_value(dev, "ID_MODEL_ID")) && *str) { if ((str = udev_device_get_property_value(dev, "ID_MODEL_ID")) && *str) {
spa_pod_builder_add(builder, "s", "device.product.id", "s", str, 0); add_dict(builder, "device.product.id", str, 0);
} }
spa_pod_builder_add(builder, "s", "device.product.name", "s", name, 0); add_dict(builder, "device.product.name", name, 0);
if ((str = udev_device_get_property_value(dev, "ID_SERIAL")) && *str) { if ((str = udev_device_get_property_value(dev, "ID_SERIAL")) && *str) {
spa_pod_builder_add(builder, "s", "device.serial", "s", str, 0); add_dict(builder, "device.serial", str, 0);
} }
if ((str = udev_device_get_property_value(dev, "SOUND_FORM_FACTOR")) && *str) { if ((str = udev_device_get_property_value(dev, "SOUND_FORM_FACTOR")) && *str) {
spa_pod_builder_add(builder, "s", "device.form_factor", "s", str, 0); add_dict(builder, "device.form_factor", str, 0);
} }
*item = spa_pod_builder_add(builder, "]}", NULL); spa_pod_builder_pop(builder);
*item = spa_pod_builder_pop(builder);
spa_debug_pod(0, NULL, *item);
return 0; return 0;
} }
@ -347,7 +366,7 @@ static void impl_on_fd_events(struct spa_source *source)
struct impl *this = source->data; struct impl *this = source->data;
struct udev_device *dev; struct udev_device *dev;
const char *action; const char *action;
uint32_t id; uint32_t type;
struct card *card; struct card *card;
struct spa_event *event; struct spa_event *event;
@ -357,18 +376,18 @@ static void impl_on_fd_events(struct spa_source *source)
action = "change"; action = "change";
if (strcmp(action, "add") == 0) { if (strcmp(action, "add") == 0) {
id = SPA_MONITOR_EVENT_Added; type = SPA_MONITOR_EVENT_Added;
} else if (strcmp(action, "change") == 0) { } else if (strcmp(action, "change") == 0) {
id = SPA_MONITOR_EVENT_Changed; type = SPA_MONITOR_EVENT_Changed;
} else if (strcmp(action, "remove") == 0) { } else if (strcmp(action, "remove") == 0) {
id = SPA_MONITOR_EVENT_Removed; type = SPA_MONITOR_EVENT_Removed;
} else } else
return; return;
if ((card = find_card(this, dev)) == NULL) if ((card = find_card(this, dev)) == NULL)
return; return;
if (id == SPA_MONITOR_EVENT_Removed) { if (type == SPA_MONITOR_EVENT_Removed) {
int i; int i;
for (i = 0; i < MAX_DEVICES; i++) { for (i = 0; i < MAX_DEVICES; i++) {
@ -377,23 +396,24 @@ static void impl_on_fd_events(struct spa_source *source)
char id[64]; char id[64];
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer)); struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer));
if (SPA_FLAG_CHECK(device->flags, DEVICE_FLAG_PLAYBACK)) { if (SPA_FLAG_CHECK(device->flags, DEVICE_FLAG_PLAYBACK)) {
snprintf(id, 64, "%s,%d/P", card->name, device->id); snprintf(id, 64, "%s,%d/P", card->name, device->id);
event = spa_pod_builder_object(&b, SPA_TYPE_EVENT_Monitor, id); event = spa_pod_builder_object(&b, SPA_TYPE_EVENT_Monitor, type, 0);
spa_pod_builder_object(&b, spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_MonitorItem, 0, SPA_TYPE_OBJECT_MonitorItem, 0,
":", SPA_MONITOR_ITEM_id, "s", id, SPA_MONITOR_ITEM_id, SPA_POD_Stringv(id),
":", SPA_MONITOR_ITEM_name, "s", id); SPA_MONITOR_ITEM_name, SPA_POD_Stringv(id),
0);
this->callbacks->event(this->callbacks_data, event); this->callbacks->event(this->callbacks_data, event);
} }
if (SPA_FLAG_CHECK(device->flags, DEVICE_FLAG_RECORD)) { if (SPA_FLAG_CHECK(device->flags, DEVICE_FLAG_RECORD)) {
snprintf(id, 64, "%s,%d/C", card->name, device->id); snprintf(id, 64, "%s,%d/C", card->name, device->id);
event = spa_pod_builder_object(&b, SPA_TYPE_EVENT_Monitor, id); event = spa_pod_builder_object(&b, SPA_TYPE_EVENT_Monitor, type, 0);
spa_pod_builder_object(&b, spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_MonitorItem, 0, SPA_TYPE_OBJECT_MonitorItem, 0,
":", SPA_MONITOR_ITEM_id, "s", id, SPA_MONITOR_ITEM_id, SPA_POD_Stringv(id),
":", SPA_MONITOR_ITEM_name, "s", id); SPA_MONITOR_ITEM_name, SPA_POD_Stringv(id),
0);
this->callbacks->event(this->callbacks_data, event); this->callbacks->event(this->callbacks_data, event);
} }
device->flags = 0; device->flags = 0;
@ -408,7 +428,7 @@ static void impl_on_fd_events(struct spa_source *source)
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer)); struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer));
struct spa_pod *item; struct spa_pod *item;
event = spa_pod_builder_object(&b, SPA_TYPE_EVENT_Monitor, id); event = spa_pod_builder_object(&b, SPA_TYPE_EVENT_Monitor, type, 0);
if (get_next_device(this, card, &item, &b) < 0) if (get_next_device(this, card, &item, &b) < 0)
break; break;

View file

@ -69,8 +69,10 @@ static int impl_node_enum_params(struct spa_node *node,
SPA_PARAM_Props }; SPA_PARAM_Props };
if (*index < SPA_N_ELEMENTS(list)) if (*index < SPA_N_ELEMENTS(list))
param = spa_pod_builder_object(&b, SPA_TYPE_OBJECT_ParamList, id, param = spa_pod_builder_object(&b,
":", SPA_PARAM_LIST_id, "I", list[*index]); SPA_TYPE_OBJECT_ParamList, id,
SPA_PARAM_LIST_id, &SPA_POD_Id(list[*index]),
0);
else else
return 0; return 0;
break; break;
@ -83,39 +85,42 @@ static int impl_node_enum_params(struct spa_node *node,
case 0: case 0:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_PropInfo, id, SPA_TYPE_OBJECT_PropInfo, id,
":", SPA_PROP_INFO_id, "I", SPA_PROP_device, SPA_PROP_INFO_id, &SPA_POD_Id(SPA_PROP_device),
":", SPA_PROP_INFO_name, "s", "The ALSA device", SPA_PROP_INFO_name, &SPA_POD_Stringc("The ALSA device"),
":", SPA_PROP_INFO_type, "S", p->device, sizeof(p->device)); SPA_PROP_INFO_type, &SPA_POD_String(p->device, sizeof(p->device)),
0);
break; break;
case 1: case 1:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_PropInfo, id, SPA_TYPE_OBJECT_PropInfo, id,
":", SPA_PROP_INFO_id, "I", SPA_PROP_deviceName, SPA_PROP_INFO_id, &SPA_POD_Id(SPA_PROP_deviceName),
":", SPA_PROP_INFO_name, "s", "The ALSA device name", SPA_PROP_INFO_name, &SPA_POD_Stringc("The ALSA device name"),
":", SPA_PROP_INFO_type, "S-r", p->device_name, sizeof(p->device_name)); SPA_PROP_INFO_type, &SPA_POD_String(p->device_name, sizeof(p->device_name)),
0);
break; break;
case 2: case 2:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_PropInfo, id, SPA_TYPE_OBJECT_PropInfo, id,
":", SPA_PROP_INFO_id, "I", SPA_PROP_cardName, SPA_PROP_INFO_id, &SPA_POD_Id(SPA_PROP_cardName),
":", SPA_PROP_INFO_name, "s", "The ALSA card name", SPA_PROP_INFO_name, &SPA_POD_Stringc("The ALSA card name"),
":", SPA_PROP_INFO_type, "S-r", p->card_name, sizeof(p->card_name)); SPA_PROP_INFO_type, &SPA_POD_String(p->card_name, sizeof(p->card_name)),
0);
break; break;
case 3: case 3:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_PropInfo, id, SPA_TYPE_OBJECT_PropInfo, id,
":", SPA_PROP_INFO_id, "I", SPA_PROP_minLatency, SPA_PROP_INFO_id, &SPA_POD_Id(SPA_PROP_minLatency),
":", SPA_PROP_INFO_name, "s", "The minimum latency", SPA_PROP_INFO_name, &SPA_POD_Stringc("The minimum latency"),
":", SPA_PROP_INFO_type, "ir", p->min_latency, SPA_PROP_INFO_type, &SPA_POD_CHOICE_RANGE_Int(p->min_latency, 1, INT32_MAX),
SPA_POD_PROP_MIN_MAX(1, INT32_MAX)); 0);
break; break;
case 4: case 4:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_PropInfo, id, SPA_TYPE_OBJECT_PropInfo, id,
":", SPA_PROP_INFO_id, "I", SPA_PROP_maxLatency, SPA_PROP_INFO_id, &SPA_POD_Id(SPA_PROP_maxLatency),
":", SPA_PROP_INFO_name, "s", "The maximum latency", SPA_PROP_INFO_name, &SPA_POD_Stringc("The maximum latency"),
":", SPA_PROP_INFO_type, "ir", p->max_latency, SPA_PROP_INFO_type, &SPA_POD_CHOICE_RANGE_Int(p->max_latency, 1, INT32_MAX),
SPA_POD_PROP_MIN_MAX(1, INT32_MAX)); 0);
break; break;
default: default:
return 0; return 0;
@ -130,11 +135,12 @@ static int impl_node_enum_params(struct spa_node *node,
case 0: case 0:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_Props, id, SPA_TYPE_OBJECT_Props, id,
":", SPA_PROP_device, "S", p->device, sizeof(p->device), SPA_PROP_device, &SPA_POD_String(p->device, sizeof(p->device)),
":", SPA_PROP_deviceName, "S-r", p->device_name, sizeof(p->device_name), SPA_PROP_deviceName, &SPA_POD_String(p->device_name, sizeof(p->device_name)),
":", SPA_PROP_cardName, "S-r", p->card_name, sizeof(p->card_name), SPA_PROP_cardName, &SPA_POD_String(p->card_name, sizeof(p->card_name)),
":", SPA_PROP_minLatency, "i", p->min_latency, SPA_PROP_minLatency, &SPA_POD_Int(p->min_latency),
":", SPA_PROP_maxLatency, "i", p->max_latency); SPA_PROP_maxLatency, &SPA_POD_Int(p->max_latency),
0);
break; break;
default: default:
return 0; return 0;
@ -327,8 +333,10 @@ impl_node_port_enum_params(struct spa_node *node,
SPA_PARAM_IO, }; SPA_PARAM_IO, };
if (*index < SPA_N_ELEMENTS(list)) if (*index < SPA_N_ELEMENTS(list))
param = spa_pod_builder_object(&b, SPA_TYPE_OBJECT_ParamList, id, param = spa_pod_builder_object(&b,
":", SPA_PARAM_LIST_id, "I", list[*index]); SPA_TYPE_OBJECT_ParamList, id,
SPA_PARAM_LIST_id, &SPA_POD_Id(list[*index]),
0);
else else
return 0; return 0;
break; break;
@ -353,15 +361,15 @@ impl_node_port_enum_params(struct spa_node *node,
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamBuffers, id, SPA_TYPE_OBJECT_ParamBuffers, id,
":", SPA_PARAM_BUFFERS_buffers, "ir", 1, SPA_PARAM_BUFFERS_buffers, &SPA_POD_CHOICE_RANGE_Int(1, 1, MAX_BUFFERS),
SPA_POD_PROP_MIN_MAX(1, MAX_BUFFERS), SPA_PARAM_BUFFERS_blocks, &SPA_POD_Int(1),
":", SPA_PARAM_BUFFERS_blocks, "i", 1, SPA_PARAM_BUFFERS_size, &SPA_POD_CHOICE_RANGE_Int(
":", SPA_PARAM_BUFFERS_size, "iru", this->props.max_latency * this->frame_size,
this->props.max_latency * this->frame_size, this->props.min_latency * this->frame_size,
SPA_POD_PROP_MIN_MAX(this->props.min_latency * this->frame_size, INT32_MAX),
INT32_MAX), SPA_PARAM_BUFFERS_stride, &SPA_POD_Int(0),
":", SPA_PARAM_BUFFERS_stride, "i", 0, SPA_PARAM_BUFFERS_align, &SPA_POD_Int(16),
":", SPA_PARAM_BUFFERS_align, "i", 16); 0);
break; break;
case SPA_PARAM_Meta: case SPA_PARAM_Meta:
@ -372,8 +380,9 @@ impl_node_port_enum_params(struct spa_node *node,
case 0: case 0:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamMeta, id, SPA_TYPE_OBJECT_ParamMeta, id,
":", SPA_PARAM_META_type, "I", SPA_META_Header, SPA_PARAM_META_type, &SPA_POD_Id(SPA_META_Header),
":", SPA_PARAM_META_size, "i", sizeof(struct spa_meta_header)); SPA_PARAM_META_size, &SPA_POD_Int(sizeof(struct spa_meta_header)),
0);
break; break;
default: default:
return 0; return 0;
@ -385,20 +394,23 @@ impl_node_port_enum_params(struct spa_node *node,
case 0: case 0:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamIO, id, SPA_TYPE_OBJECT_ParamIO, id,
":", SPA_PARAM_IO_id, "I", SPA_IO_Buffers, SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Buffers),
":", SPA_PARAM_IO_size, "i", sizeof(struct spa_io_buffers)); SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_buffers)),
0);
break; break;
case 1: case 1:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamIO, id, SPA_TYPE_OBJECT_ParamIO, id,
":", SPA_PARAM_IO_id, "I", SPA_IO_Range, SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Range),
":", SPA_PARAM_IO_size, "i", sizeof(struct spa_io_range)); SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_range)),
0);
break; break;
case 2: case 2:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamIO, id, SPA_TYPE_OBJECT_ParamIO, id,
":", SPA_PARAM_IO_id, "I", SPA_IO_Clock, SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Clock),
":", SPA_PARAM_IO_size, "i", sizeof(struct spa_io_clock)); SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_clock)),
0);
break; break;
default: default:
return 0; return 0;

View file

@ -73,8 +73,10 @@ static int impl_node_enum_params(struct spa_node *node,
SPA_PARAM_Props, }; SPA_PARAM_Props, };
if (*index < SPA_N_ELEMENTS(list)) if (*index < SPA_N_ELEMENTS(list))
param = spa_pod_builder_object(&b, SPA_TYPE_OBJECT_ParamList, id, param = spa_pod_builder_object(&b,
":", SPA_PARAM_LIST_id, "I", list[*index]); SPA_TYPE_OBJECT_ParamList, id,
SPA_PARAM_LIST_id, &SPA_POD_Id(list[*index]),
0);
else else
return 0; return 0;
break; break;
@ -84,39 +86,42 @@ static int impl_node_enum_params(struct spa_node *node,
case 0: case 0:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_PropInfo, id, SPA_TYPE_OBJECT_PropInfo, id,
":", SPA_PROP_INFO_id, "I", SPA_PROP_device, SPA_PROP_INFO_id, &SPA_POD_Id(SPA_PROP_device),
":", SPA_PROP_INFO_name, "s", "The ALSA device", SPA_PROP_INFO_name, &SPA_POD_Stringc("The ALSA device"),
":", SPA_PROP_INFO_type, "S", p->device, sizeof(p->device)); SPA_PROP_INFO_type, &SPA_POD_String(p->device, sizeof(p->device)),
0);
break; break;
case 1: case 1:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_PropInfo, id, SPA_TYPE_OBJECT_PropInfo, id,
":", SPA_PROP_INFO_id, "I", SPA_PROP_deviceName, SPA_PROP_INFO_id, &SPA_POD_Id(SPA_PROP_deviceName),
":", SPA_PROP_INFO_name, "s", "The ALSA device name", SPA_PROP_INFO_name, &SPA_POD_Stringc("The ALSA device name"),
":", SPA_PROP_INFO_type, "S-r", p->device_name, sizeof(p->device_name)); SPA_PROP_INFO_type, &SPA_POD_String(p->device_name, sizeof(p->device_name)),
0);
break; break;
case 2: case 2:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_PropInfo, id, SPA_TYPE_OBJECT_PropInfo, id,
":", SPA_PROP_INFO_id, "I", SPA_PROP_cardName, SPA_PROP_INFO_id, &SPA_POD_Id(SPA_PROP_cardName),
":", SPA_PROP_INFO_name, "s", "The ALSA card name", SPA_PROP_INFO_name, &SPA_POD_Stringc("The ALSA card name"),
":", SPA_PROP_INFO_type, "S-r", p->card_name, sizeof(p->card_name)); SPA_PROP_INFO_type, &SPA_POD_String(p->card_name, sizeof(p->card_name)),
0);
break; break;
case 3: case 3:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_PropInfo, id, SPA_TYPE_OBJECT_PropInfo, id,
":", SPA_PROP_INFO_id, "I", SPA_PROP_minLatency, SPA_PROP_INFO_id, &SPA_POD_Id(SPA_PROP_minLatency),
":", SPA_PROP_INFO_name, "s", "The minimum latency", SPA_PROP_INFO_name, &SPA_POD_Stringc("The minimum latency"),
":", SPA_PROP_INFO_type, "ir", p->min_latency, SPA_PROP_INFO_type, &SPA_POD_CHOICE_RANGE_Int(p->min_latency, 1, INT32_MAX),
SPA_POD_PROP_MIN_MAX(1, INT32_MAX)); 0);
break; break;
case 4: case 4:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_PropInfo, id, SPA_TYPE_OBJECT_PropInfo, id,
":", SPA_PROP_INFO_id, "I", SPA_PROP_maxLatency, SPA_PROP_INFO_id, &SPA_POD_Id(SPA_PROP_maxLatency),
":", SPA_PROP_INFO_name, "s", "The maximum latency", SPA_PROP_INFO_name, &SPA_POD_Stringc("The maximum latency"),
":", SPA_PROP_INFO_type, "ir", p->max_latency, SPA_PROP_INFO_type, &SPA_POD_CHOICE_RANGE_Int(p->max_latency, 1, INT32_MAX),
SPA_POD_PROP_MIN_MAX(1, INT32_MAX)); 0);
break; break;
default: default:
return 0; return 0;
@ -128,11 +133,12 @@ static int impl_node_enum_params(struct spa_node *node,
case 0: case 0:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_Props, id, SPA_TYPE_OBJECT_Props, id,
":", SPA_PROP_device, "S", p->device, sizeof(p->device), SPA_PROP_device, &SPA_POD_String(p->device, sizeof(p->device)),
":", SPA_PROP_deviceName, "S-r", p->device_name, sizeof(p->device_name), SPA_PROP_deviceName, &SPA_POD_String(p->device_name, sizeof(p->device_name)),
":", SPA_PROP_cardName, "S-r", p->card_name, sizeof(p->card_name), SPA_PROP_cardName, &SPA_POD_String(p->card_name, sizeof(p->card_name)),
":", SPA_PROP_minLatency, "i", p->min_latency, SPA_PROP_minLatency, &SPA_POD_Int(p->min_latency),
":", SPA_PROP_maxLatency, "i", p->max_latency); SPA_PROP_maxLatency, &SPA_POD_Int(p->max_latency),
0);
break; break;
default: default:
return 0; return 0;
@ -338,8 +344,10 @@ impl_node_port_enum_params(struct spa_node *node,
SPA_PARAM_Meta }; SPA_PARAM_Meta };
if (*index < SPA_N_ELEMENTS(list)) if (*index < SPA_N_ELEMENTS(list))
param = spa_pod_builder_object(&b, SPA_TYPE_OBJECT_ParamList, id, param = spa_pod_builder_object(&b,
":", SPA_PARAM_LIST_id, "I", list[*index]); SPA_TYPE_OBJECT_ParamList, id,
SPA_PARAM_LIST_id, &SPA_POD_Id(list[*index]),
0);
else else
return 0; return 0;
break; break;
@ -364,15 +372,15 @@ impl_node_port_enum_params(struct spa_node *node,
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamBuffers, id, SPA_TYPE_OBJECT_ParamBuffers, id,
":", SPA_PARAM_BUFFERS_buffers, "ir", 2, SPA_PARAM_BUFFERS_buffers, &SPA_POD_CHOICE_RANGE_Int(2, 1, MAX_BUFFERS),
SPA_POD_PROP_MIN_MAX(1, MAX_BUFFERS), SPA_PARAM_BUFFERS_blocks, &SPA_POD_Int(1),
":", SPA_PARAM_BUFFERS_blocks, "i", 1, SPA_PARAM_BUFFERS_size, &SPA_POD_CHOICE_RANGE_Int(
":", SPA_PARAM_BUFFERS_size, "iru", this->props.max_latency * this->props.max_latency * this->frame_size,
this->frame_size, this->props.min_latency * this->frame_size,
SPA_POD_PROP_MIN_MAX(this->props.min_latency * this->frame_size, INT32_MAX),
INT32_MAX), SPA_PARAM_BUFFERS_stride, &SPA_POD_Int(this->frame_size),
":", SPA_PARAM_BUFFERS_stride, "i", this->frame_size, SPA_PARAM_BUFFERS_align, &SPA_POD_Int(16),
":", SPA_PARAM_BUFFERS_align, "i", 16); 0);
break; break;
case SPA_PARAM_Meta: case SPA_PARAM_Meta:
@ -383,8 +391,9 @@ impl_node_port_enum_params(struct spa_node *node,
case 0: case 0:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamMeta, id, SPA_TYPE_OBJECT_ParamMeta, id,
":", SPA_PARAM_META_type, "I", SPA_META_Header, SPA_PARAM_META_type, &SPA_POD_Id(SPA_META_Header),
":", SPA_PARAM_META_size, "i", sizeof(struct spa_meta_header)); SPA_PARAM_META_size, &SPA_POD_Int(sizeof(struct spa_meta_header)),
0);
break; break;
default: default:
return 0; return 0;
@ -396,14 +405,16 @@ impl_node_port_enum_params(struct spa_node *node,
case 0: case 0:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamIO, id, SPA_TYPE_OBJECT_ParamIO, id,
":", SPA_PARAM_IO_id, "I", SPA_IO_Buffers, SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Buffers),
":", SPA_PARAM_IO_size, "i", sizeof(struct spa_io_buffers)); SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_buffers)),
0);
break; break;
case 1: case 1:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamIO, id, SPA_TYPE_OBJECT_ParamIO, id,
":", SPA_PARAM_IO_id, "I", SPA_IO_Clock, SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Clock),
":", SPA_PARAM_IO_size, "i", sizeof(struct spa_io_clock)); SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_clock)),
0);
break; break;
default: default:
return 0; return 0;

View file

@ -112,7 +112,7 @@ spa_alsa_enum_format(struct state *state, uint32_t *index,
unsigned int min, max; unsigned int min, max;
uint8_t buffer[4096]; uint8_t buffer[4096];
struct spa_pod_builder b = { 0 }; struct spa_pod_builder b = { 0 };
struct spa_pod_prop *prop; struct spa_pod_choice *choice;
struct spa_pod *fmt; struct spa_pod *fmt;
int res; int res;
bool opened; bool opened;
@ -134,76 +134,82 @@ spa_alsa_enum_format(struct state *state, uint32_t *index,
CHECK(snd_pcm_hw_params_any(hndl, params), "Broken configuration: no configurations available"); CHECK(snd_pcm_hw_params_any(hndl, params), "Broken configuration: no configurations available");
spa_pod_builder_push_object(&b, SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat); spa_pod_builder_push_object(&b, SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat);
spa_pod_builder_add(&b, spa_pod_builder_props(&b,
":", SPA_FORMAT_mediaType, "I", SPA_MEDIA_TYPE_audio, SPA_FORMAT_mediaType, &SPA_POD_Id(SPA_MEDIA_TYPE_audio),
":", SPA_FORMAT_mediaSubtype, "I", SPA_MEDIA_SUBTYPE_raw, 0); SPA_FORMAT_mediaSubtype, &SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw),
0);
snd_pcm_format_mask_alloca(&fmask); snd_pcm_format_mask_alloca(&fmask);
snd_pcm_hw_params_get_format_mask(params, fmask); snd_pcm_hw_params_get_format_mask(params, fmask);
prop = spa_pod_builder_deref(&b, spa_pod_builder_prop(&b, SPA_FORMAT_AUDIO_format, 0);
spa_pod_builder_push_prop(&b, SPA_FORMAT_AUDIO_format,
SPA_POD_PROP_RANGE_NONE)); choice = spa_pod_builder_deref(&b,
spa_pod_builder_push_choice(&b, SPA_CHOICE_None, 0));
for (i = 1, j = 0; i < SPA_N_ELEMENTS(format_info); i++) { for (i = 1, j = 0; i < SPA_N_ELEMENTS(format_info); i++) {
const struct format_info *fi = &format_info[i]; const struct format_info *fi = &format_info[i];
if (snd_pcm_format_mask_test(fmask, fi->format)) { if (snd_pcm_format_mask_test(fmask, fi->format)) {
if (j++ == 0) if (j++ == 0)
spa_pod_builder_enum(&b, fi->spa_format); spa_pod_builder_id(&b, fi->spa_format);
spa_pod_builder_enum(&b, fi->spa_format); spa_pod_builder_id(&b, fi->spa_format);
} }
} }
if (j > 1) if (j > 1)
prop->body.flags |= SPA_POD_PROP_RANGE_ENUM | SPA_POD_PROP_FLAG_UNSET; choice->body.type = SPA_CHOICE_Enum;
spa_pod_builder_pop(&b); spa_pod_builder_pop(&b);
snd_pcm_access_mask_alloca(&amask); snd_pcm_access_mask_alloca(&amask);
snd_pcm_hw_params_get_access_mask(params, amask); snd_pcm_hw_params_get_access_mask(params, amask);
prop = spa_pod_builder_deref(&b, spa_pod_builder_prop(&b, SPA_FORMAT_AUDIO_layout, 0);
spa_pod_builder_push_prop(&b, SPA_FORMAT_AUDIO_layout,
SPA_POD_PROP_RANGE_NONE)); choice = spa_pod_builder_deref(&b,
spa_pod_builder_push_choice(&b, SPA_CHOICE_None, 0));
j = 0; j = 0;
if (snd_pcm_access_mask_test(amask, SND_PCM_ACCESS_MMAP_INTERLEAVED)) { if (snd_pcm_access_mask_test(amask, SND_PCM_ACCESS_MMAP_INTERLEAVED)) {
if (j++ == 0) if (j++ == 0)
spa_pod_builder_enum(&b, SPA_AUDIO_LAYOUT_INTERLEAVED); spa_pod_builder_id(&b, SPA_AUDIO_LAYOUT_INTERLEAVED);
spa_pod_builder_enum(&b, SPA_AUDIO_LAYOUT_INTERLEAVED); spa_pod_builder_id(&b, SPA_AUDIO_LAYOUT_INTERLEAVED);
} }
if (snd_pcm_access_mask_test(amask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED)) { if (snd_pcm_access_mask_test(amask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED)) {
if (j++ == 0) if (j++ == 0)
spa_pod_builder_enum(&b, SPA_AUDIO_LAYOUT_NON_INTERLEAVED); spa_pod_builder_id(&b, SPA_AUDIO_LAYOUT_NON_INTERLEAVED);
spa_pod_builder_enum(&b, SPA_AUDIO_LAYOUT_NON_INTERLEAVED); spa_pod_builder_id(&b, SPA_AUDIO_LAYOUT_NON_INTERLEAVED);
} }
if (j > 1) if (j > 1)
prop->body.flags |= SPA_POD_PROP_RANGE_ENUM | SPA_POD_PROP_FLAG_UNSET; choice->body.type = SPA_CHOICE_Enum;
spa_pod_builder_pop(&b); spa_pod_builder_pop(&b);
CHECK(snd_pcm_hw_params_get_rate_min(params, &min, &dir), "get_rate_min"); CHECK(snd_pcm_hw_params_get_rate_min(params, &min, &dir), "get_rate_min");
CHECK(snd_pcm_hw_params_get_rate_max(params, &max, &dir), "get_rate_max"); CHECK(snd_pcm_hw_params_get_rate_max(params, &max, &dir), "get_rate_max");
prop = spa_pod_builder_deref(&b, spa_pod_builder_prop(&b, SPA_FORMAT_AUDIO_rate, 0);
spa_pod_builder_push_prop(&b, SPA_FORMAT_AUDIO_rate, SPA_POD_PROP_RANGE_NONE));
choice = spa_pod_builder_deref(&b,
spa_pod_builder_push_choice(&b, SPA_CHOICE_None, 0));
spa_pod_builder_int(&b, SPA_CLAMP(DEFAULT_RATE, min, max)); spa_pod_builder_int(&b, SPA_CLAMP(DEFAULT_RATE, min, max));
if (min != max) { if (min != max) {
spa_pod_builder_int(&b, min); spa_pod_builder_int(&b, min);
spa_pod_builder_int(&b, max); spa_pod_builder_int(&b, max);
prop->body.flags |= SPA_POD_PROP_RANGE_MIN_MAX | SPA_POD_PROP_FLAG_UNSET; choice->body.type = SPA_CHOICE_Range;
} }
spa_pod_builder_pop(&b); spa_pod_builder_pop(&b);
CHECK(snd_pcm_hw_params_get_channels_min(params, &min), "get_channels_min"); CHECK(snd_pcm_hw_params_get_channels_min(params, &min), "get_channels_min");
CHECK(snd_pcm_hw_params_get_channels_max(params, &max), "get_channels_max"); CHECK(snd_pcm_hw_params_get_channels_max(params, &max), "get_channels_max");
prop = spa_pod_builder_deref(&b, spa_pod_builder_prop(&b, SPA_FORMAT_AUDIO_channels, 0);
spa_pod_builder_push_prop(&b, SPA_FORMAT_AUDIO_channels, SPA_POD_PROP_RANGE_NONE));
choice = spa_pod_builder_deref(&b,
spa_pod_builder_push_choice(&b, SPA_CHOICE_None, 0));
spa_pod_builder_int(&b, SPA_CLAMP(DEFAULT_CHANNELS, min, max)); spa_pod_builder_int(&b, SPA_CLAMP(DEFAULT_CHANNELS, min, max));
if (min != max) { if (min != max) {
spa_pod_builder_int(&b, min); spa_pod_builder_int(&b, min);
spa_pod_builder_int(&b, max); spa_pod_builder_int(&b, max);
prop->body.flags |= SPA_POD_PROP_RANGE_MIN_MAX | SPA_POD_PROP_FLAG_UNSET; choice->body.type = SPA_CHOICE_Range;
} }
spa_pod_builder_pop(&b); spa_pod_builder_pop(&b);

View file

@ -564,9 +564,9 @@ impl_node_port_enum_params(struct spa_node *node,
case 0: case 0:
param = spa_pod_builder_object(builder, param = spa_pod_builder_object(builder,
SPA_TYPE_OBJECT_PropInfo, id, SPA_TYPE_OBJECT_PropInfo, id,
":", SPA_PROP_INFO_id, "I", SPA_PROP_volume, SPA_PROP_INFO_id, &SPA_POD_Id(SPA_PROP_volume),
":", SPA_PROP_INFO_type, "fru", 1.0, SPA_PROP_INFO_type, &SPA_POD_CHOICE_RANGE_Float(1.0, 0.0, 10.0),
SPA_POD_PROP_MIN_MAX(0.0, 10.0)); 0);
break; break;
default: default:
return 0; return 0;
@ -578,20 +578,23 @@ impl_node_port_enum_params(struct spa_node *node,
case 0: case 0:
param = spa_pod_builder_object(builder, param = spa_pod_builder_object(builder,
SPA_TYPE_OBJECT_ParamIO, id, SPA_TYPE_OBJECT_ParamIO, id,
":", SPA_PARAM_IO_id, "I", SPA_IO_Buffers, SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Buffers),
":", SPA_PARAM_IO_size, "i", sizeof(struct spa_io_buffers)); SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_buffers)),
0);
break; break;
case 1: case 1:
param = spa_pod_builder_object(builder, param = spa_pod_builder_object(builder,
SPA_TYPE_OBJECT_ParamIO, id, SPA_TYPE_OBJECT_ParamIO, id,
":", SPA_PARAM_IO_id, "I", SPA_IO_Range, SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Range),
":", SPA_PARAM_IO_size, "i", sizeof(struct spa_io_range)); SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_range)),
0);
break; break;
case 2: case 2:
param = spa_pod_builder_object(builder, param = spa_pod_builder_object(builder,
SPA_TYPE_OBJECT_ParamIO, id, SPA_TYPE_OBJECT_ParamIO, id,
":", SPA_PARAM_IO_id, "I", SPA_IO_Control, SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Control),
":", SPA_PARAM_IO_size, "i", sizeof(struct spa_io_sequence)); SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_sequence)),
0);
break; break;
default: default:
return 0; return 0;

View file

@ -309,24 +309,23 @@ static int port_enum_formats(struct spa_node *node,
if (other->have_format) { if (other->have_format) {
*param = spa_pod_builder_object(builder, *param = spa_pod_builder_object(builder,
SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat, SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
":", SPA_FORMAT_mediaType, "I", SPA_MEDIA_TYPE_audio, SPA_FORMAT_mediaType, &SPA_POD_Id(SPA_MEDIA_TYPE_audio),
":", SPA_FORMAT_mediaSubtype, "I", SPA_MEDIA_SUBTYPE_raw, SPA_FORMAT_mediaSubtype, &SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw),
":", SPA_FORMAT_AUDIO_format, "I", SPA_AUDIO_FORMAT_F32, SPA_FORMAT_AUDIO_format, &SPA_POD_Id(SPA_AUDIO_FORMAT_F32),
":", SPA_FORMAT_AUDIO_layout, "I", SPA_AUDIO_LAYOUT_NON_INTERLEAVED, SPA_FORMAT_AUDIO_layout, &SPA_POD_Id(SPA_AUDIO_LAYOUT_NON_INTERLEAVED),
":", SPA_FORMAT_AUDIO_rate, "i", other->format.info.raw.rate, SPA_FORMAT_AUDIO_rate, &SPA_POD_Int(other->format.info.raw.rate),
":", SPA_FORMAT_AUDIO_channels, "iru", 2, SPA_FORMAT_AUDIO_channels, &SPA_POD_CHOICE_RANGE_Int(DEFAULT_CHANNELS, 1, INT32_MAX),
SPA_POD_PROP_MIN_MAX(1, INT32_MAX)); 0);
} else { } else {
*param = spa_pod_builder_object(builder, *param = spa_pod_builder_object(builder,
SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat, SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
":", SPA_FORMAT_mediaType, "I", SPA_MEDIA_TYPE_audio, SPA_FORMAT_mediaType, &SPA_POD_Id(SPA_MEDIA_TYPE_audio),
":", SPA_FORMAT_mediaSubtype, "I", SPA_MEDIA_SUBTYPE_raw, SPA_FORMAT_mediaSubtype, &SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw),
":", SPA_FORMAT_AUDIO_format, "I", SPA_AUDIO_FORMAT_F32, SPA_FORMAT_AUDIO_format, &SPA_POD_Id(SPA_AUDIO_FORMAT_F32),
":", SPA_FORMAT_AUDIO_layout, "I", SPA_AUDIO_LAYOUT_NON_INTERLEAVED, SPA_FORMAT_AUDIO_layout, &SPA_POD_Id(SPA_AUDIO_LAYOUT_NON_INTERLEAVED),
":", SPA_FORMAT_AUDIO_rate, "iru", DEFAULT_RATE, SPA_FORMAT_AUDIO_rate, &SPA_POD_CHOICE_RANGE_Int(DEFAULT_RATE, 1, INT32_MAX),
SPA_POD_PROP_MIN_MAX(1, INT32_MAX), SPA_FORMAT_AUDIO_channels, &SPA_POD_CHOICE_RANGE_Int(DEFAULT_CHANNELS, 1, INT32_MAX),
":", SPA_FORMAT_AUDIO_channels, "iru", DEFAULT_CHANNELS, 0);
SPA_POD_PROP_MIN_MAX(1, INT32_MAX));
} }
break; break;
default: default:
@ -374,8 +373,10 @@ impl_node_port_enum_params(struct spa_node *node,
SPA_PARAM_IO }; SPA_PARAM_IO };
if (*index < SPA_N_ELEMENTS(list)) if (*index < SPA_N_ELEMENTS(list))
param = spa_pod_builder_object(&b, SPA_TYPE_OBJECT_ParamList, id, param = spa_pod_builder_object(&b,
":", SPA_PARAM_LIST_id, "I", list[*index]); SPA_TYPE_OBJECT_ParamList, id,
SPA_PARAM_LIST_id, &SPA_POD_Id(list[*index]),
0);
else else
return 0; return 0;
break; break;
@ -413,13 +414,15 @@ impl_node_port_enum_params(struct spa_node *node,
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamBuffers, id, SPA_TYPE_OBJECT_ParamBuffers, id,
":", SPA_PARAM_BUFFERS_buffers, "iru", buffers, SPA_PARAM_BUFFERS_buffers, &SPA_POD_CHOICE_RANGE_Int(buffers, 1, MAX_BUFFERS),
SPA_POD_PROP_MIN_MAX(1, MAX_BUFFERS), SPA_PARAM_BUFFERS_blocks, &SPA_POD_Int(port->blocks),
":", SPA_PARAM_BUFFERS_blocks, "i", port->blocks, SPA_PARAM_BUFFERS_size, &SPA_POD_CHOICE_RANGE_Int(
":", SPA_PARAM_BUFFERS_size, "iru", size * port->stride, size * port->stride,
SPA_POD_PROP_MIN_MAX(16 * port->stride, INT32_MAX / port->stride), 16 * port->stride,
":", SPA_PARAM_BUFFERS_stride, "i", port->stride, INT32_MAX / port->stride),
":", SPA_PARAM_BUFFERS_align, "i", 16); SPA_PARAM_BUFFERS_stride, &SPA_POD_Int(port->stride),
SPA_PARAM_BUFFERS_align, &SPA_POD_Int(16),
0);
break; break;
} }
case SPA_PARAM_Meta: case SPA_PARAM_Meta:
@ -430,8 +433,9 @@ impl_node_port_enum_params(struct spa_node *node,
case 0: case 0:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamMeta, id, SPA_TYPE_OBJECT_ParamMeta, id,
":", SPA_PARAM_META_type, "I", SPA_META_Header, SPA_PARAM_META_type, &SPA_POD_Id(SPA_META_Header),
":", SPA_PARAM_META_size, "i", sizeof(struct spa_meta_header)); SPA_PARAM_META_size, &SPA_POD_Int(sizeof(struct spa_meta_header)),
0);
break; break;
default: default:
return 0; return 0;
@ -443,14 +447,16 @@ impl_node_port_enum_params(struct spa_node *node,
case 0: case 0:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamIO, id, SPA_TYPE_OBJECT_ParamIO, id,
":", SPA_PARAM_IO_id, "I", SPA_IO_Buffers, SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Buffers),
":", SPA_PARAM_IO_size, "i", sizeof(struct spa_io_buffers)); SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_buffers)),
0);
break; break;
case 1: case 1:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamIO, id, SPA_TYPE_OBJECT_ParamIO, id,
":", SPA_PARAM_IO_id, "I", SPA_IO_Control, SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Control),
":", SPA_PARAM_IO_size, "i", sizeof(struct spa_io_sequence)); SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_sequence)),
0);
break; break;
default: default:
return 0; return 0;
@ -707,15 +713,13 @@ static int process_control(struct impl *this, struct port *port, struct spa_pod_
{ {
struct props *p = &this->props; struct props *p = &this->props;
float volume = p->volume; float volume = p->volume;
struct spa_pod *pod; struct spa_pod_prop *prop;
struct spa_pod_object *obj = (struct spa_pod_object *) &c->value; struct spa_pod_object *obj = (struct spa_pod_object *) &c->value;
SPA_POD_OBJECT_FOREACH(obj, pod) { SPA_POD_OBJECT_FOREACH(obj, prop) {
struct spa_pod_prop *prop = (struct spa_pod_prop *)pod; switch (prop->key) {
switch (prop->body.key) {
case SPA_PROP_volume: case SPA_PROP_volume:
volume = SPA_POD_VALUE(struct spa_pod_float, &prop->body.value); volume = SPA_POD_VALUE(struct spa_pod_float, &prop->value);
if (volume != p->volume) { if (volume != p->volume) {
p->volume = volume; p->volume = volume;
setup_matrix(this, setup_matrix(this,

View file

@ -422,41 +422,47 @@ static int port_enum_formats(struct spa_node *node,
if (other->info.raw.channels > 0) { if (other->info.raw.channels > 0) {
*param = spa_pod_builder_object(builder, *param = spa_pod_builder_object(builder,
SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat, SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
":", SPA_FORMAT_mediaType, "I", SPA_MEDIA_TYPE_audio, SPA_FORMAT_mediaType, &SPA_POD_Id(SPA_MEDIA_TYPE_audio),
":", SPA_FORMAT_mediaSubtype, "I", SPA_MEDIA_SUBTYPE_raw, SPA_FORMAT_mediaSubtype, &SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw),
":", SPA_FORMAT_AUDIO_format, "Ieu", other->info.raw.format, SPA_FORMAT_AUDIO_format, &SPA_POD_CHOICE_ENUM_Id(4,
SPA_POD_PROP_ENUM(3, other->info.raw.format, other->info.raw.format,
SPA_AUDIO_FORMAT_F32, other->info.raw.format,
SPA_AUDIO_FORMAT_F32_OE), SPA_AUDIO_FORMAT_F32,
":", SPA_FORMAT_AUDIO_layout, "Ieu", other->info.raw.layout, SPA_AUDIO_FORMAT_F32_OE),
SPA_POD_PROP_ENUM(2, SPA_AUDIO_LAYOUT_INTERLEAVED, SPA_FORMAT_AUDIO_layout, &SPA_POD_CHOICE_ENUM_Id(3,
SPA_AUDIO_LAYOUT_NON_INTERLEAVED), other->info.raw.layout,
":", SPA_FORMAT_AUDIO_rate, "i", other->info.raw.rate, SPA_AUDIO_LAYOUT_INTERLEAVED,
":", SPA_FORMAT_AUDIO_channels, "i", other->info.raw.channels); SPA_AUDIO_LAYOUT_NON_INTERLEAVED),
SPA_FORMAT_AUDIO_rate, &SPA_POD_Int(other->info.raw.rate),
SPA_FORMAT_AUDIO_channels, &SPA_POD_Int(other->info.raw.channels),
0);
} else { } else {
*param = spa_pod_builder_object(builder, *param = spa_pod_builder_object(builder,
SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat, SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
":", SPA_FORMAT_mediaType, "I", SPA_MEDIA_TYPE_audio, SPA_FORMAT_mediaType, &SPA_POD_Id(SPA_MEDIA_TYPE_audio),
":", SPA_FORMAT_mediaSubtype, "I", SPA_MEDIA_SUBTYPE_raw, SPA_FORMAT_mediaSubtype, &SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw),
":", SPA_FORMAT_AUDIO_format, "Ieu", SPA_AUDIO_FORMAT_S16, SPA_FORMAT_AUDIO_format, &SPA_POD_CHOICE_ENUM_Id(12,
SPA_POD_PROP_ENUM(11, SPA_AUDIO_FORMAT_U8, SPA_AUDIO_FORMAT_S16,
SPA_AUDIO_FORMAT_S16, SPA_AUDIO_FORMAT_U8,
SPA_AUDIO_FORMAT_S16_OE, SPA_AUDIO_FORMAT_S16,
SPA_AUDIO_FORMAT_F32, SPA_AUDIO_FORMAT_S16_OE,
SPA_AUDIO_FORMAT_F32_OE, SPA_AUDIO_FORMAT_F32,
SPA_AUDIO_FORMAT_S32, SPA_AUDIO_FORMAT_F32_OE,
SPA_AUDIO_FORMAT_S32_OE, SPA_AUDIO_FORMAT_S32,
SPA_AUDIO_FORMAT_S24, SPA_AUDIO_FORMAT_S32_OE,
SPA_AUDIO_FORMAT_S24_OE, SPA_AUDIO_FORMAT_S24,
SPA_AUDIO_FORMAT_S24_32, SPA_AUDIO_FORMAT_S24_OE,
SPA_AUDIO_FORMAT_S24_32_OE), SPA_AUDIO_FORMAT_S24_32,
":", SPA_FORMAT_AUDIO_layout, "Ieu", SPA_AUDIO_LAYOUT_INTERLEAVED, SPA_AUDIO_FORMAT_S24_32_OE),
SPA_POD_PROP_ENUM(2, SPA_AUDIO_LAYOUT_INTERLEAVED, SPA_FORMAT_AUDIO_layout, &SPA_POD_CHOICE_ENUM_Id(3,
SPA_AUDIO_LAYOUT_NON_INTERLEAVED), SPA_AUDIO_LAYOUT_INTERLEAVED,
":", SPA_FORMAT_AUDIO_rate, "iru", DEFAULT_RATE, SPA_AUDIO_LAYOUT_INTERLEAVED,
SPA_POD_PROP_MIN_MAX(1, INT32_MAX), SPA_AUDIO_LAYOUT_NON_INTERLEAVED),
":", SPA_FORMAT_AUDIO_channels, "iru", DEFAULT_CHANNELS, SPA_FORMAT_AUDIO_rate, &SPA_POD_CHOICE_RANGE_Int(
SPA_POD_PROP_MIN_MAX(1, INT32_MAX)); DEFAULT_RATE, 1, INT32_MAX),
SPA_FORMAT_AUDIO_channels, &SPA_POD_CHOICE_RANGE_Int(
DEFAULT_CHANNELS, 1, INT32_MAX),
0);
} }
break; break;
default: default:
@ -506,7 +512,7 @@ impl_node_port_enum_params(struct spa_node *node,
if (*index < SPA_N_ELEMENTS(list)) if (*index < SPA_N_ELEMENTS(list))
param = spa_pod_builder_object(&b, SPA_TYPE_OBJECT_ParamList, id, param = spa_pod_builder_object(&b, SPA_TYPE_OBJECT_ParamList, id,
":", SPA_PARAM_LIST_id, "I", list[*index]); SPA_PARAM_LIST_id, &SPA_POD_Id(list[*index]), 0);
else else
return 0; return 0;
break; break;
@ -527,8 +533,8 @@ impl_node_port_enum_params(struct spa_node *node,
case SPA_PARAM_Buffers: case SPA_PARAM_Buffers:
{ {
uint32_t buffers, size; uint32_t buffers;
const char *size_fmt; void *pod;
if (!port->have_format) if (!port->have_format)
return -EIO; return -EIO;
@ -537,23 +543,22 @@ impl_node_port_enum_params(struct spa_node *node,
if (other->n_buffers > 0) { if (other->n_buffers > 0) {
buffers = other->n_buffers; buffers = other->n_buffers;
size = other->size / other->stride; pod = &SPA_POD_Int(other->size / other->stride * port->stride);
size_fmt = "ir";
} else { } else {
buffers = 1; buffers = 1;
size = 1024; pod = &SPA_POD_CHOICE_RANGE_Int(1024 * port->stride,
size_fmt = "iru"; 16 * port->stride,
INT32_MAX / port->stride);
} }
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamBuffers, id, SPA_TYPE_OBJECT_ParamBuffers, id,
":", SPA_PARAM_BUFFERS_buffers, "iru", buffers, SPA_PARAM_BUFFERS_buffers, &SPA_POD_CHOICE_RANGE_Int(buffers, 2, MAX_BUFFERS),
SPA_POD_PROP_MIN_MAX(2, MAX_BUFFERS), SPA_PARAM_BUFFERS_blocks, &SPA_POD_Int(port->blocks),
":", SPA_PARAM_BUFFERS_blocks, "i", port->blocks, SPA_PARAM_BUFFERS_size, pod,
":", SPA_PARAM_BUFFERS_size, size_fmt, size * port->stride, SPA_PARAM_BUFFERS_stride, &SPA_POD_Int(port->stride),
SPA_POD_PROP_MIN_MAX(16 * port->stride, INT32_MAX / port->stride), SPA_PARAM_BUFFERS_align, &SPA_POD_Int(16),
":", SPA_PARAM_BUFFERS_stride, "i", port->stride, 0);
":", SPA_PARAM_BUFFERS_align, "i", 16);
break; break;
} }
case SPA_PARAM_Meta: case SPA_PARAM_Meta:
@ -564,8 +569,9 @@ impl_node_port_enum_params(struct spa_node *node,
case 0: case 0:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamMeta, id, SPA_TYPE_OBJECT_ParamMeta, id,
":", SPA_PARAM_META_type, "I", SPA_META_Header, SPA_PARAM_META_type, &SPA_POD_Id(SPA_META_Header),
":", SPA_PARAM_META_size, "i", sizeof(struct spa_meta_header)); SPA_PARAM_META_size, &SPA_POD_Int(sizeof(struct spa_meta_header)),
0);
break; break;
default: default:
return 0; return 0;
@ -577,8 +583,9 @@ impl_node_port_enum_params(struct spa_node *node,
case 0: case 0:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamIO, id, SPA_TYPE_OBJECT_ParamIO, id,
":", SPA_PARAM_IO_id, "I", SPA_IO_Buffers, SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Buffers),
":", SPA_PARAM_IO_size, "i", sizeof(struct spa_io_buffers)); SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_buffers)),
0);
break; break;
default: default:
return 0; return 0;

View file

@ -303,55 +303,53 @@ static int port_enum_formats(struct spa_node *node,
struct spa_pod_builder *builder) struct spa_pod_builder *builder)
{ {
struct impl *this = SPA_CONTAINER_OF(node, struct impl, node); struct impl *this = SPA_CONTAINER_OF(node, struct impl, node);
uint32_t rate; void *rate;
const char *rspec;
switch (*index) { switch (*index) {
case 0: case 0:
if (this->have_format || this->force_rate) { if (this->have_format || this->force_rate) {
rate = this->format.info.raw.rate; rate = &SPA_POD_Int(this->format.info.raw.rate);
rspec = "ir";
} }
else { else {
rate = DEFAULT_RATE; rate = &SPA_POD_CHOICE_RANGE_Int(DEFAULT_RATE, 1, INT32_MAX);
rspec = "iru";
} }
if (direction == SPA_DIRECTION_OUTPUT) { if (direction == SPA_DIRECTION_OUTPUT) {
*param = spa_pod_builder_object(builder, *param = spa_pod_builder_object(builder,
SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat, SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
":", SPA_FORMAT_mediaType, "I", SPA_MEDIA_TYPE_audio, SPA_FORMAT_mediaType, &SPA_POD_Id(SPA_MEDIA_TYPE_audio),
":", SPA_FORMAT_mediaSubtype, "I", SPA_MEDIA_SUBTYPE_raw, SPA_FORMAT_mediaSubtype, &SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw),
":", SPA_FORMAT_AUDIO_format, "Ieu", SPA_AUDIO_FORMAT_F32, SPA_FORMAT_AUDIO_format, &SPA_POD_CHOICE_ENUM_Id(12,
SPA_POD_PROP_ENUM(11, SPA_AUDIO_FORMAT_F32,
SPA_AUDIO_FORMAT_F32, SPA_AUDIO_FORMAT_F32,
SPA_AUDIO_FORMAT_F32_OE, SPA_AUDIO_FORMAT_F32_OE,
SPA_AUDIO_FORMAT_S32, SPA_AUDIO_FORMAT_S32,
SPA_AUDIO_FORMAT_S32_OE, SPA_AUDIO_FORMAT_S32_OE,
SPA_AUDIO_FORMAT_S24_32, SPA_AUDIO_FORMAT_S24_32,
SPA_AUDIO_FORMAT_S24_32_OE, SPA_AUDIO_FORMAT_S24_32_OE,
SPA_AUDIO_FORMAT_S24, SPA_AUDIO_FORMAT_S24,
SPA_AUDIO_FORMAT_S24_OE, SPA_AUDIO_FORMAT_S24_OE,
SPA_AUDIO_FORMAT_S16, SPA_AUDIO_FORMAT_S16,
SPA_AUDIO_FORMAT_S16_OE, SPA_AUDIO_FORMAT_S16_OE,
SPA_AUDIO_FORMAT_U8), SPA_AUDIO_FORMAT_U8),
":", SPA_FORMAT_AUDIO_layout, "Ieu", SPA_AUDIO_LAYOUT_INTERLEAVED, SPA_FORMAT_AUDIO_layout, &SPA_POD_CHOICE_ENUM_Id(3,
SPA_POD_PROP_ENUM(2, SPA_AUDIO_LAYOUT_INTERLEAVED, SPA_AUDIO_LAYOUT_INTERLEAVED,
SPA_AUDIO_LAYOUT_NON_INTERLEAVED), SPA_AUDIO_LAYOUT_INTERLEAVED,
":", SPA_FORMAT_AUDIO_rate, rspec, rate, SPA_AUDIO_LAYOUT_NON_INTERLEAVED),
SPA_POD_PROP_MIN_MAX(1, INT32_MAX), SPA_FORMAT_AUDIO_rate, rate,
":", SPA_FORMAT_AUDIO_channels, "i", this->port_count); SPA_FORMAT_AUDIO_channels, &SPA_POD_Int(this->port_count),
0);
} }
else { else {
*param = spa_pod_builder_object(builder, *param = spa_pod_builder_object(builder,
SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat, SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
":", SPA_FORMAT_mediaType, "I", SPA_MEDIA_TYPE_audio, SPA_FORMAT_mediaType, &SPA_POD_Id(SPA_MEDIA_TYPE_audio),
":", SPA_FORMAT_mediaSubtype, "I", SPA_MEDIA_SUBTYPE_raw, SPA_FORMAT_mediaSubtype, &SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw),
":", SPA_FORMAT_AUDIO_format, "I", SPA_AUDIO_FORMAT_F32, SPA_FORMAT_AUDIO_format, &SPA_POD_Id(SPA_AUDIO_FORMAT_F32),
":", SPA_FORMAT_AUDIO_layout, "I", SPA_AUDIO_LAYOUT_NON_INTERLEAVED, SPA_FORMAT_AUDIO_layout, &SPA_POD_Id(SPA_AUDIO_LAYOUT_NON_INTERLEAVED),
":", SPA_FORMAT_AUDIO_rate, rspec, rate, SPA_FORMAT_AUDIO_rate, rate,
SPA_POD_PROP_MIN_MAX(1, INT32_MAX), SPA_FORMAT_AUDIO_channels, &SPA_POD_Int(1),
":", SPA_FORMAT_AUDIO_channels, "i", 1); 0);
} }
break; break;
default: default:
@ -400,8 +398,9 @@ impl_node_port_enum_params(struct spa_node *node,
SPA_PARAM_IO, }; SPA_PARAM_IO, };
if (*index < SPA_N_ELEMENTS(list)) if (*index < SPA_N_ELEMENTS(list))
param = spa_pod_builder_object(&b, SPA_TYPE_OBJECT_ParamList, id, param = spa_pod_builder_object(&b,
":", SPA_PARAM_LIST_id, "I", list[*index]); SPA_TYPE_OBJECT_ParamList, id,
SPA_PARAM_LIST_id, &SPA_POD_Id(list[*index]), 0);
else else
return 0; return 0;
} }
@ -425,13 +424,15 @@ impl_node_port_enum_params(struct spa_node *node,
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamBuffers, id, SPA_TYPE_OBJECT_ParamBuffers, id,
":", SPA_PARAM_BUFFERS_buffers, "iru", 1, SPA_PARAM_BUFFERS_buffers, &SPA_POD_CHOICE_RANGE_Int(1, 1, MAX_BUFFERS),
SPA_POD_PROP_MIN_MAX(1, MAX_BUFFERS), SPA_PARAM_BUFFERS_blocks, &SPA_POD_Int(port->blocks),
":", SPA_PARAM_BUFFERS_blocks, "i", port->blocks, SPA_PARAM_BUFFERS_size, &SPA_POD_CHOICE_RANGE_Int(
":", SPA_PARAM_BUFFERS_size, "iru", 1024 * port->stride, 1024 * port->stride,
SPA_POD_PROP_MIN_MAX(16 * port->stride, MAX_SAMPLES * port->stride), 16 * port->stride,
":", SPA_PARAM_BUFFERS_stride, "i", port->stride, MAX_SAMPLES * port->stride),
":", SPA_PARAM_BUFFERS_align, "i", 16); SPA_PARAM_BUFFERS_stride, &SPA_POD_Int(port->stride),
SPA_PARAM_BUFFERS_align, &SPA_POD_Int(16),
0);
break; break;
case SPA_PARAM_Meta: case SPA_PARAM_Meta:
if (!port->have_format) if (!port->have_format)
@ -441,8 +442,9 @@ impl_node_port_enum_params(struct spa_node *node,
case 0: case 0:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamMeta, id, SPA_TYPE_OBJECT_ParamMeta, id,
":", SPA_PARAM_META_type, "i", SPA_META_Header, SPA_PARAM_META_type, &SPA_POD_Id(SPA_META_Header),
":", SPA_PARAM_META_size, "i", sizeof(struct spa_meta_header)); SPA_PARAM_META_size, &SPA_POD_Int(sizeof(struct spa_meta_header)),
0);
break; break;
default: default:
return 0; return 0;
@ -453,8 +455,9 @@ impl_node_port_enum_params(struct spa_node *node,
case 0: case 0:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamIO, id, SPA_TYPE_OBJECT_ParamIO, id,
":", SPA_PARAM_IO_id, "I", SPA_IO_Buffers, SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Buffers),
":", SPA_PARAM_IO_size, "i", sizeof(struct spa_io_buffers)); SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_buffers)),
0);
break; break;
default: default:
return 0; return 0;

View file

@ -283,24 +283,24 @@ static int port_enum_formats(struct spa_node *node,
if (other->have_format) { if (other->have_format) {
*param = spa_pod_builder_object(builder, *param = spa_pod_builder_object(builder,
SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat, SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
":", SPA_FORMAT_mediaType, "I", SPA_MEDIA_TYPE_audio, SPA_FORMAT_mediaType, &SPA_POD_Id(SPA_MEDIA_TYPE_audio),
":", SPA_FORMAT_mediaSubtype, "I", SPA_MEDIA_SUBTYPE_raw, SPA_FORMAT_mediaSubtype, &SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw),
":", SPA_FORMAT_AUDIO_format, "I", SPA_AUDIO_FORMAT_F32, SPA_FORMAT_AUDIO_format, &SPA_POD_Id(SPA_AUDIO_FORMAT_F32),
":", SPA_FORMAT_AUDIO_layout, "I", SPA_AUDIO_LAYOUT_NON_INTERLEAVED, SPA_FORMAT_AUDIO_layout, &SPA_POD_Id(SPA_AUDIO_LAYOUT_NON_INTERLEAVED),
":", SPA_FORMAT_AUDIO_rate, "iru", other->format.info.raw.rate, SPA_FORMAT_AUDIO_rate, &SPA_POD_CHOICE_RANGE_Int(
SPA_POD_PROP_MIN_MAX(1, INT32_MAX), other->format.info.raw.rate, 1, INT32_MAX),
":", SPA_FORMAT_AUDIO_channels, "i", other->format.info.raw.channels); SPA_FORMAT_AUDIO_channels, &SPA_POD_Int(other->format.info.raw.channels),
0);
} else { } else {
*param = spa_pod_builder_object(builder, *param = spa_pod_builder_object(builder,
SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat, SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
":", SPA_FORMAT_mediaType, "I", SPA_MEDIA_TYPE_audio, SPA_FORMAT_mediaType, &SPA_POD_Id(SPA_MEDIA_TYPE_audio),
":", SPA_FORMAT_mediaSubtype, "I", SPA_MEDIA_SUBTYPE_raw, SPA_FORMAT_mediaSubtype, &SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw),
":", SPA_FORMAT_AUDIO_format, "I", SPA_AUDIO_FORMAT_F32, SPA_FORMAT_AUDIO_format, &SPA_POD_Id(SPA_AUDIO_FORMAT_F32),
":", SPA_FORMAT_AUDIO_layout, "I", SPA_AUDIO_LAYOUT_NON_INTERLEAVED, SPA_FORMAT_AUDIO_layout, &SPA_POD_Id(SPA_AUDIO_LAYOUT_NON_INTERLEAVED),
":", SPA_FORMAT_AUDIO_rate, "iru", DEFAULT_RATE, SPA_FORMAT_AUDIO_rate, &SPA_POD_CHOICE_RANGE_Int(DEFAULT_RATE, 1, INT32_MAX),
SPA_POD_PROP_MIN_MAX(1, INT32_MAX), SPA_FORMAT_AUDIO_channels, &SPA_POD_CHOICE_RANGE_Int(DEFAULT_CHANNELS, 1, INT32_MAX),
":", SPA_FORMAT_AUDIO_channels, "iru", DEFAULT_CHANNELS, 0);
SPA_POD_PROP_MIN_MAX(1, INT32_MAX));
} }
break; break;
default: default:
@ -348,8 +348,10 @@ impl_node_port_enum_params(struct spa_node *node,
SPA_PARAM_IO }; SPA_PARAM_IO };
if (*index < SPA_N_ELEMENTS(list)) if (*index < SPA_N_ELEMENTS(list))
param = spa_pod_builder_object(&b, SPA_TYPE_OBJECT_ParamList, id, param = spa_pod_builder_object(&b,
":", SPA_PARAM_LIST_id, "I", list[*index]); SPA_TYPE_OBJECT_ParamList, id,
SPA_PARAM_LIST_id, &SPA_POD_Id(list[*index]),
0);
else else
return 0; return 0;
break; break;
@ -386,13 +388,15 @@ impl_node_port_enum_params(struct spa_node *node,
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamBuffers, id, SPA_TYPE_OBJECT_ParamBuffers, id,
":", SPA_PARAM_BUFFERS_buffers, "iru", buffers, SPA_PARAM_BUFFERS_buffers, &SPA_POD_CHOICE_RANGE_Int(buffers, 1, MAX_BUFFERS),
SPA_POD_PROP_MIN_MAX(1, MAX_BUFFERS), SPA_PARAM_BUFFERS_blocks, &SPA_POD_Int(port->blocks),
":", SPA_PARAM_BUFFERS_blocks, "i", port->blocks, SPA_PARAM_BUFFERS_size, &SPA_POD_CHOICE_RANGE_Int(
":", SPA_PARAM_BUFFERS_size, "iru", size * port->stride, size * port->stride,
SPA_POD_PROP_MIN_MAX(16 * port->stride, INT32_MAX / port->stride), 16 * port->stride,
":", SPA_PARAM_BUFFERS_stride, "i", port->stride, INT32_MAX / port->stride),
":", SPA_PARAM_BUFFERS_align, "i", 16); SPA_PARAM_BUFFERS_stride, &SPA_POD_Int(port->stride),
SPA_PARAM_BUFFERS_align, &SPA_POD_Int(16),
0);
break; break;
} }
case SPA_PARAM_Meta: case SPA_PARAM_Meta:
@ -403,8 +407,9 @@ impl_node_port_enum_params(struct spa_node *node,
case 0: case 0:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamMeta, id, SPA_TYPE_OBJECT_ParamMeta, id,
":", SPA_PARAM_META_type, "I", SPA_META_Header, SPA_PARAM_META_type, &SPA_POD_Id(SPA_META_Header),
":", SPA_PARAM_META_size, "i", sizeof(struct spa_meta_header)); SPA_PARAM_META_size, &SPA_POD_Int(sizeof(struct spa_meta_header)),
0);
break; break;
default: default:
return 0; return 0;
@ -415,14 +420,16 @@ impl_node_port_enum_params(struct spa_node *node,
case 0: case 0:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamIO, id, SPA_TYPE_OBJECT_ParamIO, id,
":", SPA_PARAM_IO_id, "I", SPA_IO_Buffers, SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Buffers),
":", SPA_PARAM_IO_size, "i", sizeof(struct spa_io_buffers)); SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_buffers)),
0);
break; break;
case 1: case 1:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamIO, id, SPA_TYPE_OBJECT_ParamIO, id,
":", SPA_PARAM_IO_id, "I", SPA_IO_Range, SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Range),
":", SPA_PARAM_IO_size, "i", sizeof(struct spa_io_range)); SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_range)),
0);
break; break;
default: default:
return 0; return 0;

View file

@ -303,55 +303,51 @@ static int port_enum_formats(struct spa_node *node,
struct spa_pod_builder *builder) struct spa_pod_builder *builder)
{ {
struct impl *this = SPA_CONTAINER_OF(node, struct impl, node); struct impl *this = SPA_CONTAINER_OF(node, struct impl, node);
uint32_t rate; struct spa_pod *prate;
const char *rspec;
switch (*index) { switch (*index) {
case 0: case 0:
if (this->have_format || this->force_rate) { if (this->have_format || this->force_rate)
rate = this->format.info.raw.rate; prate = (struct spa_pod*)&SPA_POD_Int(this->format.info.raw.rate);
rspec = "ir"; else
} prate = (struct spa_pod*)&SPA_POD_CHOICE_RANGE_Int(DEFAULT_RATE, 1, INT32_MAX);
else {
rate = DEFAULT_RATE;
rspec = "iru";
}
if (direction == SPA_DIRECTION_INPUT) { if (direction == SPA_DIRECTION_INPUT) {
*param = spa_pod_builder_object(builder, *param = spa_pod_builder_object(builder,
SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat, SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
":", SPA_FORMAT_mediaType, "I", SPA_MEDIA_TYPE_audio, SPA_FORMAT_mediaType, &SPA_POD_Id(SPA_MEDIA_TYPE_audio),
":", SPA_FORMAT_mediaSubtype, "I", SPA_MEDIA_SUBTYPE_raw, SPA_FORMAT_mediaSubtype, &SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw),
":", SPA_FORMAT_AUDIO_format, "Ieu", SPA_AUDIO_FORMAT_F32, SPA_FORMAT_AUDIO_format, &SPA_POD_CHOICE_ENUM_Id(12,
SPA_POD_PROP_ENUM(11, SPA_AUDIO_FORMAT_F32,
SPA_AUDIO_FORMAT_F32, SPA_AUDIO_FORMAT_F32,
SPA_AUDIO_FORMAT_F32_OE, SPA_AUDIO_FORMAT_F32_OE,
SPA_AUDIO_FORMAT_S32, SPA_AUDIO_FORMAT_S32,
SPA_AUDIO_FORMAT_S32_OE, SPA_AUDIO_FORMAT_S32_OE,
SPA_AUDIO_FORMAT_S24_32, SPA_AUDIO_FORMAT_S24_32,
SPA_AUDIO_FORMAT_S24_32_OE, SPA_AUDIO_FORMAT_S24_32_OE,
SPA_AUDIO_FORMAT_S24, SPA_AUDIO_FORMAT_S24,
SPA_AUDIO_FORMAT_S24_OE, SPA_AUDIO_FORMAT_S24_OE,
SPA_AUDIO_FORMAT_S16, SPA_AUDIO_FORMAT_S16,
SPA_AUDIO_FORMAT_S16_OE, SPA_AUDIO_FORMAT_S16_OE,
SPA_AUDIO_FORMAT_U8), SPA_AUDIO_FORMAT_U8),
":", SPA_FORMAT_AUDIO_layout, "Ieu", SPA_AUDIO_LAYOUT_INTERLEAVED, SPA_FORMAT_AUDIO_layout, &SPA_POD_CHOICE_ENUM_Id(3,
SPA_POD_PROP_ENUM(2, SPA_AUDIO_LAYOUT_INTERLEAVED, SPA_AUDIO_LAYOUT_INTERLEAVED,
SPA_AUDIO_LAYOUT_NON_INTERLEAVED), SPA_AUDIO_LAYOUT_INTERLEAVED,
":", SPA_FORMAT_AUDIO_rate, rspec, rate, SPA_AUDIO_LAYOUT_NON_INTERLEAVED),
SPA_POD_PROP_MIN_MAX(1, INT32_MAX), SPA_FORMAT_AUDIO_rate, prate,
":", SPA_FORMAT_AUDIO_channels, "i", this->port_count); SPA_FORMAT_AUDIO_channels, &SPA_POD_Int(this->port_count),
0);
} }
else { else {
*param = spa_pod_builder_object(builder, *param = spa_pod_builder_object(builder,
SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat, SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
":", SPA_FORMAT_mediaType, "I", SPA_MEDIA_TYPE_audio, SPA_FORMAT_mediaType, &SPA_POD_Id(SPA_MEDIA_TYPE_audio),
":", SPA_FORMAT_mediaSubtype, "I", SPA_MEDIA_SUBTYPE_raw, SPA_FORMAT_mediaSubtype, &SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw),
":", SPA_FORMAT_AUDIO_format, "I", SPA_AUDIO_FORMAT_F32, SPA_FORMAT_AUDIO_format, &SPA_POD_Id(SPA_AUDIO_FORMAT_F32),
":", SPA_FORMAT_AUDIO_layout, "I", SPA_AUDIO_LAYOUT_NON_INTERLEAVED, SPA_FORMAT_AUDIO_layout, &SPA_POD_Id(SPA_AUDIO_LAYOUT_NON_INTERLEAVED),
":", SPA_FORMAT_AUDIO_rate, rspec, rate, SPA_FORMAT_AUDIO_rate, prate,
SPA_POD_PROP_MIN_MAX(1, INT32_MAX), SPA_FORMAT_AUDIO_channels, &SPA_POD_Int(1),
":", SPA_FORMAT_AUDIO_channels, "i", 1); 0);
} }
break; break;
default: default:
@ -400,8 +396,10 @@ impl_node_port_enum_params(struct spa_node *node,
SPA_PARAM_IO }; SPA_PARAM_IO };
if (*index < SPA_N_ELEMENTS(list)) if (*index < SPA_N_ELEMENTS(list))
param = spa_pod_builder_object(&b, SPA_TYPE_OBJECT_ParamList, id, param = spa_pod_builder_object(&b,
":", SPA_PARAM_LIST_id, "I", list[*index]); SPA_TYPE_OBJECT_ParamList, id,
SPA_PARAM_LIST_id, &SPA_POD_Id(list[*index]),
0);
else else
return 0; return 0;
break; break;
@ -426,13 +424,15 @@ impl_node_port_enum_params(struct spa_node *node,
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamBuffers, id, SPA_TYPE_OBJECT_ParamBuffers, id,
":", SPA_PARAM_BUFFERS_buffers, "iru", 1, SPA_PARAM_BUFFERS_buffers, &SPA_POD_CHOICE_RANGE_Int(1, 1, MAX_BUFFERS),
SPA_POD_PROP_MIN_MAX(1, MAX_BUFFERS), SPA_PARAM_BUFFERS_blocks, &SPA_POD_Int(port->blocks),
":", SPA_PARAM_BUFFERS_blocks, "i", port->blocks, SPA_PARAM_BUFFERS_size, &SPA_POD_CHOICE_RANGE_Int(
":", SPA_PARAM_BUFFERS_size, "iru", 1024 * port->stride, 1024 * port->stride,
SPA_POD_PROP_MIN_MAX(16 * port->stride, MAX_SAMPLES * port->stride), 16 * port->stride,
":", SPA_PARAM_BUFFERS_stride, "i", port->stride, MAX_SAMPLES * port->stride),
":", SPA_PARAM_BUFFERS_align, "i", 16); SPA_PARAM_BUFFERS_stride, &SPA_POD_Int(port->stride),
SPA_PARAM_BUFFERS_align, &SPA_POD_Int(16),
0);
break; break;
case SPA_PARAM_Meta: case SPA_PARAM_Meta:
@ -443,8 +443,9 @@ impl_node_port_enum_params(struct spa_node *node,
case 0: case 0:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamMeta, id, SPA_TYPE_OBJECT_ParamMeta, id,
":", SPA_PARAM_META_type, "I", SPA_META_Header, SPA_PARAM_META_type, &SPA_POD_Id(SPA_META_Header),
":", SPA_PARAM_META_size, "i", sizeof(struct spa_meta_header)); SPA_PARAM_META_size, &SPA_POD_Int(sizeof(struct spa_meta_header)),
0);
break; break;
default: default:
return 0; return 0;
@ -455,8 +456,9 @@ impl_node_port_enum_params(struct spa_node *node,
case 0: case 0:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamIO, id, SPA_TYPE_OBJECT_ParamIO, id,
":", SPA_PARAM_IO_id, "I", SPA_IO_Buffers, SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Buffers),
":", SPA_PARAM_IO_size, "i", sizeof(struct spa_io_buffers)); SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_buffers)),
0);
break; break;
default: default:
return 0; return 0;

View file

@ -328,23 +328,24 @@ static int port_enum_formats(struct spa_node *node,
if (this->have_format) { if (this->have_format) {
*param = spa_pod_builder_object(builder, *param = spa_pod_builder_object(builder,
SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat, SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
":", SPA_FORMAT_mediaType, "I", SPA_MEDIA_TYPE_audio, SPA_FORMAT_mediaType, &SPA_POD_Id(SPA_MEDIA_TYPE_audio),
":", SPA_FORMAT_mediaSubtype, "I", SPA_MEDIA_SUBTYPE_raw, SPA_FORMAT_mediaSubtype, &SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw),
":", SPA_FORMAT_AUDIO_format, "I", this->format.info.raw.format, SPA_FORMAT_AUDIO_format, &SPA_POD_Id(this->format.info.raw.format),
":", SPA_FORMAT_AUDIO_rate, "i", this->format.info.raw.rate, SPA_FORMAT_AUDIO_rate, &SPA_POD_Int(this->format.info.raw.rate),
":", SPA_FORMAT_AUDIO_channels, "i", this->format.info.raw.channels); SPA_FORMAT_AUDIO_channels, &SPA_POD_Int(this->format.info.raw.channels),
0);
} else { } else {
*param = spa_pod_builder_object(builder, *param = spa_pod_builder_object(builder,
SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat, SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
":", SPA_FORMAT_mediaType, "I", SPA_MEDIA_TYPE_audio, SPA_FORMAT_mediaType, &SPA_POD_Id(SPA_MEDIA_TYPE_audio),
":", SPA_FORMAT_mediaSubtype, "I", SPA_MEDIA_SUBTYPE_raw, SPA_FORMAT_mediaSubtype, &SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw),
":", SPA_FORMAT_AUDIO_format, "Ieu", SPA_AUDIO_FORMAT_S16, SPA_FORMAT_AUDIO_format, &SPA_POD_CHOICE_ENUM_Int(3,
SPA_POD_PROP_ENUM(2, SPA_AUDIO_FORMAT_S16, SPA_AUDIO_FORMAT_S16,
SPA_AUDIO_FORMAT_F32), SPA_AUDIO_FORMAT_S16,
":", SPA_FORMAT_AUDIO_rate, "iru", 44100, SPA_AUDIO_FORMAT_F32),
SPA_POD_PROP_MIN_MAX(1, INT32_MAX), SPA_FORMAT_AUDIO_rate, &SPA_POD_CHOICE_RANGE_Int(44100, 1, INT32_MAX),
":", SPA_FORMAT_AUDIO_channels, "iru", 2, SPA_FORMAT_AUDIO_channels, &SPA_POD_CHOICE_RANGE_Int(2, 1, INT32_MAX),
SPA_POD_PROP_MIN_MAX(1, INT32_MAX)); 0);
} }
break; break;
default: default:
@ -391,8 +392,10 @@ impl_node_port_enum_params(struct spa_node *node,
SPA_PARAM_IO, }; SPA_PARAM_IO, };
if (*index < SPA_N_ELEMENTS(list)) if (*index < SPA_N_ELEMENTS(list))
param = spa_pod_builder_object(&b, SPA_TYPE_OBJECT_ParamList, id, param = spa_pod_builder_object(&b,
":", SPA_PARAM_LIST_id, "I", list[*index]); SPA_TYPE_OBJECT_ParamList, id,
SPA_PARAM_LIST_id, &SPA_POD_Id(list[*index]),
0);
else else
return 0; return 0;
break; break;
@ -417,13 +420,15 @@ impl_node_port_enum_params(struct spa_node *node,
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamBuffers, id, SPA_TYPE_OBJECT_ParamBuffers, id,
":", SPA_PARAM_BUFFERS_buffers, "iru", 1, SPA_PARAM_BUFFERS_buffers, &SPA_POD_CHOICE_RANGE_Int(1, 1, MAX_BUFFERS),
SPA_POD_PROP_MIN_MAX(1, MAX_BUFFERS), SPA_PARAM_BUFFERS_blocks, &SPA_POD_Int(1),
":", SPA_PARAM_BUFFERS_blocks, "i", 1, SPA_PARAM_BUFFERS_size, &SPA_POD_CHOICE_RANGE_Int(
":", SPA_PARAM_BUFFERS_size, "iru", 1024 * this->bpf, 1024 * this->bpf,
SPA_POD_PROP_MIN_MAX(16 * this->bpf, INT32_MAX / this->bpf), 16 * this->bpf,
":", SPA_PARAM_BUFFERS_stride, "i", 0, INT32_MAX / this->bpf),
":", SPA_PARAM_BUFFERS_align, "i", 16); SPA_PARAM_BUFFERS_stride, &SPA_POD_Int(0),
SPA_PARAM_BUFFERS_align, &SPA_POD_Int(16),
0);
break; break;
case SPA_PARAM_Meta: case SPA_PARAM_Meta:
if (!port->have_format) if (!port->have_format)
@ -433,8 +438,9 @@ impl_node_port_enum_params(struct spa_node *node,
case 0: case 0:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamMeta, id, SPA_TYPE_OBJECT_ParamMeta, id,
":", SPA_PARAM_META_type, "I", SPA_META_Header, SPA_PARAM_META_type, &SPA_POD_Id(SPA_META_Header),
":", SPA_PARAM_META_size, "i", sizeof(struct spa_meta_header)); SPA_PARAM_META_size, &SPA_POD_Int(sizeof(struct spa_meta_header)),
0);
break; break;
default: default:
return 0; return 0;
@ -445,20 +451,23 @@ impl_node_port_enum_params(struct spa_node *node,
case 0: case 0:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamIO, id, SPA_TYPE_OBJECT_ParamIO, id,
":", SPA_PARAM_IO_id, "I", SPA_IO_Buffers, SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Buffers),
":", SPA_PARAM_IO_size, "i", sizeof(struct spa_io_buffers)); SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_buffers)),
0);
break; break;
case 1: case 1:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamIO, id, SPA_TYPE_OBJECT_ParamIO, id,
":", SPA_PARAM_IO_id, "I", SPA_IO_Range, SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Range),
":", SPA_PARAM_IO_size, "i", sizeof(struct spa_io_range)); SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_range)),
0);
break; break;
case 2: case 2:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamIO, id, SPA_TYPE_OBJECT_ParamIO, id,
":", SPA_PARAM_IO_id, "I", SPA_IO_Control, SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Control),
":", SPA_PARAM_IO_size, "i", sizeof(struct spa_io_sequence)); SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_sequence)),
0);
break; break;
default: default:
return 0; return 0;

View file

@ -53,8 +53,8 @@ enum wave_type {
struct props { struct props {
bool live; bool live;
uint32_t wave; uint32_t wave;
double freq; float freq;
double volume; float volume;
}; };
static void reset_props(struct props *props) static void reset_props(struct props *props)
@ -100,15 +100,11 @@ struct impl {
struct spa_io_range *io_range; struct spa_io_range *io_range;
struct spa_io_sequence *io_control; struct spa_io_sequence *io_control;
uint32_t *io_wave;
double *io_freq;
double *io_volume;
bool have_format; bool have_format;
struct spa_audio_info current_format; struct spa_audio_info current_format;
size_t bpf; size_t bpf;
render_func_t render_func; render_func_t render_func;
double accumulator; float accumulator;
struct buffer buffers[MAX_BUFFERS]; struct buffer buffers[MAX_BUFFERS];
uint32_t n_buffers; uint32_t n_buffers;
@ -150,8 +146,10 @@ static int impl_node_enum_params(struct spa_node *node,
SPA_PARAM_Props }; SPA_PARAM_Props };
if (*index < SPA_N_ELEMENTS(list)) if (*index < SPA_N_ELEMENTS(list))
param = spa_pod_builder_object(&b, SPA_TYPE_OBJECT_ParamList, id, param = spa_pod_builder_object(&b,
":", SPA_PARAM_LIST_id, "I", list[*index]); SPA_TYPE_OBJECT_ParamList, id,
SPA_PARAM_LIST_id, &SPA_POD_Id(list[*index]),
0);
else else
return 0; return 0;
break; break;
@ -164,35 +162,42 @@ static int impl_node_enum_params(struct spa_node *node,
case 0: case 0:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_PropInfo, id, SPA_TYPE_OBJECT_PropInfo, id,
":", SPA_PROP_INFO_id, "I", SPA_PROP_live, SPA_PROP_INFO_id, &SPA_POD_Id(SPA_PROP_live),
":", SPA_PROP_INFO_name, "s", "Configure live mode of the source", SPA_PROP_INFO_name, &SPA_POD_Stringc("Configure live mode of the source"),
":", SPA_PROP_INFO_type, "b", p->live); SPA_PROP_INFO_type, &SPA_POD_Bool(p->live),
0);
break; break;
case 1: case 1:
param = spa_pod_builder_object(&b, spa_pod_builder_push_object(&b, SPA_TYPE_OBJECT_PropInfo, id);
SPA_TYPE_OBJECT_PropInfo, id, spa_pod_builder_props(&b,
":", SPA_PROP_INFO_id, "I", SPA_PROP_waveType, SPA_PROP_INFO_id, &SPA_POD_Id(SPA_PROP_waveType),
":", SPA_PROP_INFO_name, "s", "Select the waveform", SPA_PROP_INFO_name, &SPA_POD_Stringc("Select the waveform"),
":", SPA_PROP_INFO_type, "i", p->wave, SPA_PROP_INFO_type, &SPA_POD_Int(p->wave),
":", SPA_PROP_INFO_labels, "[-i", 0);
"i", WAVE_SINE, "s", "Sine wave", spa_pod_builder_prop(&b, SPA_PROP_INFO_labels, SPA_POD_PROP_FLAG_INFO);
"i", WAVE_SQUARE, "s", "Square wave", "]"); spa_pod_builder_push_struct(&b);
spa_pod_builder_int(&b, WAVE_SINE);
spa_pod_builder_string(&b, "Sine wave");
spa_pod_builder_int(&b, WAVE_SQUARE);
spa_pod_builder_string(&b, "Square wave");
spa_pod_builder_pop(&b);
param = spa_pod_builder_pop(&b);
break; break;
case 2: case 2:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_PropInfo, id, SPA_TYPE_OBJECT_PropInfo, id,
":", SPA_PROP_INFO_id, "I", SPA_PROP_frequency, SPA_PROP_INFO_id, &SPA_POD_Id(SPA_PROP_frequency),
":", SPA_PROP_INFO_name, "s", "Select the frequency", SPA_PROP_INFO_name, &SPA_POD_Stringc("Select the frequency"),
":", SPA_PROP_INFO_type, "dr", p->freq, SPA_PROP_INFO_type, &SPA_POD_CHOICE_RANGE_Float(p->freq, 0.0, 50000000.0),
SPA_POD_PROP_MIN_MAX(0.0, 50000000.0)); 0);
break; break;
case 3: case 3:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_PropInfo, id, SPA_TYPE_OBJECT_PropInfo, id,
":", SPA_PROP_INFO_id, "I", SPA_PROP_volume, SPA_PROP_INFO_id, &SPA_POD_Id(SPA_PROP_volume),
":", SPA_PROP_INFO_name, "s", "Select the volume", SPA_PROP_INFO_name, &SPA_POD_Stringc("Select the volume"),
":", SPA_PROP_INFO_type, "dr", p->volume, SPA_PROP_INFO_type, &SPA_POD_CHOICE_RANGE_Float(p->volume, 0.0, 10.0),
SPA_POD_PROP_MIN_MAX(0.0, 10.0)); 0);
break; break;
default: default:
return 0; return 0;
@ -207,10 +212,11 @@ static int impl_node_enum_params(struct spa_node *node,
case 0: case 0:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_Props, id, SPA_TYPE_OBJECT_Props, id,
":", SPA_PROP_live, "b", p->live, SPA_PROP_live, &SPA_POD_Bool(p->live),
":", SPA_PROP_waveType, "i", p->wave, SPA_PROP_waveType, &SPA_POD_Int(p->wave),
":", SPA_PROP_frequency, "d", p->freq, SPA_PROP_frequency, &SPA_POD_Float(p->freq),
":", SPA_PROP_volume, "d", p->volume); SPA_PROP_volume, &SPA_POD_Float(p->volume),
0);
break; break;
default: default:
return 0; return 0;
@ -527,18 +533,18 @@ port_enum_formats(struct impl *this,
case 0: case 0:
*param = spa_pod_builder_object(builder, *param = spa_pod_builder_object(builder,
SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat, SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
":", SPA_FORMAT_mediaType, "I", SPA_MEDIA_TYPE_audio, SPA_FORMAT_mediaType, &SPA_POD_Id(SPA_MEDIA_TYPE_audio),
":", SPA_FORMAT_mediaSubtype, "I", SPA_MEDIA_SUBTYPE_raw, SPA_FORMAT_mediaSubtype, &SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw),
":", SPA_FORMAT_AUDIO_format, "Ieu", SPA_AUDIO_FORMAT_S16, SPA_FORMAT_AUDIO_format, &SPA_POD_CHOICE_ENUM_Id(5,
SPA_POD_PROP_ENUM(4, SPA_AUDIO_FORMAT_S16, SPA_AUDIO_FORMAT_S16,
SPA_AUDIO_FORMAT_S32, SPA_AUDIO_FORMAT_S16,
SPA_AUDIO_FORMAT_F32, SPA_AUDIO_FORMAT_S32,
SPA_AUDIO_FORMAT_F64), SPA_AUDIO_FORMAT_F32,
":", SPA_FORMAT_AUDIO_layout, "I", SPA_AUDIO_LAYOUT_INTERLEAVED, SPA_AUDIO_FORMAT_F64),
":", SPA_FORMAT_AUDIO_rate, "iru", 44100, SPA_FORMAT_AUDIO_layout, &SPA_POD_Id(SPA_AUDIO_LAYOUT_INTERLEAVED),
SPA_POD_PROP_MIN_MAX(1, INT32_MAX), SPA_FORMAT_AUDIO_rate, &SPA_POD_CHOICE_RANGE_Int(44100, 1, INT32_MAX),
":", SPA_FORMAT_AUDIO_channels, "iru", 2, SPA_FORMAT_AUDIO_channels, &SPA_POD_CHOICE_RANGE_Int(2, 1, INT32_MAX),
SPA_POD_PROP_MIN_MAX(1, INT32_MAX)); 0);
break; break;
default: default:
return 0; return 0;
@ -581,8 +587,10 @@ impl_node_port_enum_params(struct spa_node *node,
SPA_PARAM_IO, }; SPA_PARAM_IO, };
if (*index < SPA_N_ELEMENTS(list)) if (*index < SPA_N_ELEMENTS(list))
param = spa_pod_builder_object(&b, SPA_TYPE_OBJECT_ParamList, id, param = spa_pod_builder_object(&b,
":", SPA_PARAM_LIST_id, "I", list[*index]); SPA_TYPE_OBJECT_ParamList, id,
SPA_PARAM_LIST_id, &SPA_POD_Id(list[*index]),
0);
else else
return 0; return 0;
break; break;
@ -609,13 +617,15 @@ impl_node_port_enum_params(struct spa_node *node,
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamBuffers, id, SPA_TYPE_OBJECT_ParamBuffers, id,
":", SPA_PARAM_BUFFERS_buffers, "iru", 1, SPA_PARAM_BUFFERS_buffers, &SPA_POD_CHOICE_RANGE_Int(1, 1, MAX_BUFFERS),
SPA_POD_PROP_MIN_MAX(1, MAX_BUFFERS), SPA_PARAM_BUFFERS_blocks, &SPA_POD_Int(1),
":", SPA_PARAM_BUFFERS_blocks, "i", 1, SPA_PARAM_BUFFERS_size, &SPA_POD_CHOICE_RANGE_Int(
":", SPA_PARAM_BUFFERS_size, "iru", 1024 * this->bpf, 1024 * this->bpf,
SPA_POD_PROP_MIN_MAX(16 * this->bpf, INT32_MAX / this->bpf), 16 * this->bpf,
":", SPA_PARAM_BUFFERS_stride, "i", 0, INT32_MAX / this->bpf),
":", SPA_PARAM_BUFFERS_align, "i", 16); SPA_PARAM_BUFFERS_stride, &SPA_POD_Int(0),
SPA_PARAM_BUFFERS_align, &SPA_POD_Int(16),
0);
break; break;
case SPA_PARAM_Meta: case SPA_PARAM_Meta:
if (!this->have_format) if (!this->have_format)
@ -625,8 +635,9 @@ impl_node_port_enum_params(struct spa_node *node,
case 0: case 0:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamMeta, id, SPA_TYPE_OBJECT_ParamMeta, id,
":", SPA_PARAM_META_type, "I", SPA_META_Header, SPA_PARAM_META_type, &SPA_POD_Id(SPA_META_Header),
":", SPA_PARAM_META_size, "i", sizeof(struct spa_meta_header)); SPA_PARAM_META_size, &SPA_POD_Int(sizeof(struct spa_meta_header)),
0);
break; break;
default: default:
return 0; return 0;
@ -637,20 +648,23 @@ impl_node_port_enum_params(struct spa_node *node,
case 0: case 0:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamIO, id, SPA_TYPE_OBJECT_ParamIO, id,
":", SPA_PARAM_IO_id, "I", SPA_IO_Buffers, SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Buffers),
":", SPA_PARAM_IO_size, "i", sizeof(struct spa_io_buffers)); SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_buffers)),
0);
break; break;
case 1: case 1:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamIO, id, SPA_TYPE_OBJECT_ParamIO, id,
":", SPA_PARAM_IO_id, "I", SPA_IO_Range, SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Range),
":", SPA_PARAM_IO_size, "i", sizeof(struct spa_io_range)); SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_range)),
0);
break; break;
case 2: case 2:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamIO, id, SPA_TYPE_OBJECT_ParamIO, id,
":", SPA_PARAM_IO_id, "I", SPA_IO_Control, SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Control),
":", SPA_PARAM_IO_size, "i", sizeof(struct spa_io_sequence)); SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_sequence)),
0);
break; break;
default: default:
return 0; return 0;
@ -1041,10 +1055,6 @@ impl_init(const struct spa_handle_factory *factory,
this->node = impl_node; this->node = impl_node;
reset_props(&this->props); reset_props(&this->props);
this->io_wave = &this->props.wave;
this->io_freq = &this->props.freq;
this->io_volume = &this->props.volume;
spa_list_init(&this->empty); spa_list_init(&this->empty);
this->timer_source.func = on_output; this->timer_source.func = on_output;

View file

@ -26,9 +26,9 @@ static void \
audio_test_src_create_sine_##type (struct impl *this, type *samples, size_t n_samples) \ audio_test_src_create_sine_##type (struct impl *this, type *samples, size_t n_samples) \
{ \ { \
int i, c, channels; \ int i, c, channels; \
double step, amp; \ float step, amp; \
double freq = *this->io_freq; \ float freq = this->props.freq; \
double volume = *this->io_volume; \ float volume = this->props.volume; \
\ \
channels = this->current_format.info.raw.channels; \ channels = this->current_format.info.raw.channels; \
step = M_PI_M2 * freq / this->current_format.info.raw.rate; \ step = M_PI_M2 * freq / this->current_format.info.raw.rate; \

View file

@ -166,8 +166,10 @@ static int impl_node_enum_params(struct spa_node *node,
SPA_PARAM_Props }; SPA_PARAM_Props };
if (*index < SPA_N_ELEMENTS(list)) if (*index < SPA_N_ELEMENTS(list))
param = spa_pod_builder_object(&b, SPA_TYPE_OBJECT_ParamList, id, param = spa_pod_builder_object(&b,
":", SPA_PARAM_LIST_id, "I", list[*index]); SPA_TYPE_OBJECT_ParamList, id,
SPA_PARAM_LIST_id, &SPA_POD_Id(list[*index]),
0);
else else
return 0; return 0;
break; break;
@ -180,18 +182,18 @@ static int impl_node_enum_params(struct spa_node *node,
case 0: case 0:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_PropInfo, id, SPA_TYPE_OBJECT_PropInfo, id,
":", SPA_PROP_INFO_id, "I", SPA_PROP_minLatency, SPA_PROP_INFO_id, &SPA_POD_Id(SPA_PROP_minLatency),
":", SPA_PROP_INFO_name, "s", "The minimum latency", SPA_PROP_INFO_name, &SPA_POD_Stringc("The minimum latency"),
":", SPA_PROP_INFO_type, "ir", p->min_latency, SPA_PROP_INFO_type, &SPA_POD_CHOICE_RANGE_Int(p->min_latency, 1, INT32_MAX),
SPA_POD_PROP_MIN_MAX(1, INT32_MAX)); 0);
break; break;
case 1: case 1:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_PropInfo, id, SPA_TYPE_OBJECT_PropInfo, id,
":", SPA_PROP_INFO_id, "I", SPA_PROP_maxLatency, SPA_PROP_INFO_id, &SPA_POD_Id(SPA_PROP_maxLatency),
":", SPA_PROP_INFO_name, "s", "The maximum latency", SPA_PROP_INFO_name, &SPA_POD_Stringc("The maximum latency"),
":", SPA_PROP_INFO_type, "ir", p->max_latency, SPA_PROP_INFO_type, &SPA_POD_CHOICE_RANGE_Int(p->max_latency, 1, INT32_MAX),
SPA_POD_PROP_MIN_MAX(1, INT32_MAX)); 0);
break; break;
default: default:
return 0; return 0;
@ -206,8 +208,9 @@ static int impl_node_enum_params(struct spa_node *node,
case 0: case 0:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_Props, id, SPA_TYPE_OBJECT_Props, id,
":", SPA_PROP_minLatency, "i", p->min_latency, SPA_PROP_minLatency, &SPA_POD_Int(p->min_latency),
":", SPA_PROP_maxLatency, "i", p->max_latency); SPA_PROP_maxLatency, &SPA_POD_Int(p->max_latency),
0);
break; break;
default: default:
return 0; return 0;
@ -946,8 +949,10 @@ impl_node_port_enum_params(struct spa_node *node,
SPA_PARAM_Meta }; SPA_PARAM_Meta };
if (*index < SPA_N_ELEMENTS(list)) if (*index < SPA_N_ELEMENTS(list))
param = spa_pod_builder_object(&b, SPA_TYPE_OBJECT_ParamList, id, param = spa_pod_builder_object(&b,
":", SPA_PARAM_LIST_id, "I", list[*index]); SPA_TYPE_OBJECT_ParamList, id,
SPA_PARAM_LIST_id, &SPA_POD_Id(list[*index]),
0);
else else
return 0; return 0;
break; break;
@ -967,12 +972,13 @@ impl_node_port_enum_params(struct spa_node *node,
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_Format, id, SPA_TYPE_OBJECT_Format, id,
":", SPA_FORMAT_mediaType, "I", SPA_MEDIA_TYPE_audio, SPA_FORMAT_mediaType, &SPA_POD_Id(SPA_MEDIA_TYPE_audio),
":", SPA_FORMAT_mediaSubtype, "I", SPA_MEDIA_SUBTYPE_raw, SPA_FORMAT_mediaSubtype, &SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw),
":", SPA_FORMAT_AUDIO_format, "I", SPA_AUDIO_FORMAT_S16, SPA_FORMAT_AUDIO_format, &SPA_POD_Id(SPA_AUDIO_FORMAT_S16),
":", SPA_FORMAT_AUDIO_layout, "I", SPA_AUDIO_LAYOUT_INTERLEAVED, SPA_FORMAT_AUDIO_layout, &SPA_POD_Id(SPA_AUDIO_LAYOUT_INTERLEAVED),
":", SPA_FORMAT_AUDIO_rate, "i", rate, SPA_FORMAT_AUDIO_rate, &SPA_POD_Int(rate),
":", SPA_FORMAT_AUDIO_channels, "i", channels); SPA_FORMAT_AUDIO_channels, &SPA_POD_Int(channels),
0);
} }
else else
return -EIO; return -EIO;
@ -995,15 +1001,15 @@ impl_node_port_enum_params(struct spa_node *node,
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamBuffers, id, SPA_TYPE_OBJECT_ParamBuffers, id,
":", SPA_PARAM_BUFFERS_buffers, "ir", 2, SPA_PARAM_BUFFERS_buffers, &SPA_POD_CHOICE_RANGE_Int(2, 2, MAX_BUFFERS),
SPA_POD_PROP_MIN_MAX(2, MAX_BUFFERS), SPA_PARAM_BUFFERS_blocks, &SPA_POD_Int(1),
":", SPA_PARAM_BUFFERS_blocks, "i", 1, SPA_PARAM_BUFFERS_size, &SPA_POD_CHOICE_RANGE_Int(
":", SPA_PARAM_BUFFERS_size, "iru", this->props.min_latency * this->props.min_latency * this->frame_size,
this->frame_size, this->props.min_latency * this->frame_size,
SPA_POD_PROP_MIN_MAX(this->props.min_latency * this->frame_size, INT32_MAX),
INT32_MAX), SPA_PARAM_BUFFERS_stride, &SPA_POD_Int(0),
":", SPA_PARAM_BUFFERS_stride, "i", 0, SPA_PARAM_BUFFERS_align, &SPA_POD_Int(16),
":", SPA_PARAM_BUFFERS_align, "i", 16); 0);
break; break;
case SPA_PARAM_Meta: case SPA_PARAM_Meta:
@ -1014,8 +1020,9 @@ impl_node_port_enum_params(struct spa_node *node,
case 0: case 0:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamMeta, id, SPA_TYPE_OBJECT_ParamMeta, id,
":", SPA_PARAM_META_type, "I", SPA_META_Header, SPA_PARAM_META_type, &SPA_POD_Id(SPA_META_Header),
":", SPA_PARAM_META_size, "i", sizeof(struct spa_meta_header)); SPA_PARAM_META_size, &SPA_POD_Int(sizeof(struct spa_meta_header)),
0);
break; break;
default: default:
return 0; return 0;

View file

@ -64,33 +64,39 @@ struct spa_bt_monitor {
struct spa_handle_factory spa_a2dp_sink_factory; struct spa_handle_factory spa_a2dp_sink_factory;
static inline void add_dict(struct spa_pod_builder *builder, const char *key, const char *val)
{
spa_pod_builder_string(builder, key);
spa_pod_builder_string(builder, val);
}
static void fill_item(struct spa_bt_monitor *this, struct spa_bt_transport *transport, static void fill_item(struct spa_bt_monitor *this, struct spa_bt_transport *transport,
struct spa_pod **result, struct spa_pod_builder *builder) struct spa_pod **result, struct spa_pod_builder *builder)
{ {
char trans[16]; char trans[16];
spa_pod_builder_add(builder, spa_pod_builder_push_object(builder, SPA_TYPE_OBJECT_MonitorItem, 0);
"{", SPA_TYPE_OBJECT_MonitorItem, 0, spa_pod_builder_props(builder,
":", SPA_MONITOR_ITEM_id, "s", transport->path, SPA_MONITOR_ITEM_id, &SPA_POD_Stringv(transport->path),
":", SPA_MONITOR_ITEM_flags, "I", SPA_MONITOR_ITEM_FLAG_NONE, SPA_MONITOR_ITEM_flags, &SPA_POD_Id(SPA_MONITOR_ITEM_FLAG_NONE),
":", SPA_MONITOR_ITEM_state, "I", SPA_MONITOR_ITEM_STATE_Available, SPA_MONITOR_ITEM_state, &SPA_POD_Id(SPA_MONITOR_ITEM_STATE_Available),
":", SPA_MONITOR_ITEM_name, "s", transport->path, SPA_MONITOR_ITEM_name, &SPA_POD_Stringv(transport->path),
":", SPA_MONITOR_ITEM_class, "s", "Adapter/Bluetooth", SPA_MONITOR_ITEM_class, &SPA_POD_Stringc("Adapter/Bluetooth"),
":", SPA_MONITOR_ITEM_factory, "p", SPA_TYPE_INTERFACE_HandleFactory, &spa_a2dp_sink_factory, SPA_MONITOR_ITEM_factory, &SPA_POD_Pointer(SPA_TYPE_INTERFACE_HandleFactory, &spa_a2dp_sink_factory),
":", SPA_MONITOR_ITEM_info, "[", 0);
NULL);
spa_pod_builder_prop(builder, SPA_MONITOR_ITEM_info, 0);
spa_pod_builder_push_struct(builder);
snprintf(trans, sizeof(trans), "%p", transport); snprintf(trans, sizeof(trans), "%p", transport);
spa_pod_builder_add(builder, add_dict(builder, "device.api", "bluez5");
"s", "device.api", "s", "bluez5", add_dict(builder, "device.name", transport->device->name);
"s", "device.name", "s", transport->device->name, add_dict(builder, "device.icon", transport->device->icon);
"s", "device.icon", "s", transport->device->icon, add_dict(builder, "device.bluez5.address", transport->device->address);
"s", "device.bluez5.address", "s", transport->device->address, add_dict(builder, "bluez5.transport", trans);
"s", "bluez5.transport", "s", trans,
NULL);
*result = spa_pod_builder_add(builder, "]}", NULL); spa_pod_builder_pop(builder);
*result = spa_pod_builder_pop(builder);
} }
static uint8_t a2dp_default_bitpool(struct spa_bt_monitor *monitor, uint8_t freq, uint8_t mode) { static uint8_t a2dp_default_bitpool(struct spa_bt_monitor *monitor, uint8_t freq, uint8_t mode) {
@ -640,7 +646,7 @@ static struct spa_bt_node *node_create(struct spa_bt_monitor *monitor, struct sp
struct spa_pod *item; struct spa_pod *item;
spa_pod_builder_init(&b, buffer, sizeof(buffer)); spa_pod_builder_init(&b, buffer, sizeof(buffer));
event = spa_pod_builder_object(&b, SPA_TYPE_EVENT_Monitor, SPA_MONITOR_EVENT_Added); event = spa_pod_builder_object(&b, SPA_TYPE_EVENT_Monitor, SPA_MONITOR_EVENT_Added, 0);
fill_item(monitor, transport, &item, &b); fill_item(monitor, transport, &item, &b);
monitor->callbacks->event(monitor->callbacks_data, event); monitor->callbacks->event(monitor->callbacks_data, event);
@ -656,7 +662,7 @@ static struct spa_bt_node *node_destroy(struct spa_bt_monitor *monitor, struct s
struct spa_pod *item; struct spa_pod *item;
spa_pod_builder_init(&b, buffer, sizeof(buffer)); spa_pod_builder_init(&b, buffer, sizeof(buffer));
event = spa_pod_builder_object(&b, SPA_TYPE_EVENT_Monitor, SPA_MONITOR_EVENT_Removed); event = spa_pod_builder_object(&b, SPA_TYPE_EVENT_Monitor, SPA_MONITOR_EVENT_Removed, 0);
fill_item(monitor, transport, &item, &b); fill_item(monitor, transport, &item, &b);
monitor->callbacks->event(monitor->callbacks_data, event); monitor->callbacks->event(monitor->callbacks_data, event);

View file

@ -275,8 +275,10 @@ spa_ffmpeg_dec_node_port_enum_params(struct spa_node *node,
SPA_PARAM_Format }; SPA_PARAM_Format };
if (*index < SPA_N_ELEMENTS(list)) if (*index < SPA_N_ELEMENTS(list))
param = spa_pod_builder_object(&b, SPA_TYPE_OBJECT_ParamList, id, param = spa_pod_builder_object(&b,
":", SPA_PARAM_LIST_id, "I", list[*index]); SPA_TYPE_OBJECT_ParamList, id,
SPA_PARAM_LIST_id, &SPA_POD_Id(list[*index]),
0);
else else
return 0; return 0;
break; break;

View file

@ -264,8 +264,10 @@ spa_ffmpeg_enc_node_port_enum_params(struct spa_node *node,
SPA_PARAM_Format }; SPA_PARAM_Format };
if (*index < SPA_N_ELEMENTS(list)) if (*index < SPA_N_ELEMENTS(list))
param = spa_pod_builder_object(&b, SPA_TYPE_OBJECT_ParamList, id, param = spa_pod_builder_object(&b,
":", SPA_PARAM_LIST_id, "I", list[*index]); SPA_TYPE_OBJECT_ParamList, id,
SPA_PARAM_LIST_id, &SPA_POD_Id(list[*index]),
0);
else else
return 0; return 0;
break; break;

View file

@ -117,7 +117,8 @@ static int impl_node_enum_params(struct spa_node *node,
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamList, id, SPA_TYPE_OBJECT_ParamList, id,
":", SPA_PARAM_LIST_id, "I", SPA_PARAM_Props); SPA_PARAM_LIST_id, &SPA_POD_Id(SPA_PARAM_Props),
0);
break; break;
case SPA_PARAM_Props: case SPA_PARAM_Props:
if (*index > 0) if (*index > 0)
@ -125,7 +126,8 @@ static int impl_node_enum_params(struct spa_node *node,
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_Props, id, SPA_TYPE_OBJECT_Props, id,
":", SPA_PROP_live, "b", this->props.live); SPA_PROP_live, &SPA_POD_Bool(this->props.live),
0);
break; break;
default: default:
return -ENOENT; return -ENOENT;
@ -460,8 +462,10 @@ impl_node_port_enum_params(struct spa_node *node,
SPA_PARAM_Meta }; SPA_PARAM_Meta };
if (*index < SPA_N_ELEMENTS(list)) if (*index < SPA_N_ELEMENTS(list))
param = spa_pod_builder_object(&b, SPA_TYPE_OBJECT_ParamList, id, param = spa_pod_builder_object(&b,
":", SPA_PARAM_LIST_id, "I", list[*index]); SPA_TYPE_OBJECT_ParamList, id,
SPA_PARAM_LIST_id, &SPA_POD_Id(list[*index]),
0);
else else
return 0; return 0;
break; break;
@ -480,20 +484,21 @@ impl_node_port_enum_params(struct spa_node *node,
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamBuffers, id, SPA_TYPE_OBJECT_ParamBuffers, id,
":", SPA_PARAM_BUFFERS_buffers, "ir", 2, SPA_PARAM_BUFFERS_buffers, &SPA_POD_CHOICE_RANGE_Int(2, 1, 32),
SPA_POD_PROP_MIN_MAX(1, 32), SPA_PARAM_BUFFERS_blocks, &SPA_POD_Int(1),
":", SPA_PARAM_BUFFERS_blocks, "i", 1, SPA_PARAM_BUFFERS_size, &SPA_POD_Int(128),
":", SPA_PARAM_BUFFERS_size, "i", 128, SPA_PARAM_BUFFERS_stride, &SPA_POD_Int(1),
":", SPA_PARAM_BUFFERS_stride, "i", 1, SPA_PARAM_BUFFERS_align, &SPA_POD_Int(16),
":", SPA_PARAM_BUFFERS_align, "i", 16); 0);
break; break;
case SPA_PARAM_Meta: case SPA_PARAM_Meta:
switch (*index) { switch (*index) {
case 0: case 0:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamMeta, id, SPA_TYPE_OBJECT_ParamMeta, id,
":", SPA_PARAM_META_type, "I", SPA_META_Header, SPA_PARAM_META_type, &SPA_POD_Id(SPA_META_Header),
":", SPA_PARAM_META_size, "i", sizeof(struct spa_meta_header)); SPA_PARAM_META_size, &SPA_POD_Int(sizeof(struct spa_meta_header)),
0);
break; break;
default: default:
return 0; return 0;

View file

@ -121,8 +121,9 @@ static int impl_node_enum_params(struct spa_node *node,
return 0; return 0;
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamList, id, SPA_TYPE_OBJECT_ParamList, id,
":", SPA_PARAM_LIST_id, "I", SPA_PARAM_Props); SPA_PARAM_LIST_id, &SPA_POD_Id(SPA_PARAM_Props),
0);
break; break;
case SPA_PARAM_Props: case SPA_PARAM_Props:
@ -134,9 +135,9 @@ static int impl_node_enum_params(struct spa_node *node,
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_Props, id, SPA_TYPE_OBJECT_Props, id,
":", SPA_PROP_live, "b", p->live, SPA_PROP_live, &SPA_POD_Bool(p->live),
":", SPA_PROP_patternType, "Ie", p->pattern, SPA_PROP_patternType, &SPA_POD_CHOICE_ENUM_Id(2, p->pattern, p->pattern),
SPA_POD_PROP_ENUM(1, p->pattern)); 0);
break; break;
} }
default: default:
@ -476,8 +477,10 @@ impl_node_port_enum_params(struct spa_node *node,
SPA_PARAM_Meta }; SPA_PARAM_Meta };
if (*index < SPA_N_ELEMENTS(list)) if (*index < SPA_N_ELEMENTS(list))
param = spa_pod_builder_object(&b, SPA_TYPE_OBJECT_ParamList, id, param = spa_pod_builder_object(&b,
":", SPA_PARAM_LIST_id, "I", list[*index]); SPA_TYPE_OBJECT_ParamList, id,
SPA_PARAM_LIST_id, &SPA_POD_Id(list[*index]),
0);
else else
return 0; return 0;
break; break;
@ -496,20 +499,21 @@ impl_node_port_enum_params(struct spa_node *node,
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamBuffers, id, SPA_TYPE_OBJECT_ParamBuffers, id,
":", SPA_PARAM_BUFFERS_buffers, "ir", 32, SPA_PARAM_BUFFERS_buffers, &SPA_POD_CHOICE_RANGE_Int(32, 2, 32),
SPA_POD_PROP_MIN_MAX(2, 32), SPA_PARAM_BUFFERS_blocks, &SPA_POD_Int(1),
":", SPA_PARAM_BUFFERS_blocks, "i", 1, SPA_PARAM_BUFFERS_size, &SPA_POD_Int(128),
":", SPA_PARAM_BUFFERS_size, "i", 128, SPA_PARAM_BUFFERS_stride, &SPA_POD_Int(1),
":", SPA_PARAM_BUFFERS_stride, "i", 1, SPA_PARAM_BUFFERS_align, &SPA_POD_Int(16),
":", SPA_PARAM_BUFFERS_align, "i", 16); 0);
break; break;
case SPA_PARAM_Meta: case SPA_PARAM_Meta:
switch (*index) { switch (*index) {
case 0: case 0:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamMeta, id, SPA_TYPE_OBJECT_ParamMeta, id,
":", SPA_PARAM_META_type, "I", SPA_META_Header, SPA_PARAM_META_type, &SPA_POD_Id(SPA_META_Header),
":", SPA_PARAM_META_size, "i", sizeof(struct spa_meta_header)); SPA_PARAM_META_size, &SPA_POD_Int(sizeof(struct spa_meta_header)),
0);
break; break;
default: default:
return 0; return 0;

View file

@ -73,6 +73,12 @@ static int impl_udev_open(struct impl *this)
return 0; return 0;
} }
static inline void add_dict(struct spa_pod_builder *builder, const char *key, const char *val)
{
spa_pod_builder_string(builder, key);
spa_pod_builder_string(builder, val);
}
static void fill_item(struct impl *this, struct item *item, struct udev_device *udevice, static void fill_item(struct impl *this, struct item *item, struct udev_device *udevice,
struct spa_pod **result, struct spa_pod_builder *builder) struct spa_pod **result, struct spa_pod_builder *builder)
{ {
@ -97,43 +103,43 @@ static void fill_item(struct impl *this, struct item *item, struct udev_device *
if (!(name && *name)) if (!(name && *name))
name = "Unknown"; name = "Unknown";
spa_pod_builder_add(builder, spa_pod_builder_push_object(builder, SPA_TYPE_OBJECT_MonitorItem, 0);
"{", SPA_TYPE_OBJECT_MonitorItem, 0, spa_pod_builder_props(builder,
":", SPA_MONITOR_ITEM_id, "s", udev_device_get_syspath(item->udevice), SPA_MONITOR_ITEM_id, &SPA_POD_Stringv(udev_device_get_syspath(item->udevice)),
":", SPA_MONITOR_ITEM_flags, "I", SPA_MONITOR_ITEM_FLAG_NONE, SPA_MONITOR_ITEM_flags, &SPA_POD_Id(SPA_MONITOR_ITEM_FLAG_NONE),
":", SPA_MONITOR_ITEM_state, "I", SPA_MONITOR_ITEM_STATE_Available, SPA_MONITOR_ITEM_state, &SPA_POD_Id(SPA_MONITOR_ITEM_STATE_Available),
":", SPA_MONITOR_ITEM_name, "s", name, SPA_MONITOR_ITEM_name, &SPA_POD_Stringv(name),
":", SPA_MONITOR_ITEM_class, "s", "Video/Source", SPA_MONITOR_ITEM_class, &SPA_POD_Stringc("Video/Source"),
":", SPA_MONITOR_ITEM_factory, "p", SPA_TYPE_INTERFACE_HandleFactory, &spa_v4l2_source_factory, SPA_MONITOR_ITEM_factory, &SPA_POD_Pointer(SPA_TYPE_INTERFACE_HandleFactory, &spa_v4l2_source_factory),
":", SPA_MONITOR_ITEM_info, "[", 0);
NULL);
spa_pod_builder_prop(builder, SPA_MONITOR_ITEM_info, 0);
spa_pod_builder_push_struct(builder);
add_dict(builder, "udev-probed", "1");
add_dict(builder, "device.api", "v4l2");
add_dict(builder, "device.path", udev_device_get_devnode(item->udevice));
spa_pod_builder_add(builder,
"s", "udev-probed", "s", "1",
"s", "device.api", "s", "v4l2",
"s", "device.path", "s", udev_device_get_devnode(item->udevice),
NULL);
str = udev_device_get_property_value(item->udevice, "ID_PATH"); str = udev_device_get_property_value(item->udevice, "ID_PATH");
if (!(str && *str)) if (!(str && *str))
str = udev_device_get_syspath(item->udevice); str = udev_device_get_syspath(item->udevice);
if (str && *str) { if (str && *str) {
spa_pod_builder_add(builder, "s", "device.bus_path", "s", str, 0); add_dict(builder, "device.bus_path", str);
} }
if ((str = udev_device_get_syspath(item->udevice)) && *str) { if ((str = udev_device_get_syspath(item->udevice)) && *str) {
spa_pod_builder_add(builder, "s", "sysfs.path", "s", str, 0); add_dict(builder, "sysfs.path", str);
} }
if ((str = udev_device_get_property_value(item->udevice, "ID_ID")) && *str) { if ((str = udev_device_get_property_value(item->udevice, "ID_ID")) && *str) {
spa_pod_builder_add(builder, "s", "udev.id", "s", str, 0); add_dict(builder, "udev.id", str);
} }
if ((str = udev_device_get_property_value(item->udevice, "ID_BUS")) && *str) { if ((str = udev_device_get_property_value(item->udevice, "ID_BUS")) && *str) {
spa_pod_builder_add(builder, "s", "device.bus", "s", str, 0); add_dict(builder, "device.bus", str);
} }
if ((str = udev_device_get_property_value(item->udevice, "SUBSYSTEM")) && *str) { if ((str = udev_device_get_property_value(item->udevice, "SUBSYSTEM")) && *str) {
spa_pod_builder_add(builder, "s", "device.subsystem", "s", str, 0); add_dict(builder, "device.subsystem", str);
} }
if ((str = udev_device_get_property_value(item->udevice, "ID_VENDOR_ID")) && *str) { if ((str = udev_device_get_property_value(item->udevice, "ID_VENDOR_ID")) && *str) {
spa_pod_builder_add(builder, "s", "device.vendor.id", "s", str, 0); add_dict(builder, "device.vendor.id", str);
} }
str = udev_device_get_property_value(item->udevice, "ID_VENDOR_FROM_DATABASE"); str = udev_device_get_property_value(item->udevice, "ID_VENDOR_FROM_DATABASE");
if (!(str && *str)) { if (!(str && *str)) {
@ -143,20 +149,21 @@ static void fill_item(struct impl *this, struct item *item, struct udev_device *
} }
} }
if (str && *str) { if (str && *str) {
spa_pod_builder_add(builder, "s", "device.vendor.name", "s", str, 0); add_dict(builder, "device.vendor.name", str);
} }
if ((str = udev_device_get_property_value(item->udevice, "ID_MODEL_ID")) && *str) { if ((str = udev_device_get_property_value(item->udevice, "ID_MODEL_ID")) && *str) {
spa_pod_builder_add(builder, "s", "device.product.id", "s", str, 0); add_dict(builder, "device.product.id", str);
} }
spa_pod_builder_add(builder, "s", "device.product.name", "s", name, 0); add_dict(builder, "device.product.name", name);
if ((str = udev_device_get_property_value(item->udevice, "ID_SERIAL")) && *str) { if ((str = udev_device_get_property_value(item->udevice, "ID_SERIAL")) && *str) {
spa_pod_builder_add(builder, "s", "device.serial", "s", str, 0); add_dict(builder, "device.serial", str);
} }
if ((str = udev_device_get_property_value(item->udevice, "ID_V4L_CAPABILITIES")) && *str) { if ((str = udev_device_get_property_value(item->udevice, "ID_V4L_CAPABILITIES")) && *str) {
spa_pod_builder_add(builder, "s", "device.capabilities", "s", str, 0); add_dict(builder, "device.capabilities", str);
} }
*result = spa_pod_builder_add(builder, "]}", NULL); spa_pod_builder_pop(builder);
*result = spa_pod_builder_pop(builder);
} }
static void impl_on_fd_events(struct spa_source *source) static void impl_on_fd_events(struct spa_source *source)
@ -187,7 +194,7 @@ static void impl_on_fd_events(struct spa_source *source)
return; return;
spa_pod_builder_init(&b, buffer, sizeof(buffer)); spa_pod_builder_init(&b, buffer, sizeof(buffer));
event = spa_pod_builder_object(&b, SPA_TYPE_EVENT_Monitor, id); event = spa_pod_builder_object(&b, SPA_TYPE_EVENT_Monitor, id, 0);
fill_item(this, &this->uitem, dev, &item, &b); fill_item(this, &this->uitem, dev, &item, &b);
this->callbacks->event(this->callbacks_data, event); this->callbacks->event(this->callbacks_data, event);

View file

@ -164,8 +164,10 @@ static int impl_node_enum_params(struct spa_node *node,
SPA_PARAM_Props }; SPA_PARAM_Props };
if (*index < SPA_N_ELEMENTS(list)) if (*index < SPA_N_ELEMENTS(list))
param = spa_pod_builder_object(&b, SPA_TYPE_OBJECT_ParamList, id, param = spa_pod_builder_object(&b,
":", SPA_PARAM_LIST_id, "I", list[*index]); SPA_TYPE_OBJECT_ParamList, id,
SPA_PARAM_LIST_id, &SPA_POD_Id(list[*index]),
0);
else else
return 0; return 0;
break; break;
@ -178,23 +180,26 @@ static int impl_node_enum_params(struct spa_node *node,
case 0: case 0:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_PropInfo, id, SPA_TYPE_OBJECT_PropInfo, id,
":", SPA_PROP_INFO_id, "I", SPA_PROP_device, SPA_PROP_INFO_id, &SPA_POD_Id(SPA_PROP_device),
":", SPA_PROP_INFO_name, "s", "The V4L2 device", SPA_PROP_INFO_name, &SPA_POD_Stringc("The V4L2 device"),
":", SPA_PROP_INFO_type, "S", p->device, sizeof(p->device)); SPA_PROP_INFO_type, &SPA_POD_Stringv(p->device),
0);
break; break;
case 1: case 1:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_PropInfo, id, SPA_TYPE_OBJECT_PropInfo, id,
":", SPA_PROP_INFO_id, "I", SPA_PROP_deviceName, SPA_PROP_INFO_id, &SPA_POD_Id(SPA_PROP_deviceName),
":", SPA_PROP_INFO_name, "s", "The V4L2 device name", SPA_PROP_INFO_name, &SPA_POD_Stringc("The V4L2 device name"),
":", SPA_PROP_INFO_type, "S-r", p->device_name, sizeof(p->device_name)); SPA_PROP_INFO_type, &SPA_POD_Stringv(p->device_name),
0);
break; break;
case 2: case 2:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_PropInfo, id, SPA_TYPE_OBJECT_PropInfo, id,
":", SPA_PROP_INFO_id, "I", SPA_PROP_deviceFd, SPA_PROP_INFO_id, &SPA_POD_Id(SPA_PROP_deviceFd),
":", SPA_PROP_INFO_name, "s", "The V4L2 fd", SPA_PROP_INFO_name, &SPA_POD_Stringc("The V4L2 fd"),
":", SPA_PROP_INFO_type, "i-r", p->device_fd); SPA_PROP_INFO_type, &SPA_POD_Int(p->device_fd),
0);
break; break;
default: default:
return 0; return 0;
@ -209,9 +214,10 @@ static int impl_node_enum_params(struct spa_node *node,
case 0: case 0:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_Props, id, SPA_TYPE_OBJECT_Props, id,
":", SPA_PROP_device, "S", p->device, sizeof(p->device), SPA_PROP_device, &SPA_POD_Stringv(p->device),
":", SPA_PROP_deviceName, "S-r", p->device_name, sizeof(p->device_name), SPA_PROP_deviceName, &SPA_POD_Stringv(p->device_name),
":", SPA_PROP_deviceFd, "i-r", p->device_fd); SPA_PROP_deviceFd, &SPA_POD_Int(p->device_fd),
0);
break; break;
default: default:
return 0; return 0;
@ -250,7 +256,7 @@ static int impl_node_set_param(struct spa_node *node,
return 0; return 0;
} }
spa_pod_object_parse(param, spa_pod_object_parse(param,
":", SPA_PROP_device, "?S", p->device, sizeof(p->device), NULL); SPA_PROP_device, "?S", p->device, sizeof(p->device), NULL);
break; break;
} }
default: default:
@ -395,28 +401,31 @@ static int port_get_format(struct spa_node *node,
return 0; return 0;
spa_pod_builder_push_object(builder, SPA_TYPE_OBJECT_Format, SPA_PARAM_Format); spa_pod_builder_push_object(builder, SPA_TYPE_OBJECT_Format, SPA_PARAM_Format);
spa_pod_builder_props(builder,
spa_pod_builder_add(builder, SPA_FORMAT_mediaType, &SPA_POD_Id(port->current_format.media_type),
":", SPA_FORMAT_mediaType, "I", port->current_format.media_type, SPA_FORMAT_mediaSubtype, &SPA_POD_Id(port->current_format.media_subtype),
":", SPA_FORMAT_mediaSubtype, "I", port->current_format.media_subtype, 0); 0);
switch (port->current_format.media_subtype) { switch (port->current_format.media_subtype) {
case SPA_MEDIA_SUBTYPE_raw: case SPA_MEDIA_SUBTYPE_raw:
spa_pod_builder_add(builder, spa_pod_builder_props(builder,
":", SPA_FORMAT_VIDEO_format, "I", port->current_format.info.raw.format, SPA_FORMAT_VIDEO_format, &SPA_POD_Id(port->current_format.info.raw.format),
":", SPA_FORMAT_VIDEO_size, "R", &port->current_format.info.raw.size, SPA_FORMAT_VIDEO_size, &SPA_POD_Rectangle(port->current_format.info.raw.size),
":", SPA_FORMAT_VIDEO_framerate, "F", &port->current_format.info.raw.framerate, 0); SPA_FORMAT_VIDEO_framerate, &SPA_POD_Fraction(port->current_format.info.raw.framerate),
0);
break; break;
case SPA_MEDIA_SUBTYPE_mjpg: case SPA_MEDIA_SUBTYPE_mjpg:
case SPA_MEDIA_SUBTYPE_jpeg: case SPA_MEDIA_SUBTYPE_jpeg:
spa_pod_builder_add(builder, spa_pod_builder_props(builder,
":", SPA_FORMAT_VIDEO_size, "R", &port->current_format.info.mjpg.size, SPA_FORMAT_VIDEO_size, &SPA_POD_Rectangle(port->current_format.info.mjpg.size),
":", SPA_FORMAT_VIDEO_framerate, "F", &port->current_format.info.mjpg.framerate, 0); SPA_FORMAT_VIDEO_framerate, &SPA_POD_Fraction(port->current_format.info.mjpg.framerate),
0);
break; break;
case SPA_MEDIA_SUBTYPE_h264: case SPA_MEDIA_SUBTYPE_h264:
spa_pod_builder_add(builder, spa_pod_builder_props(builder,
":", SPA_FORMAT_VIDEO_size, "R", &port->current_format.info.h264.size, SPA_FORMAT_VIDEO_size, &SPA_POD_Rectangle(port->current_format.info.h264.size),
":", SPA_FORMAT_VIDEO_framerate, "F", &port->current_format.info.h264.framerate, 0); SPA_FORMAT_VIDEO_framerate, &SPA_POD_Fraction(port->current_format.info.h264.framerate),
0);
break; break;
default: default:
return -EIO; return -EIO;
@ -467,8 +476,10 @@ static int impl_node_port_enum_params(struct spa_node *node,
SPA_PARAM_IO }; SPA_PARAM_IO };
if (*index < SPA_N_ELEMENTS(list)) if (*index < SPA_N_ELEMENTS(list))
param = spa_pod_builder_object(&b, SPA_TYPE_OBJECT_ParamList, id, param = spa_pod_builder_object(&b,
":", SPA_PARAM_LIST_id, "I", list[*index]); SPA_TYPE_OBJECT_ParamList, id,
SPA_PARAM_LIST_id, &SPA_POD_Id(list[*index]),
0);
else else
return 0; return 0;
break; break;
@ -491,12 +502,12 @@ static int impl_node_port_enum_params(struct spa_node *node,
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamBuffers, id, SPA_TYPE_OBJECT_ParamBuffers, id,
":", SPA_PARAM_BUFFERS_buffers, "iru", MAX_BUFFERS, SPA_PARAM_BUFFERS_buffers, &SPA_POD_CHOICE_RANGE_Int(MAX_BUFFERS, 2, MAX_BUFFERS),
SPA_POD_PROP_MIN_MAX(2, MAX_BUFFERS), SPA_PARAM_BUFFERS_blocks, &SPA_POD_Int(1),
":", SPA_PARAM_BUFFERS_blocks, "i", 1, SPA_PARAM_BUFFERS_size, &SPA_POD_Int(port->fmt.fmt.pix.sizeimage),
":", SPA_PARAM_BUFFERS_size, "i", port->fmt.fmt.pix.sizeimage, SPA_PARAM_BUFFERS_stride, &SPA_POD_Int(port->fmt.fmt.pix.bytesperline),
":", SPA_PARAM_BUFFERS_stride, "i", port->fmt.fmt.pix.bytesperline, SPA_PARAM_BUFFERS_align, &SPA_POD_Int(16),
":", SPA_PARAM_BUFFERS_align, "i", 16); 0);
break; break;
case SPA_PARAM_Meta: case SPA_PARAM_Meta:
@ -504,8 +515,9 @@ static int impl_node_port_enum_params(struct spa_node *node,
case 0: case 0:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamMeta, id, SPA_TYPE_OBJECT_ParamMeta, id,
":", SPA_PARAM_META_type, "I", SPA_META_Header, SPA_PARAM_META_type, &SPA_POD_Id(SPA_META_Header),
":", SPA_PARAM_META_size, "i", sizeof(struct spa_meta_header)); SPA_PARAM_META_size, &SPA_POD_Int(sizeof(struct spa_meta_header)),
0);
break; break;
default: default:
return 0; return 0;
@ -516,20 +528,23 @@ static int impl_node_port_enum_params(struct spa_node *node,
case 0: case 0:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamIO, id, SPA_TYPE_OBJECT_ParamIO, id,
":", SPA_PARAM_IO_id, "I", SPA_IO_Buffers, SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Buffers),
":", SPA_PARAM_IO_size, "i", sizeof(struct spa_io_buffers)); SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_buffers)),
0);
break; break;
case 1: case 1:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamIO, id, SPA_TYPE_OBJECT_ParamIO, id,
":", SPA_PARAM_IO_id, "I", SPA_IO_Clock, SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Clock),
":", SPA_PARAM_IO_size, "i", sizeof(struct spa_io_clock)); SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_clock)),
0);
break; break;
case 2: case 2:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamIO, id, SPA_TYPE_OBJECT_ParamIO, id,
":", SPA_PARAM_IO_id, "I", SPA_IO_Control, SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Control),
":", SPA_PARAM_IO_size, "i", sizeof(struct spa_io_sequence)); SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_sequence)),
0);
break; break;
default: default:
return 0; return 0;
@ -813,20 +828,19 @@ static int process_control(struct impl *this, struct port *port, struct spa_pod_
switch (c->type) { switch (c->type) {
case SPA_CONTROL_Properties: case SPA_CONTROL_Properties:
{ {
struct spa_pod *pod; struct spa_pod_prop *prop;
struct spa_pod_object *obj = (struct spa_pod_object *) &c->value; struct spa_pod_object *obj = (struct spa_pod_object *) &c->value;
SPA_POD_OBJECT_FOREACH(obj, pod) { SPA_POD_OBJECT_FOREACH(obj, prop) {
struct spa_pod_prop *prop = (struct spa_pod_prop *)pod;
struct v4l2_control c; struct v4l2_control c;
uint32_t control_id; uint32_t control_id;
if ((control_id = prop_to_control_id(prop->body.key)) == 0) if ((control_id = prop_to_control_id(prop->key)) == 0)
continue; continue;
memset (&c, 0, sizeof (c)); memset (&c, 0, sizeof (c));
c.id = control_id; c.id = control_id;
c.value = SPA_POD_VALUE(struct spa_pod_float, &prop->body.value); c.value = SPA_POD_VALUE(struct spa_pod_float, &prop->value);
if (ioctl(port->fd, VIDIOC_S_CTRL, &c) < 0) if (ioctl(port->fd, VIDIOC_S_CTRL, &c) < 0)
spa_log_error(port->log, "VIDIOC_S_CTRL %m"); spa_log_error(port->log, "VIDIOC_S_CTRL %m");

View file

@ -403,24 +403,26 @@ enum_filter_format(uint32_t media_type, int32_t media_subtype,
case SPA_MEDIA_TYPE_image: case SPA_MEDIA_TYPE_image:
if (media_subtype == SPA_MEDIA_SUBTYPE_raw) { if (media_subtype == SPA_MEDIA_SUBTYPE_raw) {
struct spa_pod_prop *p; struct spa_pod_prop *p;
uint32_t n_values; const struct spa_pod *val;
uint32_t n_values, choice;
const uint32_t *values; const uint32_t *values;
if (!(p = spa_pod_find_prop(filter, SPA_FORMAT_VIDEO_format))) if (!(p = spa_pod_find_prop(filter, SPA_FORMAT_VIDEO_format)))
return SPA_VIDEO_FORMAT_UNKNOWN; return SPA_VIDEO_FORMAT_UNKNOWN;
if (p->body.value.type != SPA_TYPE_Enum) val = spa_pod_get_values(&p->value, &n_values, &choice);
if (val->type != SPA_TYPE_Id)
return SPA_VIDEO_FORMAT_UNKNOWN; return SPA_VIDEO_FORMAT_UNKNOWN;
values = SPA_POD_BODY_CONST(&p->body.value); values = SPA_POD_BODY(val);
n_values = SPA_POD_PROP_N_VALUES(p);
if (p->body.flags & SPA_POD_PROP_FLAG_UNSET) { if (choice == SPA_CHOICE_None) {
if (index + 1 < n_values)
video_format = values[index + 1];
} else {
if (index == 0) if (index == 0)
video_format = values[0]; video_format = values[0];
} else {
if (index + 1 < n_values)
video_format = values[index + 1];
} }
} else { } else {
if (index == 0) if (index == 0)
@ -527,7 +529,7 @@ spa_v4l2_enum_format(struct impl *this,
struct port *port = &this->out_ports[0]; struct port *port = &this->out_ports[0];
int res, n_fractions; int res, n_fractions;
const struct format_info *info; const struct format_info *info;
struct spa_pod_prop *prop; struct spa_pod_choice *choice;
uint32_t filter_media_type, filter_media_subtype, video_format; uint32_t filter_media_type, filter_media_subtype, video_format;
if ((res = spa_v4l2_open(this)) < 0) if ((res = spa_v4l2_open(this)) < 0)
@ -590,18 +592,19 @@ spa_v4l2_enum_format(struct impl *this,
while (port->next_frmsize) { while (port->next_frmsize) {
if (filter) { if (filter) {
struct spa_pod_prop *p; struct spa_pod_prop *p;
struct spa_pod *val;
uint32_t n_vals, choice;
/* check if we have a fixed frame size */ /* check if we have a fixed frame size */
if (!(p = spa_pod_find_prop(filter, SPA_FORMAT_VIDEO_size))) if (!(p = spa_pod_find_prop(filter, SPA_FORMAT_VIDEO_size)))
goto do_frmsize; goto do_frmsize;
if (p->body.value.type != SPA_TYPE_Rectangle) { val = spa_pod_get_values(&p->value, &n_vals, &choice);
if (val->type != SPA_TYPE_Rectangle)
goto enum_end; goto enum_end;
}
if (!(p->body.flags & SPA_POD_PROP_FLAG_UNSET)) { if (choice == SPA_CHOICE_None) {
const struct spa_rectangle *values = const struct spa_rectangle *values = SPA_POD_BODY(val);
SPA_POD_BODY_CONST(&p->body.value);
if (port->frmsize.index > 0) if (port->frmsize.index > 0)
goto next_fmtdesc; goto next_fmtdesc;
@ -623,25 +626,27 @@ spa_v4l2_enum_format(struct impl *this,
} }
if (filter) { if (filter) {
struct spa_pod_prop *p; struct spa_pod_prop *p;
struct spa_pod *val;
const struct spa_rectangle step = { 1, 1 }, *values; const struct spa_rectangle step = { 1, 1 }, *values;
uint32_t range; uint32_t choice, i, n_values;
uint32_t i, n_values;
/* check if we have a fixed frame size */ /* check if we have a fixed frame size */
if (!(p = spa_pod_find_prop(filter, SPA_FORMAT_VIDEO_size))) if (!(p = spa_pod_find_prop(filter, SPA_FORMAT_VIDEO_size)))
goto have_size; goto have_size;
range = p->body.flags & SPA_POD_PROP_RANGE_MASK; val = spa_pod_get_values(&p->value, &n_values, &choice);
values = SPA_POD_BODY_CONST(&p->body.value); if (val->type != SPA_TYPE_Rectangle)
n_values = SPA_POD_PROP_N_VALUES(p); goto have_size;
if (range == SPA_POD_PROP_RANGE_MIN_MAX && n_values > 2) { values = SPA_POD_BODY_CONST(val);
if (choice == SPA_CHOICE_Range && n_values > 2) {
if (filter_framesize(&port->frmsize, &values[1], &values[2], &step)) if (filter_framesize(&port->frmsize, &values[1], &values[2], &step))
goto have_size; goto have_size;
} else if (range == SPA_POD_PROP_RANGE_STEP && n_values > 3) { } else if (choice == SPA_CHOICE_Step && n_values > 3) {
if (filter_framesize(&port->frmsize, &values[1], &values[2], &values[3])) if (filter_framesize(&port->frmsize, &values[1], &values[2], &values[3]))
goto have_size; goto have_size;
} else if (range == SPA_POD_PROP_RANGE_ENUM) { } else if (choice == SPA_CHOICE_Enum) {
for (i = 1; i < n_values; i++) { for (i = 1; i < n_values; i++) {
if (filter_framesize(&port->frmsize, &values[i], &values[i], &step)) if (filter_framesize(&port->frmsize, &values[i], &values[i], &step))
goto have_size; goto have_size;
@ -675,23 +680,24 @@ spa_v4l2_enum_format(struct impl *this,
} }
spa_pod_builder_push_object(builder, SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat); spa_pod_builder_push_object(builder, SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat);
spa_pod_builder_add(builder, spa_pod_builder_props(builder,
":", SPA_FORMAT_mediaType, "I", info->media_type, SPA_FORMAT_mediaType, &SPA_POD_Id(info->media_type),
":", SPA_FORMAT_mediaSubtype, "I", info->media_subtype, 0); SPA_FORMAT_mediaSubtype, &SPA_POD_Id(info->media_subtype),
0);
if (info->media_subtype == SPA_MEDIA_SUBTYPE_raw) { if (info->media_subtype == SPA_MEDIA_SUBTYPE_raw) {
spa_pod_builder_add(builder, spa_pod_builder_prop(builder, SPA_FORMAT_VIDEO_format, 0);
":", SPA_FORMAT_VIDEO_format, "I", info->format, 0); spa_pod_builder_id(builder, info->format);
} }
spa_pod_builder_add(builder, spa_pod_builder_prop(builder, SPA_FORMAT_VIDEO_size, 0);
":", SPA_FORMAT_VIDEO_size, "R", &SPA_RECTANGLE(port->frmsize.discrete.width, spa_pod_builder_rectangle(builder, port->frmsize.discrete.width, port->frmsize.discrete.height);
port->frmsize.discrete.height), 0);
spa_pod_builder_prop(builder, SPA_FORMAT_VIDEO_framerate, 0);
prop = spa_pod_builder_deref(builder,
spa_pod_builder_push_prop(builder, SPA_FORMAT_VIDEO_framerate,
SPA_POD_PROP_RANGE_NONE | SPA_POD_PROP_FLAG_UNSET));
n_fractions = 0; n_fractions = 0;
choice = spa_pod_builder_deref(builder,
spa_pod_builder_push_choice(builder, SPA_CHOICE_None, 0));
port->frmival.index = 0; port->frmival.index = 0;
while (true) { while (true) {
@ -709,34 +715,44 @@ spa_v4l2_enum_format(struct impl *this,
} }
if (filter) { if (filter) {
struct spa_pod_prop *p; struct spa_pod_prop *p;
uint32_t range; struct spa_pod *val;
uint32_t i, n_values; uint32_t i, n_values, choice;
const struct spa_fraction step = { 1, 1 }, *values; const struct spa_fraction step = { 1, 1 }, *values;
if (!(p = spa_pod_find_prop(filter, SPA_FORMAT_VIDEO_framerate))) if (!(p = spa_pod_find_prop(filter, SPA_FORMAT_VIDEO_framerate)))
goto have_framerate; goto have_framerate;
if (p->body.value.type != SPA_TYPE_Fraction) val = spa_pod_get_values(&p->value, &n_values, &choice);
if (val->type != SPA_TYPE_Fraction)
goto enum_end; goto enum_end;
range = p->body.flags & SPA_POD_PROP_RANGE_MASK; values = SPA_POD_BODY(val);
values = SPA_POD_BODY_CONST(&p->body.value);
n_values = SPA_POD_PROP_N_VALUES(p);
if (!(p->body.flags & SPA_POD_PROP_FLAG_UNSET)) { switch (choice) {
case SPA_CHOICE_None:
if (filter_framerate(&port->frmival, &values[0], &values[0], &step)) if (filter_framerate(&port->frmival, &values[0], &values[0], &step))
goto have_framerate; goto have_framerate;
} else if (range == SPA_POD_PROP_RANGE_MIN_MAX && n_values > 2) { break;
if (filter_framerate(&port->frmival, &values[1], &values[2], &step))
case SPA_CHOICE_Range:
if (n_values > 2 && filter_framerate(&port->frmival, &values[1], &values[2], &step))
goto have_framerate; goto have_framerate;
} else if (range == SPA_POD_PROP_RANGE_STEP && n_values > 3) { break;
if (filter_framerate(&port->frmival, &values[1], &values[2], &values[3]))
case SPA_CHOICE_Step:
if (n_values > 3 && filter_framerate(&port->frmival, &values[1], &values[2], &values[3]))
goto have_framerate; goto have_framerate;
} else if (range == SPA_POD_PROP_RANGE_ENUM) { break;
case SPA_CHOICE_Enum:
for (i = 1; i < n_values; i++) { for (i = 1; i < n_values; i++) {
if (filter_framerate(&port->frmival, &values[i], &values[i], &step)) if (filter_framerate(&port->frmival, &values[i], &values[i], &step))
goto have_framerate; goto have_framerate;
} }
break;
default:
break;
} }
port->frmival.index++; port->frmival.index++;
continue; continue;
@ -745,7 +761,7 @@ spa_v4l2_enum_format(struct impl *this,
have_framerate: have_framerate:
if (port->frmival.type == V4L2_FRMIVAL_TYPE_DISCRETE) { if (port->frmival.type == V4L2_FRMIVAL_TYPE_DISCRETE) {
prop->body.flags |= SPA_POD_PROP_RANGE_ENUM; choice->body.type = SPA_CHOICE_Enum;
if (n_fractions == 0) if (n_fractions == 0)
spa_pod_builder_fraction(builder, spa_pod_builder_fraction(builder,
port->frmival.discrete.denominator, port->frmival.discrete.denominator,
@ -766,9 +782,9 @@ spa_v4l2_enum_format(struct impl *this,
port->frmival.stepwise.max.numerator); port->frmival.stepwise.max.numerator);
if (port->frmival.type == V4L2_FRMIVAL_TYPE_CONTINUOUS) { if (port->frmival.type == V4L2_FRMIVAL_TYPE_CONTINUOUS) {
prop->body.flags |= SPA_POD_PROP_RANGE_MIN_MAX; choice->body.type = SPA_CHOICE_Range;
} else { } else {
prop->body.flags |= SPA_POD_PROP_RANGE_STEP; choice->body.type = SPA_CHOICE_Step;
spa_pod_builder_fraction(builder, spa_pod_builder_fraction(builder,
port->frmival.stepwise.step.denominator, port->frmival.stepwise.step.denominator,
port->frmival.stepwise.step.numerator); port->frmival.stepwise.step.numerator);
@ -780,9 +796,9 @@ spa_v4l2_enum_format(struct impl *this,
} }
n_fractions++; n_fractions++;
} }
if (n_fractions <= 1) { if (n_fractions <= 1)
prop->body.flags &= ~(SPA_POD_PROP_RANGE_MASK | SPA_POD_PROP_FLAG_UNSET); choice->body.type = SPA_CHOICE_None;
}
spa_pod_builder_pop(builder); spa_pod_builder_pop(builder);
*result = spa_pod_builder_pop(builder); *result = spa_pod_builder_pop(builder);
@ -1052,35 +1068,38 @@ spa_v4l2_enum_controls(struct impl *this,
case V4L2_CTRL_TYPE_INTEGER: case V4L2_CTRL_TYPE_INTEGER:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_PropInfo, SPA_PARAM_PropInfo, SPA_TYPE_OBJECT_PropInfo, SPA_PARAM_PropInfo,
":", SPA_PROP_INFO_id, "I", prop_id, SPA_PROP_INFO_id, &SPA_POD_Id(prop_id),
":", SPA_PROP_INFO_type, "isu", queryctrl.default_value, SPA_PROP_INFO_type, &SPA_POD_CHOICE_STEP_Int(
SPA_POD_PROP_STEP(queryctrl.minimum, queryctrl.default_value,
queryctrl.maximum, queryctrl.minimum,
queryctrl.step), queryctrl.maximum,
":", SPA_PROP_INFO_name, "s", queryctrl.name); queryctrl.step),
SPA_PROP_INFO_name, &SPA_POD_Stringv(queryctrl.name),
0);
break; break;
case V4L2_CTRL_TYPE_BOOLEAN: case V4L2_CTRL_TYPE_BOOLEAN:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_PropInfo, SPA_PARAM_PropInfo, SPA_TYPE_OBJECT_PropInfo, SPA_PARAM_PropInfo,
":", SPA_PROP_INFO_id, "I", prop_id, SPA_PROP_INFO_id, &SPA_POD_Id(prop_id),
":", SPA_PROP_INFO_type, "b-u", queryctrl.default_value, SPA_PROP_INFO_type, &SPA_POD_CHOICE_Bool(queryctrl.default_value),
":", SPA_PROP_INFO_name, "s", queryctrl.name); SPA_PROP_INFO_name, &SPA_POD_Stringv(queryctrl.name),
0);
break; break;
case V4L2_CTRL_TYPE_MENU: case V4L2_CTRL_TYPE_MENU:
{ {
struct v4l2_querymenu querymenu; struct v4l2_querymenu querymenu;
spa_pod_builder_push_object(&b, SPA_TYPE_OBJECT_PropInfo, SPA_PARAM_PropInfo); spa_pod_builder_push_object(&b, SPA_TYPE_OBJECT_PropInfo, SPA_PARAM_PropInfo);
spa_pod_builder_add(&b, spa_pod_builder_props(&b,
":", SPA_PROP_INFO_id, "I", prop_id, SPA_PROP_INFO_id, &SPA_POD_Id(prop_id),
":", SPA_PROP_INFO_type, "i-u", queryctrl.default_value, SPA_PROP_INFO_type, &SPA_POD_CHOICE_ENUM_Int(1, queryctrl.default_value),
":", SPA_PROP_INFO_name, "s", queryctrl.name, SPA_PROP_INFO_name, &SPA_POD_Stringv(queryctrl.name),
NULL); 0);
spa_zero(querymenu); spa_zero(querymenu);
querymenu.id = queryctrl.id; querymenu.id = queryctrl.id;
spa_pod_builder_push_prop(&b, SPA_PROP_INFO_labels, 0); spa_pod_builder_prop(&b, SPA_PROP_INFO_labels, 0);
spa_pod_builder_push_struct(&b); spa_pod_builder_push_struct(&b);
for (querymenu.index = queryctrl.minimum; for (querymenu.index = queryctrl.minimum;
querymenu.index <= queryctrl.maximum; querymenu.index <= queryctrl.maximum;
@ -1091,7 +1110,6 @@ spa_v4l2_enum_controls(struct impl *this,
} }
} }
spa_pod_builder_pop(&b); spa_pod_builder_pop(&b);
spa_pod_builder_pop(&b);
param = spa_pod_builder_pop(&b); param = spa_pod_builder_pop(&b);
break; break;
} }

View file

@ -132,7 +132,8 @@ static int impl_node_enum_params(struct spa_node *node,
if (*index < SPA_N_ELEMENTS(list)) if (*index < SPA_N_ELEMENTS(list))
param = spa_pod_builder_object(&b, SPA_TYPE_OBJECT_ParamList, id, param = spa_pod_builder_object(&b, SPA_TYPE_OBJECT_ParamList, id,
":", SPA_PARAM_LIST_id, "I", list[*index]); SPA_PARAM_LIST_id, &SPA_POD_Id(list[*index]),
0);
else else
return 0; return 0;
break; break;
@ -145,19 +146,26 @@ static int impl_node_enum_params(struct spa_node *node,
case 0: case 0:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_PropInfo, id, SPA_TYPE_OBJECT_PropInfo, id,
":", SPA_PROP_INFO_id, "I", SPA_PROP_live, SPA_PROP_INFO_id, &SPA_POD_Id(SPA_PROP_live),
":", SPA_PROP_INFO_name, "s", "Configure live mode of the source", SPA_PROP_INFO_name, &SPA_POD_Stringc("Configure live mode of the source"),
":", SPA_PROP_INFO_type, "b", p->live); SPA_PROP_INFO_type, &SPA_POD_Bool(p->live),
0);
break; break;
case 1: case 1:
param = spa_pod_builder_object(&b, spa_pod_builder_push_object(&b, SPA_TYPE_OBJECT_PropInfo, id);
SPA_TYPE_OBJECT_PropInfo, id, spa_pod_builder_props(&b,
":", SPA_PROP_INFO_id, "I", SPA_PROP_patternType, SPA_PROP_INFO_id, &SPA_POD_Id(SPA_PROP_patternType),
":", SPA_PROP_INFO_name, "s", "The pattern", SPA_PROP_INFO_name, &SPA_POD_Stringc("The pattern"),
":", SPA_PROP_INFO_type, "i", p->pattern, SPA_PROP_INFO_type, &SPA_POD_Int(p->pattern),
":", SPA_PROP_INFO_labels, "[-i", 0);
"i", PATTERN_SMPTE_SNOW, "s", "SMPTE snow", spa_pod_builder_prop(&b, SPA_PROP_INFO_labels, SPA_POD_PROP_FLAG_INFO),
"i", PATTERN_SNOW, "s", "Snow", "]"); spa_pod_builder_push_struct(&b);
spa_pod_builder_int(&b, PATTERN_SMPTE_SNOW);
spa_pod_builder_string(&b, "SMPTE snow");
spa_pod_builder_int(&b, PATTERN_SNOW);
spa_pod_builder_string(&b, "Snow");
spa_pod_builder_pop(&b);
param = spa_pod_builder_pop(&b);
break; break;
default: default:
return 0; return 0;
@ -172,8 +180,9 @@ static int impl_node_enum_params(struct spa_node *node,
case 0: case 0:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_Props, id, SPA_TYPE_OBJECT_Props, id,
":", SPA_PROP_live, "b", p->live, SPA_PROP_live, &SPA_POD_Bool(p->live),
":", SPA_PROP_patternType, "i", p->pattern); SPA_PROP_patternType, &SPA_POD_Int(p->pattern),
0);
break; break;
default: default:
return 0; return 0;
@ -464,17 +473,21 @@ static int port_enum_formats(struct spa_node *node,
case 0: case 0:
*param = spa_pod_builder_object(builder, *param = spa_pod_builder_object(builder,
SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat, SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
":", SPA_FORMAT_mediaType, "I", SPA_MEDIA_TYPE_video, SPA_FORMAT_mediaType, &SPA_POD_Id(SPA_MEDIA_TYPE_video),
":", SPA_FORMAT_mediaSubtype, "I", SPA_MEDIA_SUBTYPE_raw, SPA_FORMAT_mediaSubtype, &SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw),
":", SPA_FORMAT_VIDEO_format, "Ieu", SPA_VIDEO_FORMAT_RGB, SPA_FORMAT_VIDEO_format, &SPA_POD_CHOICE_ENUM_Id(3,
SPA_POD_PROP_ENUM(2, SPA_VIDEO_FORMAT_RGB, SPA_VIDEO_FORMAT_RGB,
SPA_VIDEO_FORMAT_UYVY), SPA_VIDEO_FORMAT_RGB,
":", SPA_FORMAT_VIDEO_size, "Rru", &SPA_RECTANGLE(320, 240), SPA_VIDEO_FORMAT_UYVY),
SPA_POD_PROP_MIN_MAX(&SPA_RECTANGLE(1, 1), SPA_FORMAT_VIDEO_size, &SPA_POD_CHOICE_RANGE_Rectangle(
&SPA_RECTANGLE(INT32_MAX, INT32_MAX)), SPA_RECTANGLE(320, 240),
":", SPA_FORMAT_VIDEO_framerate, "Fru", &SPA_FRACTION(25,1), SPA_RECTANGLE(1, 1),
SPA_POD_PROP_MIN_MAX(&SPA_FRACTION(0, 1), SPA_RECTANGLE(INT32_MAX, INT32_MAX)),
&SPA_FRACTION(INT32_MAX, 1))); SPA_FORMAT_VIDEO_framerate, &SPA_POD_CHOICE_RANGE_Fraction(
SPA_FRACTION(25,1),
SPA_FRACTION(0, 1),
SPA_FRACTION(INT32_MAX, 1)),
0);
break; break;
default: default:
return 0; return 0;
@ -516,8 +529,10 @@ impl_node_port_enum_params(struct spa_node *node,
SPA_PARAM_Meta }; SPA_PARAM_Meta };
if (*index < SPA_N_ELEMENTS(list)) if (*index < SPA_N_ELEMENTS(list))
param = spa_pod_builder_object(&b, SPA_TYPE_OBJECT_ParamList, id, param = spa_pod_builder_object(&b,
":", SPA_PARAM_LIST_id, "I", list[*index]); SPA_TYPE_OBJECT_ParamList, id,
SPA_PARAM_LIST_id, &SPA_POD_Id(list[*index]),
0);
else else
return 0; return 0;
break; break;
@ -547,12 +562,12 @@ impl_node_port_enum_params(struct spa_node *node,
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamBuffers, id, SPA_TYPE_OBJECT_ParamBuffers, id,
":", SPA_PARAM_BUFFERS_buffers, "ir", 2, SPA_PARAM_BUFFERS_buffers, &SPA_POD_CHOICE_RANGE_Int(2, 1, MAX_BUFFERS),
SPA_POD_PROP_MIN_MAX(1, MAX_BUFFERS), SPA_PARAM_BUFFERS_blocks, &SPA_POD_Int(1),
":", SPA_PARAM_BUFFERS_blocks, "i", 1, SPA_PARAM_BUFFERS_size, &SPA_POD_Int(this->stride * raw_info->size.height),
":", SPA_PARAM_BUFFERS_size, "i", this->stride * raw_info->size.height, SPA_PARAM_BUFFERS_stride, &SPA_POD_Int(this->stride),
":", SPA_PARAM_BUFFERS_stride, "i", this->stride, SPA_PARAM_BUFFERS_align, &SPA_POD_Int(16),
":", SPA_PARAM_BUFFERS_align, "i", 16); 0);
break; break;
} }
case SPA_PARAM_Meta: case SPA_PARAM_Meta:
@ -563,8 +578,9 @@ impl_node_port_enum_params(struct spa_node *node,
case 0: case 0:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamMeta, id, SPA_TYPE_OBJECT_ParamMeta, id,
":", SPA_PARAM_META_type, "I", SPA_META_Header, SPA_PARAM_META_type, &SPA_POD_Id(SPA_META_Header),
":", SPA_PARAM_META_size, "i", sizeof(struct spa_meta_header)); SPA_PARAM_META_size, &SPA_POD_Int(sizeof(struct spa_meta_header)),
0);
break; break;
default: default:

View file

@ -125,8 +125,10 @@ static int impl_node_enum_params(struct spa_node *node,
SPA_PARAM_Props }; SPA_PARAM_Props };
if (*index < SPA_N_ELEMENTS(list)) if (*index < SPA_N_ELEMENTS(list))
param = spa_pod_builder_object(&b, SPA_TYPE_OBJECT_ParamList, id, param = spa_pod_builder_object(&b,
":", SPA_PARAM_LIST_id, "I", list[*index]); SPA_TYPE_OBJECT_ParamList, id,
SPA_PARAM_LIST_id, &SPA_POD_Id(list[*index]),
0);
else else
return 0; return 0;
break; break;
@ -136,17 +138,18 @@ static int impl_node_enum_params(struct spa_node *node,
case 0: case 0:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_PropInfo, id, SPA_TYPE_OBJECT_PropInfo, id,
":", SPA_PROP_INFO_id, "I", SPA_PROP_volume, SPA_PROP_INFO_id, &SPA_POD_Id(SPA_PROP_volume),
":", SPA_PROP_INFO_name, "s", "The volume", SPA_PROP_INFO_name, &SPA_POD_Stringc("The volume"),
":", SPA_PROP_INFO_type, "dr", p->volume, SPA_PROP_INFO_type, &SPA_POD_CHOICE_RANGE_Float(p->volume, 0.0, 10.0),
SPA_POD_PROP_MIN_MAX(0.0, 10.0)); 0);
break; break;
case 1: case 1:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_PropInfo, id, SPA_TYPE_OBJECT_PropInfo, id,
":", SPA_PROP_INFO_id, "I", SPA_PROP_mute, SPA_PROP_INFO_id, &SPA_POD_Id(SPA_PROP_mute),
":", SPA_PROP_INFO_name, "s", "Mute", SPA_PROP_INFO_name, &SPA_POD_Stringc("Mute"),
":", SPA_PROP_INFO_type, "b", p->mute); SPA_PROP_INFO_type, &SPA_POD_Bool(p->mute),
0);
break; break;
default: default:
return 0; return 0;
@ -157,8 +160,9 @@ static int impl_node_enum_params(struct spa_node *node,
case 0: case 0:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_Props, id, SPA_TYPE_OBJECT_Props, id,
":", SPA_PROP_volume, "d", p->volume, SPA_PROP_volume, &SPA_POD_Float(p->volume),
":", SPA_PROP_mute, "b", p->mute); SPA_PROP_mute, &SPA_POD_Bool(p->mute),
0);
break; break;
default: default:
return 0; return 0;
@ -328,15 +332,15 @@ static int port_enum_formats(struct spa_node *node,
case 0: case 0:
*param = spa_pod_builder_object(builder, *param = spa_pod_builder_object(builder,
SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat, SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
":", SPA_FORMAT_mediaType, "I", SPA_MEDIA_TYPE_audio, SPA_FORMAT_mediaType, &SPA_POD_Id(SPA_MEDIA_TYPE_audio),
":", SPA_FORMAT_mediaSubtype, "I", SPA_MEDIA_SUBTYPE_raw, SPA_FORMAT_mediaSubtype, &SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw),
":", SPA_FORMAT_AUDIO_format, "Ieu", SPA_AUDIO_FORMAT_S16, SPA_FORMAT_AUDIO_format, &SPA_POD_CHOICE_ENUM_Id(3,
SPA_POD_PROP_ENUM(2, SPA_AUDIO_FORMAT_S16, SPA_AUDIO_FORMAT_S16,
SPA_AUDIO_FORMAT_S32), SPA_AUDIO_FORMAT_S16,
":", SPA_FORMAT_AUDIO_rate, "iru", 44100, SPA_AUDIO_FORMAT_S32),
SPA_POD_PROP_MIN_MAX(1, INT32_MAX), SPA_FORMAT_AUDIO_rate, &SPA_POD_CHOICE_RANGE_Int(44100, 1, INT32_MAX),
":", SPA_FORMAT_AUDIO_channels,"iru", 2, SPA_FORMAT_AUDIO_channels, &SPA_POD_CHOICE_RANGE_Int(2, 1, INT32_MAX),
SPA_POD_PROP_MIN_MAX(1, INT32_MAX)); 0);
break; break;
default: default:
return 0; return 0;
@ -382,8 +386,10 @@ impl_node_port_enum_params(struct spa_node *node,
SPA_PARAM_IO }; SPA_PARAM_IO };
if (*index < SPA_N_ELEMENTS(list)) if (*index < SPA_N_ELEMENTS(list))
param = spa_pod_builder_object(&b, SPA_TYPE_OBJECT_ParamList, id, param = spa_pod_builder_object(&b,
":", SPA_PARAM_LIST_id, "I", list[*index]); SPA_TYPE_OBJECT_ParamList, id,
SPA_PARAM_LIST_id, &SPA_POD_Id(list[*index]),
0);
else else
return 0; return 0;
break; break;
@ -410,21 +416,24 @@ impl_node_port_enum_params(struct spa_node *node,
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamBuffers, id, SPA_TYPE_OBJECT_ParamBuffers, id,
":", SPA_PARAM_BUFFERS_buffers, "iru", 2, SPA_PARAM_BUFFERS_buffers, &SPA_POD_CHOICE_RANGE_Int(2, 1, MAX_BUFFERS),
SPA_POD_PROP_MIN_MAX(1, MAX_BUFFERS), SPA_PARAM_BUFFERS_blocks, &SPA_POD_Int(1),
":", SPA_PARAM_BUFFERS_blocks, "i", 1, SPA_PARAM_BUFFERS_size, &SPA_POD_CHOICE_RANGE_Int(
":", SPA_PARAM_BUFFERS_size, "iru", 1024 * this->bpf, 1024 * this->bpf,
SPA_POD_PROP_MIN_MAX(16 * this->bpf, INT32_MAX / this->bpf), 16 * this->bpf,
":", SPA_PARAM_BUFFERS_stride, "i", 0, INT32_MAX / this->bpf),
":", SPA_PARAM_BUFFERS_align, "i", 16); SPA_PARAM_BUFFERS_stride, &SPA_POD_Int(0),
SPA_PARAM_BUFFERS_align, &SPA_POD_Int(16),
0);
break; break;
case SPA_PARAM_Meta: case SPA_PARAM_Meta:
switch (*index) { switch (*index) {
case 0: case 0:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamMeta, id, SPA_TYPE_OBJECT_ParamMeta, id,
":", SPA_PARAM_META_type, "I", SPA_META_Header, SPA_PARAM_META_type, &SPA_POD_Id(SPA_META_Header),
":", SPA_PARAM_META_size, "i", sizeof(struct spa_meta_header)); SPA_PARAM_META_size, &SPA_POD_Int(sizeof(struct spa_meta_header)),
0);
break; break;
default: default:
return 0; return 0;
@ -435,14 +444,16 @@ impl_node_port_enum_params(struct spa_node *node,
case 0: case 0:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamIO, id, SPA_TYPE_OBJECT_ParamIO, id,
":", SPA_PARAM_IO_id, "I", SPA_IO_Buffers, SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Buffers),
":", SPA_PARAM_IO_size, "i", sizeof(struct spa_io_buffers)); SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_buffers)),
0);
break; break;
case 1: case 1:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamIO, id, SPA_TYPE_OBJECT_ParamIO, id,
":", SPA_PARAM_IO_id, "I", SPA_IO_Range, SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Range),
":", SPA_PARAM_IO_size, "i", sizeof(struct spa_io_range)); SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_range)),
0);
break; break;
default: default:
return 0; return 0;

View file

@ -52,10 +52,10 @@ executable('test-props2', 'test-props2.c',
# include_directories : [spa_inc ], # include_directories : [spa_inc ],
# dependencies : [], # dependencies : [],
# install : false) # install : false)
executable('test-props5', 'test-props5.c', #executable('test-props5', 'test-props5.c',
include_directories : [spa_inc ], # include_directories : [spa_inc ],
dependencies : [], # dependencies : [],
install : false) # install : false)
executable('test-control', 'test-control.c', executable('test-control', 'test-control.c',
include_directories : [spa_inc ], include_directories : [spa_inc ],
dependencies : [dl_lib, pthread_lib, mathlib], dependencies : [dl_lib, pthread_lib, mathlib],

View file

@ -199,13 +199,6 @@ static void update_props(struct data *data)
spa_pod_builder_init(&b, data->ctrl, sizeof(data->ctrl)); spa_pod_builder_init(&b, data->ctrl, sizeof(data->ctrl));
#if 1
pod = spa_pod_builder_sequence(&b, 0,
".", 0, SPA_CONTROL_Properties,
SPA_POD_OBJECT(SPA_TYPE_OBJECT_Props, 0,
":", SPA_PROP_frequency, "d", ((sin(data->freq_accum) + 1.0) * 200.0) + 440.0,
":", SPA_PROP_volume, "d", (sin(data->volume_accum) / 2.0) + 0.5));
#endif
#if 0 #if 0
spa_pod_builder_push_sequence(&b, 0); spa_pod_builder_push_sequence(&b, 0);
spa_pod_builder_control_header(&b, 0, SPA_CONTROL_Properties); spa_pod_builder_control_header(&b, 0, SPA_CONTROL_Properties);
@ -218,14 +211,14 @@ static void update_props(struct data *data)
spa_pod_builder_pop(&b); spa_pod_builder_pop(&b);
spa_pod_builder_pop(&b); spa_pod_builder_pop(&b);
pod = spa_pod_builder_pop(&b); pod = spa_pod_builder_pop(&b);
#endif #else
#if 0
spa_pod_builder_push_sequence(&b, 0); spa_pod_builder_push_sequence(&b, 0);
spa_pod_builder_control_header(&b, 0, SPA_CONTROL_Properties); spa_pod_builder_control_header(&b, 0, SPA_CONTROL_Properties);
spa_pod_builder_object(&b, spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_Props, 0, SPA_TYPE_OBJECT_Props, 0,
":", SPA_PROP_frequency, "d", ((sin(data->freq_accum) + 1.0) * 200.0) + 440.0, SPA_PROP_frequency, &SPA_POD_Float(((sin(data->freq_accum) + 1.0) * 200.0) + 440.0),
":", SPA_PROP_volume, "d", (sin(data->volume_accum) / 2.0) + 0.5); SPA_PROP_volume, &SPA_POD_Float((sin(data->volume_accum) / 2.0) + 0.5),
0);
pod = spa_pod_builder_pop(&b); pod = spa_pod_builder_pop(&b);
#endif #endif
@ -311,8 +304,9 @@ static int make_nodes(struct data *data, const char *device)
spa_pod_builder_init(&b, buffer, sizeof(buffer)); spa_pod_builder_init(&b, buffer, sizeof(buffer));
props = spa_pod_builder_object(&b, props = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_Props, 0, SPA_TYPE_OBJECT_Props, 0,
":", SPA_PROP_device, "s", device ? device : "hw:0", SPA_PROP_device, &SPA_POD_Stringv(device ? device : "hw:0"),
":", SPA_PROP_minLatency, "i", MIN_LATENCY); SPA_PROP_minLatency, &SPA_POD_Int(MIN_LATENCY),
0);
spa_debug_pod(0, NULL, props); spa_debug_pod(0, NULL, props);
@ -329,9 +323,10 @@ static int make_nodes(struct data *data, const char *device)
spa_pod_builder_init(&b, buffer, sizeof(buffer)); spa_pod_builder_init(&b, buffer, sizeof(buffer));
props = spa_pod_builder_object(&b, props = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_Props, 0, SPA_TYPE_OBJECT_Props, 0,
":", SPA_PROP_frequency, "d", 600.0, SPA_PROP_frequency, &SPA_POD_Float(600.0),
":", SPA_PROP_volume, "d", 0.5, SPA_PROP_volume, &SPA_POD_Float(0.5),
":", SPA_PROP_live, "b", false); SPA_PROP_live, &SPA_POD_Bool(false),
0);
if ((res = spa_node_set_param(data->source, SPA_PARAM_Props, 0, props)) < 0) if ((res = spa_node_set_param(data->source, SPA_PARAM_Props, 0, props)) < 0)
printf("got set_props error %d\n", res); printf("got set_props error %d\n", res);

View file

@ -258,8 +258,9 @@ static int make_nodes(struct data *data, const char *device)
spa_pod_builder_init(&b, buffer, sizeof(buffer)); spa_pod_builder_init(&b, buffer, sizeof(buffer));
props = spa_pod_builder_object(&b, props = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_Props, 0, SPA_TYPE_OBJECT_Props, 0,
":", SPA_PROP_device, "s", device ? device : "hw:0", SPA_PROP_device, &SPA_POD_Stringv(device ? device : "hw:0"),
":", SPA_PROP_minLatency, "i", MIN_LATENCY); SPA_PROP_minLatency, &SPA_POD_Int(MIN_LATENCY),
0);
spa_debug_pod(0, NULL, props); spa_debug_pod(0, NULL, props);
@ -282,9 +283,10 @@ static int make_nodes(struct data *data, const char *device)
spa_pod_builder_init(&b, buffer, sizeof(buffer)); spa_pod_builder_init(&b, buffer, sizeof(buffer));
props = spa_pod_builder_object(&b, props = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_Props, 0, SPA_TYPE_OBJECT_Props, 0,
":", SPA_PROP_frequency, "d", 600.0, SPA_PROP_frequency, &SPA_POD_Float(600.0),
":", SPA_PROP_volume, "d", 0.5, SPA_PROP_volume, &SPA_POD_Float(0.5),
":", SPA_PROP_live, "b", false); SPA_PROP_live, &SPA_POD_Bool(false),
0);
if ((res = spa_node_set_param(data->source, SPA_PARAM_Props, 0, props)) < 0) if ((res = spa_node_set_param(data->source, SPA_PARAM_Props, 0, props)) < 0)
printf("got set_props error %d\n", res); printf("got set_props error %d\n", res);

View file

@ -320,8 +320,9 @@ static int make_nodes(struct data *data, const char *device)
spa_pod_builder_init(&b, buffer, sizeof(buffer)); spa_pod_builder_init(&b, buffer, sizeof(buffer));
props = spa_pod_builder_object(&b, props = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_Props, 0, SPA_TYPE_OBJECT_Props, 0,
":", SPA_PROP_device, "s", device ? device : "hw:0", SPA_PROP_device, &SPA_POD_Stringv(device ? device : "hw:0"),
":", SPA_PROP_minLatency, "i", MIN_LATENCY); SPA_PROP_minLatency, &SPA_POD_Int(MIN_LATENCY),
0);
if ((res = spa_node_set_param(data->sink, SPA_PARAM_Props, 0, props)) < 0) if ((res = spa_node_set_param(data->sink, SPA_PARAM_Props, 0, props)) < 0)
error(0, -res, "set_param props"); error(0, -res, "set_param props");
@ -343,9 +344,10 @@ static int make_nodes(struct data *data, const char *device)
spa_pod_builder_init(&b, buffer, sizeof(buffer)); spa_pod_builder_init(&b, buffer, sizeof(buffer));
props = spa_pod_builder_object(&b, props = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_Props, SPA_PARAM_Props, SPA_TYPE_OBJECT_Props, SPA_PARAM_Props,
":", SPA_PROP_frequency, "d", 600.0, SPA_PROP_frequency, &SPA_POD_Float(600.0),
":", SPA_PROP_volume, "d", 1.0, SPA_PROP_volume, &SPA_POD_Float(1.0),
":", SPA_PROP_live, "b", false); SPA_PROP_live, &SPA_POD_Bool(false),
0);
if ((res = spa_node_set_param(data->source1, SPA_PARAM_Props, 0, props)) < 0) if ((res = spa_node_set_param(data->source1, SPA_PARAM_Props, 0, props)) < 0)
printf("got set_props error %d\n", res); printf("got set_props error %d\n", res);
@ -360,9 +362,10 @@ static int make_nodes(struct data *data, const char *device)
spa_pod_builder_init(&b, buffer, sizeof(buffer)); spa_pod_builder_init(&b, buffer, sizeof(buffer));
props = spa_pod_builder_object(&b, props = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_Props, SPA_PARAM_Props, SPA_TYPE_OBJECT_Props, SPA_PARAM_Props,
":", SPA_PROP_frequency, "d", 440.0, SPA_PROP_frequency, &SPA_POD_Float(440.0),
":", SPA_PROP_volume, "d", 1.0, SPA_PROP_volume, &SPA_POD_Float(1.0),
":", SPA_PROP_live, "b", false); SPA_PROP_live, &SPA_POD_Bool(false),
0);
if ((res = spa_node_set_param(data->source2, SPA_PARAM_Props, 0, props)) < 0) if ((res = spa_node_set_param(data->source2, SPA_PARAM_Props, 0, props)) < 0)
printf("got set_props error %d\n", res); printf("got set_props error %d\n", res);
@ -404,8 +407,8 @@ static int make_nodes(struct data *data, const char *device)
SPA_IO_Buffers, SPA_IO_Buffers,
&data->mix_sink_io[0], sizeof(data->mix_sink_io[0])); &data->mix_sink_io[0], sizeof(data->mix_sink_io[0]));
data->ctrl_volume[0] = SPA_POD_DOUBLE_INIT(0.5); data->ctrl_volume[0] = SPA_POD_Double(0.5);
data->ctrl_volume[1] = SPA_POD_DOUBLE_INIT(0.5); data->ctrl_volume[1] = SPA_POD_Double(0.5);
#if 0 #if 0
if ((res = spa_node_port_set_io(data->mix, if ((res = spa_node_port_set_io(data->mix,

View file

@ -360,8 +360,9 @@ static int negotiate_formats(struct data *data)
spa_pod_builder_init(&b, buffer, sizeof(buffer)); spa_pod_builder_init(&b, buffer, sizeof(buffer));
format = spa_pod_builder_object(&b, format = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_Format, 0, SPA_TYPE_OBJECT_Format, 0,
":", SPA_FORMAT_mediaType, "I", SPA_MEDIA_TYPE_binary, SPA_FORMAT_mediaType, &SPA_POD_Id(SPA_MEDIA_TYPE_binary),
":", SPA_FORMAT_mediaSubtype, "I", SPA_MEDIA_SUBTYPE_raw); SPA_FORMAT_mediaSubtype, &SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw),
0);
if ((res = spa_node_port_set_param(data->sink, if ((res = spa_node_port_set_param(data->sink,
SPA_DIRECTION_INPUT, 0, SPA_DIRECTION_INPUT, 0,

View file

@ -22,6 +22,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>
#include <time.h>
#include <spa/support/log-impl.h> #include <spa/support/log-impl.h>
#include <spa/pod/pod.h> #include <spa/pod/pod.h>
@ -147,21 +148,38 @@ key: "<name>"
} }
] ]
( "Format",
("video", "raw" ),
{
"format": ( "seu", "I420", ( "I420","YUY2" ) ),
"size": ( "Rru", (320, 242), ( (1,1), (MAX, MAX)) ),
"framerate": ( "Fru", (25, 1), ( (0,1), (MAX, 1)) )
}
)
{ "Type" : "Format", "Id" : 0,
"mediaType": "video",
"mediaSubtype": "raw",
"videoFormat": [ "enum", "I420", "YUY2" ],
"videoSize": [ "range", [320,242], [1,1], [MAX,MAX] ],
"videoFramerate": [ "range", [25,1], [0,1], [MAX,1] ]
}
spa_build(SPA_MEDIA_TYPE_VIDEO, SPA_MEDIA_SUBTYPE_RAW, spa_build(SPA_MEDIA_TYPE_VIDEO, SPA_MEDIA_SUBTYPE_RAW,
SPA_FORMAT_VIDEO_format, SPA_PROP_TYPE_ID, SPA_FORMAT_VIDEO_format, SPA_PROP_TYPE_ID,
video_format.I420 video_format.I420
SPA_POD_PROP_FLAG_UNSET | SPA_POD_PROP_FLAG_UNSET |
SPA_PROP_RANGE_ENUM, 2, SPA_CHOICE_ENUM, 2,
video_format.I420, video_format.I420,
video_format.YUY2, video_format.YUY2,
SPA_FORMAT_VIDEO_size, SPA_PROP_TYPE_RECTANGLE, SPA_FORMAT_VIDEO_size, SPA_PROP_TYPE_RECTANGLE,
320, 240, 320, 240,
SPA_POD_PROP_FLAG_UNSET | SPA_POD_PROP_FLAG_UNSET |
SPA_PROP_RANGE_MIN_MAX, SPA_CHOICE_RANGE,
1, 1, 1, 1,
INT32_MAX, INT32_MAX, INT32_MAX, INT32_MAX,
SPA_FORMAT_VIDEO_framerate, SPA_PROP_TYPE_FRACTION, 25, 1, SPA_FORMAT_VIDEO_framerate, SPA_PROP_TYPE_FRACTION, 25, 1,
SPA_POD_PROP_FLAG_UNSET | SPA_PROP_RANGE_MIN_MAX, 0, 1, INT32_MAX, 1, 0); SPA_POD_PROP_FLAG_UNSET | SPA_CHOICE_RANGE, 0, 1, INT32_MAX, 1, 0);
#endif #endif
static void do_static_struct(void) static void do_static_struct(void)
@ -170,17 +188,22 @@ static void do_static_struct(void)
struct spa_pod_object fmt; struct spa_pod_object fmt;
struct { struct {
struct spa_pod_enum media_type SPA_ALIGNED(8); struct spa_pod_prop prop_media_type SPA_ALIGNED(8);
struct spa_pod_enum media_subtype SPA_ALIGNED(8); uint32_t media_type;
struct spa_pod_prop prop_media_subtype SPA_ALIGNED(8);
uint32_t media_subtype;
struct spa_pod_prop prop_format SPA_ALIGNED(8); struct spa_pod_prop prop_format SPA_ALIGNED(8);
struct { struct {
struct spa_pod_choice_body choice;
uint32_t def_format; uint32_t def_format;
uint32_t enum_format[2]; uint32_t enum_format[2];
} format_vals; } format_vals;
struct spa_pod_prop prop_size SPA_ALIGNED(8); struct spa_pod_prop prop_size SPA_ALIGNED(8);
struct { struct {
struct spa_pod_choice_body choice;
struct spa_rectangle def_size; struct spa_rectangle def_size;
struct spa_rectangle min_size; struct spa_rectangle min_size;
struct spa_rectangle max_size; struct spa_rectangle max_size;
@ -188,43 +211,46 @@ static void do_static_struct(void)
struct spa_pod_prop prop_framerate SPA_ALIGNED(8); struct spa_pod_prop prop_framerate SPA_ALIGNED(8);
struct { struct {
struct spa_pod_choice_body array;
struct spa_fraction def_framerate; struct spa_fraction def_framerate;
struct spa_fraction min_framerate; struct spa_fraction min_framerate;
struct spa_fraction max_framerate; struct spa_fraction max_framerate;
} framerate_vals; } framerate_vals;
} props; } props;
} test_format = { } test_format = {
SPA_POD_OBJECT_INIT(sizeof(test_format.props) + sizeof(struct spa_pod_object_body), SPA_POD_Object(sizeof(test_format.props) + sizeof(struct spa_pod_object_body),
SPA_TYPE_OBJECT_Format, 0), SPA_TYPE_OBJECT_Format, 0),
{ {
SPA_POD_ENUM_INIT(SPA_MEDIA_TYPE_video), SPA_POD_Prop(SPA_FORMAT_mediaType, 0,
SPA_POD_ENUM_INIT(SPA_MEDIA_SUBTYPE_raw), sizeof(test_format.props.media_type), SPA_TYPE_Id),
SPA_MEDIA_TYPE_video,
SPA_POD_PROP_INIT(sizeof(test_format.props.format_vals) + SPA_POD_Prop(SPA_FORMAT_mediaSubtype, 0,
sizeof(struct spa_pod_prop_body), sizeof(test_format.props.media_subtype), SPA_TYPE_Id),
SPA_FORMAT_VIDEO_format, SPA_MEDIA_SUBTYPE_raw,
SPA_POD_PROP_RANGE_ENUM | SPA_POD_PROP_FLAG_UNSET,
sizeof(uint32_t), SPA_TYPE_Enum), SPA_POD_Prop(SPA_FORMAT_VIDEO_format, 0,
sizeof(test_format.props.format_vals), SPA_TYPE_Choice),
{ {
SPA_POD_CHOICE_BODY_INIT(SPA_CHOICE_Enum, 0,
sizeof(uint32_t), SPA_TYPE_Id),
SPA_VIDEO_FORMAT_I420, SPA_VIDEO_FORMAT_I420,
{ SPA_VIDEO_FORMAT_I420, SPA_VIDEO_FORMAT_YUY2 } { SPA_VIDEO_FORMAT_I420, SPA_VIDEO_FORMAT_YUY2 }
}, },
SPA_POD_PROP_INIT(sizeof(test_format.props.size_vals) + SPA_POD_Prop(SPA_FORMAT_VIDEO_size, 0,
sizeof(struct spa_pod_prop_body), sizeof(test_format.props.size_vals), SPA_TYPE_Choice),
SPA_FORMAT_VIDEO_size,
SPA_POD_PROP_RANGE_MIN_MAX | SPA_POD_PROP_FLAG_UNSET,
sizeof(struct spa_rectangle), SPA_TYPE_Rectangle),
{ {
SPA_POD_CHOICE_BODY_INIT(SPA_CHOICE_Range, 0,
sizeof(struct spa_rectangle), SPA_TYPE_Rectangle),
SPA_RECTANGLE(320,243), SPA_RECTANGLE(320,243),
SPA_RECTANGLE(1,1), SPA_RECTANGLE(INT32_MAX, INT32_MAX) SPA_RECTANGLE(1,1), SPA_RECTANGLE(INT32_MAX, INT32_MAX)
}, },
SPA_POD_PROP_INIT(sizeof(test_format.props.framerate_vals) + SPA_POD_Prop(SPA_FORMAT_VIDEO_framerate, 0,
sizeof(struct spa_pod_prop_body), sizeof(test_format.props.framerate_vals), SPA_TYPE_Choice),
SPA_FORMAT_VIDEO_framerate,
SPA_POD_PROP_RANGE_MIN_MAX | SPA_POD_PROP_FLAG_UNSET,
sizeof(struct spa_fraction), SPA_TYPE_Fraction),
{ {
SPA_POD_CHOICE_BODY_INIT(SPA_CHOICE_Range, 0,
sizeof(struct spa_fraction), SPA_TYPE_Fraction),
SPA_FRACTION(25,1), SPA_FRACTION(25,1),
SPA_FRACTION(0,1), SPA_FRACTION(INT32_MAX,1) SPA_FRACTION(0,1), SPA_FRACTION(INT32_MAX,1)
} }
@ -256,106 +282,170 @@ static void do_static_struct(void)
} }
#define ITER 10000000
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
struct spa_pod_builder b = { NULL, }; struct spa_pod_builder b = { NULL, };
uint8_t buffer[1024]; uint8_t buffer[1024];
struct spa_pod_object *fmt; struct spa_pod_object *fmt;
int i;
struct timespec ts1, ts2;
fprintf(stderr, "build 1: ");
clock_gettime(CLOCK_MONOTONIC, &ts1);
for (i = 0 ; i < ITER; i++) {
spa_pod_builder_init(&b, buffer, sizeof(buffer)); spa_pod_builder_init(&b, buffer, sizeof(buffer));
spa_pod_builder_push_object(&b, SPA_TYPE_OBJECT_Format, 0); spa_pod_builder_push_object(&b, SPA_TYPE_OBJECT_Format, 0);
spa_pod_builder_enum(&b, SPA_MEDIA_TYPE_video); spa_pod_builder_prop(&b, SPA_FORMAT_mediaType, 0);
spa_pod_builder_enum(&b, SPA_MEDIA_SUBTYPE_raw); spa_pod_builder_id(&b, SPA_MEDIA_TYPE_video);
spa_pod_builder_prop(&b, SPA_FORMAT_mediaSubtype, 0);
spa_pod_builder_id(&b, SPA_MEDIA_SUBTYPE_raw);
spa_pod_builder_push_prop(&b, SPA_FORMAT_VIDEO_format, spa_pod_builder_prop(&b, SPA_FORMAT_VIDEO_format, 0);
SPA_POD_PROP_RANGE_ENUM | SPA_POD_PROP_FLAG_UNSET); spa_pod_builder_push_choice(&b, SPA_CHOICE_Enum, 0);
spa_pod_builder_enum(&b, SPA_VIDEO_FORMAT_I420); spa_pod_builder_id(&b, SPA_VIDEO_FORMAT_I420);
spa_pod_builder_enum(&b, SPA_VIDEO_FORMAT_I420); spa_pod_builder_id(&b, SPA_VIDEO_FORMAT_I420);
spa_pod_builder_enum(&b, SPA_VIDEO_FORMAT_YUY2); spa_pod_builder_id(&b, SPA_VIDEO_FORMAT_YUY2);
spa_pod_builder_pop(&b); spa_pod_builder_pop(&b);
struct spa_rectangle size_min_max[] = { {1, 1}, {INT32_MAX, INT32_MAX} }; struct spa_rectangle size_min_max[] = { {1, 1}, {INT32_MAX, INT32_MAX} };
spa_pod_builder_push_prop(&b, spa_pod_builder_prop(&b, SPA_FORMAT_VIDEO_size, 0);
SPA_FORMAT_VIDEO_size, spa_pod_builder_push_choice(&b, SPA_CHOICE_Range, 0);
SPA_POD_PROP_RANGE_MIN_MAX | SPA_POD_PROP_FLAG_UNSET);
spa_pod_builder_rectangle(&b, 320, 240); spa_pod_builder_rectangle(&b, 320, 240);
spa_pod_builder_raw(&b, size_min_max, sizeof(size_min_max)); spa_pod_builder_raw(&b, size_min_max, sizeof(size_min_max));
spa_pod_builder_pop(&b); spa_pod_builder_pop(&b);
struct spa_fraction rate_min_max[] = { {0, 1}, {INT32_MAX, 1} }; struct spa_fraction rate_min_max[] = { {0, 1}, {INT32_MAX, 1} };
spa_pod_builder_push_prop(&b, spa_pod_builder_prop(&b, SPA_FORMAT_VIDEO_framerate, 0);
SPA_FORMAT_VIDEO_framerate, spa_pod_builder_push_choice(&b, SPA_CHOICE_Range, 0);
SPA_POD_PROP_RANGE_MIN_MAX | SPA_POD_PROP_FLAG_UNSET);
spa_pod_builder_fraction(&b, 25, 1); spa_pod_builder_fraction(&b, 25, 1);
spa_pod_builder_raw(&b, rate_min_max, sizeof(rate_min_max)); spa_pod_builder_raw(&b, rate_min_max, sizeof(rate_min_max));
spa_pod_builder_pop(&b); spa_pod_builder_pop(&b);
fmt = spa_pod_builder_pop(&b); fmt = spa_pod_builder_pop(&b);
}
clock_gettime(CLOCK_MONOTONIC, &ts2);
fprintf(stderr, "elapsed %lld\n", SPA_TIMESPEC_TO_TIME(&ts2) - SPA_TIMESPEC_TO_TIME(&ts1));
spa_debug_pod(0, NULL, &fmt->pod); spa_debug_pod(0, NULL, &fmt->pod);
fprintf(stderr, "build 2: ");
clock_gettime(CLOCK_MONOTONIC, &ts1);
for (i = 0 ; i < ITER; i++) {
spa_pod_builder_init(&b, buffer, sizeof(buffer)); spa_pod_builder_init(&b, buffer, sizeof(buffer));
fmt = spa_pod_builder_object(&b, fmt = spa_pod_builder_add_object(&b,
SPA_TYPE_OBJECT_Format, 0, SPA_TYPE_OBJECT_Format, 0,
":", SPA_FORMAT_mediaType, "I", SPA_MEDIA_TYPE_video, ":", SPA_FORMAT_mediaType, "I", SPA_MEDIA_TYPE_video,
":", SPA_FORMAT_mediaSubtype, "I", SPA_MEDIA_SUBTYPE_raw, ":", SPA_FORMAT_mediaSubtype, "I", SPA_MEDIA_SUBTYPE_raw,
":", SPA_FORMAT_VIDEO_format, "Ieu", SPA_VIDEO_FORMAT_I420, ":", SPA_FORMAT_VIDEO_format, "?eI", 3, SPA_VIDEO_FORMAT_I420,
2, SPA_VIDEO_FORMAT_I420, SPA_VIDEO_FORMAT_I420,
SPA_VIDEO_FORMAT_YUY2, SPA_VIDEO_FORMAT_YUY2,
":", SPA_FORMAT_VIDEO_size, "Rru", &SPA_RECTANGLE(320,241), ":", SPA_FORMAT_VIDEO_size, "?rR", 3, &SPA_RECTANGLE(320,241),
2, &SPA_RECTANGLE(1,1), &SPA_RECTANGLE(1,1),
&SPA_RECTANGLE(INT32_MAX,INT32_MAX), &SPA_RECTANGLE(INT32_MAX,INT32_MAX),
":", SPA_FORMAT_VIDEO_framerate, "Fru", &SPA_FRACTION(25,1), ":", SPA_FORMAT_VIDEO_framerate, "?rF", 3, &SPA_FRACTION(25,1),
2, &SPA_FRACTION(0,1), &SPA_FRACTION(0,1),
&SPA_FRACTION(INT32_MAX,1)); &SPA_FRACTION(INT32_MAX,1));
}
clock_gettime(CLOCK_MONOTONIC, &ts2);
fprintf(stderr, "elapsed %lld\n", SPA_TIMESPEC_TO_TIME(&ts2) - SPA_TIMESPEC_TO_TIME(&ts1));
spa_debug_pod(0, NULL, &fmt->pod); spa_debug_pod(0, NULL, &fmt->pod);
spa_debug_format(0, NULL, &fmt->pod); spa_debug_format(0, NULL, &fmt->pod);
fprintf(stderr, "build 3: ");
clock_gettime(CLOCK_MONOTONIC, &ts1);
for (i = 0 ; i < ITER; i++) {
spa_pod_builder_init(&b, buffer, sizeof(buffer)); spa_pod_builder_init(&b, buffer, sizeof(buffer));
/*
* ( "Format",
* ("video", "raw" ),
* {
* "format": ( "seu", "I420", ( "I420","YUY2" ) ),
* "size": ( "Rru", (320, 242), ( (1,1), (MAX, MAX)) ),
* "framerate": ( "Fru", (25, 1), ( (0,1), (MAX, 1)) )
* }
* )
*
* { "Type" : "Format", "Id" : 0,
* "mediaType": "video",
* "mediaSubtype": "raw",
* "videoFormat": [ "enum", "I420", "YUY2" ],
* "videoSize": [ "range", [320,242], [1,1], [MAX,MAX] ],
* "videoFramerate": [ "range", [25,1], [0,1], [MAX,1] ]
* }
*
*/
fmt = spa_pod_builder_add(&b, fmt = spa_pod_builder_add(&b,
"{", SPA_TYPE_OBJECT_Format, 0, "{", SPA_TYPE_OBJECT_Format, 0,
":", SPA_FORMAT_mediaType, "I", SPA_MEDIA_TYPE_video, ":", SPA_FORMAT_mediaType, "I", SPA_MEDIA_TYPE_video,
":", SPA_FORMAT_mediaSubtype, "I", SPA_MEDIA_SUBTYPE_raw, ":", SPA_FORMAT_mediaSubtype, "I", SPA_MEDIA_SUBTYPE_raw,
":", SPA_FORMAT_VIDEO_format, "Ieu", SPA_VIDEO_FORMAT_I420, ":", SPA_FORMAT_VIDEO_format, "P", &SPA_POD_CHOICE_ENUM_Id(3,
2, SPA_VIDEO_FORMAT_I420, SPA_VIDEO_FORMAT_I420,
SPA_VIDEO_FORMAT_YUY2, SPA_VIDEO_FORMAT_I420,
":", SPA_FORMAT_VIDEO_size, "Rru", &SPA_RECTANGLE(320,242), SPA_VIDEO_FORMAT_YUY2),
2, &SPA_RECTANGLE(1,1), ":", SPA_FORMAT_VIDEO_size, "P", &SPA_POD_CHOICE_RANGE_Rectangle(
&SPA_RECTANGLE(INT32_MAX,INT32_MAX), SPA_RECTANGLE(320,242),
":", SPA_FORMAT_VIDEO_framerate, "Fru", &SPA_FRACTION(25,1), SPA_RECTANGLE(1,1),
2, &SPA_FRACTION(0,1), SPA_RECTANGLE(INT32_MAX,INT32_MAX)),
&SPA_FRACTION(INT32_MAX,1), ":", SPA_FORMAT_VIDEO_framerate, "P", &SPA_POD_CHOICE_RANGE_Fraction(
SPA_FRACTION(25,1),
SPA_FRACTION(0,1),
SPA_FRACTION(INT32_MAX,1)),
"}", NULL); "}", NULL);
}
clock_gettime(CLOCK_MONOTONIC, &ts2);
fprintf(stderr, "elapsed %lld\n", SPA_TIMESPEC_TO_TIME(&ts2) - SPA_TIMESPEC_TO_TIME(&ts1));
spa_debug_pod(0, NULL, &fmt->pod); spa_debug_pod(0, NULL, &fmt->pod);
spa_debug_format(0, NULL, &fmt->pod); spa_debug_format(0, NULL, &fmt->pod);
do_static_struct(); do_static_struct();
fprintf(stderr, "build 4: ");
clock_gettime(CLOCK_MONOTONIC, &ts1);
for (i = 0 ; i < ITER; i++) {
spa_pod_builder_init(&b, buffer, sizeof(buffer));
spa_pod_builder_push_object(&b, SPA_TYPE_OBJECT_Format, 0);
spa_pod_builder_prop(&b, SPA_FORMAT_mediaType, 0);
spa_pod_builder_id(&b, SPA_MEDIA_TYPE_video);
spa_pod_builder_prop(&b, SPA_FORMAT_mediaSubtype, 0);
spa_pod_builder_id(&b, SPA_MEDIA_SUBTYPE_raw);
spa_pod_builder_prop(&b, SPA_FORMAT_VIDEO_format, 0);
spa_pod_builder_primitive(&b, (struct spa_pod*)&SPA_POD_CHOICE_ENUM_Id(3,
SPA_VIDEO_FORMAT_I420, SPA_VIDEO_FORMAT_I420, SPA_VIDEO_FORMAT_YUY2));
spa_pod_builder_prop(&b, SPA_FORMAT_VIDEO_size, 0);
spa_pod_builder_primitive(&b, (struct spa_pod*)&SPA_POD_CHOICE_RANGE_Rectangle(
SPA_RECTANGLE(320,242),
SPA_RECTANGLE(1,1),
SPA_RECTANGLE(INT32_MAX,INT32_MAX)));
spa_pod_builder_prop(&b, SPA_FORMAT_VIDEO_framerate, 0);
spa_pod_builder_primitive(&b, (struct spa_pod *)&SPA_POD_CHOICE_RANGE_Fraction(
SPA_FRACTION(25,1),
SPA_FRACTION(0,1),
SPA_FRACTION(INT32_MAX,1)));
}
clock_gettime(CLOCK_MONOTONIC, &ts2);
fprintf(stderr, "elapsed %lld\n", SPA_TIMESPEC_TO_TIME(&ts2) - SPA_TIMESPEC_TO_TIME(&ts1));
fmt = spa_pod_builder_pop(&b);
spa_debug_pod(0, NULL, &fmt->pod);
spa_debug_format(0, NULL, &fmt->pod);
fprintf(stderr, "build 5: ");
clock_gettime(CLOCK_MONOTONIC, &ts1);
for (i = 0 ; i < ITER; i++) {
spa_pod_builder_init(&b, buffer, sizeof(buffer));
fmt = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_Format, 0,
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_CHOICE_ENUM_Id(3,
SPA_VIDEO_FORMAT_I420,
SPA_VIDEO_FORMAT_I420,
SPA_VIDEO_FORMAT_YUY2),
SPA_FORMAT_VIDEO_size, &SPA_POD_CHOICE_RANGE_Rectangle(
SPA_RECTANGLE(320,242),
SPA_RECTANGLE(1,1),
SPA_RECTANGLE(INT32_MAX,INT32_MAX)),
SPA_FORMAT_VIDEO_framerate,&SPA_POD_CHOICE_RANGE_Fraction(
SPA_FRACTION(25,1),
SPA_FRACTION(0,1),
SPA_FRACTION(INT32_MAX,1)),
0);
}
clock_gettime(CLOCK_MONOTONIC, &ts2);
fprintf(stderr, "elapsed %lld\n", SPA_TIMESPEC_TO_TIME(&ts2) - SPA_TIMESPEC_TO_TIME(&ts1));
spa_debug_pod(0, NULL, &fmt->pod);
spa_debug_format(0, NULL, &fmt->pod);
#if 0 #if 0
printf("media type is enum %d\n", spa_type_is_a(SPA_TYPE__mediaType, SPA_TYPE_ENUM_BASE)); printf("media type is enum %d\n", spa_type_is_a(SPA_TYPE__mediaType, SPA_TYPE_ENUM_BASE));
printf("media sybtype is enum %d\n", printf("media sybtype is enum %d\n",

View file

@ -46,24 +46,24 @@ int main(int argc, char *argv[])
spa_pod_builder_push_object(&b, 0, 0); spa_pod_builder_push_object(&b, 0, 0);
uint32_t formats[] = { 1, 2 }; uint32_t formats[] = { 1, 2 };
spa_pod_builder_push_prop(&b, 1, SPA_POD_PROP_RANGE_ENUM); spa_pod_builder_prop(&b, 1, 0);
spa_pod_builder_push_array(&b);
spa_pod_builder_int(&b, 1); spa_pod_builder_int(&b, 1);
spa_pod_builder_int(&b, formats[0]); spa_pod_builder_int(&b, formats[0]);
spa_pod_builder_int(&b, formats[1]); spa_pod_builder_int(&b, formats[1]);
spa_pod_builder_pop(&b); spa_pod_builder_pop(&b);
spa_pod_builder_push_prop(&b, 2, 0); spa_pod_builder_prop(&b, 2, 0);
spa_pod_builder_int(&b, 42); spa_pod_builder_int(&b, 42);
spa_pod_builder_pop(&b);
struct spa_rectangle sizes[] = { {0, 0}, {1024, 1024} }; struct spa_rectangle sizes[] = { {0, 0}, {1024, 1024} };
spa_pod_builder_push_prop(&b, spa_pod_builder_prop(&b, 3, 0);
3, SPA_POD_PROP_RANGE_MIN_MAX | SPA_POD_PROP_FLAG_UNSET); spa_pod_builder_push_array(&b);
spa_pod_builder_rectangle(&b, 320, 240); spa_pod_builder_rectangle(&b, 320, 240);
spa_pod_builder_raw(&b, sizes, sizeof(sizes)); spa_pod_builder_raw(&b, sizes, sizeof(sizes));
spa_pod_builder_pop(&b); spa_pod_builder_pop(&b);
spa_pod_builder_push_prop(&b, 4, SPA_POD_PROP_FLAG_READONLY); spa_pod_builder_prop(&b, 4, SPA_POD_PROP_FLAG_READONLY);
ref = spa_pod_builder_push_struct(&b); ref = spa_pod_builder_push_struct(&b);
spa_pod_builder_int(&b, 4); spa_pod_builder_int(&b, 4);
spa_pod_builder_long(&b, 6000); spa_pod_builder_long(&b, 6000);
@ -78,14 +78,12 @@ int main(int argc, char *argv[])
spa_pod_builder_int(&b, 6); spa_pod_builder_int(&b, 6);
spa_pod_builder_pop(&b); spa_pod_builder_pop(&b);
spa_pod_builder_pop(&b); spa_pod_builder_pop(&b);
spa_pod_builder_pop(&b);
obj = spa_pod_builder_pop(&b); obj = spa_pod_builder_pop(&b);
spa_debug_pod(0, NULL, obj); spa_debug_pod(0, NULL, obj);
struct spa_pod_prop *p = spa_pod_find_prop(obj, 4); struct spa_pod_prop *p = spa_pod_find_prop(obj, 4);
printf("%d %d\n", p->body.key, p->body.flags); spa_debug_pod(0, NULL, &p->value);
spa_debug_pod(0, NULL, &p->body.value);
obj = spa_pod_builder_deref(&b, ref); obj = spa_pod_builder_deref(&b, ref);

View file

@ -237,8 +237,9 @@ static int make_nodes(struct data *data, const char *device)
spa_pod_builder_init(&b, buffer, sizeof(buffer)); spa_pod_builder_init(&b, buffer, sizeof(buffer));
props = spa_pod_builder_object(&b, props = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_Props, 0, SPA_TYPE_OBJECT_Props, 0,
":", SPA_PROP_device, "s", device ? device : "hw:0", SPA_PROP_device, &SPA_POD_Stringv(device ? device : "hw:0"),
":", SPA_PROP_minLatency, "i", 64); SPA_PROP_minLatency, &SPA_POD_Int(64),
0);
if ((res = spa_node_set_param(data->sink, SPA_PARAM_Props, 0, props)) < 0) if ((res = spa_node_set_param(data->sink, SPA_PARAM_Props, 0, props)) < 0)
printf("got set_props error %d\n", res); printf("got set_props error %d\n", res);
@ -253,7 +254,8 @@ static int make_nodes(struct data *data, const char *device)
spa_pod_builder_init(&b, buffer, sizeof(buffer)); spa_pod_builder_init(&b, buffer, sizeof(buffer));
props = spa_pod_builder_object(&b, props = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_Props, 0, SPA_TYPE_OBJECT_Props, 0,
":", SPA_PROP_live, "b", false); SPA_PROP_live, &SPA_POD_Bool(false),
0);
if ((res = spa_node_set_param(data->source, SPA_PARAM_Props, 0, props)) < 0) if ((res = spa_node_set_param(data->source, SPA_PARAM_Props, 0, props)) < 0)
printf("got set_props error %d\n", res); printf("got set_props error %d\n", res);

View file

@ -289,7 +289,8 @@ static int make_nodes(struct data *data, const char *device)
spa_pod_builder_init(&b, buffer, sizeof(buffer)); spa_pod_builder_init(&b, buffer, sizeof(buffer));
props = spa_pod_builder_object(&b, props = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_Props, 0, SPA_TYPE_OBJECT_Props, 0,
":", SPA_PROP_device, "s", device ? device : "/dev/video0"); SPA_PROP_device, &SPA_POD_Stringv(device ? device : "/dev/video0"),
0);
if ((res = spa_node_set_param(data->source, SPA_PARAM_Props, 0, props)) < 0) if ((res = spa_node_set_param(data->source, SPA_PARAM_Props, 0, props)) < 0)
printf("got set_props error %d\n", res); printf("got set_props error %d\n", res);

View file

@ -112,10 +112,13 @@ static void update_param(struct data *data)
return; return;
spa_pod_builder_init(&b, data->io_notify, data->io_notify_size); spa_pod_builder_init(&b, data->io_notify, data->io_notify_size);
spa_pod_builder_sequence(&b, 0, spa_pod_builder_push_sequence(&b, 0);
".", 0, SPA_CONTROL_Properties, spa_pod_builder_control_header(&b, 0, SPA_CONTROL_Properties);
SPA_POD_OBJECT(SPA_TYPE_OBJECT_Props, 0, spa_pod_builder_push_object(&b, SPA_TYPE_OBJECT_Props, 0);
":", SPA_PROP_contrast, "f", (sin(data->param_accum) * 127.0) + 127.0)); spa_pod_builder_prop(&b, SPA_PROP_contrast, 0);
spa_pod_builder_float(&b, (sin(data->param_accum) * 127.0) + 127.0);
spa_pod_builder_pop(&b);
spa_pod_builder_pop(&b);
data->param_accum += M_PI_M2 / 30.0; data->param_accum += M_PI_M2 / 30.0;
if (data->param_accum >= M_PI_M2) if (data->param_accum >= M_PI_M2)
@ -235,7 +238,8 @@ static int impl_port_enum_params(struct spa_node *node,
if (*index < SPA_N_ELEMENTS(list)) if (*index < SPA_N_ELEMENTS(list))
param = spa_pod_builder_object(builder, param = spa_pod_builder_object(builder,
SPA_TYPE_OBJECT_ParamList, id, SPA_TYPE_OBJECT_ParamList, id,
":", SPA_PARAM_LIST_id, "I", list[*index]); SPA_PARAM_LIST_id, &SPA_POD_Id(list[*index]),
0);
else else
return 0; return 0;
break; break;
@ -255,12 +259,12 @@ static int impl_port_enum_params(struct spa_node *node,
param = spa_pod_builder_object(builder, param = spa_pod_builder_object(builder,
SPA_TYPE_OBJECT_ParamBuffers, id, SPA_TYPE_OBJECT_ParamBuffers, id,
":", SPA_PARAM_BUFFERS_buffers, "iru", 2, SPA_PARAM_BUFFERS_buffers, &SPA_POD_CHOICE_RANGE_Int(2, 2, MAX_BUFFERS),
SPA_POD_PROP_MIN_MAX(2, MAX_BUFFERS), SPA_PARAM_BUFFERS_blocks, &SPA_POD_Int(1),
":", SPA_PARAM_BUFFERS_blocks, "i", 1, SPA_PARAM_BUFFERS_size, &SPA_POD_Int(d->stride * d->format.size.height),
":", SPA_PARAM_BUFFERS_size, "i", d->stride * d->format.size.height, SPA_PARAM_BUFFERS_stride, &SPA_POD_Int(d->stride),
":", SPA_PARAM_BUFFERS_stride, "i", d->stride, SPA_PARAM_BUFFERS_align, &SPA_POD_Int(16),
":", SPA_PARAM_BUFFERS_align, "i", 16); 0);
break; break;
case SPA_PARAM_Meta: case SPA_PARAM_Meta:
@ -268,14 +272,16 @@ static int impl_port_enum_params(struct spa_node *node,
case 0: case 0:
param = spa_pod_builder_object(builder, param = spa_pod_builder_object(builder,
SPA_TYPE_OBJECT_ParamMeta, id, SPA_TYPE_OBJECT_ParamMeta, id,
":", SPA_PARAM_META_type, "I", SPA_META_Header, SPA_PARAM_META_type, &SPA_POD_Id(SPA_META_Header),
":", SPA_PARAM_META_size, "i", sizeof(struct spa_meta_header)); SPA_PARAM_META_size, &SPA_POD_Int(sizeof(struct spa_meta_header)),
0);
break; break;
case 1: case 1:
param = spa_pod_builder_object(builder, param = spa_pod_builder_object(builder,
SPA_TYPE_OBJECT_ParamMeta, id, SPA_TYPE_OBJECT_ParamMeta, id,
":", SPA_PARAM_META_type, "I", SPA_META_VideoDamage, SPA_PARAM_META_type, &SPA_POD_Id(SPA_META_VideoDamage),
":", SPA_PARAM_META_size, "i", sizeof(struct spa_meta_region)); SPA_PARAM_META_size, &SPA_POD_Int(sizeof(struct spa_meta_region)),
0);
break; break;
default: default:
return 0; return 0;
@ -287,14 +293,16 @@ static int impl_port_enum_params(struct spa_node *node,
case 0: case 0:
param = spa_pod_builder_object(builder, param = spa_pod_builder_object(builder,
SPA_TYPE_OBJECT_ParamIO, id, SPA_TYPE_OBJECT_ParamIO, id,
":", SPA_PARAM_IO_id, "I", SPA_IO_Buffers, SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Buffers),
":", SPA_PARAM_IO_size, "i", sizeof(struct spa_io_buffers)); SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_buffers)),
0);
break; break;
case 1: case 1:
param = spa_pod_builder_object(builder, param = spa_pod_builder_object(builder,
SPA_TYPE_OBJECT_ParamIO, id, SPA_TYPE_OBJECT_ParamIO, id,
":", SPA_PARAM_IO_id, "I", SPA_IO_Notify, SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Notify),
":", SPA_PARAM_IO_size, "i", sizeof(struct spa_io_sequence) + 1024); SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_sequence) + 1024),
0);
break; break;
default: default:
return 0; return 0;

View file

@ -33,17 +33,6 @@
#define BUFFER_SAMPLES 128 #define BUFFER_SAMPLES 128
#define DEFAULT_VOLUME 1.0
struct props {
double volume;
};
static void reset_props(struct props *props)
{
props->volume = DEFAULT_VOLUME;
}
struct buffer { struct buffer {
struct spa_buffer *buffer; struct spa_buffer *buffer;
struct spa_list link; struct spa_list link;
@ -52,8 +41,6 @@ struct buffer {
}; };
struct data { struct data {
struct props props;
const char *path; const char *path;
struct pw_main_loop *loop; struct pw_main_loop *loop;
@ -72,8 +59,8 @@ struct data {
const struct spa_node_callbacks *callbacks; const struct spa_node_callbacks *callbacks;
void *callbacks_data; void *callbacks_data;
struct spa_io_buffers *io; struct spa_io_buffers *io;
struct spa_io_control *io_notify;
struct spa_pod_double *ctrl_volume; uint32_t io_notify_size;
struct spa_audio_info_raw format; struct spa_audio_info_raw format;
@ -87,10 +74,20 @@ struct data {
static void update_volume(struct data *data) static void update_volume(struct data *data)
{ {
if (data->ctrl_volume == NULL) struct spa_pod_builder b = { 0, };
if (data->io_notify == NULL)
return; return;
data->ctrl_volume->value = (sin(data->volume_accum) / 2.0) + 0.5; spa_pod_builder_init(&b, data->io_notify, data->io_notify_size);
spa_pod_builder_push_sequence(&b, 0);
spa_pod_builder_control_header(&b, 0, SPA_CONTROL_Properties);
spa_pod_builder_push_object(&b, SPA_TYPE_OBJECT_Props, 0);
spa_pod_builder_prop(&b, SPA_PROP_volume, 0);
spa_pod_builder_float(&b, (sin(data->volume_accum) / 2.0) + 0.5);
spa_pod_builder_pop(&b);
spa_pod_builder_pop(&b);
data->volume_accum += M_PI_M2 / 1000.0; data->volume_accum += M_PI_M2 / 1000.0;
if (data->volume_accum >= M_PI_M2) if (data->volume_accum >= M_PI_M2)
data->volume_accum -= M_PI_M2; data->volume_accum -= M_PI_M2;
@ -137,19 +134,17 @@ static int impl_port_set_io(struct spa_node *node, enum spa_direction direction,
{ {
struct data *d = SPA_CONTAINER_OF(node, struct data, impl_node); struct data *d = SPA_CONTAINER_OF(node, struct data, impl_node);
if (id == SPA_IO_Buffers) switch (id) {
case SPA_IO_Buffers:
d->io = data; d->io = data;
#if 0 break;
else if (id == type.io_prop_volume) { case SPA_IO_Notify:
if (data && size >= sizeof(struct spa_pod_double)) d->io_notify = data;
d->ctrl_volume = data; d->io_notify_size = size;
else break;
d->ctrl_volume = NULL; default:
}
#endif
else
return -ENOENT; return -ENOENT;
}
return 0; return 0;
} }
@ -182,18 +177,19 @@ static int port_enum_formats(struct spa_node *node,
*param = spa_pod_builder_object(builder, *param = spa_pod_builder_object(builder,
SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat, SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
":", SPA_FORMAT_mediaType, "I", SPA_MEDIA_TYPE_audio, SPA_FORMAT_mediaType, &SPA_POD_Id(SPA_MEDIA_TYPE_audio),
":", SPA_FORMAT_mediaSubtype, "I", SPA_MEDIA_SUBTYPE_raw, SPA_FORMAT_mediaSubtype, &SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw),
":", SPA_FORMAT_AUDIO_format, "Ieu", SPA_AUDIO_FORMAT_S16, SPA_FORMAT_AUDIO_format, &SPA_POD_CHOICE_ENUM_Id(3,
SPA_POD_PROP_ENUM(2, SPA_AUDIO_FORMAT_S16, SPA_AUDIO_FORMAT_S16,
SPA_AUDIO_FORMAT_F32), SPA_AUDIO_FORMAT_S16,
":", SPA_FORMAT_AUDIO_layout, "Ieu", SPA_AUDIO_LAYOUT_INTERLEAVED, SPA_AUDIO_FORMAT_F32),
SPA_POD_PROP_ENUM(2, SPA_AUDIO_LAYOUT_INTERLEAVED, SPA_FORMAT_AUDIO_layout, &SPA_POD_CHOICE_ENUM_Id(3,
SPA_AUDIO_LAYOUT_NON_INTERLEAVED), SPA_AUDIO_LAYOUT_INTERLEAVED,
":", SPA_FORMAT_AUDIO_channels, "iru", 2, SPA_AUDIO_LAYOUT_INTERLEAVED,
SPA_POD_PROP_MIN_MAX(1, INT32_MAX), SPA_AUDIO_LAYOUT_NON_INTERLEAVED),
":", SPA_FORMAT_AUDIO_rate, "iru", 44100, SPA_FORMAT_AUDIO_channels, &SPA_POD_CHOICE_RANGE_Int(2, 1, INT32_MAX),
SPA_POD_PROP_MIN_MAX(1, INT32_MAX)); SPA_FORMAT_AUDIO_rate, &SPA_POD_CHOICE_RANGE_Int(44100, 1, INT32_MAX),
0);
(*index)++; (*index)++;
@ -222,7 +218,8 @@ static int impl_port_enum_params(struct spa_node *node,
if (*index < SPA_N_ELEMENTS(list)) if (*index < SPA_N_ELEMENTS(list))
param = spa_pod_builder_object(builder, param = spa_pod_builder_object(builder,
SPA_TYPE_OBJECT_ParamList, id, SPA_TYPE_OBJECT_ParamList, id,
":", SPA_PARAM_LIST_id, "I", list[*index]); SPA_PARAM_LIST_id, &SPA_POD_Id(list[*index]),
0);
else else
return 0; return 0;
break; break;
@ -244,13 +241,12 @@ static int impl_port_enum_params(struct spa_node *node,
param = spa_pod_builder_object(builder, param = spa_pod_builder_object(builder,
SPA_TYPE_OBJECT_ParamBuffers, id, SPA_TYPE_OBJECT_ParamBuffers, id,
":", SPA_PARAM_BUFFERS_buffers, "iru", 1, SPA_PARAM_BUFFERS_buffers, &SPA_POD_CHOICE_RANGE_Int(1, 1, 32),
SPA_POD_PROP_MIN_MAX(1, 32), SPA_PARAM_BUFFERS_blocks, &SPA_POD_Int(1),
":", SPA_PARAM_BUFFERS_blocks, "i", 1, SPA_PARAM_BUFFERS_size, &SPA_POD_CHOICE_RANGE_Int(BUFFER_SAMPLES * sizeof(float), 32, 4096),
":", SPA_PARAM_BUFFERS_size, "iru", BUFFER_SAMPLES * sizeof(float), SPA_PARAM_BUFFERS_stride, &SPA_POD_Int(0),
SPA_POD_PROP_MIN_MAX(32, 4096), SPA_PARAM_BUFFERS_align, &SPA_POD_Int(16),
":", SPA_PARAM_BUFFERS_stride, "i", 0, 0);
":", SPA_PARAM_BUFFERS_align, "i", 16);
break; break;
case SPA_PARAM_Meta: case SPA_PARAM_Meta:
@ -258,8 +254,9 @@ static int impl_port_enum_params(struct spa_node *node,
case 0: case 0:
param = spa_pod_builder_object(builder, param = spa_pod_builder_object(builder,
SPA_TYPE_OBJECT_ParamMeta, id, SPA_TYPE_OBJECT_ParamMeta, id,
":", SPA_PARAM_META_type, "I", SPA_META_Header, SPA_PARAM_META_type, &SPA_POD_Id(SPA_META_Header),
":", SPA_PARAM_META_size, "i", sizeof(struct spa_meta_header)); SPA_PARAM_META_size, &SPA_POD_Int(sizeof(struct spa_meta_header)),
0);
break; break;
default: default:
return 0; return 0;
@ -270,32 +267,21 @@ static int impl_port_enum_params(struct spa_node *node,
case 0: case 0:
param = spa_pod_builder_object(builder, param = spa_pod_builder_object(builder,
SPA_TYPE_OBJECT_ParamIO, id, SPA_TYPE_OBJECT_ParamIO, id,
":", SPA_PARAM_IO_id, "I", SPA_IO_Buffers, SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Buffers),
":", SPA_PARAM_IO_size, "i", sizeof(struct spa_io_buffers)); SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_buffers)),
0);
break;
case 1:
param = spa_pod_builder_object(builder,
SPA_TYPE_OBJECT_ParamIO, id,
SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Notify),
SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_sequence) + 1024),
0);
break; break;
default: default:
return 0; return 0;
} }
break; break;
#if 0
else if (id == t->param_io.idPropsOut) {
struct props *p = &d->props;
switch (*index) {
case 0:
param = spa_pod_builder_object(builder,
id, t->param_io.Prop,
":", t->param_io.id, "I", d->type.io_prop_volume,
":", t->param_io.size, "i", sizeof(struct spa_pod_double),
":", t->param.propId, "I", d->type.prop_volume,
":", t->param.propType, "dru", p->volume,
SPA_POD_PROP_MIN_MAX(0.0, 10.0));
break;
default:
return 0;
}
}
#endif
default: default:
return -ENOENT; return -ENOENT;
} }
@ -554,7 +540,6 @@ int main(int argc, char *argv[])
data.path = argc > 1 ? argv[1] : NULL; data.path = argc > 1 ? argv[1] : NULL;
spa_list_init(&data.empty); spa_list_init(&data.empty);
reset_props(&data.props);
pw_remote_add_listener(data.remote, &data.remote_listener, &remote_events, &data); pw_remote_add_listener(data.remote, &data.remote_listener, &remote_events, &data);

View file

@ -20,7 +20,11 @@
#include <stdio.h> #include <stdio.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <SDL2/SDL.h> #define WIDTH 640
#define HEIGHT 480
#define BPP 3
#include "sdl.h"
#include <spa/param/video/format-utils.h> #include <spa/param/video/format-utils.h>
#include <spa/param/props.h> #include <spa/param/props.h>
@ -31,10 +35,6 @@
#include <pipewire/module.h> #include <pipewire/module.h>
#include <pipewire/factory.h> #include <pipewire/factory.h>
#define WIDTH 640
#define HEIGHT 480
#define BPP 3
struct data { struct data {
SDL_Renderer *renderer; SDL_Renderer *renderer;
SDL_Window *window; SDL_Window *window;
@ -76,76 +76,6 @@ static void handle_events(struct data *data)
} }
} }
static struct {
Uint32 format;
uint32_t id;
} video_formats[] = {
{ SDL_PIXELFORMAT_UNKNOWN, SPA_VIDEO_FORMAT_UNKNOWN,},
{ SDL_PIXELFORMAT_INDEX1LSB, SPA_VIDEO_FORMAT_UNKNOWN,},
{ SDL_PIXELFORMAT_UNKNOWN, SPA_VIDEO_FORMAT_UNKNOWN,},
{ SDL_PIXELFORMAT_INDEX1LSB, SPA_VIDEO_FORMAT_UNKNOWN,},
{ SDL_PIXELFORMAT_INDEX1MSB, SPA_VIDEO_FORMAT_UNKNOWN,},
{ SDL_PIXELFORMAT_INDEX4LSB, SPA_VIDEO_FORMAT_UNKNOWN,},
{ SDL_PIXELFORMAT_INDEX4MSB, SPA_VIDEO_FORMAT_UNKNOWN,},
{ SDL_PIXELFORMAT_INDEX8, SPA_VIDEO_FORMAT_UNKNOWN,},
{ SDL_PIXELFORMAT_RGB332, SPA_VIDEO_FORMAT_UNKNOWN,},
{ SDL_PIXELFORMAT_RGB444, SPA_VIDEO_FORMAT_UNKNOWN,},
{ SDL_PIXELFORMAT_RGB555, SPA_VIDEO_FORMAT_UNKNOWN,},
{ SDL_PIXELFORMAT_BGR555, SPA_VIDEO_FORMAT_UNKNOWN,},
{ SDL_PIXELFORMAT_ARGB4444, SPA_VIDEO_FORMAT_UNKNOWN,},
{ SDL_PIXELFORMAT_RGBA4444, SPA_VIDEO_FORMAT_UNKNOWN,},
{ SDL_PIXELFORMAT_ABGR4444, SPA_VIDEO_FORMAT_UNKNOWN,},
{ SDL_PIXELFORMAT_BGRA4444, SPA_VIDEO_FORMAT_UNKNOWN,},
{ SDL_PIXELFORMAT_ARGB1555, SPA_VIDEO_FORMAT_UNKNOWN,},
{ SDL_PIXELFORMAT_RGBA5551, SPA_VIDEO_FORMAT_UNKNOWN,},
{ SDL_PIXELFORMAT_ABGR1555, SPA_VIDEO_FORMAT_UNKNOWN,},
{ SDL_PIXELFORMAT_BGRA5551, SPA_VIDEO_FORMAT_UNKNOWN,},
{ SDL_PIXELFORMAT_RGB565, SPA_VIDEO_FORMAT_UNKNOWN,},
{ SDL_PIXELFORMAT_BGR565, SPA_VIDEO_FORMAT_UNKNOWN,},
{ SDL_PIXELFORMAT_RGB24, SPA_VIDEO_FORMAT_RGB,},
{ SDL_PIXELFORMAT_RGB888, SPA_VIDEO_FORMAT_RGB,},
{ SDL_PIXELFORMAT_RGBX8888, SPA_VIDEO_FORMAT_RGBx,},
{ SDL_PIXELFORMAT_BGR24, SPA_VIDEO_FORMAT_BGR,},
{ SDL_PIXELFORMAT_BGR888, SPA_VIDEO_FORMAT_BGR,},
{ SDL_PIXELFORMAT_BGRX8888, SPA_VIDEO_FORMAT_BGRx,},
{ SDL_PIXELFORMAT_ARGB2101010, SPA_VIDEO_FORMAT_UNKNOWN,},
{ SDL_PIXELFORMAT_RGBA8888, SPA_VIDEO_FORMAT_RGBA,},
{ SDL_PIXELFORMAT_ARGB8888, SPA_VIDEO_FORMAT_ARGB,},
{ SDL_PIXELFORMAT_BGRA8888, SPA_VIDEO_FORMAT_BGRA,},
{ SDL_PIXELFORMAT_ABGR8888, SPA_VIDEO_FORMAT_ABGR,},
{ SDL_PIXELFORMAT_YV12, SPA_VIDEO_FORMAT_YV12,},
{ SDL_PIXELFORMAT_IYUV, SPA_VIDEO_FORMAT_I420,},
{ SDL_PIXELFORMAT_YUY2, SPA_VIDEO_FORMAT_YUY2,},
{ SDL_PIXELFORMAT_UYVY, SPA_VIDEO_FORMAT_UYVY,},
{ SDL_PIXELFORMAT_YVYU, SPA_VIDEO_FORMAT_YVYU,},
#if SDL_VERSION_ATLEAST(2,0,4)
{ SDL_PIXELFORMAT_NV12, SPA_VIDEO_FORMAT_NV12,},
{ SDL_PIXELFORMAT_NV21, SPA_VIDEO_FORMAT_NV21,},
#endif
};
static uint32_t sdl_format_to_id(struct data *data, Uint32 format)
{
size_t i;
for (i = 0; i < SPA_N_ELEMENTS(video_formats); i++) {
if (video_formats[i].format == format)
return video_formats[i].id;
}
return SPA_VIDEO_FORMAT_UNKNOWN;
}
static Uint32 id_to_sdl_format(struct data *data, uint32_t id)
{
size_t i;
for (i = 0; i < SPA_N_ELEMENTS(video_formats); i++) {
if (video_formats[i].id == id)
return video_formats[i].format;
}
return SDL_PIXELFORMAT_UNKNOWN;
}
static int impl_send_command(struct spa_node *node, const struct spa_command *command) static int impl_send_command(struct spa_node *node, const struct spa_command *command)
{ {
return 0; return 0;
@ -218,50 +148,12 @@ static int port_enum_formats(struct spa_node *node,
{ {
struct data *d = SPA_CONTAINER_OF(node, struct data, impl_node); struct data *d = SPA_CONTAINER_OF(node, struct data, impl_node);
SDL_RendererInfo info; SDL_RendererInfo info;
uint32_t i, c;
if (*index != 0) if (*index != 0)
return 0; return 0;
SDL_GetRendererInfo(d->renderer, &info); SDL_GetRendererInfo(d->renderer, &info);
*result = sdl_build_formats(&info, builder);
spa_pod_builder_push_object(builder, SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat);
spa_pod_builder_push_prop(builder, SPA_FORMAT_mediaType, 0);
spa_pod_builder_enum(builder, SPA_MEDIA_TYPE_video);
spa_pod_builder_pop(builder);
spa_pod_builder_push_prop(builder, SPA_FORMAT_mediaSubtype, 0);
spa_pod_builder_enum(builder, SPA_MEDIA_SUBTYPE_raw);
spa_pod_builder_pop(builder);
spa_pod_builder_push_prop(builder, SPA_FORMAT_VIDEO_format,
SPA_POD_PROP_FLAG_UNSET |
SPA_POD_PROP_RANGE_ENUM);
for (i = 0, c = 0; i < info.num_texture_formats; i++) {
uint32_t id = sdl_format_to_id(d, info.texture_formats[i]);
if (id == 0)
continue;
if (c++ == 0)
spa_pod_builder_enum(builder, id);
spa_pod_builder_enum(builder, id);
}
for (i = 0; i < SPA_N_ELEMENTS(video_formats); i++) {
uint32_t id = video_formats[i].id;
if (id != SPA_VIDEO_FORMAT_UNKNOWN)
spa_pod_builder_enum(builder, id);
}
spa_pod_builder_pop(builder);
spa_pod_builder_add(builder,
":", SPA_FORMAT_VIDEO_size, "Rru", &SPA_RECTANGLE(WIDTH, HEIGHT),
SPA_POD_PROP_MIN_MAX(&SPA_RECTANGLE(1,1),
&SPA_RECTANGLE(info.max_texture_width,
info.max_texture_height)),
":", SPA_FORMAT_VIDEO_framerate, "Fru", &SPA_FRACTION(25,1),
SPA_POD_PROP_MIN_MAX(&SPA_FRACTION(0,1),
&SPA_FRACTION(30,1)),
NULL);
*result = spa_pod_builder_pop(builder);
(*index)++; (*index)++;
@ -287,12 +179,12 @@ static int impl_port_enum_params(struct spa_node *node,
*result = spa_pod_builder_object(builder, *result = spa_pod_builder_object(builder,
SPA_TYPE_OBJECT_ParamBuffers, id, SPA_TYPE_OBJECT_ParamBuffers, id,
":", SPA_PARAM_BUFFERS_buffers, "iru", 2, SPA_PARAM_BUFFERS_buffers, &SPA_POD_CHOICE_RANGE_Int(2, 1, 32),
SPA_POD_PROP_MIN_MAX(1, 32), SPA_PARAM_BUFFERS_blocks, &SPA_POD_Int(1),
":", SPA_PARAM_BUFFERS_blocks, "i", 1, SPA_PARAM_BUFFERS_size, &SPA_POD_Int(d->stride * d->format.size.height),
":", SPA_PARAM_BUFFERS_size, "i", d->stride * d->format.size.height, SPA_PARAM_BUFFERS_stride, &SPA_POD_Int(d->stride),
":", SPA_PARAM_BUFFERS_stride, "i", d->stride, SPA_PARAM_BUFFERS_align, &SPA_POD_Int(16),
":", SPA_PARAM_BUFFERS_align, "i", 16); 0);
break; break;
case SPA_PARAM_Meta: case SPA_PARAM_Meta:
@ -301,8 +193,9 @@ static int impl_port_enum_params(struct spa_node *node,
*result = spa_pod_builder_object(builder, *result = spa_pod_builder_object(builder,
SPA_TYPE_OBJECT_ParamMeta, id, SPA_TYPE_OBJECT_ParamMeta, id,
":", SPA_PARAM_META_type, "I", SPA_META_Header, SPA_PARAM_META_type, &SPA_POD_Id(SPA_META_Header),
":", SPA_PARAM_META_size, "i", sizeof(struct spa_meta_header)); SPA_PARAM_META_size, &SPA_POD_Int(sizeof(struct spa_meta_header)),
0);
break; break;
default: default:
@ -327,7 +220,7 @@ static int port_set_format(struct spa_node *node, enum spa_direction direction,
spa_format_video_raw_parse(format, &d->format); spa_format_video_raw_parse(format, &d->format);
sdl_format = id_to_sdl_format(d, d->format.format); sdl_format = id_to_sdl_format(d->format.format);
if (sdl_format == SDL_PIXELFORMAT_UNKNOWN) if (sdl_format == SDL_PIXELFORMAT_UNKNOWN)
return -EINVAL; return -EINVAL;

View file

@ -98,38 +98,37 @@ static struct spa_pod *sdl_build_formats(SDL_RendererInfo *info, struct spa_pod_
int i, c; int i, c;
spa_pod_builder_push_object(b, SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat); spa_pod_builder_push_object(b, SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat);
spa_pod_builder_push_prop(b, SPA_FORMAT_mediaType, 0); spa_pod_builder_prop(b, SPA_FORMAT_mediaType, 0);
spa_pod_builder_enum(b, SPA_MEDIA_TYPE_video); spa_pod_builder_id(b, SPA_MEDIA_TYPE_video);
spa_pod_builder_pop(b); spa_pod_builder_prop(b, SPA_FORMAT_mediaSubtype, 0);
spa_pod_builder_push_prop(b, SPA_FORMAT_mediaSubtype, 0); spa_pod_builder_id(b, SPA_MEDIA_SUBTYPE_raw);
spa_pod_builder_enum(b, SPA_MEDIA_SUBTYPE_raw);
spa_pod_builder_pop(b);
spa_pod_builder_push_prop(b, SPA_FORMAT_VIDEO_format, spa_pod_builder_prop(b, SPA_FORMAT_VIDEO_format, 0);
SPA_POD_PROP_FLAG_UNSET | spa_pod_builder_push_choice(b, SPA_CHOICE_Enum, 0);
SPA_POD_PROP_RANGE_ENUM);
for (i = 0, c = 0; i < info->num_texture_formats; i++) { for (i = 0, c = 0; i < info->num_texture_formats; i++) {
uint32_t id = sdl_format_to_id(info->texture_formats[i]); uint32_t id = sdl_format_to_id(info->texture_formats[i]);
if (id == 0) if (id == 0)
continue; continue;
if (c++ == 0) if (c++ == 0)
spa_pod_builder_enum(b, id); spa_pod_builder_id(b, id);
spa_pod_builder_enum(b, id); spa_pod_builder_id(b, id);
} }
for (i = 0; i < SPA_N_ELEMENTS(sdl_video_formats); i++) { for (i = 0; i < SPA_N_ELEMENTS(sdl_video_formats); i++) {
uint32_t id = sdl_video_formats[i].id; uint32_t id = sdl_video_formats[i].id;
if (id != SPA_VIDEO_FORMAT_UNKNOWN) if (id != SPA_VIDEO_FORMAT_UNKNOWN)
spa_pod_builder_enum(b, id); spa_pod_builder_id(b, id);
} }
spa_pod_builder_pop(b); spa_pod_builder_pop(b);
spa_pod_builder_add(b, spa_pod_builder_props(b,
":", SPA_FORMAT_VIDEO_size, "Rru", &SPA_RECTANGLE(WIDTH, HEIGHT), SPA_FORMAT_VIDEO_size, &SPA_POD_CHOICE_RANGE_Rectangle(
SPA_POD_PROP_MIN_MAX(&SPA_RECTANGLE(1,1), SPA_RECTANGLE(WIDTH, HEIGHT),
&SPA_RECTANGLE(info->max_texture_width, SPA_RECTANGLE(1,1),
info->max_texture_height)), SPA_RECTANGLE(info->max_texture_width,
":", SPA_FORMAT_VIDEO_framerate, "Fru", &SPA_FRACTION(25,1), info->max_texture_height)),
SPA_POD_PROP_MIN_MAX(&SPA_FRACTION(0,1), SPA_FORMAT_VIDEO_framerate, &SPA_POD_CHOICE_RANGE_Fraction(
&SPA_FRACTION(30,1)), SPA_FRACTION(25,1),
NULL); SPA_FRACTION(0,1),
SPA_FRACTION(30,1)),
0);
return spa_pod_builder_pop(b); return spa_pod_builder_pop(b);
} }

View file

@ -170,17 +170,18 @@ on_stream_format_changed(void *_data, const struct spa_pod *format)
params[0] = spa_pod_builder_object(&b, params[0] = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamBuffers, SPA_PARAM_Buffers, SPA_TYPE_OBJECT_ParamBuffers, SPA_PARAM_Buffers,
":", SPA_PARAM_BUFFERS_buffers, "iru", 8, SPA_PARAM_BUFFERS_buffers, &SPA_POD_CHOICE_RANGE_Int(8, 2, 16),
SPA_POD_PROP_MIN_MAX(2, 16), SPA_PARAM_BUFFERS_blocks, &SPA_POD_Int(1),
":", SPA_PARAM_BUFFERS_blocks, "i", 1, SPA_PARAM_BUFFERS_size, &SPA_POD_Int(data->stride * data->format.size.height),
":", SPA_PARAM_BUFFERS_size, "i", data->stride * data->format.size.height, SPA_PARAM_BUFFERS_stride, &SPA_POD_Int(data->stride),
":", SPA_PARAM_BUFFERS_stride, "i", data->stride, SPA_PARAM_BUFFERS_align, &SPA_POD_Int(16),
":", SPA_PARAM_BUFFERS_align, "i", 16); 0);
params[1] = spa_pod_builder_object(&b, params[1] = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta, SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta,
":", SPA_PARAM_META_type, "I", SPA_META_Header, SPA_PARAM_META_type, &SPA_POD_Id(SPA_META_Header),
":", SPA_PARAM_META_size, "i", sizeof(struct spa_meta_header)); SPA_PARAM_META_size, &SPA_POD_Int(sizeof(struct spa_meta_header)),
0);
pw_stream_finish_format(stream, 0, params, 2); pw_stream_finish_format(stream, 0, params, 2);
} }

View file

@ -169,24 +169,27 @@ on_stream_format_changed(void *_data, const struct spa_pod *format)
params[0] = spa_pod_builder_object(&b, params[0] = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamBuffers, SPA_PARAM_Buffers, SPA_TYPE_OBJECT_ParamBuffers, SPA_PARAM_Buffers,
":", SPA_PARAM_BUFFERS_buffers, "iru", 2, SPA_PARAM_BUFFERS_buffers, &SPA_POD_CHOICE_RANGE_Int(2, 1, 32),
SPA_POD_PROP_MIN_MAX(1, 32), SPA_PARAM_BUFFERS_blocks, &SPA_POD_Int(1),
":", SPA_PARAM_BUFFERS_blocks, "i", 1, SPA_PARAM_BUFFERS_size, &SPA_POD_Int(data->stride * data->format.size.height),
":", SPA_PARAM_BUFFERS_size, "i", data->stride * data->format.size.height, SPA_PARAM_BUFFERS_stride, &SPA_POD_Int(data->stride),
":", SPA_PARAM_BUFFERS_stride, "i", data->stride, SPA_PARAM_BUFFERS_align, &SPA_POD_Int(16),
":", SPA_PARAM_BUFFERS_align, "i", 16); 0);
params[1] = spa_pod_builder_object(&b, params[1] = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta, SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta,
":", SPA_PARAM_META_type, "I", SPA_META_Header, SPA_PARAM_META_type, &SPA_POD_Id(SPA_META_Header),
":", SPA_PARAM_META_size, "i", sizeof(struct spa_meta_header)); SPA_PARAM_META_size, &SPA_POD_Int(sizeof(struct spa_meta_header)),
0);
params[2] = spa_pod_builder_object(&b, params[2] = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta, SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta,
":", SPA_PARAM_META_type, "I", SPA_META_VideoDamage, SPA_PARAM_META_type, &SPA_POD_Id(SPA_META_VideoDamage),
":", SPA_PARAM_META_size, "iru", sizeof(struct spa_meta_region) * 16, SPA_PARAM_META_size, &SPA_POD_CHOICE_RANGE_Int(
SPA_POD_PROP_MIN_MAX(sizeof(struct spa_meta_region) * 1, sizeof(struct spa_meta_region) * 16,
sizeof(struct spa_meta_region) * 16)); sizeof(struct spa_meta_region) * 1,
sizeof(struct spa_meta_region) * 16),
0);
pw_stream_finish_format(stream, 0, params, 3); pw_stream_finish_format(stream, 0, params, 3);
} }
@ -224,13 +227,15 @@ static void on_state_changed(void *_data, enum pw_remote_state old, enum pw_remo
params[0] = spa_pod_builder_object(&b, params[0] = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat, SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
":", SPA_FORMAT_mediaType, "I", SPA_MEDIA_TYPE_video, SPA_FORMAT_mediaType, &SPA_POD_Id(SPA_MEDIA_TYPE_video),
":", SPA_FORMAT_mediaSubtype, "I", SPA_MEDIA_SUBTYPE_raw, SPA_FORMAT_mediaSubtype, &SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw),
":", SPA_FORMAT_VIDEO_format, "I", SPA_VIDEO_FORMAT_RGB, SPA_FORMAT_VIDEO_format, &SPA_POD_Id(SPA_VIDEO_FORMAT_RGB),
":", SPA_FORMAT_VIDEO_size, "Rru", &SPA_RECTANGLE(320, 240), SPA_FORMAT_VIDEO_size, &SPA_POD_CHOICE_RANGE_Rectangle(
SPA_POD_PROP_MIN_MAX(&SPA_RECTANGLE(1, 1), SPA_RECTANGLE(320, 240),
&SPA_RECTANGLE(4096, 4096)), SPA_RECTANGLE(1, 1),
":", SPA_FORMAT_VIDEO_framerate, "F", &SPA_FRACTION(25, 1)); SPA_RECTANGLE(4096, 4096)),
SPA_FORMAT_VIDEO_framerate, &SPA_POD_Fraction(SPA_FRACTION(25, 1)),
0);
pw_stream_add_listener(data->stream, pw_stream_add_listener(data->stream,
&data->stream_listener, &data->stream_listener,

View file

@ -317,22 +317,22 @@ get_range_type (const GValue *val)
GType type = G_VALUE_TYPE (val); GType type = G_VALUE_TYPE (val);
if (type == GST_TYPE_LIST) if (type == GST_TYPE_LIST)
return SPA_POD_PROP_RANGE_ENUM; return SPA_CHOICE_Enum;
if (type == GST_TYPE_DOUBLE_RANGE || type == GST_TYPE_FRACTION_RANGE) if (type == GST_TYPE_DOUBLE_RANGE || type == GST_TYPE_FRACTION_RANGE)
return SPA_POD_PROP_RANGE_MIN_MAX; return SPA_CHOICE_Range;
if (type == GST_TYPE_INT_RANGE) { if (type == GST_TYPE_INT_RANGE) {
if (gst_value_get_int_range_step (val) == 1) if (gst_value_get_int_range_step (val) == 1)
return SPA_POD_PROP_RANGE_MIN_MAX; return SPA_CHOICE_Range;
else else
return SPA_POD_PROP_RANGE_STEP; return SPA_CHOICE_Step;
} }
if (type == GST_TYPE_INT64_RANGE) { if (type == GST_TYPE_INT64_RANGE) {
if (gst_value_get_int64_range_step (val) == 1) if (gst_value_get_int64_range_step (val) == 1)
return SPA_POD_PROP_RANGE_MIN_MAX; return SPA_CHOICE_Range;
else else
return SPA_POD_PROP_RANGE_STEP; return SPA_CHOICE_Step;
} }
return SPA_POD_PROP_RANGE_NONE; return SPA_CHOICE_None;
} }
static const uint32_t static const uint32_t
@ -345,11 +345,11 @@ get_range_type2 (const GValue *v1, const GValue *v2)
if (r1 == r2) if (r1 == r2)
return r1; return r1;
if (r1 == SPA_POD_PROP_RANGE_STEP || r2 == SPA_POD_PROP_RANGE_STEP) if (r1 == SPA_CHOICE_Step || r2 == SPA_CHOICE_Step)
return SPA_POD_PROP_RANGE_STEP; return SPA_CHOICE_Step;
if (r1 == SPA_POD_PROP_RANGE_MIN_MAX || r2 == SPA_POD_PROP_RANGE_MIN_MAX) if (r1 == SPA_CHOICE_Range || r2 == SPA_CHOICE_Range)
return SPA_POD_PROP_RANGE_MIN_MAX; return SPA_CHOICE_Range;
return SPA_POD_PROP_RANGE_MIN_MAX; return SPA_CHOICE_Range;
} }
static gboolean static gboolean
@ -357,73 +357,73 @@ handle_video_fields (ConvertData *d)
{ {
const GValue *value, *value2; const GValue *value, *value2;
int i; int i;
struct spa_pod_prop *prop; struct spa_pod_choice *choice;
value = gst_structure_get_value (d->cs, "format"); value = gst_structure_get_value (d->cs, "format");
if (value) { if (value) {
const char *v; const char *v;
int idx; int idx;
for (i = 0; (v = get_nth_string (value, i)); i++) { for (i = 0; (v = get_nth_string (value, i)); i++) {
if (i == 0) if (i == 0) {
spa_pod_builder_push_prop (&d->b, spa_pod_builder_prop (&d->b, SPA_FORMAT_VIDEO_format, 0);
SPA_FORMAT_VIDEO_format, spa_pod_builder_push_choice(&d->b, get_range_type (value), 0);
get_range_type (value)); }
idx = gst_video_format_from_string (v); idx = gst_video_format_from_string (v);
if (idx < SPA_N_ELEMENTS (video_format_map)) if (idx < SPA_N_ELEMENTS (video_format_map))
spa_pod_builder_enum (&d->b, video_format_map[idx]); spa_pod_builder_id (&d->b, video_format_map[idx]);
} }
prop = spa_pod_builder_pop(&d->b); choice = spa_pod_builder_pop(&d->b);
if (i > 1) if (i <= 1)
prop->body.flags |= SPA_POD_PROP_FLAG_UNSET; choice->body.type = SPA_CHOICE_None;
} }
value = gst_structure_get_value (d->cs, "width"); value = gst_structure_get_value (d->cs, "width");
value2 = gst_structure_get_value (d->cs, "height"); value2 = gst_structure_get_value (d->cs, "height");
if (value || value2) { if (value || value2) {
struct spa_rectangle v; struct spa_rectangle v;
for (i = 0; get_nth_rectangle (value, value2, i, &v); i++) { for (i = 0; get_nth_rectangle (value, value2, i, &v); i++) {
if (i == 0) if (i == 0) {
spa_pod_builder_push_prop (&d->b, spa_pod_builder_prop (&d->b, SPA_FORMAT_VIDEO_size, 0);
SPA_FORMAT_VIDEO_size, spa_pod_builder_push_choice(&d->b, get_range_type2 (value, value2), 0);
get_range_type2 (value, value2)); }
spa_pod_builder_rectangle (&d->b, v.width, v.height); spa_pod_builder_rectangle (&d->b, v.width, v.height);
} }
prop = spa_pod_builder_pop(&d->b); choice = spa_pod_builder_pop(&d->b);
if (i > 1) if (i <= 1)
prop->body.flags |= SPA_POD_PROP_FLAG_UNSET; choice->body.type = SPA_CHOICE_None;
} }
value = gst_structure_get_value (d->cs, "framerate"); value = gst_structure_get_value (d->cs, "framerate");
if (value) { if (value) {
struct spa_fraction v; struct spa_fraction v;
for (i = 0; get_nth_fraction (value, i, &v); i++) { for (i = 0; get_nth_fraction (value, i, &v); i++) {
if (i == 0) if (i == 0) {
spa_pod_builder_push_prop (&d->b, spa_pod_builder_prop (&d->b, SPA_FORMAT_VIDEO_framerate, 0);
SPA_FORMAT_VIDEO_framerate, spa_pod_builder_push_choice(&d->b, get_range_type (value), 0);
get_range_type (value)); }
spa_pod_builder_fraction (&d->b, v.num, v.denom); spa_pod_builder_fraction (&d->b, v.num, v.denom);
} }
prop = spa_pod_builder_pop(&d->b); choice = spa_pod_builder_pop(&d->b);
if (i > 1) if (i <= 1)
prop->body.flags |= SPA_POD_PROP_FLAG_UNSET; choice->body.type = SPA_CHOICE_None;
} }
value = gst_structure_get_value (d->cs, "max-framerate"); value = gst_structure_get_value (d->cs, "max-framerate");
if (value) { if (value) {
struct spa_fraction v; struct spa_fraction v;
for (i = 0; get_nth_fraction (value, i, &v); i++) { for (i = 0; get_nth_fraction (value, i, &v); i++) {
if (i == 0) if (i == 0) {
spa_pod_builder_push_prop (&d->b, spa_pod_builder_prop (&d->b, SPA_FORMAT_VIDEO_maxFramerate, 0);
SPA_FORMAT_VIDEO_maxFramerate, spa_pod_builder_push_choice(&d->b, get_range_type (value), 0);
get_range_type (value)); }
spa_pod_builder_fraction (&d->b, v.num, v.denom); spa_pod_builder_fraction (&d->b, v.num, v.denom);
} }
prop = spa_pod_builder_pop(&d->b); choice = spa_pod_builder_pop(&d->b);
if (i > 1) if (i <= 1)
prop->body.flags |= SPA_POD_PROP_FLAG_UNSET; choice->body.type = SPA_CHOICE_None;
} }
return TRUE; return TRUE;
} }
@ -432,7 +432,7 @@ static gboolean
handle_audio_fields (ConvertData *d) handle_audio_fields (ConvertData *d)
{ {
const GValue *value; const GValue *value;
struct spa_pod_prop *prop; struct spa_pod_choice *choice;
int i = 0; int i = 0;
value = gst_structure_get_value (d->cs, "format"); value = gst_structure_get_value (d->cs, "format");
@ -440,18 +440,18 @@ handle_audio_fields (ConvertData *d)
const char *v; const char *v;
int idx; int idx;
for (i = 0; (v = get_nth_string (value, i)); i++) { for (i = 0; (v = get_nth_string (value, i)); i++) {
if (i == 0) if (i == 0) {
spa_pod_builder_push_prop (&d->b, spa_pod_builder_prop (&d->b, SPA_FORMAT_AUDIO_format, 0);
SPA_FORMAT_AUDIO_format, spa_pod_builder_push_choice(&d->b, get_range_type (value), 0);
get_range_type (value)); }
idx = gst_audio_format_from_string (v); idx = gst_audio_format_from_string (v);
if (idx < SPA_N_ELEMENTS (audio_format_map)) if (idx < SPA_N_ELEMENTS (audio_format_map))
spa_pod_builder_enum (&d->b, audio_format_map[idx]); spa_pod_builder_id (&d->b, audio_format_map[idx]);
} }
prop = spa_pod_builder_pop(&d->b); choice = spa_pod_builder_pop(&d->b);
if (i > 1) if (i <= 1)
prop->body.flags |= SPA_POD_PROP_FLAG_UNSET; choice->body.type = SPA_CHOICE_None;
} }
value = gst_structure_get_value (d->cs, "layout"); value = gst_structure_get_value (d->cs, "layout");
@ -467,46 +467,46 @@ handle_audio_fields (ConvertData *d)
else else
break; break;
if (i == 0) if (i == 0) {
spa_pod_builder_push_prop (&d->b, spa_pod_builder_prop (&d->b, SPA_FORMAT_AUDIO_layout, 0);
SPA_FORMAT_AUDIO_layout, spa_pod_builder_push_choice(&d->b, get_range_type (value), 0);
get_range_type (value)); }
spa_pod_builder_enum (&d->b, layout); spa_pod_builder_id (&d->b, layout);
} }
prop = spa_pod_builder_pop(&d->b); choice = spa_pod_builder_pop(&d->b);
if (i > 1) if (i <= 1)
prop->body.flags |= SPA_POD_PROP_FLAG_UNSET; choice->body.type = SPA_CHOICE_None;
} }
value = gst_structure_get_value (d->cs, "rate"); value = gst_structure_get_value (d->cs, "rate");
if (value) { if (value) {
int v; int v;
for (i = 0; get_nth_int (value, i, &v); i++) { for (i = 0; get_nth_int (value, i, &v); i++) {
if (i == 0) if (i == 0) {
spa_pod_builder_push_prop (&d->b, spa_pod_builder_prop (&d->b, SPA_FORMAT_AUDIO_rate, 0);
SPA_FORMAT_AUDIO_rate, spa_pod_builder_push_choice(&d->b, get_range_type (value), 0);
get_range_type (value)); }
spa_pod_builder_int (&d->b, v); spa_pod_builder_int (&d->b, v);
} }
prop = spa_pod_builder_pop(&d->b); choice = spa_pod_builder_pop(&d->b);
if (i > 1) if (i <= 1)
prop->body.flags |= SPA_POD_PROP_FLAG_UNSET; choice->body.type = SPA_CHOICE_None;
} }
value = gst_structure_get_value (d->cs, "channels"); value = gst_structure_get_value (d->cs, "channels");
if (value) { if (value) {
int v; int v;
for (i = 0; get_nth_int (value, i, &v); i++) { for (i = 0; get_nth_int (value, i, &v); i++) {
if (i == 0) if (i == 0) {
spa_pod_builder_push_prop (&d->b, spa_pod_builder_prop (&d->b, SPA_FORMAT_AUDIO_channels, 0);
SPA_FORMAT_AUDIO_channels, spa_pod_builder_push_choice(&d->b, get_range_type (value), 0);
get_range_type (value)); }
spa_pod_builder_int (&d->b, v); spa_pod_builder_int (&d->b, v);
} }
prop = spa_pod_builder_pop(&d->b); choice = spa_pod_builder_pop(&d->b);
if (i > 1) if (i <= 1)
prop->body.flags |= SPA_POD_PROP_FLAG_UNSET; choice->body.type = SPA_CHOICE_None;
} }
return TRUE; return TRUE;
} }
@ -536,13 +536,11 @@ convert_1 (ConvertData *d)
spa_pod_builder_push_object (&d->b, SPA_TYPE_OBJECT_Format, d->id); spa_pod_builder_push_object (&d->b, SPA_TYPE_OBJECT_Format, d->id);
spa_pod_builder_push_prop (&d->b, SPA_FORMAT_mediaType, 0); spa_pod_builder_prop (&d->b, SPA_FORMAT_mediaType, 0);
spa_pod_builder_enum(&d->b, d->type->media_type); spa_pod_builder_id(&d->b, d->type->media_type);
spa_pod_builder_pop (&d->b);
spa_pod_builder_push_prop (&d->b, SPA_FORMAT_mediaSubtype, 0); spa_pod_builder_prop (&d->b, SPA_FORMAT_mediaSubtype, 0);
spa_pod_builder_enum(&d->b, d->type->media_subtype); spa_pod_builder_id(&d->b, d->type->media_subtype);
spa_pod_builder_pop (&d->b);
if (d->type->media_type == SPA_MEDIA_TYPE_video) if (d->type->media_type == SPA_MEDIA_TYPE_video)
handle_video_fields (d); handle_video_fields (d);
@ -627,21 +625,23 @@ static void
handle_id_prop (struct spa_pod_prop *prop, const char *key, id_to_string_func func, GstCaps *res) handle_id_prop (struct spa_pod_prop *prop, const char *key, id_to_string_func func, GstCaps *res)
{ {
const char * str; const char * str;
uint32_t *id = SPA_POD_CONTENTS (struct spa_pod_prop, prop); struct spa_pod *val;
uint32_t i, n_items = SPA_POD_PROP_N_VALUES (prop); uint32_t *id;
uint32_t flags; uint32_t i, n_items, choice;
flags = prop->body.flags; val = spa_pod_get_values(&prop->value, &n_items, &choice);
if (!(flags & SPA_POD_PROP_FLAG_UNSET)) if (val->type != SPA_TYPE_Id)
flags &= ~SPA_POD_PROP_RANGE_MASK; return;
switch (flags & SPA_POD_PROP_RANGE_MASK) { id = SPA_POD_BODY(val);
case SPA_POD_PROP_RANGE_NONE:
switch (choice) {
case SPA_CHOICE_None:
if (!(str = func(id[0]))) if (!(str = func(id[0])))
return; return;
gst_caps_set_simple (res, key, G_TYPE_STRING, rindex (str, ':') + 1, NULL); gst_caps_set_simple (res, key, G_TYPE_STRING, rindex (str, ':') + 1, NULL);
break; break;
case SPA_POD_PROP_RANGE_ENUM: case SPA_CHOICE_Enum:
{ {
GValue list = { 0 }, v = { 0 }; GValue list = { 0 }, v = { 0 };
@ -666,34 +666,36 @@ handle_id_prop (struct spa_pod_prop *prop, const char *key, id_to_string_func fu
static void static void
handle_int_prop (struct spa_pod_prop *prop, const char *key, GstCaps *res) handle_int_prop (struct spa_pod_prop *prop, const char *key, GstCaps *res)
{ {
uint32_t *val = SPA_POD_CONTENTS (struct spa_pod_prop, prop); struct spa_pod *val;
uint32_t i, n_items = SPA_POD_PROP_N_VALUES (prop); uint32_t *ints;
uint32_t flags; uint32_t i, n_items, choice;
flags = prop->body.flags; val = spa_pod_get_values(&prop->value, &n_items, &choice);
if (!(flags & SPA_POD_PROP_FLAG_UNSET)) if (val->type != SPA_TYPE_Int)
flags &= ~SPA_POD_PROP_RANGE_MASK; return;
switch (flags & SPA_POD_PROP_RANGE_MASK) { ints = SPA_POD_BODY(val);
case SPA_POD_PROP_RANGE_NONE:
gst_caps_set_simple (res, key, G_TYPE_INT, val[0], NULL); switch (choice) {
case SPA_CHOICE_None:
gst_caps_set_simple (res, key, G_TYPE_INT, ints[0], NULL);
break; break;
case SPA_POD_PROP_RANGE_MIN_MAX: case SPA_CHOICE_Range:
case SPA_POD_PROP_RANGE_STEP: case SPA_CHOICE_Step:
{ {
if (n_items < 3) if (n_items < 3)
return; return;
gst_caps_set_simple (res, key, GST_TYPE_INT_RANGE, val[1], val[2], NULL); gst_caps_set_simple (res, key, GST_TYPE_INT_RANGE, ints[1], ints[2], NULL);
break; break;
} }
case SPA_POD_PROP_RANGE_ENUM: case SPA_CHOICE_Enum:
{ {
GValue list = { 0 }, v = { 0 }; GValue list = { 0 }, v = { 0 };
g_value_init (&list, GST_TYPE_LIST); g_value_init (&list, GST_TYPE_LIST);
for (i = 1; i < n_items; i++) { for (i = 1; i < n_items; i++) {
g_value_init (&v, G_TYPE_INT); g_value_init (&v, G_TYPE_INT);
g_value_set_int (&v, val[i]); g_value_set_int (&v, ints[i]);
gst_value_list_append_and_take_value (&list, &v); gst_value_list_append_and_take_value (&list, &v);
} }
gst_caps_set_value (res, key, &list); gst_caps_set_value (res, key, &list);
@ -708,21 +710,23 @@ handle_int_prop (struct spa_pod_prop *prop, const char *key, GstCaps *res)
static void static void
handle_rect_prop (struct spa_pod_prop *prop, const char *width, const char *height, GstCaps *res) handle_rect_prop (struct spa_pod_prop *prop, const char *width, const char *height, GstCaps *res)
{ {
struct spa_rectangle *rect = SPA_POD_CONTENTS (struct spa_pod_prop, prop); struct spa_pod *val;
uint32_t i, n_items = SPA_POD_PROP_N_VALUES (prop); struct spa_rectangle *rect;
uint32_t flags; uint32_t i, n_items, choice;
flags = prop->body.flags; val = spa_pod_get_values(&prop->value, &n_items, &choice);
if (!(flags & SPA_POD_PROP_FLAG_UNSET)) if (val->type != SPA_TYPE_Rectangle)
flags &= ~SPA_POD_PROP_RANGE_MASK; return;
switch (flags & SPA_POD_PROP_RANGE_MASK) { rect = SPA_POD_BODY(val);
case SPA_POD_PROP_RANGE_NONE:
switch (choice) {
case SPA_CHOICE_None:
gst_caps_set_simple (res, width, G_TYPE_INT, rect[0].width, gst_caps_set_simple (res, width, G_TYPE_INT, rect[0].width,
height, G_TYPE_INT, rect[0].height, NULL); height, G_TYPE_INT, rect[0].height, NULL);
break; break;
case SPA_POD_PROP_RANGE_MIN_MAX: case SPA_CHOICE_Range:
case SPA_POD_PROP_RANGE_STEP: case SPA_CHOICE_Step:
{ {
if (n_items < 3) if (n_items < 3)
return; return;
@ -730,7 +734,7 @@ handle_rect_prop (struct spa_pod_prop *prop, const char *width, const char *heig
height, GST_TYPE_INT_RANGE, rect[1].height, rect[2].height, NULL); height, GST_TYPE_INT_RANGE, rect[1].height, rect[2].height, NULL);
break; break;
} }
case SPA_POD_PROP_RANGE_ENUM: case SPA_CHOICE_Enum:
{ {
GValue l1 = { 0 }, l2 = { 0 }, v1 = { 0 }, v2 = { 0 }; GValue l1 = { 0 }, l2 = { 0 }, v1 = { 0 }, v2 = { 0 };
@ -759,20 +763,22 @@ handle_rect_prop (struct spa_pod_prop *prop, const char *width, const char *heig
static void static void
handle_fraction_prop (struct spa_pod_prop *prop, const char *key, GstCaps *res) handle_fraction_prop (struct spa_pod_prop *prop, const char *key, GstCaps *res)
{ {
struct spa_fraction *fract = SPA_POD_CONTENTS (struct spa_pod_prop, prop); struct spa_pod *val;
uint32_t i, n_items = SPA_POD_PROP_N_VALUES (prop); struct spa_fraction *fract;
uint32_t flags; uint32_t i, n_items, choice;
flags = prop->body.flags; val = spa_pod_get_values(&prop->value, &n_items, &choice);
if (!(flags & SPA_POD_PROP_FLAG_UNSET)) if (val->type != SPA_TYPE_Fraction)
flags &= ~SPA_POD_PROP_RANGE_MASK; return;
switch (flags & SPA_POD_PROP_RANGE_MASK) { fract = SPA_POD_BODY(val);
case SPA_POD_PROP_RANGE_NONE:
switch (choice) {
case SPA_CHOICE_None:
gst_caps_set_simple (res, key, GST_TYPE_FRACTION, fract[0].num, fract[0].denom, NULL); gst_caps_set_simple (res, key, GST_TYPE_FRACTION, fract[0].num, fract[0].denom, NULL);
break; break;
case SPA_POD_PROP_RANGE_MIN_MAX: case SPA_CHOICE_Range:
case SPA_POD_PROP_RANGE_STEP: case SPA_CHOICE_Step:
{ {
if (n_items < 3) if (n_items < 3)
return; return;
@ -780,7 +786,7 @@ handle_fraction_prop (struct spa_pod_prop *prop, const char *key, GstCaps *res)
fract[2].num, fract[2].denom, NULL); fract[2].num, fract[2].denom, NULL);
break; break;
} }
case SPA_POD_PROP_RANGE_ENUM: case SPA_CHOICE_Enum:
{ {
GValue l1 = { 0 }, v1 = { 0 }; GValue l1 = { 0 }, v1 = { 0 };

View file

@ -232,25 +232,25 @@ pool_activated (GstPipeWirePool *pool, GstPipeWireSink *sink)
spa_pod_builder_init (&b, buffer, sizeof (buffer)); spa_pod_builder_init (&b, buffer, sizeof (buffer));
spa_pod_builder_push_object (&b, SPA_TYPE_OBJECT_ParamBuffers, SPA_PARAM_Buffers); spa_pod_builder_push_object (&b, SPA_TYPE_OBJECT_ParamBuffers, SPA_PARAM_Buffers);
if (size == 0) if (size == 0)
spa_pod_builder_add (&b, spa_pod_builder_props (&b,
":", SPA_PARAM_BUFFERS_size, "iru", 0, SPA_POD_PROP_MIN_MAX(0, INT32_MAX), NULL); SPA_PARAM_BUFFERS_size, &SPA_POD_CHOICE_RANGE_Int(0, 0, INT32_MAX), 0);
else else
spa_pod_builder_add (&b, spa_pod_builder_props (&b,
":", SPA_PARAM_BUFFERS_size, "iru", size, SPA_POD_PROP_MIN_MAX(size, INT32_MAX), NULL); SPA_PARAM_BUFFERS_size, &SPA_POD_CHOICE_RANGE_Int(size, size, INT32_MAX), 0);
spa_pod_builder_add (&b, spa_pod_builder_props (&b,
":", SPA_PARAM_BUFFERS_stride, "iru", 0, SPA_POD_PROP_MIN_MAX(0, INT32_MAX), SPA_PARAM_BUFFERS_stride, &SPA_POD_CHOICE_RANGE_Int(0, 0, INT32_MAX),
":", SPA_PARAM_BUFFERS_buffers, "iru", min_buffers, SPA_PARAM_BUFFERS_buffers, &SPA_POD_CHOICE_RANGE_Int(min_buffers, min_buffers,
SPA_POD_PROP_MIN_MAX(min_buffers,
max_buffers ? max_buffers : INT32_MAX), max_buffers ? max_buffers : INT32_MAX),
":", SPA_PARAM_BUFFERS_align, "i", 16, SPA_PARAM_BUFFERS_align, &SPA_POD_Int(16),
NULL); 0);
port_params[0] = spa_pod_builder_pop (&b); port_params[0] = spa_pod_builder_pop (&b);
port_params[1] = spa_pod_builder_object (&b, port_params[1] = spa_pod_builder_object (&b,
SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta, SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta,
":", SPA_PARAM_META_type, "I", SPA_META_Header, SPA_PARAM_META_type, &SPA_POD_Int(SPA_META_Header),
":", SPA_PARAM_META_size, "i", sizeof (struct spa_meta_header)); SPA_PARAM_META_size, &SPA_POD_Int(sizeof (struct spa_meta_header)),
0);
pw_thread_loop_lock (sink->main_loop); pw_thread_loop_lock (sink->main_loop);

View file

@ -703,16 +703,18 @@ on_format_changed (void *data,
spa_pod_builder_init (&b, buffer, sizeof (buffer)); spa_pod_builder_init (&b, buffer, sizeof (buffer));
params[0] = spa_pod_builder_object (&b, params[0] = spa_pod_builder_object (&b,
SPA_TYPE_OBJECT_ParamBuffers, SPA_PARAM_Buffers, SPA_TYPE_OBJECT_ParamBuffers, SPA_PARAM_Buffers,
":", SPA_PARAM_BUFFERS_buffers, "iru", 16, SPA_POD_PROP_MIN_MAX(1, INT32_MAX), SPA_PARAM_BUFFERS_buffers, &SPA_POD_CHOICE_RANGE_Int(16, 1, INT32_MAX),
":", SPA_PARAM_BUFFERS_blocks, "iru", 0, SPA_POD_PROP_MIN_MAX(1, INT32_MAX), SPA_PARAM_BUFFERS_blocks, &SPA_POD_CHOICE_RANGE_Int(0, 1, INT32_MAX),
":", SPA_PARAM_BUFFERS_size, "iru", 0, SPA_POD_PROP_MIN_MAX(0, INT32_MAX), SPA_PARAM_BUFFERS_size, &SPA_POD_CHOICE_RANGE_Int(0, 0, INT32_MAX),
":", SPA_PARAM_BUFFERS_stride, "iru", 0, SPA_POD_PROP_MIN_MAX(0, INT32_MAX), SPA_PARAM_BUFFERS_stride, &SPA_POD_CHOICE_RANGE_Int(0, 0, INT32_MAX),
":", SPA_PARAM_BUFFERS_align, "i", 16); SPA_PARAM_BUFFERS_align, &SPA_POD_Int(16),
0);
params[1] = spa_pod_builder_object (&b, params[1] = spa_pod_builder_object (&b,
SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta, SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta,
":", SPA_PARAM_META_type, "I", SPA_META_Header, SPA_PARAM_META_type, &SPA_POD_Id(SPA_META_Header),
":", SPA_PARAM_META_size, "i", sizeof (struct spa_meta_header)); SPA_PARAM_META_size, &SPA_POD_Int(sizeof (struct spa_meta_header)),
0);
GST_DEBUG_OBJECT (pwsrc, "doing finish format"); GST_DEBUG_OBJECT (pwsrc, "doing finish format");
pw_stream_finish_format (pwsrc->stream, 0, params, 2); pw_stream_finish_format (pwsrc->stream, 0, params, 2);

View file

@ -37,7 +37,7 @@ client_node_marshal_done(void *object, int seq, int res)
b = pw_protocol_native_begin_proxy(proxy, PW_CLIENT_NODE_PROXY_METHOD_DONE); b = pw_protocol_native_begin_proxy(proxy, PW_CLIENT_NODE_PROXY_METHOD_DONE);
spa_pod_builder_struct(b, spa_pod_builder_add_struct(b,
"i", seq, "i", seq,
"i", res); "i", res);
@ -136,7 +136,7 @@ static void client_node_marshal_set_active(void *object, bool active)
b = pw_protocol_native_begin_proxy(proxy, PW_CLIENT_NODE_PROXY_METHOD_SET_ACTIVE); b = pw_protocol_native_begin_proxy(proxy, PW_CLIENT_NODE_PROXY_METHOD_SET_ACTIVE);
spa_pod_builder_struct(b, "b", active); spa_pod_builder_add_struct(b, "b", active);
pw_protocol_native_end_proxy(proxy, b); pw_protocol_native_end_proxy(proxy, b);
} }
@ -148,7 +148,7 @@ static void client_node_marshal_event_method(void *object, struct spa_event *eve
b = pw_protocol_native_begin_proxy(proxy, PW_CLIENT_NODE_PROXY_METHOD_EVENT); b = pw_protocol_native_begin_proxy(proxy, PW_CLIENT_NODE_PROXY_METHOD_EVENT);
spa_pod_builder_struct(b, "P", event); spa_pod_builder_add_struct(b, "P", event);
pw_protocol_native_end_proxy(proxy, b); pw_protocol_native_end_proxy(proxy, b);
} }
@ -160,7 +160,7 @@ static void client_node_marshal_destroy(void *object)
b = pw_protocol_native_begin_proxy(proxy, PW_CLIENT_NODE_PROXY_METHOD_DESTROY); b = pw_protocol_native_begin_proxy(proxy, PW_CLIENT_NODE_PROXY_METHOD_DESTROY);
spa_pod_builder_struct(b); spa_pod_builder_add_struct(b);
pw_protocol_native_end_proxy(proxy, b); pw_protocol_native_end_proxy(proxy, b);
} }
@ -471,7 +471,7 @@ client_node_marshal_add_mem(void *object,
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_ADD_MEM); b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_ADD_MEM);
spa_pod_builder_struct(b, spa_pod_builder_add_struct(b,
"i", mem_id, "i", mem_id,
"I", type, "I", type,
"i", pw_protocol_native_add_resource_fd(resource, memfd), "i", pw_protocol_native_add_resource_fd(resource, memfd),
@ -487,7 +487,7 @@ static void client_node_marshal_transport(void *object, uint32_t node_id, int re
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_TRANSPORT); b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_TRANSPORT);
spa_pod_builder_struct(b, spa_pod_builder_add_struct(b,
"i", node_id, "i", node_id,
"i", pw_protocol_native_add_resource_fd(resource, readfd), "i", pw_protocol_native_add_resource_fd(resource, readfd),
"i", pw_protocol_native_add_resource_fd(resource, writefd)); "i", pw_protocol_native_add_resource_fd(resource, writefd));
@ -504,7 +504,7 @@ client_node_marshal_set_param(void *object, uint32_t seq, uint32_t id, uint32_t
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_SET_PARAM); b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_SET_PARAM);
spa_pod_builder_struct(b, spa_pod_builder_add_struct(b,
"i", seq, "i", seq,
"I", id, "I", id,
"i", flags, "i", flags,
@ -520,7 +520,7 @@ static void client_node_marshal_event_event(void *object, const struct spa_event
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_EVENT); b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_EVENT);
spa_pod_builder_struct(b, "P", event); spa_pod_builder_add_struct(b, "P", event);
pw_protocol_native_end_resource(resource, b); pw_protocol_native_end_resource(resource, b);
} }
@ -533,7 +533,7 @@ client_node_marshal_command(void *object, uint32_t seq, const struct spa_command
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_COMMAND); b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_COMMAND);
spa_pod_builder_struct(b, "i", seq, "P", command); spa_pod_builder_add_struct(b, "i", seq, "P", command);
pw_protocol_native_end_resource(resource, b); pw_protocol_native_end_resource(resource, b);
} }
@ -547,7 +547,7 @@ client_node_marshal_add_port(void *object,
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_ADD_PORT); b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_ADD_PORT);
spa_pod_builder_struct(b, spa_pod_builder_add_struct(b,
"i", seq, "i", seq,
"i", direction, "i", direction,
"i", port_id); "i", port_id);
@ -564,7 +564,7 @@ client_node_marshal_remove_port(void *object,
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_REMOVE_PORT); b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_REMOVE_PORT);
spa_pod_builder_struct(b, spa_pod_builder_add_struct(b,
"i", seq, "i", seq,
"i", direction, "i", direction,
"i", port_id); "i", port_id);
@ -586,7 +586,7 @@ client_node_marshal_port_set_param(void *object,
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_PORT_SET_PARAM); b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_PORT_SET_PARAM);
spa_pod_builder_struct(b, spa_pod_builder_add_struct(b,
"i", seq, "i", seq,
"i", direction, "i", direction,
"i", port_id, "i", port_id,
@ -662,7 +662,7 @@ client_node_marshal_port_command(void *object,
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_PORT_COMMAND); b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_PORT_COMMAND);
spa_pod_builder_struct(b, spa_pod_builder_add_struct(b,
"i", direction, "i", direction,
"i", port_id, "i", port_id,
"P", command); "P", command);
@ -686,7 +686,7 @@ client_node_marshal_port_set_io(void *object,
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_PORT_SET_IO); b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_PORT_SET_IO);
spa_pod_builder_struct(b, spa_pod_builder_add_struct(b,
"i", seq, "i", seq,
"i", direction, "i", direction,
"i", port_id, "i", port_id,
@ -710,7 +710,7 @@ client_node_marshal_set_io(void *object,
struct spa_pod_builder *b; struct spa_pod_builder *b;
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_SET_IO); b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_SET_IO);
spa_pod_builder_struct(b, spa_pod_builder_add_struct(b,
"I", id, "I", id,
"i", memid, "i", memid,
"i", offset, "i", offset,

View file

@ -329,13 +329,13 @@ static int port_enum_formats(struct spa_node *node,
} else { } else {
*param = spa_pod_builder_object(builder, *param = spa_pod_builder_object(builder,
SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat, SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
":", SPA_FORMAT_mediaType, "I", SPA_MEDIA_TYPE_audio, SPA_FORMAT_mediaType, &SPA_POD_Id(SPA_MEDIA_TYPE_audio),
":", SPA_FORMAT_mediaSubtype, "I", SPA_MEDIA_SUBTYPE_raw, SPA_FORMAT_mediaSubtype, &SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw),
":", SPA_FORMAT_AUDIO_format, "I", SPA_AUDIO_FORMAT_F32, SPA_FORMAT_AUDIO_format, &SPA_POD_Id(SPA_AUDIO_FORMAT_F32),
":", SPA_FORMAT_AUDIO_layout, "I", SPA_AUDIO_LAYOUT_NON_INTERLEAVED, SPA_FORMAT_AUDIO_layout, &SPA_POD_Id(SPA_AUDIO_LAYOUT_NON_INTERLEAVED),
":", SPA_FORMAT_AUDIO_rate, "iru", 44100, SPA_FORMAT_AUDIO_rate, &SPA_POD_CHOICE_RANGE_Int(44100, 1, INT32_MAX),
SPA_POD_PROP_MIN_MAX(1, INT32_MAX), SPA_FORMAT_AUDIO_channels, &SPA_POD_Int(1),
":", SPA_FORMAT_AUDIO_channels, "iru", 1); 0);
} }
break; break;
default: default:
@ -382,8 +382,10 @@ impl_node_port_enum_params(struct spa_node *node,
SPA_PARAM_IO }; SPA_PARAM_IO };
if (*index < SPA_N_ELEMENTS(list)) if (*index < SPA_N_ELEMENTS(list))
param = spa_pod_builder_object(&b, SPA_TYPE_OBJECT_ParamList, id, param = spa_pod_builder_object(&b,
":", SPA_PARAM_LIST_id, "I", list[*index]); SPA_TYPE_OBJECT_ParamList, id,
SPA_PARAM_LIST_id, &SPA_POD_Id(list[*index]),
0);
else else
return 0; return 0;
break; break;
@ -410,13 +412,15 @@ impl_node_port_enum_params(struct spa_node *node,
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamBuffers, id, SPA_TYPE_OBJECT_ParamBuffers, id,
":", SPA_PARAM_BUFFERS_buffers, "iru", 1, SPA_PARAM_BUFFERS_buffers, &SPA_POD_CHOICE_RANGE_Int(1, 1, MAX_BUFFERS),
SPA_POD_PROP_MIN_MAX(1, MAX_BUFFERS), SPA_PARAM_BUFFERS_blocks, &SPA_POD_Int(1),
":", SPA_PARAM_BUFFERS_blocks, "i", 1, SPA_PARAM_BUFFERS_size, &SPA_POD_CHOICE_RANGE_Int(
":", SPA_PARAM_BUFFERS_size, "iru", 1024 * this->stride, 1024 * this->stride,
SPA_POD_PROP_MIN_MAX(16 * this->stride, INT32_MAX / this->stride), 16 * this->stride,
":", SPA_PARAM_BUFFERS_stride, "i", this->stride, INT32_MAX / this->stride),
":", SPA_PARAM_BUFFERS_align, "i", 16); SPA_PARAM_BUFFERS_stride, &SPA_POD_Int(this->stride),
SPA_PARAM_BUFFERS_align, &SPA_POD_Int(16),
0);
break; break;
case SPA_PARAM_Meta: case SPA_PARAM_Meta:
@ -427,8 +431,9 @@ impl_node_port_enum_params(struct spa_node *node,
case 0: case 0:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamMeta, id, SPA_TYPE_OBJECT_ParamMeta, id,
":", SPA_PARAM_META_type, "I", SPA_META_Header, SPA_PARAM_META_type, &SPA_POD_Id(SPA_META_Header),
":", SPA_PARAM_META_size, "i", sizeof(struct spa_meta_header)); SPA_PARAM_META_size, &SPA_POD_Int(sizeof(struct spa_meta_header)),
0);
break; break;
default: default:
return 0; return 0;
@ -440,20 +445,23 @@ impl_node_port_enum_params(struct spa_node *node,
case 0: case 0:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamIO, id, SPA_TYPE_OBJECT_ParamIO, id,
":", SPA_PARAM_IO_id, "I", SPA_IO_Buffers, SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Buffers),
":", SPA_PARAM_IO_size, "i", sizeof(struct spa_io_buffers)); SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_buffers)),
0);
break; break;
case 1: case 1:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamIO, id, SPA_TYPE_OBJECT_ParamIO, id,
":", SPA_PARAM_IO_id, "I", SPA_IO_Range, SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Range),
":", SPA_PARAM_IO_size, "i", sizeof(struct spa_io_range)); SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_range)),
0);
break; break;
case 2: case 2:
param = spa_pod_builder_object(&b, param = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamIO, id, SPA_TYPE_OBJECT_ParamIO, id,
":", SPA_PARAM_IO_id, "I", SPA_IO_Control, SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Control),
":", SPA_PARAM_IO_size, "i", sizeof(struct spa_io_sequence)); SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_sequence)),
0);
break; break;
default: default:
return 0; return 0;

View file

@ -37,7 +37,7 @@ static void core_marshal_hello(void *object)
b = pw_protocol_native_begin_proxy(proxy, PW_CORE_PROXY_METHOD_HELLO); b = pw_protocol_native_begin_proxy(proxy, PW_CORE_PROXY_METHOD_HELLO);
spa_pod_builder_struct(b, "P", NULL); spa_pod_builder_add_struct(b, "P", NULL);
pw_protocol_native_end_proxy(proxy, b); pw_protocol_native_end_proxy(proxy, b);
} }
@ -93,7 +93,7 @@ static void core_marshal_sync(void *object, uint32_t seq)
b = pw_protocol_native_begin_proxy(proxy, PW_CORE_PROXY_METHOD_SYNC); b = pw_protocol_native_begin_proxy(proxy, PW_CORE_PROXY_METHOD_SYNC);
spa_pod_builder_struct(b, "i", seq); spa_pod_builder_add_struct(b, "i", seq);
pw_protocol_native_end_proxy(proxy, b); pw_protocol_native_end_proxy(proxy, b);
} }
@ -105,7 +105,7 @@ static void core_marshal_get_registry(void *object, uint32_t version, uint32_t n
b = pw_protocol_native_begin_proxy(proxy, PW_CORE_PROXY_METHOD_GET_REGISTRY); b = pw_protocol_native_begin_proxy(proxy, PW_CORE_PROXY_METHOD_GET_REGISTRY);
spa_pod_builder_struct(b, spa_pod_builder_add_struct(b,
"i", version, "i", version,
"i", new_id); "i", new_id);
@ -153,7 +153,7 @@ core_marshal_destroy(void *object, uint32_t id)
b = pw_protocol_native_begin_proxy(proxy, PW_CORE_PROXY_METHOD_DESTROY); b = pw_protocol_native_begin_proxy(proxy, PW_CORE_PROXY_METHOD_DESTROY);
spa_pod_builder_struct(b, "i", id); spa_pod_builder_add_struct(b, "i", id);
pw_protocol_native_end_proxy(proxy, b); pw_protocol_native_end_proxy(proxy, b);
} }
@ -276,7 +276,7 @@ static void core_marshal_done(void *object, uint32_t seq)
b = pw_protocol_native_begin_resource(resource, PW_CORE_PROXY_EVENT_DONE); b = pw_protocol_native_begin_resource(resource, PW_CORE_PROXY_EVENT_DONE);
spa_pod_builder_struct(b, "i", seq); spa_pod_builder_add_struct(b, "i", seq);
pw_protocol_native_end_resource(resource, b); pw_protocol_native_end_resource(resource, b);
} }
@ -294,7 +294,7 @@ static void core_marshal_error(void *object, uint32_t id, int res, const char *e
vsnprintf(buffer, sizeof(buffer), error, ap); vsnprintf(buffer, sizeof(buffer), error, ap);
va_end(ap); va_end(ap);
spa_pod_builder_struct(b, spa_pod_builder_add_struct(b,
"i", id, "i", id,
"i", res, "i", res,
"s", buffer); "s", buffer);
@ -309,7 +309,7 @@ static void core_marshal_remove_id(void *object, uint32_t id)
b = pw_protocol_native_begin_resource(resource, PW_CORE_PROXY_EVENT_REMOVE_ID); b = pw_protocol_native_begin_resource(resource, PW_CORE_PROXY_EVENT_REMOVE_ID);
spa_pod_builder_struct(b, "i", id); spa_pod_builder_add_struct(b, "i", id);
pw_protocol_native_end_resource(resource, b); pw_protocol_native_end_resource(resource, b);
} }
@ -485,7 +485,7 @@ static void registry_marshal_global_remove(void *object, uint32_t id)
b = pw_protocol_native_begin_resource(resource, PW_REGISTRY_PROXY_EVENT_GLOBAL_REMOVE); b = pw_protocol_native_begin_resource(resource, PW_REGISTRY_PROXY_EVENT_GLOBAL_REMOVE);
spa_pod_builder_struct(b, "i", id); spa_pod_builder_add_struct(b, "i", id);
pw_protocol_native_end_resource(resource, b); pw_protocol_native_end_resource(resource, b);
} }
@ -704,7 +704,7 @@ static void node_marshal_param(void *object, uint32_t id, uint32_t index, uint32
b = pw_protocol_native_begin_resource(resource, PW_NODE_PROXY_EVENT_PARAM); b = pw_protocol_native_begin_resource(resource, PW_NODE_PROXY_EVENT_PARAM);
spa_pod_builder_struct(b, "I", id, "i", index, "i", next, "P", param); spa_pod_builder_add_struct(b, "I", id, "i", index, "i", next, "P", param);
pw_protocol_native_end_resource(resource, b); pw_protocol_native_end_resource(resource, b);
} }
@ -736,7 +736,7 @@ static void node_marshal_enum_params(void *object, uint32_t id, uint32_t index,
b = pw_protocol_native_begin_proxy(proxy, PW_NODE_PROXY_METHOD_ENUM_PARAMS); b = pw_protocol_native_begin_proxy(proxy, PW_NODE_PROXY_METHOD_ENUM_PARAMS);
spa_pod_builder_struct(b, spa_pod_builder_add_struct(b,
"I", id, "I", id,
"i", index, "i", index,
"i", num, "i", num,
@ -828,7 +828,7 @@ static void port_marshal_param(void *object, uint32_t id, uint32_t index, uint32
b = pw_protocol_native_begin_resource(resource, PW_PORT_PROXY_EVENT_PARAM); b = pw_protocol_native_begin_resource(resource, PW_PORT_PROXY_EVENT_PARAM);
spa_pod_builder_struct(b, "I", id, "i", index, "i", next, "P", param); spa_pod_builder_add_struct(b, "I", id, "i", index, "i", next, "P", param);
pw_protocol_native_end_resource(resource, b); pw_protocol_native_end_resource(resource, b);
} }
@ -860,7 +860,7 @@ static void port_marshal_enum_params(void *object, uint32_t id, uint32_t index,
b = pw_protocol_native_begin_proxy(proxy, PW_PORT_PROXY_METHOD_ENUM_PARAMS); b = pw_protocol_native_begin_proxy(proxy, PW_PORT_PROXY_METHOD_ENUM_PARAMS);
spa_pod_builder_struct(b, spa_pod_builder_add_struct(b,
"I", id, "I", id,
"i", index, "i", index,
"i", num, "i", num,
@ -1060,7 +1060,7 @@ static void registry_marshal_bind(void *object, uint32_t id,
b = pw_protocol_native_begin_proxy(proxy, PW_REGISTRY_PROXY_METHOD_BIND); b = pw_protocol_native_begin_proxy(proxy, PW_REGISTRY_PROXY_METHOD_BIND);
spa_pod_builder_struct(b, spa_pod_builder_add_struct(b,
"i", id, "i", id,
"I", type, "I", type,
"i", version, "i", version,

View file

@ -31,6 +31,7 @@
#include <spa/node/node.h> #include <spa/node/node.h>
#include <spa/monitor/monitor.h> #include <spa/monitor/monitor.h>
#include <spa/pod/parser.h> #include <spa/pod/parser.h>
#include <spa/debug/pod.h>
#include <pipewire/log.h> #include <pipewire/log.h>
#include <pipewire/type.h> #include <pipewire/type.h>
@ -80,8 +81,11 @@ static struct monitor_item *add_item(struct pw_spa_monitor *this,
":", SPA_MONITOR_ITEM_name, "s", &name, ":", SPA_MONITOR_ITEM_name, "s", &name,
":", SPA_MONITOR_ITEM_class, "s", &klass, ":", SPA_MONITOR_ITEM_class, "s", &klass,
":", SPA_MONITOR_ITEM_factory, "p", &factory, ":", SPA_MONITOR_ITEM_factory, "p", &factory,
":", SPA_MONITOR_ITEM_info, "T", &info, NULL) < 0) ":", SPA_MONITOR_ITEM_info, "T", &info, NULL) < 0) {
pw_log_warn("monitor %p: could not parse item", this);
spa_debug_pod(0, NULL, item);
return NULL; return NULL;
}
pw_log_debug("monitor %p: add: \"%s\" (%s)", this, name, id); pw_log_debug("monitor %p: add: \"%s\" (%s)", this, name, id);

View file

@ -181,29 +181,29 @@ setup_props(struct pw_core *core, struct spa_node *spa_node, struct pw_propertie
pw_log_info("configure prop %s", key); pw_log_info("configure prop %s", key);
switch(prop->body.value.type) { switch(prop->value.type) {
case SPA_TYPE_Bool: case SPA_TYPE_Bool:
SPA_POD_VALUE(struct spa_pod_bool, &prop->body.value) = SPA_POD_VALUE(struct spa_pod_bool, &prop->value) =
pw_properties_parse_bool(value); pw_properties_parse_bool(value);
break; break;
case SPA_TYPE_Enum: case SPA_TYPE_Id:
SPA_POD_VALUE(struct spa_pod_enum, &prop->body.value) = SPA_POD_VALUE(struct spa_pod_id, &prop->value) =
spa_debug_type_find_type(NULL, value); spa_debug_type_find_type(NULL, value);
break; break;
case SPA_TYPE_Int: case SPA_TYPE_Int:
SPA_POD_VALUE(struct spa_pod_int, &prop->body.value) = SPA_POD_VALUE(struct spa_pod_int, &prop->value) =
pw_properties_parse_int(value); pw_properties_parse_int(value);
break; break;
case SPA_TYPE_Long: case SPA_TYPE_Long:
SPA_POD_VALUE(struct spa_pod_long, &prop->body.value) = SPA_POD_VALUE(struct spa_pod_long, &prop->value) =
pw_properties_parse_int64(value); pw_properties_parse_int64(value);
break; break;
case SPA_TYPE_Float: case SPA_TYPE_Float:
SPA_POD_VALUE(struct spa_pod_float, &prop->body.value) = SPA_POD_VALUE(struct spa_pod_float, &prop->value) =
pw_properties_parse_float(value); pw_properties_parse_float(value);
break; break;
case SPA_TYPE_Double: case SPA_TYPE_Double:
SPA_POD_VALUE(struct spa_pod_double, &prop->body.value) = SPA_POD_VALUE(struct spa_pod_double, &prop->value) =
pw_properties_parse_double(value); pw_properties_parse_double(value);
break; break;
case SPA_TYPE_String: case SPA_TYPE_String:

View file

@ -406,7 +406,8 @@ static int impl_port_enum_params(struct spa_node *node,
if (last_id == SPA_ID_INVALID){ if (last_id == SPA_ID_INVALID){
*result = spa_pod_builder_object(builder, *result = spa_pod_builder_object(builder,
SPA_TYPE_OBJECT_ParamList, id, SPA_TYPE_OBJECT_ParamList, id,
":", SPA_PARAM_LIST_id, "I", new_id); SPA_PARAM_LIST_id, &SPA_POD_Id(new_id),
0);
last_id = new_id; last_id = new_id;
} }
else if (last_id != new_id) { else if (last_id != new_id) {
@ -631,10 +632,9 @@ static int process_notify(struct stream *impl, struct spa_pod_sequence *sequence
if (impl->props.changed) { if (impl->props.changed) {
spa_pod_builder_control_header(&b, 0, SPA_CONTROL_Properties); spa_pod_builder_control_header(&b, 0, SPA_CONTROL_Properties);
spa_pod_builder_push_object(&b, SPA_TYPE_OBJECT_Props, 0); spa_pod_builder_push_object(&b, SPA_TYPE_OBJECT_Props, 0);
spa_pod_builder_push_prop(&b, SPA_PROP_volume, 0); spa_pod_builder_prop(&b, SPA_PROP_volume, 0);
spa_pod_builder_float(&b, impl->props.volume); spa_pod_builder_float(&b, impl->props.volume);
spa_pod_builder_pop(&b); spa_pod_builder_pop(&b);
spa_pod_builder_pop(&b);
impl->props.changed = false; impl->props.changed = false;
} }
spa_pod_builder_pop(&b); spa_pod_builder_pop(&b);
@ -1004,14 +1004,16 @@ static void add_controls(struct pw_stream *stream)
add_param(stream, PARAM_TYPE_INIT, add_param(stream, PARAM_TYPE_INIT,
spa_pod_builder_object(&b, spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamIO, SPA_PARAM_IO, SPA_TYPE_OBJECT_ParamIO, SPA_PARAM_IO,
":", SPA_PARAM_IO_id, "I", SPA_IO_Notify, SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Notify),
":", SPA_PARAM_IO_size, "i", sizeof(struct spa_io_sequence) + 1024)); SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_sequence) + 1024),
0));
add_param(stream, PARAM_TYPE_INIT, add_param(stream, PARAM_TYPE_INIT,
spa_pod_builder_object(&b, spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_ParamIO, SPA_PARAM_IO, SPA_TYPE_OBJECT_ParamIO, SPA_PARAM_IO,
":", SPA_PARAM_IO_id, "I", SPA_IO_Control, SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Control),
":", SPA_PARAM_IO_size, "i", sizeof(struct spa_io_sequence))); SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_sequence)),
0));
} }
int int