mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-01 22:58:50 -04:00
pod: improve the vararg pod builder and parser
Automatically parse and build key/value when in objects without having to prefix the key with ":" Automatically build control/value when in sequence without the "." prefix. Remove the builder with key/pod, taking a reference to the stack built temporary pods is not allowed in c++. We can use the varargs version with the same convenient syntax. Remove the parser "*" option, it is unused. Improve spa_pod_builder_add_* and spa_pod_parser_get_* and make them look similar.
This commit is contained in:
parent
79d68ace68
commit
80cfda89c1
59 changed files with 1833 additions and 2005 deletions
|
|
@ -121,19 +121,17 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
if (*index > 0)
|
||||
return 0;
|
||||
|
||||
param = spa_pod_builder_object(&b,
|
||||
param = spa_pod_builder_add_object(&b,
|
||||
SPA_TYPE_OBJECT_ParamList, id,
|
||||
SPA_PARAM_LIST_id, &SPA_POD_Id(SPA_PARAM_Props),
|
||||
0);
|
||||
SPA_PARAM_LIST_id, SPA_POD_Id(SPA_PARAM_Props));
|
||||
break;
|
||||
case SPA_PARAM_Props:
|
||||
if (*index > 0)
|
||||
return 0;
|
||||
|
||||
param = spa_pod_builder_object(&b,
|
||||
param = spa_pod_builder_add_object(&b,
|
||||
SPA_TYPE_OBJECT_Props, id,
|
||||
SPA_PROP_live, &SPA_POD_Bool(this->props.live),
|
||||
0);
|
||||
SPA_PROP_live, SPA_POD_Bool(this->props.live));
|
||||
break;
|
||||
default:
|
||||
return -ENOENT;
|
||||
|
|
@ -167,8 +165,9 @@ static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flag
|
|||
reset_props(this, &this->props);
|
||||
return 0;
|
||||
}
|
||||
spa_pod_object_parse(param,
|
||||
":", SPA_PROP_live, "?b", &this->props.live, NULL);
|
||||
spa_pod_parse_object(param,
|
||||
SPA_TYPE_OBJECT_Props, NULL,
|
||||
SPA_PROP_live, "?b", &this->props.live);
|
||||
|
||||
if (this->props.live)
|
||||
this->info.flags |= SPA_PORT_INFO_FLAG_LIVE;
|
||||
|
|
@ -473,10 +472,9 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
SPA_PARAM_Meta };
|
||||
|
||||
if (*index < SPA_N_ELEMENTS(list))
|
||||
param = spa_pod_builder_object(&b,
|
||||
param = spa_pod_builder_add_object(&b,
|
||||
SPA_TYPE_OBJECT_ParamList, id,
|
||||
SPA_PARAM_LIST_id, &SPA_POD_Id(list[*index]),
|
||||
0);
|
||||
SPA_PARAM_LIST_id, SPA_POD_Id(list[*index]));
|
||||
else
|
||||
return 0;
|
||||
break;
|
||||
|
|
@ -493,23 +491,21 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
if (*index > 0)
|
||||
return 0;
|
||||
|
||||
param = spa_pod_builder_object(&b,
|
||||
param = spa_pod_builder_add_object(&b,
|
||||
SPA_TYPE_OBJECT_ParamBuffers, id,
|
||||
SPA_PARAM_BUFFERS_buffers, &SPA_POD_CHOICE_RANGE_Int(2, 1, 32),
|
||||
SPA_PARAM_BUFFERS_blocks, &SPA_POD_Int(1),
|
||||
SPA_PARAM_BUFFERS_size, &SPA_POD_Int(128),
|
||||
SPA_PARAM_BUFFERS_stride, &SPA_POD_Int(1),
|
||||
SPA_PARAM_BUFFERS_align, &SPA_POD_Int(16),
|
||||
0);
|
||||
SPA_PARAM_BUFFERS_buffers, SPA_POD_CHOICE_RANGE_Int(2, 1, 32),
|
||||
SPA_PARAM_BUFFERS_blocks, SPA_POD_Int(1),
|
||||
SPA_PARAM_BUFFERS_size, SPA_POD_Int(128),
|
||||
SPA_PARAM_BUFFERS_stride, SPA_POD_Int(1),
|
||||
SPA_PARAM_BUFFERS_align, SPA_POD_Int(16));
|
||||
break;
|
||||
case SPA_PARAM_Meta:
|
||||
switch (*index) {
|
||||
case 0:
|
||||
param = spa_pod_builder_object(&b,
|
||||
param = spa_pod_builder_add_object(&b,
|
||||
SPA_TYPE_OBJECT_ParamMeta, id,
|
||||
SPA_PARAM_META_type, &SPA_POD_Id(SPA_META_Header),
|
||||
SPA_PARAM_META_size, &SPA_POD_Int(sizeof(struct spa_meta_header)),
|
||||
0);
|
||||
SPA_PARAM_META_type, SPA_POD_Id(SPA_META_Header),
|
||||
SPA_PARAM_META_size, SPA_POD_Int(sizeof(struct spa_meta_header)));
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -126,10 +126,9 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
if (*index > 0)
|
||||
return 0;
|
||||
|
||||
param = spa_pod_builder_object(&b,
|
||||
param = spa_pod_builder_add_object(&b,
|
||||
SPA_TYPE_OBJECT_ParamList, id,
|
||||
SPA_PARAM_LIST_id, &SPA_POD_Id(SPA_PARAM_Props),
|
||||
0);
|
||||
SPA_PARAM_LIST_id, SPA_POD_Id(SPA_PARAM_Props));
|
||||
break;
|
||||
|
||||
case SPA_PARAM_Props:
|
||||
|
|
@ -139,11 +138,10 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
if (*index > 0)
|
||||
return 0;
|
||||
|
||||
param = spa_pod_builder_object(&b,
|
||||
param = spa_pod_builder_add_object(&b,
|
||||
SPA_TYPE_OBJECT_Props, id,
|
||||
SPA_PROP_live, &SPA_POD_Bool(p->live),
|
||||
SPA_PROP_patternType, &SPA_POD_CHOICE_ENUM_Id(2, p->pattern, p->pattern),
|
||||
0);
|
||||
SPA_PROP_live, SPA_POD_Bool(p->live),
|
||||
SPA_PROP_patternType, SPA_POD_CHOICE_ENUM_Id(2, p->pattern, p->pattern));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
@ -181,9 +179,10 @@ static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flag
|
|||
reset_props(this, p);
|
||||
return 0;
|
||||
}
|
||||
spa_pod_object_parse(param,
|
||||
":", SPA_PROP_live, "?b", &p->live,
|
||||
":", SPA_PROP_patternType, "?I", &p->pattern, NULL);
|
||||
spa_pod_parse_object(param,
|
||||
SPA_TYPE_OBJECT_Props, NULL,
|
||||
SPA_PROP_live, SPA_POD_OPT_Bool(&p->live),
|
||||
SPA_PROP_patternType, SPA_POD_OPT_Id(&p->pattern));
|
||||
|
||||
if (p->live)
|
||||
this->info.flags |= SPA_PORT_INFO_FLAG_LIVE;
|
||||
|
|
@ -488,10 +487,9 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
SPA_PARAM_Meta };
|
||||
|
||||
if (*index < SPA_N_ELEMENTS(list))
|
||||
param = spa_pod_builder_object(&b,
|
||||
param = spa_pod_builder_add_object(&b,
|
||||
SPA_TYPE_OBJECT_ParamList, id,
|
||||
SPA_PARAM_LIST_id, &SPA_POD_Id(list[*index]),
|
||||
0);
|
||||
SPA_PARAM_LIST_id, SPA_POD_Id(list[*index]));
|
||||
else
|
||||
return 0;
|
||||
break;
|
||||
|
|
@ -508,23 +506,21 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
if (*index > 0)
|
||||
return 0;
|
||||
|
||||
param = spa_pod_builder_object(&b,
|
||||
param = spa_pod_builder_add_object(&b,
|
||||
SPA_TYPE_OBJECT_ParamBuffers, id,
|
||||
SPA_PARAM_BUFFERS_buffers, &SPA_POD_CHOICE_RANGE_Int(32, 2, 32),
|
||||
SPA_PARAM_BUFFERS_blocks, &SPA_POD_Int(1),
|
||||
SPA_PARAM_BUFFERS_size, &SPA_POD_Int(128),
|
||||
SPA_PARAM_BUFFERS_stride, &SPA_POD_Int(1),
|
||||
SPA_PARAM_BUFFERS_align, &SPA_POD_Int(16),
|
||||
0);
|
||||
SPA_PARAM_BUFFERS_buffers, SPA_POD_CHOICE_RANGE_Int(32, 2, 32),
|
||||
SPA_PARAM_BUFFERS_blocks, SPA_POD_Int(1),
|
||||
SPA_PARAM_BUFFERS_size, SPA_POD_Int(128),
|
||||
SPA_PARAM_BUFFERS_stride, SPA_POD_Int(1),
|
||||
SPA_PARAM_BUFFERS_align, SPA_POD_Int(16));
|
||||
break;
|
||||
case SPA_PARAM_Meta:
|
||||
switch (*index) {
|
||||
case 0:
|
||||
param = spa_pod_builder_object(&b,
|
||||
param = spa_pod_builder_add_object(&b,
|
||||
SPA_TYPE_OBJECT_ParamMeta, id,
|
||||
SPA_PARAM_META_type, &SPA_POD_Id(SPA_META_Header),
|
||||
SPA_PARAM_META_size, &SPA_POD_Int(sizeof(struct spa_meta_header)),
|
||||
0);
|
||||
SPA_PARAM_META_type, SPA_POD_Id(SPA_META_Header),
|
||||
SPA_PARAM_META_size, SPA_POD_Int(sizeof(struct spa_meta_header)));
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue