mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-10 13:30:05 -05:00
debug: allow custom type root
This commit is contained in:
parent
05d3502c84
commit
7cdb980b1a
32 changed files with 102 additions and 83 deletions
|
|
@ -122,6 +122,9 @@ static inline int spa_debug_format(int indent,
|
|||
[SPA_TYPE_Pod] = "pod"
|
||||
};
|
||||
|
||||
if (info == NULL)
|
||||
info = spa_type_format;
|
||||
|
||||
if (format == NULL || SPA_POD_TYPE(format) != SPA_TYPE_Object)
|
||||
return -EINVAL;
|
||||
|
||||
|
|
@ -135,8 +138,6 @@ static inline int spa_debug_format(int indent,
|
|||
media_type ? rindex(media_type, ':') + 1 : "unknown",
|
||||
media_subtype ? rindex(media_subtype, ':') + 1 : "unknown");
|
||||
|
||||
info = spa_type_format;
|
||||
|
||||
SPA_POD_OBJECT_FOREACH((struct spa_pod_object*)format, pod) {
|
||||
struct spa_pod_prop *prop;
|
||||
const char *key;
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ spa_debug_pod_value(int indent, const struct spa_type_info *info,
|
|||
{
|
||||
struct spa_pod_pointer_body *b = body;
|
||||
spa_debug("%*s" "Pointer %s %p", indent, "",
|
||||
spa_debug_type_find_name(spa_types, b->type), b->value);
|
||||
spa_debug_type_find_name(SPA_TYPE_ROOT, b->type), b->value);
|
||||
break;
|
||||
}
|
||||
case SPA_TYPE_Rectangle:
|
||||
|
|
@ -140,9 +140,9 @@ spa_debug_pod_value(int indent, const struct spa_type_info *info,
|
|||
ti ? ti->name : "unknown");
|
||||
|
||||
SPA_POD_SEQUENCE_BODY_FOREACH(b, size, c) {
|
||||
ii = spa_debug_type_find(info, c->type);
|
||||
ii = spa_debug_type_find(spa_type_control, c->type);
|
||||
|
||||
spa_debug("%*s" "Event: offset %d, type %s", indent+2, "",
|
||||
spa_debug("%*s" "Control: offset %d, type %s", indent+2, "",
|
||||
c->offset, ii ? ii->name : "unknown");
|
||||
|
||||
spa_debug_pod_value(indent + 2, info,
|
||||
|
|
@ -234,7 +234,7 @@ spa_debug_pod_value(int indent, const struct spa_type_info *info,
|
|||
static inline int spa_debug_pod(int indent,
|
||||
const struct spa_type_info *info, const struct spa_pod *pod)
|
||||
{
|
||||
return spa_debug_pod_value(indent, info,
|
||||
return spa_debug_pod_value(indent, info ? info : SPA_TYPE_ROOT,
|
||||
SPA_POD_TYPE(pod),
|
||||
SPA_POD_BODY(pod),
|
||||
SPA_POD_BODY_SIZE(pod));
|
||||
|
|
|
|||
|
|
@ -26,21 +26,19 @@ extern "C" {
|
|||
|
||||
#include <spa/utils/type-info.h>
|
||||
|
||||
static const struct spa_type_info spa_debug_types[] =
|
||||
{
|
||||
{ SPA_ID_INVALID, "", SPA_TYPE_Enum, spa_types },
|
||||
{ 0, NULL, },
|
||||
};
|
||||
|
||||
static inline const struct spa_type_info *spa_debug_type_find(const struct spa_type_info *info, uint32_t type)
|
||||
{
|
||||
const struct spa_type_info *res;
|
||||
|
||||
if (info == NULL)
|
||||
info = SPA_TYPE_ROOT;
|
||||
|
||||
while (info && info->name) {
|
||||
if (info->type == SPA_ID_INVALID)
|
||||
if ((res = spa_debug_type_find(info->values, type)))
|
||||
if (info->type == SPA_ID_INVALID) {
|
||||
if (info->values && (res = spa_debug_type_find(info->values, type)))
|
||||
return res;
|
||||
if (info->type == type)
|
||||
}
|
||||
else if (info->type == type)
|
||||
return info;
|
||||
info++;
|
||||
}
|
||||
|
|
@ -56,11 +54,14 @@ static inline const char *spa_debug_type_find_name(const struct spa_type_info *i
|
|||
|
||||
static inline uint32_t spa_debug_type_find_type(const struct spa_type_info *info, const char *name)
|
||||
{
|
||||
if (info == NULL)
|
||||
info = SPA_TYPE_ROOT;
|
||||
|
||||
while (info && info->name) {
|
||||
uint32_t res;
|
||||
if (strcmp(info->name, name) == 0)
|
||||
return info->type;
|
||||
if ((res = spa_debug_type_find_type(info->values, name)) != SPA_ID_INVALID)
|
||||
if (info->values && (res = spa_debug_type_find_type(info->values, name)) != SPA_ID_INVALID)
|
||||
return res;
|
||||
info++;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue