All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ v1 06/10] shared/mcp: Don't drop commands before supported opcodes are read
Date: Fri, 30 Oct 2026 17:29:35 -0400	[thread overview]
Message-ID: <20261030212940.753771-7-luiz.dentz@gmail.com> (raw)
In-Reply-To: <20261030212940.753771-1-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

The remote player is created once the CCID of the service is read,
before Media Control Point Opcodes Supported is, and until then every
command was dropped. As the player returned the request id as error
code, the D-Bus call succeeded anyway, so e.g. a Play right after the
player appeared was silently lost.

Only refuse opcodes once the supported ones are known, letting the
server reject them otherwise, and report commands that were not sent as
errors.

Fixes: 9027edc4604e ("shared/mcp, mcp: support multiple MCP, and add non-stub MCS server")
Assisted-by: Claude:claude-opus-5-5
---
 profiles/audio/mcp.c | 10 +++++-----
 src/shared/mcp.c     |  8 +++++++-
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/profiles/audio/mcp.c b/profiles/audio/mcp.c
index 314bce2439df..7522ca4e6ea3 100644
--- a/profiles/audio/mcp.c
+++ b/profiles/audio/mcp.c
@@ -253,35 +253,35 @@ static int remote_mp_play(struct media_player *mp, void *user_data)
 {
 	struct remote_player *remote = user_data;
 
-	return bt_mcp_play(remote->mcp, remote->ccid);
+	return bt_mcp_play(remote->mcp, remote->ccid) ? 0 : -EIO;
 }
 
 static int remote_mp_pause(struct media_player *mp, void *user_data)
 {
 	struct remote_player *remote = user_data;
 
-	return bt_mcp_pause(remote->mcp, remote->ccid);
+	return bt_mcp_pause(remote->mcp, remote->ccid) ? 0 : -EIO;
 }
 
 static int remote_mp_stop(struct media_player *mp, void *user_data)
 {
 	struct remote_player *remote = user_data;
 
-	return bt_mcp_stop(remote->mcp, remote->ccid);
+	return bt_mcp_stop(remote->mcp, remote->ccid) ? 0 : -EIO;
 }
 
 static int remote_mp_next(struct media_player *mp, void *user_data)
 {
 	struct remote_player *remote = user_data;
 
-	return bt_mcp_next_track(remote->mcp, remote->ccid);
+	return bt_mcp_next_track(remote->mcp, remote->ccid) ? 0 : -EIO;
 }
 
 static int remote_mp_previous(struct media_player *mp, void *user_data)
 {
 	struct remote_player *remote = user_data;
 
-	return bt_mcp_previous_track(remote->mcp, remote->ccid);
+	return bt_mcp_previous_track(remote->mcp, remote->ccid) ? 0 : -EIO;
 }
 
 static bool remote_mp_set_setting(struct media_player *mp, const char *key,
diff --git a/src/shared/mcp.c b/src/shared/mcp.c
index 4ee14d1567fe..8ddc072dacaa 100644
--- a/src/shared/mcp.c
+++ b/src/shared/mcp.c
@@ -108,6 +108,7 @@ struct bt_mcp_service {
 	struct bt_mcs_db rdb;
 
 	bool ready;
+	bool op_supported_known;
 
 	unsigned int notify_id[MAX_ATTR];
 	unsigned int notify_id_count;
@@ -1256,7 +1257,11 @@ static unsigned int mcp_command(struct bt_mcp *mcp, uint8_t ccid, uint8_t op,
 	if (!service || !cmd)
 		return 0;
 
-	if (!(service->rdb.media_cp_op_supported_value & cmd->support))
+	/* The service is added once its CCID is read, so commands may come
+	 * before the supported opcodes are known: let the server reject them
+	 */
+	if (service->op_supported_known &&
+		!(service->rdb.media_cp_op_supported_value & cmd->support))
 		return 0;
 
 	DBG_SVC(service, "%s %d", cmd->name, arg);
@@ -1686,6 +1691,7 @@ static void update_media_cp_op_supported(bool success, uint8_t att_ecode,
 	DBG_SVC(service, "Media CP Op Supported: %d", v);
 
 	service->rdb.media_cp_op_supported_value = v;
+	service->op_supported_known = true;
 }
 
 static void update_add_service(void *data, void *user_data)
-- 
2.56.0


  parent reply	other threads:[~2026-10-30 21:29 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-30 21:29 [PATCH BlueZ v1 00/10] Run test-functional under User Mode Linux Luiz Augusto von Dentz
2026-10-30 21:29 ` [PATCH BlueZ v1 01/10] tools/test-runner: Default to time travel with " Luiz Augusto von Dentz
2026-10-30 23:58   ` Run test-functional under " bluez.test.bot
2026-10-30 21:29 ` [PATCH BlueZ v1 02/10] tools/test-runner: Unbind virtio devices before powering off UML Luiz Augusto von Dentz
2026-10-30 21:29 ` [PATCH BlueZ v1 03/10] emulator: Answer the time of a guest with a skew Luiz Augusto von Dentz
2026-10-30 21:29 ` [PATCH BlueZ v1 04/10] adapter: Don't return Busy when a pending change sets the same value Luiz Augusto von Dentz
2026-10-30 21:34   ` Luiz Augusto von Dentz
2026-10-30 21:29 ` [PATCH BlueZ v1 05/10] test: functional: wait for BAP transports to be configured Luiz Augusto von Dentz
2026-10-30 21:29 ` Luiz Augusto von Dentz [this message]
2026-10-30 21:29 ` [PATCH BlueZ v1 07/10] doc/test-functional: Document User Mode Linux VM hosts Luiz Augusto von Dentz
2026-10-30 21:29 ` [PATCH BlueZ v1 08/10] a2dp: Fix refusing the AVDTP connection of a new link Luiz Augusto von Dentz
2026-10-30 21:29 ` [PATCH BlueZ v1 09/10] adapter: Don't cancel requests of a new link on stale disconnection Luiz Augusto von Dentz
2026-10-30 21:29 ` [PATCH BlueZ v1 10/10] test: Cover A2DP reconnection with a pending disconnection Luiz Augusto von Dentz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261030212940.753771-7-luiz.dentz@gmail.com \
    --to=luiz.dentz@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.