Backport upstream fix for AVRCP volume initialization failure when
AVRCP connects before AVDTP.

Upstream-Status: Backport [bluez/bluez@121e5ca]
Signed-off-by: Jinwang Li <[email protected]>
---
Changes in v2:
- Add Signed-off-by tag
- Link to V1: 
https://lists.openembedded.org/g/openembedded-core/topic/patch_bluez5_fix_set/119542720

 meta/recipes-connectivity/bluez5/bluez5.inc   |  1 +
 ...t-volume-failure-with-invalid-device.patch | 46 +++++++++++++++++++
 2 files changed, 47 insertions(+)
 create mode 100644 
meta/recipes-connectivity/bluez5/bluez5/0001-transport-Fix-set-volume-failure-with-invalid-device.patch

diff --git a/meta/recipes-connectivity/bluez5/bluez5.inc 
b/meta/recipes-connectivity/bluez5/bluez5.inc
index 87252b990c..e827d0a6d7 100644
--- a/meta/recipes-connectivity/bluez5/bluez5.inc
+++ b/meta/recipes-connectivity/bluez5/bluez5.inc
@@ -71,6 +71,7 @@ SRC_URI = 
"${KERNELORG_MIRROR}/linux/bluetooth/bluez-${PV}.tar.xz \
            
file://0001-Revert-shared-shell-Don-t-init-input-for-non-interac.patch \
            
file://0001-tools-Work-around-broken-stdin-handling-in-home-made.patch \
            
file://0001-gatt-client-Fix-use-after-free-caused-by-reentrant-c.patch \
+           
file://0001-transport-Fix-set-volume-failure-with-invalid-device.patch \
            "
 S = "${UNPACKDIR}/bluez-${PV}"
 
diff --git 
a/meta/recipes-connectivity/bluez5/bluez5/0001-transport-Fix-set-volume-failure-with-invalid-device.patch
 
b/meta/recipes-connectivity/bluez5/bluez5/0001-transport-Fix-set-volume-failure-with-invalid-device.patch
new file mode 100644
index 0000000000..b5846dec47
--- /dev/null
+++ 
b/meta/recipes-connectivity/bluez5/bluez5/0001-transport-Fix-set-volume-failure-with-invalid-device.patch
@@ -0,0 +1,46 @@
+From 8a80f70c23ca5f93b1db7e3956cc7ee28c1fa767 Mon Sep 17 00:00:00 2001
+From: Jinwang Li <[email protected]>
+Date: Mon, 9 Mar 2026 19:18:26 +0800
+Subject: [PATCH] transport: Fix set volume failure with invalid device volume
+
+When AVRCP is connected before AVDTP, an invalid device volume causes
+the target to reject registration for the EVENT_VOLUME_CHANGED
+notification, which breaks subsequent volume updates.
+
+Fix this by initializing the volume to the maximum value in the AVRCP
+target init path when it is invalid, allowing the controller to
+subscribe to AVRCP_EVENT_VOLUME_CHANGED.
+
+Fixes: fa7828bddd21 ("transport: Fix not being able to initialize volume 
properly")
+Suggested-by: Luiz Augusto von Dentz <[email protected]>
+Signed-off-by: Jinwang Li <[email protected]>
+Upstream-Status: Backport 
[https://github.com/bluez/bluez/commit/121e5ca79be559c5374f8a54c6fb6e233e383379]
+---
+ profiles/audio/avrcp.c | 9 ++++++++-
+ 1 file changed, 8 insertions(+), 1 deletion(-)
+
+diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
+index 724b46c59..326dfdab7 100644
+--- a/profiles/audio/avrcp.c
++++ b/profiles/audio/avrcp.c
+@@ -4296,9 +4296,16 @@ static void target_init(struct avrcp *session)
+       if (target->version < 0x0104)
+               return;
+ 
+-      if (avrcp_volume_supported(target))
++      if (avrcp_volume_supported(target)) {
+               session->supported_events |=
+                               (1 << AVRCP_EVENT_VOLUME_CHANGED);
++              /* Check if transport volume hasn't been initialized then set it
++               * to max so it works properly if the controller attempts to
++               * subscribe to AVRCP_EVENT_VOLUME_CHANGED.
++               */
++              if (media_transport_get_a2dp_volume(session->dev) < 0)
++                      media_transport_set_a2dp_volume(session->dev, 127);
++      }
+ 
+       session->supported_events |=
+                               (1 << AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED) |
+-- 
+2.34.1
+
-- 
2.34.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#237744): 
https://lists.openembedded.org/g/openembedded-core/message/237744
Mute This Topic: https://lists.openembedded.org/mt/119543123/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to