* [PATCH v4 2/3] android/avrcp: Fix not handling SetAbsoluteVolume response
2014-03-10 12:05 [PATCH v4 1/3] android/avrcp: Fill attributes in case of empty for GetElementAttributes Luiz Augusto von Dentz
@ 2014-03-10 12:05 ` Luiz Augusto von Dentz
2014-03-10 12:05 ` [PATCH v4 3/3] android/avrcp: Fix setting wrong type for volume changed event Luiz Augusto von Dentz
2014-03-10 12:12 ` [PATCH v4 1/3] android/avrcp: Fill attributes in case of empty for GetElementAttributes Luiz Augusto von Dentz
2 siblings, 0 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2014-03-10 12:05 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This follow what is stated in AVRCP specification 1.5 page 83:
" When the volume is changed on the TG by this command the Volume Change
notification shall not be completed."
Therefore the only option is to treat the response and self generate
changed notification.
---
android/avrcp.c | 33 ++++++++++++++++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)
diff --git a/android/avrcp.c b/android/avrcp.c
index 70266f7..eab519a 100644
--- a/android/avrcp.c
+++ b/android/avrcp.c
@@ -330,6 +330,36 @@ done:
HAL_OP_AVRCP_REGISTER_NOTIFICATION, status);
}
+static gboolean set_volume_rsp(struct avctp *conn,
+ uint8_t code, uint8_t subunit,
+ uint8_t *operands, size_t operand_count,
+ void *user_data)
+{
+ struct hal_ev_avrcp_volume_changed ev;
+ uint8_t *params;
+
+ if (code != AVC_CTYPE_ACCEPTED) {
+ ev.volume = 0;
+ ev.type = code;
+ goto done;
+ }
+
+ if (operands == NULL || operand_count < 7)
+ return FALSE;
+
+ params = &operands[7];
+
+ ev.volume = params[0] & 0x7F;
+ ev.type = code;
+
+done:
+ ipc_send_notif(hal_ipc, HAL_SERVICE_ID_AVRCP,
+ HAL_EV_AVRCP_VOLUME_CHANGED,
+ sizeof(ev), &ev);
+
+ return FALSE;
+}
+
static void handle_set_volume(const void *buf, uint16_t len)
{
struct hal_cmd_avrcp_set_volume *cmd = (void *) buf;
@@ -350,7 +380,8 @@ static void handle_set_volume(const void *buf, uint16_t len)
*/
dev = devices->data;
- ret = avrcp_set_volume(dev->session, cmd->value & 0x7f, NULL, NULL);
+ ret = avrcp_set_volume(dev->session, cmd->value & 0x7f, set_volume_rsp,
+ dev);
if (ret < 0) {
status = HAL_STATUS_FAILED;
goto done;
--
1.8.5.3
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH v4 1/3] android/avrcp: Fill attributes in case of empty for GetElementAttributes
2014-03-10 12:05 [PATCH v4 1/3] android/avrcp: Fill attributes in case of empty for GetElementAttributes Luiz Augusto von Dentz
2014-03-10 12:05 ` [PATCH v4 2/3] android/avrcp: Fix not handling SetAbsoluteVolume response Luiz Augusto von Dentz
2014-03-10 12:05 ` [PATCH v4 3/3] android/avrcp: Fix setting wrong type for volume changed event Luiz Augusto von Dentz
@ 2014-03-10 12:12 ` Luiz Augusto von Dentz
2 siblings, 0 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2014-03-10 12:12 UTC (permalink / raw)
To: linux-bluetooth@vger.kernel.org
Hi,
On Mon, Mar 10, 2014 at 2:05 PM, Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> This has to be done since Android do not interpret empty list as get all
> attributes as it should.
> ---
> v2: Move empty list handling to daemon side and fix starting with attribute
> 0x00 which is illegal.
> v3: Fix not handling response code properly in set_volume_rsp
> v4: Add fix to pass correct type to volume changed notification
>
> android/avrcp.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/android/avrcp.c b/android/avrcp.c
> index e26ddf2..70266f7 100644
> --- a/android/avrcp.c
> +++ b/android/avrcp.c
> @@ -655,11 +655,23 @@ static ssize_t handle_get_element_attrs_cmd(struct avrcp *session,
> return -EINVAL;
>
> params += 9;
> +
> + /* Set everything in case of empty list */
> + if (ev->number == 0) {
> + for (i = 0; i < HAL_AVRCP_MEDIA_ATTR_DURATION; i++) {
> + /* Skip 0x00 as the attributes start with 0x01 */
> + ev->attrs[i] = i + 1;
> + }
> + ev->number = i;
> + goto done;
> + }
> +
> for (i = 0; i < ev->number; i++) {
> ev->attrs[i] = bt_get_be32(params);
> params += 4;
> }
>
> +done:
> ipc_send_notif(hal_ipc, HAL_SERVICE_ID_AVRCP,
> HAL_EV_AVRCP_GET_ELEMENT_ATTRS,
> sizeof(*ev) + ev->number, ev);
> --
> 1.8.5.3
Pushed.
--
Luiz Augusto von Dentz
^ permalink raw reply [flat|nested] 4+ messages in thread