From 6d79ce25891e2df7958f2546e1952db3a039343b Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 10 May 2018 11:23:51 +0200 Subject: [PATCH] small cleanups --- spa/include/spa/node/node.h | 11 ++-- spa/plugins/alsa/alsa-sink.c | 4 +- spa/plugins/alsa/alsa-utils.c | 4 +- spa/plugins/audioconvert/audioconvert.c | 4 +- spa/plugins/audioconvert/fmtconvert.c | 8 +-- spa/plugins/audioconvert/splitter.c | 55 ++++++------------- src/modules/module-audio-session.c | 4 +- src/modules/module-audio-session/audio-dsp.c | 4 +- src/modules/module-client-node/client-node.c | 14 ++--- .../module-client-node/client-stream.c | 6 +- src/pipewire/remote.c | 2 +- src/pipewire/stream.c | 2 +- 12 files changed, 46 insertions(+), 72 deletions(-) diff --git a/spa/include/spa/node/node.h b/spa/include/spa/node/node.h index a36eb6ea4..b76ae09c5 100644 --- a/spa/include/spa/node/node.h +++ b/spa/include/spa/node/node.h @@ -118,9 +118,6 @@ enum spa_node_param_flags { /** * A spa_node is a component that can consume and produce buffers. - * - * - * */ struct spa_node { /* the version of this node. This can be used to expand this @@ -477,11 +474,11 @@ struct spa_node { * Input areas with SPA_STATUS_HAVE_BUFFER are consumed if possible * and the status is set to SPA_STATUS_NEED_BUFFER or SPA_STATUS_OK. * - * When the node has new output buffers, SPA_STATUS_HAVE_BUFFER - * is returned. + * When the node has new output buffers, the SPA_STATUS_HAVE_BUFFER + * bit will be set. * - * When no new output could be produced, SPA_STATUS_NEED_BUFFER is - * returned. + * When the node can accept new input in the next cycle, the + * SPA_STATUS_NEED_BUFFER bit will be set. */ int (*process) (struct spa_node *node); }; diff --git a/spa/plugins/alsa/alsa-sink.c b/spa/plugins/alsa/alsa-sink.c index 9ee9ef6f9..284d11560 100644 --- a/spa/plugins/alsa/alsa-sink.c +++ b/spa/plugins/alsa/alsa-sink.c @@ -404,7 +404,7 @@ static int port_set_format(struct spa_node *node, int err; if (format == NULL) { - spa_log_info(this->log, "clear format"); + spa_log_debug(this->log, "clear format"); spa_alsa_pause(this, false); clear_buffers(this); spa_alsa_close(this); @@ -475,7 +475,7 @@ impl_node_port_use_buffers(struct spa_node *node, spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL); - spa_log_info(this->log, "use buffers %d", n_buffers); + spa_log_debug(this->log, "use buffers %d", n_buffers); if (!this->have_format) return -EIO; diff --git a/spa/plugins/alsa/alsa-utils.c b/spa/plugins/alsa/alsa-utils.c index ae404c7ff..e6b469165 100644 --- a/spa/plugins/alsa/alsa-utils.c +++ b/spa/plugins/alsa/alsa-utils.c @@ -273,7 +273,7 @@ int spa_alsa_set_format(struct state *state, struct spa_audio_info *fmt, uint32_ rchannels = info->channels; CHECK(snd_pcm_hw_params_set_channels_near(hndl, params, &rchannels), "set_channels"); if (rchannels != info->channels) { - spa_log_info(state->log, "Channels doesn't match (requested %u, get %u", info->channels, rchannels); + spa_log_warn(state->log, "Channels doesn't match (requested %u, get %u", info->channels, rchannels); if (flags & SPA_NODE_PARAM_FLAG_NEAREST) info->channels = rchannels; else @@ -284,7 +284,7 @@ int spa_alsa_set_format(struct state *state, struct spa_audio_info *fmt, uint32_ rrate = info->rate; CHECK(snd_pcm_hw_params_set_rate_near(hndl, params, &rrate, 0), "set_rate_near"); if (rrate != info->rate) { - spa_log_info(state->log, "Rate doesn't match (requested %iHz, get %iHz)", info->rate, rrate); + spa_log_warn(state->log, "Rate doesn't match (requested %iHz, get %iHz)", info->rate, rrate); if (flags & SPA_NODE_PARAM_FLAG_NEAREST) info->rate = rrate; else diff --git a/spa/plugins/audioconvert/audioconvert.c b/spa/plugins/audioconvert/audioconvert.c index d3916b1df..de70b0601 100644 --- a/spa/plugins/audioconvert/audioconvert.c +++ b/spa/plugins/audioconvert/audioconvert.c @@ -457,7 +457,7 @@ static int setup_buffers(struct impl *this, enum spa_direction direction) { int i, res; - spa_log_info(this->log, NAME " %p: %d", this, direction); + spa_log_debug(this->log, NAME " %p: %d", this, direction); if (direction == SPA_DIRECTION_INPUT) { for (i = 1; i < this->n_links-1; i++) { @@ -656,7 +656,7 @@ 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_debug(this->log, NAME " %p: set format on port %d %d", this, port_id, res); } return res; } diff --git a/spa/plugins/audioconvert/fmtconvert.c b/spa/plugins/audioconvert/fmtconvert.c index f1a40e929..dd5f8b916 100644 --- a/spa/plugins/audioconvert/fmtconvert.c +++ b/spa/plugins/audioconvert/fmtconvert.c @@ -163,7 +163,7 @@ static int setup_convert(struct impl *this) src_fmt = inport->format.info.raw.format; dst_fmt = outport->format.info.raw.format; - spa_log_info(this->log, NAME " %p: %s/%d@%d.%d->%s/%d@%d.%d", this, + spa_log_debug(this->log, NAME " %p: %s/%d@%d.%d->%s/%d@%d.%d", this, spa_type_map_get_type(this->map, src_fmt), inport->format.info.raw.channels, inport->format.info.raw.rate, @@ -545,7 +545,7 @@ static int calc_width(struct spa_audio_info *info, struct type *t) static int clear_buffers(struct impl *this, struct port *port) { if (port->n_buffers > 0) { - spa_log_info(this->log, NAME " %p: clear buffers %p", this, port); + spa_log_debug(this->log, NAME " %p: clear buffers %p", this, port); port->n_buffers = 0; spa_list_init(&port->queue); } @@ -602,7 +602,7 @@ 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 %d %d", + spa_log_debug(this->log, NAME " %p: set format on port %d %d %d %d", this, port_id, res, port->stride, other->stride); } return res; @@ -654,7 +654,7 @@ impl_node_port_use_buffers(struct spa_node *node, spa_return_val_if_fail(port->have_format, -EIO); - spa_log_info(this->log, NAME " %p: use buffers %d on port %d", this, n_buffers, port_id); + spa_log_debug(this->log, NAME " %p: use buffers %d on port %d", this, n_buffers, port_id); clear_buffers(this, port); diff --git a/spa/plugins/audioconvert/splitter.c b/spa/plugins/audioconvert/splitter.c index 007ff9f72..79f8377aa 100644 --- a/spa/plugins/audioconvert/splitter.c +++ b/spa/plugins/audioconvert/splitter.c @@ -39,16 +39,9 @@ #define MAX_BUFFERS 64 #define MAX_PORTS 128 -#define PORT_DEFAULT_VOLUME 1.0 -#define PORT_DEFAULT_MUTE false - struct type { uint32_t node; uint32_t format; - uint32_t prop_volume; - uint32_t prop_mute; - uint32_t io_prop_volume; - uint32_t io_prop_mute; struct spa_type_io io; struct spa_type_param param; struct spa_type_media_type media_type; @@ -67,10 +60,6 @@ static inline void init_type(struct type *type, struct spa_type_map *map) { type->node = spa_type_map_get_id(map, SPA_TYPE__Node); type->format = spa_type_map_get_id(map, SPA_TYPE__Format); - type->prop_volume = spa_type_map_get_id(map, SPA_TYPE_PROPS__volume); - type->prop_mute = spa_type_map_get_id(map, SPA_TYPE_PROPS__mute); - type->io_prop_volume = spa_type_map_get_id(map, SPA_TYPE_IO_PROP_BASE "volume"); - type->io_prop_mute = spa_type_map_get_id(map, SPA_TYPE_IO_PROP_BASE "mute"); spa_type_io_map(map, &type->io); spa_type_param_map(map, &type->param); spa_type_media_type_map(map, &type->media_type); @@ -85,17 +74,6 @@ static inline void init_type(struct type *type, struct spa_type_map *map) spa_type_param_io_map(map, &type->param_io); } -struct port_props { - double volume; - int32_t mute; -}; - -static void port_props_reset(struct port_props *props) -{ - props->volume = PORT_DEFAULT_VOLUME; - props->mute = PORT_DEFAULT_MUTE; -} - struct buffer { #define BUFFER_FLAG_QUEUED (1<<0) uint32_t flags; @@ -107,11 +85,8 @@ struct port { bool valid; uint32_t id; - struct port_props props; - struct spa_io_buffers *io; - double *io_volume; - int32_t *io_mute; + struct spa_io_control_range *ctrl; struct spa_port_info info; struct spa_dict info_props; @@ -277,10 +252,6 @@ static int impl_node_add_port(struct spa_node *node, enum spa_direction directio port->valid = true; port->id = port_id; - port_props_reset(&port->props); - port->io_volume = &port->props.volume; - port->io_mute = &port->props.mute; - spa_list_init(&port->queue); port->info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS | SPA_PORT_INFO_FLAG_REMOVABLE; @@ -293,7 +264,7 @@ static int impl_node_add_port(struct spa_node *node, enum spa_direction directio if (this->last_port <= port_id) this->last_port = port_id + 1; - spa_log_info(this->log, NAME " %p: add port %d %d", this, port_id, this->have_format); + spa_log_debug(this->log, NAME " %p: add port %d %d", this, port_id, this->have_format); return 0; } @@ -328,7 +299,7 @@ impl_node_remove_port(struct spa_node *node, enum spa_direction direction, uint3 this->last_port = i + 1; } - spa_log_info(this->log, NAME " %p: remove port %d", this, port_id); + spa_log_debug(this->log, NAME " %p: remove port %d", this, port_id); return 0; } @@ -457,7 +428,7 @@ impl_node_port_enum_params(struct spa_node *node, next: spa_pod_builder_init(&b, buffer, sizeof(buffer)); - spa_log_info(this->log, NAME " %p: enum param %d %d", this, id, this->have_format); + spa_log_debug(this->log, NAME " %p: enum param %d %d", this, id, this->have_format); if (id == t->param.idList) { uint32_t list[] = { t->param.idEnumFormat, @@ -544,7 +515,7 @@ impl_node_port_enum_params(struct spa_node *node, static int clear_buffers(struct impl *this, struct port *port) { if (port->n_buffers > 0) { - spa_log_info(this->log, NAME " %p: clear buffers %p", this, port); + spa_log_debug(this->log, NAME " %p: clear buffers %p", this, port); port->n_buffers = 0; spa_list_init(&port->queue); } @@ -563,7 +534,7 @@ static int port_set_format(struct spa_node *node, port = GET_PORT(this, direction, port_id); - spa_log_info(this->log, NAME " %p: set format %d", this, this->have_format); + spa_log_debug(this->log, NAME " %p: set format %d", this, this->have_format); if (format == NULL) { if (port->have_format) { @@ -610,7 +581,7 @@ static int port_set_format(struct spa_node *node, if (!port->have_format) { this->n_formats++; port->have_format = true; - spa_log_info(this->log, NAME " %p: set format on port %d", this, port_id); + spa_log_debug(this->log, NAME " %p: set format on port %d", this, port_id); } } @@ -690,7 +661,7 @@ impl_node_port_use_buffers(struct spa_node *node, spa_return_val_if_fail(port->have_format, -EIO); - spa_log_info(this->log, NAME " %p: use buffers %d on port %d", this, n_buffers, port_id); + spa_log_debug(this->log, NAME " %p: use buffers %d on port %d", this, n_buffers, port_id); clear_buffers(this, port); @@ -749,6 +720,8 @@ impl_node_port_set_io(struct spa_node *node, if (id == t->io.Buffers) port->io = data; + else if (id == t->io.ControlRange) + port->ctrl = data; else return -ENOENT; @@ -829,7 +802,12 @@ static int impl_node_process(struct spa_node *node) spa_log_trace(this->log, NAME " %p: %d %d %d", this, sd->chunk->size, dd->maxsize, inport->offset); - size = SPA_MIN(sd->chunk->size - inport->offset, dd->maxsize); + if (outport->ctrl) + size = SPA_MIN(outport->ctrl->max_size, dd->maxsize); + else + size = dd->maxsize; + + size = SPA_MIN(size, sd->chunk->size - inport->offset); memcpy(dd->data, SPA_MEMBER(sd->data, inport->offset, void), size); @@ -839,7 +817,6 @@ static int impl_node_process(struct spa_node *node) outio->buffer_id = dbuf->buf->id; outio->status = SPA_STATUS_HAVE_BUFFER; SPA_FLAG_SET(res, SPA_STATUS_HAVE_BUFFER); - } inport->offset += size; if (inport->offset >= sbuf->buf->datas[0].chunk->size) { diff --git a/src/modules/module-audio-session.c b/src/modules/module-audio-session.c index 7052c38c0..c40851ad1 100644 --- a/src/modules/module-audio-session.c +++ b/src/modules/module-audio-session.c @@ -44,8 +44,8 @@ #define DEFAULT_CHANNELS 2 #define DEFAULT_SAMPLE_RATE 44100 -#define DEFAULT_BUFFER_SIZE 64 -#define MAX_BUFFER_SIZE 2048 +#define DEFAULT_BUFFER_SIZE (64 * sizeof(float)) +#define MAX_BUFFER_SIZE (1024 * sizeof(float)) struct type { struct spa_type_media_type media_type; diff --git a/src/modules/module-audio-session/audio-dsp.c b/src/modules/module-audio-session/audio-dsp.c index 719393653..39e798013 100644 --- a/src/modules/module-audio-session/audio-dsp.c +++ b/src/modules/module-audio-session/audio-dsp.c @@ -208,7 +208,7 @@ static int node_remove_port(struct spa_node *node, enum spa_direction direction, static int clear_buffers(struct node *n, struct port *p) { if (p->n_buffers > 0) { - pw_log_info(NAME " %p: clear buffers %p", n, p); + pw_log_debug(NAME " %p: clear buffers %p", n, p); p->n_buffers = 0; spa_list_init(&p->queue); } @@ -586,7 +586,7 @@ static int port_set_format(struct spa_node *node, struct port *p, if (spa_format_audio_raw_parse(format, &info.info.raw, &t->format_audio) < 0) return -EINVAL; - pw_log_info(NAME " %p: set format on port %p", n, p); + pw_log_debug(NAME " %p: set format on port %p", n, p); n->sample_rate = info.info.raw.rate; if (!SPA_FLAG_CHECK(p->flags, PORT_FLAG_DSP)) { diff --git a/src/modules/module-client-node/client-node.c b/src/modules/module-client-node/client-node.c index 1c26908c4..14ba1f723 100644 --- a/src/modules/module-client-node/client-node.c +++ b/src/modules/module-client-node/client-node.c @@ -434,7 +434,7 @@ do_update_port(struct node *this, if (change_mask & PW_CLIENT_NODE_PORT_UPDATE_PARAMS) { port->have_format = false; - spa_log_info(this->log, "node %p: port %u update %d params", this, port_id, n_params); + spa_log_debug(this->log, "node %p: port %u update %d params", this, port_id, n_params); for (i = 0; i < port->n_params; i++) free(port->params[i]); port->n_params = n_params; @@ -464,7 +464,7 @@ do_update_port(struct node *this, } if (!port->valid) { - spa_log_info(this->log, "node %p: adding port %d", this, port_id); + spa_log_debug(this->log, "node %p: adding port %d", this, port_id); port->have_format = false; port->valid = true; for (i = 0; i < MAX_IO; i++) @@ -494,7 +494,7 @@ static void do_uninit_port(struct node *this, enum spa_direction direction, uint { struct port *port; - spa_log_info(this->log, "node %p: removing port %d", this, port_id); + spa_log_debug(this->log, "node %p: removing port %d", this, port_id); if (direction == SPA_DIRECTION_INPUT) { port = GET_IN_PORT(this, port_id); @@ -716,7 +716,7 @@ impl_node_port_use_buffers(struct spa_node *node, this = SPA_CONTAINER_OF(node, struct node, node); impl = this->impl; - spa_log_info(this->log, "node %p: use buffers %p %u", this, buffers, n_buffers); + spa_log_debug(this->log, "node %p: use buffers %p %u", this, buffers, n_buffers); t = impl->t; @@ -931,7 +931,7 @@ client_node_update(void *data, this->max_outputs = max_output_ports; if (change_mask & PW_CLIENT_NODE_UPDATE_PARAMS) { int i; - spa_log_info(this->log, "node %p: update %d params", this, n_params); + spa_log_debug(this->log, "node %p: update %d params", this, n_params); for (i = 0; i < this->n_params; i++) free(this->params[i]); @@ -941,7 +941,7 @@ client_node_update(void *data, for (i = 0; i < this->n_params; i++) this->params[i] = pw_spa_pod_copy(params[i]); } - spa_log_info(this->log, "node %p: got node update max_in %u, max_out %u", this, + spa_log_debug(this->log, "node %p: got node update max_in %u, max_out %u", this, this->max_inputs, this->max_outputs); } @@ -958,7 +958,7 @@ client_node_port_update(void *data, struct node *this = &impl->node; bool remove; - spa_log_info(this->log, "node %p: got port update", this); + spa_log_debug(this->log, "node %p: got port update", this); if (!CHECK_PORT_ID(this, direction, port_id)) return; diff --git a/src/modules/module-client-node/client-stream.c b/src/modules/module-client-node/client-stream.c index 0e7722e53..90c95d547 100644 --- a/src/modules/module-client-node/client-stream.c +++ b/src/modules/module-client-node/client-stream.c @@ -335,7 +335,7 @@ static int negotiate_format(struct impl *impl) spa_pod_builder_init(&b, buffer, sizeof(buffer)); - spa_log_info(this->log, "%p: negiotiate", impl); + spa_log_debug(this->log, "%p: negiotiate", impl); state = 0; if ((res = spa_node_port_enum_params(impl->adapter, @@ -385,7 +385,7 @@ static int negotiate_buffers(struct impl *impl) struct spa_buffer_alloc_info info = { 0, }; void *skel; - spa_log_info(this->log, "%p: %d", impl, impl->n_buffers); + spa_log_debug(this->log, "%p: %d", impl, impl->n_buffers); if (impl->n_buffers > 0) return 0; @@ -593,7 +593,7 @@ impl_node_port_use_buffers(struct spa_node *node, return res; - spa_log_info(this->log, "%p: %d %d", impl, n_buffers, port_id); + spa_log_debug(this->log, "%p: %d %d", impl, n_buffers, port_id); if (n_buffers > 0 && impl->use_converter) { if (port_id == 0) diff --git a/src/pipewire/remote.c b/src/pipewire/remote.c index fd2c71bcb..eea82cf3c 100644 --- a/src/pipewire/remote.c +++ b/src/pipewire/remote.c @@ -750,7 +750,7 @@ static void client_node_transport(void *object, uint32_t node_id, data->node_id = node_id; - pw_log_info("remote-node %p: create transport with fds %d %d for node %u", + pw_log_debug("remote-node %p: create transport with fds %d %d for node %u", proxy, readfd, writefd, node_id); data->rtwritefd = writefd; diff --git a/src/pipewire/stream.c b/src/pipewire/stream.c index ae95150e5..fe26239fa 100644 --- a/src/pipewire/stream.c +++ b/src/pipewire/stream.c @@ -633,7 +633,7 @@ static int impl_port_use_buffers(struct spa_node *node, enum spa_direction direc } else size = buf_size; } - pw_log_info("got buffer %d %d datas, mapped size %d", i, + pw_log_debug("got buffer %d %d datas, mapped size %d", i, buffers[i]->n_datas, size); }