summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2014-04-01 13:27:51 +0300
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2014-04-02 14:25:40 +0300
commit97518af91a9de8d48d6363e26058c495e1bc7030 (patch)
treecf2b462175e35443f6f7f48c7674d9d966ef3b18
parentac93ba0e4465b248ffbb9c23a1582d52f69edda1 (diff)
downloadbluez-97518af91a9de8d48d6363e26058c495e1bc7030.tar.gz
android/avrcp-lib: Add support for parsing SetAddressed response
-rw-r--r--android/avrcp-lib.c35
-rw-r--r--android/avrcp-lib.h5
-rw-r--r--unit/test-avrcp.c3
3 files changed, 36 insertions, 7 deletions
diff --git a/android/avrcp-lib.c b/android/avrcp-lib.c
index cf7dadfad..c218fd7fd 100644
--- a/android/avrcp-lib.c
+++ b/android/avrcp-lib.c
@@ -1463,8 +1463,36 @@ int avrcp_get_element_attributes(struct avrcp *session)
get_element_attributes_rsp, session);
}
-int avrcp_set_addressed_player(struct avrcp *session, uint16_t player_id,
- avctp_rsp_cb func, void *user_data)
+static gboolean set_addressed_rsp(struct avctp *conn,
+ uint8_t code, uint8_t subunit,
+ uint8_t *operands, size_t operand_count,
+ void *user_data)
+{
+ struct avrcp *session = user_data;
+ struct avrcp_player *player = session->player;
+ struct avrcp_header *pdu;
+ int err;
+
+ DBG("");
+
+ if (!player || !player->cfm || !player->cfm->set_addressed)
+ return FALSE;
+
+ pdu = parse_pdu(operands, operand_count);
+ if (!pdu) {
+ err = -EPROTO;
+ goto done;
+ }
+
+ err = parse_status(pdu);
+
+done:
+ player->cfm->set_addressed(session, err, player->user_data);
+
+ return FALSE;
+}
+
+int avrcp_set_addressed_player(struct avrcp *session, uint16_t player_id)
{
uint8_t params[2];
@@ -1472,7 +1500,8 @@ int avrcp_set_addressed_player(struct avrcp *session, uint16_t player_id,
return avrcp_send_req(session, AVC_CTYPE_CONTROL, AVC_SUBUNIT_PANEL,
AVRCP_SET_ADDRESSED_PLAYER, params,
- sizeof(params), func, user_data);
+ sizeof(params), set_addressed_rsp,
+ session);
}
int avrcp_get_capabilities_rsp(struct avrcp *session, uint8_t transaction,
diff --git a/android/avrcp-lib.h b/android/avrcp-lib.h
index 0b867aa91..5c5790ab0 100644
--- a/android/avrcp-lib.h
+++ b/android/avrcp-lib.h
@@ -194,6 +194,8 @@ struct avrcp_control_cfm {
bool (*register_notification) (struct avrcp *session, int err,
uint8_t code, uint8_t event,
uint8_t *params, void *user_data);
+ void (*set_addressed) (struct avrcp *session, int err,
+ void *user_data);
};
struct avrcp_passthrough_handler {
@@ -237,8 +239,7 @@ int avrcp_get_play_status(struct avrcp *session);
int avrcp_set_volume(struct avrcp *session, uint8_t volume, avctp_rsp_cb func,
void *user_data);
int avrcp_get_element_attributes(struct avrcp *session);
-int avrcp_set_addressed_player(struct avrcp *session, uint16_t player_id,
- avctp_rsp_cb func, void *user_data);
+int avrcp_set_addressed_player(struct avrcp *session, uint16_t player_id);
int avrcp_get_capabilities_rsp(struct avrcp *session, uint8_t transaction,
uint8_t number, uint8_t *events);
diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c
index 5b259bdd4..73fd58d8c 100644
--- a/unit/test-avrcp.c
+++ b/unit/test-avrcp.c
@@ -487,8 +487,7 @@ static void test_client(gconstpointer data)
struct context *context = create_context(0x0100, data);
if (g_str_equal(context->data->test_name, "/TP/MPS/BV-01-C"))
- avrcp_set_addressed_player(context->session, 0xabcd, NULL,
- NULL);
+ avrcp_set_addressed_player(context->session, 0xabcd);
if (g_str_equal(context->data->test_name, "/TP/CFG/BV-01-C"))
avrcp_get_capabilities(context->session, CAP_EVENTS_SUPPORTED);