diff --git a/spa/plugins/audioconvert/audioconvert.c b/spa/plugins/audioconvert/audioconvert.c index 9477e3e75..285aa1903 100644 --- a/spa/plugins/audioconvert/audioconvert.c +++ b/spa/plugins/audioconvert/audioconvert.c @@ -287,6 +287,9 @@ static int setup_convert(struct impl *this) outport->format.info.raw.rate, outport->format.info.raw.layout); + if (this->n_links > 0) + return 0; + /* unpack */ make_link(this, NULL, 0, this->fmt_in, 0, &inport->format); prev = this->fmt_in; diff --git a/src/examples/video-play.c b/src/examples/video-play.c index 96215a43c..918a078b5 100644 --- a/src/examples/video-play.c +++ b/src/examples/video-play.c @@ -100,6 +100,9 @@ on_process(void *_data) uint8_t *src, *dst; b = pw_stream_dequeue_buffer(stream); + if (b == NULL) + return; + buf = b->buffer; pw_log_trace("new buffer %d", buf->id); diff --git a/src/pipewire/link.c b/src/pipewire/link.c index 7692e803e..9e540dd78 100644 --- a/src/pipewire/link.c +++ b/src/pipewire/link.c @@ -1198,6 +1198,10 @@ struct pw_link *pw_link_new(struct pw_core *core, if (output == input) goto same_ports; + if (output->direction != PW_DIRECTION_OUTPUT || + input->direction != PW_DIRECTION_INPUT) + goto wrong_direction; + if (pw_link_find(output, input)) goto link_exists; @@ -1276,6 +1280,9 @@ struct pw_link *pw_link_new(struct pw_core *core, same_ports: asprintf(error, "can't link the same ports"); return NULL; + wrong_direction: + asprintf(error, "ports have wrong direction"); + return NULL; link_exists: asprintf(error, "link already exists"); return NULL; diff --git a/src/pipewire/node.c b/src/pipewire/node.c index bbc833046..e66187a09 100644 --- a/src/pipewire/node.c +++ b/src/pipewire/node.c @@ -815,8 +815,10 @@ struct pw_port *pw_node_get_free_port(struct pw_node *node, enum pw_direction di /* first try to find an unlinked port */ spa_list_for_each(p, ports, link) { - if (spa_list_is_empty(&p->links)) - return p; + if (spa_list_is_empty(&p->links)) { + port = p; + goto found; + } /* for output we can reuse an existing port, for input only * when there is a multiplex */ if (direction == PW_DIRECTION_OUTPUT || p->mix != NULL) @@ -841,6 +843,7 @@ struct pw_port *pw_node_get_free_port(struct pw_node *node, enum pw_direction di } else { port = mixport; } + found: pw_log_debug("node %p: return port %p", node, port); return port;