From ce31e66fb701f0726e3ea61731323326c317b6d4 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 27 Jan 2025 10:18:02 +0100 Subject: [PATCH] audioadapter: only add/remove port when passthrough changed We only need to switch between the converter ports and the follower port when we switch between passthrough. Avoid emiting remove of the (non existing) follower ports when the mode changes from none to DSP at startup. --- spa/plugins/audioconvert/audioadapter.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/spa/plugins/audioconvert/audioadapter.c b/spa/plugins/audioconvert/audioadapter.c index a9123f689..1c79c149d 100644 --- a/spa/plugins/audioconvert/audioadapter.c +++ b/spa/plugins/audioconvert/audioadapter.c @@ -703,13 +703,14 @@ static int reconfigure_mode(struct impl *this, enum spa_param_port_config_mode m int res = 0; struct spa_hook l; bool passthrough = mode == SPA_PARAM_PORT_CONFIG_MODE_passthrough; + bool old_passthrough = this->mode == SPA_PARAM_PORT_CONFIG_MODE_passthrough; spa_log_debug(this->log, "%p: passthrough mode %d", this, passthrough); if (!passthrough && this->convert == NULL) return -ENOTSUP; - if (this->mode != mode) { + if (old_passthrough != passthrough) { if (passthrough) { /* remove converter split/merge ports */ configure_convert(this, SPA_PARAM_PORT_CONFIG_MODE_none); @@ -729,8 +730,9 @@ static int reconfigure_mode(struct impl *this, enum spa_param_port_config_mode m if ((res = configure_format(this, SPA_NODE_PARAM_FLAG_NEAREST, format)) < 0) return res; - if (this->mode != mode) { - this->mode = mode; + this->mode = mode; + + if (old_passthrough != passthrough) { if (passthrough) { /* add follower ports */ spa_zero(l);