mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-01 22:58:50 -04:00
spa: don't use constructor attribute to register factories
This commit is contained in:
parent
30da60ab6b
commit
a563050797
7 changed files with 40 additions and 85 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue