mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-10 13:30:05 -05:00
Make structure private
Make structs private. Expose methods for things we need. Signals only work on exposed structures so make a new callback helper to signal events.
This commit is contained in:
parent
e24c934a1b
commit
b898eb46cd
72 changed files with 2980 additions and 2120 deletions
|
|
@ -49,7 +49,9 @@ bool pipewire__module_init(struct pw_module *module, const char *args)
|
|||
if ((dir = getenv("SPA_PLUGIN_DIR")) == NULL)
|
||||
dir = PLUGINDIR;
|
||||
|
||||
pw_spa_monitor_load(module->core, module->global, dir, argv[0], argv[1], argv[2]);
|
||||
pw_spa_monitor_load(pw_module_get_core(module),
|
||||
pw_module_get_global(module),
|
||||
dir, argv[0], argv[1], argv[2]);
|
||||
|
||||
pw_free_strv(argv);
|
||||
|
||||
|
|
|
|||
|
|
@ -25,21 +25,24 @@
|
|||
#include "config.h"
|
||||
|
||||
#include "pipewire/interfaces.h"
|
||||
#include "pipewire/private.h"
|
||||
#include "pipewire/core.h"
|
||||
#include "pipewire/module.h"
|
||||
|
||||
#include "spa-node.h"
|
||||
|
||||
struct impl {
|
||||
struct pw_node_factory this;
|
||||
struct factory_data {
|
||||
struct pw_core *core;
|
||||
struct pw_node_factory *this;
|
||||
struct pw_properties *properties;
|
||||
};
|
||||
|
||||
static struct pw_node *create_node(struct pw_node_factory *factory,
|
||||
static struct pw_node *create_node(void *_data,
|
||||
struct pw_resource *resource,
|
||||
const char *name,
|
||||
struct pw_properties *properties)
|
||||
{
|
||||
struct factory_data *data = _data;
|
||||
struct pw_node *node;
|
||||
const char *lib, *factory_name;
|
||||
|
||||
|
|
@ -52,7 +55,7 @@ static struct pw_node *create_node(struct pw_node_factory *factory,
|
|||
if(lib == NULL || factory_name == NULL)
|
||||
goto no_properties;
|
||||
|
||||
node = pw_spa_node_load(factory->core,
|
||||
node = pw_spa_node_load(data->core,
|
||||
NULL,
|
||||
NULL,
|
||||
lib,
|
||||
|
|
@ -82,28 +85,32 @@ static struct pw_node *create_node(struct pw_node_factory *factory,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static const struct pw_node_factory_implementation impl_factory = {
|
||||
PW_VERSION_NODE_FACRORY_IMPLEMENTATION,
|
||||
.create_node = create_node,
|
||||
};
|
||||
|
||||
static bool module_init(struct pw_module *module, struct pw_properties *properties)
|
||||
{
|
||||
struct pw_core *core = module->core;
|
||||
struct impl *impl;
|
||||
struct pw_node_factory *factory;
|
||||
struct factory_data *data;
|
||||
|
||||
impl = calloc(1, sizeof(struct impl));
|
||||
if (impl == NULL)
|
||||
factory = pw_node_factory_new(core, "spa-node-factory", sizeof(*data));
|
||||
if (factory == NULL)
|
||||
return false;
|
||||
|
||||
pw_log_debug("module %p: new", impl);
|
||||
data = pw_node_factory_get_user_data(factory);
|
||||
data->this = factory;
|
||||
data->properties = properties;
|
||||
|
||||
impl->properties = properties;
|
||||
pw_log_debug("module %p: new", module);
|
||||
|
||||
impl->this.core = core;
|
||||
impl->this.name = "spa-node-factory";
|
||||
pw_signal_init(&impl->this.destroy_signal);
|
||||
impl->this.create_node = create_node;
|
||||
pw_node_factory_set_implementation(factory,
|
||||
&impl_factory,
|
||||
data);
|
||||
|
||||
spa_list_insert(core->node_factory_list.prev, &impl->this.link);
|
||||
|
||||
impl->this.global = pw_core_add_global(core, NULL, module->global, core->type.node_factory, 0,
|
||||
NULL, impl);
|
||||
pw_node_factory_export(factory, NULL, module->global);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ bool pipewire__module_init(struct pw_module *module, const char *args)
|
|||
pw_free_strv(prop);
|
||||
}
|
||||
|
||||
pw_spa_node_load(module->core, NULL, module->global, argv[0], argv[1], argv[2], props);
|
||||
pw_spa_node_load(pw_module_get_core(module), NULL, pw_module_get_global(module), argv[0], argv[1], argv[2], props);
|
||||
|
||||
pw_free_strv(argv);
|
||||
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ struct impl {
|
|||
struct pw_spa_monitor this;
|
||||
|
||||
struct pw_core *core;
|
||||
struct pw_type *t;
|
||||
struct pw_global *parent;
|
||||
|
||||
void *hnd;
|
||||
|
|
@ -66,13 +67,16 @@ static void add_item(struct pw_spa_monitor *this, struct spa_monitor_item *item)
|
|||
const char *name, *id, *klass;
|
||||
struct spa_handle_factory *factory;
|
||||
struct spa_pod *info = NULL;
|
||||
struct pw_type *t = pw_core_get_type(impl->core);
|
||||
const struct spa_support *support;
|
||||
uint32_t n_support;
|
||||
|
||||
spa_pod_object_query(&item->object,
|
||||
impl->core->type.monitor.name, SPA_POD_TYPE_STRING, &name,
|
||||
impl->core->type.monitor.id, SPA_POD_TYPE_STRING, &id,
|
||||
impl->core->type.monitor.klass, SPA_POD_TYPE_STRING, &klass,
|
||||
impl->core->type.monitor.factory, SPA_POD_TYPE_POINTER, &factory,
|
||||
impl->core->type.monitor.info, SPA_POD_TYPE_STRUCT, &info, 0);
|
||||
t->monitor.name, SPA_POD_TYPE_STRING, &name,
|
||||
t->monitor.id, SPA_POD_TYPE_STRING, &id,
|
||||
t->monitor.klass, SPA_POD_TYPE_STRING, &klass,
|
||||
t->monitor.factory, SPA_POD_TYPE_POINTER, &factory,
|
||||
t->monitor.info, SPA_POD_TYPE_STRUCT, &info, 0);
|
||||
|
||||
pw_log_debug("monitor %p: add: \"%s\" (%s)", this, name, id);
|
||||
|
||||
|
|
@ -92,19 +96,22 @@ static void add_item(struct pw_spa_monitor *this, struct spa_monitor_item *item)
|
|||
}
|
||||
pw_properties_set(props, "media.class", klass);
|
||||
|
||||
support = pw_core_get_support(impl->core, &n_support);
|
||||
|
||||
handle = calloc(1, factory->size);
|
||||
if ((res = spa_handle_factory_init(factory,
|
||||
handle,
|
||||
&props->dict,
|
||||
impl->core->support, impl->core->n_support)) < 0) {
|
||||
support,
|
||||
n_support)) < 0) {
|
||||
pw_log_error("can't make factory instance: %d", res);
|
||||
return;
|
||||
}
|
||||
if ((res = spa_handle_get_interface(handle, impl->core->type.spa_node, &node_iface)) < 0) {
|
||||
if ((res = spa_handle_get_interface(handle, t->spa_node, &node_iface)) < 0) {
|
||||
pw_log_error("can't get NODE interface: %d", res);
|
||||
return;
|
||||
}
|
||||
if ((res = spa_handle_get_interface(handle, impl->core->type.spa_clock, &clock_iface)) < 0) {
|
||||
if ((res = spa_handle_get_interface(handle, t->spa_clock, &clock_iface)) < 0) {
|
||||
pw_log_info("no CLOCK interface: %d", res);
|
||||
}
|
||||
|
||||
|
|
@ -143,10 +150,11 @@ static void remove_item(struct pw_spa_monitor *this, struct spa_monitor_item *it
|
|||
struct impl *impl = SPA_CONTAINER_OF(this, struct impl, this);
|
||||
struct monitor_item *mitem;
|
||||
const char *name, *id;
|
||||
struct pw_type *t = pw_core_get_type(impl->core);
|
||||
|
||||
spa_pod_object_query(&item->object,
|
||||
impl->core->type.monitor.name, SPA_POD_TYPE_STRING, &name,
|
||||
impl->core->type.monitor.id, SPA_POD_TYPE_STRING, &id, 0);
|
||||
t->monitor.name, SPA_POD_TYPE_STRING, &name,
|
||||
t->monitor.id, SPA_POD_TYPE_STRING, &id, 0);
|
||||
|
||||
pw_log_debug("monitor %p: remove: \"%s\" (%s)", this, name, id);
|
||||
mitem = find_item(this, id);
|
||||
|
|
@ -158,19 +166,20 @@ static void on_monitor_event(struct spa_monitor *monitor, struct spa_event *even
|
|||
{
|
||||
struct impl *impl = user_data;
|
||||
struct pw_spa_monitor *this = &impl->this;
|
||||
struct pw_type *t = pw_core_get_type(impl->core);
|
||||
|
||||
if (SPA_EVENT_TYPE(event) == impl->core->type.monitor.Added) {
|
||||
if (SPA_EVENT_TYPE(event) == t->monitor.Added) {
|
||||
struct spa_monitor_item *item = SPA_POD_CONTENTS(struct spa_event, event);
|
||||
add_item(this, item);
|
||||
} else if (SPA_EVENT_TYPE(event) == impl->core->type.monitor.Removed) {
|
||||
} else if (SPA_EVENT_TYPE(event) == t->monitor.Removed) {
|
||||
struct spa_monitor_item *item = SPA_POD_CONTENTS(struct spa_event, event);
|
||||
remove_item(this, item);
|
||||
} else if (SPA_EVENT_TYPE(event) == impl->core->type.monitor.Changed) {
|
||||
} else if (SPA_EVENT_TYPE(event) == t->monitor.Changed) {
|
||||
struct spa_monitor_item *item = SPA_POD_CONTENTS(struct spa_event, event);
|
||||
const char *name;
|
||||
|
||||
spa_pod_object_query(&item->object,
|
||||
impl->core->type.monitor.name, SPA_POD_TYPE_STRING, &name, 0);
|
||||
t->monitor.name, SPA_POD_TYPE_STRING, &name, 0);
|
||||
|
||||
pw_log_debug("monitor %p: changed: \"%s\"", this, name);
|
||||
}
|
||||
|
|
@ -180,10 +189,13 @@ static void update_monitor(struct pw_core *core, const char *name)
|
|||
{
|
||||
const char *monitors;
|
||||
struct spa_dict_item item;
|
||||
const struct spa_dict *props;
|
||||
struct spa_dict dict = SPA_DICT_INIT(1, &item);
|
||||
|
||||
if (core->properties)
|
||||
monitors = pw_properties_get(core->properties, "monitors");
|
||||
props = pw_core_get_properties(core);
|
||||
|
||||
if (props)
|
||||
monitors = spa_dict_lookup(props, "monitors");
|
||||
else
|
||||
monitors = NULL;
|
||||
|
||||
|
|
@ -220,6 +232,9 @@ struct pw_spa_monitor *pw_spa_monitor_load(struct pw_core *core,
|
|||
spa_handle_factory_enum_func_t enum_func;
|
||||
const struct spa_handle_factory *factory;
|
||||
char *filename;
|
||||
const struct spa_support *support;
|
||||
uint32_t n_support;
|
||||
struct pw_type *t = pw_core_get_type(core);
|
||||
|
||||
asprintf(&filename, "%s/%s.so", dir, lib);
|
||||
|
||||
|
|
@ -241,13 +256,14 @@ struct pw_spa_monitor *pw_spa_monitor_load(struct pw_core *core,
|
|||
if (strcmp(factory->name, factory_name) == 0)
|
||||
break;
|
||||
}
|
||||
support = pw_core_get_support(core, &n_support);
|
||||
handle = calloc(1, factory->size);
|
||||
if ((res = spa_handle_factory_init(factory,
|
||||
handle, NULL, core->support, core->n_support)) < 0) {
|
||||
handle, NULL, support, n_support)) < 0) {
|
||||
pw_log_error("can't make factory instance: %d", res);
|
||||
goto init_failed;
|
||||
}
|
||||
if ((res = spa_handle_get_interface(handle, core->type.spa_monitor, &iface)) < 0) {
|
||||
if ((res = spa_handle_get_interface(handle, t->spa_monitor, &iface)) < 0) {
|
||||
free(handle);
|
||||
pw_log_error("can't get MONITOR interface: %d", res);
|
||||
goto interface_failed;
|
||||
|
|
@ -255,6 +271,7 @@ struct pw_spa_monitor *pw_spa_monitor_load(struct pw_core *core,
|
|||
|
||||
impl = calloc(1, sizeof(struct impl));
|
||||
impl->core = core;
|
||||
impl->t = t;
|
||||
impl->parent = parent;
|
||||
impl->hnd = hnd;
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
#include <spa/node.h>
|
||||
|
||||
#include "spa-node.h"
|
||||
#include "pipewire/private.h"
|
||||
|
||||
struct impl {
|
||||
struct pw_node *this;
|
||||
|
|
@ -41,101 +42,111 @@ struct impl {
|
|||
struct spa_node *node; /**< handle to SPA node */
|
||||
char *lib;
|
||||
char *factory_name;
|
||||
|
||||
struct pw_callback_info node_callbacks;
|
||||
};
|
||||
|
||||
struct port {
|
||||
struct pw_port *port;
|
||||
|
||||
enum pw_direction direction;
|
||||
uint32_t port_id;
|
||||
struct spa_node *node;
|
||||
};
|
||||
|
||||
static int port_impl_enum_formats(struct pw_port *port,
|
||||
static int port_impl_set_io(void *data, struct spa_port_io *io)
|
||||
{
|
||||
struct port *p = data;
|
||||
return spa_node_port_set_io(p->node, p->direction, p->port_id, io);
|
||||
}
|
||||
|
||||
static int port_impl_enum_formats(void *data,
|
||||
struct spa_format **format,
|
||||
const struct spa_format *filter,
|
||||
int32_t index)
|
||||
{
|
||||
struct port *p = port->user_data;
|
||||
return spa_node_port_enum_formats(p->node, port->direction, port->port_id, format, filter, index);
|
||||
struct port *p = data;
|
||||
return spa_node_port_enum_formats(p->node, p->direction, p->port_id, format, filter, index);
|
||||
}
|
||||
|
||||
static int port_impl_set_format(struct pw_port *port, uint32_t flags, const struct spa_format *format)
|
||||
static int port_impl_set_format(void *data, uint32_t flags, const struct spa_format *format)
|
||||
{
|
||||
struct port *p = port->user_data;
|
||||
return spa_node_port_set_format(p->node, port->direction, port->port_id, flags, format);
|
||||
struct port *p = data;
|
||||
return spa_node_port_set_format(p->node, p->direction, p->port_id, flags, format);
|
||||
}
|
||||
|
||||
static int port_impl_get_format(struct pw_port *port, const struct spa_format **format)
|
||||
static int port_impl_get_format(void *data, const struct spa_format **format)
|
||||
{
|
||||
struct port *p = port->user_data;
|
||||
return spa_node_port_get_format(p->node, port->direction, port->port_id, format);
|
||||
struct port *p = data;
|
||||
return spa_node_port_get_format(p->node, p->direction, p->port_id, format);
|
||||
}
|
||||
|
||||
static int port_impl_get_info(struct pw_port *port, const struct spa_port_info **info)
|
||||
static int port_impl_get_info(void *data, const struct spa_port_info **info)
|
||||
{
|
||||
struct port *p = port->user_data;
|
||||
return spa_node_port_get_info(p->node, port->direction, port->port_id, info);
|
||||
struct port *p = data;
|
||||
return spa_node_port_get_info(p->node, p->direction, p->port_id, info);
|
||||
}
|
||||
|
||||
static int port_impl_enum_params(struct pw_port *port, uint32_t index, struct spa_param **param)
|
||||
static int port_impl_enum_params(void *data, uint32_t index, struct spa_param **param)
|
||||
{
|
||||
struct port *p = port->user_data;
|
||||
return spa_node_port_enum_params(p->node, port->direction, port->port_id, index, param);
|
||||
struct port *p = data;
|
||||
return spa_node_port_enum_params(p->node, p->direction, p->port_id, index, param);
|
||||
}
|
||||
|
||||
static int port_impl_set_param(struct pw_port *port, struct spa_param *param)
|
||||
static int port_impl_set_param(void *data, struct spa_param *param)
|
||||
{
|
||||
struct port *p = port->user_data;
|
||||
return spa_node_port_set_param(p->node, port->direction, port->port_id, param);
|
||||
struct port *p = data;
|
||||
return spa_node_port_set_param(p->node, p->direction, p->port_id, param);
|
||||
}
|
||||
|
||||
static int port_impl_use_buffers(struct pw_port *port, struct spa_buffer **buffers, uint32_t n_buffers)
|
||||
static int port_impl_use_buffers(void *data, struct spa_buffer **buffers, uint32_t n_buffers)
|
||||
{
|
||||
struct port *p = port->user_data;
|
||||
return spa_node_port_use_buffers(p->node, port->direction, port->port_id, buffers, n_buffers);
|
||||
struct port *p = data;
|
||||
return spa_node_port_use_buffers(p->node, p->direction, p->port_id, buffers, n_buffers);
|
||||
}
|
||||
|
||||
static int port_impl_alloc_buffers(struct pw_port *port,
|
||||
static int port_impl_alloc_buffers(void *data,
|
||||
struct spa_param **params, uint32_t n_params,
|
||||
struct spa_buffer **buffers, uint32_t *n_buffers)
|
||||
{
|
||||
struct port *p = port->user_data;
|
||||
return spa_node_port_alloc_buffers(p->node, port->direction, port->port_id,
|
||||
struct port *p = data;
|
||||
return spa_node_port_alloc_buffers(p->node, p->direction, p->port_id,
|
||||
params, n_params, buffers, n_buffers);
|
||||
}
|
||||
|
||||
static int port_impl_reuse_buffer(struct pw_port *port, uint32_t buffer_id)
|
||||
static int port_impl_reuse_buffer(void *data, uint32_t buffer_id)
|
||||
{
|
||||
struct port *p = port->user_data;
|
||||
return spa_node_port_reuse_buffer(p->node, port->port_id, buffer_id);
|
||||
struct port *p = data;
|
||||
return spa_node_port_reuse_buffer(p->node, p->port_id, buffer_id);
|
||||
}
|
||||
|
||||
static int port_impl_send_command(struct pw_port *port, struct spa_command *command)
|
||||
static int port_impl_send_command(void *data, struct spa_command *command)
|
||||
{
|
||||
struct port *p = port->user_data;
|
||||
struct port *p = data;
|
||||
return spa_node_port_send_command(p->node,
|
||||
port->direction,
|
||||
port->port_id,
|
||||
p->direction,
|
||||
p->port_id,
|
||||
command);
|
||||
}
|
||||
|
||||
const struct pw_port_implementation port_impl = {
|
||||
PW_VERSION_PORT_IMPLEMENTATION,
|
||||
port_impl_enum_formats,
|
||||
port_impl_set_format,
|
||||
port_impl_get_format,
|
||||
port_impl_get_info,
|
||||
port_impl_enum_params,
|
||||
port_impl_set_param,
|
||||
port_impl_use_buffers,
|
||||
port_impl_alloc_buffers,
|
||||
port_impl_reuse_buffer,
|
||||
port_impl_send_command,
|
||||
.set_io = port_impl_set_io,
|
||||
.enum_formats = port_impl_enum_formats,
|
||||
.set_format = port_impl_set_format,
|
||||
.get_format = port_impl_get_format,
|
||||
.get_info = port_impl_get_info,
|
||||
.enum_params = port_impl_enum_params,
|
||||
.set_param = port_impl_set_param,
|
||||
.use_buffers = port_impl_use_buffers,
|
||||
.alloc_buffers = port_impl_alloc_buffers,
|
||||
.reuse_buffer = port_impl_reuse_buffer,
|
||||
.send_command = port_impl_send_command,
|
||||
};
|
||||
|
||||
static struct pw_port *
|
||||
make_port(struct pw_node *node, enum pw_direction direction, uint32_t port_id)
|
||||
make_port(struct impl *impl, enum pw_direction direction, uint32_t port_id)
|
||||
{
|
||||
struct impl *impl = node->user_data;
|
||||
struct pw_node *node = impl->this;
|
||||
struct pw_port *port;
|
||||
struct port *p;
|
||||
|
||||
|
|
@ -143,13 +154,13 @@ make_port(struct pw_node *node, enum pw_direction direction, uint32_t port_id)
|
|||
if (port == NULL)
|
||||
return NULL;
|
||||
|
||||
p = port->user_data;
|
||||
p = pw_port_get_user_data(port);
|
||||
p->port = port;
|
||||
p->direction = direction;
|
||||
p->port_id = port_id;
|
||||
p->node = impl->node;
|
||||
|
||||
port->implementation = &port_impl;
|
||||
|
||||
spa_node_port_set_io(impl->node, direction, port_id, &port->io);
|
||||
|
||||
pw_port_set_implementation(port, &port_impl, p);
|
||||
pw_port_add(port, node);
|
||||
|
||||
return port;
|
||||
|
|
@ -192,7 +203,7 @@ static void update_port_ids(struct impl *impl)
|
|||
|| i < n_input_ports) {
|
||||
struct pw_port *np;
|
||||
pw_log_debug("node %p: input port added %d", this, input_port_ids[i]);
|
||||
np = make_port(this, PW_DIRECTION_INPUT, input_port_ids[i]);
|
||||
np = make_port(impl, PW_DIRECTION_INPUT, input_port_ids[i]);
|
||||
|
||||
ports = np->link.next;
|
||||
i++;
|
||||
|
|
@ -220,7 +231,7 @@ static void update_port_ids(struct impl *impl)
|
|||
|| i < n_output_ports) {
|
||||
struct pw_port *np;
|
||||
pw_log_debug("node %p: output port added %d", this, output_port_ids[i]);
|
||||
np = make_port(this, PW_DIRECTION_OUTPUT, output_port_ids[i]);
|
||||
np = make_port(impl, PW_DIRECTION_OUTPUT, output_port_ids[i]);
|
||||
ports = np->link.next;
|
||||
i++;
|
||||
} else if (p) {
|
||||
|
|
@ -235,66 +246,66 @@ static void update_port_ids(struct impl *impl)
|
|||
}
|
||||
|
||||
|
||||
static int node_impl_get_props(struct pw_node *node, struct spa_props **props)
|
||||
static int node_impl_get_props(void *data, struct spa_props **props)
|
||||
{
|
||||
struct impl *impl = node->user_data;
|
||||
struct impl *impl = data;
|
||||
return spa_node_get_props(impl->node, props);
|
||||
}
|
||||
|
||||
static int node_impl_set_props(struct pw_node *node, const struct spa_props *props)
|
||||
static int node_impl_set_props(void *data, const struct spa_props *props)
|
||||
{
|
||||
struct impl *impl = node->user_data;
|
||||
struct impl *impl = data;
|
||||
return spa_node_set_props(impl->node, props);
|
||||
}
|
||||
|
||||
static int node_impl_send_command(struct pw_node *node, const struct spa_command *command)
|
||||
static int node_impl_send_command(void *data, const struct spa_command *command)
|
||||
{
|
||||
struct impl *impl = node->user_data;
|
||||
struct impl *impl = data;
|
||||
return spa_node_send_command(impl->node, command);
|
||||
}
|
||||
|
||||
static struct pw_port*
|
||||
node_impl_add_port(struct pw_node *node,
|
||||
node_impl_add_port(void *data,
|
||||
enum pw_direction direction,
|
||||
uint32_t port_id)
|
||||
{
|
||||
struct impl *impl = node->user_data;
|
||||
struct impl *impl = data;
|
||||
int res;
|
||||
|
||||
if ((res = spa_node_add_port(impl->node, direction, port_id)) < 0) {
|
||||
pw_log_error("node %p: could not add port %d %d", node, port_id, res);
|
||||
pw_log_error("node %p: could not add port %d %d", impl->this, port_id, res);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return make_port(node, direction, port_id);
|
||||
return make_port(impl, direction, port_id);
|
||||
}
|
||||
|
||||
static int node_impl_schedule_input(struct pw_node *node)
|
||||
static int node_impl_process_input(void *data)
|
||||
{
|
||||
struct impl *impl = node->user_data;
|
||||
struct impl *impl = data;
|
||||
return spa_node_process_input(impl->node);
|
||||
}
|
||||
|
||||
static int node_impl_schedule_output(struct pw_node *node)
|
||||
static int node_impl_process_output(void *data)
|
||||
{
|
||||
struct impl *impl = node->user_data;
|
||||
struct impl *impl = data;
|
||||
return spa_node_process_output(impl->node);
|
||||
}
|
||||
|
||||
static const struct pw_node_implementation node_impl = {
|
||||
PW_VERSION_NODE_IMPLEMENTATION,
|
||||
node_impl_get_props,
|
||||
node_impl_set_props,
|
||||
node_impl_send_command,
|
||||
node_impl_add_port,
|
||||
node_impl_schedule_input,
|
||||
node_impl_schedule_output,
|
||||
.get_props = node_impl_get_props,
|
||||
.set_props = node_impl_set_props,
|
||||
.send_command = node_impl_send_command,
|
||||
.add_port = node_impl_add_port,
|
||||
.process_input = node_impl_process_input,
|
||||
.process_output = node_impl_process_output,
|
||||
};
|
||||
|
||||
static void pw_spa_node_destroy(void *object)
|
||||
static void pw_spa_node_destroy(void *data)
|
||||
{
|
||||
struct pw_node *node = object;
|
||||
struct impl *impl = node->user_data;
|
||||
struct impl *impl = data;
|
||||
struct pw_node *node = impl->this;
|
||||
|
||||
pw_log_debug("spa-node %p: destroy", node);
|
||||
|
||||
|
|
@ -326,7 +337,7 @@ static void on_node_done(struct spa_node *node, int seq, int res, void *user_dat
|
|||
}
|
||||
|
||||
pw_log_debug("spa-node %p: async complete event %d %d", this, seq, res);
|
||||
pw_signal_emit(&this->async_complete, this, seq, res);
|
||||
pw_callback_emit(&this->callback_list, struct pw_node_callbacks, async_complete, seq, res);
|
||||
}
|
||||
|
||||
static void on_node_event(struct spa_node *node, struct spa_event *event, void *user_data)
|
||||
|
|
@ -334,21 +345,21 @@ static void on_node_event(struct spa_node *node, struct spa_event *event, void *
|
|||
struct impl *impl = user_data;
|
||||
struct pw_node *this = impl->this;
|
||||
|
||||
pw_signal_emit(&this->event, this, event);
|
||||
pw_callback_emit(&this->callback_list, struct pw_node_callbacks, event, event);
|
||||
}
|
||||
|
||||
static void on_node_need_input(struct spa_node *node, void *user_data)
|
||||
{
|
||||
struct impl *impl = user_data;
|
||||
struct pw_node *this = impl->this;
|
||||
pw_signal_emit(&this->need_input, this);
|
||||
pw_callback_emit_na(&this->callback_list, struct pw_node_callbacks, need_input);
|
||||
}
|
||||
|
||||
static void on_node_have_output(struct spa_node *node, void *user_data)
|
||||
{
|
||||
struct impl *impl = user_data;
|
||||
struct pw_node *this = impl->this;
|
||||
pw_signal_emit(&this->have_output, this);
|
||||
pw_callback_emit_na(&this->callback_list, struct pw_node_callbacks, have_output);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -370,13 +381,18 @@ on_node_reuse_buffer(struct spa_node *node, uint32_t port_id, uint32_t buffer_id
|
|||
}
|
||||
}
|
||||
|
||||
static const struct spa_node_callbacks node_callbacks = {
|
||||
static const struct spa_node_callbacks spa_node_callbacks = {
|
||||
SPA_VERSION_NODE_CALLBACKS,
|
||||
&on_node_done,
|
||||
&on_node_event,
|
||||
&on_node_need_input,
|
||||
&on_node_have_output,
|
||||
&on_node_reuse_buffer,
|
||||
.done = on_node_done,
|
||||
.event = on_node_event,
|
||||
.need_input = on_node_need_input,
|
||||
.have_output = on_node_have_output,
|
||||
.reuse_buffer = on_node_reuse_buffer,
|
||||
};
|
||||
|
||||
static const struct pw_node_callbacks node_callbacks = {
|
||||
PW_VERSION_NODE_CALLBACKS,
|
||||
.destroy = pw_spa_node_destroy,
|
||||
};
|
||||
|
||||
struct pw_node *
|
||||
|
|
@ -411,8 +427,6 @@ pw_spa_node_new(struct pw_core *core,
|
|||
if (this == NULL)
|
||||
return NULL;
|
||||
|
||||
this->destroy = pw_spa_node_destroy;
|
||||
this->implementation = &node_impl;
|
||||
this->clock = clock;
|
||||
|
||||
impl = this->user_data;
|
||||
|
|
@ -420,7 +434,11 @@ pw_spa_node_new(struct pw_core *core,
|
|||
impl->node = node;
|
||||
impl->async_init = async;
|
||||
|
||||
if (spa_node_set_callbacks(impl->node, &node_callbacks, impl) < 0)
|
||||
pw_node_add_callbacks(this, &impl->node_callbacks, &node_callbacks, impl);
|
||||
|
||||
pw_node_set_implementation(this, &node_impl, impl);
|
||||
|
||||
if (spa_node_set_callbacks(impl->node, &spa_node_callbacks, impl) < 0)
|
||||
pw_log_warn("spa-node %p: error setting callback", this);
|
||||
|
||||
if (!async) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue