public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] transport: Fix set volume failure with invalid device volume
@ 2026-03-05  8:38 Jinwang Li
  2026-03-05  9:33 ` [v2] " bluez.test.bot
  2026-03-06 15:00 ` [PATCH v2] " Luiz Augusto von Dentz
  0 siblings, 2 replies; 4+ messages in thread
From: Jinwang Li @ 2026-03-05  8:38 UTC (permalink / raw)
  To: luiz.dentz, linux-bluetooth
  Cc: cheng.jiang, quic_chezhou, wei.deng, shuai.zhang, mengshi.wu,
	jinwang.li

When AVRCP is connected earlier than AVDTP, this invalid device volume
causes the A2DP sink to reject the peer's registration for the
EVENT_VOLUME_CHANGED notification. As a result, subsequent attempts to
set the volume fail.

Fix this by ensuring a valid device volume is returned when the device
volume is invalid, allowing volume registration to succeed.

Fixes: fa7828bddd21 ("transport: Fix not being able to initialize volume properly")
Signed-off-by: Jinwang Li <jinwang.li@oss.qualcomm.com>
---
 profiles/audio/transport.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Changes from v1:
 - Return the max volume from media_transport_get_a2dp_volume()
   when there is no A2DP transport and the device volume is invalid.
 - Restore the default device volume in device_new().
 - Update the commit subject name.
 - Link to v1
   https://lore.kernel.org/all/20260122063640.310090-1-jinwang.li@oss.qualcomm.com/

diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c
index d9feef768..41d8d0a75 100644
--- a/profiles/audio/transport.c
+++ b/profiles/audio/transport.c
@@ -2767,6 +2767,7 @@ static void media_transport_emit_volume(struct media_transport *transport)
 int media_transport_get_a2dp_volume(struct btd_device *dev)
 {
 	GSList *l;
+	int volume;
 
 	if (dev == NULL)
 		return -1;
@@ -2793,7 +2794,11 @@ int media_transport_get_a2dp_volume(struct btd_device *dev)
 	 * of ordering between AVRCP and A2DP session start. (Note BAP+VCP do
 	 * not have this issue.)
 	 */
-	return btd_device_get_volume(dev);
+	volume = btd_device_get_volume(dev);
+	if (volume < 0)
+		volume = 127;
+
+	return volume;
 }
 
 void media_transport_set_a2dp_volume(struct btd_device *dev, int volume)
-- 
2.34.1


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

end of thread, other threads:[~2026-03-09 10:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-05  8:38 [PATCH v2] transport: Fix set volume failure with invalid device volume Jinwang Li
2026-03-05  9:33 ` [v2] " bluez.test.bot
2026-03-06 15:00 ` [PATCH v2] " Luiz Augusto von Dentz
2026-03-09 10:39   ` Jinwang Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox