From e8aef6b4bdeaed23dcf50e8281884b153f24ab86 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 23 Sep 2022 15:32:36 +0200 Subject: [PATCH] audioconvert: only Suspend should trigger negotiate A Suspend should clear all the negotiated state and start a new negotiation in Start. Use a flag to control this. This avoids recalculation of state for each pause/play state change. See #2701 --- spa/plugins/audioconvert/audioconvert.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/spa/plugins/audioconvert/audioconvert.c b/spa/plugins/audioconvert/audioconvert.c index 2eabdd426..9cca99617 100644 --- a/spa/plugins/audioconvert/audioconvert.c +++ b/spa/plugins/audioconvert/audioconvert.c @@ -215,6 +215,7 @@ struct impl { uint32_t in_offset; uint32_t out_offset; unsigned int started:1; + unsigned int setup:1; unsigned int peaks:1; unsigned int is_passthrough:1; unsigned int drained:1; @@ -1463,6 +1464,12 @@ static int setup_convert(struct impl *this) in = &this->dir[SPA_DIRECTION_INPUT]; out = &this->dir[SPA_DIRECTION_OUTPUT]; + spa_log_debug(this->log, "%p: setup:%d in_format:%d out_format:%d", this, + this->setup, in->have_format, out->have_format); + + if (this->setup) + return 0; + if (!in->have_format || !out->have_format) return -EINVAL; @@ -1506,6 +1513,7 @@ static int setup_convert(struct impl *this) this->tmp_datas[1][i] = SPA_PTROFF(this->tmp[1], this->empty_size * i, void); this->tmp_datas[1][i] = SPA_PTR_ALIGN(this->tmp_datas[1][i], MAX_ALIGN, void); } + this->setup = true; emit_node_info(this, false); @@ -1537,6 +1545,7 @@ static int impl_node_send_command(void *object, const struct spa_command *comman this->started = true; break; case SPA_NODE_COMMAND_Suspend: + this->setup = false; SPA_FALLTHROUGH; case SPA_NODE_COMMAND_Flush: reset_node(this);