spa: don't use constructor attribute to register factories

This commit is contained in:
Wim Taymans 2019-02-06 11:38:12 +01:00
parent 30da60ab6b
commit a563050797
7 changed files with 40 additions and 85 deletions

View file

@ -27,21 +27,7 @@
#include <spa/support/plugin.h>
#define MAX_FACTORIES 16
static const struct spa_handle_factory *factories[MAX_FACTORIES];
static uint32_t n_factories;
int spa_handle_factory_register(const struct spa_handle_factory *factory)
{
if (n_factories >= MAX_FACTORIES) {
fprintf(stderr, "too many factories\n");
return -ENOMEM;
}
factories[n_factories++] = factory;
return 0;
}
extern const struct spa_handle_factory spa_bluez5_monitor_factory;
int
spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t *index)
@ -49,10 +35,13 @@ spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t *ind
spa_return_val_if_fail(factory != NULL, -EINVAL);
spa_return_val_if_fail(index != NULL, -EINVAL);
if (*index >= n_factories)
switch (*index) {
case 0:
*factory = &spa_bluez5_monitor_factory;
break;
default:
return 0;
*factory = factories[(*index)++];
}
(*index)++;
return 1;
}