From 5cf84fa3fe0d0125c1bb20764096288d98199e87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Wed, 9 Jul 2025 18:19:25 +0200 Subject: [PATCH] spa: debug: pod: print custom properties with more detail Previously, custom object properties were printed as "unknown", and the offset (wrt. `SPA_PROP_START_CUSTOM`) was not displayed. A custom property is distinct from an "unknown" one. Being able to quickly differentiate the two is useful. Furthermore, knowing the custom property id (i.e. the actual numeric id minus `SPA_PROP_START_CUSTOM`) is also very helpful. To address the above, print a custom property (i.e. anything with an id at least `SPA_PROP_START_CUSTOM`) as follows: Spa:Pod:Object:Param:Props:Custom:123 where the last component is the custom property id. --- spa/include/spa/debug/pod.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/spa/include/spa/debug/pod.h b/spa/include/spa/debug/pod.h index bec620b48..21771691a 100644 --- a/spa/include/spa/debug/pod.h +++ b/spa/include/spa/debug/pod.h @@ -133,10 +133,21 @@ spa_debugc_pod_value(struct spa_debug_context *ctx, int indent, const struct spa info = ti ? ti->values : info; SPA_POD_OBJECT_BODY_FOREACH(b, size, p) { + static const char custom_prefix[] = SPA_TYPE_INFO_PROPS_BASE "Custom:"; + char custom_name[sizeof(custom_prefix) + 16]; + const char *name = "unknown"; + ii = spa_debug_type_find(info, p->key); + if (ii) { + name = ii->name; + } else if (p->key >= SPA_PROP_START_CUSTOM) { + snprintf(custom_name, sizeof(custom_name), + "%s%" PRIu32, custom_prefix, p->key - SPA_PROP_START_CUSTOM); + name = custom_name; + } spa_debugc(ctx, "%*s" "Prop: key %s (%" PRIu32 "), flags %08" PRIx32, - indent+2, "", ii ? ii->name : "unknown", p->key, p->flags); + indent+2, "", name, p->key, p->flags); spa_debugc_pod_value(ctx, indent + 4, ii ? ii->values : NULL, p->value.type,