Only pass data to callbacks.
Rename some structs
Provide methods to access structs
This commit is contained in:
Wim Taymans 2017-08-06 06:42:26 +02:00
parent 1b79419554
commit 0602d76b9e
57 changed files with 716 additions and 422 deletions

View file

@ -24,12 +24,12 @@
#include "config.h"
#include "pipewire/interfaces.h"
#include "pipewire/private.h"
#include "pipewire/core.h"
#include "pipewire/module.h"
struct impl {
struct pw_core *core;
struct pw_type *t;
struct pw_module *module;
struct pw_properties *properties;
@ -76,10 +76,12 @@ link_port_unlinked(void *data, struct pw_port *port)
struct node_info *info = data;
struct pw_link *link = info->link;
struct impl *impl = info->impl;
struct pw_port *input = pw_link_get_input(link);
pw_log_debug("module %p: link %p: port %p unlinked", impl, link, port);
if (port->direction == PW_DIRECTION_OUTPUT && link->input)
try_link_port(link->input->node, link->input, info);
if (pw_port_get_direction(port) == PW_DIRECTION_OUTPUT && input)
try_link_port(pw_port_get_node(input), input, info);
}
static void
@ -91,23 +93,8 @@ link_state_changed(void *data, enum pw_link_state old, enum pw_link_state state,
switch (state) {
case PW_LINK_STATE_ERROR:
{
struct pw_resource *resource;
pw_log_debug("module %p: link %p: state error: %s", impl, link, error);
spa_list_for_each(resource, &link->resource_list, link) {
pw_core_resource_error(resource->client->core_resource,
resource->id, SPA_RESULT_ERROR, error);
}
if (info->node->owner) {
pw_core_resource_error(info->node->owner->client->core_resource,
info->node->owner->id,
SPA_RESULT_ERROR, error);
}
break;
}
pw_log_debug("module %p: link %p: state error: %s", impl, link, error);
break;
case PW_LINK_STATE_UNLINKED:
pw_log_debug("module %p: link %p: unlinked", impl, link);
@ -151,7 +138,7 @@ static void try_link_port(struct pw_node *node, struct pw_port *port, struct nod
struct pw_link *link;
struct pw_port *target;
props = node->properties;
props = pw_node_get_properties(node);
if (props == NULL) {
pw_log_debug("module %p: node has no properties", impl);
return;
@ -175,11 +162,13 @@ static void try_link_port(struct pw_node *node, struct pw_port *port, struct nod
if (target == NULL)
goto error;
if (port->direction == PW_DIRECTION_OUTPUT)
link = pw_link_new(impl->core, impl->module->global, port, target, NULL, NULL, &error);
else
link = pw_link_new(impl->core, impl->module->global, target, port, NULL, NULL, &error);
if (pw_port_get_direction(port) == PW_DIRECTION_INPUT) {
struct pw_port *tmp = target;
target = port;
port = tmp;
}
link = pw_link_new(impl->core, pw_module_get_global(impl->module), port, target, NULL, NULL, &error);
if (link == NULL)
goto error;
@ -192,9 +181,10 @@ static void try_link_port(struct pw_node *node, struct pw_port *port, struct nod
error:
pw_log_error("module %p: can't link node '%s'", impl, error);
if (info->node->owner && info->node->owner->client->core_resource) {
pw_core_resource_error(info->node->owner->client->core_resource,
info->node->owner->id, SPA_RESULT_ERROR, error);
{
struct pw_resource *owner = pw_node_get_owner(info->node);
if (owner)
pw_resource_error(owner, SPA_RESULT_ERROR, error);
}
free(error);
return;
@ -210,15 +200,16 @@ static void node_port_removed(void *data, struct pw_port *port)
{
}
static bool on_node_port_added(void *data, struct pw_port *port)
{
node_port_added(data, port);
return true;
}
static void on_node_created(struct pw_node *node, struct node_info *info)
{
struct pw_port *port;
spa_list_for_each(port, &node->input_ports, link)
node_port_added(info, port);
spa_list_for_each(port, &node->output_ports, link)
node_port_added(info, port);
pw_node_for_each_port(node, PW_DIRECTION_INPUT, on_node_port_added, info);
pw_node_for_each_port(node, PW_DIRECTION_OUTPUT, on_node_port_added, info);
}
static void
@ -242,8 +233,8 @@ core_global_added(void *data, struct pw_global *global)
{
struct impl *impl = data;
if (global->type == impl->core->type.node) {
struct pw_node *node = global->object;
if (pw_global_get_type(global) == impl->t->node) {
struct pw_node *node = pw_global_get_object(global);
struct node_info *ninfo;
ninfo = calloc(1, sizeof(struct node_info));
@ -257,7 +248,7 @@ core_global_added(void *data, struct pw_global *global)
pw_log_debug("module %p: node %p added", impl, node);
if (node->info.state > PW_NODE_STATE_CREATING)
if (pw_node_get_info(node)->state > PW_NODE_STATE_CREATING)
on_node_created(node, ninfo);
}
}
@ -267,8 +258,8 @@ core_global_removed(void *data, struct pw_global *global)
{
struct impl *impl = data;
if (global->type == impl->core->type.node) {
struct pw_node *node = global->object;
if (pw_global_get_type(global) == impl->t->node) {
struct pw_node *node = pw_global_get_object(global);
struct node_info *ninfo;
if ((ninfo = find_node_info(impl, node)))
@ -296,13 +287,14 @@ const struct pw_core_events core_events = {
*/
static bool module_init(struct pw_module *module, struct pw_properties *properties)
{
struct pw_core *core = module->core;
struct pw_core *core = pw_module_get_core(module);
struct impl *impl;
impl = calloc(1, sizeof(struct impl));
pw_log_debug("module %p: new", impl);
impl->core = core;
impl->t = pw_core_get_type(core);
impl->module = module;
impl->properties = properties;

View file

@ -25,7 +25,6 @@
#include "config.h"
#include "pipewire/interfaces.h"
#include "pipewire/private.h"
#include "pipewire/core.h"
#include "pipewire/module.h"
@ -53,8 +52,7 @@ static struct pw_node *create_node(void *_data,
no_mem:
pw_log_error("can't create node");
pw_core_resource_error(resource->client->core_resource,
resource->client->core_resource->id, SPA_RESULT_NO_MEMORY, "no memory");
pw_resource_error(resource, SPA_RESULT_NO_MEMORY, "no memory");
if (properties)
pw_properties_free(properties);
return NULL;
@ -67,7 +65,7 @@ static const struct pw_node_factory_implementation impl_factory = {
static bool module_init(struct pw_module *module, struct pw_properties *properties)
{
struct pw_core *core = module->core;
struct pw_core *core = pw_module_get_core(module);
struct pw_node_factory *factory;
struct factory_data *data;
@ -87,7 +85,7 @@ static bool module_init(struct pw_module *module, struct pw_properties *properti
pw_protocol_native_ext_client_node_init(core);
pw_node_factory_export(factory, NULL, module->global);
pw_node_factory_export(factory, NULL, pw_module_get_global(module));
return true;
}

View file

@ -94,7 +94,7 @@ struct proxy {
struct spa_loop *data_loop;
const struct spa_node_callbacks *callbacks;
void *user_data;
void *callbacks_data;
struct pw_resource *resource;
@ -116,6 +116,7 @@ struct impl {
struct pw_client_node this;
struct pw_core *core;
struct pw_type *t;
struct proxy proxy;
@ -161,7 +162,7 @@ static int spa_proxy_node_send_command(struct spa_node *node, const struct spa_c
{
struct proxy *this;
int res = SPA_RESULT_OK;
struct pw_core *core;
struct pw_type *t;
if (node == NULL || command == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
@ -171,9 +172,9 @@ static int spa_proxy_node_send_command(struct spa_node *node, const struct spa_c
if (this->resource == NULL)
return SPA_RESULT_OK;
core = this->impl->core;
t = this->impl->t;
if (SPA_COMMAND_TYPE(command) == core->type.command_node.ClockUpdate) {
if (SPA_COMMAND_TYPE(command) == t->command_node.ClockUpdate) {
pw_client_node_resource_node_command(this->resource, this->seq++, command);
} else {
/* send start */
@ -186,7 +187,7 @@ static int spa_proxy_node_send_command(struct spa_node *node, const struct spa_c
static int
spa_proxy_node_set_callbacks(struct spa_node *node,
const struct spa_node_callbacks *callbacks,
void *user_data)
void *data)
{
struct proxy *this;
@ -195,7 +196,7 @@ spa_proxy_node_set_callbacks(struct spa_node *node,
this = SPA_CONTAINER_OF(node, struct proxy, node);
this->callbacks = callbacks;
this->user_data = user_data;
this->callbacks_data = data;
return SPA_RESULT_OK;
}
@ -577,11 +578,14 @@ spa_proxy_node_port_use_buffers(struct spa_node *node,
size_t n_mem;
struct pw_client_node_buffer *mb;
struct spa_meta_shared *msh;
struct pw_type *t;
this = SPA_CONTAINER_OF(node, struct proxy, node);
impl = this->impl;
spa_log_info(this->log, "proxy %p: use buffers %p %u", this, buffers, n_buffers);
t = impl->t;
if (!CHECK_PORT(this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
@ -608,7 +612,7 @@ spa_proxy_node_port_use_buffers(struct spa_node *node,
for (i = 0; i < n_buffers; i++) {
struct proxy_buffer *b = &port->buffers[i];
msh = spa_buffer_find_meta(buffers[i], impl->core->type.meta.Shared);
msh = spa_buffer_find_meta(buffers[i], t->meta.Shared);
if (msh == NULL) {
spa_log_error(this->log, "missing shared metadata on buffer %d", i);
return SPA_RESULT_ERROR;
@ -628,7 +632,7 @@ spa_proxy_node_port_use_buffers(struct spa_node *node,
direction,
port_id,
mb[i].mem_id,
impl->core->type.data.MemFd,
t->data.MemFd,
msh->fd, msh->flags, msh->offset, msh->size);
for (j = 0; j < buffers[i]->n_metas; j++) {
@ -640,8 +644,8 @@ spa_proxy_node_port_use_buffers(struct spa_node *node,
memcpy(&b->buffer.datas[j], d, sizeof(struct spa_data));
if (d->type == impl->core->type.data.DmaBuf ||
d->type == impl->core->type.data.MemFd) {
if (d->type == t->data.DmaBuf ||
d->type == t->data.MemFd) {
pw_client_node_resource_add_mem(this->resource,
direction,
port_id,
@ -649,10 +653,10 @@ spa_proxy_node_port_use_buffers(struct spa_node *node,
d->type,
d->fd,
d->flags, d->mapoffset, d->maxsize);
b->buffer.datas[j].type = impl->core->type.data.Id;
b->buffer.datas[j].type = t->data.Id;
b->buffer.datas[j].data = SPA_UINT32_TO_PTR(n_mem);
n_mem++;
} else if (d->type == impl->core->type.data.MemPtr) {
} else if (d->type == t->data.MemPtr) {
b->buffer.datas[j].data = SPA_INT_TO_PTR(b->size);
b->size += d->maxsize;
} else {
@ -716,7 +720,7 @@ spa_proxy_node_port_reuse_buffer(struct spa_node *node, uint32_t port_id, uint32
spa_log_trace(this->log, "reuse buffer %d", buffer_id);
{
struct pw_event_transport_reuse_buffer rb = PW_EVENT_TRANSPORT_REUSE_BUFFER_INIT
(impl->core->type.event_transport.ReuseBuffer, port_id, buffer_id);
(impl->t->event_transport.ReuseBuffer, port_id, buffer_id);
pw_transport_add_event(impl->transport, (struct spa_event *) &rb);
}
@ -763,7 +767,7 @@ static int spa_proxy_node_process_input(struct spa_node *node)
io->status = SPA_RESULT_NEED_BUFFER;
}
pw_transport_add_event(impl->transport,
&SPA_EVENT_INIT(impl->core->type.event_transport.ProcessInput));
&SPA_EVENT_INIT(impl->t->event_transport.ProcessInput));
do_flush(this);
if (this->callbacks->need_input)
@ -797,7 +801,7 @@ static int spa_proxy_node_process_output(struct spa_node *node)
pw_log_trace("%d %d %d", io->status, io->buffer_id, io->status);
}
pw_transport_add_event(impl->transport,
&SPA_EVENT_INIT(impl->core->type.event_transport.ProcessOutput));
&SPA_EVENT_INIT(impl->t->event_transport.ProcessOutput));
do_flush(this);
return res;
@ -808,7 +812,7 @@ static int handle_node_event(struct proxy *this, struct spa_event *event)
struct impl *impl = SPA_CONTAINER_OF(this, struct impl, proxy);
int i;
if (SPA_EVENT_TYPE(event) == impl->core->type.event_transport.HaveOutput) {
if (SPA_EVENT_TYPE(event) == impl->t->event_transport.HaveOutput) {
for (i = 0; i < MAX_OUTPUTS; i++) {
struct spa_port_io *io = this->out_ports[i].io;
@ -818,14 +822,14 @@ static int handle_node_event(struct proxy *this, struct spa_event *event)
*io = impl->transport->outputs[i];
pw_log_trace("%d %d", io->status, io->buffer_id);
}
this->callbacks->have_output(&this->node, this->user_data);
} else if (SPA_EVENT_TYPE(event) == impl->core->type.event_transport.NeedInput) {
this->callbacks->need_input(&this->node, this->user_data);
} else if (SPA_EVENT_TYPE(event) == impl->core->type.event_transport.ReuseBuffer) {
this->callbacks->have_output(this->callbacks_data);
} else if (SPA_EVENT_TYPE(event) == impl->t->event_transport.NeedInput) {
this->callbacks->need_input(this->callbacks_data);
} else if (SPA_EVENT_TYPE(event) == impl->t->event_transport.ReuseBuffer) {
struct pw_event_transport_reuse_buffer *p =
(struct pw_event_transport_reuse_buffer *) event;
this->callbacks->reuse_buffer(&this->node, p->body.port_id.value,
p->body.buffer_id.value, this->user_data);
this->callbacks->reuse_buffer(this->callbacks_data, p->body.port_id.value,
p->body.buffer_id.value);
}
return SPA_RESULT_OK;
}
@ -836,7 +840,7 @@ client_node_done(void *data, int seq, int res)
struct impl *impl = data;
struct proxy *this = &impl->proxy;
this->callbacks->done(&this->node, seq, res, this->user_data);
this->callbacks->done(this->callbacks_data, seq, res);
}
@ -895,7 +899,7 @@ static void client_node_event(void *data, struct spa_event *event)
{
struct impl *impl = data;
struct proxy *this = &impl->proxy;
this->callbacks->event(&this->node, event, this->user_data);
this->callbacks->event(this->callbacks_data, event);
}
static void client_node_destroy(void *data)
@ -1033,18 +1037,19 @@ static void node_initialized(void *data)
struct pw_node *node = this->node;
struct pw_transport_info info;
int readfd, writefd;
const struct pw_node_info *i = pw_node_get_info(node);
if (this->resource == NULL)
return;
impl->transport = pw_transport_new(node->info.max_input_ports, node->info.max_output_ports, 0);
impl->transport->area->n_input_ports = node->info.n_input_ports;
impl->transport->area->n_output_ports = node->info.n_output_ports;
impl->transport = pw_transport_new(i->max_input_ports, i->max_output_ports, 0);
impl->transport->area->n_input_ports = i->n_input_ports;
impl->transport->area->n_output_ports = i->n_output_ports;
client_node_get_fds(this, &readfd, &writefd);
pw_transport_get_info(impl->transport, &info);
pw_client_node_resource_transport(this->resource, node->global->id,
pw_client_node_resource_transport(this->resource, pw_global_get_id(pw_node_get_global(node)),
readfd, writefd, info.memfd, info.offset, info.size);
}
@ -1136,6 +1141,7 @@ struct pw_client_node *pw_client_node_new(struct pw_resource *resource,
this = &impl->this;
impl->core = core;
impl->t = pw_core_get_type(core);
impl->fds[0] = impl->fds[1] = -1;
pw_log_debug("client-node %p: new", impl);

View file

@ -54,6 +54,7 @@ struct client_info {
struct spa_list link;
struct pw_client *client;
bool is_sandboxed;
bool in_override;
const struct pw_core_proxy_methods *old_methods;
struct pw_core_proxy_methods core_methods;
struct spa_list async_pending;
@ -438,9 +439,20 @@ static void client_resource_impl(void *data, struct pw_resource *resource)
struct pw_client *client = cinfo->client;
if (resource->type == client->core->type.core) {
cinfo->old_methods = resource->implementation;
struct pw_listener *impl = pw_resource_get_implementation(resource);
if (cinfo->in_override)
return;
cinfo->old_methods = impl->events;
cinfo->core_methods = *cinfo->old_methods;
resource->implementation = &cinfo->core_methods;
cinfo->in_override = true;
pw_resource_set_implementation(resource,
&cinfo->core_methods,
impl->data);
cinfo->in_override = false;
resource->access_private = cinfo;
cinfo->core_methods.create_node = do_create_node;
cinfo->core_methods.create_link = do_create_link;

View file

@ -35,7 +35,6 @@
#include "config.h"
#include "pipewire/pipewire.h"
#include "pipewire/private.h"
#include "pipewire/log.h"
#include "pipewire/interfaces.h"
@ -79,6 +78,7 @@ struct socket {
struct impl {
struct pw_core *core;
struct pw_type *t;
struct pw_module *module;
struct spa_list link;
@ -107,7 +107,7 @@ static void client_destroy(void *data)
{
struct client *this = data;
pw_loop_destroy_source(this->impl->core->main_loop, this->source);
pw_loop_destroy_source(pw_core_get_main_loop(this->impl->core), this->source);
spa_list_remove(&this->link);
close(this->fd);
@ -224,6 +224,7 @@ handle_client_open(struct client *client)
char name[JACK_CLIENT_NAME_SIZE+1];
int result, ref_num, shared_engine, shared_client, shared_graph;
struct jack_client *jc;
const struct ucred *ucred;
CheckSize(kClientOpen_size);
CheckRead(&PID, sizeof(int));
@ -250,7 +251,9 @@ handle_client_open(struct client *client)
goto reply;
}
jc->control = jack_client_control_alloc(name, client->client->ucred.pid, ref_num, -1);
ucred = pw_client_get_ucred(client->client);
jc->control = jack_client_control_alloc(name, ucred ? ucred->pid : 0, ref_num, -1);
if (jc->control == NULL) {
result = -1;
goto reply;
@ -407,7 +410,7 @@ client_busy_changed(void *data, bool busy)
if (!busy)
mask |= SPA_IO_IN;
pw_loop_update_io(c->impl->core->main_loop, c->source, mask);
pw_loop_update_io(pw_core_get_main_loop(c->impl->core), c->source, mask);
if (!busy)
process_messages(c);
@ -450,14 +453,15 @@ static struct client *client_new(struct impl *impl, int fd)
ucredp = &ucred;
}
client = pw_client_new(impl->core, impl->module->global, ucredp, NULL, sizeof(struct client));
client = pw_client_new(impl->core, pw_module_get_global(impl->module),
ucredp, NULL, sizeof(struct client));
if (client == NULL)
goto no_client;
this = client->user_data;
this = pw_client_get_user_data(client);
this->impl = impl;
this->fd = fd;
this->source = pw_loop_add_io(impl->core->main_loop,
this->source = pw_loop_add_io(pw_core_get_main_loop(impl->core),
this->fd,
SPA_IO_ERR | SPA_IO_HUP, false, connection_data, this);
if (this->source == NULL)
@ -526,28 +530,35 @@ make_int_client(struct impl *impl, struct pw_node *node)
return 0;
}
static bool on_global(void *data, struct pw_global *global)
{
struct impl *impl = data;
struct pw_node *node;
struct pw_properties *properties;
const char *str;
if (pw_global_get_type(global) != impl->t->node)
return true;
node = pw_global_get_object(global);
properties = pw_node_get_properties(node);
if ((str = pw_properties_get(properties, "media.class")) == NULL)
return true;
if (strcmp(str, "Audio/Sink") != 0)
return true;
make_int_client(impl, node);
return true;
}
static bool init_nodes(struct impl *impl)
{
struct pw_core *core = impl->core;
struct pw_node *n;
spa_list_for_each(n, &core->node_list, link) {
const char *str;
if (n->global == NULL)
continue;
if (n->properties == NULL)
continue;
if ((str = pw_properties_get(n->properties, "media.class")) == NULL)
continue;
if (strcmp(str, "Audio/Sink") != 0)
continue;
make_int_client(impl, n);
}
pw_core_for_each_global(core, on_global, impl);
return true;
}
@ -626,7 +637,7 @@ socket_data(struct spa_loop_utils *utils,
return;
}
pw_loop_update_io(impl->core->main_loop,
pw_loop_update_io(pw_core_get_main_loop(impl->core),
client->source, SPA_IO_IN | SPA_IO_ERR | SPA_IO_HUP);
}
@ -648,7 +659,7 @@ static bool add_socket(struct impl *impl, struct socket *s)
return false;
}
s->loop = impl->core->main_loop;
s->loop = pw_core_get_main_loop(impl->core);
s->source = pw_loop_add_io(s->loop, s->fd, SPA_IO_IN, false, socket_data, impl);
if (s->source == NULL)
return false;
@ -701,7 +712,7 @@ static int init_server(struct impl *impl, const char *name, bool promiscuous)
static struct impl *module_init(struct pw_module *module, struct pw_properties *properties)
{
struct pw_core *core = module->core;
struct pw_core *core = pw_module_get_core(module);
struct impl *impl;
const char *name, *str;
bool promiscuous;
@ -710,6 +721,7 @@ static struct impl *module_init(struct pw_module *module, struct pw_properties *
pw_log_debug("protocol-jack %p: new", impl);
impl->core = core;
impl->t = pw_core_get_type(core);
impl->module = module;
impl->properties = properties;

View file

@ -25,7 +25,6 @@
#include "config.h"
#include "pipewire/core.h"
#include "pipewire/private.h"
#include "pipewire/module.h"
#include "modules/spa/spa-node.h"
@ -33,6 +32,7 @@
struct impl {
struct pw_core *core;
struct pw_type *t;
struct pw_module *module;
struct pw_properties *properties;
@ -92,26 +92,30 @@ static struct pw_node *make_node(struct impl *impl)
struct spa_node *spa_node;
struct spa_clock *spa_clock;
struct pw_node *node;
const struct spa_support *support;
uint32_t n_support;
support = pw_core_get_support(impl->core, &n_support);
handle = calloc(1, impl->factory->size);
if ((res = spa_handle_factory_init(impl->factory,
handle,
NULL, impl->core->support, impl->core->n_support)) < 0) {
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, impl->core->type.spa_node, &iface)) < 0) {
if ((res = spa_handle_get_interface(handle, impl->t->spa_node, &iface)) < 0) {
pw_log_error("can't get interface %d", res);
goto interface_failed;
}
spa_node = iface;
if ((res = spa_handle_get_interface(handle, impl->core->type.spa_clock, &iface)) < 0) {
if ((res = spa_handle_get_interface(handle, impl->t->spa_clock, &iface)) < 0) {
iface = NULL;
}
spa_clock = iface;
node = pw_spa_node_new(impl->core, NULL, impl->module->global,
node = pw_spa_node_new(impl->core, NULL, pw_module_get_global(impl->module),
"audiomixer", false, spa_node, spa_clock, NULL);
return node;
@ -123,53 +127,60 @@ static struct pw_node *make_node(struct impl *impl)
return NULL;
}
static bool on_global(void *data, struct pw_global *global)
{
struct impl *impl = data;
struct pw_node *n, *node;
struct pw_properties *properties;
const char *str;
char *error;
struct pw_port *ip, *op;
struct pw_link *link;
if (pw_global_get_type(global) != impl->t->node)
return true;
n = pw_global_get_object(global);
properties = pw_node_get_properties(n);
if ((str = pw_properties_get(properties, "media.class")) == NULL)
return true;
if (strcmp(str, "Audio/Sink") != 0)
return true;
if ((ip = pw_node_get_free_port(n, PW_DIRECTION_INPUT)) == NULL)
return true;
node = make_node(impl);
op = pw_node_get_free_port(node, PW_DIRECTION_OUTPUT);
if (op == NULL)
return true;
link = pw_link_new(impl->core, pw_module_get_global(impl->module), op, ip, NULL, NULL, &error);
pw_link_inc_idle(link);
return true;
}
static bool module_init(struct pw_module *module, struct pw_properties *properties)
{
struct pw_core *core = module->core;
struct pw_core *core = pw_module_get_core(module);
struct impl *impl;
struct pw_node *n;
impl = calloc(1, sizeof(struct impl));
pw_log_debug("module %p: new", impl);
impl->core = core;
impl->t = pw_core_get_type(core);
impl->module = module;
impl->properties = properties;
impl->factory = find_factory(impl);
spa_list_for_each(n, &core->node_list, link) {
const char *str;
char *error;
struct pw_node *node;
struct pw_port *ip, *op;
pw_core_for_each_global(core, on_global, impl);
if (n->global == NULL)
continue;
if (n->properties == NULL)
continue;
if ((str = pw_properties_get(n->properties, "media.class")) == NULL)
continue;
if (strcmp(str, "Audio/Sink") != 0)
continue;
if ((ip = pw_node_get_free_port(n, PW_DIRECTION_INPUT)) == NULL)
continue;
node = make_node(impl);
op = pw_node_get_free_port(node, PW_DIRECTION_OUTPUT);
if (op == NULL)
continue;
n->idle_used_input_links++;
node->idle_used_output_links++;
pw_link_new(core, module->global, op, ip, NULL, NULL, &error);
}
return impl;
return true;
}
#if 0

View file

@ -23,7 +23,6 @@
#include "spa/pod-iter.h"
#include "pipewire/pipewire.h"
#include "pipewire/private.h"
#include "pipewire/protocol.h"
#include "pipewire/interfaces.h"
#include "pipewire/resource.h"

View file

@ -25,7 +25,6 @@
#include "config.h"
#include "pipewire/interfaces.h"
#include "pipewire/private.h"
#include "pipewire/core.h"
#include "pipewire/module.h"
@ -70,17 +69,13 @@ static struct pw_node *create_node(void *_data,
no_properties:
pw_log_error("missing properties");
if (resource) {
pw_core_resource_error(resource->client->core_resource,
resource->client->core_resource->id,
SPA_RESULT_INVALID_ARGUMENTS, "missing properties");
pw_resource_error(resource, SPA_RESULT_INVALID_ARGUMENTS, "missing properties");
}
return NULL;
no_mem:
pw_log_error("can't create node");
if (resource) {
pw_core_resource_error(resource->client->core_resource,
resource->client->core_resource->id,
SPA_RESULT_NO_MEMORY, "no memory");
pw_resource_error(resource, SPA_RESULT_NO_MEMORY, "no memory");
}
return NULL;
}
@ -92,7 +87,7 @@ static const struct pw_node_factory_implementation impl_factory = {
static bool module_init(struct pw_module *module, struct pw_properties *properties)
{
struct pw_core *core = module->core;
struct pw_core *core = pw_module_get_core(module);
struct pw_node_factory *factory;
struct factory_data *data;
@ -110,7 +105,7 @@ static bool module_init(struct pw_module *module, struct pw_properties *properti
&impl_factory,
data);
pw_node_factory_export(factory, NULL, module->global);
pw_node_factory_export(factory, NULL, pw_module_get_global(module));
return true;
}

View file

@ -162,9 +162,9 @@ static void remove_item(struct pw_spa_monitor *this, struct spa_monitor_item *it
destroy_item(mitem);
}
static void on_monitor_event(struct spa_monitor *monitor, struct spa_event *event, void *user_data)
static void on_monitor_event(void *data, struct spa_event *event)
{
struct impl *impl = user_data;
struct impl *impl = data;
struct pw_spa_monitor *this = &impl->this;
struct pw_type *t = pw_core_get_type(impl->core);
@ -213,7 +213,7 @@ static void update_monitor(struct pw_core *core, const char *name)
static const struct spa_monitor_callbacks callbacks = {
SPA_VERSION_MONITOR_CALLBACKS,
on_monitor_event,
.event = on_monitor_event,
};
struct pw_spa_monitor *pw_spa_monitor_load(struct pw_core *core,

View file

@ -326,9 +326,9 @@ static void complete_init(struct impl *impl)
pw_node_register(this);
}
static void on_node_done(struct spa_node *node, int seq, int res, void *user_data)
static void on_node_done(void *data, int seq, int res)
{
struct impl *impl = user_data;
struct impl *impl = data;
struct pw_node *this = impl->this;
if (impl->async_init) {
@ -340,32 +340,32 @@ static void on_node_done(struct spa_node *node, int seq, int res, void *user_dat
pw_listener_list_emit(&this->listener_list, struct pw_node_events, async_complete, seq, res);
}
static void on_node_event(struct spa_node *node, struct spa_event *event, void *user_data)
static void on_node_event(void *data, struct spa_event *event)
{
struct impl *impl = user_data;
struct impl *impl = data;
struct pw_node *this = impl->this;
pw_listener_list_emit(&this->listener_list, struct pw_node_events, event, event);
}
static void on_node_need_input(struct spa_node *node, void *user_data)
static void on_node_need_input(void *data)
{
struct impl *impl = user_data;
struct impl *impl = data;
struct pw_node *this = impl->this;
pw_listener_list_emit_na(&this->listener_list, struct pw_node_events, need_input);
}
static void on_node_have_output(struct spa_node *node, void *user_data)
static void on_node_have_output(void *data)
{
struct impl *impl = user_data;
struct impl *impl = data;
struct pw_node *this = impl->this;
pw_listener_list_emit_na(&this->listener_list, struct pw_node_events, have_output);
}
static void
on_node_reuse_buffer(struct spa_node *node, uint32_t port_id, uint32_t buffer_id, void *user_data)
on_node_reuse_buffer(void *data, uint32_t port_id, uint32_t buffer_id)
{
struct impl *impl = user_data;
struct impl *impl = data;
struct pw_node *this = impl->this;
struct spa_graph_port *p, *pp;
@ -374,8 +374,8 @@ on_node_reuse_buffer(struct spa_node *node, uint32_t port_id, uint32_t buffer_id
continue;
pp = p->peer;
if (pp && pp->methods->reuse_buffer)
pp->methods->reuse_buffer(pp, buffer_id, pp->user_data);
if (pp && pp->callbacks->reuse_buffer)
pp->callbacks->reuse_buffer(pp->callbacks_data, buffer_id);
break;
}