Thread (24 messages) 24 messages, 5 authors, 2013-01-15
STALE4942d

[PATCH BlueZ 10/11] avrcp: Handle SetAbsoluteVolume command

From: João Paulo Rechi Vita <hidden>
Date: 2013-01-11 20:25:33
Subsystem: the rest · Maintainer: Linus Torvalds

---
 profiles/audio/avrcp.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
index d715177..8bd5fb6 100644
--- a/profiles/audio/avrcp.c
+++ b/profiles/audio/avrcp.c
@@ -1392,6 +1392,32 @@ err:
 	return AVC_CTYPE_REJECTED;
 }
 
+static uint8_t avrcp_handle_set_absolute_volume(struct avrcp *session,
+						struct avrcp_header *pdu,
+						uint8_t transaction)
+{
+	struct avrcp_player *player = session->player;
+	uint16_t len = ntohs(pdu->params_len);
+
+	if (len != 1)
+		goto err;
+
+	if (pdu->params[0] > 127)
+		goto err;
+
+	if (!player)
+		goto err;
+
+	media_transport_update_device_volume(session->dev, pdu->params[0]);
+
+	return AVC_CTYPE_ACCEPTED;
+
+err:
+	pdu->params_len = htons(1);
+	pdu->params[0] = AVRCP_STATUS_INVALID_PARAM;
+	return AVC_CTYPE_REJECTED;
+}
+
 static const struct control_pdu_handler tg_control_handlers[] = {
 		{ AVRCP_GET_CAPABILITIES, AVC_CTYPE_STATUS,
 					avrcp_handle_get_capabilities },
@@ -1429,6 +1455,8 @@ static const struct control_pdu_handler ct_control_handlers[] = {
 					avrcp_handle_get_capabilities },
 		{ AVRCP_REGISTER_NOTIFICATION, AVC_CTYPE_NOTIFY,
 					avrcp_handle_register_notification },
+		{ AVRCP_SET_ABSOLUTE_VOLUME, AVC_CTYPE_CONTROL,
+					avrcp_handle_set_absolute_volume },
 		{ },
 };
 
-- 
1.7.11.7
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help