}
}
- ccb.p_ctrl_cback = bta_av_rc_ctrl_cback;
- ccb.p_msg_cback = bta_av_rc_msg_cback;
+ ccb.ctrl_cback = base::Bind(bta_av_rc_ctrl_cback);
+ ccb.msg_cback = base::Bind(bta_av_rc_msg_cback);
ccb.company_id = p_bta_av_cfg->company_id;
ccb.conn = role;
/* note: BTA_AV_FEAT_RCTG = AVRC_CT_TARGET, BTA_AV_FEAT_RCCT = AVRC_CT_CONTROL
/* searching for UUID_SERVCLASS_AV_REMOTE_CONTROL gets both TG and CT */
if (AVRC_FindService(UUID_SERVCLASS_AV_REMOTE_CONTROL, *p_addr, &db_params,
- bta_av_avrc_sdp_cback) == AVRC_SUCCESS) {
+ base::Bind(bta_av_avrc_sdp_cback)) == AVRC_SUCCESS) {
p_cb->disc = disc;
APPL_TRACE_DEBUG("%s: disc 0x%x", __func__, p_cb->disc);
}
const RawAddress* peer_addr) {
uint8_t avrc_event;
- if (event <= AVRC_MAX_RCV_CTRL_EVT && avrc_cb.ccb[handle].p_ctrl_cback) {
+ if (event <= AVRC_MAX_RCV_CTRL_EVT && avrc_cb.ccb[handle].ctrl_cback) {
avrc_event = avrc_ctrl_event_map[event];
if (event == AVCT_CONNECT_CFM_EVT) {
if (result != 0) /* failed */
avrc_event = AVRC_CLOSE_IND_EVT;
}
- (*avrc_cb.ccb[handle].p_ctrl_cback)(handle, avrc_event, result, peer_addr);
+ avrc_cb.ccb[handle].ctrl_cback.Run(handle, avrc_event, result, peer_addr);
}
if ((event == AVCT_DISCONNECT_CFM_EVT) ||
param->handle, param->label);
/* Notify app */
- if (avrc_cb.ccb[param->handle].p_ctrl_cback) {
- (*avrc_cb.ccb[param->handle].p_ctrl_cback)(
+ if (avrc_cb.ccb[param->handle].ctrl_cback) {
+ avrc_cb.ccb[param->handle].ctrl_cback.Run(
param->handle, AVRC_CMD_TIMEOUT_EVT, param->label, NULL);
}
if (!drop) {
msg.hdr.opcode = opcode;
- (*avrc_cb.ccb[handle].p_msg_cback)(handle, label, opcode, &msg);
+ avrc_cb.ccb[handle].msg_cback.Run(handle, label, opcode, &msg);
} else {
AVRC_TRACE_WARNING("%s %s msg handle:%d, control:%d, cr:%d, opcode:x%x",
__func__, p_drop_msg, handle,
status = AVCT_CreateConn(p_handle, &cc, peer_addr);
if (status == AVCT_SUCCESS) {
- memcpy(&avrc_cb.ccb[*p_handle], p_ccb, sizeof(tAVRC_CONN_CB));
+ avrc_cb.ccb[*p_handle] = *p_ccb;
memset(&avrc_cb.ccb_int[*p_handle], 0, sizeof(tAVRC_CONN_INT_CB));
memset(&avrc_cb.fcb[*p_handle], 0, sizeof(tAVRC_FRAG_CB));
memset(&avrc_cb.rcb[*p_handle], 0, sizeof(tAVRC_RASM_CB));
ccb_int[AVCT_NUM_CONN]; /* Internal connection control block */
tAVRC_FRAG_CB fcb[AVCT_NUM_CONN];
tAVRC_RASM_CB rcb[AVCT_NUM_CONN];
- tAVRC_FIND_CBACK* p_cback; /* pointer to application callback */
+ tAVRC_FIND_CBACK find_cback; /* sdp discovery callback */
tSDP_DISCOVERY_DB* p_db; /* pointer to discovery database */
uint16_t service_uuid; /* service UUID to search */
uint8_t trace_level;
avrc_cb.service_uuid = 0;
/* return info from sdp record in app callback function */
- (*avrc_cb.p_cback)(status);
+ avrc_cb.find_cback.Run(status);
return;
}
*****************************************************************************/
uint16_t AVRC_FindService(uint16_t service_uuid, const RawAddress& bd_addr,
tAVRC_SDP_DB_PARAMS* p_db,
- tAVRC_FIND_CBACK* p_cback) {
+ const tAVRC_FIND_CBACK& find_cback) {
bool result = true;
AVRC_TRACE_API("%s uuid: %x", __func__, service_uuid);
if ((service_uuid != UUID_SERVCLASS_AV_REM_CTRL_TARGET &&
service_uuid != UUID_SERVCLASS_AV_REMOTE_CONTROL) ||
- p_db == NULL || p_db->p_db == NULL || p_cback == NULL)
+ p_db == NULL || p_db->p_db == NULL || find_cback.is_null())
return AVRC_BAD_PARAM;
/* check if it is busy */
/* store service_uuid and discovery db pointer */
avrc_cb.p_db = p_db->p_db;
avrc_cb.service_uuid = service_uuid;
- avrc_cb.p_cback = p_cback;
+ avrc_cb.find_cback = find_cback;
/* perform service search */
result =
******************************************************************************/
#ifndef AVRC_API_H
#define AVRC_API_H
+
+#include <base/bind.h>
+
#include "avct_api.h"
#include "avrc_defs.h"
#include "bt_target.h"
* implementation of this callback function must copy the p_service_name
* and p_provider_name parameters passed to it as they are not guaranteed
* to remain after the callback function exits. */
-typedef void(tAVRC_FIND_CBACK)(uint16_t status);
+using tAVRC_FIND_CBACK = base::Callback<void(uint16_t status)>;
/* This is the control callback function. This function passes events
* listed in Table 20 to the application. */
-typedef void(tAVRC_CTRL_CBACK)(uint8_t handle, uint8_t event, uint16_t result,
- const RawAddress* peer_addr);
+using tAVRC_CTRL_CBACK =
+ base::Callback<void(uint8_t handle, uint8_t event, uint16_t result,
+ const RawAddress* peer_addr)>;
/* This is the message callback function. It is executed when AVCTP has
* a message packet ready for the application. The implementation of this
* callback function must copy the tAVRC_MSG structure passed to it as it
* is not guaranteed to remain after the callback function exits. */
-typedef void(tAVRC_MSG_CBACK)(uint8_t handle, uint8_t label, uint8_t opcode,
- tAVRC_MSG* p_msg);
+using tAVRC_MSG_CBACK = base::Callback<void(uint8_t handle, uint8_t label,
+ uint8_t opcode, tAVRC_MSG* p_msg)>;
typedef struct {
- tAVRC_CTRL_CBACK* p_ctrl_cback; /* pointer to application control callback */
- tAVRC_MSG_CBACK* p_msg_cback; /* pointer to application message callback */
+ tAVRC_CTRL_CBACK ctrl_cback; /* application control callback */
+ tAVRC_MSG_CBACK msg_cback; /* application message callback */
uint32_t company_id; /* the company ID */
uint8_t conn; /* Connection role (Initiator/acceptor) */
uint8_t control; /* Control role (Control/Target) */
extern uint16_t AVRC_FindService(uint16_t service_uuid,
const RawAddress& bd_addr,
tAVRC_SDP_DB_PARAMS* p_db,
- tAVRC_FIND_CBACK* p_cback);
+ const tAVRC_FIND_CBACK& cback);
/******************************************************************************
*