From 3f386ecd34b531d9256e2a1e5aed38106179a2d0 Mon Sep 17 00:00:00 2001 From: "Christian F.K. Schaller" Date: Wed, 8 Apr 2026 17:10:32 -0400 Subject: [PATCH] module-avb: fix ACMP error responses sent with wrong message type In handle_connect_tx_command() and handle_disconnect_tx_command(), AVB_PACKET_ACMP_SET_MESSAGE_TYPE() is called after the goto done target. When find_stream() fails and jumps to done, the response is sent with the original command message type (e.g., CONNECT_TX_COMMAND) instead of the correct response type (CONNECT_TX_RESPONSE). Move the SET_MESSAGE_TYPE call before find_stream() so error responses are always sent with the correct response message type. Co-Authored-By: Claude Opus 4.6 --- src/modules/module-avb/acmp.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/modules/module-avb/acmp.c b/src/modules/module-avb/acmp.c index eacfb6133..73a84ba89 100644 --- a/src/modules/module-avb/acmp.c +++ b/src/modules/module-avb/acmp.c @@ -174,13 +174,14 @@ static int handle_connect_tx_command(struct acmp *acmp, uint64_t now, const void return 0; memcpy(buf, m, len); + AVB_PACKET_ACMP_SET_MESSAGE_TYPE(reply, AVB_ACMP_MESSAGE_TYPE_CONNECT_TX_RESPONSE); + stream = find_stream(server, SPA_DIRECTION_OUTPUT, ntohs(reply->talker_unique_id)); if (stream == NULL) { status = AVB_ACMP_STATUS_TALKER_NO_STREAM_INDEX; goto done; } - AVB_PACKET_ACMP_SET_MESSAGE_TYPE(reply, AVB_ACMP_MESSAGE_TYPE_CONNECT_TX_RESPONSE); reply->stream_id = htobe64(stream->id); stream_activate(stream, ntohs(reply->talker_unique_id), now); @@ -251,14 +252,14 @@ static int handle_disconnect_tx_command(struct acmp *acmp, uint64_t now, const v return 0; memcpy(buf, m, len); + AVB_PACKET_ACMP_SET_MESSAGE_TYPE(reply, AVB_ACMP_MESSAGE_TYPE_DISCONNECT_TX_RESPONSE); + stream = find_stream(server, SPA_DIRECTION_OUTPUT, ntohs(reply->talker_unique_id)); if (stream == NULL) { status = AVB_ACMP_STATUS_TALKER_NO_STREAM_INDEX; goto done; } - AVB_PACKET_ACMP_SET_MESSAGE_TYPE(reply, AVB_ACMP_MESSAGE_TYPE_DISCONNECT_TX_RESPONSE); - stream_deactivate(stream, now); done: