System: More work on making system functions pluggable

Move the epoll functions to the system functions and make the loop
use those. Use simple mask for events instead of enum.
Add the used system api in pw_loop.
Add System API to spa_support and use it where possible.
Pass the system API used in the realtime loops in spa_support as
well and use this in the realtime paths.
Improve bootstrapping, load only the log and cpu interfaces because
those can/need to be shared between instances. Let the core load
the other interfaces.
Add keys to configure the System and Loop implementations used in
pw_loop.
This commit is contained in:
Wim Taymans 2019-06-06 15:21:40 +02:00
parent 86dc0496a5
commit db88e9f954
22 changed files with 455 additions and 342 deletions

View file

@ -28,8 +28,8 @@
#include <errno.h>
#include <unistd.h>
#include <time.h>
#include <sys/eventfd.h>
#include <spa/support/system.h>
#include <spa/node/node.h>
#include <spa/node/utils.h>
#include <spa/pod/filter.h>
@ -127,6 +127,7 @@ struct node {
struct spa_log *log;
struct spa_loop *data_loop;
struct spa_system *data_system;
struct spa_hook_list hooks;
struct spa_callbacks callbacks;
@ -978,15 +979,14 @@ static int impl_node_process(void *object)
struct impl *impl = this->impl;
struct pw_node *n = impl->this.node;
struct timespec ts;
uint64_t cmd = 1;
spa_log_trace_fp(this->log, "%p: send process %p", this, impl->this.node->driver_node);
clock_gettime(CLOCK_MONOTONIC, &ts);
spa_system_clock_gettime(this->data_system, CLOCK_MONOTONIC, &ts);
n->rt.activation->status = TRIGGERED;
n->rt.activation->signal_time = SPA_TIMESPEC_TO_NSEC(&ts);
if (write(this->writefd, &cmd, sizeof(cmd)) != sizeof(cmd))
if (spa_system_eventfd_write(this->data_system, this->writefd, 1) < 0)
spa_log_warn(this->log, "node %p: error %m", this);
return SPA_STATUS_OK;
@ -1118,7 +1118,8 @@ static void node_on_data_fd_events(struct spa_source *source)
if (source->rmask & SPA_IO_IN) {
uint64_t cmd;
if (read(this->data_source.fd, &cmd, sizeof(cmd)) != sizeof(cmd) || cmd != 1)
if (spa_system_eventfd_read(this->data_system,
this->data_source.fd, &cmd) < 0 || cmd != 1)
spa_log_warn(this->log, "node %p: read %"PRIu64" failed %m", this, cmd);
spa_log_trace_fp(this->log, "node %p: got ready", this);
@ -1162,7 +1163,8 @@ node_init(struct node *this,
case SPA_TYPE_INTERFACE_DataLoop:
this->data_loop = support[i].data;
break;
default:
case SPA_TYPE_INTERFACE_DataSystem:
this->data_system = support[i].data;
break;
}
}
@ -1170,6 +1172,10 @@ node_init(struct node *this,
spa_log_error(this->log, "a data-loop is needed");
return -EINVAL;
}
if (this->data_system == NULL) {
spa_log_error(this->log, "a data-system is needed");
return -EINVAL;
}
this->node.iface = SPA_INTERFACE_INIT(
SPA_TYPE_INTERFACE_Node,
@ -1292,13 +1298,14 @@ static void node_initialized(void *data)
struct pw_client_node *this = &impl->this;
struct pw_node *node = this->node;
struct pw_global *global;
struct spa_system *data_system = impl->node.data_system;
size_t size;
if (this->resource == NULL)
return;
impl->fds[0] = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
impl->fds[1] = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
impl->fds[0] = spa_system_eventfd_create(data_system, SPA_FD_CLOEXEC | SPA_FD_NONBLOCK);
impl->fds[1] = spa_system_eventfd_create(data_system, SPA_FD_CLOEXEC | SPA_FD_NONBLOCK);
impl->node.data_source.fd = impl->fds[0];
impl->node.writefd = impl->fds[1];
impl->other_fds[0] = impl->fds[1];
@ -1325,6 +1332,7 @@ static void node_initialized(void *data)
static void node_free(void *data)
{
struct impl *impl = data;
struct spa_system *data_system = impl->node.data_system;
pw_log_debug("client-node %p: free", &impl->this);
node_clear(&impl->node);
@ -1338,9 +1346,9 @@ static void node_free(void *data)
pw_map_clear(&impl->io_map);
if (impl->fds[0] != -1)
close(impl->fds[0]);
spa_system_close(data_system, impl->fds[0]);
if (impl->fds[1] != -1)
close(impl->fds[1]);
spa_system_close(data_system, impl->fds[1]);
free(impl);
}

View file

@ -194,7 +194,7 @@ client_busy_changed(void *data, bool busy)
{
struct client_data *c = data;
struct pw_client *client = c->client;
enum spa_io mask = SPA_IO_ERR | SPA_IO_HUP;
uint32_t mask = SPA_IO_ERR | SPA_IO_HUP;
c->busy = busy;
@ -210,7 +210,7 @@ client_busy_changed(void *data, bool busy)
}
static void
connection_data(void *data, int fd, enum spa_io mask)
connection_data(void *data, int fd, uint32_t mask)
{
struct client_data *this = data;
struct pw_client *client = this->client;
@ -370,7 +370,7 @@ static bool lock_socket(struct server *s)
}
static void
socket_data(void *data, int fd, enum spa_io mask)
socket_data(void *data, int fd, uint32_t mask)
{
struct server *s = data;
struct pw_client *client;
@ -467,7 +467,7 @@ static int impl_steal_fd(struct pw_protocol_client *client)
}
static void
on_remote_data(void *data, int fd, enum spa_io mask)
on_remote_data(void *data, int fd, uint32_t mask)
{
struct client *impl = data;
struct pw_remote *this = impl->this.remote;

View file

@ -445,7 +445,8 @@ struct pw_core *pw_core_new(struct pw_loop *main_loop,
struct pw_core *this;
const char *name;
void *dbus_iface = NULL;
int res;
uint32_t n_support;
int res = 0;
impl = calloc(1, sizeof(struct impl) + user_data_size);
if (impl == NULL)
@ -465,31 +466,33 @@ struct pw_core *pw_core_new(struct pw_loop *main_loop,
this->properties = properties;
this->data_loop_impl = pw_data_loop_new(properties);
this->data_loop_impl = pw_data_loop_new(pw_properties_copy(properties));
if (this->data_loop_impl == NULL)
goto no_data_loop;
this->data_loop = pw_data_loop_get_loop(this->data_loop_impl);
this->data_system = this->data_loop->system;
this->main_loop = main_loop;
pw_array_init(&this->factory_lib, 32);
pw_map_init(&this->globals, 128, 32);
this->support[0] = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_DataLoop, this->data_loop->loop);
this->support[1] = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_MainLoop, this->main_loop->loop);
this->support[2] = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_LoopUtils, this->main_loop->utils);
this->support[3] = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_Log, pw_log_get());
n_support = pw_get_support(this->support, SPA_N_ELEMENTS(this->support));
this->support[n_support++] = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_System, this->main_loop->system);
this->support[n_support++] = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_Loop, this->main_loop->loop);
this->support[n_support++] = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_LoopUtils, this->main_loop->utils);
this->support[n_support++] = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_DataSystem, this->data_system);
this->support[n_support++] = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_DataLoop, this->data_loop->loop);
impl->dbus_handle = pw_load_spa_handle("support/libspa-dbus", "dbus", NULL, 4, this->support);
if (impl->dbus_handle) {
if ((res = spa_handle_get_interface(impl->dbus_handle,
SPA_TYPE_INTERFACE_DBus, &dbus_iface)) < 0)
impl->dbus_handle = pw_load_spa_handle("support/libspa-dbus", "dbus", NULL, n_support, this->support);
if (impl->dbus_handle == NULL ||
(res = spa_handle_get_interface(impl->dbus_handle,
SPA_TYPE_INTERFACE_DBus, &dbus_iface)) < 0) {
pw_log_warn("can't load dbus interface: %s", spa_strerror(res));
} else {
this->support[n_support++] = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_DBus, dbus_iface);
}
this->support[4] = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_DBus, dbus_iface);
this->support[5] = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_CPU,
pw_get_support_interface(SPA_TYPE_INTERFACE_CPU));
this->n_support = 6;
this->n_support = n_support;
pw_data_loop_start(this->data_loop_impl);

View file

@ -61,6 +61,11 @@ extern "C" {
#define PW_KEY_SEC_GID "pipewire.sec.gid" /**< client gid, set by protocol*/
#define PW_KEY_SEC_LABEL "pipewire.sec.label" /**< client security label, set by protocol*/
#define PW_KEY_LOOP_LIBRARY_SYSTEM "loop.library.system" /**< name of the system library to use for
* a loop. */
#define PW_KEY_LOOP_LIBRARY_LOOP "loop.library.loop" /**< name of the loop library to use for a
* a loop. */
#define PW_KEY_CORE_MONITORS "core.monitors" /**< the apis monitored by core. */
/* remote keys */

View file

@ -38,7 +38,9 @@
struct impl {
struct pw_loop this;
struct spa_handle *handle;
struct spa_handle *system_handle;
struct spa_handle *loop_handle;
struct pw_properties *properties;
};
/** \endcond */
@ -52,63 +54,97 @@ struct pw_loop *pw_loop_new(struct pw_properties *properties)
int res;
struct impl *impl;
struct pw_loop *this;
const struct spa_handle_factory *factory;
void *iface;
const struct spa_support *support;
struct spa_support support[32];
uint32_t n_support;
const char *lib;
support = pw_get_support(&n_support);
if (support == NULL)
return NULL;
n_support = pw_get_support(support, 32);
factory = pw_get_support_factory("loop");
if (factory == NULL)
return NULL;
impl = calloc(1, sizeof(struct impl) + spa_handle_factory_get_size(factory, NULL));
impl = calloc(1, sizeof(struct impl));
if (impl == NULL)
return NULL;
impl->handle = SPA_MEMBER(impl, sizeof(struct impl), struct spa_handle);
this = &impl->this;
impl->properties = properties;
if ((res = spa_handle_factory_init(factory,
impl->handle,
NULL,
support,
n_support)) < 0) {
fprintf(stderr, "can't make factory instance: %d\n", res);
goto failed;
if (properties)
lib = pw_properties_get(properties, PW_KEY_LOOP_LIBRARY_SYSTEM);
else
lib = NULL;
impl->system_handle = pw_load_spa_handle(lib,
"system",
properties ? &properties->dict : NULL,
n_support, support);
if (impl->system_handle == NULL) {
pw_log_error("can't make system handle");
goto out_free;
}
if ((res = spa_handle_get_interface(impl->handle,
if ((res = spa_handle_get_interface(impl->system_handle,
SPA_TYPE_INTERFACE_System,
&iface)) < 0) {
fprintf(stderr, "can't get System interface %d\n", res);
goto out_free_system;
}
this->system = iface;
support[n_support++] = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_System, iface);
if (properties)
lib = pw_properties_get(properties, PW_KEY_LOOP_LIBRARY_LOOP);
else
lib = NULL;
impl->loop_handle = pw_load_spa_handle(lib,
"loop",
properties ? &properties->dict : NULL,
n_support, support);
if (impl->loop_handle == NULL) {
pw_log_error("can't make loop handle");
goto out_free_system;
}
if ((res = spa_handle_get_interface(impl->system_handle,
SPA_TYPE_INTERFACE_System,
&iface)) < 0) {
fprintf(stderr, "can't get System interface %d\n", res);
goto out_free_loop;
}
this->system = iface;
if ((res = spa_handle_get_interface(impl->loop_handle,
SPA_TYPE_INTERFACE_Loop,
&iface)) < 0) {
fprintf(stderr, "can't get Loop interface %d\n", res);
goto failed;
goto out_free_loop;
}
this->loop = iface;
if ((res = spa_handle_get_interface(impl->handle,
if ((res = spa_handle_get_interface(impl->loop_handle,
SPA_TYPE_INTERFACE_LoopControl,
&iface)) < 0) {
fprintf(stderr, "can't get LoopControl interface %d\n", res);
goto failed;
goto out_free_loop;
}
this->control = iface;
if ((res = spa_handle_get_interface(impl->handle,
if ((res = spa_handle_get_interface(impl->loop_handle,
SPA_TYPE_INTERFACE_LoopUtils,
&iface)) < 0) {
fprintf(stderr, "can't get LoopUtils interface %d\n", res);
goto failed;
goto out_free_loop;
}
this->utils = iface;
return this;
failed:
out_free_loop:
pw_unload_spa_handle(impl->loop_handle);
out_free_system:
pw_unload_spa_handle(impl->system_handle);
out_free:
free(impl);
return NULL;
}
@ -122,6 +158,9 @@ void pw_loop_destroy(struct pw_loop *loop)
{
struct impl *impl = SPA_CONTAINER_OF(loop, struct impl, this);
spa_handle_clear(impl->handle);
if (impl->properties)
pw_properties_free(impl->properties);
pw_unload_spa_handle(impl->loop_handle);
pw_unload_spa_handle(impl->system_handle);
free(impl);
}

View file

@ -30,6 +30,7 @@
#include <time.h>
#include <sys/eventfd.h>
#include <spa/support/system.h>
#include <spa/pod/parser.h>
#include <spa/node/utils.h>
#include <spa/debug/types.h>
@ -671,6 +672,7 @@ static inline int resume_node(struct pw_node *this, int status)
struct pw_node_target *t;
struct timespec ts;
struct pw_node_activation *activation = this->rt.activation;
struct spa_system *data_system = this->core->data_system;
uint64_t nsec;
if (status & SPA_STATUS_HAVE_BUFFER) {
@ -678,7 +680,7 @@ static inline int resume_node(struct pw_node *this, int status)
spa_node_process(p->mix);
}
clock_gettime(CLOCK_MONOTONIC, &ts);
spa_system_clock_gettime(data_system, CLOCK_MONOTONIC, &ts);
nsec = SPA_TIMESPEC_TO_NSEC(&ts);
activation->status = FINISHED;
activation->finish_time = nsec;
@ -708,11 +710,12 @@ static inline int process_node(void *data)
struct timespec ts;
struct pw_port *p;
struct pw_node_activation *a = this->rt.activation;
struct spa_system *data_system = this->core->data_system;
int status;
pw_log_trace_fp("node %p: process", this);
clock_gettime(CLOCK_MONOTONIC, &ts);
spa_system_clock_gettime(data_system, CLOCK_MONOTONIC, &ts);
a->status = AWAKE;
a->awake_time = SPA_TIMESPEC_TO_NSEC(&ts);
@ -723,7 +726,7 @@ static inline int process_node(void *data)
a->state[0].status = status;
if (this == this->driver_node && !this->exported) {
clock_gettime(CLOCK_MONOTONIC, &ts);
spa_system_clock_gettime(data_system, CLOCK_MONOTONIC, &ts);
a->status = FINISHED;
a->signal_time = a->finish_time;
a->finish_time = SPA_TIMESPEC_TO_NSEC(&ts);
@ -742,6 +745,7 @@ static inline int process_node(void *data)
static void node_on_fd_events(struct spa_source *source)
{
struct pw_node *this = source->data;
struct spa_system *data_system = this->core->data_system;
if (source->rmask & (SPA_IO_ERR | SPA_IO_HUP)) {
pw_log_warn("node %p: got socket error %08x", this, source->rmask);
@ -751,7 +755,7 @@ static void node_on_fd_events(struct spa_source *source)
if (source->rmask & SPA_IO_IN) {
uint64_t cmd;
if (read(this->source.fd, &cmd, sizeof(cmd)) != sizeof(cmd) || cmd != 1)
if (spa_system_eventfd_read(data_system, this->source.fd, &cmd) < 0 || cmd != 1)
pw_log_warn("node %p: read %"PRIu64" failed %m", this, cmd);
pw_log_trace_fp("node %p: got process", this);
@ -768,6 +772,7 @@ struct pw_node *pw_node_new(struct pw_core *core,
struct impl *impl;
struct pw_node *this;
size_t size;
struct spa_system *data_system = core->data_system;
char *n;
impl = calloc(1, sizeof(struct impl) + user_data_size);
@ -795,7 +800,7 @@ struct pw_node *pw_node_new(struct pw_core *core,
size = sizeof(struct pw_node_activation);
this->source.fd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
this->source.fd = spa_system_eventfd_create(data_system, SPA_FD_CLOEXEC | SPA_FD_NONBLOCK);
if (this->source.fd == -1)
goto clean_impl;
@ -856,7 +861,7 @@ struct pw_node *pw_node_new(struct pw_core *core,
clean_impl:
if (this->source.func != NULL)
close(this->source.fd);
spa_system_close(this->core->data_system, this->source.fd);
if (properties)
pw_properties_free(properties);
free(impl);
@ -1197,7 +1202,7 @@ void pw_node_destroy(struct pw_node *node)
clear_info(node);
close(node->source.fd);
spa_system_close(node->core->data_system, node->source.fd);
free(impl);
}

View file

@ -41,6 +41,8 @@
#define MAX_SUPPORT 32
#define SUPPORTLIB "support/libspa-support"
struct plugin {
struct spa_list link;
char *filename;
@ -53,7 +55,7 @@ struct plugin {
struct handle {
struct spa_list link;
struct plugin *plugin;
const char *factory_name;
char *factory_name;
int ref;
struct spa_handle handle;
};
@ -65,9 +67,9 @@ struct registry {
struct support {
char **categories;
const char *plugin_dir;
struct plugin *support_plugin;
struct spa_support support[MAX_SUPPORT];
const char *support_lib;
struct registry *registry;
struct spa_support support[MAX_SUPPORT];
uint32_t n_support;
};
@ -164,52 +166,13 @@ static const struct spa_handle_factory *find_factory(struct plugin *plugin, cons
return NULL;
}
static struct handle *
load_handle(struct plugin *plugin,
const char *factory_name,
const struct spa_dict *info,
uint32_t n_support,
struct spa_support support[n_support])
{
int res;
struct handle *handle;
const struct spa_handle_factory *factory;
factory = find_factory(plugin, factory_name);
if (factory == NULL)
goto not_found;
handle = calloc(1, sizeof(struct handle) + spa_handle_factory_get_size(factory, info));
if (handle == NULL)
goto alloc_failed;
if ((res = spa_handle_factory_init(factory,
&handle->handle, info,
support, n_support)) < 0) {
fprintf(stderr, "can't make factory instance %s: %d\n", factory_name, res);
goto init_failed;
}
handle->ref = 1;
handle->plugin = plugin;
handle->factory_name = factory_name;
spa_list_append(&plugin->handles, &handle->link);
return handle;
init_failed:
free(handle);
alloc_failed:
not_found:
return NULL;
}
static void unref_handle(struct handle *handle)
{
if (--handle->ref == 0) {
spa_list_remove(&handle->link);
spa_handle_clear(&handle->handle);
unref_plugin(handle->plugin);
free(handle->factory_name);
free(handle);
}
}
@ -230,30 +193,13 @@ static void configure_debug(struct support *support, const char *str)
pw_free_strv(level);
}
/** Get a support interface
* \param type the interface type
* \return the interface or NULL when not configured
*/
SPA_EXPORT
void *pw_get_support_interface(uint32_t type)
uint32_t pw_get_support(struct spa_support *support, uint32_t max_support)
{
return spa_support_find(global_support.support, global_support.n_support, type);
}
SPA_EXPORT
const struct spa_handle_factory *pw_get_support_factory(const char *factory_name)
{
struct plugin *plugin = global_support.support_plugin;
if (plugin == NULL)
return NULL;
return find_factory(plugin, factory_name);
}
SPA_EXPORT
const struct spa_support *pw_get_support(uint32_t *n_support)
{
*n_support = global_support.n_support;
return global_support.support;
uint32_t i, n = SPA_MIN(global_support.n_support, max_support);
for (i = 0; i < n; i++)
support[i] = global_support.support[i];
return n;
}
SPA_EXPORT
@ -264,31 +210,53 @@ struct spa_handle *pw_load_spa_handle(const char *lib,
const struct spa_support support[])
{
struct support *sup = &global_support;
struct spa_support extra_support[MAX_SUPPORT];
uint32_t extra_n_support;
struct plugin *plugin;
struct handle *handle;
uint32_t i;
const struct spa_handle_factory *factory;
int res;
extra_n_support = sup->n_support;
memcpy(extra_support, sup->support,
sizeof(struct spa_support) * sup->n_support);
for (i = 0; i < n_support; i++) {
extra_support[extra_n_support++] =
SPA_SUPPORT_INIT(support[i].type, support[i].data);
}
pw_log_debug("load \"%s\", \"%s\"", lib, factory_name);
spa_return_val_if_fail(factory_name != NULL, NULL);
if (lib == NULL)
lib = sup->support_lib;
if (lib == NULL)
return NULL;
if ((plugin = open_plugin(sup->registry, sup->plugin_dir, lib)) == NULL) {
pw_log_warn("can't load '%s'", lib);
return NULL;
goto out;
}
handle = load_handle(plugin, factory_name, info, extra_n_support, extra_support);
factory = find_factory(plugin, factory_name);
if (factory == NULL)
goto out_unref_plugin;
handle = calloc(1, sizeof(struct handle) + spa_handle_factory_get_size(factory, info));
if (handle == NULL)
return NULL;
goto out;
if ((res = spa_handle_factory_init(factory,
&handle->handle, info,
support, n_support)) < 0) {
pw_log_warn("can't make factory instance %s: %d\n", factory_name, res);
goto out_free_handle;
}
handle->ref = 1;
handle->plugin = plugin;
handle->factory_name = strdup(factory_name);
spa_list_append(&plugin->handles, &handle->link);
return &handle->handle;
out_free_handle:
free(handle);
out_unref_plugin:
unref_plugin(plugin);
out:
return NULL;
}
static struct handle *find_handle(struct spa_handle *handle)
@ -319,6 +287,29 @@ int pw_unload_spa_handle(struct spa_handle *handle)
return 0;
}
static void *add_interface(struct support *support,
const char *factory_name,
uint32_t type,
const struct spa_dict *info)
{
struct spa_handle *handle;
void *iface = NULL;
int res = -ENOENT;
handle = pw_load_spa_handle(support->support_lib,
factory_name, info,
support->n_support, support->support);
if (handle == NULL ||
(res = spa_handle_get_interface(handle, type, &iface)) < 0) {
fprintf(stderr, "can't get %d interface %d\n", type, res);
} else {
support->support[support->n_support++] =
SPA_SUPPORT_INIT(type, iface);
}
return iface;
}
/** Initialize PipeWire
*
* \param argc pointer to argc
@ -335,74 +326,46 @@ SPA_EXPORT
void pw_init(int *argc, char **argv[])
{
const char *str;
struct handle *handle;
void *iface;
struct support *support = &global_support;
struct plugin *plugin;
struct spa_dict_item items[2];
uint32_t n_items;
struct spa_dict info;
struct spa_dict_item items[1];
int res = 0;
struct support *support = &global_support;
struct spa_log *log;
char level[32];
if (support->registry != NULL)
return;
if ((str = getenv("PIPEWIRE_DEBUG")))
configure_debug(support, str);
if ((str = getenv("SPA_PLUGIN_DIR")) == NULL)
str = PLUGINDIR;
support->plugin_dir = str;
if ((str = getenv("SPA_SUPPORT_LIB")) == NULL)
str = SUPPORTLIB;
support->support_lib = str;
spa_list_init(&global_registry.plugins);
support->registry = &global_registry;
if (support->n_support > 0)
return;
n_items = 0;
items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_LOG_COLORS, "1");
snprintf(level, sizeof(level), "%d", pw_log_level);
items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_LOG_LEVEL, level);
info = SPA_DICT_INIT(items, n_items);
plugin = open_plugin(support->registry, support->plugin_dir, "support/libspa-support");
if (plugin == NULL) {
fprintf(stderr, "can't open support library");
return;
}
log = add_interface(support, "logger", SPA_TYPE_INTERFACE_Log, &info);
if (log)
pw_log_set(log);
support->support_plugin = plugin;
n_items = 0;
if ((str = getenv("PIPEWIRE_CPU")))
items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_CPU_FORCE, str);
info = SPA_DICT_INIT(items, n_items);
items[0] = SPA_DICT_ITEM_INIT(SPA_KEY_LOG_COLORS, "1");
info = SPA_DICT_INIT(items, 1);
handle = load_handle(plugin, "logger", &info, support->n_support, support->support);
if (handle == NULL ||
(res = spa_handle_get_interface(&handle->handle,
SPA_TYPE_INTERFACE_Log, &iface)) < 0) {
fprintf(stderr, "can't get Log interface %d\n", res);
}
else {
support->support[support->n_support++] =
SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_Log, iface);
pw_log_set(iface);
}
handle = load_handle(plugin, "system", NULL, support->n_support, support->support);
if (handle == NULL ||
(res = spa_handle_get_interface(&handle->handle,
SPA_TYPE_INTERFACE_System, &iface)) < 0) {
fprintf(stderr, "can't get System interface %d\n", res);
}
else {
support->support[support->n_support++] =
SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_System, iface);
}
handle = load_handle(plugin, "cpu", NULL, support->n_support, support->support);
if (handle == NULL ||
(res = spa_handle_get_interface(&handle->handle,
SPA_TYPE_INTERFACE_CPU, &iface)) < 0) {
fprintf(stderr, "can't get CPU interface %d\n", res);
}
else {
struct spa_cpu *cpu = iface;
if ((str = getenv("PIPEWIRE_CPU")))
spa_cpu_force_flags(cpu, strtoul(str, NULL, 0));
support->support[support->n_support++] =
SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_CPU, iface);
}
add_interface(support, "cpu", SPA_TYPE_INTERFACE_CPU, &info);
pw_log_info("version %s", pw_get_library_version());
}

View file

@ -137,8 +137,7 @@ pw_fill_stream_properties(struct pw_core *core, struct pw_properties *properties
enum pw_direction
pw_direction_reverse(enum pw_direction direction);
void *
pw_get_support_interface(uint32_t type);
uint32_t pw_get_support(struct spa_support *support, uint32_t max_support);
struct spa_handle *pw_load_spa_handle(const char *lib,
const char *factory_name,
@ -148,12 +147,6 @@ struct spa_handle *pw_load_spa_handle(const char *lib,
int pw_unload_spa_handle(struct spa_handle *handle);
const struct spa_handle_factory *
pw_get_support_factory(const char *factory_name);
const struct spa_support *
pw_get_support(uint32_t *n_support);
#ifdef __cplusplus
}
#endif

View file

@ -232,6 +232,7 @@ struct pw_core {
struct pw_loop *main_loop; /**< main loop for control */
struct pw_loop *data_loop; /**< data loop for data passing */
struct pw_data_loop *data_loop_impl;
struct spa_system *data_system; /**< data system for data passing */
struct spa_support support[16]; /**< support for spa plugins */
uint32_t n_support; /**< number of support items */

View file

@ -1312,7 +1312,7 @@ static bool parse(struct data *data, char *buf, size_t size, char **error)
return false;
}
static void do_input(void *data, int fd, enum spa_io mask)
static void do_input(void *data, int fd, uint32_t mask)
{
struct data *d = data;
char buf[4096], *error;