From 855bebf0ea097ce4d7b673b8531953272e7bed63 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 27 Oct 2022 10:29:15 +0200 Subject: [PATCH] audioconvert: update started field better Set up the adapter and then set the started field to true before we Start the follower and converter. It is possible that the follower will start processing immediately so the started state needs to be set correctly. Similarly, first perform the Pause and Suspend calls on the follower and converter before clearing our buffers and format so that things are stopped properly. See #2764 --- spa/plugins/audioconvert/audioadapter.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/spa/plugins/audioconvert/audioadapter.c b/spa/plugins/audioconvert/audioadapter.c index e146ddfec..4704c7e61 100644 --- a/spa/plugins/audioconvert/audioadapter.c +++ b/spa/plugins/audioconvert/audioadapter.c @@ -814,21 +814,23 @@ static int impl_node_send_command(void *object, const struct spa_command *comman switch (SPA_NODE_COMMAND_ID(command)) { case SPA_NODE_COMMAND_Start: + spa_log_debug(this->log, "%p: starting %d", this, this->started); if (this->started) return 0; if ((res = negotiate_format(this)) < 0) return res; if ((res = negotiate_buffers(this)) < 0) return res; + this->started = true; break; case SPA_NODE_COMMAND_Suspend: - configure_format(this, 0, NULL); - SPA_FALLTHROUGH + spa_log_debug(this->log, "%p: suspending", this); + break; case SPA_NODE_COMMAND_Pause: - this->started = false; - spa_log_debug(this->log, "%p: stopped", this); + spa_log_debug(this->log, "%p: pausing", this); break; case SPA_NODE_COMMAND_Flush: + spa_log_debug(this->log, "%p: flushing", this); this->io_buffers.status = SPA_STATUS_OK; break; default: @@ -852,9 +854,18 @@ static int impl_node_send_command(void *object, const struct spa_command *comman } switch (SPA_NODE_COMMAND_ID(command)) { case SPA_NODE_COMMAND_Start: - this->started = true; spa_log_debug(this->log, "%p: started", this); break; + case SPA_NODE_COMMAND_Suspend: + configure_format(this, 0, NULL); + SPA_FALLTHROUGH + case SPA_NODE_COMMAND_Pause: + this->started = false; + spa_log_debug(this->log, "%p: stopped", this); + break; + case SPA_NODE_COMMAND_Flush: + spa_log_debug(this->log, "%p: flushed", this); + break; } return res; }