From 7e8fac22729899f86d2e72696d34854adefd3931 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 31 Oct 2018 16:05:58 +0000 Subject: [PATCH] type: restore type info for pipewire types --- src/pipewire/core.c | 2 +- src/pipewire/factory.c | 2 +- src/pipewire/global.c | 2 +- src/pipewire/pipewire.c | 19 +++++++++++++++++++ src/pipewire/private.h | 1 + src/pipewire/protocol.c | 2 +- src/pipewire/type.h | 2 ++ src/tools/pipewire-cli.c | 8 ++++---- src/tools/pipewire-monitor.c | 4 ++-- 9 files changed, 32 insertions(+), 10 deletions(-) diff --git a/src/pipewire/core.c b/src/pipewire/core.c index eeefd514d..678b7a60e 100644 --- a/src/pipewire/core.c +++ b/src/pipewire/core.c @@ -68,7 +68,7 @@ static void registry_bind(void *object, uint32_t id, goto wrong_interface; pw_log_debug("global %p: bind global id %d, iface %s to %d", global, id, - spa_debug_type_find_name(NULL, type), new_id); + spa_debug_type_find_name(pw_type_info(), type), new_id); if (pw_global_bind(global, client, permissions, version, new_id) < 0) goto exit; diff --git a/src/pipewire/factory.c b/src/pipewire/factory.c index cba492b97..2e8ad2f3b 100644 --- a/src/pipewire/factory.c +++ b/src/pipewire/factory.c @@ -147,7 +147,7 @@ int pw_factory_register(struct pw_factory *factory, pw_properties_set(properties, "factory.name", factory->info.name); pw_properties_setf(properties, "factory.type.name", "%s", - spa_debug_type_find_name(NULL, factory->info.type)); + spa_debug_type_find_name(pw_type_info(), factory->info.type)); pw_properties_setf(properties, "factory.type.version", "%d", factory->info.version); spa_list_append(&core->factory_list, &factory->link); diff --git a/src/pipewire/global.c b/src/pipewire/global.c index 11f509f1c..0110933ee 100644 --- a/src/pipewire/global.c +++ b/src/pipewire/global.c @@ -85,7 +85,7 @@ pw_global_new(struct pw_core *core, spa_hook_list_init(&this->listener_list); pw_log_debug("global %p: new %s %d", this, - spa_debug_type_find_name(NULL, this->type), + spa_debug_type_find_name(pw_type_info(), this->type), this->id); return this; diff --git a/src/pipewire/pipewire.c b/src/pipewire/pipewire.c index 50c031c56..8698e742e 100644 --- a/src/pipewire/pipewire.c +++ b/src/pipewire/pipewire.c @@ -594,3 +594,22 @@ const char* pw_get_library_version(void) { return pw_get_headers_version(); } + +static const struct spa_type_info type_info[] = { + { PW_TYPE_INTERFACE_Core, PW_TYPE_INTERFACE_BASE "Core", SPA_TYPE_Pointer, }, + { PW_TYPE_INTERFACE_Registry, PW_TYPE_INTERFACE_BASE "Registry", SPA_TYPE_Pointer, }, + { PW_TYPE_INTERFACE_Node, PW_TYPE_INTERFACE_BASE "Node", SPA_TYPE_Pointer, }, + { PW_TYPE_INTERFACE_Port, PW_TYPE_INTERFACE_BASE "Port", SPA_TYPE_Pointer, }, + { PW_TYPE_INTERFACE_Factory, PW_TYPE_INTERFACE_BASE "Factory", SPA_TYPE_Pointer, }, + { PW_TYPE_INTERFACE_Link, PW_TYPE_INTERFACE_BASE "Link", SPA_TYPE_Pointer, }, + { PW_TYPE_INTERFACE_Client, PW_TYPE_INTERFACE_BASE "Client", SPA_TYPE_Pointer, }, + { PW_TYPE_INTERFACE_Module, PW_TYPE_INTERFACE_BASE "Module", SPA_TYPE_Pointer, }, + { PW_TYPE_INTERFACE_ClientNode, PW_TYPE_INTERFACE_BASE "ClientNode", SPA_TYPE_Pointer, }, + { SPA_ID_INVALID, "spa_types", SPA_ID_INVALID, spa_types }, + { 0, NULL, }, +}; + +const struct spa_type_info * pw_type_info(void) +{ + return type_info; +} diff --git a/src/pipewire/private.h b/src/pipewire/private.h index 872a1afbf..0c9b83f29 100644 --- a/src/pipewire/private.h +++ b/src/pipewire/private.h @@ -37,6 +37,7 @@ extern "C" { #endif #include +#include struct pw_command; diff --git a/src/pipewire/protocol.c b/src/pipewire/protocol.c index 5a73a07a4..5703c0e95 100644 --- a/src/pipewire/protocol.c +++ b/src/pipewire/protocol.c @@ -129,7 +129,7 @@ pw_protocol_add_marshal(struct pw_protocol *protocol, spa_list_append(&protocol->marshal_list, &impl->link); pw_log_debug("Add marshal %d/%s:%d to protocol %s", marshal->type, - spa_debug_type_find_name(NULL, marshal->type), marshal->version, + spa_debug_type_find_name(pw_type_info(), marshal->type), marshal->version, protocol->name); return 0; diff --git a/src/pipewire/type.h b/src/pipewire/type.h index bc1b37b41..f46de7411 100644 --- a/src/pipewire/type.h +++ b/src/pipewire/type.h @@ -55,6 +55,8 @@ enum { #define PW_TYPE__Interface PW_TYPE_BASE "Interface" #define PW_TYPE_INTERFACE_BASE PW_TYPE__Interface ":" +const struct spa_type_info * pw_type_info(void); + #ifdef __cplusplus } #endif diff --git a/src/tools/pipewire-cli.c b/src/tools/pipewire-cli.c index 2b3926b8d..1c6838d6d 100644 --- a/src/tools/pipewire-cli.c +++ b/src/tools/pipewire-cli.c @@ -268,7 +268,7 @@ static int print_global(void *obj, void *data) return 0; fprintf(stdout, "\tid %d, parent %d, type %s/%d\n", global->id, global->parent_id, - spa_debug_type_find_name(NULL, global->type), + spa_debug_type_find_name(pw_type_info(), global->type), global->version); if (global->properties) print_properties(&global->properties->dict, ' ', false); @@ -503,7 +503,7 @@ static void info_global(struct proxy_data *pd) fprintf(stdout, "\tpermissions: %c%c%c\n", global->permissions & PW_PERM_R ? 'r' : '-', global->permissions & PW_PERM_W ? 'w' : '-', global->permissions & PW_PERM_X ? 'x' : '-'); - fprintf(stdout, "\ttype: %s/%d\n", spa_debug_type_find_name(NULL, global->type), pd->global->version); + fprintf(stdout, "\ttype: %s/%d\n", spa_debug_type_find_name(pw_type_info(), global->type), pd->global->version); } static void info_core(struct proxy_data *pd) @@ -568,7 +568,7 @@ static void info_factory(struct proxy_data *pd) info_global(pd); fprintf(stdout, "\tname: \"%s\"\n", info->name); - fprintf(stdout, "\tobject-type: %s/%d\n", spa_debug_type_find_name(NULL, info->type), info->version); + fprintf(stdout, "\tobject-type: %s/%d\n", spa_debug_type_find_name(pw_type_info(), info->type), info->version); print_properties(info->props, MARK_CHANGE(0), true); info->change_mask = 0; } @@ -856,7 +856,7 @@ static bool bind_global(struct remote_data *rd, struct global *global, char **er info_func = info_link; break; default: - asprintf(error, "unsupported type %s", spa_debug_type_find_name(NULL, global->type)); + asprintf(error, "unsupported type %s", spa_debug_type_find_name(pw_type_info(), global->type)); return false; } diff --git a/src/tools/pipewire-monitor.c b/src/tools/pipewire-monitor.c index 82dac1ca2..1feadd394 100644 --- a/src/tools/pipewire-monitor.c +++ b/src/tools/pipewire-monitor.c @@ -354,7 +354,7 @@ static void factory_event_info(void *object, struct pw_factory_info *info) data->permissions & PW_PERM_X ? 'x' : '-'); printf("\ttype: %s (version %d)\n", PW_TYPE_INTERFACE__Factory, data->version); printf("\tname: \"%s\"\n", info->name); - printf("\tobject-type: %s/%d\n", spa_debug_type_find_name(NULL, info->type), info->version); + printf("\tobject-type: %s/%d\n", spa_debug_type_find_name(pw_type_info(), info->type), info->version); if (print_all) { print_properties(info->props, MARK_CHANGE(0)); } @@ -517,7 +517,7 @@ static void registry_event_global(void *data, uint32_t id, uint32_t parent_id, printf("\tpermissions: %c%c%c\n", permissions & PW_PERM_R ? 'r' : '-', permissions & PW_PERM_W ? 'w' : '-', permissions & PW_PERM_X ? 'x' : '-'); - printf("\ttype: %s (version %d)\n", spa_debug_type_find_name(NULL, type), version); + printf("\ttype: %s (version %d)\n", spa_debug_type_find_name(pw_type_info(), type), version); print_properties(props, ' '); return; }