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 */
|
||||
|
|
|
|||
|
|
@ -163,12 +163,12 @@ static int debug_params(struct impl *this, struct spa_node *node,
|
|||
if (res <= 0)
|
||||
break;
|
||||
|
||||
spa_debug_pod(2, spa_debug_types, param);
|
||||
spa_debug_pod(2, NULL, param);
|
||||
}
|
||||
|
||||
spa_log_error(this->log, "failed filter:");
|
||||
if (filter)
|
||||
spa_debug_pod(2, spa_debug_types, filter);
|
||||
spa_debug_pod(2, NULL, filter);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ struct data {
|
|||
|
||||
static void inspect_item(struct data *data, struct spa_pod *item)
|
||||
{
|
||||
spa_debug_pod(0, spa_debug_types, item);
|
||||
spa_debug_pod(0, NULL, item);
|
||||
}
|
||||
|
||||
static void monitor_event(void *_data, struct spa_event *event)
|
||||
|
|
|
|||
|
|
@ -208,7 +208,7 @@ static void update_props(struct data *data)
|
|||
#endif
|
||||
#if 0
|
||||
spa_pod_builder_push_sequence(&b, 0);
|
||||
spa_pod_builder_event_header(&b, 0, SPA_CONTROL_properties);
|
||||
spa_pod_builder_control_header(&b, 0, SPA_CONTROL_Properties);
|
||||
spa_pod_builder_push_object(&b, SPA_TYPE_OBJECT_Props, 0);
|
||||
spa_pod_builder_push_prop(&b, SPA_PROP_frequency, 0);
|
||||
spa_pod_builder_double(&b, ((sin(data->freq_accum) + 1.0) * 200.0) + 440.0);
|
||||
|
|
@ -221,7 +221,7 @@ static void update_props(struct data *data)
|
|||
#endif
|
||||
#if 0
|
||||
spa_pod_builder_push_sequence(&b, 0);
|
||||
spa_pod_builder_event_header(&b, 0, SPA_CONTROL_properties);
|
||||
spa_pod_builder_control_header(&b, 0, SPA_CONTROL_Properties);
|
||||
spa_pod_builder_object(&b,
|
||||
SPA_TYPE_OBJECT_Props, 0,
|
||||
":", SPA_PROP_frequency, "d", ((sin(data->freq_accum) + 1.0) * 200.0) + 440.0,
|
||||
|
|
@ -229,7 +229,7 @@ static void update_props(struct data *data)
|
|||
pod = spa_pod_builder_pop(&b);
|
||||
#endif
|
||||
|
||||
spa_debug_pod(0, spa_types, pod);
|
||||
spa_debug_pod(0, NULL, pod);
|
||||
|
||||
data->freq_accum += M_PI_M2 / 880.0;
|
||||
if (data->freq_accum >= M_PI_M2)
|
||||
|
|
@ -314,7 +314,7 @@ static int make_nodes(struct data *data, const char *device)
|
|||
":", SPA_PROP_device, "s", device ? device : "hw:0",
|
||||
":", SPA_PROP_minLatency, "i", MIN_LATENCY);
|
||||
|
||||
spa_debug_pod(0, spa_debug_types, props);
|
||||
spa_debug_pod(0, NULL, props);
|
||||
|
||||
if ((res = spa_node_set_param(data->sink, SPA_PARAM_Props, 0, props)) < 0)
|
||||
printf("got set_props error %d\n", res);
|
||||
|
|
@ -386,7 +386,7 @@ static int negotiate_formats(struct data *data)
|
|||
.rate = 44100,
|
||||
.channels = 2 ));
|
||||
|
||||
spa_debug_pod(0, spa_debug_types, filter);
|
||||
spa_debug_pod(0, NULL, filter);
|
||||
|
||||
spa_log_debug(&default_log.log, "enum_params");
|
||||
if ((res = spa_node_port_enum_params(data->sink,
|
||||
|
|
@ -395,7 +395,7 @@ static int negotiate_formats(struct data *data)
|
|||
filter, &format, &b)) <= 0)
|
||||
return -EBADF;
|
||||
|
||||
spa_debug_pod(0, spa_debug_types, format);
|
||||
spa_debug_pod(0, NULL, format);
|
||||
|
||||
spa_log_debug(&default_log.log, "sink set_param");
|
||||
if ((res = spa_node_port_set_param(data->sink,
|
||||
|
|
|
|||
|
|
@ -267,7 +267,7 @@ static int negotiate_buffers(struct data *data)
|
|||
NULL, ¶m, &b)) <= 0)
|
||||
return -EBADF;
|
||||
|
||||
spa_debug_pod(0, spa_debug_types, param);
|
||||
spa_debug_pod(0, NULL, param);
|
||||
|
||||
init_buffer(data, data->in_buffers, data->in_buffer, 1, BUFFER_SIZE, 1);
|
||||
if ((res =
|
||||
|
|
@ -284,7 +284,7 @@ static int negotiate_buffers(struct data *data)
|
|||
NULL, ¶m, &b)) <= 0)
|
||||
return -EBADF;
|
||||
|
||||
spa_debug_pod(0, spa_debug_types, param);
|
||||
spa_debug_pod(0, NULL, param);
|
||||
|
||||
init_buffer(data, data->out_buffers, data->out_buffer, 1, BUFFER_SIZE, 2);
|
||||
if ((res =
|
||||
|
|
|
|||
|
|
@ -320,7 +320,7 @@ static int negotiate_link_buffers(struct data *data, struct link *link)
|
|||
}
|
||||
|
||||
spa_pod_fixate(param);
|
||||
spa_debug_pod(0, spa_debug_types, param);
|
||||
spa_debug_pod(0, NULL, param);
|
||||
|
||||
if (link->in_info)
|
||||
in_alloc = SPA_FLAG_CHECK(link->in_info->flags, SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS);
|
||||
|
|
|
|||
|
|
@ -261,7 +261,7 @@ static int make_nodes(struct data *data, const char *device)
|
|||
":", SPA_PROP_device, "s", device ? device : "hw:0",
|
||||
":", SPA_PROP_minLatency, "i", MIN_LATENCY);
|
||||
|
||||
spa_debug_pod(0, spa_debug_types, props);
|
||||
spa_debug_pod(0, NULL, props);
|
||||
|
||||
if ((res = spa_node_set_param(data->sink, SPA_PARAM_Props, 0, props)) < 0)
|
||||
printf("got set_props error %d\n", res);
|
||||
|
|
@ -353,7 +353,7 @@ static int negotiate_formats(struct data *data)
|
|||
.rate = 44100,
|
||||
.channels = 2 ));
|
||||
|
||||
spa_debug_pod(0, spa_debug_types, filter);
|
||||
spa_debug_pod(0, NULL, filter);
|
||||
|
||||
spa_log_debug(&default_log.log, "enum_params");
|
||||
if ((res = spa_node_port_enum_params(data->sink,
|
||||
|
|
@ -362,7 +362,7 @@ static int negotiate_formats(struct data *data)
|
|||
filter, &format, &b)) <= 0)
|
||||
return -EBADF;
|
||||
|
||||
spa_debug_pod(0, spa_debug_types, format);
|
||||
spa_debug_pod(0, NULL, format);
|
||||
|
||||
spa_log_debug(&default_log.log, "sink set_param");
|
||||
if ((res = spa_node_port_set_param(data->sink,
|
||||
|
|
|
|||
|
|
@ -231,7 +231,7 @@ static void do_static_struct(void)
|
|||
}
|
||||
};
|
||||
|
||||
spa_debug_pod(0, spa_debug_types, &test_format.fmt.pod);
|
||||
spa_debug_pod(0, NULL, &test_format.fmt.pod);
|
||||
spa_debug_format(0, NULL, &test_format.fmt.pod);
|
||||
|
||||
{
|
||||
|
|
@ -294,7 +294,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
fmt = spa_pod_builder_pop(&b);
|
||||
|
||||
spa_debug_pod(0, spa_debug_types, &fmt->pod);
|
||||
spa_debug_pod(0, NULL, &fmt->pod);
|
||||
|
||||
spa_pod_builder_init(&b, buffer, sizeof(buffer));
|
||||
|
||||
|
|
@ -312,7 +312,7 @@ int main(int argc, char *argv[])
|
|||
2, &SPA_FRACTION(0,1),
|
||||
&SPA_FRACTION(INT32_MAX,1));
|
||||
|
||||
spa_debug_pod(0, spa_debug_types, &fmt->pod);
|
||||
spa_debug_pod(0, NULL, &fmt->pod);
|
||||
spa_debug_format(0, NULL, &fmt->pod);
|
||||
|
||||
spa_pod_builder_init(&b, buffer, sizeof(buffer));
|
||||
|
|
@ -342,7 +342,7 @@ int main(int argc, char *argv[])
|
|||
&SPA_FRACTION(INT32_MAX,1),
|
||||
"}", NULL);
|
||||
|
||||
spa_debug_pod(0, spa_debug_types, &fmt->pod);
|
||||
spa_debug_pod(0, NULL, &fmt->pod);
|
||||
spa_debug_format(0, NULL, &fmt->pod);
|
||||
|
||||
do_static_struct();
|
||||
|
|
|
|||
|
|
@ -81,11 +81,11 @@ int main(int argc, char *argv[])
|
|||
spa_pod_builder_pop(&b);
|
||||
obj = spa_pod_builder_pop(&b);
|
||||
|
||||
spa_debug_pod(0, spa_debug_types, obj);
|
||||
spa_debug_pod(0, NULL, obj);
|
||||
|
||||
struct spa_pod_prop *p = spa_pod_find_prop(obj, 4);
|
||||
printf("%d %d\n", p->body.key, p->body.flags);
|
||||
spa_debug_pod(0, spa_debug_types, &p->body.value);
|
||||
spa_debug_pod(0, NULL, &p->body.value);
|
||||
|
||||
obj = spa_pod_builder_deref(&b, ref);
|
||||
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ inspect_node_params(struct data *data, struct spa_node *node)
|
|||
":", SPA_PARAM_LIST_id, "I", &id,
|
||||
NULL);
|
||||
|
||||
printf("enumerating: %s:\n", spa_debug_type_find_name(spa_debug_types, id));
|
||||
printf("enumerating: %s:\n", spa_debug_type_find_name(NULL, id));
|
||||
for (idx2 = 0;;) {
|
||||
spa_pod_builder_init(&b, buffer, sizeof(buffer));
|
||||
if ((res = spa_node_enum_params(node,
|
||||
|
|
@ -79,7 +79,7 @@ inspect_node_params(struct data *data, struct spa_node *node)
|
|||
error(0, -res, "enum_params %d", id);
|
||||
break;
|
||||
}
|
||||
spa_debug_pod(0, spa_debug_types, param);
|
||||
spa_debug_pod(0, NULL, param);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -110,7 +110,7 @@ inspect_port_params(struct data *data, struct spa_node *node,
|
|||
":", SPA_PARAM_LIST_id, "I", &id,
|
||||
NULL);
|
||||
|
||||
printf("enumerating: %s:\n", spa_debug_type_find_name(spa_debug_types, id));
|
||||
printf("enumerating: %s:\n", spa_debug_type_find_name(NULL, id));
|
||||
for (idx2 = 0;;) {
|
||||
spa_pod_builder_init(&b, buffer, sizeof(buffer));
|
||||
if ((res = spa_node_port_enum_params(node,
|
||||
|
|
@ -125,7 +125,7 @@ inspect_port_params(struct data *data, struct spa_node *node,
|
|||
if (spa_pod_is_object_id(param, SPA_TYPE_OBJECT_Format))
|
||||
spa_debug_format(0, NULL, param);
|
||||
else
|
||||
spa_debug_pod(0, spa_debug_types, param);
|
||||
spa_debug_pod(0, NULL, param);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ struct data {
|
|||
|
||||
static void inspect_item(struct data *data, struct spa_pod *item)
|
||||
{
|
||||
spa_debug_pod(0, spa_types, item);
|
||||
spa_debug_pod(0, NULL, item);
|
||||
}
|
||||
|
||||
static void on_monitor_event(void *_data, struct spa_event *event)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue