spa: support props flags building and parsing

Add an option to make a property with specific flags. Do this by
changing the parser and builder to see the invalid property as an escape
sequence followed by the property key and the flags.
This commit is contained in:
Wim Taymans 2025-09-12 16:54:04 +02:00
parent 41e6e875e5
commit 9df770eb16
3 changed files with 17 additions and 5 deletions

View file

@ -625,10 +625,14 @@ spa_pod_builder_addv(struct spa_pod_builder *builder, va_list args)
switch (ftype) {
case SPA_TYPE_Object:
{
uint32_t key = va_arg(args, uint32_t);
uint32_t key = va_arg(args, uint32_t), flags = 0;
if (key == 0)
goto exit;
spa_pod_builder_prop(builder, key, 0);
if (key == SPA_ID_INVALID) {
key = va_arg(args, uint32_t);
flags = va_arg(args, uint32_t);
}
spa_pod_builder_prop(builder, key, flags);
break;
}
case SPA_TYPE_Sequence:

View file

@ -800,13 +800,19 @@ SPA_API_POD_PARSER int spa_pod_parser_getv(struct spa_pod_parser *parser, va_lis
struct spa_pod_prop prop;
if (f->pod.type == SPA_TYPE_Object) {
uint32_t key = va_arg(args, uint32_t);
uint32_t key = va_arg(args, uint32_t), *flags = NULL;
if (key == 0)
break;
if (spa_pod_parser_object_find_prop(parser, key, &prop, &body) >= 0)
if (key == SPA_ID_INVALID) {
key = va_arg(args, uint32_t);
flags = va_arg(args, uint32_t*);
}
if (spa_pod_parser_object_find_prop(parser, key, &prop, &body) >= 0) {
pod = prop.value;
if (flags)
*flags = prop.flags;
}
}
if ((format = va_arg(args, char *)) == NULL)

View file

@ -20,6 +20,8 @@ extern "C" {
#define SPA_POD_Prop(key,...) \
key, ##__VA_ARGS__
#define SPA_POD_Propf(key,flags,...) \
SPA_ID_INVALID, key, flags, ##__VA_ARGS__
#define SPA_POD_Control(offset,type,...) \
offset, type, ##__VA_ARGS__