small cleanups

This commit is contained in:
Wim Taymans 2018-04-13 19:57:34 +02:00
parent 03b914405d
commit f4f2e4bf68
8 changed files with 63 additions and 42 deletions

View file

@ -141,13 +141,9 @@ struct impl {
bool started; bool started;
const struct buffer *src;
const struct conv_info *conv[2]; const struct conv_info *conv[2];
convert_func_t convert; convert_func_t convert;
uint8_t temp[8192];
}; };
#define CHECK_PORT(this,d,id) (id == 0) #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) if (other->have_format)
res = setup_convert(this); 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; 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; 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); this->convert(this, n_dst_datas, dst_datas, n_src_datas, src_datas, n_bytes);
inport->offset += n_bytes; inport->offset += n_bytes;

View file

@ -48,7 +48,6 @@ pipewire_module_client_node = shared_library('pipewire-module-client-node',
[ 'module-client-node.c', [ 'module-client-node.c',
'module-client-node/client-node.c', 'module-client-node/client-node.c',
'module-client-node/protocol-native.c', 'module-client-node/protocol-native.c',
'module-protocol-native/connection.c',
'spa/spa-node.c', ], 'spa/spa-node.c', ],
c_args : pipewire_module_c_args, c_args : pipewire_module_c_args,
include_directories : [configinc, spa_inc], include_directories : [configinc, spa_inc],

View file

@ -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++); 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) static int impl_node_send_command(struct spa_node *node, const struct spa_command *command)
{ {
struct node *this; 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) static int impl_node_process(struct spa_node *node)
{ {
struct node *this = SPA_CONTAINER_OF(node, struct node, node); struct node *this = SPA_CONTAINER_OF(node, struct node, node);
spa_log_trace(this->log, "%p: process", this); uint64_t cmd = 1;
send_process(this);
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; return SPA_STATUS_OK;
} }
@ -1137,6 +1134,8 @@ static void node_initialized(void *data)
struct pw_client_node *this = &impl->this; struct pw_client_node *this = &impl->this;
struct pw_node *node = this->node; struct pw_node *node = this->node;
struct pw_type *t = impl->t; struct pw_type *t = impl->t;
struct pw_global *global;
uint32_t node_id;
if (this->resource == NULL) if (this->resource == NULL)
return; 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); 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); 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_client_node_resource_transport(this->resource,
pw_global_get_id(pw_node_get_global(node)), node_id,
impl->other_fds[0], impl->other_fds[0],
impl->other_fds[1]); impl->other_fds[1]);
} }

View file

@ -1259,7 +1259,7 @@ struct pw_link *pw_link_new(struct pw_core *core,
this->info.format = NULL; this->info.format = NULL;
this->info.props = this->properties ? &this->properties->dict : 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; impl->io.status = SPA_STATUS_NEED_BUFFER;
pw_port_init_mix(output, &this->rt.mix[SPA_DIRECTION_OUTPUT]); pw_port_init_mix(output, &this->rt.mix[SPA_DIRECTION_OUTPUT]);

View file

@ -165,6 +165,7 @@ static void update_port_map(struct pw_node *node, enum pw_direction direction,
uint32_t o, n; uint32_t o, n;
size_t os, ns; size_t os, ns;
struct pw_port *port; struct pw_port *port;
int res;
o = n = 0; o = n = 0;
os = pw_map_get_size(portmap); 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]); pw_direction_as_string(direction), ids[n]);
if (port == NULL) { if (port == NULL) {
if ((port = pw_port_new(direction, ids[n], NULL, 0))) if ((port = pw_port_new(direction, ids[n], NULL, 0))) {
pw_port_add(port, node); 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; o = ids[n] + 1;
os++; os++;
} }
@ -238,7 +244,7 @@ int pw_node_update_ports(struct pw_node *node)
if (res < 0) if (res < 0)
return res; 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); 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); 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 spa_list *ports;
struct pw_port *port = NULL, *p, *mixport = NULL; struct pw_port *port = NULL, *p, *mixport = NULL;
struct pw_map *portmap; struct pw_map *portmap;
int res;
if (direction == PW_DIRECTION_INPUT) { if (direction == PW_DIRECTION_INPUT) {
max_ports = node->info.max_input_ports; 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 ? */ /* no port, can we create one ? */
if (n_ports < max_ports) { if (n_ports < max_ports) {
uint32_t port_id = pw_map_insert_new(portmap, NULL); 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); 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) { 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; goto no_mem;
} }
port = pw_port_new(direction, port_id, NULL, 0); port = pw_port_new(direction, port_id, NULL, 0);
if (port == NULL) if (port == NULL)
goto no_mem; goto no_mem;
pw_port_add(port, node); if ((res = pw_port_add(port, node)) < 0)
goto add_failed;
} else { } else {
port = mixport; port = mixport;
} }
@ -850,6 +858,10 @@ struct pw_port *pw_node_get_free_port(struct pw_node *node, enum pw_direction di
no_mem: no_mem:
pw_log_error("node %p: can't create new port", node); pw_log_error("node %p: can't create new port", node);
return NULL; 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) static void on_state_complete(struct pw_node *node, void *data, int res)

View file

@ -36,7 +36,7 @@
static char **categories = NULL; static char **categories = NULL;
static struct support_info { static struct plugin_info {
void *hnd; void *hnd;
spa_handle_factory_enum_func_t enum_func; spa_handle_factory_enum_func_t enum_func;
struct spa_support support[16]; struct spa_support support[16];
@ -44,9 +44,9 @@ static struct support_info {
} support_info; } support_info;
static bool static bool
open_support(const char *path, open_plugin(const char *path,
const char *lib, const char *lib,
struct support_info *info) struct plugin_info *info)
{ {
char *filename; char *filename;
@ -73,7 +73,7 @@ open_support(const char *path,
return false; 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; int res;
uint32_t index; uint32_t index;
@ -92,7 +92,7 @@ static const struct spa_handle_factory *get_factory(struct support_info *info, c
} }
static void * static void *
load_interface(struct support_info *info, load_interface(struct plugin_info *info,
const char *factory_name, const char *factory_name,
const char *type) 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, void *pw_load_spa_interface(const char *lib, const char *factory_name, const char *type,
struct spa_support *support, uint32_t n_support) struct spa_support *support, uint32_t n_support)
{ {
struct support_info extra_support_info; struct plugin_info extra_support_info;
const char *str; const char *str;
int i; 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); 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 load_interface(&extra_support_info, factory_name, type);
return NULL; return NULL;
@ -220,7 +220,7 @@ void pw_init(int *argc, char **argv[])
{ {
const char *str; const char *str;
void *iface; void *iface;
struct support_info *info = &support_info; struct plugin_info *info = &support_info;
if ((str = getenv("PIPEWIRE_DEBUG"))) if ((str = getenv("PIPEWIRE_DEBUG")))
configure_debug(str); configure_debug(str);
@ -231,7 +231,7 @@ void pw_init(int *argc, char **argv[])
if (support_info.n_support > 0) if (support_info.n_support > 0)
return; 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); iface = load_interface(info, "mapper", SPA_TYPE__TypeMap);
if (iface != NULL) if (iface != NULL)
info->support[info->n_support++] = SPA_SUPPORT_INIT(SPA_TYPE__TypeMap, iface); info->support[info->n_support++] = SPA_SUPPORT_INIT(SPA_TYPE__TypeMap, iface);

View file

@ -430,15 +430,17 @@ int pw_port_add(struct pw_port *port, struct pw_node *node)
struct pw_core *core = node->core; struct pw_core *core = node->core;
struct pw_type *t = &core->type; struct pw_type *t = &core->type;
const char *str, *dir; const char *str, *dir;
int res;
if (port->node != NULL) if (port->node != NULL)
return -EEXIST; return -EEXIST;
port->node = node; if ((res = spa_node_port_get_info(node->node,
spa_node_port_get_info(node->node,
port->direction, port_id, port->direction, port_id,
&port->spa_info); &port->spa_info)) < 0)
return res;
port->node = node;
if (port->spa_info->props) if (port->spa_info->props)
pw_port_update_properties(port, port->spa_info->props); pw_port_update_properties(port, port->spa_info->props);

View file

@ -41,6 +41,7 @@
#define MAX_BUFFERS 64 #define MAX_BUFFERS 64
#define MASK_BUFFERS (MAX_BUFFERS-1) #define MASK_BUFFERS (MAX_BUFFERS-1)
#define MAX_PORTS 1
struct type { struct type {
uint32_t client_node; uint32_t client_node;
@ -179,8 +180,10 @@ static int configure_converter(struct stream *impl)
param = impl->init_params[i]; param = impl->init_params[i];
if (spa_pod_is_object_type(param, t->spa_format)) { 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; 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); struct stream *d = SPA_CONTAINER_OF(node, struct stream, impl_node);
if (d->direction == SPA_DIRECTION_INPUT) { 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; *n_output_ports = *max_output_ports = 0;
} }
else { else {
*n_input_ports = *max_input_ports = 0; *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; return 0;
} }
@ -484,7 +489,6 @@ static int port_set_format(struct spa_node *node,
else else
impl->format = NULL; impl->format = NULL;
if ((res = configure_converter(impl)) < 0) { if ((res = configure_converter(impl)) < 0) {
pw_stream_finish_format(stream, res, NULL, 0); pw_stream_finish_format(stream, res, NULL, 0);
return res; return res;