From 179ccb9362b7eb2d56412acdf9a281ba495f75b6 Mon Sep 17 00:00:00 2001 From: Yu Liu Date: Wed, 9 Sep 2020 14:26:43 -0700 Subject: [PATCH] avrcp: Set volume if volume changed event is registered 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. --- profiles/audio/avrcp.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c index d9471c083..1c9aade48 100644 --- a/profiles/audio/avrcp.c +++ b/profiles/audio/avrcp.c @@ -4477,6 +4477,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; @@ -4502,7 +4507,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)); -- 2.47.3