From 90f5b4a4bf5514f3e8d91b875d9fea329711a7ae Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 17 Nov 2022 19:26:46 +0100 Subject: [PATCH] audioconvert: improve renegotiation When the follower updates EnumFormat, it probably wants to renegotiate to a new format, so clear the current format so that we do that when starting the next time. EnumFormat should also not only return the current format in case we are negotiated but it should return all possible formats. See #2832 --- spa/plugins/audioconvert/audioadapter.c | 4 ++++ spa/plugins/audioconvert/audioconvert.c | 7 +------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/spa/plugins/audioconvert/audioadapter.c b/spa/plugins/audioconvert/audioadapter.c index 06a2f38ce..9ddd4e031 100644 --- a/spa/plugins/audioconvert/audioadapter.c +++ b/spa/plugins/audioconvert/audioadapter.c @@ -1096,6 +1096,10 @@ static void follower_port_info(void *data, spa_log_debug(this->log, "latency: %d (%s)", res, spa_strerror(res)); } + if (idx == IDX_EnumFormat) { + this->have_format = false; + spa_log_debug(this->log, "new formats"); + } this->info.change_mask |= SPA_NODE_CHANGE_MASK_PARAMS; if (!this->add_listener) { diff --git a/spa/plugins/audioconvert/audioconvert.c b/spa/plugins/audioconvert/audioconvert.c index ba2ea4178..2e18dbfa9 100644 --- a/spa/plugins/audioconvert/audioconvert.c +++ b/spa/plugins/audioconvert/audioconvert.c @@ -1646,7 +1646,6 @@ static int port_enum_formats(void *object, struct spa_pod_builder *builder) { struct impl *this = object; - struct port *port = GET_PORT(this, direction, port_id); switch (index) { case 0: @@ -1660,11 +1659,7 @@ static int port_enum_formats(void *object, SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat, SPA_FORMAT_mediaType, SPA_POD_Id(SPA_MEDIA_TYPE_application), SPA_FORMAT_mediaSubtype, SPA_POD_Id(SPA_MEDIA_SUBTYPE_control)); - } else if (port->have_format) { - *param = spa_format_audio_raw_build(builder, - SPA_PARAM_EnumFormat, &this->dir[direction].format.info.raw); - } - else { + } else { uint32_t rate = this->io_position ? this->io_position->clock.rate.denom : DEFAULT_RATE;