diff --git a/audio/avctp.c b/audio/avctp.c
index 20aed66..157b9fa 100644
--- a/audio/avctp.c
+++ b/audio/avctp.c
struct avctp_server {
bdaddr_t src;
- GIOChannel *io;
+ GIOChannel *control_io;
GSList *sessions;
};
int uinput;
- GIOChannel *io;
- guint io_id;
+ GIOChannel *control_io;
+ guint control_io_id;
- uint16_t mtu;
+ uint16_t control_mtu;
uint8_t key_quirks[256];
GSList *handlers;
struct avctp_pdu_handler {
uint8_t opcode;
- avctp_pdu_cb cb;
+ avctp_control_pdu_cb cb;
void *user_data;
unsigned int id;
};
static GSList *callbacks = NULL;
static GSList *servers = NULL;
-static GSList *handlers = NULL;
+static GSList *control_handlers = NULL;
static uint8_t id = 0;
static void auth_cb(DBusError *derr, void *user_data);
if (!session)
return;
- if (session->io) {
- g_io_channel_shutdown(session->io, TRUE, NULL);
- g_io_channel_unref(session->io);
- session->io = NULL;
+ if (session->control_io) {
+ g_io_channel_shutdown(session->control_io, TRUE, NULL);
+ g_io_channel_unref(session->control_io);
+ session->control_io = NULL;
}
- if (session->io_id) {
- g_source_remove(session->io_id);
- session->io_id = 0;
+ if (session->control_io_id) {
+ g_source_remove(session->control_io_id);
+ session->control_io_id = 0;
if (session->state == AVCTP_STATE_CONNECTING) {
struct audio_device *dev;
if (cond & (G_IO_ERR | G_IO_HUP | G_IO_NVAL))
goto failed;
- sock = g_io_channel_unix_get_fd(session->io);
+ sock = g_io_channel_unix_get_fd(session->control_io);
ret = read(sock, buf, sizeof(buf));
if (ret <= 0)
goto done;
}
- handler = find_handler(handlers, avc->opcode);
+ handler = find_handler(control_handlers, avc->opcode);
if (!handler) {
DBG("handler not found for 0x%02x", avc->opcode);
packet_size += avrcp_handle_vendor_reject(&code, operands);
DBG("AVCTP: connected to %s", address);
- if (!session->io)
- session->io = g_io_channel_ref(chan);
+ if (!session->control_io)
+ session->control_io = g_io_channel_ref(chan);
init_uinput(session);
avctp_set_state(session, AVCTP_STATE_CONNECTED);
- session->mtu = imtu;
- session->io_id = g_io_add_watch(chan,
+ session->control_mtu = imtu;
+ session->control_io_id = g_io_add_watch(chan,
G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL,
(GIOFunc) session_cb, session);
}
struct avctp *session = user_data;
GError *err = NULL;
- if (session->io_id) {
- g_source_remove(session->io_id);
- session->io_id = 0;
+ if (session->control_io_id) {
+ g_source_remove(session->control_io_id);
+ session->control_io_id = 0;
}
if (derr && dbus_error_is_set(derr)) {
return;
}
- if (!bt_io_accept(session->io, avctp_connect_cb, session,
+ if (!bt_io_accept(session->control_io, avctp_connect_cb, session,
NULL, &err)) {
error("bt_io_accept: %s", err->message);
g_error_free(err);
goto drop;
}
- if (session->io) {
+ if (session->control_io) {
error("Refusing unexpected connect from %s", address);
goto drop;
}
avctp_set_state(session, AVCTP_STATE_CONNECTING);
- session->io = g_io_channel_ref(chan);
+ session->control_io = g_io_channel_ref(chan);
if (audio_device_request_authorization(dev, AVRCP_TARGET_UUID,
auth_cb, session) < 0)
goto drop;
- session->io_id = g_io_add_watch(chan, G_IO_ERR | G_IO_HUP | G_IO_NVAL,
- session_cb, session);
+ session->control_io_id = g_io_add_watch(chan,
+ G_IO_ERR | G_IO_HUP | G_IO_NVAL,
+ session_cb, session);
return;
drop:
- if (!session || !session->io)
+ if (!session || !session->control_io)
g_io_channel_shutdown(chan, TRUE, NULL);
if (session)
avctp_set_state(session, AVCTP_STATE_DISCONNECTED);
server = g_new0(struct avctp_server, 1);
- server->io = avctp_server_socket(src, master);
- if (!server->io) {
+ server->control_io = avctp_server_socket(src, master);
+ if (!server->control_io) {
g_free(server);
return -1;
}
servers = g_slist_remove(servers, server);
- g_io_channel_shutdown(server->io, TRUE, NULL);
- g_io_channel_unref(server->io);
+ g_io_channel_shutdown(server->control_io, TRUE, NULL);
+ g_io_channel_unref(server->control_io);
g_free(server);
if (servers)
operands[0] = op & 0x7f;
operands[1] = 0;
- sk = g_io_channel_unix_get_fd(session->io);
+ sk = g_io_channel_unix_get_fd(session->control_io);
if (write(sk, buf, sizeof(buf)) < 0)
return -errno;
if (session->state != AVCTP_STATE_CONNECTED)
return -ENOTCONN;
- sk = g_io_channel_unix_get_fd(session->io);
+ sk = g_io_channel_unix_get_fd(session->control_io);
memset(buf, 0, sizeof(buf));
return FALSE;
}
-unsigned int avctp_register_pdu_handler(uint8_t opcode, avctp_pdu_cb cb,
+unsigned int avctp_register_pdu_handler(uint8_t opcode, avctp_control_pdu_cb cb,
void *user_data)
{
struct avctp_pdu_handler *handler;
static unsigned int id = 0;
- handler = find_handler(handlers, opcode);
+ handler = find_handler(control_handlers, opcode);
if (handler)
return 0;
handler->user_data = user_data;
handler->id = ++id;
- handlers = g_slist_append(handlers, handler);
+ control_handlers = g_slist_append(control_handlers, handler);
return handler->id;
}
{
GSList *l;
- for (l = handlers; l != NULL; l = l->next) {
+ for (l = control_handlers; l != NULL; l = l->next) {
struct avctp_pdu_handler *handler = l->data;
if (handler->id == id) {
- handlers = g_slist_remove(handlers, handler);
+ control_handlers = g_slist_remove(control_handlers,
+ handler);
g_free(handler);
return TRUE;
}
return NULL;
}
- session->io = io;
+ session->control_io = io;
return session;
}
void avctp_disconnect(struct avctp *session)
{
- if (!session->io)
+ if (!session->control_io)
return;
avctp_set_state(session, AVCTP_STATE_DISCONNECTED);
diff --git a/audio/avctp.h b/audio/avctp.h
index 9d19b5d..6d22759 100644
--- a/audio/avctp.h
+++ b/audio/avctp.h
avctp_state_t new_state,
void *user_data);
-typedef size_t (*avctp_pdu_cb) (struct avctp *session, uint8_t transaction,
- uint8_t *code, uint8_t *subunit,
- uint8_t *operands, size_t operand_count,
- void *user_data);
+typedef size_t (*avctp_control_pdu_cb) (struct avctp *session,
+ uint8_t transaction, uint8_t *code,
+ uint8_t *subunit, uint8_t *operands,
+ size_t operand_count, void *user_data);
typedef gboolean (*avctp_rsp_cb) (struct avctp *session, uint8_t code,
uint8_t subunit, uint8_t *operands,
size_t operand_count, void *user_data);
struct avctp *avctp_get(const bdaddr_t *src, const bdaddr_t *dst);
void avctp_disconnect(struct avctp *session);
-unsigned int avctp_register_pdu_handler(uint8_t opcode, avctp_pdu_cb cb,
+unsigned int avctp_register_pdu_handler(uint8_t opcode, avctp_control_pdu_cb cb,
void *user_data);
gboolean avctp_unregister_pdu_handler(unsigned int id);
diff --git a/audio/avrcp.c b/audio/avrcp.c
index d2a9855..e2bdc5b 100644
--- a/audio/avrcp.c
+++ b/audio/avrcp.c
struct avctp *session;
struct audio_device *dev;
- unsigned int handler;
+ unsigned int control_handler;
uint16_t registered_events;
uint8_t transaction_events[AVRCP_EVENT_LAST + 1];
struct pending_pdu *pending_pdu;
sdp_list_t *svclass_id, *pfseq, *apseq, *root, *apseq_browsing;
uuid_t root_uuid, l2cap, avctp, avrtg;
sdp_profile_desc_t profile[1];
- sdp_list_t *aproto, *proto[2];
+ sdp_list_t *aproto_control, *proto_control[2];
sdp_record_t *record;
- sdp_data_t *psm, *version, *features, *psm_browsing;
+ sdp_data_t *psm_control, *version, *features, *psm_browsing;
sdp_list_t *aproto_browsing, *proto_browsing[2] = {0};
uint16_t lp = AVCTP_CONTROL_PSM;
uint16_t lp_browsing = AVCTP_BROWSING_PSM;
/* Protocol Descriptor List */
sdp_uuid16_create(&l2cap, L2CAP_UUID);
- proto[0] = sdp_list_append(0, &l2cap);
- psm = sdp_data_alloc(SDP_UINT16, &lp);
- proto[0] = sdp_list_append(proto[0], psm);
- apseq = sdp_list_append(0, proto[0]);
+ proto_control[0] = sdp_list_append(0, &l2cap);
+ psm_control = sdp_data_alloc(SDP_UINT16, &lp);
+ proto_control[0] = sdp_list_append(proto_control[0], psm_control);
+ apseq = sdp_list_append(0, proto_control[0]);
sdp_uuid16_create(&avctp, AVCTP_UUID);
- proto[1] = sdp_list_append(0, &avctp);
+ proto_control[1] = sdp_list_append(0, &avctp);
version = sdp_data_alloc(SDP_UINT16, &avctp_ver);
- proto[1] = sdp_list_append(proto[1], version);
- apseq = sdp_list_append(apseq, proto[1]);
+ proto_control[1] = sdp_list_append(proto_control[1], version);
+ apseq = sdp_list_append(apseq, proto_control[1]);
- aproto = sdp_list_append(0, apseq);
- sdp_set_access_protos(record, aproto);
+ aproto_control = sdp_list_append(0, apseq);
+ sdp_set_access_protos(record, aproto_control);
proto_browsing[0] = sdp_list_append(0, &l2cap);
psm_browsing = sdp_data_alloc(SDP_UINT16, &lp_browsing);
proto_browsing[0] = sdp_list_append(proto_browsing[0], psm_browsing);
sdp_list_free(apseq_browsing, 0);
sdp_list_free(aproto_browsing, 0);
- free(psm);
+ free(psm_control);
free(version);
- sdp_list_free(proto[0], 0);
- sdp_list_free(proto[1], 0);
+ sdp_list_free(proto_control[0], 0);
+ sdp_list_free(proto_control[1], 0);
sdp_list_free(apseq, 0);
- sdp_list_free(aproto, 0);
+ sdp_list_free(aproto_control, 0);
sdp_list_free(pfseq, 0);
sdp_list_free(root, 0);
sdp_list_free(svclass_id, 0);
return AVC_CTYPE_REJECTED;
}
-static struct pdu_handler {
+static struct control_pdu_handler {
uint8_t pdu_id;
uint8_t code;
uint8_t (*func) (struct avrcp_player *player,
struct avrcp_header *pdu,
uint8_t transaction);
-} handlers[] = {
+} control_handlers[] = {
{ AVRCP_GET_CAPABILITIES, AVC_CTYPE_STATUS,
avrcp_handle_get_capabilities },
{ AVRCP_LIST_PLAYER_ATTRIBUTES, AVC_CTYPE_STATUS,
void *user_data)
{
struct avrcp_player *player = user_data;
- struct pdu_handler *handler;
+ struct control_pdu_handler *handler;
struct avrcp_header *pdu = (void *) operands;
uint32_t company_id = get_company_id(pdu->company_id);
goto err_metadata;
}
- for (handler = handlers; handler->pdu_id; handler++) {
+ for (handler = control_handlers; handler->pdu_id; handler++) {
if (handler->pdu_id == pdu->pdu_id)
break;
}
player->dev = NULL;
player->registered_events = 0;
- if (player->handler) {
- avctp_unregister_pdu_handler(player->handler);
- player->handler = 0;
+ if (player->control_handler) {
+ avctp_unregister_pdu_handler(player->control_handler);
+ player->control_handler = 0;
}
break;
player->session = avctp_connect(&dev->src, &dev->dst);
player->dev = dev;
- if (!player->handler)
- player->handler = avctp_register_pdu_handler(
+ if (!player->control_handler)
+ player->control_handler = avctp_register_pdu_handler(
AVC_OP_VENDORDEP,
handle_vendordep_pdu,
player);
player_abort_pending_pdu(player);
- if (player->handler)
- avctp_unregister_pdu_handler(player->handler);
+ if (player->control_handler)
+ avctp_unregister_pdu_handler(player->control_handler);
g_free(player);
}