mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -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++;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,20 @@ extern "C" {
|
|||
#include <spa/node/event.h>
|
||||
#include <spa/node/io.h>
|
||||
|
||||
#define SPA_TYPE__IO SPA_TYPE_ENUM_BASE "IO"
|
||||
#define SPA_TYPE_IO_BASE SPA_TYPE__IO ":"
|
||||
|
||||
static const struct spa_type_info spa_type_io[] = {
|
||||
{ SPA_IO_Invalid, SPA_TYPE_IO_BASE "Invalid", SPA_TYPE_Int, },
|
||||
{ SPA_IO_Buffers, SPA_TYPE_IO_BASE "Buffers", SPA_TYPE_Int, },
|
||||
{ SPA_IO_Range, SPA_TYPE_IO_BASE "Range", SPA_TYPE_Int, },
|
||||
{ SPA_IO_Clock, SPA_TYPE_IO_BASE "Clock", SPA_TYPE_Int, },
|
||||
{ SPA_IO_Latency, SPA_TYPE_IO_BASE "Latency", SPA_TYPE_Int, },
|
||||
{ SPA_IO_Control, SPA_TYPE_IO_BASE "Control", SPA_TYPE_Int, },
|
||||
{ SPA_IO_Notify, SPA_TYPE_IO_BASE "Notify", SPA_TYPE_Int, },
|
||||
{ 0, NULL, },
|
||||
};
|
||||
|
||||
#define SPA_TYPE__NodeEvent SPA_TYPE_EVENT_BASE "Node"
|
||||
#define SPA_TYPE_NODE_EVENT_BASE SPA_TYPE__NodeEvent ":"
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ extern "C" {
|
|||
#include <spa/utils/type-info.h>
|
||||
#include <spa/param/props.h>
|
||||
#include <spa/param/format.h>
|
||||
#include <spa/node/io.h>
|
||||
|
||||
/* base for parameter object enumerations */
|
||||
#define SPA_TYPE__ParamId SPA_TYPE_ENUM_BASE "ParamId"
|
||||
|
|
@ -126,7 +127,7 @@ static const struct spa_type_info spa_type_param_meta[] = {
|
|||
|
||||
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_id, SPA_TYPE_PARAM_IO_BASE "id", SPA_TYPE_Enum, },
|
||||
{ SPA_PARAM_IO_id, SPA_TYPE_PARAM_IO_BASE "id", SPA_TYPE_Enum, spa_type_io },
|
||||
{ SPA_PARAM_IO_size, SPA_TYPE_PARAM_IO_BASE "size", SPA_TYPE_Int, },
|
||||
{ 0, NULL, },
|
||||
};
|
||||
|
|
|
|||
|
|
@ -26,6 +26,10 @@ extern "C" {
|
|||
|
||||
#include <spa/utils/defs.h>
|
||||
|
||||
#ifndef SPA_TYPE_ROOT
|
||||
#define SPA_TYPE_ROOT spa_types
|
||||
#endif
|
||||
|
||||
|
||||
static inline bool spa_type_is_a(const char *type, const char *parent)
|
||||
{
|
||||
|
|
@ -71,6 +75,7 @@ struct spa_type_info {
|
|||
#include <spa/monitor/type-info.h>
|
||||
#include <spa/node/type-info.h>
|
||||
#include <spa/param/type-info.h>
|
||||
#include <spa/control/type-info.h>
|
||||
|
||||
static const struct spa_type_info spa_types[] = {
|
||||
/* Basic types */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue