diff --git a/spa/plugins/audioconvert/fmtconvert.c b/spa/plugins/audioconvert/fmtconvert.c index 283aa0cbf..3b40bdff1 100644 --- a/spa/plugins/audioconvert/fmtconvert.c +++ b/spa/plugins/audioconvert/fmtconvert.c @@ -141,13 +141,9 @@ struct impl { bool started; - const struct buffer *src; - const struct conv_info *conv[2]; convert_func_t convert; - - uint8_t temp[8192]; }; #define CHECK_PORT(this,d,id) (id == 0) @@ -606,7 +602,8 @@ static int port_set_format(struct spa_node *node, if (other->have_format) res = setup_convert(this); - spa_log_info(this->log, NAME " %p: set format on port %d %d", this, port_id, res); + spa_log_info(this->log, NAME " %p: set format on port %d %d %d %d", + this, port_id, res, port->stride, other->stride); } return res; } @@ -845,6 +842,9 @@ static int impl_node_process(struct spa_node *node) db->datas[i].chunk->size = (n_bytes / inport->stride) * outport->stride; } + spa_log_trace(this->log, NAME " %p: %d %d %d %d", this, + n_src_datas, n_dst_datas, n_bytes, inport->offset); + this->convert(this, n_dst_datas, dst_datas, n_src_datas, src_datas, n_bytes); inport->offset += n_bytes; diff --git a/src/modules/meson.build b/src/modules/meson.build index d931573f3..42dec14c5 100644 --- a/src/modules/meson.build +++ b/src/modules/meson.build @@ -48,7 +48,6 @@ pipewire_module_client_node = shared_library('pipewire-module-client-node', [ 'module-client-node.c', 'module-client-node/client-node.c', 'module-client-node/protocol-native.c', - 'module-protocol-native/connection.c', 'spa/spa-node.c', ], c_args : pipewire_module_c_args, include_directories : [configinc, spa_inc], diff --git a/src/modules/module-client-node/client-node.c b/src/modules/module-client-node/client-node.c index 38b7ced59..4d7036389 100644 --- a/src/modules/module-client-node/client-node.c +++ b/src/modules/module-client-node/client-node.c @@ -317,14 +317,6 @@ static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flag return SPA_RESULT_RETURN_ASYNC(this->seq++); } -static inline void send_process(struct node *this) -{ - uint64_t cmd = 1; - pw_log_trace("client-node %p: send process", this); - if (write(this->writefd, &cmd, 8) != 8) - spa_log_warn(this->log, "node %p: error %s", this, strerror(errno)); -} - static int impl_node_send_command(struct spa_node *node, const struct spa_command *command) { struct node *this; @@ -895,8 +887,13 @@ impl_node_port_send_command(struct spa_node *node, static int impl_node_process(struct spa_node *node) { struct node *this = SPA_CONTAINER_OF(node, struct node, node); - spa_log_trace(this->log, "%p: process", this); - send_process(this); + uint64_t cmd = 1; + + spa_log_trace(this->log, "%p: send process", this); + + if (write(this->writefd, &cmd, 8) != 8) + spa_log_warn(this->log, "node %p: error %s", this, strerror(errno)); + return SPA_STATUS_OK; } @@ -1137,6 +1134,8 @@ static void node_initialized(void *data) struct pw_client_node *this = &impl->this; struct pw_node *node = this->node; struct pw_type *t = impl->t; + struct pw_global *global; + uint32_t node_id; if (this->resource == NULL) return; @@ -1161,8 +1160,13 @@ static void node_initialized(void *data) ensure_mem(impl, impl->io_areas->fd, t->data.MemFd, impl->io_areas->flags); pw_log_debug("client-node %p: io areas %p", node, impl->io_areas->ptr); + if ((global = pw_node_get_global(node)) != NULL) + node_id = pw_global_get_id(global); + else + node_id = SPA_ID_INVALID; + pw_client_node_resource_transport(this->resource, - pw_global_get_id(pw_node_get_global(node)), + node_id, impl->other_fds[0], impl->other_fds[1]); } diff --git a/src/pipewire/link.c b/src/pipewire/link.c index 9e540dd78..e72cf9aca 100644 --- a/src/pipewire/link.c +++ b/src/pipewire/link.c @@ -1259,7 +1259,7 @@ struct pw_link *pw_link_new(struct pw_core *core, this->info.format = NULL; this->info.props = this->properties ? &this->properties->dict : NULL; - impl->io = SPA_IO_BUFFERS_INIT; + impl->io.buffer_id = SPA_ID_INVALID; impl->io.status = SPA_STATUS_NEED_BUFFER; pw_port_init_mix(output, &this->rt.mix[SPA_DIRECTION_OUTPUT]); diff --git a/src/pipewire/node.c b/src/pipewire/node.c index e66187a09..40afc814d 100644 --- a/src/pipewire/node.c +++ b/src/pipewire/node.c @@ -165,6 +165,7 @@ static void update_port_map(struct pw_node *node, enum pw_direction direction, uint32_t o, n; size_t os, ns; struct pw_port *port; + int res; o = n = 0; os = pw_map_get_size(portmap); @@ -187,8 +188,13 @@ static void update_port_map(struct pw_node *node, enum pw_direction direction, pw_direction_as_string(direction), ids[n]); if (port == NULL) { - if ((port = pw_port_new(direction, ids[n], NULL, 0))) - pw_port_add(port, node); + if ((port = pw_port_new(direction, ids[n], NULL, 0))) { + if ((res = pw_port_add(port, node)) < 0) { + pw_log_error("node %p: can't add port %p: %d, %s", + node, port, res, spa_strerror(res)); + pw_port_destroy(port); + } + } o = ids[n] + 1; os++; } @@ -238,7 +244,7 @@ int pw_node_update_ports(struct pw_node *node) if (res < 0) return res; - pw_log_debug("node %p: update_port ids %u/%u, %u/%u", node, + pw_log_debug("node %p: update_port ids input %u/%u, outputs %u/%u", node, n_input_ports, max_input_ports, n_output_ports, max_output_ports); update_port_map(node, PW_DIRECTION_INPUT, &node->input_port_map, input_port_ids, n_input_ports); @@ -798,6 +804,7 @@ struct pw_port *pw_node_get_free_port(struct pw_node *node, enum pw_direction di struct spa_list *ports; struct pw_port *port = NULL, *p, *mixport = NULL; struct pw_map *portmap; + int res; if (direction == PW_DIRECTION_INPUT) { max_ports = node->info.max_input_ports; @@ -828,18 +835,19 @@ struct pw_port *pw_node_get_free_port(struct pw_node *node, enum pw_direction di /* no port, can we create one ? */ if (n_ports < max_ports) { uint32_t port_id = pw_map_insert_new(portmap, NULL); - int res; pw_log_debug("node %p: creating port direction %d %u", node, direction, port_id); if ((res = spa_node_add_port(node->node, direction, port_id)) < 0) { - pw_log_error("node %p: could not add port %d %s", node, port_id, spa_strerror(res)); + pw_log_error("node %p: could not add port %d %s", node, port_id, + spa_strerror(res)); goto no_mem; } port = pw_port_new(direction, port_id, NULL, 0); if (port == NULL) goto no_mem; - pw_port_add(port, node); + if ((res = pw_port_add(port, node)) < 0) + goto add_failed; } else { port = mixport; } @@ -850,6 +858,10 @@ struct pw_port *pw_node_get_free_port(struct pw_node *node, enum pw_direction di no_mem: pw_log_error("node %p: can't create new port", node); return NULL; + add_failed: + pw_log_error("node %p: can't add new port: %s", node, spa_strerror(res)); + pw_port_destroy(port); + return NULL; } static void on_state_complete(struct pw_node *node, void *data, int res) diff --git a/src/pipewire/pipewire.c b/src/pipewire/pipewire.c index 2de855af6..d07c5f4fe 100644 --- a/src/pipewire/pipewire.c +++ b/src/pipewire/pipewire.c @@ -36,7 +36,7 @@ static char **categories = NULL; -static struct support_info { +static struct plugin_info { void *hnd; spa_handle_factory_enum_func_t enum_func; struct spa_support support[16]; @@ -44,9 +44,9 @@ static struct support_info { } support_info; static bool -open_support(const char *path, - const char *lib, - struct support_info *info) +open_plugin(const char *path, + const char *lib, + struct plugin_info *info) { char *filename; @@ -73,7 +73,7 @@ open_support(const char *path, return false; } -static const struct spa_handle_factory *get_factory(struct support_info *info, const char *factory_name) +static const struct spa_handle_factory *get_factory(struct plugin_info *info, const char *factory_name) { int res; uint32_t index; @@ -92,7 +92,7 @@ static const struct spa_handle_factory *get_factory(struct support_info *info, c } static void * -load_interface(struct support_info *info, +load_interface(struct plugin_info *info, const char *factory_name, const char *type) { @@ -173,7 +173,7 @@ const struct spa_support *pw_get_support(uint32_t *n_support) void *pw_load_spa_interface(const char *lib, const char *factory_name, const char *type, struct spa_support *support, uint32_t n_support) { - struct support_info extra_support_info; + struct plugin_info extra_support_info; const char *str; int i; @@ -190,7 +190,7 @@ void *pw_load_spa_interface(const char *lib, const char *factory_name, const cha pw_log_debug("load \"%s\", \"%s\"", lib, factory_name); - if (open_support(str, lib, &extra_support_info)) + if (open_plugin(str, lib, &extra_support_info)) return load_interface(&extra_support_info, factory_name, type); return NULL; @@ -220,7 +220,7 @@ void pw_init(int *argc, char **argv[]) { const char *str; void *iface; - struct support_info *info = &support_info; + struct plugin_info *info = &support_info; if ((str = getenv("PIPEWIRE_DEBUG"))) configure_debug(str); @@ -231,7 +231,7 @@ void pw_init(int *argc, char **argv[]) if (support_info.n_support > 0) return; - if (open_support(str, "support/libspa-support", info)) { + if (open_plugin(str, "support/libspa-support", info)) { iface = load_interface(info, "mapper", SPA_TYPE__TypeMap); if (iface != NULL) info->support[info->n_support++] = SPA_SUPPORT_INIT(SPA_TYPE__TypeMap, iface); diff --git a/src/pipewire/port.c b/src/pipewire/port.c index 30ea71ea9..25ccdb4da 100644 --- a/src/pipewire/port.c +++ b/src/pipewire/port.c @@ -430,15 +430,17 @@ int pw_port_add(struct pw_port *port, struct pw_node *node) struct pw_core *core = node->core; struct pw_type *t = &core->type; const char *str, *dir; + int res; if (port->node != NULL) return -EEXIST; - port->node = node; - - spa_node_port_get_info(node->node, + if ((res = spa_node_port_get_info(node->node, port->direction, port_id, - &port->spa_info); + &port->spa_info)) < 0) + return res; + + port->node = node; if (port->spa_info->props) pw_port_update_properties(port, port->spa_info->props); diff --git a/src/pipewire/stream.c b/src/pipewire/stream.c index 6670b8ff6..d7112fcdc 100644 --- a/src/pipewire/stream.c +++ b/src/pipewire/stream.c @@ -41,6 +41,7 @@ #define MAX_BUFFERS 64 #define MASK_BUFFERS (MAX_BUFFERS-1) +#define MAX_PORTS 1 struct type { uint32_t client_node; @@ -179,8 +180,10 @@ static int configure_converter(struct stream *impl) param = impl->init_params[i]; if (spa_pod_is_object_type(param, t->spa_format)) { - if (spa_pod_filter(&b, &filtered, impl->format, param) >= 0) + if (spa_pod_filter(&b, &filtered, impl->format, param) >= 0) { + pw_log_debug("stream %p: format matches filter", impl); return 0; + } } } @@ -341,12 +344,14 @@ static int impl_get_n_ports(struct spa_node *node, { struct stream *d = SPA_CONTAINER_OF(node, struct stream, impl_node); if (d->direction == SPA_DIRECTION_INPUT) { - *n_input_ports = *max_input_ports = 1; + *n_input_ports = 1; + *max_input_ports = MAX_PORTS; *n_output_ports = *max_output_ports = 0; } else { *n_input_ports = *max_input_ports = 0; - *n_output_ports = *max_output_ports = 1; + *n_output_ports = 1; + *max_output_ports = MAX_PORTS; } return 0; } @@ -484,7 +489,6 @@ static int port_set_format(struct spa_node *node, else impl->format = NULL; - if ((res = configure_converter(impl)) < 0) { pw_stream_finish_format(stream, res, NULL, 0); return res;