diff --git a/src/pipewire/impl-link.c b/src/pipewire/impl-link.c index b7c401280..e465ef86a 100644 --- a/src/pipewire/impl-link.c +++ b/src/pipewire/impl-link.c @@ -1049,15 +1049,28 @@ static void port_state_changed(struct pw_impl_link *this, struct pw_impl_port *p struct pw_impl_port *other, enum pw_impl_port_state old, enum pw_impl_port_state state, const char *error) { + struct impl *impl = SPA_CONTAINER_OF(this, struct impl, this); + struct port_info *info; + pw_log_debug("%p: port %p old:%d -> state:%d prepared:%d preparing:%d", this, port, old, state, this->prepared, this->preparing); + if (port == impl->output.port) + info = &impl->output; + else + info = &impl->input; + switch (state) { case PW_IMPL_PORT_STATE_ERROR: link_update_state(this, PW_LINK_STATE_ERROR, -EIO, error ? strdup(error) : NULL); break; case PW_IMPL_PORT_STATE_INIT: case PW_IMPL_PORT_STATE_CONFIGURE: + if (old == PW_IMPL_PORT_STATE_INIT) { + port_set_busy_id(this, info, SPA_ID_INVALID, SPA_ID_INVALID); + pw_work_queue_cancel(impl->work, info, SPA_ID_INVALID); + old = PW_IMPL_PORT_STATE_READY; + } if (this->prepared || state < old) { this->prepared = this->preparing = false; link_update_state(this, PW_LINK_STATE_INIT, 0, NULL); diff --git a/src/pipewire/impl-port.c b/src/pipewire/impl-port.c index 0a7af2c93..c4a654ab7 100644 --- a/src/pipewire/impl-port.c +++ b/src/pipewire/impl-port.c @@ -1615,6 +1615,7 @@ void pw_impl_port_suspend(struct pw_impl_port *port) int res; if ((res = pw_impl_port_set_param(port, SPA_PARAM_Format, 0, NULL)) < 0) pw_log_warn("%p: error unset format: %s", port, spa_strerror(res)); + port->state = PW_IMPL_PORT_STATE_INIT; /* force CONFIGURE in case of async, use update_state to * notify links so they can cancel pending work */ pw_impl_port_update_state(port, PW_IMPL_PORT_STATE_CONFIGURE, 0, NULL);