mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -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
|
|
@ -2117,7 +2117,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
|
|||
return 1;
|
||||
}
|
||||
|
||||
static const struct spa_handle_factory spa_bluez5_monitor_factory = {
|
||||
const struct spa_handle_factory spa_bluez5_monitor_factory = {
|
||||
SPA_VERSION_MONITOR,
|
||||
NAME,
|
||||
NULL,
|
||||
|
|
@ -2125,11 +2125,3 @@ static const struct spa_handle_factory spa_bluez5_monitor_factory = {
|
|||
impl_init,
|
||||
impl_enum_interface_info,
|
||||
};
|
||||
|
||||
int spa_handle_factory_register(const struct spa_handle_factory *factory);
|
||||
|
||||
static void reg(void) __attribute__ ((constructor));
|
||||
static void reg(void)
|
||||
{
|
||||
spa_handle_factory_register(&spa_bluez5_monitor_factory);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
|
|||
return 1;
|
||||
}
|
||||
|
||||
static const struct spa_handle_factory cpu_factory = {
|
||||
const struct spa_handle_factory spa_support_cpu_factory = {
|
||||
SPA_VERSION_HANDLE_FACTORY,
|
||||
NAME,
|
||||
NULL,
|
||||
|
|
@ -200,11 +200,3 @@ static const struct spa_handle_factory cpu_factory = {
|
|||
impl_init,
|
||||
impl_enum_interface_info,
|
||||
};
|
||||
|
||||
int spa_handle_factory_register(const struct spa_handle_factory *factory);
|
||||
|
||||
static void reg(void) __attribute__ ((constructor));
|
||||
static void reg(void)
|
||||
{
|
||||
spa_handle_factory_register(&cpu_factory);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -277,7 +277,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
|
|||
return 1;
|
||||
}
|
||||
|
||||
static const struct spa_handle_factory logger_factory = {
|
||||
const struct spa_handle_factory spa_support_logger_factory = {
|
||||
SPA_VERSION_HANDLE_FACTORY,
|
||||
NAME,
|
||||
NULL,
|
||||
|
|
@ -285,11 +285,3 @@ static const struct spa_handle_factory logger_factory = {
|
|||
impl_init,
|
||||
impl_enum_interface_info,
|
||||
};
|
||||
|
||||
int spa_handle_factory_register(const struct spa_handle_factory *factory);
|
||||
|
||||
static void reg(void) __attribute__ ((constructor));
|
||||
static void reg(void)
|
||||
{
|
||||
spa_handle_factory_register(&logger_factory);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -775,7 +775,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
|
|||
return 1;
|
||||
}
|
||||
|
||||
static const struct spa_handle_factory loop_factory = {
|
||||
const struct spa_handle_factory spa_support_loop_factory = {
|
||||
SPA_VERSION_HANDLE_FACTORY,
|
||||
NAME,
|
||||
NULL,
|
||||
|
|
@ -783,11 +783,3 @@ static const struct spa_handle_factory loop_factory = {
|
|||
impl_init,
|
||||
impl_enum_interface_info
|
||||
};
|
||||
|
||||
int spa_handle_factory_register(const struct spa_handle_factory *factory);
|
||||
|
||||
static void reg(void) __attribute__ ((constructor));
|
||||
static void reg(void)
|
||||
{
|
||||
spa_handle_factory_register(&loop_factory);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,31 +27,29 @@
|
|||
|
||||
#include <spa/support/plugin.h>
|
||||
|
||||
#define MAX_FACTORIES 16
|
||||
extern const struct spa_handle_factory spa_support_logger_factory;
|
||||
extern const struct spa_handle_factory spa_support_loop_factory;
|
||||
extern const struct spa_handle_factory spa_support_cpu_factory;
|
||||
|
||||
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)
|
||||
factories[n_factories++] = factory;
|
||||
else {
|
||||
fprintf(stderr, "too many factories\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
SPA_EXPORT int
|
||||
spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t *index)
|
||||
{
|
||||
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_support_logger_factory;
|
||||
break;
|
||||
case 1:
|
||||
*factory = &spa_support_loop_factory;
|
||||
break;
|
||||
case 2:
|
||||
*factory = &spa_support_cpu_factory;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
|
||||
*factory = factories[(*index)++];
|
||||
}
|
||||
(*index)++;
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue