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
|
|
@ -1252,7 +1252,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct spa_handle_factory spa_bluez5_monitor_factory = {
|
const struct spa_handle_factory spa_bluez5_monitor_factory = {
|
||||||
SPA_VERSION_MONITOR,
|
SPA_VERSION_MONITOR,
|
||||||
NAME,
|
NAME,
|
||||||
NULL,
|
NULL,
|
||||||
|
|
@ -1260,11 +1260,3 @@ static const struct spa_handle_factory spa_bluez5_monitor_factory = {
|
||||||
impl_init,
|
impl_init,
|
||||||
impl_enum_interface_info,
|
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);
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -22,21 +22,7 @@
|
||||||
|
|
||||||
#include <spa/support/plugin.h>
|
#include <spa/support/plugin.h>
|
||||||
|
|
||||||
#define MAX_FACTORIES 16
|
extern const struct spa_handle_factory spa_bluez5_monitor_factory;
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t *index)
|
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(factory != NULL, -EINVAL);
|
||||||
spa_return_val_if_fail(index != 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;
|
return 0;
|
||||||
|
}
|
||||||
*factory = factories[(*index)++];
|
(*index)++;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -255,7 +255,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct spa_handle_factory logger_factory = {
|
const struct spa_handle_factory spa_support_logger_factory = {
|
||||||
SPA_VERSION_HANDLE_FACTORY,
|
SPA_VERSION_HANDLE_FACTORY,
|
||||||
NAME,
|
NAME,
|
||||||
NULL,
|
NULL,
|
||||||
|
|
@ -263,11 +263,3 @@ static const struct spa_handle_factory logger_factory = {
|
||||||
impl_init,
|
impl_init,
|
||||||
impl_enum_interface_info,
|
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);
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -776,7 +776,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct spa_handle_factory loop_factory = {
|
const struct spa_handle_factory spa_support_loop_factory = {
|
||||||
SPA_VERSION_HANDLE_FACTORY,
|
SPA_VERSION_HANDLE_FACTORY,
|
||||||
NAME,
|
NAME,
|
||||||
NULL,
|
NULL,
|
||||||
|
|
@ -784,11 +784,3 @@ static const struct spa_handle_factory loop_factory = {
|
||||||
impl_init,
|
impl_init,
|
||||||
impl_enum_interface_info
|
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);
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -202,7 +202,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct spa_handle_factory type_map_factory = {
|
const struct spa_handle_factory spa_support_type_map_factory = {
|
||||||
SPA_VERSION_HANDLE_FACTORY,
|
SPA_VERSION_HANDLE_FACTORY,
|
||||||
NAME,
|
NAME,
|
||||||
NULL,
|
NULL,
|
||||||
|
|
@ -210,11 +210,3 @@ static const struct spa_handle_factory type_map_factory = {
|
||||||
impl_init,
|
impl_init,
|
||||||
impl_enum_interface_info,
|
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(&type_map_factory);
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -4,17 +4,17 @@ spa_support_sources = ['mapper.c',
|
||||||
'plugin.c']
|
'plugin.c']
|
||||||
|
|
||||||
spa_support_lib = shared_library('spa-support',
|
spa_support_lib = shared_library('spa-support',
|
||||||
spa_support_sources,
|
spa_support_sources,
|
||||||
include_directories : [ spa_inc],
|
include_directories : [ spa_inc],
|
||||||
dependencies : threads_dep,
|
dependencies : threads_dep,
|
||||||
install : true,
|
install : true,
|
||||||
install_dir : '@0@/spa/support'.format(get_option('libdir')))
|
install_dir : '@0@/spa/support'.format(get_option('libdir')))
|
||||||
|
|
||||||
spa_dbus_sources = ['dbus.c']
|
spa_dbus_sources = ['dbus.c']
|
||||||
|
|
||||||
spa_dbus_lib = shared_library('spa-dbus',
|
spa_dbus_lib = shared_library('spa-dbus',
|
||||||
spa_dbus_sources,
|
spa_dbus_sources,
|
||||||
include_directories : [ spa_inc],
|
include_directories : [ spa_inc],
|
||||||
dependencies : dbus_dep,
|
dependencies : dbus_dep,
|
||||||
install : true,
|
install : true,
|
||||||
install_dir : '@0@/spa/support'.format(get_option('libdir')))
|
install_dir : '@0@/spa/support'.format(get_option('libdir')))
|
||||||
|
|
|
||||||
|
|
@ -22,31 +22,29 @@
|
||||||
|
|
||||||
#include <spa/support/plugin.h>
|
#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_type_map_factory;
|
||||||
|
|
||||||
static const struct spa_handle_factory *factories[MAX_FACTORIES];
|
SPA_EXPORT int
|
||||||
static int 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_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t *index)
|
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(factory != NULL, -EINVAL);
|
||||||
spa_return_val_if_fail(index != 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_type_map_factory;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
*factory = factories[(*index)++];
|
(*index)++;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue