Skip to contentSkip to conversation

android/avrcp: Add remote features notification

PATCH In review Luiz Augusto von Dentz 1 participant 5 messages Mar 6, 2014 Bluetooth drivers

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH v2 1/4 android/avrcp: Add remote features notification

From: Luiz Augusto von Dentz <[email protected]>

---
v2: Keep uint16_t as type of device features.

 android/avrcp.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
android/avrcp.c +17 -0
index cb46dcc..d5eb31d 100644
@@ -43,6 +43,7 @@
 #include "ipc.h"
 #include "bluetooth.h"
 #include "avrcp.h"
+#include "utils.h"
 
 #define L2CAP_PSM_AVCTP 0x17
 
@@ -699,6 +700,7 @@ static const struct avrcp_control_handler control_handlers[] = {
 static int avrcp_device_add_session(struct avrcp_device *dev, int fd,
 						uint16_t imtu, uint16_t omtu)
 {
+	struct hal_ev_avrcp_remote_features ev;
 	char address[18];
 
 	dev->session = avrcp_new(fd, imtu, omtu, dev->version);
@@ -717,6 +719,21 @@ static int avrcp_device_add_session(struct avrcp_device *dev, int fd,
 	/* FIXME: get the real name of the device */
 	avrcp_init_uinput(dev->session, "bluetooth", address);
 
+	bdaddr2android(&dev->dst, ev.bdaddr);
+	ev.features = HAL_AVRCP_FEATURE_NONE;
+
+	DBG("version 0x%02x", dev->version);
+
+	if (dev->version < 0x0103)
+		goto done;
+
+	ev.features |= HAL_AVRCP_FEATURE_METADATA;
+
+done:
+	ipc_send_notif(hal_ipc, HAL_SERVICE_ID_AVRCP,
+					HAL_EV_AVRCP_REMOTE_FEATURES,
+					sizeof(ev), &ev);
+
 	return 0;
 }
 
Signature · 1 line
1.8.5.3
author maintainer
#1 lore raw

PATCH v2 2/4 android/client: Add AVRCP remote_features_cb support

From: Luiz Augusto von Dentz <[email protected]>

---
 android/client/if-rc.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
android/client/if-rc.c +10 -0
index 55fdf1d..60c3247 100644
@@ -46,6 +46,15 @@ SINTMAP(btrc_media_attr_t, -1, "(unknown)")
 	DELEMENT(BTRC_MEDIA_ATTR_PLAYING_TIME),
 ENDMAP
 
+static char last_addr[MAX_ADDR_STR_LEN];
+
+static void remote_features_cb(bt_bdaddr_t *bd_addr,
+					btrc_remote_features_t features)
+{
+	haltest_info("%s: remote_bd_addr=%s features=%u\n", __func__,
+				bt_bdaddr_t2str(bd_addr, last_addr), features);
+}
+
 static void get_play_status_cb(void)
 {
 	haltest_info("%s\n", __func__);
@@ -73,6 +82,7 @@ static void volume_change_cb(uint8_t volume, uint8_t ctype)
 
 static btrc_callbacks_t rc_cbacks = {
 	.size = sizeof(rc_cbacks),
+	.remote_features_cb = remote_features_cb,
 	.get_play_status_cb = get_play_status_cb,
 	.get_element_attr_cb = get_element_attr_cb,
 	.register_notification_cb = register_notification_cb,
Signature · 1 line
1.8.5.3
author maintainer
#2 lore raw

PATCH v2 3/4 android/arvrcp: Fix not parsing SDP record correctly

In reply to Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

---
 android/avrcp.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)
android/avrcp.c +15 -7
index d5eb31d..911b1df 100644
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#include <stdlib.h>
 #include <stdbool.h>
 #include <errno.h>
 #include <glib.h>
@@ -817,15 +818,22 @@ static void search_cb(sdp_list_t *recs, int err, gpointer data)
 
 	for (list = recs; list; list = list->next) {
 		sdp_record_t *rec = list->data;
-		sdp_data_t *data;
+		sdp_list_t *l;
+		sdp_profile_desc_t *desc;
+		int features;
 
-		data = sdp_data_get(rec, SDP_ATTR_VERSION);
-		if (data)
-			dev->version = data->val.uint16;
+		if (sdp_get_profile_descs(rec, &l) < 0)
+			continue;
 
-		data = sdp_data_get(rec, SDP_ATTR_SUPPORTED_FEATURES);
-		if (data)
-			dev->features = data->val.uint16;
+		desc = l->data;
+		dev->version = desc->version;
+
+		if (sdp_get_int_attr(rec, SDP_ATTR_SUPPORTED_FEATURES,
+							&features) == 0)
+			dev->features = features;
+
+		sdp_list_free(l, free);
+		break;
 	}
 
 	if (dev->io) {
Signature · 1 line
1.8.5.3
author maintainer
#3 lore raw

PATCH v2 4/4 android/avrcp: Fix warnings when freeing avrcp_device struct

In reply to Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

If the device does not yet have queue due to not have a session it cause the following warnings when avrcp_device_free is called:
(bluetoothd:1102): GLib-CRITICAL **: g_queue_foreach: assertion 'queue != NULL' failed (bluetoothd:1102): GLib-CRITICAL **: g_queue_free: assertion 'queue != NULL' failed

---
 android/avrcp.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
android/avrcp.c +4 -2
index 911b1df..1d211ad 100644
@@ -442,8 +442,10 @@ static void avrcp_device_free(void *data)
 {
 	struct avrcp_device *dev = data;
 
-	g_queue_foreach(dev->queue, (GFunc) g_free, NULL);
-	g_queue_free(dev->queue);
+	if (dev->queue) {
+		g_queue_foreach(dev->queue, (GFunc) g_free, NULL);
+		g_queue_free(dev->queue);
+	}
 
 	if (dev->session)
 		avrcp_shutdown(dev->session);
Signature · 1 line
1.8.5.3
author maintainer
#4 lore raw
In reply to Luiz Augusto von Dentz

Hi,

Quoted 51 lines · Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

---
v2: Keep uint16_t as type of device features.

 android/avrcp.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
android/avrcp.c +17 -1
index cb46dcc..d5eb31d 100644
@@ -43,6 +43,7 @@
 #include "ipc.h"
 #include "bluetooth.h"
 #include "avrcp.h"
+#include "utils.h"
 
 #define L2CAP_PSM_AVCTP 0x17
 
@@ -699,6 +700,7 @@ static const struct avrcp_control_handler control_handlers[] = {
 static int avrcp_device_add_session(struct avrcp_device *dev, int fd,
                                                uint16_t imtu, uint16_t omtu)
 {
+       struct hal_ev_avrcp_remote_features ev;
        char address[18];
 
        dev->session = avrcp_new(fd, imtu, omtu, dev->version);
@@ -717,6 +719,21 @@ static int avrcp_device_add_session(struct avrcp_device *dev, int fd,
        /* FIXME: get the real name of the device */
        avrcp_init_uinput(dev->session, "bluetooth", address);
 
+       bdaddr2android(&dev->dst, ev.bdaddr);
+       ev.features = HAL_AVRCP_FEATURE_NONE;
+
+       DBG("version 0x%02x", dev->version);
+
+       if (dev->version < 0x0103)
+               goto done;
+
+       ev.features |= HAL_AVRCP_FEATURE_METADATA;
+
+done:
+       ipc_send_notif(hal_ipc, HAL_SERVICE_ID_AVRCP,
+                                       HAL_EV_AVRCP_REMOTE_FEATURES,
+                                       sizeof(ev), &ev);
+
        return 0;
 }
 
--
Quoted 1 line

1.8.5.3

Pushed.

Signature · 1 line
Luiz Augusto von Dentz