mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-06 13:30:01 -05:00
spa: don't use constructor attribute to register factories
This commit is contained in:
parent
e4cac644d2
commit
703309f6cd
7 changed files with 39 additions and 84 deletions
|
|
@ -22,21 +22,7 @@
|
|||
|
||||
#include <spa/support/plugin.h>
|
||||
|
||||
#define MAX_FACTORIES 16
|
||||
|
||||
static const struct spa_handle_factory *factories[MAX_FACTORIES];
|
||||
static int 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)
|
||||
|
|
@ -44,10 +30,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