All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ 1/1] avrcp: Add strict checks for supported events
@ 2024-02-29 16:09 Xiao Yao
  2024-02-29 18:06 ` [BlueZ,1/1] " bluez.test.bot
  0 siblings, 1 reply; 2+ messages in thread
From: Xiao Yao @ 2024-02-29 16:09 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Xiao Yao

From: Xiao Yao <xiaoyao@rock-chips.com>

In some resource-limited embedded systems, if the player is not
registered, but the supported event contains the status/track/
settings events that need player support, it will return some
unreasonable values to the peer, which will cause confusion on
the peer device and cause some unknown problems.

In my test scenario, bluez was the role of the source to connect
the bose speaker. bluez could send absolute volume to the bose
speaker, but it could not adjust the volume of bluez. By checking
the btsnoop, we could see that bluez had registered volume change
notification. When I removed the events above, everything worked
fine. I also tested on iPhone/Android and everything worked fine.
---
 profiles/audio/avrcp.c | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
index 36ce01a14..34fc23306 100644
--- a/profiles/audio/avrcp.c
+++ b/profiles/audio/avrcp.c
@@ -4152,21 +4152,26 @@ static void target_init(struct avrcp *session)
 
 		init_volume = media_player_get_device_volume(session->dev);
 		media_transport_update_device_volume(session->dev, init_volume);
-	}
 
-	session->supported_events |= (1 << AVRCP_EVENT_STATUS_CHANGED) |
-				(1 << AVRCP_EVENT_TRACK_CHANGED) |
-				(1 << AVRCP_EVENT_TRACK_REACHED_START) |
-				(1 << AVRCP_EVENT_TRACK_REACHED_END) |
-				(1 << AVRCP_EVENT_SETTINGS_CHANGED);
+		/* These events below requires a player */
+		session->supported_events |= (1 << AVRCP_EVENT_STATUS_CHANGED) |
+					(1 << AVRCP_EVENT_TRACK_CHANGED) |
+					(1 << AVRCP_EVENT_TRACK_REACHED_START) |
+					(1 << AVRCP_EVENT_TRACK_REACHED_END) |
+					(1 << AVRCP_EVENT_SETTINGS_CHANGED);
 
-	if (target->version < 0x0104)
-		return;
+		if (target->version < 0x0104)
+			return;
 
-	session->supported_events |=
+		session->supported_events |=
 				(1 << AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED) |
 				(1 << AVRCP_EVENT_AVAILABLE_PLAYERS_CHANGED) |
 				(1 << AVRCP_EVENT_VOLUME_CHANGED);
+	} else {
+		if (target->version > 0x0103)
+			session->supported_events =
+					(1 << AVRCP_EVENT_VOLUME_CHANGED);
+	}
 
 	/* Only check capabilities if controller is not supported */
 	if (session->controller == NULL)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-02-29 18:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-29 16:09 [PATCH BlueZ 1/1] avrcp: Add strict checks for supported events Xiao Yao
2024-02-29 18:06 ` [BlueZ,1/1] " bluez.test.bot

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.