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

@ -339,7 +339,7 @@ static const struct spa_dbus_methods impl_dbus = {
.get_connection = impl_get_connection,
};
static int impl_get_interface(struct spa_handle *handle, uint32_t type, void **interface)
static int impl_get_interface(struct spa_handle *handle, const char *type, void **interface)
{
struct impl *this;
@ -348,7 +348,7 @@ static int impl_get_interface(struct spa_handle *handle, uint32_t type, void **i
this = (struct impl *) handle;
if (type == SPA_TYPE_INTERFACE_DBus)
if (strcmp(type, SPA_TYPE_INTERFACE_DBus) == 0)
*interface = &this->dbus;
else
return -ENOENT;
@ -377,7 +377,6 @@ impl_init(const struct spa_handle_factory *factory,
uint32_t n_support)
{
struct impl *this;
uint32_t i;
spa_return_val_if_fail(factory != NULL, -EINVAL);
spa_return_val_if_fail(handle != NULL, -EINVAL);
@ -393,16 +392,9 @@ impl_init(const struct spa_handle_factory *factory,
SPA_VERSION_DBUS,
&impl_dbus, this);
for (i = 0; i < n_support; i++) {
switch (support[i].type) {
case SPA_TYPE_INTERFACE_Log:
this->log = support[i].data;
break;
case SPA_TYPE_INTERFACE_LoopUtils:
this->utils = support[i].data;
break;
}
}
this->log = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_Log);
this->utils = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_LoopUtils);
if (this->utils == NULL) {
spa_log_error(this->log, "a LoopUtils is needed");
return -EINVAL;