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

@ -796,7 +796,7 @@ static const struct spa_node_methods impl_node = {
.process = impl_node_process,
};
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 seq_state *this;
@ -805,7 +805,7 @@ static int impl_get_interface(struct spa_handle *handle, uint32_t type, void **i
this = (struct seq_state *) handle;
if (type == SPA_TYPE_INTERFACE_Node)
if (strcmp(type, SPA_TYPE_INTERFACE_Node) == 0)
*interface = &this->node;
else
return -ENOENT;
@ -851,22 +851,11 @@ impl_init(const struct spa_handle_factory *factory,
this = (struct seq_state *) handle;
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_DataSystem:
this->data_system = support[i].data;
break;
case SPA_TYPE_INTERFACE_DataLoop:
this->data_loop = support[i].data;
break;
case SPA_TYPE_INTERFACE_Loop:
this->main_loop = support[i].data;
break;
}
}
this->log = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_Log);
this->data_system = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_DataSystem);
this->data_loop = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_DataLoop);
this->main_loop = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_Loop);
if (this->data_loop == NULL) {
spa_log_error(this->log, "a data loop is needed");
return -EINVAL;