avrcp: Set volume if volume changed event is registered
authorYu Liu <yudiliu@google.com>
Wed, 9 Sep 2020 21:26:43 +0000 (14:26 -0700)
committerAyush Garg <ayush.garg@samsung.com>
Fri, 11 Mar 2022 13:38:32 +0000 (19:08 +0530)
Some audio devices don't list the AVRCP TG role in SDP but still support
absolute volume and volume changed event, this change should allow the
stack to control the volumes on these audio devices.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
profiles/audio/avrcp.c

index c22b0aa..73c6f96 100644 (file)
@@ -5004,6 +5004,11 @@ static int avrcp_event(struct avrcp *session, uint8_t id, const void *data)
        return err;
 }
 
+static bool avrcp_event_registered(struct avrcp *session, uint8_t event)
+{
+       return session->registered_events & (1 << event);
+}
+
 int avrcp_set_volume(struct btd_device *dev, int8_t volume, bool notify)
 {
        struct avrcp_server *server;
@@ -5029,7 +5034,8 @@ int avrcp_set_volume(struct btd_device *dev, int8_t volume, bool notify)
                                                                &volume);
        }
 
-       if (!session->controller || session->controller->version < 0x0104)
+       if (!session->controller && !avrcp_event_registered(session,
+                                       AVRCP_EVENT_VOLUME_CHANGED))
                return -ENOTSUP;
 
        memset(buf, 0, sizeof(buf));