Make interface types a string

This is more in line with wayland and it allows us to create new
interfaces in modules without having to add anything to the type
enum. It also removes some lookups to map type_id to readable
name in debug.
This commit is contained in:
Wim Taymans 2019-12-19 13:15:10 +01:00
parent 9657486a81
commit f391353c7f
123 changed files with 791 additions and 1251 deletions

View file

@ -34,6 +34,7 @@
#include <spa/node/node.h>
#include <spa/utils/hook.h>
#include <spa/utils/names.h>
#include <spa/utils/result.h>
#include <spa/param/audio/format-utils.h>
#include <spa/param/props.h>
#include <spa/debug/dict.h>
@ -116,7 +117,7 @@ static struct node *create_node(struct object *obj, uint32_t id,
pw_log_debug("new node %u", id);
if (info->type != SPA_TYPE_INTERFACE_Node)
if (strcmp(info->type, SPA_TYPE_INTERFACE_Node) != 0)
return NULL;
handle = pw_context_load_spa_handle(context,
@ -128,7 +129,7 @@ static struct node *create_node(struct object *obj, uint32_t id,
}
if ((res = spa_handle_get_interface(handle, info->type, &iface)) < 0) {
pw_log_error("can't get %d interface: %d", info->type, res);
pw_log_error("can't get %s interface: %s", info->type, spa_strerror(res));
goto unload_handle;
}
@ -225,7 +226,7 @@ static struct object *create_object(struct impl *impl, uint32_t id,
pw_log_debug("new object %u", id);
if (info->type != SPA_TYPE_INTERFACE_Device)
if (strcmp(info->type, SPA_TYPE_INTERFACE_Device) != 0)
return NULL;
handle = pw_context_load_spa_handle(context,
@ -237,7 +238,7 @@ static struct object *create_object(struct impl *impl, uint32_t id,
}
if ((res = spa_handle_get_interface(handle, info->type, &iface)) < 0) {
pw_log_error("can't get %d interface: %d", info->type, res);
pw_log_error("can't get %s interface: %s", info->type, spa_strerror(res));
goto unload_handle;
}