component/bt: format the new source files

This commit is contained in:
wangmengyang 2017-03-17 22:46:49 +08:00
parent a849ce9942
commit e132e95476
51 changed files with 3496 additions and 5105 deletions

104
components/bt/bluedroid/bta/ar/bta_ar.c Executable file → Normal file
View file

@ -46,12 +46,9 @@ tBTA_AR_CB bta_ar_cb;
static UINT8 bta_ar_id(tBTA_SYS_ID sys_id) static UINT8 bta_ar_id(tBTA_SYS_ID sys_id)
{ {
UINT8 mask = 0; UINT8 mask = 0;
if (sys_id == BTA_ID_AV) if (sys_id == BTA_ID_AV) {
{
mask = BTA_AR_AV_MASK; mask = BTA_AR_AV_MASK;
} } else if (sys_id == BTA_ID_AVK) {
else if (sys_id == BTA_ID_AVK)
{
mask = BTA_AR_AVK_MASK; mask = BTA_AR_AVK_MASK;
} }
@ -85,11 +82,13 @@ void bta_ar_init(void)
static void bta_ar_avdt_cback(UINT8 handle, BD_ADDR bd_addr, UINT8 event, tAVDT_CTRL *p_data) static void bta_ar_avdt_cback(UINT8 handle, BD_ADDR bd_addr, UINT8 event, tAVDT_CTRL *p_data)
{ {
/* route the AVDT registration callback to av or avk */ /* route the AVDT registration callback to av or avk */
if (bta_ar_cb.p_av_conn_cback) if (bta_ar_cb.p_av_conn_cback) {
(*bta_ar_cb.p_av_conn_cback)(handle, bd_addr, event, p_data); (*bta_ar_cb.p_av_conn_cback)(handle, bd_addr, event, p_data);
if (bta_ar_cb.p_avk_conn_cback) }
if (bta_ar_cb.p_avk_conn_cback) {
(*bta_ar_cb.p_avk_conn_cback)(handle, bd_addr, event, p_data); (*bta_ar_cb.p_avk_conn_cback)(handle, bd_addr, event, p_data);
} }
}
/******************************************************************************* /*******************************************************************************
** **
@ -104,27 +103,21 @@ void bta_ar_reg_avdt(tAVDT_REG *p_reg, tAVDT_CTRL_CBACK *p_cback, tBTA_SYS_ID sy
{ {
UINT8 mask = 0; UINT8 mask = 0;
if (sys_id == BTA_ID_AV) if (sys_id == BTA_ID_AV) {
{
bta_ar_cb.p_av_conn_cback = p_cback; bta_ar_cb.p_av_conn_cback = p_cback;
mask = BTA_AR_AV_MASK; mask = BTA_AR_AV_MASK;
} } else if (sys_id == BTA_ID_AVK) {
else if (sys_id == BTA_ID_AVK)
{
bta_ar_cb.p_avk_conn_cback = p_cback; bta_ar_cb.p_avk_conn_cback = p_cback;
mask = BTA_AR_AVK_MASK; mask = BTA_AR_AVK_MASK;
} }
#if (BTA_AR_DEBUG == TRUE) #if (BTA_AR_DEBUG == TRUE)
else else {
{
APPL_TRACE_ERROR("bta_ar_reg_avdt: the registration is from wrong sys_id:%d", sys_id); APPL_TRACE_ERROR("bta_ar_reg_avdt: the registration is from wrong sys_id:%d", sys_id);
} }
#endif #endif
if (mask) if (mask) {
{ if (bta_ar_cb.avdt_registered == 0) {
if (bta_ar_cb.avdt_registered == 0)
{
AVDT_Register(p_reg, bta_ar_avdt_cback); AVDT_Register(p_reg, bta_ar_avdt_cback);
} }
bta_ar_cb.avdt_registered |= mask; bta_ar_cb.avdt_registered |= mask;
@ -144,21 +137,19 @@ void bta_ar_dereg_avdt(tBTA_SYS_ID sys_id)
{ {
UINT8 mask = 0; UINT8 mask = 0;
if (sys_id == BTA_ID_AV) if (sys_id == BTA_ID_AV) {
{
bta_ar_cb.p_av_conn_cback = NULL; bta_ar_cb.p_av_conn_cback = NULL;
mask = BTA_AR_AV_MASK; mask = BTA_AR_AV_MASK;
} } else if (sys_id == BTA_ID_AVK) {
else if (sys_id == BTA_ID_AVK)
{
bta_ar_cb.p_avk_conn_cback = NULL; bta_ar_cb.p_avk_conn_cback = NULL;
mask = BTA_AR_AVK_MASK; mask = BTA_AR_AVK_MASK;
} }
bta_ar_cb.avdt_registered &= ~mask; bta_ar_cb.avdt_registered &= ~mask;
if (bta_ar_cb.avdt_registered == 0) if (bta_ar_cb.avdt_registered == 0) {
AVDT_Deregister(); AVDT_Deregister();
} }
}
/******************************************************************************* /*******************************************************************************
** **
@ -177,17 +168,12 @@ void bta_ar_avdt_conn(tBTA_SYS_ID sys_id, BD_ADDR bd_addr)
UINT8 event = BTA_AR_AVDT_CONN_EVT; UINT8 event = BTA_AR_AVDT_CONN_EVT;
tAVDT_CTRL data; tAVDT_CTRL data;
if (sys_id == BTA_ID_AV) if (sys_id == BTA_ID_AV) {
{ if (bta_ar_cb.p_avk_conn_cback) {
if (bta_ar_cb.p_avk_conn_cback)
{
(*bta_ar_cb.p_avk_conn_cback)(0, bd_addr, event, &data); (*bta_ar_cb.p_avk_conn_cback)(0, bd_addr, event, &data);
} }
} } else if (sys_id == BTA_ID_AVK) {
else if (sys_id == BTA_ID_AVK) if (bta_ar_cb.p_av_conn_cback) {
{
if (bta_ar_cb.p_av_conn_cback)
{
(*bta_ar_cb.p_av_conn_cback)(0, bd_addr, event, &data); (*bta_ar_cb.p_av_conn_cback)(0, bd_addr, event, &data);
} }
} }
@ -206,10 +192,8 @@ void bta_ar_reg_avct(UINT16 mtu, UINT16 mtu_br, UINT8 sec_mask, tBTA_SYS_ID sys_
{ {
UINT8 mask = bta_ar_id (sys_id); UINT8 mask = bta_ar_id (sys_id);
if (mask) if (mask) {
{ if (bta_ar_cb.avct_registered == 0) {
if (bta_ar_cb.avct_registered == 0)
{
AVCT_Register(mtu, mtu_br, sec_mask); AVCT_Register(mtu, mtu_br, sec_mask);
} }
bta_ar_cb.avct_registered |= mask; bta_ar_cb.avct_registered |= mask;
@ -231,9 +215,10 @@ void bta_ar_dereg_avct(tBTA_SYS_ID sys_id)
bta_ar_cb.avct_registered &= ~mask; bta_ar_cb.avct_registered &= ~mask;
if (bta_ar_cb.avct_registered == 0) if (bta_ar_cb.avct_registered == 0) {
AVCT_Deregister(); AVCT_Deregister();
} }
}
/****************************************************************************** /******************************************************************************
** **
@ -250,13 +235,12 @@ void bta_ar_reg_avrc(UINT16 service_uuid, char *service_name, char *provider_nam
UINT8 mask = bta_ar_id (sys_id); UINT8 mask = bta_ar_id (sys_id);
UINT8 temp[8], *p; UINT8 temp[8], *p;
if (!mask || !categories) if (!mask || !categories) {
return; return;
}
if (service_uuid == UUID_SERVCLASS_AV_REM_CTRL_TARGET) if (service_uuid == UUID_SERVCLASS_AV_REM_CTRL_TARGET) {
{ if (bta_ar_cb.sdp_tg_handle == 0) {
if (bta_ar_cb.sdp_tg_handle == 0)
{
bta_ar_cb.tg_registered = mask; bta_ar_cb.tg_registered = mask;
bta_ar_cb.sdp_tg_handle = SDP_CreateRecord(); bta_ar_cb.sdp_tg_handle = SDP_CreateRecord();
AVRC_AddRecord(service_uuid, service_name, provider_name, categories, bta_ar_cb.sdp_tg_handle); AVRC_AddRecord(service_uuid, service_name, provider_name, categories, bta_ar_cb.sdp_tg_handle);
@ -264,19 +248,14 @@ void bta_ar_reg_avrc(UINT16 service_uuid, char *service_name, char *provider_nam
} }
/* only one TG is allowed (first-come, first-served). /* only one TG is allowed (first-come, first-served).
* If sdp_tg_handle is non-0, ignore this request */ * If sdp_tg_handle is non-0, ignore this request */
} } else if ((service_uuid == UUID_SERVCLASS_AV_REMOTE_CONTROL) || (service_uuid == UUID_SERVCLASS_AV_REM_CTRL_CONTROL)) {
else if ((service_uuid == UUID_SERVCLASS_AV_REMOTE_CONTROL) || (service_uuid == UUID_SERVCLASS_AV_REM_CTRL_CONTROL))
{
bta_ar_cb.ct_categories [mask - 1] = categories; bta_ar_cb.ct_categories [mask - 1] = categories;
categories = bta_ar_cb.ct_categories[0] | bta_ar_cb.ct_categories[1]; categories = bta_ar_cb.ct_categories[0] | bta_ar_cb.ct_categories[1];
if (bta_ar_cb.sdp_ct_handle == 0) if (bta_ar_cb.sdp_ct_handle == 0) {
{
bta_ar_cb.sdp_ct_handle = SDP_CreateRecord(); bta_ar_cb.sdp_ct_handle = SDP_CreateRecord();
AVRC_AddRecord(service_uuid, service_name, provider_name, categories, bta_ar_cb.sdp_ct_handle); AVRC_AddRecord(service_uuid, service_name, provider_name, categories, bta_ar_cb.sdp_ct_handle);
bta_sys_add_uuid(service_uuid); bta_sys_add_uuid(service_uuid);
} } else {
else
{
/* multiple CTs are allowed. /* multiple CTs are allowed.
* Change supported categories on the second one */ * Change supported categories on the second one */
p = temp; p = temp;
@ -302,34 +281,27 @@ void bta_ar_dereg_avrc(UINT16 service_uuid, tBTA_SYS_ID sys_id)
UINT16 categories = 0; UINT16 categories = 0;
UINT8 temp[8], *p; UINT8 temp[8], *p;
if (!mask) if (!mask) {
return; return;
}
if (service_uuid == UUID_SERVCLASS_AV_REM_CTRL_TARGET) if (service_uuid == UUID_SERVCLASS_AV_REM_CTRL_TARGET) {
{ if (bta_ar_cb.sdp_tg_handle && mask == bta_ar_cb.tg_registered) {
if (bta_ar_cb.sdp_tg_handle && mask == bta_ar_cb.tg_registered)
{
bta_ar_cb.tg_registered = 0; bta_ar_cb.tg_registered = 0;
SDP_DeleteRecord(bta_ar_cb.sdp_tg_handle); SDP_DeleteRecord(bta_ar_cb.sdp_tg_handle);
bta_ar_cb.sdp_tg_handle = 0; bta_ar_cb.sdp_tg_handle = 0;
bta_sys_remove_uuid(service_uuid); bta_sys_remove_uuid(service_uuid);
} }
} } else if (service_uuid == UUID_SERVCLASS_AV_REMOTE_CONTROL) {
else if (service_uuid == UUID_SERVCLASS_AV_REMOTE_CONTROL) if (bta_ar_cb.sdp_ct_handle) {
{
if (bta_ar_cb.sdp_ct_handle)
{
bta_ar_cb.ct_categories [mask - 1] = 0; bta_ar_cb.ct_categories [mask - 1] = 0;
categories = bta_ar_cb.ct_categories[0] | bta_ar_cb.ct_categories[1]; categories = bta_ar_cb.ct_categories[0] | bta_ar_cb.ct_categories[1];
if (!categories) if (!categories) {
{
/* no CT is still registered - cleaup */ /* no CT is still registered - cleaup */
SDP_DeleteRecord(bta_ar_cb.sdp_ct_handle); SDP_DeleteRecord(bta_ar_cb.sdp_ct_handle);
bta_ar_cb.sdp_ct_handle = 0; bta_ar_cb.sdp_ct_handle = 0;
bta_sys_remove_uuid(service_uuid); bta_sys_remove_uuid(service_uuid);
} } else {
else
{
/* change supported categories to the remaning one */ /* change supported categories to the remaning one */
p = temp; p = temp;
UINT16_TO_BE_STREAM(p, categories); UINT16_TO_BE_STREAM(p, categories);

3
components/bt/bluedroid/bta/ar/bta_ar_int.h Executable file → Normal file
View file

@ -36,8 +36,7 @@
#define BTA_AR_AVK_MASK 0x02 #define BTA_AR_AVK_MASK 0x02
/* data associated with BTA_AR */ /* data associated with BTA_AR */
typedef struct typedef struct {
{
tAVDT_CTRL_CBACK *p_av_conn_cback; /* av connection callback function */ tAVDT_CTRL_CBACK *p_av_conn_cback; /* av connection callback function */
tAVDT_CTRL_CBACK *p_avk_conn_cback; /* avk connection callback function */ tAVDT_CTRL_CBACK *p_avk_conn_cback; /* avk connection callback function */
UINT8 avdt_registered; UINT8 avdt_registered;

785
components/bt/bluedroid/bta/av/bta_av_aact.c Executable file → Normal file

File diff suppressed because it is too large Load diff

680
components/bt/bluedroid/bta/av/bta_av_act.c Executable file → Normal file

File diff suppressed because it is too large Load diff

103
components/bt/bluedroid/bta/av/bta_av_api.c Executable file → Normal file
View file

@ -38,8 +38,7 @@
** Constants ** Constants
*****************************************************************************/ *****************************************************************************/
static const tBTA_SYS_REG bta_av_reg = static const tBTA_SYS_REG bta_av_reg = {
{
bta_av_hdl_event, bta_av_hdl_event,
BTA_AvDisable BTA_AvDisable
}; };
@ -64,8 +63,7 @@ void BTA_AvEnable(tBTA_SEC sec_mask, tBTA_AV_FEAT features, tBTA_AV_CBACK *p_cba
/* register with BTA system manager */ /* register with BTA system manager */
bta_sys_register(BTA_ID_AV, &bta_av_reg); bta_sys_register(BTA_ID_AV, &bta_av_reg);
if ((p_buf = (tBTA_AV_API_ENABLE *) GKI_getbuf(sizeof(tBTA_AV_API_ENABLE))) != NULL) if ((p_buf = (tBTA_AV_API_ENABLE *) GKI_getbuf(sizeof(tBTA_AV_API_ENABLE))) != NULL) {
{
p_buf->hdr.event = BTA_AV_API_ENABLE_EVT; p_buf->hdr.event = BTA_AV_API_ENABLE_EVT;
p_buf->p_cback = p_cback; p_buf->p_cback = p_cback;
p_buf->features = features; p_buf->features = features;
@ -88,8 +86,7 @@ void BTA_AvDisable(void)
BT_HDR *p_buf; BT_HDR *p_buf;
bta_sys_deregister(BTA_ID_AV); bta_sys_deregister(BTA_ID_AV);
if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) {
{
p_buf->event = BTA_AV_API_DISABLE_EVT; p_buf->event = BTA_AV_API_DISABLE_EVT;
bta_sys_sendmsg(p_buf); bta_sys_sendmsg(p_buf);
} }
@ -113,17 +110,13 @@ void BTA_AvRegister(tBTA_AV_CHNL chnl, const char *p_service_name, UINT8 app_id,
tBTA_AV_API_REG *p_buf; tBTA_AV_API_REG *p_buf;
if ((p_buf = (tBTA_AV_API_REG *) GKI_getbuf(sizeof(tBTA_AV_API_REG))) != NULL) if ((p_buf = (tBTA_AV_API_REG *) GKI_getbuf(sizeof(tBTA_AV_API_REG))) != NULL) {
{
p_buf->hdr.layer_specific = chnl; p_buf->hdr.layer_specific = chnl;
p_buf->hdr.event = BTA_AV_API_REGISTER_EVT; p_buf->hdr.event = BTA_AV_API_REGISTER_EVT;
if(p_service_name) if (p_service_name) {
{
BCM_STRNCPY_S(p_buf->p_service_name, sizeof(p_buf->p_service_name), p_service_name, BTA_SERVICE_NAME_LEN); BCM_STRNCPY_S(p_buf->p_service_name, sizeof(p_buf->p_service_name), p_service_name, BTA_SERVICE_NAME_LEN);
p_buf->p_service_name[BTA_SERVICE_NAME_LEN - 1] = 0; p_buf->p_service_name[BTA_SERVICE_NAME_LEN - 1] = 0;
} } else {
else
{
p_buf->p_service_name[0] = 0; p_buf->p_service_name[0] = 0;
} }
p_buf->app_id = app_id; p_buf->app_id = app_id;
@ -146,8 +139,7 @@ void BTA_AvDeregister(tBTA_AV_HNDL hndl)
{ {
BT_HDR *p_buf; BT_HDR *p_buf;
if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) {
{
p_buf->layer_specific = hndl; p_buf->layer_specific = hndl;
p_buf->event = BTA_AV_API_DEREGISTER_EVT; p_buf->event = BTA_AV_API_DEREGISTER_EVT;
bta_sys_sendmsg(p_buf); bta_sys_sendmsg(p_buf);
@ -170,8 +162,7 @@ void BTA_AvOpen(BD_ADDR bd_addr, tBTA_AV_HNDL handle, BOOLEAN use_rc, tBTA_SEC s
{ {
tBTA_AV_API_OPEN *p_buf; tBTA_AV_API_OPEN *p_buf;
if ((p_buf = (tBTA_AV_API_OPEN *) GKI_getbuf(sizeof(tBTA_AV_API_OPEN))) != NULL) if ((p_buf = (tBTA_AV_API_OPEN *) GKI_getbuf(sizeof(tBTA_AV_API_OPEN))) != NULL) {
{
p_buf->hdr.event = BTA_AV_API_OPEN_EVT; p_buf->hdr.event = BTA_AV_API_OPEN_EVT;
p_buf->hdr.layer_specific = handle; p_buf->hdr.layer_specific = handle;
bdcpy(p_buf->bd_addr, bd_addr); bdcpy(p_buf->bd_addr, bd_addr);
@ -196,8 +187,7 @@ void BTA_AvClose(tBTA_AV_HNDL handle)
{ {
BT_HDR *p_buf; BT_HDR *p_buf;
if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) {
{
p_buf->event = BTA_AV_API_CLOSE_EVT; p_buf->event = BTA_AV_API_CLOSE_EVT;
p_buf->layer_specific = handle; p_buf->layer_specific = handle;
bta_sys_sendmsg(p_buf); bta_sys_sendmsg(p_buf);
@ -217,8 +207,7 @@ void BTA_AvDisconnect(BD_ADDR bd_addr)
{ {
tBTA_AV_API_DISCNT *p_buf; tBTA_AV_API_DISCNT *p_buf;
if ((p_buf = (tBTA_AV_API_DISCNT *) GKI_getbuf(sizeof(tBTA_AV_API_DISCNT))) != NULL) if ((p_buf = (tBTA_AV_API_DISCNT *) GKI_getbuf(sizeof(tBTA_AV_API_DISCNT))) != NULL) {
{
p_buf->hdr.event = BTA_AV_API_DISCONNECT_EVT; p_buf->hdr.event = BTA_AV_API_DISCONNECT_EVT;
bdcpy(p_buf->bd_addr, bd_addr); bdcpy(p_buf->bd_addr, bd_addr);
bta_sys_sendmsg(p_buf); bta_sys_sendmsg(p_buf);
@ -238,8 +227,7 @@ void BTA_AvStart(void)
{ {
BT_HDR *p_buf; BT_HDR *p_buf;
if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) {
{
p_buf->event = BTA_AV_API_START_EVT; p_buf->event = BTA_AV_API_START_EVT;
bta_sys_sendmsg(p_buf); bta_sys_sendmsg(p_buf);
} }
@ -258,8 +246,7 @@ void BTA_AvEnable_Sink(int enable)
{ {
#if (BTA_AV_SINK_INCLUDED == TRUE) #if (BTA_AV_SINK_INCLUDED == TRUE)
BT_HDR *p_buf; BT_HDR *p_buf;
if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) {
{
p_buf->event = BTA_AV_API_SINK_ENABLE_EVT; p_buf->event = BTA_AV_API_SINK_ENABLE_EVT;
p_buf->layer_specific = enable; p_buf->layer_specific = enable;
bta_sys_sendmsg(p_buf); bta_sys_sendmsg(p_buf);
@ -284,8 +271,7 @@ void BTA_AvStop(BOOLEAN suspend)
{ {
tBTA_AV_API_STOP *p_buf; tBTA_AV_API_STOP *p_buf;
if ((p_buf = (tBTA_AV_API_STOP *) GKI_getbuf(sizeof(tBTA_AV_API_STOP))) != NULL) if ((p_buf = (tBTA_AV_API_STOP *) GKI_getbuf(sizeof(tBTA_AV_API_STOP))) != NULL) {
{
p_buf->hdr.event = BTA_AV_API_STOP_EVT; p_buf->hdr.event = BTA_AV_API_STOP_EVT;
p_buf->flush = TRUE; p_buf->flush = TRUE;
p_buf->suspend = suspend; p_buf->suspend = suspend;
@ -311,8 +297,7 @@ void BTA_AvReconfig(tBTA_AV_HNDL hndl, BOOLEAN suspend, UINT8 sep_info_idx,
{ {
tBTA_AV_API_RCFG *p_buf; tBTA_AV_API_RCFG *p_buf;
if ((p_buf = (tBTA_AV_API_RCFG *) GKI_getbuf((UINT16) (sizeof(tBTA_AV_API_RCFG) + num_protect))) != NULL) if ((p_buf = (tBTA_AV_API_RCFG *) GKI_getbuf((UINT16) (sizeof(tBTA_AV_API_RCFG) + num_protect))) != NULL) {
{
p_buf->hdr.layer_specific = hndl; p_buf->hdr.layer_specific = hndl;
p_buf->hdr.event = BTA_AV_API_RECONFIG_EVT; p_buf->hdr.event = BTA_AV_API_RECONFIG_EVT;
p_buf->num_protect = num_protect; p_buf->num_protect = num_protect;
@ -339,17 +324,13 @@ void BTA_AvProtectReq(tBTA_AV_HNDL hndl, UINT8 *p_data, UINT16 len)
{ {
tBTA_AV_API_PROTECT_REQ *p_buf; tBTA_AV_API_PROTECT_REQ *p_buf;
if ((p_buf = (tBTA_AV_API_PROTECT_REQ *) GKI_getbuf((UINT16) (sizeof(tBTA_AV_API_PROTECT_REQ) + len))) != NULL) if ((p_buf = (tBTA_AV_API_PROTECT_REQ *) GKI_getbuf((UINT16) (sizeof(tBTA_AV_API_PROTECT_REQ) + len))) != NULL) {
{
p_buf->hdr.layer_specific = hndl; p_buf->hdr.layer_specific = hndl;
p_buf->hdr.event = BTA_AV_API_PROTECT_REQ_EVT; p_buf->hdr.event = BTA_AV_API_PROTECT_REQ_EVT;
p_buf->len = len; p_buf->len = len;
if (p_data == NULL) if (p_data == NULL) {
{
p_buf->p_data = NULL; p_buf->p_data = NULL;
} } else {
else
{
p_buf->p_data = (UINT8 *) (p_buf + 1); p_buf->p_data = (UINT8 *) (p_buf + 1);
memcpy(p_buf->p_data, p_data, len); memcpy(p_buf->p_data, p_data, len);
} }
@ -373,18 +354,14 @@ void BTA_AvProtectRsp(tBTA_AV_HNDL hndl, UINT8 error_code, UINT8 *p_data, UINT16
{ {
tBTA_AV_API_PROTECT_RSP *p_buf; tBTA_AV_API_PROTECT_RSP *p_buf;
if ((p_buf = (tBTA_AV_API_PROTECT_RSP *) GKI_getbuf((UINT16) (sizeof(tBTA_AV_API_PROTECT_RSP) + len))) != NULL) if ((p_buf = (tBTA_AV_API_PROTECT_RSP *) GKI_getbuf((UINT16) (sizeof(tBTA_AV_API_PROTECT_RSP) + len))) != NULL) {
{
p_buf->hdr.layer_specific = hndl; p_buf->hdr.layer_specific = hndl;
p_buf->hdr.event = BTA_AV_API_PROTECT_RSP_EVT; p_buf->hdr.event = BTA_AV_API_PROTECT_RSP_EVT;
p_buf->len = len; p_buf->len = len;
p_buf->error_code = error_code; p_buf->error_code = error_code;
if (p_data == NULL) if (p_data == NULL) {
{
p_buf->p_data = NULL; p_buf->p_data = NULL;
} } else {
else
{
p_buf->p_data = (UINT8 *) (p_buf + 1); p_buf->p_data = (UINT8 *) (p_buf + 1);
memcpy(p_buf->p_data, p_data, len); memcpy(p_buf->p_data, p_data, len);
} }
@ -406,8 +383,7 @@ void BTA_AvRemoteCmd(UINT8 rc_handle, UINT8 label, tBTA_AV_RC rc_id, tBTA_AV_STA
{ {
tBTA_AV_API_REMOTE_CMD *p_buf; tBTA_AV_API_REMOTE_CMD *p_buf;
if ((p_buf = (tBTA_AV_API_REMOTE_CMD *) GKI_getbuf(sizeof(tBTA_AV_API_REMOTE_CMD))) != NULL) if ((p_buf = (tBTA_AV_API_REMOTE_CMD *) GKI_getbuf(sizeof(tBTA_AV_API_REMOTE_CMD))) != NULL) {
{
p_buf->hdr.event = BTA_AV_API_REMOTE_CMD_EVT; p_buf->hdr.event = BTA_AV_API_REMOTE_CMD_EVT;
p_buf->hdr.layer_specific = rc_handle; p_buf->hdr.layer_specific = rc_handle;
p_buf->msg.op_id = rc_id; p_buf->msg.op_id = rc_id;
@ -434,8 +410,7 @@ void BTA_AvVendorCmd(UINT8 rc_handle, UINT8 label, tBTA_AV_CODE cmd_code, UINT8
{ {
tBTA_AV_API_VENDOR *p_buf; tBTA_AV_API_VENDOR *p_buf;
if ((p_buf = (tBTA_AV_API_VENDOR *) GKI_getbuf((UINT16) (sizeof(tBTA_AV_API_VENDOR) + len))) != NULL) if ((p_buf = (tBTA_AV_API_VENDOR *) GKI_getbuf((UINT16) (sizeof(tBTA_AV_API_VENDOR) + len))) != NULL) {
{
p_buf->hdr.event = BTA_AV_API_VENDOR_CMD_EVT; p_buf->hdr.event = BTA_AV_API_VENDOR_CMD_EVT;
p_buf->hdr.layer_specific = rc_handle; p_buf->hdr.layer_specific = rc_handle;
p_buf->msg.hdr.ctype = cmd_code; p_buf->msg.hdr.ctype = cmd_code;
@ -444,12 +419,9 @@ void BTA_AvVendorCmd(UINT8 rc_handle, UINT8 label, tBTA_AV_CODE cmd_code, UINT8
p_buf->msg.company_id = p_bta_av_cfg->company_id; p_buf->msg.company_id = p_bta_av_cfg->company_id;
p_buf->label = label; p_buf->label = label;
p_buf->msg.vendor_len = len; p_buf->msg.vendor_len = len;
if (p_data == NULL) if (p_data == NULL) {
{
p_buf->msg.p_vendor_data = NULL; p_buf->msg.p_vendor_data = NULL;
} } else {
else
{
p_buf->msg.p_vendor_data = (UINT8 *) (p_buf + 1); p_buf->msg.p_vendor_data = (UINT8 *) (p_buf + 1);
memcpy(p_buf->msg.p_vendor_data, p_data, len); memcpy(p_buf->msg.p_vendor_data, p_data, len);
} }
@ -473,25 +445,22 @@ void BTA_AvVendorRsp(UINT8 rc_handle, UINT8 label, tBTA_AV_CODE rsp_code, UINT8
{ {
tBTA_AV_API_VENDOR *p_buf; tBTA_AV_API_VENDOR *p_buf;
if ((p_buf = (tBTA_AV_API_VENDOR *) GKI_getbuf((UINT16) (sizeof(tBTA_AV_API_VENDOR) + len))) != NULL) if ((p_buf = (tBTA_AV_API_VENDOR *) GKI_getbuf((UINT16) (sizeof(tBTA_AV_API_VENDOR) + len))) != NULL) {
{
p_buf->hdr.event = BTA_AV_API_VENDOR_RSP_EVT; p_buf->hdr.event = BTA_AV_API_VENDOR_RSP_EVT;
p_buf->hdr.layer_specific = rc_handle; p_buf->hdr.layer_specific = rc_handle;
p_buf->msg.hdr.ctype = rsp_code; p_buf->msg.hdr.ctype = rsp_code;
p_buf->msg.hdr.subunit_type = AVRC_SUB_PANEL; p_buf->msg.hdr.subunit_type = AVRC_SUB_PANEL;
p_buf->msg.hdr.subunit_id = 0; p_buf->msg.hdr.subunit_id = 0;
if(company_id) if (company_id) {
p_buf->msg.company_id = company_id; p_buf->msg.company_id = company_id;
else } else {
p_buf->msg.company_id = p_bta_av_cfg->company_id; p_buf->msg.company_id = p_bta_av_cfg->company_id;
}
p_buf->label = label; p_buf->label = label;
p_buf->msg.vendor_len = len; p_buf->msg.vendor_len = len;
if (p_data == NULL) if (p_data == NULL) {
{
p_buf->msg.p_vendor_data = NULL; p_buf->msg.p_vendor_data = NULL;
} } else {
else
{
p_buf->msg.p_vendor_data = (UINT8 *) (p_buf + 1); p_buf->msg.p_vendor_data = (UINT8 *) (p_buf + 1);
memcpy(p_buf->msg.p_vendor_data, p_data, len); memcpy(p_buf->msg.p_vendor_data, p_data, len);
} }
@ -513,8 +482,7 @@ void BTA_AvOpenRc(tBTA_AV_HNDL handle)
{ {
tBTA_AV_API_OPEN_RC *p_buf; tBTA_AV_API_OPEN_RC *p_buf;
if ((p_buf = (tBTA_AV_API_OPEN_RC *) GKI_getbuf(sizeof(tBTA_AV_API_OPEN_RC))) != NULL) if ((p_buf = (tBTA_AV_API_OPEN_RC *) GKI_getbuf(sizeof(tBTA_AV_API_OPEN_RC))) != NULL) {
{
p_buf->hdr.event = BTA_AV_API_RC_OPEN_EVT; p_buf->hdr.event = BTA_AV_API_RC_OPEN_EVT;
p_buf->hdr.layer_specific = handle; p_buf->hdr.layer_specific = handle;
bta_sys_sendmsg(p_buf); bta_sys_sendmsg(p_buf);
@ -534,8 +502,7 @@ void BTA_AvCloseRc(UINT8 rc_handle)
{ {
tBTA_AV_API_CLOSE_RC *p_buf; tBTA_AV_API_CLOSE_RC *p_buf;
if ((p_buf = (tBTA_AV_API_CLOSE_RC *) GKI_getbuf(sizeof(tBTA_AV_API_CLOSE_RC))) != NULL) if ((p_buf = (tBTA_AV_API_CLOSE_RC *) GKI_getbuf(sizeof(tBTA_AV_API_CLOSE_RC))) != NULL) {
{
p_buf->hdr.event = BTA_AV_API_RC_CLOSE_EVT; p_buf->hdr.event = BTA_AV_API_RC_CLOSE_EVT;
p_buf->hdr.layer_specific = rc_handle; p_buf->hdr.layer_specific = rc_handle;
bta_sys_sendmsg(p_buf); bta_sys_sendmsg(p_buf);
@ -559,8 +526,7 @@ void BTA_AvMetaRsp(UINT8 rc_handle, UINT8 label, tBTA_AV_CODE rsp_code,
{ {
tBTA_AV_API_META_RSP *p_buf; tBTA_AV_API_META_RSP *p_buf;
if ((p_buf = (tBTA_AV_API_META_RSP *) GKI_getbuf((UINT16) (sizeof(tBTA_AV_API_META_RSP)))) != NULL) if ((p_buf = (tBTA_AV_API_META_RSP *) GKI_getbuf((UINT16) (sizeof(tBTA_AV_API_META_RSP)))) != NULL) {
{
p_buf->hdr.event = BTA_AV_API_META_RSP_EVT; p_buf->hdr.event = BTA_AV_API_META_RSP_EVT;
p_buf->hdr.layer_specific = rc_handle; p_buf->hdr.layer_specific = rc_handle;
p_buf->rsp_code = rsp_code; p_buf->rsp_code = rsp_code;
@ -592,8 +558,7 @@ void BTA_AvMetaCmd(UINT8 rc_handle, UINT8 label, tBTA_AV_CMD cmd_code, BT_HDR *p
{ {
tBTA_AV_API_META_RSP *p_buf; tBTA_AV_API_META_RSP *p_buf;
if ((p_buf = (tBTA_AV_API_META_RSP *) GKI_getbuf((UINT16) (sizeof(tBTA_AV_API_META_RSP)))) != NULL) if ((p_buf = (tBTA_AV_API_META_RSP *) GKI_getbuf((UINT16) (sizeof(tBTA_AV_API_META_RSP)))) != NULL) {
{
p_buf->hdr.event = BTA_AV_API_META_RSP_EVT; p_buf->hdr.event = BTA_AV_API_META_RSP_EVT;
p_buf->hdr.layer_specific = rc_handle; p_buf->hdr.layer_specific = rc_handle;
p_buf->p_pkt = p_pkt; p_buf->p_pkt = p_pkt;

9
components/bt/bluedroid/bta/av/bta_av_cfg.c Executable file → Normal file
View file

@ -88,8 +88,7 @@ const UINT8 bta_av_meta_caps_evt_ids[] = {
#define BTA_AV_MAX_RC_BR_MTU 1008 #define BTA_AV_MAX_RC_BR_MTU 1008
#endif #endif
const tBTA_AV_CFG bta_av_cfg = const tBTA_AV_CFG bta_av_cfg = {
{
AVRC_CO_BROADCOM, /* AVRCP Company ID */ AVRC_CO_BROADCOM, /* AVRCP Company ID */
#if AVRC_METADATA_INCLUDED == TRUE #if AVRC_METADATA_INCLUDED == TRUE
512, /* AVRCP MTU at L2CAP for control channel */ 512, /* AVRCP MTU at L2CAP for control channel */
@ -119,8 +118,7 @@ const tBTA_AV_CFG bta_av_cfg =
tBTA_AV_CFG *p_bta_av_cfg = (tBTA_AV_CFG *) &bta_av_cfg; tBTA_AV_CFG *p_bta_av_cfg = (tBTA_AV_CFG *) &bta_av_cfg;
const UINT16 bta_av_rc_id[] = const UINT16 bta_av_rc_id[] = {
{
0x0000, /* bit mask: 0=SELECT, 1=UP, 2=DOWN, 3=LEFT, 0x0000, /* bit mask: 0=SELECT, 1=UP, 2=DOWN, 3=LEFT,
4=RIGHT, 5=RIGHT_UP, 6=RIGHT_DOWN, 7=LEFT_UP, 4=RIGHT, 5=RIGHT_UP, 6=RIGHT_DOWN, 7=LEFT_UP,
8=LEFT_DOWN, 9=ROOT_MENU, 10=SETUP_MENU, 11=CONT_MENU, 8=LEFT_DOWN, 9=ROOT_MENU, 10=SETUP_MENU, 11=CONT_MENU,
@ -168,8 +166,7 @@ const UINT16 bta_av_rc_id[] =
}; };
#if (BTA_AV_RC_PASS_RSP_CODE == BTA_AV_RSP_INTERIM) #if (BTA_AV_RC_PASS_RSP_CODE == BTA_AV_RSP_INTERIM)
const UINT16 bta_av_rc_id_ac[] = const UINT16 bta_av_rc_id_ac[] = {
{
0x0000, /* bit mask: 0=SELECT, 1=UP, 2=DOWN, 3=LEFT, 0x0000, /* bit mask: 0=SELECT, 1=UP, 2=DOWN, 3=LEFT,
4=RIGHT, 5=RIGHT_UP, 6=RIGHT_DOWN, 7=LEFT_UP, 4=RIGHT, 5=RIGHT_UP, 6=RIGHT_DOWN, 7=LEFT_UP,
8=LEFT_DOWN, 9=ROOT_MENU, 10=SETUP_MENU, 11=CONT_MENU, 8=LEFT_DOWN, 9=ROOT_MENU, 10=SETUP_MENU, 11=CONT_MENU,

13
components/bt/bluedroid/bta/av/bta_av_ci.c Executable file → Normal file
View file

@ -48,8 +48,7 @@ void bta_av_ci_src_data_ready(tBTA_AV_CHNL chnl)
{ {
BT_HDR *p_buf; BT_HDR *p_buf;
if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) {
{
p_buf->layer_specific = chnl; p_buf->layer_specific = chnl;
p_buf->event = BTA_AV_CI_SRC_DATA_READY_EVT; p_buf->event = BTA_AV_CI_SRC_DATA_READY_EVT;
bta_sys_sendmsg(p_buf); bta_sys_sendmsg(p_buf);
@ -74,8 +73,7 @@ void bta_av_ci_setconfig(tBTA_AV_HNDL hndl, UINT8 err_code, UINT8 category,
{ {
tBTA_AV_CI_SETCONFIG *p_buf; tBTA_AV_CI_SETCONFIG *p_buf;
if ((p_buf = (tBTA_AV_CI_SETCONFIG *) GKI_getbuf(sizeof(tBTA_AV_CI_SETCONFIG))) != NULL) if ((p_buf = (tBTA_AV_CI_SETCONFIG *) GKI_getbuf(sizeof(tBTA_AV_CI_SETCONFIG))) != NULL) {
{
p_buf->hdr.layer_specific = hndl; p_buf->hdr.layer_specific = hndl;
p_buf->hdr.event = (err_code == AVDT_SUCCESS) ? p_buf->hdr.event = (err_code == AVDT_SUCCESS) ?
BTA_AV_CI_SETCONFIG_OK_EVT : BTA_AV_CI_SETCONFIG_FAIL_EVT; BTA_AV_CI_SETCONFIG_OK_EVT : BTA_AV_CI_SETCONFIG_FAIL_EVT;
@ -84,13 +82,10 @@ void bta_av_ci_setconfig(tBTA_AV_HNDL hndl, UINT8 err_code, UINT8 category,
p_buf->recfg_needed = recfg_needed; p_buf->recfg_needed = recfg_needed;
p_buf->num_seid = num_seid; p_buf->num_seid = num_seid;
p_buf->avdt_handle = avdt_handle; p_buf->avdt_handle = avdt_handle;
if(p_seid && num_seid) if (p_seid && num_seid) {
{
p_buf->p_seid = (UINT8 *)(p_buf + 1); p_buf->p_seid = (UINT8 *)(p_buf + 1);
memcpy(p_buf->p_seid, p_seid, num_seid); memcpy(p_buf->p_seid, p_seid, num_seid);
} } else {
else
{
p_buf->p_seid = NULL; p_buf->p_seid = NULL;
p_buf->num_seid = 0; p_buf->num_seid = 0;
} }

93
components/bt/bluedroid/bta/av/bta_av_int.h Executable file → Normal file
View file

@ -36,8 +36,7 @@
** Constants ** Constants
*****************************************************************************/ *****************************************************************************/
enum enum {
{
/* these events are handled by the AV main state machine */ /* these events are handled by the AV main state machine */
BTA_AV_API_DISABLE_EVT = BTA_SYS_EVT_START(BTA_ID_AV), BTA_AV_API_DISABLE_EVT = BTA_SYS_EVT_START(BTA_ID_AV),
BTA_AV_API_REMOTE_CMD_EVT, BTA_AV_API_REMOTE_CMD_EVT,
@ -180,8 +179,7 @@ typedef void * (*tBTA_AV_CO_DATAPATH) (tBTA_AV_CODEC codec_type,
typedef void (*tBTA_AV_CO_DELAY) (tBTA_AV_HNDL hndl, UINT16 delay); typedef void (*tBTA_AV_CO_DELAY) (tBTA_AV_HNDL hndl, UINT16 delay);
/* the call-out functions for one stream */ /* the call-out functions for one stream */
typedef struct typedef struct {
{
tBTA_AV_CO_INIT init; tBTA_AV_CO_INIT init;
tBTA_AV_CO_DISC_RES disc_res; tBTA_AV_CO_DISC_RES disc_res;
tBTA_AV_CO_GETCFG getcfg; tBTA_AV_CO_GETCFG getcfg;
@ -196,8 +194,7 @@ typedef struct
#endif #endif
/* data type for BTA_AV_API_ENABLE_EVT */ /* data type for BTA_AV_API_ENABLE_EVT */
typedef struct typedef struct {
{
BT_HDR hdr; BT_HDR hdr;
tBTA_AV_CBACK *p_cback; tBTA_AV_CBACK *p_cback;
tBTA_AV_FEAT features; tBTA_AV_FEAT features;
@ -205,8 +202,7 @@ typedef struct
} tBTA_AV_API_ENABLE; } tBTA_AV_API_ENABLE;
/* data type for BTA_AV_API_REG_EVT */ /* data type for BTA_AV_API_REG_EVT */
typedef struct typedef struct {
{
BT_HDR hdr; BT_HDR hdr;
char p_service_name[BTA_SERVICE_NAME_LEN + 1]; char p_service_name[BTA_SERVICE_NAME_LEN + 1];
UINT8 app_id; UINT8 app_id;
@ -215,8 +211,7 @@ typedef struct
} tBTA_AV_API_REG; } tBTA_AV_API_REG;
enum enum {
{
BTA_AV_RS_NONE, /* straight API call */ BTA_AV_RS_NONE, /* straight API call */
BTA_AV_RS_OK, /* the role switch result - successful */ BTA_AV_RS_OK, /* the role switch result - successful */
BTA_AV_RS_FAIL, /* the role switch result - failed */ BTA_AV_RS_FAIL, /* the role switch result - failed */
@ -224,8 +219,7 @@ enum
}; };
typedef UINT8 tBTA_AV_RS_RES; typedef UINT8 tBTA_AV_RS_RES;
/* data type for BTA_AV_API_OPEN_EVT */ /* data type for BTA_AV_API_OPEN_EVT */
typedef struct typedef struct {
{
BT_HDR hdr; BT_HDR hdr;
BD_ADDR bd_addr; BD_ADDR bd_addr;
BOOLEAN use_rc; BOOLEAN use_rc;
@ -235,31 +229,27 @@ typedef struct
} tBTA_AV_API_OPEN; } tBTA_AV_API_OPEN;
/* data type for BTA_AV_API_STOP_EVT */ /* data type for BTA_AV_API_STOP_EVT */
typedef struct typedef struct {
{
BT_HDR hdr; BT_HDR hdr;
BOOLEAN suspend; BOOLEAN suspend;
BOOLEAN flush; BOOLEAN flush;
} tBTA_AV_API_STOP; } tBTA_AV_API_STOP;
/* data type for BTA_AV_API_DISCONNECT_EVT */ /* data type for BTA_AV_API_DISCONNECT_EVT */
typedef struct typedef struct {
{
BT_HDR hdr; BT_HDR hdr;
BD_ADDR bd_addr; BD_ADDR bd_addr;
} tBTA_AV_API_DISCNT; } tBTA_AV_API_DISCNT;
/* data type for BTA_AV_API_PROTECT_REQ_EVT */ /* data type for BTA_AV_API_PROTECT_REQ_EVT */
typedef struct typedef struct {
{
BT_HDR hdr; BT_HDR hdr;
UINT8 *p_data; UINT8 *p_data;
UINT16 len; UINT16 len;
} tBTA_AV_API_PROTECT_REQ; } tBTA_AV_API_PROTECT_REQ;
/* data type for BTA_AV_API_PROTECT_RSP_EVT */ /* data type for BTA_AV_API_PROTECT_RSP_EVT */
typedef struct typedef struct {
{
BT_HDR hdr; BT_HDR hdr;
UINT8 *p_data; UINT8 *p_data;
UINT16 len; UINT16 len;
@ -267,36 +257,31 @@ typedef struct
} tBTA_AV_API_PROTECT_RSP; } tBTA_AV_API_PROTECT_RSP;
/* data type for BTA_AV_API_REMOTE_CMD_EVT */ /* data type for BTA_AV_API_REMOTE_CMD_EVT */
typedef struct typedef struct {
{
BT_HDR hdr; BT_HDR hdr;
tAVRC_MSG_PASS msg; tAVRC_MSG_PASS msg;
UINT8 label; UINT8 label;
} tBTA_AV_API_REMOTE_CMD; } tBTA_AV_API_REMOTE_CMD;
/* data type for BTA_AV_API_VENDOR_CMD_EVT and RSP */ /* data type for BTA_AV_API_VENDOR_CMD_EVT and RSP */
typedef struct typedef struct {
{
BT_HDR hdr; BT_HDR hdr;
tAVRC_MSG_VENDOR msg; tAVRC_MSG_VENDOR msg;
UINT8 label; UINT8 label;
} tBTA_AV_API_VENDOR; } tBTA_AV_API_VENDOR;
/* data type for BTA_AV_API_RC_OPEN_EVT */ /* data type for BTA_AV_API_RC_OPEN_EVT */
typedef struct typedef struct {
{
BT_HDR hdr; BT_HDR hdr;
} tBTA_AV_API_OPEN_RC; } tBTA_AV_API_OPEN_RC;
/* data type for BTA_AV_API_RC_CLOSE_EVT */ /* data type for BTA_AV_API_RC_CLOSE_EVT */
typedef struct typedef struct {
{
BT_HDR hdr; BT_HDR hdr;
} tBTA_AV_API_CLOSE_RC; } tBTA_AV_API_CLOSE_RC;
/* data type for BTA_AV_API_META_RSP_EVT */ /* data type for BTA_AV_API_META_RSP_EVT */
typedef struct typedef struct {
{
BT_HDR hdr; BT_HDR hdr;
BOOLEAN is_rsp; BOOLEAN is_rsp;
UINT8 label; UINT8 label;
@ -306,8 +291,7 @@ typedef struct
/* data type for BTA_AV_API_RECONFIG_EVT */ /* data type for BTA_AV_API_RECONFIG_EVT */
typedef struct typedef struct {
{
BT_HDR hdr; BT_HDR hdr;
UINT8 codec_info[AVDT_CODEC_SIZE]; /* codec configuration */ UINT8 codec_info[AVDT_CODEC_SIZE]; /* codec configuration */
UINT8 *p_protect_info; UINT8 *p_protect_info;
@ -317,8 +301,7 @@ typedef struct
} tBTA_AV_API_RCFG; } tBTA_AV_API_RCFG;
/* data type for BTA_AV_CI_SETCONFIG_OK_EVT and BTA_AV_CI_SETCONFIG_FAIL_EVT */ /* data type for BTA_AV_CI_SETCONFIG_OK_EVT and BTA_AV_CI_SETCONFIG_FAIL_EVT */
typedef struct typedef struct {
{
BT_HDR hdr; BT_HDR hdr;
tBTA_AV_HNDL hndl; tBTA_AV_HNDL hndl;
UINT8 err_code; UINT8 err_code;
@ -341,8 +324,7 @@ typedef struct {
} tBTA_AV_STR_MSG; } tBTA_AV_STR_MSG;
/* data type for BTA_AV_AVRC_MSG_EVT */ /* data type for BTA_AV_AVRC_MSG_EVT */
typedef struct typedef struct {
{
BT_HDR hdr; BT_HDR hdr;
tAVRC_MSG msg; tAVRC_MSG msg;
UINT8 handle; UINT8 handle;
@ -351,39 +333,34 @@ typedef struct
} tBTA_AV_RC_MSG; } tBTA_AV_RC_MSG;
/* data type for BTA_AV_AVRC_OPEN_EVT, BTA_AV_AVRC_CLOSE_EVT */ /* data type for BTA_AV_AVRC_OPEN_EVT, BTA_AV_AVRC_CLOSE_EVT */
typedef struct typedef struct {
{
BT_HDR hdr; BT_HDR hdr;
BD_ADDR peer_addr; BD_ADDR peer_addr;
UINT8 handle; UINT8 handle;
} tBTA_AV_RC_CONN_CHG; } tBTA_AV_RC_CONN_CHG;
/* data type for BTA_AV_CONN_CHG_EVT */ /* data type for BTA_AV_CONN_CHG_EVT */
typedef struct typedef struct {
{
BT_HDR hdr; BT_HDR hdr;
BD_ADDR peer_addr; BD_ADDR peer_addr;
BOOLEAN is_up; BOOLEAN is_up;
} tBTA_AV_CONN_CHG; } tBTA_AV_CONN_CHG;
/* data type for BTA_AV_ROLE_CHANGE_EVT */ /* data type for BTA_AV_ROLE_CHANGE_EVT */
typedef struct typedef struct {
{
BT_HDR hdr; BT_HDR hdr;
UINT8 new_role; UINT8 new_role;
UINT8 hci_status; UINT8 hci_status;
} tBTA_AV_ROLE_RES; } tBTA_AV_ROLE_RES;
/* data type for BTA_AV_SDP_DISC_OK_EVT */ /* data type for BTA_AV_SDP_DISC_OK_EVT */
typedef struct typedef struct {
{
BT_HDR hdr; BT_HDR hdr;
UINT16 avdt_version; /* AVDTP protocol version */ UINT16 avdt_version; /* AVDTP protocol version */
} tBTA_AV_SDP_RES; } tBTA_AV_SDP_RES;
/* type for SEP control block */ /* type for SEP control block */
typedef struct typedef struct {
{
UINT8 av_handle; /* AVDTP handle */ UINT8 av_handle; /* AVDTP handle */
tBTA_AV_CODEC codec_type; /* codec type */ tBTA_AV_CODEC codec_type; /* codec type */
UINT8 tsep; /* SEP type of local SEP */ UINT8 tsep; /* SEP type of local SEP */
@ -403,8 +380,7 @@ typedef struct
#define BTA_AV_ROLE_SUSPEND_OPT 0x40 /* Suspend on Start option is set */ #define BTA_AV_ROLE_SUSPEND_OPT 0x40 /* Suspend on Start option is set */
/* union of all event datatypes */ /* union of all event datatypes */
typedef union typedef union {
{
BT_HDR hdr; BT_HDR hdr;
tBTA_AV_API_ENABLE api_enable; tBTA_AV_API_ENABLE api_enable;
tBTA_AV_API_REG api_reg; tBTA_AV_API_REG api_reg;
@ -428,8 +404,7 @@ typedef union
typedef void (tBTA_AV_VDP_DATA_ACT)(void *p_scb); typedef void (tBTA_AV_VDP_DATA_ACT)(void *p_scb);
typedef struct typedef struct {
{
tBTA_AV_VDP_DATA_ACT *p_act; tBTA_AV_VDP_DATA_ACT *p_act;
UINT8 *p_frame; UINT8 *p_frame;
UINT16 buf_size; UINT16 buf_size;
@ -438,8 +413,7 @@ typedef struct
UINT32 timestamp; UINT32 timestamp;
} tBTA_AV_VF_INFO; } tBTA_AV_VF_INFO;
typedef union typedef union {
{
tBTA_AV_VF_INFO vdp; /* used for video channels only */ tBTA_AV_VF_INFO vdp; /* used for video channels only */
tBTA_AV_API_OPEN open; /* used only before open and role switch tBTA_AV_API_OPEN open; /* used only before open and role switch
is needed on another AV channel */ is needed on another AV channel */
@ -465,8 +439,7 @@ typedef union
#define BTA_AV_COLL_API_CALLED 0x02 /* API open was called while incoming timer is running */ #define BTA_AV_COLL_API_CALLED 0x02 /* API open was called while incoming timer is running */
/* type for AV stream control block */ /* type for AV stream control block */
typedef struct typedef struct {
{
const tBTA_AV_ACT *p_act_tbl; /* the action table for stream state machine */ const tBTA_AV_ACT *p_act_tbl; /* the action table for stream state machine */
const tBTA_AV_CO_FUNCTS *p_cos; /* the associated callout functions */ const tBTA_AV_CO_FUNCTS *p_cos; /* the associated callout functions */
tSDP_DISCOVERY_DB *p_disc_db; /* pointer to discovery database */ tSDP_DISCOVERY_DB *p_disc_db; /* pointer to discovery database */
@ -528,8 +501,7 @@ typedef struct
/* type for AV RCP control block */ /* type for AV RCP control block */
/* index to this control block is the rc handle */ /* index to this control block is the rc handle */
typedef struct typedef struct {
{
UINT8 status; UINT8 status;
UINT8 handle; UINT8 handle;
UINT8 shdl; /* stream handle (hdi + 1) */ UINT8 shdl; /* stream handle (hdi + 1) */
@ -538,15 +510,13 @@ typedef struct
} tBTA_AV_RCB; } tBTA_AV_RCB;
#define BTA_AV_NUM_RCB (BTA_AV_NUM_STRS + 2) #define BTA_AV_NUM_RCB (BTA_AV_NUM_STRS + 2)
enum enum {
{
BTA_AV_LCB_FREE, BTA_AV_LCB_FREE,
BTA_AV_LCB_FIND BTA_AV_LCB_FIND
}; };
/* type for AV ACL Link control block */ /* type for AV ACL Link control block */
typedef struct typedef struct {
{
BD_ADDR addr; /* peer BD address */ BD_ADDR addr; /* peer BD address */
UINT8 conn_msk; /* handle mask of connected stream handle */ UINT8 conn_msk; /* handle mask of connected stream handle */
UINT8 lidx; /* index + 1 */ UINT8 lidx; /* index + 1 */
@ -557,8 +527,7 @@ typedef void (*tBTA_AV_SACT)(tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
/* type for AV control block */ /* type for AV control block */
typedef struct typedef struct {
{
tBTA_AV_SCB *p_scb[BTA_AV_NUM_STRS]; /* stream control block */ tBTA_AV_SCB *p_scb[BTA_AV_NUM_STRS]; /* stream control block */
tSDP_DISCOVERY_DB *p_disc_db; /* pointer to discovery database */ tSDP_DISCOVERY_DB *p_disc_db; /* pointer to discovery database */
tBTA_AV_CBACK *p_cback; /* application callback function */ tBTA_AV_CBACK *p_cback; /* application callback function */

329
components/bt/bluedroid/bta/av/bta_av_main.c Executable file → Normal file
View file

@ -65,15 +65,13 @@
#endif #endif
/* state machine states */ /* state machine states */
enum enum {
{
BTA_AV_INIT_ST, BTA_AV_INIT_ST,
BTA_AV_OPEN_ST BTA_AV_OPEN_ST
}; };
/* state machine action enumeration list */ /* state machine action enumeration list */
enum enum {
{
BTA_AV_DISABLE, BTA_AV_DISABLE,
BTA_AV_RC_OPENED, BTA_AV_RC_OPENED,
BTA_AV_RC_REMOTE_CMD, BTA_AV_RC_REMOTE_CMD,
@ -93,8 +91,7 @@ enum
typedef void (*tBTA_AV_ACTION)(tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data); typedef void (*tBTA_AV_ACTION)(tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data);
/* action functions */ /* action functions */
const tBTA_AV_ACTION bta_av_action[] = const tBTA_AV_ACTION bta_av_action[] = {
{
bta_av_disable, bta_av_disable,
bta_av_rc_opened, bta_av_rc_opened,
bta_av_rc_remote_cmd, bta_av_rc_remote_cmd,
@ -114,8 +111,7 @@ const tBTA_AV_ACTION bta_av_action[] =
#define BTA_AV_NUM_COLS 2 /* number of columns in state tables */ #define BTA_AV_NUM_COLS 2 /* number of columns in state tables */
/* state table for init state */ /* state table for init state */
static const UINT8 bta_av_st_init[][BTA_AV_NUM_COLS] = static const UINT8 bta_av_st_init[][BTA_AV_NUM_COLS] = {
{
/* Event Action 1 Next state */ /* Event Action 1 Next state */
/* API_DISABLE_EVT */ {BTA_AV_DISABLE, BTA_AV_INIT_ST }, /* API_DISABLE_EVT */ {BTA_AV_DISABLE, BTA_AV_INIT_ST },
/* API_REMOTE_CMD_EVT */ {BTA_AV_IGNORE, BTA_AV_INIT_ST }, /* API_REMOTE_CMD_EVT */ {BTA_AV_IGNORE, BTA_AV_INIT_ST },
@ -129,8 +125,7 @@ static const UINT8 bta_av_st_init[][BTA_AV_NUM_COLS] =
}; };
/* state table for open state */ /* state table for open state */
static const UINT8 bta_av_st_open[][BTA_AV_NUM_COLS] = static const UINT8 bta_av_st_open[][BTA_AV_NUM_COLS] = {
{
/* Event Action 1 Next state */ /* Event Action 1 Next state */
/* API_DISABLE_EVT */ {BTA_AV_DISABLE, BTA_AV_INIT_ST }, /* API_DISABLE_EVT */ {BTA_AV_DISABLE, BTA_AV_INIT_ST },
/* API_REMOTE_CMD_EVT */ {BTA_AV_RC_REMOTE_CMD, BTA_AV_OPEN_ST }, /* API_REMOTE_CMD_EVT */ {BTA_AV_RC_REMOTE_CMD, BTA_AV_OPEN_ST },
@ -147,8 +142,7 @@ static const UINT8 bta_av_st_open[][BTA_AV_NUM_COLS] =
typedef const UINT8 (*tBTA_AV_ST_TBL)[BTA_AV_NUM_COLS]; typedef const UINT8 (*tBTA_AV_ST_TBL)[BTA_AV_NUM_COLS];
/* state table */ /* state table */
static const tBTA_AV_ST_TBL bta_av_st_tbl[] = static const tBTA_AV_ST_TBL bta_av_st_tbl[] = {
{
bta_av_st_init, bta_av_st_init,
bta_av_st_open bta_av_st_open
}; };
@ -171,8 +165,7 @@ static void bta_av_sys_rs_cback (tBTA_SYS_CONN_STATUS status,UINT8 id, UINT8 app
/* action functions */ /* action functions */
const tBTA_AV_NSM_ACT bta_av_nsm_act[] = const tBTA_AV_NSM_ACT bta_av_nsm_act[] = {
{
bta_av_api_enable, /* BTA_AV_API_ENABLE_EVT */ bta_av_api_enable, /* BTA_AV_API_ENABLE_EVT */
bta_av_api_register, /* BTA_AV_API_REGISTER_EVT */ bta_av_api_register, /* BTA_AV_API_REGISTER_EVT */
bta_av_api_deregister, /* BTA_AV_API_DEREGISTER_EVT */ bta_av_api_deregister, /* BTA_AV_API_DEREGISTER_EVT */
@ -224,17 +217,14 @@ static void bta_av_timer_cback(void *p_tle)
tBTA_AV_SCB *p_scb = NULL; tBTA_AV_SCB *p_scb = NULL;
/* find the SCB that has the timer */ /* find the SCB that has the timer */
for(xx=0; xx<BTA_AV_NUM_STRS; xx++) for (xx = 0; xx < BTA_AV_NUM_STRS; xx++) {
{ if (bta_av_cb.p_scb[xx] && &(bta_av_cb.p_scb[xx]->timer) == p) {
if(bta_av_cb.p_scb[xx] && &(bta_av_cb.p_scb[xx]->timer)== p)
{
p_scb = bta_av_cb.p_scb[xx]; p_scb = bta_av_cb.p_scb[xx];
break; break;
} }
} }
if (p_scb && (p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) if (p_scb && (p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) {
{
/* send the event through the audio state machine. /* send the event through the audio state machine.
* only when the audio SM is open, the main SM opens the RC connection as INT */ * only when the audio SM is open, the main SM opens the RC connection as INT */
p_buf->event = p->event; p_buf->event = p->event;
@ -261,8 +251,9 @@ static void bta_av_api_enable(tBTA_AV_DATA *p_data)
/* initialize control block */ /* initialize control block */
memset(&bta_av_cb, 0, sizeof(tBTA_AV_CB)); memset(&bta_av_cb, 0, sizeof(tBTA_AV_CB));
for(i=0; i<BTA_AV_NUM_RCB; i++) for (i = 0; i < BTA_AV_NUM_RCB; i++) {
bta_av_cb.rcb[i].handle = BTA_AV_RC_HANDLE_NONE; bta_av_cb.rcb[i].handle = BTA_AV_RC_HANDLE_NONE;
}
bta_av_cb.rc_acp_handle = BTA_AV_RC_HANDLE_NONE; bta_av_cb.rc_acp_handle = BTA_AV_RC_HANDLE_NONE;
@ -274,8 +265,7 @@ static void bta_av_api_enable(tBTA_AV_DATA *p_data)
enable.features = bta_av_cb.features; enable.features = bta_av_cb.features;
/* Register for SCO change event */ /* Register for SCO change event */
if (!(bta_av_cb.features & BTA_AV_FEAT_NO_SCO_SSPD)) if (!(bta_av_cb.features & BTA_AV_FEAT_NO_SCO_SSPD)) {
{
bta_sys_sco_register(bta_av_sco_chg_cback); bta_sys_sco_register(bta_av_sco_chg_cback);
} }
@ -297,12 +287,9 @@ static tBTA_AV_SCB * bta_av_addr_to_scb(BD_ADDR bd_addr)
tBTA_AV_SCB *p_scb = NULL; tBTA_AV_SCB *p_scb = NULL;
int xx; int xx;
for(xx=0; xx<BTA_AV_NUM_STRS; xx++) for (xx = 0; xx < BTA_AV_NUM_STRS; xx++) {
{ if (bta_av_cb.p_scb[xx]) {
if(bta_av_cb.p_scb[xx]) if (!bdcmp(bd_addr, bta_av_cb.p_scb[xx]->peer_addr)) {
{
if(!bdcmp(bd_addr, bta_av_cb.p_scb[xx]->peer_addr))
{
p_scb = bta_av_cb.p_scb[xx]; p_scb = bta_av_cb.p_scb[xx];
break; break;
} }
@ -326,8 +313,7 @@ tBTA_AV_SCB * bta_av_hndl_to_scb(UINT16 handle)
tBTA_AV_SCB *p_scb = NULL; tBTA_AV_SCB *p_scb = NULL;
UINT8 idx = (hndl & BTA_AV_HNDL_MSK); UINT8 idx = (hndl & BTA_AV_HNDL_MSK);
if(idx && (idx <= BTA_AV_NUM_STRS) ) if (idx && (idx <= BTA_AV_NUM_STRS) ) {
{
p_scb = bta_av_cb.p_scb[idx - 1]; p_scb = bta_av_cb.p_scb[idx - 1];
} }
return p_scb; return p_scb;
@ -350,39 +336,28 @@ static tBTA_AV_SCB * bta_av_alloc_scb(tBTA_AV_CHNL chnl)
int xx; int xx;
tBTA_AV_STATUS sts = BTA_AV_SUCCESS; tBTA_AV_STATUS sts = BTA_AV_SUCCESS;
if(chnl == BTA_AV_CHNL_VIDEO) if (chnl == BTA_AV_CHNL_VIDEO) {
{ if (p_bta_av_cfg->p_act_tbl == NULL || p_bta_av_cfg->p_reg == NULL) {
if(p_bta_av_cfg->p_act_tbl == NULL || p_bta_av_cfg->p_reg == NULL)
{
APPL_TRACE_ERROR("Video streaming not supported"); APPL_TRACE_ERROR("Video streaming not supported");
sts = BTA_AV_FAIL; sts = BTA_AV_FAIL;
} } else {
else
{
/* allow only one Video channel */ /* allow only one Video channel */
if(bta_av_cb.reg_video) if (bta_av_cb.reg_video) {
{
APPL_TRACE_ERROR("Already registered"); APPL_TRACE_ERROR("Already registered");
sts = BTA_AV_FAIL; sts = BTA_AV_FAIL;
} }
} }
} } else if (chnl != BTA_AV_CHNL_AUDIO) {
else if(chnl != BTA_AV_CHNL_AUDIO)
{
APPL_TRACE_ERROR("bad channel: %d\n", chnl); APPL_TRACE_ERROR("bad channel: %d\n", chnl);
sts = BTA_AV_FAIL; sts = BTA_AV_FAIL;
} }
if(sts == BTA_AV_SUCCESS) if (sts == BTA_AV_SUCCESS) {
{ for (xx = 0; xx < BTA_AV_NUM_STRS; xx++) {
for(xx=0; xx<BTA_AV_NUM_STRS; xx++) if (bta_av_cb.p_scb[xx] == NULL) {
{
if(bta_av_cb.p_scb[xx] == NULL)
{
/* found an empty spot */ /* found an empty spot */
p_ret = (tBTA_AV_SCB *)GKI_getbuf(sizeof(tBTA_AV_SCB)); p_ret = (tBTA_AV_SCB *)GKI_getbuf(sizeof(tBTA_AV_SCB));
if(p_ret) if (p_ret) {
{
memset(p_ret, 0, sizeof(tBTA_AV_SCB)); memset(p_ret, 0, sizeof(tBTA_AV_SCB));
p_ret->rc_handle = BTA_AV_RC_HANDLE_NONE; p_ret->rc_handle = BTA_AV_RC_HANDLE_NONE;
p_ret->chnl = chnl; p_ret->chnl = chnl;
@ -434,11 +409,11 @@ void bta_av_conn_cback(UINT8 handle, BD_ADDR bd_addr, UINT8 event, tAVDT_CTRL *p
#endif #endif
{ {
evt = BTA_AV_SIG_CHG_EVT; evt = BTA_AV_SIG_CHG_EVT;
if(AVDT_DISCONNECT_IND_EVT == event) if (AVDT_DISCONNECT_IND_EVT == event) {
p_scb = bta_av_addr_to_scb(bd_addr); p_scb = bta_av_addr_to_scb(bd_addr);
}
#if (defined(BTA_AV_DEBUG) && BTA_AV_DEBUG == TRUE) #if (defined(BTA_AV_DEBUG) && BTA_AV_DEBUG == TRUE)
else if (AVDT_CONNECT_IND_EVT == event) else if (AVDT_CONNECT_IND_EVT == event) {
{
APPL_TRACE_DEBUG("CONN_IND is ACP:%d\n", p_data->hdr.err_param); APPL_TRACE_DEBUG("CONN_IND is ACP:%d\n", p_data->hdr.err_param);
} }
#endif #endif
@ -448,15 +423,13 @@ void bta_av_conn_cback(UINT8 handle, BD_ADDR bd_addr, UINT8 event, tAVDT_CTRL *p
//(AVDT_CONNECT_IND_EVT == event && AVDT_ACP == p_data->hdr.err_param)) //(AVDT_CONNECT_IND_EVT == event && AVDT_ACP == p_data->hdr.err_param))
(AVDT_CONNECT_IND_EVT == event))&& */ (AVDT_CONNECT_IND_EVT == event))&& */
(p_msg = (tBTA_AV_STR_MSG *) GKI_getbuf((UINT16) (sizeof(tBTA_AV_STR_MSG)))) != NULL) (p_msg = (tBTA_AV_STR_MSG *) GKI_getbuf((UINT16) (sizeof(tBTA_AV_STR_MSG)))) != NULL) {
{
p_msg->hdr.event = evt; p_msg->hdr.event = evt;
p_msg->hdr.layer_specific = event; p_msg->hdr.layer_specific = event;
p_msg->hdr.offset = p_data->hdr.err_param; p_msg->hdr.offset = p_data->hdr.err_param;
bdcpy(p_msg->bd_addr, bd_addr); bdcpy(p_msg->bd_addr, bd_addr);
#if (defined(BTA_AV_DEBUG) && BTA_AV_DEBUG == TRUE) #if (defined(BTA_AV_DEBUG) && BTA_AV_DEBUG == TRUE)
if(p_scb) if (p_scb) {
{
APPL_TRACE_DEBUG("scb hndl x%x, role x%x\n", p_scb->hndl, p_scb->role); APPL_TRACE_DEBUG("scb hndl x%x, role x%x\n", p_scb->hndl, p_scb->role);
} }
#endif #endif
@ -511,22 +484,17 @@ static void bta_av_api_sink_enable(tBTA_AV_DATA *p_data)
BCM_STRNCPY_S(p_service_name, sizeof(p_service_name), BCM_STRNCPY_S(p_service_name, sizeof(p_service_name),
BTIF_AVK_SERVICE_NAME, BTA_SERVICE_NAME_LEN); BTIF_AVK_SERVICE_NAME, BTA_SERVICE_NAME_LEN);
if(activate_sink) if (activate_sink) {
{
AVDT_SINK_Activate(); AVDT_SINK_Activate();
if (bta_av_cb.sdp_a2d_snk_handle == 0) if (bta_av_cb.sdp_a2d_snk_handle == 0) {
{
bta_av_cb.sdp_a2d_snk_handle = SDP_CreateRecord(); bta_av_cb.sdp_a2d_snk_handle = SDP_CreateRecord();
A2D_AddRecord(UUID_SERVCLASS_AUDIO_SINK, p_service_name, NULL, A2D_AddRecord(UUID_SERVCLASS_AUDIO_SINK, p_service_name, NULL,
A2D_SUPF_PLAYER, bta_av_cb.sdp_a2d_snk_handle); A2D_SUPF_PLAYER, bta_av_cb.sdp_a2d_snk_handle);
bta_sys_add_uuid(UUID_SERVCLASS_AUDIO_SINK); bta_sys_add_uuid(UUID_SERVCLASS_AUDIO_SINK);
} }
} } else {
else
{
AVDT_SINK_Deactivate(); AVDT_SINK_Deactivate();
if (bta_av_cb.sdp_a2d_snk_handle != 0) if (bta_av_cb.sdp_a2d_snk_handle != 0) {
{
SDP_DeleteRecord(bta_av_cb.sdp_a2d_snk_handle); SDP_DeleteRecord(bta_av_cb.sdp_a2d_snk_handle);
bta_av_cb.sdp_a2d_snk_handle = 0; bta_av_cb.sdp_a2d_snk_handle = 0;
bta_sys_remove_uuid(UUID_SERVCLASS_AUDIO_SINK); bta_sys_remove_uuid(UUID_SERVCLASS_AUDIO_SINK);
@ -564,11 +532,9 @@ static void bta_av_api_register(tBTA_AV_DATA *p_data)
registr.app_id = p_data->api_reg.app_id; registr.app_id = p_data->api_reg.app_id;
registr.chnl = (tBTA_AV_CHNL)p_data->hdr.layer_specific; registr.chnl = (tBTA_AV_CHNL)p_data->hdr.layer_specific;
registr.p_bta_av_cos = p_data->api_reg.bta_av_cos; registr.p_bta_av_cos = p_data->api_reg.bta_av_cos;
do do {
{
p_scb = bta_av_alloc_scb(registr.chnl); p_scb = bta_av_alloc_scb(registr.chnl);
if(p_scb == NULL) if (p_scb == NULL) {
{
APPL_TRACE_ERROR("failed to alloc SCB"); APPL_TRACE_ERROR("failed to alloc SCB");
break; break;
} }
@ -580,8 +546,7 @@ static void bta_av_api_register(tBTA_AV_DATA *p_data)
p_scb->timer.p_cback = (TIMER_CBACK *)&bta_av_timer_cback; p_scb->timer.p_cback = (TIMER_CBACK *)&bta_av_timer_cback;
registr.status = BTA_AV_SUCCESS; registr.status = BTA_AV_SUCCESS;
if((bta_av_cb.reg_audio + bta_av_cb.reg_video) == 0) if ((bta_av_cb.reg_audio + bta_av_cb.reg_video) == 0) {
{
/* the first channel registered. register to AVDTP */ /* the first channel registered. register to AVDTP */
reg.ctrl_mtu = p_bta_av_cfg->sig_mtu; reg.ctrl_mtu = p_bta_av_cfg->sig_mtu;
reg.ret_tout = BTA_AV_RET_TOUT; reg.ret_tout = BTA_AV_RET_TOUT;
@ -594,8 +559,7 @@ static void bta_av_api_register(tBTA_AV_DATA *p_data)
bta_sys_role_chg_register(&bta_av_sys_rs_cback); bta_sys_role_chg_register(&bta_av_sys_rs_cback);
/* create remote control TG service if required */ /* create remote control TG service if required */
if (bta_av_cb.features & (BTA_AV_FEAT_RCTG)) if (bta_av_cb.features & (BTA_AV_FEAT_RCTG)) {
{
/* register with no authorization; let AVDTP use authorization instead */ /* register with no authorization; let AVDTP use authorization instead */
#if( defined BTA_AR_INCLUDED ) && (BTA_AR_INCLUDED == TRUE) #if( defined BTA_AR_INCLUDED ) && (BTA_AR_INCLUDED == TRUE)
#if (BTA_AV_WITH_AVCTP_AUTHORIZATION == TRUE) #if (BTA_AV_WITH_AVCTP_AUTHORIZATION == TRUE)
@ -634,12 +598,9 @@ static void bta_av_api_register(tBTA_AV_DATA *p_data)
((bta_av_cb.features & BTA_AV_FEAT_PROTECT) ? 0 : AVDT_NSC_SECURITY); ((bta_av_cb.features & BTA_AV_FEAT_PROTECT) ? 0 : AVDT_NSC_SECURITY);
APPL_TRACE_DEBUG("nsc_mask: 0x%x\n", cs.nsc_mask); APPL_TRACE_DEBUG("nsc_mask: 0x%x\n", cs.nsc_mask);
if (p_data->api_reg.p_service_name[0] == 0) if (p_data->api_reg.p_service_name[0] == 0) {
{
p_service_name = NULL; p_service_name = NULL;
} } else {
else
{
p_service_name = p_data->api_reg.p_service_name; p_service_name = p_data->api_reg.p_service_name;
} }
@ -647,8 +608,7 @@ static void bta_av_api_register(tBTA_AV_DATA *p_data)
p_scb->recfg_sup = TRUE; p_scb->recfg_sup = TRUE;
cs.p_ctrl_cback = bta_av_dt_cback[p_scb->hdi]; cs.p_ctrl_cback = bta_av_dt_cback[p_scb->hdi];
if(registr.chnl == BTA_AV_CHNL_AUDIO) if (registr.chnl == BTA_AV_CHNL_AUDIO) {
{
/* set up the audio stream control block */ /* set up the audio stream control block */
p_scb->p_act_tbl = (const tBTA_AV_ACT *)bta_av_a2d_action; p_scb->p_act_tbl = (const tBTA_AV_ACT *)bta_av_a2d_action;
// p_scb->p_cos = &bta_av_a2d_cos; // p_scb->p_cos = &bta_av_a2d_cos;
@ -659,8 +619,7 @@ static void bta_av_api_register(tBTA_AV_DATA *p_data)
cs.mtu = p_bta_av_cfg->audio_mtu; cs.mtu = p_bta_av_cfg->audio_mtu;
cs.flush_to = L2CAP_DEFAULT_FLUSH_TO; cs.flush_to = L2CAP_DEFAULT_FLUSH_TO;
#if AVDT_REPORTING == TRUE #if AVDT_REPORTING == TRUE
if(bta_av_cb.features & BTA_AV_FEAT_REPORT) if (bta_av_cb.features & BTA_AV_FEAT_REPORT) {
{
cs.cfg.psc_mask |= AVDT_PSC_REPORT; cs.cfg.psc_mask |= AVDT_PSC_REPORT;
cs.p_report_cback = bta_av_a2dp_report_cback; cs.p_report_cback = bta_av_a2dp_report_cback;
#if AVDT_MULTIPLEXING == TRUE #if AVDT_MULTIPLEXING == TRUE
@ -668,46 +627,44 @@ static void bta_av_api_register(tBTA_AV_DATA *p_data)
#endif #endif
} }
#endif #endif
if(bta_av_cb.features & BTA_AV_FEAT_DELAY_RPT) if (bta_av_cb.features & BTA_AV_FEAT_DELAY_RPT) {
cs.cfg.psc_mask |= AVDT_PSC_DELAY_RPT; cs.cfg.psc_mask |= AVDT_PSC_DELAY_RPT;
}
/* keep the configuration in the stream control block */ /* keep the configuration in the stream control block */
memcpy(&p_scb->cfg, &cs.cfg, sizeof(tAVDT_CFG)); memcpy(&p_scb->cfg, &cs.cfg, sizeof(tAVDT_CFG));
while (index < BTA_AV_MAX_SEPS && while (index < BTA_AV_MAX_SEPS &&
(p_scb->p_cos->init)(&codec_type, cs.cfg.codec_info, (p_scb->p_cos->init)(&codec_type, cs.cfg.codec_info,
&cs.cfg.num_protect, cs.cfg.protect_info, index) == TRUE) &cs.cfg.num_protect, cs.cfg.protect_info, index) == TRUE) {
{
#if (BTA_AV_SINK_INCLUDED == TRUE) #if (BTA_AV_SINK_INCLUDED == TRUE)
if(index == 1) if (index == 1) {
{
cs.tsep = AVDT_TSEP_SNK; cs.tsep = AVDT_TSEP_SNK;
cs.p_data_cback = bta_av_stream_data_cback; cs.p_data_cback = bta_av_stream_data_cback;
} }
APPL_TRACE_DEBUG(" SEP Type = %d\n", cs.tsep); APPL_TRACE_DEBUG(" SEP Type = %d\n", cs.tsep);
#endif #endif
if(AVDT_CreateStream(&p_scb->seps[index].av_handle, &cs) == AVDT_SUCCESS) if (AVDT_CreateStream(&p_scb->seps[index].av_handle, &cs) == AVDT_SUCCESS) {
{
p_scb->seps[index].codec_type = codec_type; p_scb->seps[index].codec_type = codec_type;
#if (BTA_AV_SINK_INCLUDED == TRUE) #if (BTA_AV_SINK_INCLUDED == TRUE)
p_scb->seps[index].tsep = cs.tsep; p_scb->seps[index].tsep = cs.tsep;
if(cs.tsep == AVDT_TSEP_SNK) if (cs.tsep == AVDT_TSEP_SNK) {
p_scb->seps[index].p_app_data_cback = p_data->api_reg.p_app_data_cback; p_scb->seps[index].p_app_data_cback = p_data->api_reg.p_app_data_cback;
else } else {
p_scb->seps[index].p_app_data_cback = NULL; /* In case of A2DP SOURCE we don't need a callback to handle media packets */ p_scb->seps[index].p_app_data_cback = NULL; /* In case of A2DP SOURCE we don't need a callback to handle media packets */
}
#endif #endif
APPL_TRACE_DEBUG("audio[%d] av_handle: %d codec_type: %d\n", APPL_TRACE_DEBUG("audio[%d] av_handle: %d codec_type: %d\n",
index, p_scb->seps[index].av_handle, p_scb->seps[index].codec_type); index, p_scb->seps[index].av_handle, p_scb->seps[index].codec_type);
index++; index++;
} } else {
else
break; break;
} }
}
if(!bta_av_cb.reg_audio) if (!bta_av_cb.reg_audio) {
{
/* create the SDP records on the 1st audio channel */ /* create the SDP records on the 1st audio channel */
bta_av_cb.sdp_a2d_handle = SDP_CreateRecord(); bta_av_cb.sdp_a2d_handle = SDP_CreateRecord();
A2D_AddRecord(UUID_SERVCLASS_AUDIO_SOURCE, p_service_name, NULL, A2D_AddRecord(UUID_SERVCLASS_AUDIO_SOURCE, p_service_name, NULL,
@ -721,15 +678,14 @@ static void bta_av_api_register(tBTA_AV_DATA *p_data)
bta_sys_add_uuid(UUID_SERVCLASS_AUDIO_SINK); bta_sys_add_uuid(UUID_SERVCLASS_AUDIO_SINK);
#endif #endif
/* start listening when A2DP is registered */ /* start listening when A2DP is registered */
if (bta_av_cb.features & BTA_AV_FEAT_RCTG) if (bta_av_cb.features & BTA_AV_FEAT_RCTG) {
bta_av_rc_create(&bta_av_cb, AVCT_ACP, 0, BTA_AV_NUM_LINKS + 1); bta_av_rc_create(&bta_av_cb, AVCT_ACP, 0, BTA_AV_NUM_LINKS + 1);
}
/* if the AV and AVK are both supported, it cannot support the CT role */ /* if the AV and AVK are both supported, it cannot support the CT role */
if (bta_av_cb.features & (BTA_AV_FEAT_RCCT)) if (bta_av_cb.features & (BTA_AV_FEAT_RCCT)) {
{
/* if TG is not supported, we need to register to AVCT now */ /* if TG is not supported, we need to register to AVCT now */
if ((bta_av_cb.features & (BTA_AV_FEAT_RCTG)) == 0) if ((bta_av_cb.features & (BTA_AV_FEAT_RCTG)) == 0) {
{
#if( defined BTA_AR_INCLUDED ) && (BTA_AR_INCLUDED == TRUE) #if( defined BTA_AR_INCLUDED ) && (BTA_AR_INCLUDED == TRUE)
#if (BTA_AV_WITH_AVCTP_AUTHORIZATION == TRUE) #if (BTA_AV_WITH_AVCTP_AUTHORIZATION == TRUE)
bta_ar_reg_avct(p_bta_av_cfg->avrc_mtu, p_bta_av_cfg->avrc_br_mtu, bta_ar_reg_avct(p_bta_av_cfg->avrc_mtu, p_bta_av_cfg->avrc_br_mtu,
@ -749,9 +705,7 @@ static void bta_av_api_register(tBTA_AV_DATA *p_data)
} }
bta_av_cb.reg_audio |= BTA_AV_HNDL_TO_MSK(p_scb->hdi); bta_av_cb.reg_audio |= BTA_AV_HNDL_TO_MSK(p_scb->hdi);
APPL_TRACE_DEBUG("reg_audio: 0x%x\n", bta_av_cb.reg_audio); APPL_TRACE_DEBUG("reg_audio: 0x%x\n", bta_av_cb.reg_audio);
} } else {
else
{
bta_av_cb.reg_video = BTA_AV_HNDL_TO_MSK(p_scb->hdi); bta_av_cb.reg_video = BTA_AV_HNDL_TO_MSK(p_scb->hdi);
bta_av_cb.sdp_vdp_handle = SDP_CreateRecord(); bta_av_cb.sdp_vdp_handle = SDP_CreateRecord();
/* register the video channel */ /* register the video channel */
@ -778,13 +732,10 @@ void bta_av_api_deregister(tBTA_AV_DATA *p_data)
{ {
tBTA_AV_SCB *p_scb = bta_av_hndl_to_scb(p_data->hdr.layer_specific); tBTA_AV_SCB *p_scb = bta_av_hndl_to_scb(p_data->hdr.layer_specific);
if(p_scb) if (p_scb) {
{
p_scb->deregistring = TRUE; p_scb->deregistring = TRUE;
bta_av_ssm_execute(p_scb, BTA_AV_API_CLOSE_EVT, p_data); bta_av_ssm_execute(p_scb, BTA_AV_API_CLOSE_EVT, p_data);
} } else {
else
{
bta_av_dereg_comp(p_data); bta_av_dereg_comp(p_data);
} }
} }
@ -805,12 +756,10 @@ static void bta_av_ci_data(tBTA_AV_DATA *p_data)
int i; int i;
UINT8 chnl = (UINT8)p_data->hdr.layer_specific; UINT8 chnl = (UINT8)p_data->hdr.layer_specific;
for( i=0; i < BTA_AV_NUM_STRS; i++ ) for ( i = 0; i < BTA_AV_NUM_STRS; i++ ) {
{
p_scb = bta_av_cb.p_scb[i]; p_scb = bta_av_cb.p_scb[i];
if(p_scb && p_scb->chnl == chnl) if (p_scb && p_scb->chnl == chnl) {
{
bta_av_ssm_execute(p_scb, BTA_AV_SRC_DATA_READY_EVT, p_data); bta_av_ssm_execute(p_scb, BTA_AV_SRC_DATA_READY_EVT, p_data);
} }
} }
@ -847,8 +796,7 @@ static void bta_av_api_to_ssm(tBTA_AV_DATA *p_data)
int xx; int xx;
UINT16 event = p_data->hdr.event - BTA_AV_FIRST_A2S_API_EVT + BTA_AV_FIRST_A2S_SSM_EVT; UINT16 event = p_data->hdr.event - BTA_AV_FIRST_A2S_API_EVT + BTA_AV_FIRST_A2S_SSM_EVT;
for(xx=0; xx<BTA_AV_NUM_STRS; xx++) for (xx = 0; xx < BTA_AV_NUM_STRS; xx++) {
{
bta_av_ssm_execute(bta_av_cb.p_scb[xx], event, p_data); bta_av_ssm_execute(bta_av_cb.p_scb[xx], event, p_data);
} }
} }
@ -869,23 +817,18 @@ BOOLEAN bta_av_chk_start(tBTA_AV_SCB *p_scb)
tBTA_AV_SCB *p_scbi; tBTA_AV_SCB *p_scbi;
int i; int i;
if(p_scb->chnl == BTA_AV_CHNL_AUDIO) if (p_scb->chnl == BTA_AV_CHNL_AUDIO) {
{
if ((bta_av_cb.audio_open_cnt >= 2) && if ((bta_av_cb.audio_open_cnt >= 2) &&
((0 == (p_scb->role & BTA_AV_ROLE_AD_ACP)) || /* Outgoing connection or */ ((0 == (p_scb->role & BTA_AV_ROLE_AD_ACP)) || /* Outgoing connection or */
(bta_av_cb.features & BTA_AV_FEAT_ACP_START))) /* auto-starting option */ (bta_av_cb.features & BTA_AV_FEAT_ACP_START))) { /* auto-starting option */
{
/* more than one audio channel is connected */ /* more than one audio channel is connected */
/* if this is the 2nd stream as ACP, give INT a chance to issue the START command */ /* if this is the 2nd stream as ACP, give INT a chance to issue the START command */
for(i=0; i<BTA_AV_NUM_STRS; i++) for (i = 0; i < BTA_AV_NUM_STRS; i++) {
{
p_scbi = bta_av_cb.p_scb[i]; p_scbi = bta_av_cb.p_scb[i];
if(p_scbi && p_scbi->chnl == BTA_AV_CHNL_AUDIO && p_scbi->co_started) if (p_scbi && p_scbi->chnl == BTA_AV_CHNL_AUDIO && p_scbi->co_started) {
{
start = TRUE; start = TRUE;
/* may need to update the flush timeout of this already started stream */ /* may need to update the flush timeout of this already started stream */
if(p_scbi->co_started != bta_av_cb.audio_open_cnt) if (p_scbi->co_started != bta_av_cb.audio_open_cnt) {
{
p_scbi->co_started = bta_av_cb.audio_open_cnt; p_scbi->co_started = bta_av_cb.audio_open_cnt;
L2CA_SetFlushTimeout(p_scbi->peer_addr, p_bta_av_cfg->p_audio_flush_to[p_scbi->co_started - 1] ); L2CA_SetFlushTimeout(p_scbi->peer_addr, p_bta_av_cfg->p_audio_flush_to[p_scbi->co_started - 1] );
} }
@ -913,13 +856,10 @@ void bta_av_restore_switch (void)
UINT8 mask; UINT8 mask;
APPL_TRACE_DEBUG("reg_audio: 0x%x\n", bta_av_cb.reg_audio); APPL_TRACE_DEBUG("reg_audio: 0x%x\n", bta_av_cb.reg_audio);
for(i=0; i<BTA_AV_NUM_STRS; i++) for (i = 0; i < BTA_AV_NUM_STRS; i++) {
{
mask = BTA_AV_HNDL_TO_MSK(i); mask = BTA_AV_HNDL_TO_MSK(i);
if (p_cb->conn_audio == mask) if (p_cb->conn_audio == mask) {
{ if (p_cb->p_scb[i]) {
if (p_cb->p_scb[i])
{
bta_sys_set_policy(BTA_ID_AV, HCI_ENABLE_MASTER_SLAVE_SWITCH, p_cb->p_scb[i]->peer_addr); bta_sys_set_policy(BTA_ID_AV, HCI_ENABLE_MASTER_SLAVE_SWITCH, p_cb->p_scb[i]->peer_addr);
} }
break; break;
@ -946,14 +886,12 @@ static void bta_av_sys_rs_cback (tBTA_SYS_CONN_STATUS status,UINT8 id, UINT8 app
UNUSED(status); UNUSED(status);
APPL_TRACE_DEBUG("bta_av_sys_rs_cback: %d\n", bta_av_cb.rs_idx); APPL_TRACE_DEBUG("bta_av_sys_rs_cback: %d\n", bta_av_cb.rs_idx);
for(i=0; i<BTA_AV_NUM_STRS; i++) for (i = 0; i < BTA_AV_NUM_STRS; i++) {
{
/* loop through all the SCBs to find matching peer addresses and report the role change event */ /* loop through all the SCBs to find matching peer addresses and report the role change event */
/* note that more than one SCB (a2dp & vdp) maybe waiting for this event */ /* note that more than one SCB (a2dp & vdp) maybe waiting for this event */
p_scb = bta_av_cb.p_scb[i]; p_scb = bta_av_cb.p_scb[i];
if (p_scb && (bdcmp (peer_addr, p_scb->peer_addr) == 0) && if (p_scb && (bdcmp (peer_addr, p_scb->peer_addr) == 0) &&
(p_buf = (tBTA_AV_ROLE_RES *) GKI_getbuf(sizeof(tBTA_AV_ROLE_RES))) != NULL) (p_buf = (tBTA_AV_ROLE_RES *) GKI_getbuf(sizeof(tBTA_AV_ROLE_RES))) != NULL) {
{
APPL_TRACE_DEBUG("new_role:%d, hci_status:x%x hndl: x%x\n", id, app_id, p_scb->hndl); APPL_TRACE_DEBUG("new_role:%d, hci_status:x%x hndl: x%x\n", id, app_id, p_scb->hndl);
/* /*
if ((id != BTM_ROLE_MASTER) && (app_id != HCI_SUCCESS)) if ((id != BTM_ROLE_MASTER) && (app_id != HCI_SUCCESS))
@ -974,28 +912,25 @@ static void bta_av_sys_rs_cback (tBTA_SYS_CONN_STATUS status,UINT8 id, UINT8 app
/* restore role switch policy, if role switch failed */ /* restore role switch policy, if role switch failed */
if ((HCI_SUCCESS != app_id) && if ((HCI_SUCCESS != app_id) &&
(BTM_GetRole (peer_addr, &cur_role) == BTM_SUCCESS) && (BTM_GetRole (peer_addr, &cur_role) == BTM_SUCCESS) &&
(cur_role == BTM_ROLE_SLAVE) ) (cur_role == BTM_ROLE_SLAVE) ) {
{
bta_sys_set_policy(BTA_ID_AV, HCI_ENABLE_MASTER_SLAVE_SWITCH, peer_addr); bta_sys_set_policy(BTA_ID_AV, HCI_ENABLE_MASTER_SLAVE_SWITCH, peer_addr);
} }
/* if BTA_AvOpen() was called for other device, which caused the role switch of the peer_addr, */ /* if BTA_AvOpen() was called for other device, which caused the role switch of the peer_addr, */
/* we need to continue opening process for the BTA_AvOpen(). */ /* we need to continue opening process for the BTA_AvOpen(). */
if ((bta_av_cb.rs_idx != 0) && (bta_av_cb.rs_idx != peer_idx)) if ((bta_av_cb.rs_idx != 0) && (bta_av_cb.rs_idx != peer_idx)) {
{ if ((bta_av_cb.rs_idx - 1) < BTA_AV_NUM_STRS) {
if ((bta_av_cb.rs_idx -1) < BTA_AV_NUM_STRS)
{
p_scb = bta_av_cb.p_scb[bta_av_cb.rs_idx - 1]; p_scb = bta_av_cb.p_scb[bta_av_cb.rs_idx - 1];
} }
if (p_scb && p_scb->q_tag == BTA_AV_Q_TAG_OPEN) if (p_scb && p_scb->q_tag == BTA_AV_Q_TAG_OPEN) {
{
APPL_TRACE_DEBUG ("bta_av_sys_rs_cback: rs_idx(%d), hndl:x%x q_tag: %d\n", APPL_TRACE_DEBUG ("bta_av_sys_rs_cback: rs_idx(%d), hndl:x%x q_tag: %d\n",
bta_av_cb.rs_idx, p_scb->hndl, p_scb->q_tag); bta_av_cb.rs_idx, p_scb->hndl, p_scb->q_tag);
if(HCI_SUCCESS == app_id || HCI_ERR_NO_CONNECTION == app_id) if (HCI_SUCCESS == app_id || HCI_ERR_NO_CONNECTION == app_id) {
p_scb->q_info.open.switch_res = BTA_AV_RS_OK; p_scb->q_info.open.switch_res = BTA_AV_RS_OK;
else } else {
p_scb->q_info.open.switch_res = BTA_AV_RS_FAIL; p_scb->q_info.open.switch_res = BTA_AV_RS_FAIL;
}
/* Continue av open process */ /* Continue av open process */
bta_av_do_disc_a2d (p_scb, (tBTA_AV_DATA *) & (p_scb->q_info.open)); bta_av_do_disc_a2d (p_scb, (tBTA_AV_DATA *) & (p_scb->q_info.open));
@ -1026,17 +961,14 @@ static void bta_av_sco_chg_cback(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8
UNUSED(peer_addr); UNUSED(peer_addr);
APPL_TRACE_DEBUG("bta_av_sco_chg_cback:%d status:%d\n", id, status); APPL_TRACE_DEBUG("bta_av_sco_chg_cback:%d status:%d\n", id, status);
if(id) if (id) {
{
bta_av_cb.sco_occupied = TRUE; bta_av_cb.sco_occupied = TRUE;
/* either BTA_SYS_SCO_OPEN or BTA_SYS_SCO_CLOSE with remaining active SCO */ /* either BTA_SYS_SCO_OPEN or BTA_SYS_SCO_CLOSE with remaining active SCO */
for(i=0; i<BTA_AV_NUM_STRS; i++) for (i = 0; i < BTA_AV_NUM_STRS; i++) {
{
p_scb = bta_av_cb.p_scb[i]; p_scb = bta_av_cb.p_scb[i];
if( p_scb && p_scb->co_started && (p_scb->sco_suspend == FALSE)) if ( p_scb && p_scb->co_started && (p_scb->sco_suspend == FALSE)) {
{
APPL_TRACE_DEBUG("suspending scb:%d\n", i); APPL_TRACE_DEBUG("suspending scb:%d\n", i);
/* scb is used and started, not suspended automatically */ /* scb is used and started, not suspended automatically */
p_scb->sco_suspend = TRUE; p_scb->sco_suspend = TRUE;
@ -1045,17 +977,13 @@ static void bta_av_sco_chg_cback(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8
bta_av_ssm_execute(p_scb, BTA_AV_AP_STOP_EVT, (tBTA_AV_DATA *)&stop); bta_av_ssm_execute(p_scb, BTA_AV_AP_STOP_EVT, (tBTA_AV_DATA *)&stop);
} }
} }
} } else {
else
{
bta_av_cb.sco_occupied = FALSE; bta_av_cb.sco_occupied = FALSE;
for(i=0; i<BTA_AV_NUM_STRS; i++) for (i = 0; i < BTA_AV_NUM_STRS; i++) {
{
p_scb = bta_av_cb.p_scb[i]; p_scb = bta_av_cb.p_scb[i];
if( p_scb && p_scb->sco_suspend ) /* scb is used and suspended for SCO */ if ( p_scb && p_scb->sco_suspend ) { /* scb is used and suspended for SCO */
{
APPL_TRACE_DEBUG("starting scb:%d\n", i); APPL_TRACE_DEBUG("starting scb:%d\n", i);
bta_av_ssm_execute(p_scb, BTA_AV_AP_START_EVT, NULL); bta_av_ssm_execute(p_scb, BTA_AV_AP_START_EVT, NULL);
} }
@ -1082,22 +1010,19 @@ BOOLEAN bta_av_switch_if_needed(tBTA_AV_SCB *p_scb)
int i; int i;
UINT8 mask; UINT8 mask;
for(i=0; i<BTA_AV_NUM_STRS; i++) for (i = 0; i < BTA_AV_NUM_STRS; i++) {
{
mask = BTA_AV_HNDL_TO_MSK(i); mask = BTA_AV_HNDL_TO_MSK(i);
p_scbi = bta_av_cb.p_scb[i]; p_scbi = bta_av_cb.p_scb[i];
if ( p_scbi && (p_scb->hdi != i) && /* not the original channel */ if ( p_scbi && (p_scb->hdi != i) && /* not the original channel */
((bta_av_cb.conn_audio & mask) ||/* connected audio */ ((bta_av_cb.conn_audio & mask) ||/* connected audio */
(bta_av_cb.conn_video & mask)) ) /* connected video */ (bta_av_cb.conn_video & mask)) ) { /* connected video */
{
BTM_GetRole(p_scbi->peer_addr, &role); BTM_GetRole(p_scbi->peer_addr, &role);
/* this channel is open - clear the role switch link policy for this link */ /* this channel is open - clear the role switch link policy for this link */
if(BTM_ROLE_MASTER != role) if (BTM_ROLE_MASTER != role) {
{ if (bta_av_cb.features & BTA_AV_FEAT_MASTER) {
if (bta_av_cb.features & BTA_AV_FEAT_MASTER)
bta_sys_clear_policy(BTA_ID_AV, HCI_ENABLE_MASTER_SLAVE_SWITCH, p_scbi->peer_addr); bta_sys_clear_policy(BTA_ID_AV, HCI_ENABLE_MASTER_SLAVE_SWITCH, p_scbi->peer_addr);
if (BTM_CMD_STARTED != BTM_SwitchRole(p_scbi->peer_addr, BTM_ROLE_MASTER, NULL)) }
{ if (BTM_CMD_STARTED != BTM_SwitchRole(p_scbi->peer_addr, BTM_ROLE_MASTER, NULL)) {
/* can not switch role on SCBI /* can not switch role on SCBI
* start the timer on SCB - because this function is ONLY called when SCB gets API_OPEN */ * start the timer on SCB - because this function is ONLY called when SCB gets API_OPEN */
bta_sys_start_timer(&p_scb->timer, BTA_AV_AVRC_TIMER_EVT, BTA_AV_RS_TIME_VAL); bta_sys_start_timer(&p_scb->timer, BTA_AV_AVRC_TIMER_EVT, BTA_AV_RS_TIME_VAL);
@ -1127,18 +1052,16 @@ BOOLEAN bta_av_link_role_ok(tBTA_AV_SCB *p_scb, UINT8 bits)
UINT8 role; UINT8 role;
BOOLEAN is_ok = TRUE; BOOLEAN is_ok = TRUE;
if (BTM_GetRole(p_scb->peer_addr, &role) == BTM_SUCCESS) if (BTM_GetRole(p_scb->peer_addr, &role) == BTM_SUCCESS) {
{
LOG_INFO("%s hndl:x%x role:%d conn_audio:x%x bits:%d features:x%x\n", LOG_INFO("%s hndl:x%x role:%d conn_audio:x%x bits:%d features:x%x\n",
__func__, p_scb->hndl, role, bta_av_cb.conn_audio, bits, __func__, p_scb->hndl, role, bta_av_cb.conn_audio, bits,
bta_av_cb.features); bta_av_cb.features);
if (BTM_ROLE_MASTER != role && (A2D_BitsSet(bta_av_cb.conn_audio) > bits || (bta_av_cb.features & BTA_AV_FEAT_MASTER))) if (BTM_ROLE_MASTER != role && (A2D_BitsSet(bta_av_cb.conn_audio) > bits || (bta_av_cb.features & BTA_AV_FEAT_MASTER))) {
{ if (bta_av_cb.features & BTA_AV_FEAT_MASTER) {
if (bta_av_cb.features & BTA_AV_FEAT_MASTER)
bta_sys_clear_policy(BTA_ID_AV, HCI_ENABLE_MASTER_SLAVE_SWITCH, p_scb->peer_addr); bta_sys_clear_policy(BTA_ID_AV, HCI_ENABLE_MASTER_SLAVE_SWITCH, p_scb->peer_addr);
}
if (BTM_CMD_STARTED != BTM_SwitchRole(p_scb->peer_addr, BTM_ROLE_MASTER, NULL)) if (BTM_CMD_STARTED != BTM_SwitchRole(p_scb->peer_addr, BTM_ROLE_MASTER, NULL)) {
{
/* can not switch role on SCB - start the timer on SCB */ /* can not switch role on SCB - start the timer on SCB */
} }
is_ok = FALSE; is_ok = FALSE;
@ -1169,27 +1092,23 @@ UINT16 bta_av_chk_mtu(tBTA_AV_SCB *p_scb, UINT16 mtu)
UNUSED(mtu); UNUSED(mtu);
/* TODO_MV mess with the mtu according to the number of EDR/non-EDR headsets */ /* TODO_MV mess with the mtu according to the number of EDR/non-EDR headsets */
if(p_scb->chnl == BTA_AV_CHNL_AUDIO) if (p_scb->chnl == BTA_AV_CHNL_AUDIO) {
{ if (bta_av_cb.audio_open_cnt >= 2) {
if(bta_av_cb.audio_open_cnt >= 2)
{
/* more than one audio channel is connected */ /* more than one audio channel is connected */
for(i=0; i<BTA_AV_NUM_STRS; i++) for (i = 0; i < BTA_AV_NUM_STRS; i++) {
{
p_scbi = bta_av_cb.p_scb[i]; p_scbi = bta_av_cb.p_scb[i];
if((p_scb != p_scbi) && p_scbi && (p_scbi->chnl == BTA_AV_CHNL_AUDIO) ) if ((p_scb != p_scbi) && p_scbi && (p_scbi->chnl == BTA_AV_CHNL_AUDIO) ) {
{
mask = BTA_AV_HNDL_TO_MSK(i); mask = BTA_AV_HNDL_TO_MSK(i);
APPL_TRACE_DEBUG("[%d] mtu: %d, mask:0x%x\n", APPL_TRACE_DEBUG("[%d] mtu: %d, mask:0x%x\n",
i, p_scbi->stream_mtu, mask); i, p_scbi->stream_mtu, mask);
if(bta_av_cb.conn_audio & mask) if (bta_av_cb.conn_audio & mask) {
{ if (ret_mtu > p_scbi->stream_mtu) {
if(ret_mtu > p_scbi->stream_mtu)
ret_mtu = p_scbi->stream_mtu; ret_mtu = p_scbi->stream_mtu;
} }
} }
} }
} }
}
APPL_TRACE_DEBUG("bta_av_chk_mtu audio count:%d, conn_audio:0x%x, ret:%d\n", APPL_TRACE_DEBUG("bta_av_chk_mtu audio count:%d, conn_audio:0x%x, ret:%d\n",
bta_av_cb.audio_open_cnt, bta_av_cb.conn_audio, ret_mtu); bta_av_cb.audio_open_cnt, bta_av_cb.conn_audio, ret_mtu);
} }
@ -1212,25 +1131,22 @@ void bta_av_dup_audio_buf(tBTA_AV_SCB *p_scb, BT_HDR *p_buf)
UINT16 size, copy_size; UINT16 size, copy_size;
BT_HDR *p_new; BT_HDR *p_new;
if(!p_buf) if (!p_buf) {
return; return;
}
if(bta_av_cb.audio_open_cnt >= 2) if (bta_av_cb.audio_open_cnt >= 2) {
{
size = GKI_get_buf_size(p_buf); size = GKI_get_buf_size(p_buf);
copy_size = BT_HDR_SIZE + p_buf->len + p_buf->offset; copy_size = BT_HDR_SIZE + p_buf->len + p_buf->offset;
/* more than one audio channel is connected */ /* more than one audio channel is connected */
for(i=0; i<BTA_AV_NUM_STRS; i++) for (i = 0; i < BTA_AV_NUM_STRS; i++) {
{
p_scbi = bta_av_cb.p_scb[i]; p_scbi = bta_av_cb.p_scb[i];
if ( (p_scb->hdi != i) && /* not the original channel */ if ( (p_scb->hdi != i) && /* not the original channel */
(bta_av_cb.conn_audio & BTA_AV_HNDL_TO_MSK(i)) && /* connected audio */ (bta_av_cb.conn_audio & BTA_AV_HNDL_TO_MSK(i)) && /* connected audio */
p_scbi && p_scbi->co_started ) /* scb is used and started */ p_scbi && p_scbi->co_started ) { /* scb is used and started */
{
/* enqueue the data only when the stream is started */ /* enqueue the data only when the stream is started */
p_new = (BT_HDR *)GKI_getbuf(size); p_new = (BT_HDR *)GKI_getbuf(size);
if(p_new) if (p_new) {
{
memcpy(p_new, p_buf, copy_size); memcpy(p_new, p_buf, copy_size);
list_append(p_scbi->a2d_list, p_new); list_append(p_scbi->a2d_list, p_new);
if (list_length(p_scbi->a2d_list) > p_bta_av_cfg->audio_mqs) { if (list_length(p_scbi->a2d_list) > p_bta_av_cfg->audio_mqs) {
@ -1279,8 +1195,7 @@ void bta_av_sm_execute(tBTA_AV_CB *p_cb, UINT16 event, tBTA_AV_DATA *p_data)
APPL_TRACE_EVENT("next state=%d\n", p_cb->state); APPL_TRACE_EVENT("next state=%d\n", p_cb->state);
/* execute action functions */ /* execute action functions */
if ((action = state_table[event][BTA_AV_ACTION_COL]) != BTA_AV_IGNORE) if ((action = state_table[event][BTA_AV_ACTION_COL]) != BTA_AV_IGNORE) {
{
(*bta_av_action[action])(p_cb, p_data); (*bta_av_action[action])(p_cb, p_data);
} }
} }
@ -1301,13 +1216,11 @@ BOOLEAN bta_av_hdl_event(BT_HDR *p_msg)
UINT16 event = p_msg->event; UINT16 event = p_msg->event;
UINT16 first_event = BTA_AV_FIRST_NSM_EVT; UINT16 first_event = BTA_AV_FIRST_NSM_EVT;
if (event > BTA_AV_LAST_EVT) if (event > BTA_AV_LAST_EVT) {
{
return TRUE; /* to free p_msg */ return TRUE; /* to free p_msg */
} }
if(event >= first_event) if (event >= first_event) {
{
#if (defined(BTA_AV_DEBUG) && BTA_AV_DEBUG == TRUE) #if (defined(BTA_AV_DEBUG) && BTA_AV_DEBUG == TRUE)
APPL_TRACE_VERBOSE("AV nsm event=0x%x(%s)\n", event, bta_av_evt_code(event)); APPL_TRACE_VERBOSE("AV nsm event=0x%x(%s)\n", event, bta_av_evt_code(event));
#else #else
@ -1315,9 +1228,7 @@ BOOLEAN bta_av_hdl_event(BT_HDR *p_msg)
#endif #endif
/* non state machine events */ /* non state machine events */
(*bta_av_nsm_act[event - BTA_AV_FIRST_NSM_EVT]) ((tBTA_AV_DATA *) p_msg); (*bta_av_nsm_act[event - BTA_AV_FIRST_NSM_EVT]) ((tBTA_AV_DATA *) p_msg);
} } else if (event >= BTA_AV_FIRST_SM_EVT && event <= BTA_AV_LAST_SM_EVT) {
else if (event >= BTA_AV_FIRST_SM_EVT && event <= BTA_AV_LAST_SM_EVT)
{
#if (defined(BTA_AV_DEBUG) && BTA_AV_DEBUG == TRUE) #if (defined(BTA_AV_DEBUG) && BTA_AV_DEBUG == TRUE)
APPL_TRACE_VERBOSE("AV sm event=0x%x(%s)\n", event, bta_av_evt_code(event)); APPL_TRACE_VERBOSE("AV sm event=0x%x(%s)\n", event, bta_av_evt_code(event));
#else #else
@ -1325,9 +1236,7 @@ BOOLEAN bta_av_hdl_event(BT_HDR *p_msg)
#endif #endif
/* state machine events */ /* state machine events */
bta_av_sm_execute(&bta_av_cb, p_msg->event, (tBTA_AV_DATA *) p_msg); bta_av_sm_execute(&bta_av_cb, p_msg->event, (tBTA_AV_DATA *) p_msg);
} } else {
else
{
APPL_TRACE_VERBOSE("handle=0x%x\n", p_msg->layer_specific); APPL_TRACE_VERBOSE("handle=0x%x\n", p_msg->layer_specific);
/* stream state machine events */ /* stream state machine events */
bta_av_ssm_execute( bta_av_hndl_to_scb(p_msg->layer_specific), bta_av_ssm_execute( bta_av_hndl_to_scb(p_msg->layer_specific),
@ -1352,8 +1261,7 @@ BOOLEAN bta_av_hdl_event(BT_HDR *p_msg)
*******************************************************************************/ *******************************************************************************/
static char *bta_av_st_code(UINT8 state) static char *bta_av_st_code(UINT8 state)
{ {
switch(state) switch (state) {
{
case BTA_AV_INIT_ST: return "INIT"; case BTA_AV_INIT_ST: return "INIT";
case BTA_AV_OPEN_ST: return "OPEN"; case BTA_AV_OPEN_ST: return "OPEN";
default: return "unknown"; default: return "unknown";
@ -1370,8 +1278,7 @@ static char *bta_av_st_code(UINT8 state)
*******************************************************************************/ *******************************************************************************/
char *bta_av_evt_code(UINT16 evt_code) char *bta_av_evt_code(UINT16 evt_code)
{ {
switch(evt_code) switch (evt_code) {
{
case BTA_AV_API_DISABLE_EVT: return "API_DISABLE"; case BTA_AV_API_DISABLE_EVT: return "API_DISABLE";
case BTA_AV_API_REMOTE_CMD_EVT: return "API_REMOTE_CMD"; case BTA_AV_API_REMOTE_CMD_EVT: return "API_REMOTE_CMD";
case BTA_AV_API_VENDOR_CMD_EVT: return "API_VENDOR_CMD"; case BTA_AV_API_VENDOR_CMD_EVT: return "API_VENDOR_CMD";

174
components/bt/bluedroid/bta/av/bta_av_sbc.c Executable file → Normal file
View file

@ -36,8 +36,7 @@ typedef int (tBTA_AV_SBC_ACT)(void *p_src, void *p_dst,
UINT32 src_samples, UINT32 dst_samples, UINT32 src_samples, UINT32 dst_samples,
UINT32 *p_ret); UINT32 *p_ret);
typedef struct typedef struct {
{
INT32 cur_pos; /* current position */ INT32 cur_pos; /* current position */
UINT32 src_sps; /* samples per second (source audio data) */ UINT32 src_sps; /* samples per second (source audio data) */
UINT32 dst_sps; /* samples per second (converted audio data) */ UINT32 dst_sps; /* samples per second (converted audio data) */
@ -73,30 +72,21 @@ void bta_av_sbc_init_up_sample (UINT32 src_sps, UINT32 dst_sps, UINT16 bits, UIN
bta_av_sbc_ups_cb.bits = bits; bta_av_sbc_ups_cb.bits = bits;
bta_av_sbc_ups_cb.n_channels = n_channels; bta_av_sbc_ups_cb.n_channels = n_channels;
if(n_channels == 1) if (n_channels == 1) {
{
/* mono */ /* mono */
if(bits == 8) if (bits == 8) {
{
bta_av_sbc_ups_cb.p_act = bta_av_sbc_up_sample_8m; bta_av_sbc_ups_cb.p_act = bta_av_sbc_up_sample_8m;
bta_av_sbc_ups_cb.div = 1; bta_av_sbc_ups_cb.div = 1;
} } else {
else
{
bta_av_sbc_ups_cb.p_act = bta_av_sbc_up_sample_16m; bta_av_sbc_ups_cb.p_act = bta_av_sbc_up_sample_16m;
bta_av_sbc_ups_cb.div = 2; bta_av_sbc_ups_cb.div = 2;
} }
} } else {
else
{
/* stereo */ /* stereo */
if(bits == 8) if (bits == 8) {
{
bta_av_sbc_ups_cb.p_act = bta_av_sbc_up_sample_8s; bta_av_sbc_ups_cb.p_act = bta_av_sbc_up_sample_8s;
bta_av_sbc_ups_cb.div = 2; bta_av_sbc_ups_cb.div = 2;
} } else {
else
{
bta_av_sbc_ups_cb.p_act = bta_av_sbc_up_sample_16s; bta_av_sbc_ups_cb.p_act = bta_av_sbc_up_sample_16s;
bta_av_sbc_ups_cb.div = 4; bta_av_sbc_ups_cb.div = 4;
} }
@ -135,14 +125,11 @@ int bta_av_sbc_up_sample (void *p_src, void *p_dst,
UINT32 src; UINT32 src;
UINT32 dst; UINT32 dst;
if(bta_av_sbc_ups_cb.p_act) if (bta_av_sbc_ups_cb.p_act) {
{
src = src_samples / bta_av_sbc_ups_cb.div; src = src_samples / bta_av_sbc_ups_cb.div;
dst = dst_samples / bta_av_sbc_ups_cb.div; dst = dst_samples / bta_av_sbc_ups_cb.div;
return (*bta_av_sbc_ups_cb.p_act)(p_src, p_dst, src, dst, p_ret); return (*bta_av_sbc_ups_cb.p_act)(p_src, p_dst, src, dst, p_ret);
} } else {
else
{
*p_ret = 0; *p_ret = 0;
return 0; return 0;
} }
@ -176,8 +163,7 @@ int bta_av_sbc_up_sample_16s (void *p_src, void *p_dst,
UINT32 src_sps = bta_av_sbc_ups_cb.src_sps; UINT32 src_sps = bta_av_sbc_ups_cb.src_sps;
UINT32 dst_sps = bta_av_sbc_ups_cb.dst_sps; UINT32 dst_sps = bta_av_sbc_ups_cb.dst_sps;
while (bta_av_sbc_ups_cb.cur_pos > 0 && dst_samples) while (bta_av_sbc_ups_cb.cur_pos > 0 && dst_samples) {
{
*p_dst_tmp++ = *p_worker1; *p_dst_tmp++ = *p_worker1;
*p_dst_tmp++ = *p_worker2; *p_dst_tmp++ = *p_worker2;
@ -187,13 +173,11 @@ int bta_av_sbc_up_sample_16s (void *p_src, void *p_dst,
bta_av_sbc_ups_cb.cur_pos = dst_sps; bta_av_sbc_ups_cb.cur_pos = dst_sps;
while (src_samples-- && dst_samples) while (src_samples-- && dst_samples) {
{
*p_worker1 = *p_src_tmp++; *p_worker1 = *p_src_tmp++;
*p_worker2 = *p_src_tmp++; *p_worker2 = *p_src_tmp++;
do do {
{
*p_dst_tmp++ = *p_worker1; *p_dst_tmp++ = *p_worker1;
*p_dst_tmp++ = *p_worker2; *p_dst_tmp++ = *p_worker2;
@ -204,8 +188,9 @@ int bta_av_sbc_up_sample_16s (void *p_src, void *p_dst,
bta_av_sbc_ups_cb.cur_pos += dst_sps; bta_av_sbc_ups_cb.cur_pos += dst_sps;
} }
if (bta_av_sbc_ups_cb.cur_pos == (INT32)dst_sps) if (bta_av_sbc_ups_cb.cur_pos == (INT32)dst_sps) {
bta_av_sbc_ups_cb.cur_pos = 0; bta_av_sbc_ups_cb.cur_pos = 0;
}
*p_ret = ((char *)p_src_tmp - (char *)p_src); *p_ret = ((char *)p_src_tmp - (char *)p_src);
return ((char *)p_dst_tmp - (char *)p_dst); return ((char *)p_dst_tmp - (char *)p_dst);
@ -238,8 +223,7 @@ int bta_av_sbc_up_sample_16m (void *p_src, void *p_dst,
UINT32 src_sps = bta_av_sbc_ups_cb.src_sps; UINT32 src_sps = bta_av_sbc_ups_cb.src_sps;
UINT32 dst_sps = bta_av_sbc_ups_cb.dst_sps; UINT32 dst_sps = bta_av_sbc_ups_cb.dst_sps;
while (bta_av_sbc_ups_cb.cur_pos > 0 && dst_samples) while (bta_av_sbc_ups_cb.cur_pos > 0 && dst_samples) {
{
*p_dst_tmp++ = *p_worker; *p_dst_tmp++ = *p_worker;
*p_dst_tmp++ = *p_worker; *p_dst_tmp++ = *p_worker;
@ -251,12 +235,10 @@ int bta_av_sbc_up_sample_16m (void *p_src, void *p_dst,
bta_av_sbc_ups_cb.cur_pos = dst_sps; bta_av_sbc_ups_cb.cur_pos = dst_sps;
while (src_samples-- && dst_samples) while (src_samples-- && dst_samples) {
{
*p_worker = *p_src_tmp++; *p_worker = *p_src_tmp++;
do do {
{
*p_dst_tmp++ = *p_worker; *p_dst_tmp++ = *p_worker;
*p_dst_tmp++ = *p_worker; *p_dst_tmp++ = *p_worker;
@ -269,8 +251,9 @@ int bta_av_sbc_up_sample_16m (void *p_src, void *p_dst,
bta_av_sbc_ups_cb.cur_pos += dst_sps; bta_av_sbc_ups_cb.cur_pos += dst_sps;
} }
if (bta_av_sbc_ups_cb.cur_pos == (INT32)dst_sps) if (bta_av_sbc_ups_cb.cur_pos == (INT32)dst_sps) {
bta_av_sbc_ups_cb.cur_pos = 0; bta_av_sbc_ups_cb.cur_pos = 0;
}
*p_ret = ((char *)p_src_tmp - (char *)p_src); *p_ret = ((char *)p_src_tmp - (char *)p_src);
return ((char *)p_dst_tmp - (char *)p_dst); return ((char *)p_dst_tmp - (char *)p_dst);
@ -304,8 +287,7 @@ int bta_av_sbc_up_sample_8s (void *p_src, void *p_dst,
UINT32 src_sps = bta_av_sbc_ups_cb.src_sps; UINT32 src_sps = bta_av_sbc_ups_cb.src_sps;
UINT32 dst_sps = bta_av_sbc_ups_cb.dst_sps; UINT32 dst_sps = bta_av_sbc_ups_cb.dst_sps;
while (bta_av_sbc_ups_cb.cur_pos > 0 && dst_samples) while (bta_av_sbc_ups_cb.cur_pos > 0 && dst_samples) {
{
*p_dst_tmp++ = *p_worker1; *p_dst_tmp++ = *p_worker1;
*p_dst_tmp++ = *p_worker2; *p_dst_tmp++ = *p_worker2;
@ -316,8 +298,7 @@ int bta_av_sbc_up_sample_8s (void *p_src, void *p_dst,
bta_av_sbc_ups_cb.cur_pos = dst_sps; bta_av_sbc_ups_cb.cur_pos = dst_sps;
while (src_samples -- && dst_samples) while (src_samples -- && dst_samples) {
{
*p_worker1 = *(UINT8 *)p_src_tmp++; *p_worker1 = *(UINT8 *)p_src_tmp++;
*p_worker1 -= 0x80; *p_worker1 -= 0x80;
*p_worker1 <<= 8; *p_worker1 <<= 8;
@ -325,8 +306,7 @@ int bta_av_sbc_up_sample_8s (void *p_src, void *p_dst,
*p_worker2 -= 0x80; *p_worker2 -= 0x80;
*p_worker2 <<= 8; *p_worker2 <<= 8;
do do {
{
*p_dst_tmp++ = *p_worker1; *p_dst_tmp++ = *p_worker1;
*p_dst_tmp++ = *p_worker2; *p_dst_tmp++ = *p_worker2;
@ -338,8 +318,9 @@ int bta_av_sbc_up_sample_8s (void *p_src, void *p_dst,
bta_av_sbc_ups_cb.cur_pos += dst_sps; bta_av_sbc_ups_cb.cur_pos += dst_sps;
} }
if (bta_av_sbc_ups_cb.cur_pos == (INT32)dst_sps) if (bta_av_sbc_ups_cb.cur_pos == (INT32)dst_sps) {
bta_av_sbc_ups_cb.cur_pos = 0; bta_av_sbc_ups_cb.cur_pos = 0;
}
*p_ret = ((char *)p_src_tmp - (char *)p_src); *p_ret = ((char *)p_src_tmp - (char *)p_src);
return ((char *)p_dst_tmp - (char *)p_dst); return ((char *)p_dst_tmp - (char *)p_dst);
@ -372,8 +353,7 @@ int bta_av_sbc_up_sample_8m (void *p_src, void *p_dst,
UINT32 src_sps = bta_av_sbc_ups_cb.src_sps; UINT32 src_sps = bta_av_sbc_ups_cb.src_sps;
UINT32 dst_sps = bta_av_sbc_ups_cb.dst_sps; UINT32 dst_sps = bta_av_sbc_ups_cb.dst_sps;
while (bta_av_sbc_ups_cb.cur_pos > 0 && dst_samples) while (bta_av_sbc_ups_cb.cur_pos > 0 && dst_samples) {
{
*p_dst_tmp++ = *p_worker; *p_dst_tmp++ = *p_worker;
*p_dst_tmp++ = *p_worker; *p_dst_tmp++ = *p_worker;
@ -384,14 +364,12 @@ int bta_av_sbc_up_sample_8m (void *p_src, void *p_dst,
bta_av_sbc_ups_cb.cur_pos = dst_sps; bta_av_sbc_ups_cb.cur_pos = dst_sps;
while (src_samples-- && dst_samples) while (src_samples-- && dst_samples) {
{
*p_worker = *(UINT8 *)p_src_tmp++; *p_worker = *(UINT8 *)p_src_tmp++;
*p_worker -= 0x80; *p_worker -= 0x80;
*p_worker <<= 8; *p_worker <<= 8;
do do {
{
*p_dst_tmp++ = *p_worker; *p_dst_tmp++ = *p_worker;
*p_dst_tmp++ = *p_worker; *p_dst_tmp++ = *p_worker;
@ -403,8 +381,9 @@ int bta_av_sbc_up_sample_8m (void *p_src, void *p_dst,
bta_av_sbc_ups_cb.cur_pos += dst_sps; bta_av_sbc_ups_cb.cur_pos += dst_sps;
} }
if (bta_av_sbc_ups_cb.cur_pos == (INT32)dst_sps) if (bta_av_sbc_ups_cb.cur_pos == (INT32)dst_sps) {
bta_av_sbc_ups_cb.cur_pos = 0; bta_av_sbc_ups_cb.cur_pos = 0;
}
*p_ret = ((char *)p_src_tmp - (char *)p_src); *p_ret = ((char *)p_src_tmp - (char *)p_src);
return ((char *)p_dst_tmp - (char *)p_dst); return ((char *)p_dst_tmp - (char *)p_dst);
@ -433,80 +412,61 @@ UINT8 bta_av_sbc_cfg_for_cap(UINT8 *p_peer, tA2D_SBC_CIE *p_cap, tA2D_SBC_CIE *p
UNUSED(p_cap); UNUSED(p_cap);
/* parse peer capabilities */ /* parse peer capabilities */
if ((status = A2D_ParsSbcInfo(&peer_cie, p_peer, TRUE)) != 0) if ((status = A2D_ParsSbcInfo(&peer_cie, p_peer, TRUE)) != 0) {
{
return status; return status;
} }
/* Check if the peer supports our channel mode */ /* Check if the peer supports our channel mode */
if (peer_cie.ch_mode & p_pref->ch_mode) if (peer_cie.ch_mode & p_pref->ch_mode) {
{
peer_cie.ch_mode = p_pref->ch_mode; peer_cie.ch_mode = p_pref->ch_mode;
} } else {
else
{
APPL_TRACE_ERROR("bta_av_sbc_cfg_for_cap: ch_mode(0x%02X) not supported", p_pref->ch_mode); APPL_TRACE_ERROR("bta_av_sbc_cfg_for_cap: ch_mode(0x%02X) not supported", p_pref->ch_mode);
return A2D_FAIL; return A2D_FAIL;
} }
/* Check if the peer supports our sampling freq */ /* Check if the peer supports our sampling freq */
if (peer_cie.samp_freq & p_pref->samp_freq) if (peer_cie.samp_freq & p_pref->samp_freq) {
{
peer_cie.samp_freq = p_pref->samp_freq; peer_cie.samp_freq = p_pref->samp_freq;
} } else {
else
{
APPL_TRACE_ERROR("bta_av_sbc_cfg_for_cap: samp_freq(0x%02X) not supported", p_pref->samp_freq); APPL_TRACE_ERROR("bta_av_sbc_cfg_for_cap: samp_freq(0x%02X) not supported", p_pref->samp_freq);
return A2D_FAIL; return A2D_FAIL;
} }
/* Check if the peer supports our block len */ /* Check if the peer supports our block len */
if (peer_cie.block_len & p_pref->block_len) if (peer_cie.block_len & p_pref->block_len) {
{
peer_cie.block_len = p_pref->block_len; peer_cie.block_len = p_pref->block_len;
} } else {
else
{
APPL_TRACE_ERROR("bta_av_sbc_cfg_for_cap: block_len(0x%02X) not supported", p_pref->block_len); APPL_TRACE_ERROR("bta_av_sbc_cfg_for_cap: block_len(0x%02X) not supported", p_pref->block_len);
return A2D_FAIL; return A2D_FAIL;
} }
/* Check if the peer supports our num subbands */ /* Check if the peer supports our num subbands */
if (peer_cie.num_subbands & p_pref->num_subbands) if (peer_cie.num_subbands & p_pref->num_subbands) {
{
peer_cie.num_subbands = p_pref->num_subbands; peer_cie.num_subbands = p_pref->num_subbands;
} } else {
else
{
APPL_TRACE_ERROR("bta_av_sbc_cfg_for_cap: num_subbands(0x%02X) not supported", p_pref->num_subbands); APPL_TRACE_ERROR("bta_av_sbc_cfg_for_cap: num_subbands(0x%02X) not supported", p_pref->num_subbands);
return A2D_FAIL; return A2D_FAIL;
} }
/* Check if the peer supports our alloc method */ /* Check if the peer supports our alloc method */
if (peer_cie.alloc_mthd & p_pref->alloc_mthd) if (peer_cie.alloc_mthd & p_pref->alloc_mthd) {
{
peer_cie.alloc_mthd = p_pref->alloc_mthd; peer_cie.alloc_mthd = p_pref->alloc_mthd;
} } else {
else
{
APPL_TRACE_ERROR("bta_av_sbc_cfg_for_cap: alloc_mthd(0x%02X) not supported", p_pref->alloc_mthd); APPL_TRACE_ERROR("bta_av_sbc_cfg_for_cap: alloc_mthd(0x%02X) not supported", p_pref->alloc_mthd);
return A2D_FAIL; return A2D_FAIL;
} }
/* max bitpool */ /* max bitpool */
if (p_pref->max_bitpool != 0 && p_pref->max_bitpool < peer_cie.max_bitpool) if (p_pref->max_bitpool != 0 && p_pref->max_bitpool < peer_cie.max_bitpool) {
{
peer_cie.max_bitpool = p_pref->max_bitpool; peer_cie.max_bitpool = p_pref->max_bitpool;
} }
/* min bitpool */ /* min bitpool */
if (p_pref->min_bitpool != 0 && p_pref->min_bitpool > peer_cie.min_bitpool) if (p_pref->min_bitpool != 0 && p_pref->min_bitpool > peer_cie.min_bitpool) {
{
peer_cie.min_bitpool = p_pref->min_bitpool; peer_cie.min_bitpool = p_pref->min_bitpool;
} }
if (status == A2D_SUCCESS) if (status == A2D_SUCCESS) {
{
/* build configuration */ /* build configuration */
A2D_BldSbcInfo(A2D_MEDIA_TYPE_AUDIO, &peer_cie, p_peer); A2D_BldSbcInfo(A2D_MEDIA_TYPE_AUDIO, &peer_cie, p_peer);
} }
@ -529,8 +489,7 @@ UINT8 bta_av_sbc_cfg_matches_cap(UINT8 *p_cfg, tA2D_SBC_CIE *p_cap)
tA2D_SBC_CIE cfg_cie; tA2D_SBC_CIE cfg_cie;
/* parse configuration */ /* parse configuration */
if ((status = A2D_ParsSbcInfo(&cfg_cie, p_cfg, TRUE)) != 0) if ((status = A2D_ParsSbcInfo(&cfg_cie, p_cfg, TRUE)) != 0) {
{
APPL_TRACE_ERROR(" bta_av_sbc_cfg_matches_cap Parsing Failed %d", status); APPL_TRACE_ERROR(" bta_av_sbc_cfg_matches_cap Parsing Failed %d", status);
return status; return status;
} }
@ -546,38 +505,31 @@ UINT8 bta_av_sbc_cfg_matches_cap(UINT8 *p_cfg, tA2D_SBC_CIE *p_cap)
APPL_TRACE_DEBUG(" Min_bitpool peer: 0%x, capability 0%x", cfg_cie.min_bitpool, p_cap->min_bitpool); APPL_TRACE_DEBUG(" Min_bitpool peer: 0%x, capability 0%x", cfg_cie.min_bitpool, p_cap->min_bitpool);
/* sampling frequency */ /* sampling frequency */
if ((cfg_cie.samp_freq & p_cap->samp_freq) == 0) if ((cfg_cie.samp_freq & p_cap->samp_freq) == 0) {
{
status = A2D_NS_SAMP_FREQ; status = A2D_NS_SAMP_FREQ;
} }
/* channel mode */ /* channel mode */
else if ((cfg_cie.ch_mode & p_cap->ch_mode) == 0) else if ((cfg_cie.ch_mode & p_cap->ch_mode) == 0) {
{
status = A2D_NS_CH_MODE; status = A2D_NS_CH_MODE;
} }
/* block length */ /* block length */
else if ((cfg_cie.block_len & p_cap->block_len) == 0) else if ((cfg_cie.block_len & p_cap->block_len) == 0) {
{
status = A2D_BAD_BLOCK_LEN; status = A2D_BAD_BLOCK_LEN;
} }
/* subbands */ /* subbands */
else if ((cfg_cie.num_subbands & p_cap->num_subbands) == 0) else if ((cfg_cie.num_subbands & p_cap->num_subbands) == 0) {
{
status = A2D_NS_SUBBANDS; status = A2D_NS_SUBBANDS;
} }
/* allocation method */ /* allocation method */
else if ((cfg_cie.alloc_mthd & p_cap->alloc_mthd) == 0) else if ((cfg_cie.alloc_mthd & p_cap->alloc_mthd) == 0) {
{
status = A2D_NS_ALLOC_MTHD; status = A2D_NS_ALLOC_MTHD;
} }
/* max bitpool */ /* max bitpool */
else if (cfg_cie.max_bitpool > p_cap->max_bitpool) else if (cfg_cie.max_bitpool > p_cap->max_bitpool) {
{
status = A2D_NS_MAX_BITPOOL; status = A2D_NS_MAX_BITPOOL;
} }
/* min bitpool */ /* min bitpool */
else if (cfg_cie.min_bitpool < p_cap->min_bitpool) else if (cfg_cie.min_bitpool < p_cap->min_bitpool) {
{
status = A2D_NS_MIN_BITPOOL; status = A2D_NS_MIN_BITPOOL;
} }
@ -601,8 +553,7 @@ UINT8 bta_av_sbc_cfg_in_cap(UINT8 *p_cfg, tA2D_SBC_CIE *p_cap)
tA2D_SBC_CIE cfg_cie; tA2D_SBC_CIE cfg_cie;
/* parse configuration */ /* parse configuration */
if ((status = A2D_ParsSbcInfo(&cfg_cie, p_cfg, FALSE)) != 0) if ((status = A2D_ParsSbcInfo(&cfg_cie, p_cfg, FALSE)) != 0) {
{
return status; return status;
} }
@ -610,38 +561,31 @@ UINT8 bta_av_sbc_cfg_in_cap(UINT8 *p_cfg, tA2D_SBC_CIE *p_cap)
/* sampling frequency */ /* sampling frequency */
if ((cfg_cie.samp_freq & p_cap->samp_freq) == 0) if ((cfg_cie.samp_freq & p_cap->samp_freq) == 0) {
{
status = A2D_NS_SAMP_FREQ; status = A2D_NS_SAMP_FREQ;
} }
/* channel mode */ /* channel mode */
else if ((cfg_cie.ch_mode & p_cap->ch_mode) == 0) else if ((cfg_cie.ch_mode & p_cap->ch_mode) == 0) {
{
status = A2D_NS_CH_MODE; status = A2D_NS_CH_MODE;
} }
/* block length */ /* block length */
else if ((cfg_cie.block_len & p_cap->block_len) == 0) else if ((cfg_cie.block_len & p_cap->block_len) == 0) {
{
status = A2D_BAD_BLOCK_LEN; status = A2D_BAD_BLOCK_LEN;
} }
/* subbands */ /* subbands */
else if ((cfg_cie.num_subbands & p_cap->num_subbands) == 0) else if ((cfg_cie.num_subbands & p_cap->num_subbands) == 0) {
{
status = A2D_NS_SUBBANDS; status = A2D_NS_SUBBANDS;
} }
/* allocation method */ /* allocation method */
else if ((cfg_cie.alloc_mthd & p_cap->alloc_mthd) == 0) else if ((cfg_cie.alloc_mthd & p_cap->alloc_mthd) == 0) {
{
status = A2D_NS_ALLOC_MTHD; status = A2D_NS_ALLOC_MTHD;
} }
/* max bitpool */ /* max bitpool */
else if (cfg_cie.max_bitpool > p_cap->max_bitpool) else if (cfg_cie.max_bitpool > p_cap->max_bitpool) {
{
status = A2D_NS_MAX_BITPOOL; status = A2D_NS_MAX_BITPOOL;
} }
/* min bitpool */ /* min bitpool */
else if (cfg_cie.min_bitpool < p_cap->min_bitpool) else if (cfg_cie.min_bitpool < p_cap->min_bitpool) {
{
status = A2D_NS_MIN_BITPOOL; status = A2D_NS_MIN_BITPOOL;
} }

85
components/bt/bluedroid/bta/av/bta_av_ssm.c Executable file → Normal file
View file

@ -34,8 +34,7 @@
*****************************************************************************/ *****************************************************************************/
/* state machine states */ /* state machine states */
enum enum {
{
BTA_AV_INIT_SST, BTA_AV_INIT_SST,
BTA_AV_INCOMING_SST, BTA_AV_INCOMING_SST,
BTA_AV_OPENING_SST, BTA_AV_OPENING_SST,
@ -46,8 +45,7 @@ enum
/* state machine action enumeration list */ /* state machine action enumeration list */
enum enum {
{
BTA_AV_DO_DISC, BTA_AV_DO_DISC,
BTA_AV_CLEANUP, BTA_AV_CLEANUP,
BTA_AV_FREE_SDB, BTA_AV_FREE_SDB,
@ -109,8 +107,7 @@ enum
#define BTA_AV_NUM_COLS 3 /* number of columns in state tables */ #define BTA_AV_NUM_COLS 3 /* number of columns in state tables */
/* state table for init state */ /* state table for init state */
static const UINT8 bta_av_sst_init[][BTA_AV_NUM_COLS] = static const UINT8 bta_av_sst_init[][BTA_AV_NUM_COLS] = {
{
/* Event Action 1 Action 2 Next state */ /* Event Action 1 Action 2 Next state */
/* AP_OPEN_EVT */ {BTA_AV_DO_DISC, BTA_AV_SIGNORE, BTA_AV_OPENING_SST }, /* AP_OPEN_EVT */ {BTA_AV_DO_DISC, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
/* AP_CLOSE_EVT */ {BTA_AV_CLEANUP, BTA_AV_SIGNORE, BTA_AV_INIT_SST }, /* AP_CLOSE_EVT */ {BTA_AV_CLEANUP, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
@ -149,8 +146,7 @@ static const UINT8 bta_av_sst_init[][BTA_AV_NUM_COLS] =
}; };
/* state table for incoming state */ /* state table for incoming state */
static const UINT8 bta_av_sst_incoming[][BTA_AV_NUM_COLS] = static const UINT8 bta_av_sst_incoming[][BTA_AV_NUM_COLS] = {
{
/* Event Action 1 Action 2 Next state */ /* Event Action 1 Action 2 Next state */
/* AP_OPEN_EVT */ {BTA_AV_OPEN_AT_INC, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST }, /* AP_OPEN_EVT */ {BTA_AV_OPEN_AT_INC, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
/* AP_CLOSE_EVT */ {BTA_AV_CCO_CLOSE, BTA_AV_DISCONNECT_REQ, BTA_AV_CLOSING_SST }, /* AP_CLOSE_EVT */ {BTA_AV_CCO_CLOSE, BTA_AV_DISCONNECT_REQ, BTA_AV_CLOSING_SST },
@ -189,8 +185,7 @@ static const UINT8 bta_av_sst_incoming[][BTA_AV_NUM_COLS] =
}; };
/* state table for opening state */ /* state table for opening state */
static const UINT8 bta_av_sst_opening[][BTA_AV_NUM_COLS] = static const UINT8 bta_av_sst_opening[][BTA_AV_NUM_COLS] = {
{
/* Event Action 1 Action 2 Next state */ /* Event Action 1 Action 2 Next state */
/* AP_OPEN_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST }, /* AP_OPEN_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
/* AP_CLOSE_EVT */ {BTA_AV_DO_CLOSE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST }, /* AP_CLOSE_EVT */ {BTA_AV_DO_CLOSE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
@ -229,8 +224,7 @@ static const UINT8 bta_av_sst_opening[][BTA_AV_NUM_COLS] =
}; };
/* state table for open state */ /* state table for open state */
static const UINT8 bta_av_sst_open[][BTA_AV_NUM_COLS] = static const UINT8 bta_av_sst_open[][BTA_AV_NUM_COLS] = {
{
/* Event Action 1 Action 2 Next state */ /* Event Action 1 Action 2 Next state */
/* AP_OPEN_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPEN_SST }, /* AP_OPEN_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
/* AP_CLOSE_EVT */ {BTA_AV_DO_CLOSE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST }, /* AP_CLOSE_EVT */ {BTA_AV_DO_CLOSE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
@ -269,8 +263,7 @@ static const UINT8 bta_av_sst_open[][BTA_AV_NUM_COLS] =
}; };
/* state table for reconfig state */ /* state table for reconfig state */
static const UINT8 bta_av_sst_rcfg[][BTA_AV_NUM_COLS] = static const UINT8 bta_av_sst_rcfg[][BTA_AV_NUM_COLS] = {
{
/* Event Action 1 Action 2 Next state */ /* Event Action 1 Action 2 Next state */
/* AP_OPEN_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST }, /* AP_OPEN_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
/* AP_CLOSE_EVT */ {BTA_AV_DISCONNECT_REQ, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST }, /* AP_CLOSE_EVT */ {BTA_AV_DISCONNECT_REQ, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
@ -309,8 +302,7 @@ static const UINT8 bta_av_sst_rcfg[][BTA_AV_NUM_COLS] =
}; };
/* state table for closing state */ /* state table for closing state */
static const UINT8 bta_av_sst_closing[][BTA_AV_NUM_COLS] = static const UINT8 bta_av_sst_closing[][BTA_AV_NUM_COLS] = {
{
/* Event Action 1 Action 2 Next state */ /* Event Action 1 Action 2 Next state */
/* AP_OPEN_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST }, /* AP_OPEN_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
/* AP_CLOSE_EVT */ {BTA_AV_DISCONNECT_REQ, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST }, /* AP_CLOSE_EVT */ {BTA_AV_DISCONNECT_REQ, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
@ -352,8 +344,7 @@ static const UINT8 bta_av_sst_closing[][BTA_AV_NUM_COLS] =
typedef const UINT8 (*tBTA_AV_SST_TBL)[BTA_AV_NUM_COLS]; typedef const UINT8 (*tBTA_AV_SST_TBL)[BTA_AV_NUM_COLS];
/* state table */ /* state table */
static const tBTA_AV_SST_TBL bta_av_sst_tbl[] = static const tBTA_AV_SST_TBL bta_av_sst_tbl[] = {
{
bta_av_sst_init, bta_av_sst_init,
bta_av_sst_incoming, bta_av_sst_incoming,
bta_av_sst_opening, bta_av_sst_opening,
@ -382,11 +373,11 @@ BOOLEAN bta_av_is_rcfg_sst (tBTA_AV_SCB *p_scb)
{ {
BOOLEAN is_rcfg_sst = FALSE; BOOLEAN is_rcfg_sst = FALSE;
if (p_scb != NULL) if (p_scb != NULL) {
{ if (p_scb->state == BTA_AV_RCFG_SST) {
if (p_scb->state == BTA_AV_RCFG_SST)
is_rcfg_sst = TRUE; is_rcfg_sst = TRUE;
} }
}
return is_rcfg_sst; return is_rcfg_sst;
} }
@ -407,8 +398,7 @@ void bta_av_ssm_execute(tBTA_AV_SCB *p_scb, UINT16 event, tBTA_AV_DATA *p_data)
UINT8 action; UINT8 action;
int i, xx; int i, xx;
if(p_scb == NULL) if (p_scb == NULL) {
{
/* this stream is not registered */ /* this stream is not registered */
APPL_TRACE_EVENT("AV channel not registered"); APPL_TRACE_EVENT("AV channel not registered");
return; return;
@ -418,14 +408,10 @@ void bta_av_ssm_execute(tBTA_AV_SCB *p_scb, UINT16 event, tBTA_AV_DATA *p_data)
/* When ACP_CONNECT_EVT was received, we put first available scb to */ /* When ACP_CONNECT_EVT was received, we put first available scb to */
/* to Incoming state. Later, when STR_CONFIG_IND_EVT is coming, we */ /* to Incoming state. Later, when STR_CONFIG_IND_EVT is coming, we */
/* know if it is A2DP or VDP. */ /* know if it is A2DP or VDP. */
if ((p_scb->state == BTA_AV_INIT_SST) && (event == BTA_AV_STR_CONFIG_IND_EVT)) if ((p_scb->state == BTA_AV_INIT_SST) && (event == BTA_AV_STR_CONFIG_IND_EVT)) {
{ for (xx = 0; xx < BTA_AV_NUM_STRS; xx++) {
for (xx = 0; xx < BTA_AV_NUM_STRS; xx++) if (bta_av_cb.p_scb[xx]) {
{ if (bta_av_cb.p_scb[xx]->state == BTA_AV_INCOMING_SST) {
if (bta_av_cb.p_scb[xx])
{
if (bta_av_cb.p_scb[xx]->state == BTA_AV_INCOMING_SST)
{
bta_av_cb.p_scb[xx]->state = BTA_AV_INIT_SST; bta_av_cb.p_scb[xx]->state = BTA_AV_INIT_SST;
bta_av_cb.p_scb[xx]->coll_mask = 0; bta_av_cb.p_scb[xx]->coll_mask = 0;
p_scb->state = BTA_AV_INCOMING_SST; p_scb->state = BTA_AV_INCOMING_SST;
@ -451,15 +437,13 @@ void bta_av_ssm_execute(tBTA_AV_SCB *p_scb, UINT16 event, tBTA_AV_DATA *p_data)
p_scb->state = state_table[event][BTA_AV_SNEXT_STATE]; p_scb->state = state_table[event][BTA_AV_SNEXT_STATE];
/* execute action functions */ /* execute action functions */
for(i=0; i< BTA_AV_SACTIONS; i++) for (i = 0; i < BTA_AV_SACTIONS; i++) {
{ if ((action = state_table[event][i]) != BTA_AV_SIGNORE) {
if ((action = state_table[event][i]) != BTA_AV_SIGNORE)
{
(*p_scb->p_act_tbl[action])(p_scb, p_data); (*p_scb->p_act_tbl[action])(p_scb, p_data);
} } else {
else
break; break;
} }
}
} }
@ -477,11 +461,11 @@ BOOLEAN bta_av_is_scb_opening (tBTA_AV_SCB *p_scb)
{ {
BOOLEAN is_opening = FALSE; BOOLEAN is_opening = FALSE;
if (p_scb) if (p_scb) {
{ if (p_scb->state == BTA_AV_OPENING_SST) {
if (p_scb->state == BTA_AV_OPENING_SST)
is_opening = TRUE; is_opening = TRUE;
} }
}
return is_opening; return is_opening;
} }
@ -500,11 +484,11 @@ BOOLEAN bta_av_is_scb_incoming (tBTA_AV_SCB *p_scb)
{ {
BOOLEAN is_incoming = FALSE; BOOLEAN is_incoming = FALSE;
if (p_scb) if (p_scb) {
{ if (p_scb->state == BTA_AV_INCOMING_SST) {
if (p_scb->state == BTA_AV_INCOMING_SST)
is_incoming = TRUE; is_incoming = TRUE;
} }
}
return is_incoming; return is_incoming;
} }
@ -521,8 +505,7 @@ BOOLEAN bta_av_is_scb_incoming (tBTA_AV_SCB *p_scb)
*******************************************************************************/ *******************************************************************************/
void bta_av_set_scb_sst_init (tBTA_AV_SCB *p_scb) void bta_av_set_scb_sst_init (tBTA_AV_SCB *p_scb)
{ {
if (p_scb) if (p_scb) {
{
p_scb->state = BTA_AV_INIT_SST; p_scb->state = BTA_AV_INIT_SST;
} }
} }
@ -541,11 +524,11 @@ BOOLEAN bta_av_is_scb_init (tBTA_AV_SCB *p_scb)
{ {
BOOLEAN is_init = FALSE; BOOLEAN is_init = FALSE;
if (p_scb) if (p_scb) {
{ if (p_scb->state == BTA_AV_INIT_SST) {
if (p_scb->state == BTA_AV_INIT_SST)
is_init = TRUE; is_init = TRUE;
} }
}
return is_init; return is_init;
} }
@ -562,8 +545,7 @@ BOOLEAN bta_av_is_scb_init (tBTA_AV_SCB *p_scb)
*******************************************************************************/ *******************************************************************************/
void bta_av_set_scb_sst_incoming (tBTA_AV_SCB *p_scb) void bta_av_set_scb_sst_incoming (tBTA_AV_SCB *p_scb)
{ {
if (p_scb) if (p_scb) {
{
p_scb->state = BTA_AV_INCOMING_SST; p_scb->state = BTA_AV_INCOMING_SST;
} }
} }
@ -583,8 +565,7 @@ void bta_av_set_scb_sst_incoming (tBTA_AV_SCB *p_scb)
*******************************************************************************/ *******************************************************************************/
static char *bta_av_sst_code(UINT8 state) static char *bta_av_sst_code(UINT8 state)
{ {
switch(state) switch (state) {
{
case BTA_AV_INIT_SST: return "INIT"; case BTA_AV_INIT_SST: return "INIT";
case BTA_AV_INCOMING_SST: return "INCOMING"; case BTA_AV_INCOMING_SST: return "INCOMING";
case BTA_AV_OPENING_SST: return "OPENING"; case BTA_AV_OPENING_SST: return "OPENING";

0
components/bt/bluedroid/bta/include/bta_ar_api.h Executable file → Normal file
View file

66
components/bt/bluedroid/bta/include/bta_av_api.h Executable file → Normal file
View file

@ -278,8 +278,7 @@ typedef void * (*tBTA_AV_CO_DATAPATH) (tBTA_AV_CODEC codec_type,
typedef void (*tBTA_AV_CO_DELAY) (tBTA_AV_HNDL hndl, UINT16 delay); typedef void (*tBTA_AV_CO_DELAY) (tBTA_AV_HNDL hndl, UINT16 delay);
/* the call-out functions for one stream */ /* the call-out functions for one stream */
typedef struct typedef struct {
{
tBTA_AV_CO_INIT init; tBTA_AV_CO_INIT init;
tBTA_AV_CO_DISC_RES disc_res; tBTA_AV_CO_DISC_RES disc_res;
tBTA_AV_CO_GETCFG getcfg; tBTA_AV_CO_GETCFG getcfg;
@ -295,14 +294,12 @@ typedef struct
typedef UINT8 tBTA_AV_EVT; typedef UINT8 tBTA_AV_EVT;
/* Event associated with BTA_AV_ENABLE_EVT */ /* Event associated with BTA_AV_ENABLE_EVT */
typedef struct typedef struct {
{
tBTA_AV_FEAT features; tBTA_AV_FEAT features;
} tBTA_AV_ENABLE; } tBTA_AV_ENABLE;
/* Event associated with BTA_AV_REGISTER_EVT */ /* Event associated with BTA_AV_REGISTER_EVT */
typedef struct typedef struct {
{
tBTA_AV_CHNL chnl; /* audio/video */ tBTA_AV_CHNL chnl; /* audio/video */
tBTA_AV_HNDL hndl; /* Handle associated with the stream. */ tBTA_AV_HNDL hndl; /* Handle associated with the stream. */
UINT8 app_id; /* ID associated with call to BTA_AvRegister() */ UINT8 app_id; /* ID associated with call to BTA_AvRegister() */
@ -315,8 +312,7 @@ typedef struct
#define BTA_AV_EDR_3MBPS 0x02 #define BTA_AV_EDR_3MBPS 0x02
typedef UINT8 tBTA_AV_EDR; typedef UINT8 tBTA_AV_EDR;
typedef struct typedef struct {
{
tBTA_AV_CHNL chnl; tBTA_AV_CHNL chnl;
tBTA_AV_HNDL hndl; tBTA_AV_HNDL hndl;
BD_ADDR bd_addr; BD_ADDR bd_addr;
@ -327,16 +323,14 @@ typedef struct
} tBTA_AV_OPEN; } tBTA_AV_OPEN;
/* data associated with BTA_AV_CLOSE_EVT */ /* data associated with BTA_AV_CLOSE_EVT */
typedef struct typedef struct {
{
tBTA_AV_CHNL chnl; tBTA_AV_CHNL chnl;
tBTA_AV_HNDL hndl; tBTA_AV_HNDL hndl;
UINT8 disc_rsn; /* disconnection reason */ UINT8 disc_rsn; /* disconnection reason */
} tBTA_AV_CLOSE; } tBTA_AV_CLOSE;
/* data associated with BTA_AV_START_EVT */ /* data associated with BTA_AV_START_EVT */
typedef struct typedef struct {
{
tBTA_AV_CHNL chnl; tBTA_AV_CHNL chnl;
tBTA_AV_HNDL hndl; tBTA_AV_HNDL hndl;
tBTA_AV_STATUS status; tBTA_AV_STATUS status;
@ -345,8 +339,7 @@ typedef struct
} tBTA_AV_START; } tBTA_AV_START;
/* data associated with BTA_AV_SUSPEND_EVT */ /* data associated with BTA_AV_SUSPEND_EVT */
typedef struct typedef struct {
{
tBTA_AV_CHNL chnl; tBTA_AV_CHNL chnl;
tBTA_AV_HNDL hndl; tBTA_AV_HNDL hndl;
BOOLEAN initiator; /* TRUE, if local device initiates the SUSPEND */ BOOLEAN initiator; /* TRUE, if local device initiates the SUSPEND */
@ -354,16 +347,14 @@ typedef struct
} tBTA_AV_SUSPEND; } tBTA_AV_SUSPEND;
/* data associated with BTA_AV_RECONFIG_EVT */ /* data associated with BTA_AV_RECONFIG_EVT */
typedef struct typedef struct {
{
tBTA_AV_CHNL chnl; tBTA_AV_CHNL chnl;
tBTA_AV_HNDL hndl; tBTA_AV_HNDL hndl;
tBTA_AV_STATUS status; tBTA_AV_STATUS status;
} tBTA_AV_RECONFIG; } tBTA_AV_RECONFIG;
/* data associated with BTA_AV_PROTECT_REQ_EVT */ /* data associated with BTA_AV_PROTECT_REQ_EVT */
typedef struct typedef struct {
{
tBTA_AV_CHNL chnl; tBTA_AV_CHNL chnl;
tBTA_AV_HNDL hndl; tBTA_AV_HNDL hndl;
UINT8 *p_data; UINT8 *p_data;
@ -371,8 +362,7 @@ typedef struct
} tBTA_AV_PROTECT_REQ; } tBTA_AV_PROTECT_REQ;
/* data associated with BTA_AV_PROTECT_RSP_EVT */ /* data associated with BTA_AV_PROTECT_RSP_EVT */
typedef struct typedef struct {
{
tBTA_AV_CHNL chnl; tBTA_AV_CHNL chnl;
tBTA_AV_HNDL hndl; tBTA_AV_HNDL hndl;
UINT8 *p_data; UINT8 *p_data;
@ -381,8 +371,7 @@ typedef struct
} tBTA_AV_PROTECT_RSP; } tBTA_AV_PROTECT_RSP;
/* data associated with BTA_AV_RC_OPEN_EVT */ /* data associated with BTA_AV_RC_OPEN_EVT */
typedef struct typedef struct {
{
UINT8 rc_handle; UINT8 rc_handle;
tBTA_AV_FEAT peer_features; tBTA_AV_FEAT peer_features;
BD_ADDR peer_addr; BD_ADDR peer_addr;
@ -390,22 +379,19 @@ typedef struct
} tBTA_AV_RC_OPEN; } tBTA_AV_RC_OPEN;
/* data associated with BTA_AV_RC_CLOSE_EVT */ /* data associated with BTA_AV_RC_CLOSE_EVT */
typedef struct typedef struct {
{
UINT8 rc_handle; UINT8 rc_handle;
BD_ADDR peer_addr; BD_ADDR peer_addr;
} tBTA_AV_RC_CLOSE; } tBTA_AV_RC_CLOSE;
/* data associated with BTA_AV_RC_FEAT_EVT */ /* data associated with BTA_AV_RC_FEAT_EVT */
typedef struct typedef struct {
{
UINT8 rc_handle; UINT8 rc_handle;
tBTA_AV_FEAT peer_features; tBTA_AV_FEAT peer_features;
} tBTA_AV_RC_FEAT; } tBTA_AV_RC_FEAT;
/* data associated with BTA_AV_REMOTE_CMD_EVT */ /* data associated with BTA_AV_REMOTE_CMD_EVT */
typedef struct typedef struct {
{
UINT8 rc_handle; UINT8 rc_handle;
tBTA_AV_RC rc_id; tBTA_AV_RC rc_id;
tBTA_AV_STATE key_state; tBTA_AV_STATE key_state;
@ -416,8 +402,7 @@ typedef struct
} tBTA_AV_REMOTE_CMD; } tBTA_AV_REMOTE_CMD;
/* data associated with BTA_AV_REMOTE_RSP_EVT */ /* data associated with BTA_AV_REMOTE_RSP_EVT */
typedef struct typedef struct {
{
UINT8 rc_handle; UINT8 rc_handle;
tBTA_AV_RC rc_id; tBTA_AV_RC rc_id;
tBTA_AV_STATE key_state; tBTA_AV_STATE key_state;
@ -428,8 +413,7 @@ typedef struct
} tBTA_AV_REMOTE_RSP; } tBTA_AV_REMOTE_RSP;
/* data associated with BTA_AV_VENDOR_CMD_EVT, BTA_AV_VENDOR_RSP_EVT */ /* data associated with BTA_AV_VENDOR_CMD_EVT, BTA_AV_VENDOR_RSP_EVT */
typedef struct typedef struct {
{
UINT8 rc_handle; UINT8 rc_handle;
UINT16 len; /* Max vendor dependent message is 512 */ UINT16 len; /* Max vendor dependent message is 512 */
UINT8 label; UINT8 label;
@ -439,8 +423,7 @@ typedef struct
} tBTA_AV_VENDOR; } tBTA_AV_VENDOR;
/* data associated with BTA_AV_META_MSG_EVT */ /* data associated with BTA_AV_META_MSG_EVT */
typedef struct typedef struct {
{
UINT8 rc_handle; UINT8 rc_handle;
UINT16 len; UINT16 len;
UINT8 label; UINT8 label;
@ -451,22 +434,19 @@ typedef struct
} tBTA_AV_META_MSG; } tBTA_AV_META_MSG;
/* data associated with BTA_AV_PENDING_EVT */ /* data associated with BTA_AV_PENDING_EVT */
typedef struct typedef struct {
{
BD_ADDR bd_addr; BD_ADDR bd_addr;
} tBTA_AV_PEND; } tBTA_AV_PEND;
/* data associated with BTA_AV_REJECT_EVT */ /* data associated with BTA_AV_REJECT_EVT */
typedef struct typedef struct {
{
BD_ADDR bd_addr; BD_ADDR bd_addr;
tBTA_AV_HNDL hndl; /* Handle associated with the stream that rejected the connection. */ tBTA_AV_HNDL hndl; /* Handle associated with the stream that rejected the connection. */
} tBTA_AV_REJECT; } tBTA_AV_REJECT;
/* union of data associated with AV callback */ /* union of data associated with AV callback */
typedef union typedef union {
{
tBTA_AV_CHNL chnl; tBTA_AV_CHNL chnl;
tBTA_AV_ENABLE enable; tBTA_AV_ENABLE enable;
tBTA_AV_REGISTER registr; tBTA_AV_REGISTER registr;
@ -490,8 +470,7 @@ typedef union
} tBTA_AV; } tBTA_AV;
/* union of data associated with AV Media callback */ /* union of data associated with AV Media callback */
typedef union typedef union {
{
BT_HDR *p_data; BT_HDR *p_data;
UINT8 *codec_info; UINT8 *codec_info;
} tBTA_AV_MEDIA; } tBTA_AV_MEDIA;
@ -523,8 +502,7 @@ typedef void (*tBTA_AV_ACT)(void *p_cb, void *p_data);
typedef void (tBTA_AV_REG) (tAVDT_CS *p_cs, char *p_service_name, void *p_data); typedef void (tBTA_AV_REG) (tAVDT_CS *p_cs, char *p_service_name, void *p_data);
/* AV configuration structure */ /* AV configuration structure */
typedef struct typedef struct {
{
UINT32 company_id; /* AVRCP Company ID */ UINT32 company_id; /* AVRCP Company ID */
UINT16 avrc_mtu; /* AVRCP MTU at L2CAP for control channel */ UINT16 avrc_mtu; /* AVRCP MTU at L2CAP for control channel */
UINT16 avrc_br_mtu; /* AVRCP MTU at L2CAP for browsing channel */ UINT16 avrc_br_mtu; /* AVRCP MTU at L2CAP for browsing channel */

0
components/bt/bluedroid/bta/include/bta_av_ci.h Executable file → Normal file
View file

6
components/bt/bluedroid/bta/include/bta_av_co.h Executable file → Normal file
View file

@ -50,8 +50,7 @@
#define BTA_AV_CO_DEFAULT_AUDIO_OFFSET AVDT_MEDIA_OFFSET #define BTA_AV_CO_DEFAULT_AUDIO_OFFSET AVDT_MEDIA_OFFSET
enum enum {
{
BTA_AV_CO_ST_INIT, BTA_AV_CO_ST_INIT,
BTA_AV_CO_ST_IN, BTA_AV_CO_ST_IN,
BTA_AV_CO_ST_OUT, BTA_AV_CO_ST_OUT,
@ -61,8 +60,7 @@ enum
/* data type for the Audio Codec Information*/ /* data type for the Audio Codec Information*/
typedef struct typedef struct {
{
UINT16 bit_rate; /* SBC encoder bit rate in kbps */ UINT16 bit_rate; /* SBC encoder bit rate in kbps */
UINT16 bit_rate_busy; /* SBC encoder bit rate in kbps */ UINT16 bit_rate_busy; /* SBC encoder bit rate in kbps */
UINT16 bit_rate_swampd;/* SBC encoder bit rate in kbps */ UINT16 bit_rate_swampd;/* SBC encoder bit rate in kbps */

0
components/bt/bluedroid/bta/include/bta_av_sbc.h Executable file → Normal file
View file

View file

@ -120,8 +120,7 @@ static void btc_dm_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl)
p_auth_cmpl->key_present, p_auth_cmpl->key_type); p_auth_cmpl->key_present, p_auth_cmpl->key_type);
bdcpy(bd_addr.address, p_auth_cmpl->bd_addr); bdcpy(bd_addr.address, p_auth_cmpl->bd_addr);
if ( (p_auth_cmpl->success == TRUE) && (p_auth_cmpl->key_present) ) if ( (p_auth_cmpl->success == TRUE) && (p_auth_cmpl->key_present) ) {
{
#if 0 #if 0
if ((p_auth_cmpl->key_type < HCI_LKEY_TYPE_DEBUG_COMB) || if ((p_auth_cmpl->key_type < HCI_LKEY_TYPE_DEBUG_COMB) ||
(p_auth_cmpl->key_type == HCI_LKEY_TYPE_AUTH_COMB) || (p_auth_cmpl->key_type == HCI_LKEY_TYPE_AUTH_COMB) ||
@ -129,8 +128,7 @@ static void btc_dm_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl)
(p_auth_cmpl->key_type == HCI_LKEY_TYPE_AUTH_COMB_P_256) (p_auth_cmpl->key_type == HCI_LKEY_TYPE_AUTH_COMB_P_256)
) )
#endif #endif
if (1) if (1) {
{
bt_status_t ret; bt_status_t ret;
LOG_DEBUG("%s: Storing link key. key_type=0x%x", LOG_DEBUG("%s: Storing link key. key_type=0x%x",
__FUNCTION__, p_auth_cmpl->key_type); __FUNCTION__, p_auth_cmpl->key_type);
@ -138,23 +136,17 @@ static void btc_dm_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl)
p_auth_cmpl->key, p_auth_cmpl->key_type, p_auth_cmpl->key, p_auth_cmpl->key_type,
16); 16);
BTC_ASSERTC(ret == BT_STATUS_SUCCESS, "storing link key failed", ret); BTC_ASSERTC(ret == BT_STATUS_SUCCESS, "storing link key failed", ret);
} } else {
else
{
LOG_DEBUG("%s: Temporary key. Not storing. key_type=0x%x", LOG_DEBUG("%s: Temporary key. Not storing. key_type=0x%x",
__FUNCTION__, p_auth_cmpl->key_type); __FUNCTION__, p_auth_cmpl->key_type);
} }
} }
// Skip SDP for certain HID Devices // Skip SDP for certain HID Devices
if (p_auth_cmpl->success) if (p_auth_cmpl->success) {
{ } else {
}
else
{
// Map the HCI fail reason to bt status // Map the HCI fail reason to bt status
switch(p_auth_cmpl->fail_reason) switch (p_auth_cmpl->fail_reason) {
{
case HCI_ERR_PAGE_TIMEOUT: case HCI_ERR_PAGE_TIMEOUT:
LOG_WARN("%s() - Pairing timeout; retrying () ...", __FUNCTION__); LOG_WARN("%s() - Pairing timeout; retrying () ...", __FUNCTION__);
return; return;

62
components/bt/bluedroid/stack/a2dp/a2d_api.c Executable file → Normal file
View file

@ -63,45 +63,38 @@ static void a2d_sdp_cback(UINT16 status)
A2D_TRACE_API("a2d_sdp_cback status: %d", status); A2D_TRACE_API("a2d_sdp_cback status: %d", status);
if (status == SDP_SUCCESS) if (status == SDP_SUCCESS) {
{
/* loop through all records we found */ /* loop through all records we found */
do do {
{
/* get next record; if none found, we're done */ /* get next record; if none found, we're done */
if ((p_rec = SDP_FindServiceInDb(a2d_cb.find.p_db, if ((p_rec = SDP_FindServiceInDb(a2d_cb.find.p_db,
a2d_cb.find.service_uuid, p_rec)) == NULL) a2d_cb.find.service_uuid, p_rec)) == NULL) {
{
break; break;
} }
memset(&a2d_svc, 0, sizeof(tA2D_Service)); memset(&a2d_svc, 0, sizeof(tA2D_Service));
/* get service name */ /* get service name */
if ((p_attr = SDP_FindAttributeInRec(p_rec, if ((p_attr = SDP_FindAttributeInRec(p_rec,
ATTR_ID_SERVICE_NAME)) != NULL) ATTR_ID_SERVICE_NAME)) != NULL) {
{
a2d_svc.p_service_name = (char *) p_attr->attr_value.v.array; a2d_svc.p_service_name = (char *) p_attr->attr_value.v.array;
a2d_svc.service_len = SDP_DISC_ATTR_LEN(p_attr->attr_len_type); a2d_svc.service_len = SDP_DISC_ATTR_LEN(p_attr->attr_len_type);
} }
/* get provider name */ /* get provider name */
if ((p_attr = SDP_FindAttributeInRec(p_rec, if ((p_attr = SDP_FindAttributeInRec(p_rec,
ATTR_ID_PROVIDER_NAME)) != NULL) ATTR_ID_PROVIDER_NAME)) != NULL) {
{
a2d_svc.p_provider_name = (char *) p_attr->attr_value.v.array; a2d_svc.p_provider_name = (char *) p_attr->attr_value.v.array;
a2d_svc.provider_len = SDP_DISC_ATTR_LEN(p_attr->attr_len_type); a2d_svc.provider_len = SDP_DISC_ATTR_LEN(p_attr->attr_len_type);
} }
/* get supported features */ /* get supported features */
if ((p_attr = SDP_FindAttributeInRec(p_rec, if ((p_attr = SDP_FindAttributeInRec(p_rec,
ATTR_ID_SUPPORTED_FEATURES)) != NULL) ATTR_ID_SUPPORTED_FEATURES)) != NULL) {
{
a2d_svc.features = p_attr->attr_value.v.u16; a2d_svc.features = p_attr->attr_value.v.u16;
} }
/* get AVDTP version */ /* get AVDTP version */
if (SDP_FindProtocolListElemInRec(p_rec, UUID_PROTOCOL_AVDTP, &elem)) if (SDP_FindProtocolListElemInRec(p_rec, UUID_PROTOCOL_AVDTP, &elem)) {
{
a2d_svc.avdt_version = elem.params[0]; a2d_svc.avdt_version = elem.params[0];
A2D_TRACE_DEBUG("avdt_version: 0x%x", a2d_svc.avdt_version); A2D_TRACE_DEBUG("avdt_version: 0x%x", a2d_svc.avdt_version);
} }
@ -115,8 +108,7 @@ static void a2d_sdp_cback(UINT16 status)
a2d_cb.find.service_uuid = 0; a2d_cb.find.service_uuid = 0;
/* return info from sdp record in app callback function */ /* return info from sdp record in app callback function */
if (a2d_cb.find.p_cback != NULL) if (a2d_cb.find.p_cback != NULL) {
{
(*a2d_cb.find.p_cback)(found, &a2d_svc); (*a2d_cb.find.p_cback)(found, &a2d_svc);
} }
@ -180,8 +172,9 @@ tA2D_STATUS A2D_AddRecord(UINT16 service_uuid, char *p_service_name, char *p_pro
A2D_TRACE_API("A2D_AddRecord uuid: %x", service_uuid); A2D_TRACE_API("A2D_AddRecord uuid: %x", service_uuid);
if ( (sdp_handle == 0) || if ( (sdp_handle == 0) ||
(service_uuid != UUID_SERVCLASS_AUDIO_SOURCE && service_uuid != UUID_SERVCLASS_AUDIO_SINK) ) (service_uuid != UUID_SERVCLASS_AUDIO_SOURCE && service_uuid != UUID_SERVCLASS_AUDIO_SINK) ) {
return A2D_INVALID_PARAMS; return A2D_INVALID_PARAMS;
}
/* add service class id list */ /* add service class id list */
result &= SDP_AddServiceClassIdList(sdp_handle, 1, &service_uuid); result &= SDP_AddServiceClassIdList(sdp_handle, 1, &service_uuid);
@ -202,8 +195,7 @@ tA2D_STATUS A2D_AddRecord(UINT16 service_uuid, char *p_service_name, char *p_pro
result &= SDP_AddProfileDescriptorList(sdp_handle, UUID_SERVCLASS_ADV_AUDIO_DISTRIBUTION, A2D_VERSION); result &= SDP_AddProfileDescriptorList(sdp_handle, UUID_SERVCLASS_ADV_AUDIO_DISTRIBUTION, A2D_VERSION);
/* add supported feature */ /* add supported feature */
if (features != 0) if (features != 0) {
{
p = temp; p = temp;
UINT16_TO_BE_STREAM(p, features); UINT16_TO_BE_STREAM(p, features);
result &= SDP_AddAttribute(sdp_handle, ATTR_ID_SUPPORTED_FEATURES, UINT_DESC_TYPE, result &= SDP_AddAttribute(sdp_handle, ATTR_ID_SUPPORTED_FEATURES, UINT_DESC_TYPE,
@ -211,15 +203,13 @@ tA2D_STATUS A2D_AddRecord(UINT16 service_uuid, char *p_service_name, char *p_pro
} }
/* add provider name */ /* add provider name */
if (p_provider_name != NULL) if (p_provider_name != NULL) {
{
result &= SDP_AddAttribute(sdp_handle, ATTR_ID_PROVIDER_NAME, TEXT_STR_DESC_TYPE, result &= SDP_AddAttribute(sdp_handle, ATTR_ID_PROVIDER_NAME, TEXT_STR_DESC_TYPE,
(UINT32)(strlen(p_provider_name) + 1), (UINT8 *) p_provider_name); (UINT32)(strlen(p_provider_name) + 1), (UINT8 *) p_provider_name);
} }
/* add service name */ /* add service name */
if (p_service_name != NULL) if (p_service_name != NULL) {
{
result &= SDP_AddAttribute(sdp_handle, ATTR_ID_SERVICE_NAME, TEXT_STR_DESC_TYPE, result &= SDP_AddAttribute(sdp_handle, ATTR_ID_SERVICE_NAME, TEXT_STR_DESC_TYPE,
(UINT32)(strlen(p_service_name) + 1), (UINT8 *) p_service_name); (UINT32)(strlen(p_service_name) + 1), (UINT8 *) p_service_name);
} }
@ -277,23 +267,25 @@ tA2D_STATUS A2D_FindService(UINT16 service_uuid, BD_ADDR bd_addr,
ATTR_ID_SUPPORTED_FEATURES, ATTR_ID_SUPPORTED_FEATURES,
ATTR_ID_SERVICE_NAME, ATTR_ID_SERVICE_NAME,
ATTR_ID_PROTOCOL_DESC_LIST, ATTR_ID_PROTOCOL_DESC_LIST,
ATTR_ID_PROVIDER_NAME}; ATTR_ID_PROVIDER_NAME
};
A2D_TRACE_API("A2D_FindService uuid: %x", service_uuid); A2D_TRACE_API("A2D_FindService uuid: %x", service_uuid);
if ( (service_uuid != UUID_SERVCLASS_AUDIO_SOURCE && service_uuid != UUID_SERVCLASS_AUDIO_SINK) || if ( (service_uuid != UUID_SERVCLASS_AUDIO_SOURCE && service_uuid != UUID_SERVCLASS_AUDIO_SINK) ||
p_db == NULL || p_db->p_db == NULL || p_cback == NULL) p_db == NULL || p_db->p_db == NULL || p_cback == NULL) {
return A2D_INVALID_PARAMS; return A2D_INVALID_PARAMS;
}
if ( a2d_cb.find.service_uuid == UUID_SERVCLASS_AUDIO_SOURCE || if ( a2d_cb.find.service_uuid == UUID_SERVCLASS_AUDIO_SOURCE ||
a2d_cb.find.service_uuid == UUID_SERVCLASS_AUDIO_SINK) a2d_cb.find.service_uuid == UUID_SERVCLASS_AUDIO_SINK) {
return A2D_BUSY; return A2D_BUSY;
}
/* set up discovery database */ /* set up discovery database */
uuid_list.len = LEN_UUID_16; uuid_list.len = LEN_UUID_16;
uuid_list.uu.uuid16 = service_uuid; uuid_list.uu.uuid16 = service_uuid;
if(p_db->p_attrs == NULL || p_db->num_attr == 0) if (p_db->p_attrs == NULL || p_db->num_attr == 0) {
{
p_db->p_attrs = a2d_attr_list; p_db->p_attrs = a2d_attr_list;
p_db->num_attr = A2D_NUM_ATTR; p_db->num_attr = A2D_NUM_ATTR;
} }
@ -301,8 +293,7 @@ tA2D_STATUS A2D_FindService(UINT16 service_uuid, BD_ADDR bd_addr,
result = SDP_InitDiscoveryDb(p_db->p_db, p_db->db_len, 1, &uuid_list, p_db->num_attr, result = SDP_InitDiscoveryDb(p_db->p_db, p_db->db_len, 1, &uuid_list, p_db->num_attr,
p_db->p_attrs); p_db->p_attrs);
if (result == TRUE) if (result == TRUE) {
{
/* store service_uuid and discovery db pointer */ /* store service_uuid and discovery db pointer */
a2d_cb.find.p_db = p_db->p_db; a2d_cb.find.p_db = p_db->p_db;
a2d_cb.find.service_uuid = service_uuid; a2d_cb.find.service_uuid = service_uuid;
@ -310,8 +301,7 @@ tA2D_STATUS A2D_FindService(UINT16 service_uuid, BD_ADDR bd_addr,
/* perform service search */ /* perform service search */
result = SDP_ServiceSearchAttributeRequest(bd_addr, p_db->p_db, a2d_sdp_cback); result = SDP_ServiceSearchAttributeRequest(bd_addr, p_db->p_db, a2d_sdp_cback);
if(FALSE == result) if (FALSE == result) {
{
a2d_cb.find.service_uuid = 0; a2d_cb.find.service_uuid = 0;
} }
} }
@ -342,8 +332,9 @@ tA2D_STATUS A2D_FindService(UINT16 service_uuid, BD_ADDR bd_addr,
******************************************************************************/ ******************************************************************************/
UINT8 A2D_SetTraceLevel (UINT8 new_level) UINT8 A2D_SetTraceLevel (UINT8 new_level)
{ {
if (new_level != 0xFF) if (new_level != 0xFF) {
a2d_cb.trace_level = new_level; a2d_cb.trace_level = new_level;
}
return (a2d_cb.trace_level); return (a2d_cb.trace_level);
} }
@ -360,10 +351,9 @@ UINT8 A2D_BitsSet(UINT8 num)
{ {
UINT8 count; UINT8 count;
BOOLEAN res; BOOLEAN res;
if(num == 0) if (num == 0) {
res = A2D_SET_ZERO_BIT; res = A2D_SET_ZERO_BIT;
else } else {
{
count = (num & (num - 1)); count = (num & (num - 1));
res = ((count == 0) ? A2D_SET_ONE_BIT : A2D_SET_MULTL_BIT); res = ((count == 0) ? A2D_SET_ONE_BIT : A2D_SET_MULTL_BIT);
} }

84
components/bt/bluedroid/stack/a2dp/a2d_sbc.c Executable file → Normal file
View file

@ -92,14 +92,12 @@
#define A2D_SBC_GET_IDX(sc) (((sc) & 0x3) + (((sc) & 0x30) >> 2)) #define A2D_SBC_GET_IDX(sc) (((sc) & 0x3) + (((sc) & 0x30) >> 2))
typedef struct typedef struct {
{
UINT8 use; UINT8 use;
UINT8 idx; UINT8 idx;
} tA2D_SBC_FR_CB; } tA2D_SBC_FR_CB;
typedef struct typedef struct {
{
tA2D_SBC_FR_CB fr[2]; tA2D_SBC_FR_CB fr[2];
UINT8 index; UINT8 index;
UINT8 base; UINT8 base;
@ -121,16 +119,17 @@ void A2D_SbcChkFrInit(UINT8 *p_pkt)
UINT8 num_chnl = 1; UINT8 num_chnl = 1;
UINT8 num_subband = 4; UINT8 num_subband = 4;
if((p_pkt[0] & A2D_SBC_SYNC_MASK) == 0) if ((p_pkt[0] & A2D_SBC_SYNC_MASK) == 0) {
{
a2d_cb.use_desc = TRUE; a2d_cb.use_desc = TRUE;
fmt = p_pkt[1]; fmt = p_pkt[1];
p_pkt[0] |= A2D_SBC_SYNC_MASK; p_pkt[0] |= A2D_SBC_SYNC_MASK;
memset(&a2d_sbc_ds_cb, 0, sizeof(tA2D_SBC_DS_CB)); memset(&a2d_sbc_ds_cb, 0, sizeof(tA2D_SBC_DS_CB));
if(fmt & A2D_SBC_CH_M_BITS) if (fmt & A2D_SBC_CH_M_BITS) {
num_chnl = 2; num_chnl = 2;
if(fmt & A2D_SBC_SUBBAND_BIT) }
if (fmt & A2D_SBC_SUBBAND_BIT) {
num_subband = 8; num_subband = 8;
}
a2d_sbc_ds_cb.base = 6 + num_chnl * num_subband / 2; a2d_sbc_ds_cb.base = 6 + num_chnl * num_subband / 2;
/*printf("base: %d\n", a2d_sbc_ds_cb.base); /*printf("base: %d\n", a2d_sbc_ds_cb.base);
a2d_count = 0;*/ a2d_count = 0;*/
@ -150,8 +149,7 @@ void A2D_SbcDescramble(UINT8 *p_pkt, UINT16 len)
tA2D_SBC_FR_CB *p_cur, *p_last; tA2D_SBC_FR_CB *p_cur, *p_last;
UINT32 idx, tmp, tmp2; UINT32 idx, tmp, tmp2;
if(a2d_cb.use_desc) if (a2d_cb.use_desc) {
{
/* c2l */ /* c2l */
p_last = &a2d_sbc_ds_cb.fr[A2D_SBC_LIDX]; p_last = &a2d_sbc_ds_cb.fr[A2D_SBC_LIDX];
p_cur = &a2d_sbc_ds_cb.fr[A2D_SBC_CIDX]; p_cur = &a2d_sbc_ds_cb.fr[A2D_SBC_CIDX];
@ -169,11 +167,9 @@ void A2D_SbcDescramble(UINT8 *p_pkt, UINT16 len)
*/ */
/* descramble */ /* descramble */
idx = a2d_sbc_ds_cb.fr[a2d_sbc_ds_cb.index].idx; idx = a2d_sbc_ds_cb.fr[a2d_sbc_ds_cb.index].idx;
if(idx > 0) if (idx > 0) {
{
p_pkt = &p_pkt[a2d_sbc_ds_cb.base]; p_pkt = &p_pkt[a2d_sbc_ds_cb.base];
if((idx&1) && (len > (a2d_sbc_ds_cb.base+(idx<<1)))) if ((idx & 1) && (len > (a2d_sbc_ds_cb.base + (idx << 1)))) {
{
tmp2 = (idx << 1); tmp2 = (idx << 1);
tmp = p_pkt[idx]; tmp = p_pkt[idx];
p_pkt[idx] = p_pkt[tmp2]; p_pkt[idx] = p_pkt[tmp2];
@ -182,9 +178,7 @@ void A2D_SbcDescramble(UINT8 *p_pkt, UINT16 len)
printf("tmp2: %02d, len: %d, idx: %d\n", printf("tmp2: %02d, len: %d, idx: %d\n",
tmp2, len, a2d_sbc_ds_cb.fr[a2d_sbc_ds_cb.index].idx); tmp2, len, a2d_sbc_ds_cb.fr[a2d_sbc_ds_cb.index].idx);
*/ */
} } else {
else
{
tmp2 = p_pkt[idx]; tmp2 = p_pkt[idx];
tmp = (tmp2 >> 3) + (tmp2 << 5); tmp = (tmp2 >> 3) + (tmp2 << 5);
p_pkt[idx] = (UINT8)tmp; p_pkt[idx] = (UINT8)tmp;
@ -236,13 +230,10 @@ tA2D_STATUS A2D_BldSbcInfo(UINT8 media_type, tA2D_SBC_CIE *p_ie, UINT8 *p_result
(p_ie->max_bitpool < A2D_SBC_IE_MIN_BITPOOL) || (p_ie->max_bitpool < A2D_SBC_IE_MIN_BITPOOL) ||
(p_ie->max_bitpool > A2D_SBC_IE_MAX_BITPOOL) || (p_ie->max_bitpool > A2D_SBC_IE_MAX_BITPOOL) ||
(p_ie->min_bitpool < A2D_SBC_IE_MIN_BITPOOL) || (p_ie->min_bitpool < A2D_SBC_IE_MIN_BITPOOL) ||
(p_ie->min_bitpool > A2D_SBC_IE_MAX_BITPOOL) ) (p_ie->min_bitpool > A2D_SBC_IE_MAX_BITPOOL) ) {
{
/* if any unused bit is set */ /* if any unused bit is set */
status = A2D_INVALID_PARAMS; status = A2D_INVALID_PARAMS;
} } else {
else
{
status = A2D_SUCCESS; status = A2D_SUCCESS;
*p_result++ = A2D_SBC_INFO_LEN; *p_result++ = A2D_SBC_INFO_LEN;
*p_result++ = media_type; *p_result++ = media_type;
@ -282,17 +273,15 @@ tA2D_STATUS A2D_ParsSbcInfo(tA2D_SBC_CIE *p_ie, UINT8 *p_info, BOOLEAN for_caps)
tA2D_STATUS status; tA2D_STATUS status;
UINT8 losc; UINT8 losc;
if( p_ie == NULL || p_info == NULL) if ( p_ie == NULL || p_info == NULL) {
status = A2D_INVALID_PARAMS; status = A2D_INVALID_PARAMS;
else } else {
{
losc = *p_info++; losc = *p_info++;
p_info++; p_info++;
/* If the function is called for the wrong Media Type or Media Codec Type */ /* If the function is called for the wrong Media Type or Media Codec Type */
if(losc != A2D_SBC_INFO_LEN || *p_info != A2D_MEDIA_CT_SBC) if (losc != A2D_SBC_INFO_LEN || *p_info != A2D_MEDIA_CT_SBC) {
status = A2D_WRONG_CODEC; status = A2D_WRONG_CODEC;
else } else {
{
p_info++; p_info++;
p_ie->samp_freq = *p_info & A2D_SBC_IE_SAMP_FREQ_MSK; p_ie->samp_freq = *p_info & A2D_SBC_IE_SAMP_FREQ_MSK;
p_ie->ch_mode = *p_info & A2D_SBC_IE_CH_MD_MSK; p_ie->ch_mode = *p_info & A2D_SBC_IE_CH_MD_MSK;
@ -304,28 +293,34 @@ tA2D_STATUS A2D_ParsSbcInfo(tA2D_SBC_CIE *p_ie, UINT8 *p_info, BOOLEAN for_caps)
p_ie->min_bitpool = *p_info++; p_ie->min_bitpool = *p_info++;
p_ie->max_bitpool = *p_info; p_ie->max_bitpool = *p_info;
status = A2D_SUCCESS; status = A2D_SUCCESS;
if(p_ie->min_bitpool < A2D_SBC_IE_MIN_BITPOOL || p_ie->min_bitpool > A2D_SBC_IE_MAX_BITPOOL ) if (p_ie->min_bitpool < A2D_SBC_IE_MIN_BITPOOL || p_ie->min_bitpool > A2D_SBC_IE_MAX_BITPOOL ) {
status = A2D_BAD_MIN_BITPOOL; status = A2D_BAD_MIN_BITPOOL;
}
if (p_ie->max_bitpool < A2D_SBC_IE_MIN_BITPOOL || p_ie->max_bitpool > A2D_SBC_IE_MAX_BITPOOL || if (p_ie->max_bitpool < A2D_SBC_IE_MIN_BITPOOL || p_ie->max_bitpool > A2D_SBC_IE_MAX_BITPOOL ||
p_ie->max_bitpool < p_ie->min_bitpool) p_ie->max_bitpool < p_ie->min_bitpool) {
status = A2D_BAD_MAX_BITPOOL; status = A2D_BAD_MAX_BITPOOL;
}
if(for_caps == FALSE) if (for_caps == FALSE) {
{ if (A2D_BitsSet(p_ie->samp_freq) != A2D_SET_ONE_BIT) {
if(A2D_BitsSet(p_ie->samp_freq) != A2D_SET_ONE_BIT)
status = A2D_BAD_SAMP_FREQ; status = A2D_BAD_SAMP_FREQ;
if(A2D_BitsSet(p_ie->ch_mode) != A2D_SET_ONE_BIT) }
if (A2D_BitsSet(p_ie->ch_mode) != A2D_SET_ONE_BIT) {
status = A2D_BAD_CH_MODE; status = A2D_BAD_CH_MODE;
if(A2D_BitsSet(p_ie->block_len) != A2D_SET_ONE_BIT) }
if (A2D_BitsSet(p_ie->block_len) != A2D_SET_ONE_BIT) {
status = A2D_BAD_BLOCK_LEN; status = A2D_BAD_BLOCK_LEN;
if(A2D_BitsSet(p_ie->num_subbands) != A2D_SET_ONE_BIT) }
if (A2D_BitsSet(p_ie->num_subbands) != A2D_SET_ONE_BIT) {
status = A2D_BAD_SUBBANDS; status = A2D_BAD_SUBBANDS;
if(A2D_BitsSet(p_ie->alloc_mthd) != A2D_SET_ONE_BIT) }
if (A2D_BitsSet(p_ie->alloc_mthd) != A2D_SET_ONE_BIT) {
status = A2D_BAD_ALLOC_MTHD; status = A2D_BAD_ALLOC_MTHD;
} }
} }
} }
}
return status; return status;
} }
@ -353,15 +348,17 @@ tA2D_STATUS A2D_ParsSbcInfo(tA2D_SBC_CIE *p_ie, UINT8 *p_info, BOOLEAN for_caps)
******************************************************************************/ ******************************************************************************/
void A2D_BldSbcMplHdr(UINT8 *p_dst, BOOLEAN frag, BOOLEAN start, BOOLEAN last, UINT8 num) void A2D_BldSbcMplHdr(UINT8 *p_dst, BOOLEAN frag, BOOLEAN start, BOOLEAN last, UINT8 num)
{ {
if(p_dst) if (p_dst) {
{
*p_dst = 0; *p_dst = 0;
if(frag) if (frag) {
*p_dst |= A2D_SBC_HDR_F_MSK; *p_dst |= A2D_SBC_HDR_F_MSK;
if(start) }
if (start) {
*p_dst |= A2D_SBC_HDR_S_MSK; *p_dst |= A2D_SBC_HDR_S_MSK;
if(last) }
if (last) {
*p_dst |= A2D_SBC_HDR_L_MSK; *p_dst |= A2D_SBC_HDR_L_MSK;
}
*p_dst |= (A2D_SBC_HDR_NUM_MSK & num); *p_dst |= (A2D_SBC_HDR_NUM_MSK & num);
} }
} }
@ -390,8 +387,7 @@ void A2D_BldSbcMplHdr(UINT8 *p_dst, BOOLEAN frag, BOOLEAN start, BOOLEAN last, U
******************************************************************************/ ******************************************************************************/
void A2D_ParsSbcMplHdr(UINT8 *p_src, BOOLEAN *p_frag, BOOLEAN *p_start, BOOLEAN *p_last, UINT8 *p_num) void A2D_ParsSbcMplHdr(UINT8 *p_src, BOOLEAN *p_frag, BOOLEAN *p_start, BOOLEAN *p_last, UINT8 *p_num)
{ {
if(p_src && p_frag && p_start && p_last && p_num) if (p_src && p_frag && p_start && p_last && p_num) {
{
*p_frag = (*p_src & A2D_SBC_HDR_F_MSK) ? TRUE : FALSE; *p_frag = (*p_src & A2D_SBC_HDR_F_MSK) ? TRUE : FALSE;
*p_start = (*p_src & A2D_SBC_HDR_S_MSK) ? TRUE : FALSE; *p_start = (*p_src & A2D_SBC_HDR_S_MSK) ? TRUE : FALSE;
*p_last = (*p_src & A2D_SBC_HDR_L_MSK) ? TRUE : FALSE; *p_last = (*p_src & A2D_SBC_HDR_L_MSK) ? TRUE : FALSE;

6
components/bt/bluedroid/stack/a2dp/include/a2d_int.h Executable file → Normal file
View file

@ -42,15 +42,13 @@
*****************************************************************************/ *****************************************************************************/
/* Control block used by A2D_FindService(). */ /* Control block used by A2D_FindService(). */
typedef struct typedef struct {
{
tA2D_FIND_CBACK *p_cback; /* pointer to application callback */ tA2D_FIND_CBACK *p_cback; /* pointer to application callback */
tSDP_DISCOVERY_DB *p_db; /* pointer to discovery database */ tSDP_DISCOVERY_DB *p_db; /* pointer to discovery database */
UINT16 service_uuid; /* service UUID of search */ UINT16 service_uuid; /* service UUID of search */
} tA2D_FIND_CB; } tA2D_FIND_CB;
typedef struct typedef struct {
{
tA2D_FIND_CB find; /* find service control block */ tA2D_FIND_CB find; /* find service control block */
UINT8 trace_level; UINT8 trace_level;
BOOLEAN use_desc; BOOLEAN use_desc;

104
components/bt/bluedroid/stack/avct/avct_api.c Executable file → Normal file
View file

@ -77,8 +77,9 @@ void AVCT_Register(UINT16 mtu, UINT16 mtu_br, UINT8 sec_mask)
BTM_SetSecurityLevel(TRUE, "", BTM_SEC_SERVICE_AVCTP_BROWSE, sec_mask, AVCT_BR_PSM, 0, 0); BTM_SetSecurityLevel(TRUE, "", BTM_SEC_SERVICE_AVCTP_BROWSE, sec_mask, AVCT_BR_PSM, 0, 0);
BTM_SetSecurityLevel(FALSE, "", BTM_SEC_SERVICE_AVCTP_BROWSE, sec_mask, AVCT_BR_PSM, 0, 0); BTM_SetSecurityLevel(FALSE, "", BTM_SEC_SERVICE_AVCTP_BROWSE, sec_mask, AVCT_BR_PSM, 0, 0);
if (mtu_br < AVCT_MIN_BROWSE_MTU) if (mtu_br < AVCT_MIN_BROWSE_MTU) {
mtu_br = AVCT_MIN_BROWSE_MTU; mtu_br = AVCT_MIN_BROWSE_MTU;
}
avct_cb.mtu_br = mtu_br; avct_cb.mtu_br = mtu_br;
#endif #endif
@ -88,8 +89,9 @@ void AVCT_Register(UINT16 mtu, UINT16 mtu_br, UINT8 sec_mask)
avct_cb.trace_level = BT_TRACE_LEVEL_NONE; avct_cb.trace_level = BT_TRACE_LEVEL_NONE;
#endif #endif
if (mtu < AVCT_MIN_CONTROL_MTU) if (mtu < AVCT_MIN_CONTROL_MTU) {
mtu = AVCT_MIN_CONTROL_MTU; mtu = AVCT_MIN_CONTROL_MTU;
}
/* store mtu */ /* store mtu */
avct_cb.mtu = mtu; avct_cb.mtu = mtu;
} }
@ -141,37 +143,29 @@ UINT16 AVCT_CreateConn(UINT8 *p_handle, tAVCT_CC *p_cc, BD_ADDR peer_addr)
AVCT_TRACE_API("AVCT_CreateConn: %d, control:%d", p_cc->role, p_cc->control); AVCT_TRACE_API("AVCT_CreateConn: %d, control:%d", p_cc->role, p_cc->control);
/* Allocate ccb; if no ccbs, return failure */ /* Allocate ccb; if no ccbs, return failure */
if ((p_ccb = avct_ccb_alloc(p_cc)) == NULL) if ((p_ccb = avct_ccb_alloc(p_cc)) == NULL) {
{
result = AVCT_NO_RESOURCES; result = AVCT_NO_RESOURCES;
} } else {
else
{
/* get handle */ /* get handle */
*p_handle = avct_ccb_to_idx(p_ccb); *p_handle = avct_ccb_to_idx(p_ccb);
/* if initiator connection */ /* if initiator connection */
if (p_cc->role == AVCT_INT) if (p_cc->role == AVCT_INT) {
{
/* find link; if none allocate a new one */ /* find link; if none allocate a new one */
if ((p_lcb = avct_lcb_by_bd(peer_addr)) == NULL) if ((p_lcb = avct_lcb_by_bd(peer_addr)) == NULL) {
{ if ((p_lcb = avct_lcb_alloc(peer_addr)) == NULL) {
if ((p_lcb = avct_lcb_alloc(peer_addr)) == NULL)
{
/* no link resources; free ccb as well */ /* no link resources; free ccb as well */
avct_ccb_dealloc(p_ccb, AVCT_NO_EVT, 0, NULL); avct_ccb_dealloc(p_ccb, AVCT_NO_EVT, 0, NULL);
result = AVCT_NO_RESOURCES; result = AVCT_NO_RESOURCES;
} }
} }
/* check if PID already in use */ /* check if PID already in use */
else if (avct_lcb_has_pid(p_lcb, p_cc->pid)) else if (avct_lcb_has_pid(p_lcb, p_cc->pid)) {
{
avct_ccb_dealloc(p_ccb, AVCT_NO_EVT, 0, NULL); avct_ccb_dealloc(p_ccb, AVCT_NO_EVT, 0, NULL);
result = AVCT_PID_IN_USE; result = AVCT_PID_IN_USE;
} }
if (result == AVCT_SUCCESS) if (result == AVCT_SUCCESS) {
{
/* bind lcb to ccb */ /* bind lcb to ccb */
p_ccb->p_lcb = p_lcb; p_ccb->p_lcb = p_lcb;
AVCT_TRACE_DEBUG("ch_state: %d", p_lcb->ch_state); AVCT_TRACE_DEBUG("ch_state: %d", p_lcb->ch_state);
@ -203,18 +197,15 @@ UINT16 AVCT_RemoveConn(UINT8 handle)
AVCT_TRACE_API("AVCT_RemoveConn"); AVCT_TRACE_API("AVCT_RemoveConn");
/* map handle to ccb */ /* map handle to ccb */
if ((p_ccb = avct_ccb_by_idx(handle)) == NULL) if ((p_ccb = avct_ccb_by_idx(handle)) == NULL) {
{
result = AVCT_BAD_HANDLE; result = AVCT_BAD_HANDLE;
} }
/* if connection not bound to lcb, dealloc */ /* if connection not bound to lcb, dealloc */
else if (p_ccb->p_lcb == NULL) else if (p_ccb->p_lcb == NULL) {
{
avct_ccb_dealloc(p_ccb, AVCT_NO_EVT, 0, NULL); avct_ccb_dealloc(p_ccb, AVCT_NO_EVT, 0, NULL);
} }
/* send unbind event to lcb */ /* send unbind event to lcb */
else else {
{
avct_lcb_event(p_ccb->p_lcb, AVCT_LCB_UL_UNBIND_EVT, (tAVCT_LCB_EVT *) &p_ccb); avct_lcb_event(p_ccb->p_lcb, AVCT_LCB_UL_UNBIND_EVT, (tAVCT_LCB_EVT *) &p_ccb);
} }
return result; return result;
@ -247,44 +238,32 @@ UINT16 AVCT_CreateBrowse (UINT8 handle, UINT8 role)
AVCT_TRACE_API("AVCT_CreateBrowse: %d", role); AVCT_TRACE_API("AVCT_CreateBrowse: %d", role);
/* map handle to ccb */ /* map handle to ccb */
if ((p_ccb = avct_ccb_by_idx(handle)) == NULL) if ((p_ccb = avct_ccb_by_idx(handle)) == NULL) {
{
return AVCT_BAD_HANDLE; return AVCT_BAD_HANDLE;
} } else {
else
{
/* mark this CCB as supporting browsing channel */ /* mark this CCB as supporting browsing channel */
if ((p_ccb->allocated & AVCT_ALOC_BCB) == 0) if ((p_ccb->allocated & AVCT_ALOC_BCB) == 0) {
{
p_ccb->allocated |= AVCT_ALOC_BCB; p_ccb->allocated |= AVCT_ALOC_BCB;
} }
} }
/* if initiator connection */ /* if initiator connection */
if (role == AVCT_INT) if (role == AVCT_INT) {
{
/* the link control block must exist before this function is called as INT. */ /* the link control block must exist before this function is called as INT. */
if ((p_ccb->p_lcb == NULL) || (p_ccb->p_lcb->allocated == 0)) if ((p_ccb->p_lcb == NULL) || (p_ccb->p_lcb->allocated == 0)) {
{
result = AVCT_NOT_OPEN; result = AVCT_NOT_OPEN;
} } else {
else
{
/* find link; if none allocate a new one */ /* find link; if none allocate a new one */
index = p_ccb->p_lcb->allocated; index = p_ccb->p_lcb->allocated;
if (index > AVCT_NUM_LINKS) if (index > AVCT_NUM_LINKS) {
{
result = AVCT_BAD_HANDLE; result = AVCT_BAD_HANDLE;
} } else {
else
{
p_bcb = &avct_cb.bcb[index - 1]; p_bcb = &avct_cb.bcb[index - 1];
p_bcb->allocated = index; p_bcb->allocated = index;
} }
} }
if (result == AVCT_SUCCESS) if (result == AVCT_SUCCESS) {
{
/* bind bcb to ccb */ /* bind bcb to ccb */
p_ccb->p_bcb = p_bcb; p_ccb->p_bcb = p_bcb;
AVCT_TRACE_DEBUG("ch_state: %d", p_bcb->ch_state); AVCT_TRACE_DEBUG("ch_state: %d", p_bcb->ch_state);
@ -322,11 +301,9 @@ UINT16 AVCT_RemoveBrowse (UINT8 handle)
AVCT_TRACE_API("AVCT_RemoveBrowse"); AVCT_TRACE_API("AVCT_RemoveBrowse");
/* map handle to ccb */ /* map handle to ccb */
if ((p_ccb = avct_ccb_by_idx(handle)) == NULL) if ((p_ccb = avct_ccb_by_idx(handle)) == NULL) {
{
result = AVCT_BAD_HANDLE; result = AVCT_BAD_HANDLE;
} } else if (p_ccb->p_bcb != NULL)
else if (p_ccb->p_bcb != NULL)
/* send unbind event to bcb */ /* send unbind event to bcb */
{ {
avct_bcb_event(p_ccb->p_bcb, AVCT_LCB_UL_UNBIND_EVT, (tAVCT_LCB_EVT *) &p_ccb); avct_bcb_event(p_ccb->p_bcb, AVCT_LCB_UL_UNBIND_EVT, (tAVCT_LCB_EVT *) &p_ccb);
@ -354,8 +331,7 @@ UINT16 AVCT_GetBrowseMtu (UINT8 handle)
#if (AVCT_BROWSE_INCLUDED == TRUE) #if (AVCT_BROWSE_INCLUDED == TRUE)
tAVCT_CCB *p_ccb; tAVCT_CCB *p_ccb;
if ((p_ccb = avct_ccb_by_idx(handle)) != NULL && p_ccb->p_bcb != NULL) if ((p_ccb = avct_ccb_by_idx(handle)) != NULL && p_ccb->p_bcb != NULL) {
{
peer_mtu = p_ccb->p_bcb->peer_mtu; peer_mtu = p_ccb->p_bcb->peer_mtu;
} }
#else #else
@ -380,10 +356,8 @@ UINT16 AVCT_GetPeerMtu (UINT8 handle)
tAVCT_CCB *p_ccb; tAVCT_CCB *p_ccb;
/* map handle to ccb */ /* map handle to ccb */
if ((p_ccb = avct_ccb_by_idx(handle)) != NULL) if ((p_ccb = avct_ccb_by_idx(handle)) != NULL) {
{ if (p_ccb->p_lcb) {
if (p_ccb->p_lcb)
{
peer_mtu = p_ccb->p_lcb->peer_mtu; peer_mtu = p_ccb->p_lcb->peer_mtu;
} }
} }
@ -421,27 +395,23 @@ UINT16 AVCT_MsgReq(UINT8 handle, UINT8 label, UINT8 cr, BT_HDR *p_msg)
AVCT_TRACE_API("AVCT_MsgReq"); AVCT_TRACE_API("AVCT_MsgReq");
/* verify p_msg parameter */ /* verify p_msg parameter */
if (p_msg == NULL) if (p_msg == NULL) {
{
return AVCT_NO_RESOURCES; return AVCT_NO_RESOURCES;
} }
AVCT_TRACE_API("len: %d", p_msg->len); AVCT_TRACE_API("len: %d", p_msg->len);
/* map handle to ccb */ /* map handle to ccb */
if ((p_ccb = avct_ccb_by_idx(handle)) == NULL) if ((p_ccb = avct_ccb_by_idx(handle)) == NULL) {
{
result = AVCT_BAD_HANDLE; result = AVCT_BAD_HANDLE;
GKI_freebuf(p_msg); GKI_freebuf(p_msg);
} }
/* verify channel is bound to link */ /* verify channel is bound to link */
else if (p_ccb->p_lcb == NULL) else if (p_ccb->p_lcb == NULL) {
{
result = AVCT_NOT_OPEN; result = AVCT_NOT_OPEN;
GKI_freebuf(p_msg); GKI_freebuf(p_msg);
} }
if (result == AVCT_SUCCESS) if (result == AVCT_SUCCESS) {
{
ul_msg.p_buf = p_msg; ul_msg.p_buf = p_msg;
ul_msg.p_ccb = p_ccb; ul_msg.p_ccb = p_ccb;
ul_msg.label = label; ul_msg.label = label;
@ -449,16 +419,12 @@ UINT16 AVCT_MsgReq(UINT8 handle, UINT8 label, UINT8 cr, BT_HDR *p_msg)
#if (AVCT_BROWSE_INCLUDED == TRUE) #if (AVCT_BROWSE_INCLUDED == TRUE)
/* send msg event to bcb */ /* send msg event to bcb */
if (p_msg->layer_specific == AVCT_DATA_BROWSE) if (p_msg->layer_specific == AVCT_DATA_BROWSE) {
{ if (p_ccb->p_bcb == NULL && (p_ccb->allocated & AVCT_ALOC_BCB) == 0) {
if (p_ccb->p_bcb == NULL && (p_ccb->allocated & AVCT_ALOC_BCB) == 0)
{
/* BCB channel is not open and not allocated */ /* BCB channel is not open and not allocated */
result = AVCT_BAD_HANDLE; result = AVCT_BAD_HANDLE;
GKI_freebuf(p_msg); GKI_freebuf(p_msg);
} } else {
else
{
p_ccb->p_bcb = avct_bcb_by_lcb(p_ccb->p_lcb); p_ccb->p_bcb = avct_bcb_by_lcb(p_ccb->p_lcb);
avct_bcb_event(p_ccb->p_bcb, AVCT_LCB_UL_MSG_EVT, (tAVCT_LCB_EVT *) &ul_msg); avct_bcb_event(p_ccb->p_bcb, AVCT_LCB_UL_MSG_EVT, (tAVCT_LCB_EVT *) &ul_msg);
} }

27
components/bt/bluedroid/stack/avct/avct_ccb.c Executable file → Normal file
View file

@ -46,10 +46,8 @@ tAVCT_CCB *avct_ccb_alloc(tAVCT_CC *p_cc)
tAVCT_CCB *p_ccb = &avct_cb.ccb[0]; tAVCT_CCB *p_ccb = &avct_cb.ccb[0];
int i; int i;
for (i = 0; i < AVCT_NUM_CONN; i++, p_ccb++) for (i = 0; i < AVCT_NUM_CONN; i++, p_ccb++) {
{ if (!p_ccb->allocated) {
if (!p_ccb->allocated)
{
p_ccb->allocated = AVCT_ALOC_LCB; p_ccb->allocated = AVCT_ALOC_LCB;
memcpy(&p_ccb->cc, p_cc, sizeof(tAVCT_CC)); memcpy(&p_ccb->cc, p_cc, sizeof(tAVCT_CC));
AVCT_TRACE_DEBUG("avct_ccb_alloc %d", i); AVCT_TRACE_DEBUG("avct_ccb_alloc %d", i);
@ -57,8 +55,7 @@ tAVCT_CCB *avct_ccb_alloc(tAVCT_CC *p_cc)
} }
} }
if (i == AVCT_NUM_CONN) if (i == AVCT_NUM_CONN) {
{
/* out of ccbs */ /* out of ccbs */
p_ccb = NULL; p_ccb = NULL;
AVCT_TRACE_WARNING("Out of ccbs"); AVCT_TRACE_WARNING("Out of ccbs");
@ -83,10 +80,9 @@ void avct_ccb_dealloc(tAVCT_CCB *p_ccb, UINT8 event, UINT16 result, BD_ADDR bd_a
AVCT_TRACE_DEBUG("avct_ccb_dealloc %d", avct_ccb_to_idx(p_ccb)); AVCT_TRACE_DEBUG("avct_ccb_dealloc %d", avct_ccb_to_idx(p_ccb));
#if (AVCT_BROWSE_INCLUDED == TRUE) #if (AVCT_BROWSE_INCLUDED == TRUE)
if(p_ccb->p_bcb == NULL) if (p_ccb->p_bcb == NULL) {
memset(p_ccb, 0, sizeof(tAVCT_CCB)); memset(p_ccb, 0, sizeof(tAVCT_CCB));
else } else {
{
/* control channel is down, but the browsing channel is still connected 0 disconnect it now */ /* control channel is down, but the browsing channel is still connected 0 disconnect it now */
avct_bcb_event(p_ccb->p_bcb, AVCT_LCB_UL_UNBIND_EVT, (tAVCT_LCB_EVT *) &p_ccb); avct_bcb_event(p_ccb->p_bcb, AVCT_LCB_UL_UNBIND_EVT, (tAVCT_LCB_EVT *) &p_ccb);
p_ccb->p_lcb = NULL; p_ccb->p_lcb = NULL;
@ -95,8 +91,7 @@ void avct_ccb_dealloc(tAVCT_CCB *p_ccb, UINT8 event, UINT16 result, BD_ADDR bd_a
memset(p_ccb, 0, sizeof(tAVCT_CCB)); memset(p_ccb, 0, sizeof(tAVCT_CCB));
#endif #endif
if (event != AVCT_NO_EVT) if (event != AVCT_NO_EVT) {
{
(*p_cback)(avct_ccb_to_idx(p_ccb), event, result, bd_addr); (*p_cback)(avct_ccb_to_idx(p_ccb), event, result, bd_addr);
} }
} }
@ -132,19 +127,15 @@ tAVCT_CCB *avct_ccb_by_idx(UINT8 idx)
tAVCT_CCB *p_ccb; tAVCT_CCB *p_ccb;
/* verify index */ /* verify index */
if (idx < AVCT_NUM_CONN) if (idx < AVCT_NUM_CONN) {
{
p_ccb = &avct_cb.ccb[idx]; p_ccb = &avct_cb.ccb[idx];
/* verify ccb is allocated */ /* verify ccb is allocated */
if (!p_ccb->allocated) if (!p_ccb->allocated) {
{
p_ccb = NULL; p_ccb = NULL;
AVCT_TRACE_WARNING("ccb %d not allocated", idx); AVCT_TRACE_WARNING("ccb %d not allocated", idx);
} }
} } else {
else
{
p_ccb = NULL; p_ccb = NULL;
AVCT_TRACE_WARNING("No ccb for idx %d", idx); AVCT_TRACE_WARNING("No ccb for idx %d", idx);
} }

106
components/bt/bluedroid/stack/avct/avct_l2c.c Executable file → Normal file
View file

@ -78,13 +78,10 @@ static BOOLEAN avct_l2c_is_passive (tAVCT_LCB *p_lcb)
tAVCT_CCB *p_ccb = &avct_cb.ccb[0]; tAVCT_CCB *p_ccb = &avct_cb.ccb[0];
int i; int i;
for (i = 0; i < AVCT_NUM_CONN; i++, p_ccb++) for (i = 0; i < AVCT_NUM_CONN; i++, p_ccb++) {
{ if (p_ccb->allocated && (p_ccb->p_lcb == p_lcb)) {
if (p_ccb->allocated && (p_ccb->p_lcb == p_lcb))
{
AVCT_TRACE_DEBUG("avct_l2c_is_ct control:x%x", p_ccb->cc.control); AVCT_TRACE_DEBUG("avct_l2c_is_ct control:x%x", p_ccb->cc.control);
if (p_ccb->cc.control & AVCT_PASSIVE) if (p_ccb->cc.control & AVCT_PASSIVE) {
{
is_passive = TRUE; is_passive = TRUE;
break; break;
} }
@ -111,33 +108,26 @@ void avct_l2c_connect_ind_cback(BD_ADDR bd_addr, UINT16 lcid, UINT16 psm, UINT8
UNUSED(psm); UNUSED(psm);
/* do we already have a channel for this peer? */ /* do we already have a channel for this peer? */
if ((p_lcb = avct_lcb_by_bd(bd_addr)) == NULL) if ((p_lcb = avct_lcb_by_bd(bd_addr)) == NULL) {
{
/* no, allocate lcb */ /* no, allocate lcb */
if ((p_lcb = avct_lcb_alloc(bd_addr)) == NULL) if ((p_lcb = avct_lcb_alloc(bd_addr)) == NULL) {
{
/* no ccb available, reject L2CAP connection */ /* no ccb available, reject L2CAP connection */
result = L2CAP_CONN_NO_RESOURCES; result = L2CAP_CONN_NO_RESOURCES;
} }
} }
/* else we already have a channel for this peer */ /* else we already have a channel for this peer */
else else {
{ if (!avct_l2c_is_passive (p_lcb) || (p_lcb->ch_state == AVCT_CH_OPEN)) {
if (!avct_l2c_is_passive (p_lcb) || (p_lcb->ch_state == AVCT_CH_OPEN))
{
/* this LCB included CT role - reject */ /* this LCB included CT role - reject */
result = L2CAP_CONN_NO_RESOURCES; result = L2CAP_CONN_NO_RESOURCES;
} } else {
else
{
/* TG role only - accept the connection from CT. move the channel ID to the conflict list */ /* TG role only - accept the connection from CT. move the channel ID to the conflict list */
p_lcb->conflict_lcid = p_lcb->ch_lcid; p_lcb->conflict_lcid = p_lcb->ch_lcid;
AVCT_TRACE_DEBUG("avct_l2c_connect_ind_cback conflict_lcid:0x%x", p_lcb->conflict_lcid); AVCT_TRACE_DEBUG("avct_l2c_connect_ind_cback conflict_lcid:0x%x", p_lcb->conflict_lcid);
} }
} }
if(p_lcb) if (p_lcb) {
{
AVCT_TRACE_DEBUG("avct_l2c_connect_ind_cback: 0x%x, res: %d, ch_state: %d", AVCT_TRACE_DEBUG("avct_l2c_connect_ind_cback: 0x%x, res: %d, ch_state: %d",
lcid, result, p_lcb->ch_state); lcid, result, p_lcb->ch_state);
} }
@ -145,8 +135,7 @@ void avct_l2c_connect_ind_cback(BD_ADDR bd_addr, UINT16 lcid, UINT16 psm, UINT8
L2CA_ConnectRsp(bd_addr, id, lcid, result, 0); L2CA_ConnectRsp(bd_addr, id, lcid, result, 0);
/* if result ok, proceed with connection */ /* if result ok, proceed with connection */
if (result == L2CAP_CONN_OK) if (result == L2CAP_CONN_OK) {
{
/* store LCID */ /* store LCID */
p_lcb->ch_lcid = lcid; p_lcb->ch_lcid = lcid;
@ -162,8 +151,9 @@ void avct_l2c_connect_ind_cback(BD_ADDR bd_addr, UINT16 lcid, UINT16 psm, UINT8
} }
#if (BT_USE_TRACES == TRUE) #if (BT_USE_TRACES == TRUE)
if(p_lcb) if (p_lcb) {
AVCT_TRACE_DEBUG("ch_state cni: %d ", p_lcb->ch_state); AVCT_TRACE_DEBUG("ch_state cni: %d ", p_lcb->ch_state);
}
#endif #endif
} }
@ -183,16 +173,13 @@ void avct_l2c_connect_cfm_cback(UINT16 lcid, UINT16 result)
tL2CAP_CFG_INFO cfg; tL2CAP_CFG_INFO cfg;
/* look up lcb for this channel */ /* look up lcb for this channel */
if ((p_lcb = avct_lcb_by_lcid(lcid)) != NULL) if ((p_lcb = avct_lcb_by_lcid(lcid)) != NULL) {
{
AVCT_TRACE_DEBUG("avct_l2c_connect_cfm_cback lcid:0x%x result: %d ch_state: %d, conflict_lcid:0x%x", AVCT_TRACE_DEBUG("avct_l2c_connect_cfm_cback lcid:0x%x result: %d ch_state: %d, conflict_lcid:0x%x",
lcid, result, p_lcb->ch_state, p_lcb->conflict_lcid); lcid, result, p_lcb->ch_state, p_lcb->conflict_lcid);
/* if in correct state */ /* if in correct state */
if (p_lcb->ch_state == AVCT_CH_CONN) if (p_lcb->ch_state == AVCT_CH_CONN) {
{
/* if result successful */ /* if result successful */
if (result == L2CAP_CONN_OK) if (result == L2CAP_CONN_OK) {
{
/* set channel state */ /* set channel state */
p_lcb->ch_state = AVCT_CH_CFG; p_lcb->ch_state = AVCT_CH_CFG;
@ -204,21 +191,18 @@ void avct_l2c_connect_cfm_cback(UINT16 lcid, UINT16 result)
AVCT_TRACE_DEBUG("avct_l2c snd Cfg Req"); AVCT_TRACE_DEBUG("avct_l2c snd Cfg Req");
} }
/* else failure */ /* else failure */
else else {
{
AVCT_TRACE_DEBUG("avct_l2c_connect_cfm_cback conflict_lcid:0x%x", p_lcb->conflict_lcid); AVCT_TRACE_DEBUG("avct_l2c_connect_cfm_cback conflict_lcid:0x%x", p_lcb->conflict_lcid);
if (p_lcb->conflict_lcid == lcid) if (p_lcb->conflict_lcid == lcid) {
p_lcb->conflict_lcid = 0; p_lcb->conflict_lcid = 0;
else } else {
avct_lcb_event(p_lcb, AVCT_LCB_LL_CLOSE_EVT, (tAVCT_LCB_EVT *) &result); avct_lcb_event(p_lcb, AVCT_LCB_LL_CLOSE_EVT, (tAVCT_LCB_EVT *) &result);
} }
} }
else if (p_lcb->conflict_lcid == lcid) } else if (p_lcb->conflict_lcid == lcid) {
{
/* we must be in AVCT_CH_CFG state for the ch_lcid channel */ /* we must be in AVCT_CH_CFG state for the ch_lcid channel */
AVCT_TRACE_DEBUG("avct_l2c_connect_cfm_cback ch_state: %d, conflict_lcid:0x%x", p_lcb->ch_state, p_lcb->conflict_lcid); AVCT_TRACE_DEBUG("avct_l2c_connect_cfm_cback ch_state: %d, conflict_lcid:0x%x", p_lcb->ch_state, p_lcb->conflict_lcid);
if (result == L2CAP_CONN_OK) if (result == L2CAP_CONN_OK) {
{
/* just in case the peer also accepts our connection - Send L2CAP disconnect req */ /* just in case the peer also accepts our connection - Send L2CAP disconnect req */
L2CA_DisconnectReq(lcid); L2CA_DisconnectReq(lcid);
} }
@ -243,29 +227,24 @@ void avct_l2c_config_cfm_cback(UINT16 lcid, tL2CAP_CFG_INFO *p_cfg)
tAVCT_LCB *p_lcb; tAVCT_LCB *p_lcb;
/* look up lcb for this channel */ /* look up lcb for this channel */
if ((p_lcb = avct_lcb_by_lcid(lcid)) != NULL) if ((p_lcb = avct_lcb_by_lcid(lcid)) != NULL) {
{
AVCT_TRACE_DEBUG("avct_l2c_config_cfm_cback: 0x%x, ch_state: %d, res: %d", AVCT_TRACE_DEBUG("avct_l2c_config_cfm_cback: 0x%x, ch_state: %d, res: %d",
lcid, p_lcb->ch_state, p_cfg->result); lcid, p_lcb->ch_state, p_cfg->result);
/* if in correct state */ /* if in correct state */
if (p_lcb->ch_state == AVCT_CH_CFG) if (p_lcb->ch_state == AVCT_CH_CFG) {
{
/* if result successful */ /* if result successful */
if (p_cfg->result == L2CAP_CFG_OK) if (p_cfg->result == L2CAP_CFG_OK) {
{
/* update flags */ /* update flags */
p_lcb->ch_flags |= AVCT_L2C_CFG_CFM_DONE; p_lcb->ch_flags |= AVCT_L2C_CFG_CFM_DONE;
/* if configuration complete */ /* if configuration complete */
if (p_lcb->ch_flags & AVCT_L2C_CFG_IND_DONE) if (p_lcb->ch_flags & AVCT_L2C_CFG_IND_DONE) {
{
p_lcb->ch_state = AVCT_CH_OPEN; p_lcb->ch_state = AVCT_CH_OPEN;
avct_lcb_event(p_lcb, AVCT_LCB_LL_OPEN_EVT, NULL); avct_lcb_event(p_lcb, AVCT_LCB_LL_OPEN_EVT, NULL);
} }
} }
/* else failure */ /* else failure */
else else {
{
AVCT_TRACE_DEBUG("ERROR avct_l2c_config_cfm_cback L2CA_DisconnectReq %d ", p_lcb->ch_state); AVCT_TRACE_DEBUG("ERROR avct_l2c_config_cfm_cback L2CA_DisconnectReq %d ", p_lcb->ch_state);
/* store result value */ /* store result value */
p_lcb->ch_result = p_cfg->result; p_lcb->ch_result = p_cfg->result;
@ -293,16 +272,12 @@ void avct_l2c_config_ind_cback(UINT16 lcid, tL2CAP_CFG_INFO *p_cfg)
tAVCT_LCB *p_lcb; tAVCT_LCB *p_lcb;
/* look up lcb for this channel */ /* look up lcb for this channel */
if ((p_lcb = avct_lcb_by_lcid(lcid)) != NULL) if ((p_lcb = avct_lcb_by_lcid(lcid)) != NULL) {
{
AVCT_TRACE_DEBUG("avct_l2c_config_ind_cback: 0x%x, ch_state: %d", lcid, p_lcb->ch_state); AVCT_TRACE_DEBUG("avct_l2c_config_ind_cback: 0x%x, ch_state: %d", lcid, p_lcb->ch_state);
/* store the mtu in tbl */ /* store the mtu in tbl */
if (p_cfg->mtu_present) if (p_cfg->mtu_present) {
{
p_lcb->peer_mtu = p_cfg->mtu; p_lcb->peer_mtu = p_cfg->mtu;
} } else {
else
{
p_lcb->peer_mtu = L2CAP_DEFAULT_MTU; p_lcb->peer_mtu = L2CAP_DEFAULT_MTU;
} }
@ -312,14 +287,12 @@ void avct_l2c_config_ind_cback(UINT16 lcid, tL2CAP_CFG_INFO *p_cfg)
L2CA_ConfigRsp(lcid, p_cfg); L2CA_ConfigRsp(lcid, p_cfg);
/* if first config ind */ /* if first config ind */
if ((p_lcb->ch_flags & AVCT_L2C_CFG_IND_DONE) == 0) if ((p_lcb->ch_flags & AVCT_L2C_CFG_IND_DONE) == 0) {
{
/* update flags */ /* update flags */
p_lcb->ch_flags |= AVCT_L2C_CFG_IND_DONE; p_lcb->ch_flags |= AVCT_L2C_CFG_IND_DONE;
/* if configuration complete */ /* if configuration complete */
if (p_lcb->ch_flags & AVCT_L2C_CFG_CFM_DONE) if (p_lcb->ch_flags & AVCT_L2C_CFG_CFM_DONE) {
{
p_lcb->ch_state = AVCT_CH_OPEN; p_lcb->ch_state = AVCT_CH_OPEN;
avct_lcb_event(p_lcb, AVCT_LCB_LL_OPEN_EVT, NULL); avct_lcb_event(p_lcb, AVCT_LCB_LL_OPEN_EVT, NULL);
} }
@ -344,11 +317,9 @@ void avct_l2c_disconnect_ind_cback(UINT16 lcid, BOOLEAN ack_needed)
UINT16 result = AVCT_RESULT_FAIL; UINT16 result = AVCT_RESULT_FAIL;
/* look up lcb for this channel */ /* look up lcb for this channel */
if ((p_lcb = avct_lcb_by_lcid(lcid)) != NULL) if ((p_lcb = avct_lcb_by_lcid(lcid)) != NULL) {
{
AVCT_TRACE_DEBUG("avct_l2c_disconnect_ind_cback: 0x%x, ch_state: %d", lcid, p_lcb->ch_state); AVCT_TRACE_DEBUG("avct_l2c_disconnect_ind_cback: 0x%x, ch_state: %d", lcid, p_lcb->ch_state);
if (ack_needed) if (ack_needed) {
{
/* send L2CAP disconnect response */ /* send L2CAP disconnect response */
L2CA_DisconnectRsp(lcid); L2CA_DisconnectRsp(lcid);
} }
@ -374,8 +345,7 @@ void avct_l2c_disconnect_cfm_cback(UINT16 lcid, UINT16 result)
UINT16 res; UINT16 res;
/* look up lcb for this channel */ /* look up lcb for this channel */
if ((p_lcb = avct_lcb_by_lcid(lcid)) != NULL) if ((p_lcb = avct_lcb_by_lcid(lcid)) != NULL) {
{
AVCT_TRACE_DEBUG("avct_l2c_disconnect_cfm_cback: 0x%x, ch_state: %d, res: %d", AVCT_TRACE_DEBUG("avct_l2c_disconnect_cfm_cback: 0x%x, ch_state: %d, res: %d",
lcid, p_lcb->ch_state, result); lcid, p_lcb->ch_state, result);
/* result value may be previously stored */ /* result value may be previously stored */
@ -403,8 +373,7 @@ void avct_l2c_congestion_ind_cback(UINT16 lcid, BOOLEAN is_congested)
AVCT_TRACE_DEBUG("avct_l2c_congestion_ind_cback: 0x%x", lcid); AVCT_TRACE_DEBUG("avct_l2c_congestion_ind_cback: 0x%x", lcid);
/* look up lcb for this channel */ /* look up lcb for this channel */
if ((p_lcb = avct_lcb_by_lcid(lcid)) != NULL) if ((p_lcb = avct_lcb_by_lcid(lcid)) != NULL) {
{
avct_lcb_event(p_lcb, AVCT_LCB_LL_CONG_EVT, (tAVCT_LCB_EVT *) &is_congested); avct_lcb_event(p_lcb, AVCT_LCB_LL_CONG_EVT, (tAVCT_LCB_EVT *) &is_congested);
} }
} }
@ -425,12 +394,9 @@ void avct_l2c_data_ind_cback(UINT16 lcid, BT_HDR *p_buf)
AVCT_TRACE_DEBUG("avct_l2c_data_ind_cback: 0x%x", lcid); AVCT_TRACE_DEBUG("avct_l2c_data_ind_cback: 0x%x", lcid);
/* look up lcb for this channel */ /* look up lcb for this channel */
if ((p_lcb = avct_lcb_by_lcid(lcid)) != NULL) if ((p_lcb = avct_lcb_by_lcid(lcid)) != NULL) {
{
avct_lcb_event(p_lcb, AVCT_LCB_LL_MSG_EVT, (tAVCT_LCB_EVT *) &p_buf); avct_lcb_event(p_lcb, AVCT_LCB_LL_MSG_EVT, (tAVCT_LCB_EVT *) &p_buf);
} } else { /* prevent buffer leak */
else /* prevent buffer leak */
{
AVCT_TRACE_WARNING("ERROR -> avct_l2c_data_ind_cback drop buffer"); AVCT_TRACE_WARNING("ERROR -> avct_l2c_data_ind_cback drop buffer");
GKI_freebuf(p_buf); GKI_freebuf(p_buf);
} }

74
components/bt/bluedroid/stack/avct/avct_lcb.c Executable file → Normal file
View file

@ -212,14 +212,10 @@ void avct_lcb_event(tAVCT_LCB *p_lcb, UINT8 event, tAVCT_LCB_EVT *p_data)
p_lcb->state = state_table[event][AVCT_LCB_NEXT_STATE]; p_lcb->state = state_table[event][AVCT_LCB_NEXT_STATE];
/* execute action functions */ /* execute action functions */
for (i = 0; i < AVCT_LCB_ACTIONS; i++) for (i = 0; i < AVCT_LCB_ACTIONS; i++) {
{ if ((action = state_table[event][i]) != AVCT_LCB_IGNORE) {
if ((action = state_table[event][i]) != AVCT_LCB_IGNORE)
{
(*avct_lcb_action[action])(p_lcb, p_data); (*avct_lcb_action[action])(p_lcb, p_data);
} } else {
else
{
break; break;
} }
} }
@ -255,14 +251,10 @@ void avct_bcb_event(tAVCT_BCB *p_bcb, UINT8 event, tAVCT_LCB_EVT *p_data)
p_bcb->state = state_table[event][AVCT_LCB_NEXT_STATE]; p_bcb->state = state_table[event][AVCT_LCB_NEXT_STATE];
/* execute action functions */ /* execute action functions */
for (i = 0; i < AVCT_LCB_ACTIONS; i++) for (i = 0; i < AVCT_LCB_ACTIONS; i++) {
{ if ((action = state_table[event][i]) != AVCT_LCB_IGNORE) {
if ((action = state_table[event][i]) != AVCT_LCB_IGNORE)
{
(*avct_bcb_action[action])(p_bcb, p_data); (*avct_bcb_action[action])(p_bcb, p_data);
} } else {
else
{
break; break;
} }
} }
@ -284,17 +276,14 @@ tAVCT_LCB *avct_lcb_by_bd(BD_ADDR bd_addr)
tAVCT_LCB *p_lcb = &avct_cb.lcb[0]; tAVCT_LCB *p_lcb = &avct_cb.lcb[0];
int i; int i;
for (i = 0; i < AVCT_NUM_LINKS; i++, p_lcb++) for (i = 0; i < AVCT_NUM_LINKS; i++, p_lcb++) {
{
/* if allocated lcb has matching lcb */ /* if allocated lcb has matching lcb */
if (p_lcb->allocated && (!memcmp(p_lcb->peer_addr, bd_addr, BD_ADDR_LEN))) if (p_lcb->allocated && (!memcmp(p_lcb->peer_addr, bd_addr, BD_ADDR_LEN))) {
{
break; break;
} }
} }
if (i == AVCT_NUM_LINKS) if (i == AVCT_NUM_LINKS) {
{
/* if no lcb found */ /* if no lcb found */
p_lcb = NULL; p_lcb = NULL;
@ -319,10 +308,8 @@ tAVCT_LCB *avct_lcb_alloc(BD_ADDR bd_addr)
tAVCT_LCB *p_lcb = &avct_cb.lcb[0]; tAVCT_LCB *p_lcb = &avct_cb.lcb[0];
int i; int i;
for (i = 0; i < AVCT_NUM_LINKS; i++, p_lcb++) for (i = 0; i < AVCT_NUM_LINKS; i++, p_lcb++) {
{ if (!p_lcb->allocated) {
if (!p_lcb->allocated)
{
p_lcb->allocated = (UINT8)(i + 1); p_lcb->allocated = (UINT8)(i + 1);
memcpy(p_lcb->peer_addr, bd_addr, BD_ADDR_LEN); memcpy(p_lcb->peer_addr, bd_addr, BD_ADDR_LEN);
AVCT_TRACE_DEBUG("avct_lcb_alloc %d", p_lcb->allocated); AVCT_TRACE_DEBUG("avct_lcb_alloc %d", p_lcb->allocated);
@ -330,8 +317,7 @@ tAVCT_LCB *avct_lcb_alloc(BD_ADDR bd_addr)
} }
} }
if (i == AVCT_NUM_LINKS) if (i == AVCT_NUM_LINKS) {
{
/* out of lcbs */ /* out of lcbs */
p_lcb = NULL; p_lcb = NULL;
AVCT_TRACE_WARNING("Out of lcbs"); AVCT_TRACE_WARNING("Out of lcbs");
@ -358,13 +344,10 @@ void avct_lcb_dealloc(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data)
AVCT_TRACE_DEBUG("avct_lcb_dealloc %d", p_lcb->allocated); AVCT_TRACE_DEBUG("avct_lcb_dealloc %d", p_lcb->allocated);
for (i = 0; i < AVCT_NUM_CONN; i++, p_ccb++) for (i = 0; i < AVCT_NUM_CONN; i++, p_ccb++) {
{
/* if ccb allocated and */ /* if ccb allocated and */
if (p_ccb->allocated) if (p_ccb->allocated) {
{ if (p_ccb->p_lcb == p_lcb) {
if (p_ccb->p_lcb == p_lcb)
{
AVCT_TRACE_DEBUG("avct_lcb_dealloc used by ccb: %d", i); AVCT_TRACE_DEBUG("avct_lcb_dealloc used by ccb: %d", i);
found = TRUE; found = TRUE;
break; break;
@ -372,13 +355,11 @@ void avct_lcb_dealloc(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data)
} }
} }
if (!found) if (!found) {
{
AVCT_TRACE_DEBUG("avct_lcb_dealloc now"); AVCT_TRACE_DEBUG("avct_lcb_dealloc now");
/* clear reassembled msg buffer if in use */ /* clear reassembled msg buffer if in use */
if (p_lcb->p_rx_msg != NULL) if (p_lcb->p_rx_msg != NULL) {
{
GKI_freebuf(p_lcb->p_rx_msg); GKI_freebuf(p_lcb->p_rx_msg);
} }
memset(p_lcb, 0, sizeof(tAVCT_LCB)); memset(p_lcb, 0, sizeof(tAVCT_LCB));
@ -400,16 +381,13 @@ tAVCT_LCB *avct_lcb_by_lcid(UINT16 lcid)
tAVCT_LCB *p_lcb = &avct_cb.lcb[0]; tAVCT_LCB *p_lcb = &avct_cb.lcb[0];
int i; int i;
for (i = 0; i < AVCT_NUM_LINKS; i++, p_lcb++) for (i = 0; i < AVCT_NUM_LINKS; i++, p_lcb++) {
{ if (p_lcb->allocated && ((p_lcb->ch_lcid == lcid) || (p_lcb->conflict_lcid == lcid))) {
if (p_lcb->allocated && ((p_lcb->ch_lcid == lcid) || (p_lcb->conflict_lcid == lcid)))
{
break; break;
} }
} }
if (i == AVCT_NUM_LINKS) if (i == AVCT_NUM_LINKS) {
{
/* out of lcbs */ /* out of lcbs */
p_lcb = NULL; p_lcb = NULL;
AVCT_TRACE_WARNING("No lcb for lcid %x", lcid); AVCT_TRACE_WARNING("No lcb for lcid %x", lcid);
@ -433,10 +411,8 @@ tAVCT_CCB *avct_lcb_has_pid(tAVCT_LCB *p_lcb, UINT16 pid)
tAVCT_CCB *p_ccb = &avct_cb.ccb[0]; tAVCT_CCB *p_ccb = &avct_cb.ccb[0];
int i; int i;
for (i = 0; i < AVCT_NUM_CONN; i++, p_ccb++) for (i = 0; i < AVCT_NUM_CONN; i++, p_ccb++) {
{ if (p_ccb->allocated && (p_ccb->p_lcb == p_lcb) && (p_ccb->cc.pid == pid)) {
if (p_ccb->allocated && (p_ccb->p_lcb == p_lcb) && (p_ccb->cc.pid == pid))
{
return p_ccb; return p_ccb;
} }
} }
@ -459,12 +435,10 @@ BOOLEAN avct_lcb_last_ccb(tAVCT_LCB *p_lcb, tAVCT_CCB *p_ccb_last)
int i; int i;
AVCT_TRACE_WARNING("avct_lcb_last_ccb"); AVCT_TRACE_WARNING("avct_lcb_last_ccb");
for (i = 0; i < AVCT_NUM_CONN; i++, p_ccb++) for (i = 0; i < AVCT_NUM_CONN; i++, p_ccb++) {
{
AVCT_TRACE_WARNING("%x: aloc:%d, lcb:%p/%p, ccb:%p/%p", AVCT_TRACE_WARNING("%x: aloc:%d, lcb:%p/%p, ccb:%p/%p",
i, p_ccb->allocated, p_ccb->p_lcb, p_lcb, p_ccb, p_ccb_last); i, p_ccb->allocated, p_ccb->p_lcb, p_lcb, p_ccb, p_ccb_last);
if (p_ccb->allocated && (p_ccb->p_lcb == p_lcb) && (p_ccb != p_ccb_last)) if (p_ccb->allocated && (p_ccb->p_lcb == p_lcb) && (p_ccb != p_ccb_last)) {
{
return FALSE; return FALSE;
} }
} }

192
components/bt/bluedroid/stack/avct/avct_lcb_act.c Executable file → Normal file
View file

@ -64,18 +64,15 @@ static BT_HDR *avct_lcb_msg_asmbl(tAVCT_LCB *p_lcb, BT_HDR *p_buf)
AVCT_PRS_PKT_TYPE(p, pkt_type); AVCT_PRS_PKT_TYPE(p, pkt_type);
/* quick sanity check on length */ /* quick sanity check on length */
if (p_buf->len < avct_lcb_pkt_type_len[pkt_type]) if (p_buf->len < avct_lcb_pkt_type_len[pkt_type]) {
{
GKI_freebuf(p_buf); GKI_freebuf(p_buf);
AVCT_TRACE_WARNING("Bad length during reassembly"); AVCT_TRACE_WARNING("Bad length during reassembly");
p_ret = NULL; p_ret = NULL;
} }
/* single packet */ /* single packet */
else if (pkt_type == AVCT_PKT_TYPE_SINGLE) else if (pkt_type == AVCT_PKT_TYPE_SINGLE) {
{
/* if reassembly in progress drop message and process new single */ /* if reassembly in progress drop message and process new single */
if (p_lcb->p_rx_msg != NULL) if (p_lcb->p_rx_msg != NULL) {
{
GKI_freebuf(p_lcb->p_rx_msg); GKI_freebuf(p_lcb->p_rx_msg);
p_lcb->p_rx_msg = NULL; p_lcb->p_rx_msg = NULL;
AVCT_TRACE_WARNING("Got single during reassembly"); AVCT_TRACE_WARNING("Got single during reassembly");
@ -83,11 +80,9 @@ static BT_HDR *avct_lcb_msg_asmbl(tAVCT_LCB *p_lcb, BT_HDR *p_buf)
p_ret = p_buf; p_ret = p_buf;
} }
/* start packet */ /* start packet */
else if (pkt_type == AVCT_PKT_TYPE_START) else if (pkt_type == AVCT_PKT_TYPE_START) {
{
/* if reassembly in progress drop message and process new start */ /* if reassembly in progress drop message and process new start */
if (p_lcb->p_rx_msg != NULL) if (p_lcb->p_rx_msg != NULL) {
{
GKI_freebuf(p_lcb->p_rx_msg); GKI_freebuf(p_lcb->p_rx_msg);
AVCT_TRACE_WARNING("Got start during reassembly"); AVCT_TRACE_WARNING("Got start during reassembly");
} }
@ -96,13 +91,10 @@ static BT_HDR *avct_lcb_msg_asmbl(tAVCT_LCB *p_lcb, BT_HDR *p_buf)
* would have allocated smaller buffer. * would have allocated smaller buffer.
*/ */
p_lcb->p_rx_msg = (BT_HDR *)GKI_getbuf(GKI_MAX_BUF_SIZE); p_lcb->p_rx_msg = (BT_HDR *)GKI_getbuf(GKI_MAX_BUF_SIZE);
if (p_lcb->p_rx_msg == NULL) if (p_lcb->p_rx_msg == NULL) {
{
AVCT_TRACE_ERROR ("Cannot alloc buffer for reassembly !!"); AVCT_TRACE_ERROR ("Cannot alloc buffer for reassembly !!");
GKI_freebuf(p_buf); GKI_freebuf(p_buf);
} } else {
else
{
memcpy (p_lcb->p_rx_msg, p_buf, memcpy (p_lcb->p_rx_msg, p_buf,
sizeof(BT_HDR) + p_buf->offset + p_buf->len); sizeof(BT_HDR) + p_buf->offset + p_buf->len);
/* Free original buffer */ /* Free original buffer */
@ -123,17 +115,13 @@ static BT_HDR *avct_lcb_msg_asmbl(tAVCT_LCB *p_lcb, BT_HDR *p_buf)
p_ret = NULL; p_ret = NULL;
} }
/* continue or end */ /* continue or end */
else else {
{
/* if no reassembly in progress drop message */ /* if no reassembly in progress drop message */
if (p_lcb->p_rx_msg == NULL) if (p_lcb->p_rx_msg == NULL) {
{
GKI_freebuf(p_buf); GKI_freebuf(p_buf);
AVCT_TRACE_WARNING("Pkt type=%d out of order", pkt_type); AVCT_TRACE_WARNING("Pkt type=%d out of order", pkt_type);
p_ret = NULL; p_ret = NULL;
} } else {
else
{
/* get size of buffer holding assembled message */ /* get size of buffer holding assembled message */
buf_len = GKI_get_buf_size(p_lcb->p_rx_msg) - sizeof(BT_HDR); buf_len = GKI_get_buf_size(p_lcb->p_rx_msg) - sizeof(BT_HDR);
@ -142,30 +130,24 @@ static BT_HDR *avct_lcb_msg_asmbl(tAVCT_LCB *p_lcb, BT_HDR *p_buf)
p_buf->len -= AVCT_HDR_LEN_CONT; p_buf->len -= AVCT_HDR_LEN_CONT;
/* verify length */ /* verify length */
if ((p_lcb->p_rx_msg->offset + p_buf->len) > buf_len) if ((p_lcb->p_rx_msg->offset + p_buf->len) > buf_len) {
{
/* won't fit; free everything */ /* won't fit; free everything */
GKI_freebuf(p_lcb->p_rx_msg); GKI_freebuf(p_lcb->p_rx_msg);
p_lcb->p_rx_msg = NULL; p_lcb->p_rx_msg = NULL;
GKI_freebuf(p_buf); GKI_freebuf(p_buf);
p_ret = NULL; p_ret = NULL;
AVCT_TRACE_WARNING("Fragmented message to big!"); AVCT_TRACE_WARNING("Fragmented message to big!");
} } else {
else
{
/* copy contents of p_buf to p_rx_msg */ /* copy contents of p_buf to p_rx_msg */
memcpy((UINT8 *)(p_lcb->p_rx_msg + 1) + p_lcb->p_rx_msg->offset, memcpy((UINT8 *)(p_lcb->p_rx_msg + 1) + p_lcb->p_rx_msg->offset,
(UINT8 *)(p_buf + 1) + p_buf->offset, p_buf->len); (UINT8 *)(p_buf + 1) + p_buf->offset, p_buf->len);
if (pkt_type == AVCT_PKT_TYPE_END) if (pkt_type == AVCT_PKT_TYPE_END) {
{
p_lcb->p_rx_msg->offset -= p_lcb->p_rx_msg->len; p_lcb->p_rx_msg->offset -= p_lcb->p_rx_msg->len;
p_lcb->p_rx_msg->len += p_buf->len; p_lcb->p_rx_msg->len += p_buf->len;
p_ret = p_lcb->p_rx_msg; p_ret = p_lcb->p_rx_msg;
p_lcb->p_rx_msg = NULL; p_lcb->p_rx_msg = NULL;
} } else {
else
{
p_lcb->p_rx_msg->offset += p_buf->len; p_lcb->p_rx_msg->offset += p_buf->len;
p_lcb->p_rx_msg->len += p_buf->len; p_lcb->p_rx_msg->len += p_buf->len;
p_ret = NULL; p_ret = NULL;
@ -196,8 +178,7 @@ void avct_lcb_chnl_open(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data)
BTM_SetOutService(p_lcb->peer_addr, BTM_SEC_SERVICE_AVCTP, 0); BTM_SetOutService(p_lcb->peer_addr, BTM_SEC_SERVICE_AVCTP, 0);
/* call l2cap connect req */ /* call l2cap connect req */
p_lcb->ch_state = AVCT_CH_CONN; p_lcb->ch_state = AVCT_CH_CONN;
if ((p_lcb->ch_lcid = L2CA_ConnectReq(AVCT_PSM, p_lcb->peer_addr)) == 0) if ((p_lcb->ch_lcid = L2CA_ConnectReq(AVCT_PSM, p_lcb->peer_addr)) == 0) {
{
/* if connect req failed, send ourselves close event */ /* if connect req failed, send ourselves close event */
avct_lcb_event(p_lcb, AVCT_LCB_LL_CLOSE_EVT, (tAVCT_LCB_EVT *) &result); avct_lcb_event(p_lcb, AVCT_LCB_LL_CLOSE_EVT, (tAVCT_LCB_EVT *) &result);
} }
@ -239,14 +220,11 @@ void avct_lcb_open_ind(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data)
int i; int i;
BOOLEAN bind = FALSE; BOOLEAN bind = FALSE;
for (i = 0; i < AVCT_NUM_CONN; i++, p_ccb++) for (i = 0; i < AVCT_NUM_CONN; i++, p_ccb++) {
{
/* if ccb allocated and */ /* if ccb allocated and */
if (p_ccb->allocated) if (p_ccb->allocated) {
{
/* if bound to this lcb send connect confirm event */ /* if bound to this lcb send connect confirm event */
if (p_ccb->p_lcb == p_lcb) if (p_ccb->p_lcb == p_lcb) {
{
bind = TRUE; bind = TRUE;
L2CA_SetTxPriority(p_lcb->ch_lcid, L2CAP_CHNL_PRIORITY_HIGH); L2CA_SetTxPriority(p_lcb->ch_lcid, L2CAP_CHNL_PRIORITY_HIGH);
p_ccb->cc.p_ctrl_cback(avct_ccb_to_idx(p_ccb), AVCT_CONNECT_CFM_EVT, p_ccb->cc.p_ctrl_cback(avct_ccb_to_idx(p_ccb), AVCT_CONNECT_CFM_EVT,
@ -254,8 +232,7 @@ void avct_lcb_open_ind(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data)
} }
/* if unbound acceptor and lcb doesn't already have a ccb for this PID */ /* if unbound acceptor and lcb doesn't already have a ccb for this PID */
else if ((p_ccb->p_lcb == NULL) && (p_ccb->cc.role == AVCT_ACP) && else if ((p_ccb->p_lcb == NULL) && (p_ccb->cc.role == AVCT_ACP) &&
(avct_lcb_has_pid(p_lcb, p_ccb->cc.pid) == NULL)) (avct_lcb_has_pid(p_lcb, p_ccb->cc.pid) == NULL)) {
{
/* bind ccb to lcb and send connect ind event */ /* bind ccb to lcb and send connect ind event */
bind = TRUE; bind = TRUE;
p_ccb->p_lcb = p_lcb; p_ccb->p_lcb = p_lcb;
@ -267,8 +244,7 @@ void avct_lcb_open_ind(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data)
} }
/* if no ccbs bound to this lcb, disconnect */ /* if no ccbs bound to this lcb, disconnect */
if (bind == FALSE) if (bind == FALSE) {
{
avct_lcb_event(p_lcb, AVCT_LCB_INT_CLOSE_EVT, p_data); avct_lcb_event(p_lcb, AVCT_LCB_INT_CLOSE_EVT, p_data);
} }
} }
@ -289,10 +265,8 @@ void avct_lcb_open_fail(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data)
tAVCT_CCB *p_ccb = &avct_cb.ccb[0]; tAVCT_CCB *p_ccb = &avct_cb.ccb[0];
int i; int i;
for (i = 0; i < AVCT_NUM_CONN; i++, p_ccb++) for (i = 0; i < AVCT_NUM_CONN; i++, p_ccb++) {
{ if (p_ccb->allocated && (p_ccb->p_lcb == p_lcb)) {
if (p_ccb->allocated && (p_ccb->p_lcb == p_lcb))
{
avct_ccb_dealloc(p_ccb, AVCT_CONNECT_CFM_EVT, avct_ccb_dealloc(p_ccb, AVCT_CONNECT_CFM_EVT,
p_data->result, p_lcb->peer_addr); p_data->result, p_lcb->peer_addr);
} }
@ -316,17 +290,12 @@ void avct_lcb_close_ind(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data)
int i; int i;
UNUSED(p_data); UNUSED(p_data);
for (i = 0; i < AVCT_NUM_CONN; i++, p_ccb++) for (i = 0; i < AVCT_NUM_CONN; i++, p_ccb++) {
{ if (p_ccb->allocated && (p_ccb->p_lcb == p_lcb)) {
if (p_ccb->allocated && (p_ccb->p_lcb == p_lcb)) if (p_ccb->cc.role == AVCT_INT) {
{
if (p_ccb->cc.role == AVCT_INT)
{
avct_ccb_dealloc(p_ccb, AVCT_DISCONNECT_IND_EVT, avct_ccb_dealloc(p_ccb, AVCT_DISCONNECT_IND_EVT,
0, p_lcb->peer_addr); 0, p_lcb->peer_addr);
} } else {
else
{
p_ccb->p_lcb = NULL; p_ccb->p_lcb = NULL;
(*p_ccb->cc.p_ctrl_cback)(avct_ccb_to_idx(p_ccb), AVCT_DISCONNECT_IND_EVT, (*p_ccb->cc.p_ctrl_cback)(avct_ccb_to_idx(p_ccb), AVCT_DISCONNECT_IND_EVT,
0, p_lcb->peer_addr); 0, p_lcb->peer_addr);
@ -352,27 +321,19 @@ void avct_lcb_close_cfm(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data)
int i; int i;
UINT8 event; UINT8 event;
for (i = 0; i < AVCT_NUM_CONN; i++, p_ccb++) for (i = 0; i < AVCT_NUM_CONN; i++, p_ccb++) {
{ if (p_ccb->allocated && (p_ccb->p_lcb == p_lcb)) {
if (p_ccb->allocated && (p_ccb->p_lcb == p_lcb))
{
/* if this ccb initiated close send disconnect cfm otherwise ind */ /* if this ccb initiated close send disconnect cfm otherwise ind */
if (p_ccb->ch_close) if (p_ccb->ch_close) {
{
p_ccb->ch_close = FALSE; p_ccb->ch_close = FALSE;
event = AVCT_DISCONNECT_CFM_EVT; event = AVCT_DISCONNECT_CFM_EVT;
} } else {
else
{
event = AVCT_DISCONNECT_IND_EVT; event = AVCT_DISCONNECT_IND_EVT;
} }
if (p_ccb->cc.role == AVCT_INT) if (p_ccb->cc.role == AVCT_INT) {
{
avct_ccb_dealloc(p_ccb, event, p_data->result, p_lcb->peer_addr); avct_ccb_dealloc(p_ccb, event, p_data->result, p_lcb->peer_addr);
} } else {
else
{
p_ccb->p_lcb = NULL; p_ccb->p_lcb = NULL;
(*p_ccb->cc.p_ctrl_cback)(avct_ccb_to_idx(p_ccb), event, (*p_ccb->cc.p_ctrl_cback)(avct_ccb_to_idx(p_ccb), event,
p_data->result, p_lcb->peer_addr); p_data->result, p_lcb->peer_addr);
@ -416,14 +377,11 @@ void avct_lcb_chk_disc(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data)
#if (AVCT_BROWSE_INCLUDED == TRUE) #if (AVCT_BROWSE_INCLUDED == TRUE)
avct_close_bcb(p_lcb, p_data); avct_close_bcb(p_lcb, p_data);
#endif #endif
if (avct_lcb_last_ccb(p_lcb, p_data->p_ccb)) if (avct_lcb_last_ccb(p_lcb, p_data->p_ccb)) {
{
AVCT_TRACE_WARNING("closing"); AVCT_TRACE_WARNING("closing");
p_data->p_ccb->ch_close = TRUE; p_data->p_ccb->ch_close = TRUE;
avct_lcb_event(p_lcb, AVCT_LCB_INT_CLOSE_EVT, p_data); avct_lcb_event(p_lcb, AVCT_LCB_INT_CLOSE_EVT, p_data);
} } else {
else
{
AVCT_TRACE_WARNING("dealloc ccb"); AVCT_TRACE_WARNING("dealloc ccb");
avct_lcb_unbind_disc(p_lcb, p_data); avct_lcb_unbind_disc(p_lcb, p_data);
} }
@ -484,22 +442,17 @@ void avct_lcb_cong_ind(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data)
/* set event */ /* set event */
event = (p_data->cong) ? AVCT_CONG_IND_EVT : AVCT_UNCONG_IND_EVT; event = (p_data->cong) ? AVCT_CONG_IND_EVT : AVCT_UNCONG_IND_EVT;
p_lcb->cong = p_data->cong; p_lcb->cong = p_data->cong;
if (p_lcb->cong == FALSE && GKI_getfirst(&p_lcb->tx_q)) if (p_lcb->cong == FALSE && GKI_getfirst(&p_lcb->tx_q)) {
{ while ( !p_lcb->cong && (p_buf = (BT_HDR *)GKI_dequeue(&p_lcb->tx_q)) != NULL) {
while ( !p_lcb->cong && (p_buf = (BT_HDR *)GKI_dequeue(&p_lcb->tx_q)) != NULL) if (L2CA_DataWrite(p_lcb->ch_lcid, p_buf) == L2CAP_DW_CONGESTED) {
{
if (L2CA_DataWrite(p_lcb->ch_lcid, p_buf) == L2CAP_DW_CONGESTED)
{
p_lcb->cong = TRUE; p_lcb->cong = TRUE;
} }
} }
} }
/* send event to all ccbs on this lcb */ /* send event to all ccbs on this lcb */
for (i = 0; i < AVCT_NUM_CONN; i++, p_ccb++) for (i = 0; i < AVCT_NUM_CONN; i++, p_ccb++) {
{ if (p_ccb->allocated && (p_ccb->p_lcb == p_lcb)) {
if (p_ccb->allocated && (p_ccb->p_lcb == p_lcb))
{
(*p_ccb->cc.p_ctrl_cback)(avct_ccb_to_idx(p_ccb), event, 0, p_lcb->peer_addr); (*p_ccb->cc.p_ctrl_cback)(avct_ccb_to_idx(p_ccb), event, 0, p_lcb->peer_addr);
} }
} }
@ -550,31 +503,26 @@ void avct_lcb_send_msg(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data)
curr_msg_len = p_data->ul_msg.p_buf->len; curr_msg_len = p_data->ul_msg.p_buf->len;
/* initialize packet type and other stuff */ /* initialize packet type and other stuff */
if (curr_msg_len <= (p_lcb->peer_mtu - AVCT_HDR_LEN_SINGLE)) if (curr_msg_len <= (p_lcb->peer_mtu - AVCT_HDR_LEN_SINGLE)) {
{
pkt_type = AVCT_PKT_TYPE_SINGLE; pkt_type = AVCT_PKT_TYPE_SINGLE;
} } else {
else
{
pkt_type = AVCT_PKT_TYPE_START; pkt_type = AVCT_PKT_TYPE_START;
temp = (curr_msg_len + AVCT_HDR_LEN_START - p_lcb->peer_mtu); temp = (curr_msg_len + AVCT_HDR_LEN_START - p_lcb->peer_mtu);
nosp = temp / (p_lcb->peer_mtu - 1) + 1; nosp = temp / (p_lcb->peer_mtu - 1) + 1;
if ( (temp % (p_lcb->peer_mtu - 1)) != 0) if ( (temp % (p_lcb->peer_mtu - 1)) != 0) {
nosp++; nosp++;
} }
}
/* while we haven't sent all packets */ /* while we haven't sent all packets */
while (curr_msg_len != 0) while (curr_msg_len != 0) {
{
/* set header len */ /* set header len */
hdr_len = avct_lcb_pkt_type_len[pkt_type]; hdr_len = avct_lcb_pkt_type_len[pkt_type];
/* if remaining msg must be fragmented */ /* if remaining msg must be fragmented */
if (p_data->ul_msg.p_buf->len > (p_lcb->peer_mtu - hdr_len)) if (p_data->ul_msg.p_buf->len > (p_lcb->peer_mtu - hdr_len)) {
{
/* get a new buffer for fragment we are sending */ /* get a new buffer for fragment we are sending */
if ((p_buf = (BT_HDR *) GKI_getbuf(buf_size)) == NULL) if ((p_buf = (BT_HDR *) GKI_getbuf(buf_size)) == NULL) {
{
/* whoops; free original msg buf and bail */ /* whoops; free original msg buf and bail */
AVCT_TRACE_ERROR ("avct_lcb_send_msg cannot alloc buffer!!"); AVCT_TRACE_ERROR ("avct_lcb_send_msg cannot alloc buffer!!");
GKI_freebuf(p_data->ul_msg.p_buf); GKI_freebuf(p_data->ul_msg.p_buf);
@ -590,9 +538,7 @@ void avct_lcb_send_msg(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data)
p_data->ul_msg.p_buf->offset += p_buf->len; p_data->ul_msg.p_buf->offset += p_buf->len;
p_data->ul_msg.p_buf->len -= p_buf->len; p_data->ul_msg.p_buf->len -= p_buf->len;
} } else {
else
{
p_buf = p_data->ul_msg.p_buf; p_buf = p_data->ul_msg.p_buf;
} }
@ -605,36 +551,28 @@ void avct_lcb_send_msg(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data)
/* build header */ /* build header */
AVCT_BLD_HDR(p, p_data->ul_msg.label, pkt_type, p_data->ul_msg.cr); AVCT_BLD_HDR(p, p_data->ul_msg.label, pkt_type, p_data->ul_msg.cr);
if (pkt_type == AVCT_PKT_TYPE_START) if (pkt_type == AVCT_PKT_TYPE_START) {
{
UINT8_TO_STREAM(p, nosp); UINT8_TO_STREAM(p, nosp);
} }
if ((pkt_type == AVCT_PKT_TYPE_START) || (pkt_type == AVCT_PKT_TYPE_SINGLE)) if ((pkt_type == AVCT_PKT_TYPE_START) || (pkt_type == AVCT_PKT_TYPE_SINGLE)) {
{
UINT16_TO_BE_STREAM(p, p_data->ul_msg.p_ccb->cc.pid); UINT16_TO_BE_STREAM(p, p_data->ul_msg.p_ccb->cc.pid);
} }
if (p_lcb->cong == TRUE) if (p_lcb->cong == TRUE) {
{
GKI_enqueue (&p_lcb->tx_q, p_buf); GKI_enqueue (&p_lcb->tx_q, p_buf);
} }
/* send message to L2CAP */ /* send message to L2CAP */
else else {
{ if (L2CA_DataWrite(p_lcb->ch_lcid, p_buf) == L2CAP_DW_CONGESTED) {
if (L2CA_DataWrite(p_lcb->ch_lcid, p_buf) == L2CAP_DW_CONGESTED)
{
p_lcb->cong = TRUE; p_lcb->cong = TRUE;
} }
} }
/* update pkt type for next packet */ /* update pkt type for next packet */
if (curr_msg_len > (p_lcb->peer_mtu - AVCT_HDR_LEN_END)) if (curr_msg_len > (p_lcb->peer_mtu - AVCT_HDR_LEN_END)) {
{
pkt_type = AVCT_PKT_TYPE_CONT; pkt_type = AVCT_PKT_TYPE_CONT;
} } else {
else
{
pkt_type = AVCT_PKT_TYPE_END; pkt_type = AVCT_PKT_TYPE_END;
} }
} }
@ -656,8 +594,9 @@ void avct_lcb_free_msg_ind(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data)
{ {
UNUSED(p_lcb); UNUSED(p_lcb);
if (p_data) if (p_data) {
GKI_freebuf(p_data->p_buf); GKI_freebuf(p_data->p_buf);
}
return; return;
} }
@ -685,8 +624,7 @@ void avct_lcb_msg_ind(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data)
p_data->p_buf->layer_specific = AVCT_DATA_CTRL; p_data->p_buf->layer_specific = AVCT_DATA_CTRL;
/* reassemble message; if no message available (we received a fragment) return */ /* reassemble message; if no message available (we received a fragment) return */
if ((p_data->p_buf = avct_lcb_msg_asmbl(p_lcb, p_data->p_buf)) == NULL) if ((p_data->p_buf = avct_lcb_msg_asmbl(p_lcb, p_data->p_buf)) == NULL) {
{
return; return;
} }
@ -697,8 +635,7 @@ void avct_lcb_msg_ind(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data)
UNUSED(type); UNUSED(type);
/* check for invalid cr_ipid */ /* check for invalid cr_ipid */
if (cr_ipid == AVCT_CR_IPID_INVALID) if (cr_ipid == AVCT_CR_IPID_INVALID) {
{
AVCT_TRACE_WARNING("Invalid cr_ipid %d", cr_ipid); AVCT_TRACE_WARNING("Invalid cr_ipid %d", cr_ipid);
GKI_freebuf(p_data->p_buf); GKI_freebuf(p_data->p_buf);
return; return;
@ -706,24 +643,19 @@ void avct_lcb_msg_ind(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data)
/* parse and lookup PID */ /* parse and lookup PID */
BE_STREAM_TO_UINT16(pid, p); BE_STREAM_TO_UINT16(pid, p);
if ((p_ccb = avct_lcb_has_pid(p_lcb, pid)) != NULL) if ((p_ccb = avct_lcb_has_pid(p_lcb, pid)) != NULL) {
{
/* PID found; send msg up, adjust bt hdr and call msg callback */ /* PID found; send msg up, adjust bt hdr and call msg callback */
p_data->p_buf->offset += AVCT_HDR_LEN_SINGLE; p_data->p_buf->offset += AVCT_HDR_LEN_SINGLE;
p_data->p_buf->len -= AVCT_HDR_LEN_SINGLE; p_data->p_buf->len -= AVCT_HDR_LEN_SINGLE;
(*p_ccb->cc.p_msg_cback)(avct_ccb_to_idx(p_ccb), label, cr_ipid, p_data->p_buf); (*p_ccb->cc.p_msg_cback)(avct_ccb_to_idx(p_ccb), label, cr_ipid, p_data->p_buf);
} } else {
else
{
/* PID not found; drop message */ /* PID not found; drop message */
AVCT_TRACE_WARNING("No ccb for PID=%x", pid); AVCT_TRACE_WARNING("No ccb for PID=%x", pid);
GKI_freebuf(p_data->p_buf); GKI_freebuf(p_data->p_buf);
/* if command send reject */ /* if command send reject */
if (cr_ipid == AVCT_CMD) if (cr_ipid == AVCT_CMD) {
{ if ((p_buf = (BT_HDR *) GKI_getpoolbuf(AVCT_CMD_POOL_ID)) != NULL) {
if ((p_buf = (BT_HDR *) GKI_getpoolbuf(AVCT_CMD_POOL_ID)) != NULL)
{
p_buf->len = AVCT_HDR_LEN_SINGLE; p_buf->len = AVCT_HDR_LEN_SINGLE;
p_buf->offset = AVCT_MSG_OFFSET - AVCT_HDR_LEN_SINGLE; p_buf->offset = AVCT_MSG_OFFSET - AVCT_HDR_LEN_SINGLE;
p = (UINT8 *)(p_buf + 1) + p_buf->offset; p = (UINT8 *)(p_buf + 1) + p_buf->offset;

0
components/bt/bluedroid/stack/avct/include/avct_int.h Executable file → Normal file
View file

137
components/bt/bluedroid/stack/avdt/avdt_ad.c Executable file → Normal file
View file

@ -50,12 +50,9 @@ UINT8 avdt_ad_type_to_tcid(UINT8 type, tAVDT_SCB *p_scb)
{ {
UINT8 scb_idx; UINT8 scb_idx;
if (type == AVDT_CHAN_SIG) if (type == AVDT_CHAN_SIG) {
{
return 0; return 0;
} } else {
else
{
scb_idx = avdt_scb_to_hdl(p_scb) - 1; scb_idx = avdt_scb_to_hdl(p_scb) - 1;
/* /*
AVDT_TRACE_DEBUG("type: %d, tcid: %d", type, ((scb_idx * (AVDT_CHAN_NUM_TYPES - 1)) + type)); AVDT_TRACE_DEBUG("type: %d, tcid: %d", type, ((scb_idx * (AVDT_CHAN_NUM_TYPES - 1)) + type));
@ -78,12 +75,9 @@ static UINT8 avdt_ad_tcid_to_type(UINT8 tcid)
{ {
UINT8 type; UINT8 type;
if (tcid == 0) if (tcid == 0) {
{
type = AVDT_CHAN_SIG; type = AVDT_CHAN_SIG;
} } else {
else
{
/* tcid translates to type based on number of channels, as follows: /* tcid translates to type based on number of channels, as follows:
** only media channel : tcid=1,2,3,4,5,6... type=1,1,1,1,1,1... ** only media channel : tcid=1,2,3,4,5,6... type=1,1,1,1,1,1...
** media and report : tcid=1,2,3,4,5,6... type=1,2,1,2,1,2... ** media and report : tcid=1,2,3,4,5,6... type=1,2,1,2,1,2...
@ -113,8 +107,7 @@ void avdt_ad_init(void)
memset(&avdt_cb.ad, 0, sizeof(tAVDT_AD)); memset(&avdt_cb.ad, 0, sizeof(tAVDT_AD));
/* make sure the peer_mtu is a valid value */ /* make sure the peer_mtu is a valid value */
for (i = 0; i < AVDT_NUM_TC_TBL; i++, p_tbl++) for (i = 0; i < AVDT_NUM_TC_TBL; i++, p_tbl++) {
{
p_tbl->peer_mtu = L2CAP_DEFAULT_MTU; p_tbl->peer_mtu = L2CAP_DEFAULT_MTU;
} }
} }
@ -139,42 +132,31 @@ tAVDT_TC_TBL *avdt_ad_tc_tbl_by_st(UINT8 type, tAVDT_CCB *p_ccb, UINT8 state)
tAVDT_TC_TBL *p_tbl = avdt_cb.ad.tc_tbl; tAVDT_TC_TBL *p_tbl = avdt_cb.ad.tc_tbl;
UINT8 ccb_idx; UINT8 ccb_idx;
if (p_ccb == NULL) if (p_ccb == NULL) {
{
/* resending security req */ /* resending security req */
for (i = 0; i < AVDT_NUM_TC_TBL; i++, p_tbl++) for (i = 0; i < AVDT_NUM_TC_TBL; i++, p_tbl++) {
{
/* must be AVDT_CHAN_SIG - tcid always zero */ /* must be AVDT_CHAN_SIG - tcid always zero */
if ((p_tbl->tcid == 0) && if ((p_tbl->tcid == 0) &&
(p_tbl->state == state)) (p_tbl->state == state)) {
{
break; break;
} }
} }
} } else {
else
{
ccb_idx = avdt_ccb_to_idx(p_ccb); ccb_idx = avdt_ccb_to_idx(p_ccb);
for (i = 0; i < AVDT_NUM_TC_TBL; i++, p_tbl++) for (i = 0; i < AVDT_NUM_TC_TBL; i++, p_tbl++) {
{ if (type == AVDT_CHAN_SIG) {
if (type == AVDT_CHAN_SIG)
{
/* if control channel, tcid always zero */ /* if control channel, tcid always zero */
if ((p_tbl->tcid == 0) && if ((p_tbl->tcid == 0) &&
(p_tbl->ccb_idx == ccb_idx) && (p_tbl->ccb_idx == ccb_idx) &&
(p_tbl->state == state)) (p_tbl->state == state)) {
{
break; break;
} }
} } else {
else
{
/* if other channel, tcid is always > zero */ /* if other channel, tcid is always > zero */
if ((p_tbl->tcid > 0) && if ((p_tbl->tcid > 0) &&
(p_tbl->ccb_idx == ccb_idx) && (p_tbl->ccb_idx == ccb_idx) &&
(p_tbl->state == state)) (p_tbl->state == state)) {
{
break; break;
} }
} }
@ -182,8 +164,7 @@ tAVDT_TC_TBL *avdt_ad_tc_tbl_by_st(UINT8 type, tAVDT_CCB *p_ccb, UINT8 state)
} }
/* if nothing found return null */ /* if nothing found return null */
if (i == AVDT_NUM_TC_TBL) if (i == AVDT_NUM_TC_TBL) {
{
p_tbl = NULL; p_tbl = NULL;
} }
@ -207,12 +188,9 @@ tAVDT_TC_TBL *avdt_ad_tc_tbl_by_lcid(UINT16 lcid)
idx = avdt_cb.ad.lcid_tbl[lcid - L2CAP_BASE_APPL_CID]; idx = avdt_cb.ad.lcid_tbl[lcid - L2CAP_BASE_APPL_CID];
if (idx < AVDT_NUM_TC_TBL) if (idx < AVDT_NUM_TC_TBL) {
{
return &avdt_cb.ad.tc_tbl[idx]; return &avdt_cb.ad.tc_tbl[idx];
} } else {
else
{
return NULL; return NULL;
} }
} }
@ -239,10 +217,8 @@ tAVDT_TC_TBL *avdt_ad_tc_tbl_by_type(UINT8 type, tAVDT_CCB *p_ccb, tAVDT_SCB *p_
/* get tcid from type, scb */ /* get tcid from type, scb */
tcid = avdt_ad_type_to_tcid(type, p_scb); tcid = avdt_ad_type_to_tcid(type, p_scb);
for (i = 0; i < AVDT_NUM_TC_TBL; i++, p_tbl++) for (i = 0; i < AVDT_NUM_TC_TBL; i++, p_tbl++) {
{ if ((p_tbl->tcid == tcid) && (p_tbl->ccb_idx == ccb_idx)) {
if ((p_tbl->tcid == tcid) && (p_tbl->ccb_idx == ccb_idx))
{
break; break;
} }
} }
@ -269,10 +245,8 @@ tAVDT_TC_TBL *avdt_ad_tc_tbl_alloc(tAVDT_CCB *p_ccb)
tAVDT_TC_TBL *p_tbl = avdt_cb.ad.tc_tbl; tAVDT_TC_TBL *p_tbl = avdt_cb.ad.tc_tbl;
/* find next free entry in tc table */ /* find next free entry in tc table */
for (i = 0; i < AVDT_NUM_TC_TBL; i++, p_tbl++) for (i = 0; i < AVDT_NUM_TC_TBL; i++, p_tbl++) {
{ if (p_tbl->state == AVDT_AD_ST_UNUSED) {
if (p_tbl->state == AVDT_AD_ST_UNUSED)
{
break; break;
} }
} }
@ -339,19 +313,16 @@ void avdt_ad_tc_close_ind(tAVDT_TC_TBL *p_tbl, UINT16 reason)
p_tbl->tcid, close.old_tc_state); p_tbl->tcid, close.old_tc_state);
/* if signaling channel, notify ccb that channel open */ /* if signaling channel, notify ccb that channel open */
if (p_tbl->tcid == 0) if (p_tbl->tcid == 0) {
{
p_ccb = avdt_ccb_by_idx(p_tbl->ccb_idx); p_ccb = avdt_ccb_by_idx(p_tbl->ccb_idx);
p_ccb->disc_rsn = (reason == AVDT_DISC_RSN_ABNORMAL) ? AVDT_DISC_RSN_ABNORMAL : AVDT_DISC_RSN_NORMAL; p_ccb->disc_rsn = (reason == AVDT_DISC_RSN_ABNORMAL) ? AVDT_DISC_RSN_ABNORMAL : AVDT_DISC_RSN_NORMAL;
avdt_ccb_event(p_ccb, AVDT_CCB_LL_CLOSE_EVT, NULL); avdt_ccb_event(p_ccb, AVDT_CCB_LL_CLOSE_EVT, NULL);
} }
/* if media or other channel, notify scb that channel close */ /* if media or other channel, notify scb that channel close */
else else {
{
/* look up scb in stream routing table by ccb, tcid */ /* look up scb in stream routing table by ccb, tcid */
p_scb = avdt_scb_by_hdl(avdt_cb.ad.rt_tbl[p_tbl->ccb_idx][p_tbl->tcid].scb_hdl); p_scb = avdt_scb_by_hdl(avdt_cb.ad.rt_tbl[p_tbl->ccb_idx][p_tbl->tcid].scb_hdl);
if (p_scb != NULL) if (p_scb != NULL) {
{
close.tcid = p_tbl->tcid; close.tcid = p_tbl->tcid;
close.type = avdt_ad_tcid_to_type(p_tbl->tcid); close.type = avdt_ad_tcid_to_type(p_tbl->tcid);
close.disc_rsn = (reason == AVDT_DISC_RSN_ABNORMAL) ? AVDT_DISC_RSN_ABNORMAL : AVDT_DISC_RSN_NORMAL; close.disc_rsn = (reason == AVDT_DISC_RSN_ABNORMAL) ? AVDT_DISC_RSN_ABNORMAL : AVDT_DISC_RSN_NORMAL;
@ -382,8 +353,7 @@ void avdt_ad_tc_open_ind(tAVDT_TC_TBL *p_tbl)
p_tbl->state = AVDT_AD_ST_OPEN; p_tbl->state = AVDT_AD_ST_OPEN;
/* if signaling channel, notify ccb that channel open */ /* if signaling channel, notify ccb that channel open */
if (p_tbl->tcid == 0) if (p_tbl->tcid == 0) {
{
/* set the signal channel to use high priority within the ACL link */ /* set the signal channel to use high priority within the ACL link */
L2CA_SetTxPriority(avdt_cb.ad.rt_tbl[p_tbl->ccb_idx][AVDT_CHAN_SIG].lcid, L2CAP_CHNL_PRIORITY_HIGH); L2CA_SetTxPriority(avdt_cb.ad.rt_tbl[p_tbl->ccb_idx][AVDT_CHAN_SIG].lcid, L2CAP_CHNL_PRIORITY_HIGH);
@ -391,21 +361,18 @@ void avdt_ad_tc_open_ind(tAVDT_TC_TBL *p_tbl)
/* use err_param to indicate the role of connection. /* use err_param to indicate the role of connection.
* AVDT_ACP, if ACP */ * AVDT_ACP, if ACP */
evt.err_param = AVDT_INT; evt.err_param = AVDT_INT;
if(p_tbl->cfg_flags & AVDT_L2C_CFG_CONN_ACP) if (p_tbl->cfg_flags & AVDT_L2C_CFG_CONN_ACP) {
{
evt.err_param = AVDT_ACP; evt.err_param = AVDT_ACP;
} }
avdt_ccb_event(p_ccb, AVDT_CCB_LL_OPEN_EVT, (tAVDT_CCB_EVT *)&evt); avdt_ccb_event(p_ccb, AVDT_CCB_LL_OPEN_EVT, (tAVDT_CCB_EVT *)&evt);
} }
/* if media or other channel, notify scb that channel open */ /* if media or other channel, notify scb that channel open */
else else {
{
/* look up scb in stream routing table by ccb, tcid */ /* look up scb in stream routing table by ccb, tcid */
p_scb = avdt_scb_by_hdl(avdt_cb.ad.rt_tbl[p_tbl->ccb_idx][p_tbl->tcid].scb_hdl); p_scb = avdt_scb_by_hdl(avdt_cb.ad.rt_tbl[p_tbl->ccb_idx][p_tbl->tcid].scb_hdl);
/* put lcid in event data */ /* put lcid in event data */
if (p_scb != NULL) if (p_scb != NULL) {
{
open.peer_mtu = p_tbl->peer_mtu; open.peer_mtu = p_tbl->peer_mtu;
open.lcid = avdt_cb.ad.rt_tbl[p_tbl->ccb_idx][p_tbl->tcid].lcid; open.lcid = avdt_cb.ad.rt_tbl[p_tbl->ccb_idx][p_tbl->tcid].lcid;
open.hdr.err_code = avdt_ad_tcid_to_type(p_tbl->tcid); open.hdr.err_code = avdt_ad_tcid_to_type(p_tbl->tcid);
@ -435,18 +402,15 @@ void avdt_ad_tc_cong_ind(tAVDT_TC_TBL *p_tbl, BOOLEAN is_congested)
tAVDT_SCB *p_scb; tAVDT_SCB *p_scb;
/* if signaling channel, notify ccb of congestion */ /* if signaling channel, notify ccb of congestion */
if (p_tbl->tcid == 0) if (p_tbl->tcid == 0) {
{
p_ccb = avdt_ccb_by_idx(p_tbl->ccb_idx); p_ccb = avdt_ccb_by_idx(p_tbl->ccb_idx);
avdt_ccb_event(p_ccb, AVDT_CCB_LL_CONG_EVT, (tAVDT_CCB_EVT *) &is_congested); avdt_ccb_event(p_ccb, AVDT_CCB_LL_CONG_EVT, (tAVDT_CCB_EVT *) &is_congested);
} }
/* if media or other channel, notify scb that channel open */ /* if media or other channel, notify scb that channel open */
else else {
{
/* look up scb in stream routing table by ccb, tcid */ /* look up scb in stream routing table by ccb, tcid */
p_scb = avdt_scb_by_hdl(avdt_cb.ad.rt_tbl[p_tbl->ccb_idx][p_tbl->tcid].scb_hdl); p_scb = avdt_scb_by_hdl(avdt_cb.ad.rt_tbl[p_tbl->ccb_idx][p_tbl->tcid].scb_hdl);
if (p_scb != NULL) if (p_scb != NULL) {
{
avdt_scb_event(p_scb, AVDT_SCB_TC_CONG_EVT, (tAVDT_SCB_EVT *) &is_congested); avdt_scb_event(p_scb, AVDT_SCB_TC_CONG_EVT, (tAVDT_SCB_EVT *) &is_congested);
} }
} }
@ -475,21 +439,16 @@ void avdt_ad_tc_data_ind(tAVDT_TC_TBL *p_tbl, BT_HDR *p_buf)
/* if signaling channel, handle control message */ /* if signaling channel, handle control message */
if (p_tbl->tcid == 0) if (p_tbl->tcid == 0) {
{
p_ccb = avdt_ccb_by_idx(p_tbl->ccb_idx); p_ccb = avdt_ccb_by_idx(p_tbl->ccb_idx);
avdt_msg_ind(p_ccb, p_buf); avdt_msg_ind(p_ccb, p_buf);
} }
/* if media or other channel, send event to scb */ /* if media or other channel, send event to scb */
else else {
{
p_scb = avdt_scb_by_hdl(avdt_cb.ad.rt_tbl[p_tbl->ccb_idx][p_tbl->tcid].scb_hdl); p_scb = avdt_scb_by_hdl(avdt_cb.ad.rt_tbl[p_tbl->ccb_idx][p_tbl->tcid].scb_hdl);
if (p_scb != NULL) if (p_scb != NULL) {
{
avdt_scb_event(p_scb, AVDT_SCB_TC_DATA_EVT, (tAVDT_SCB_EVT *) &p_buf); avdt_scb_event(p_scb, AVDT_SCB_TC_DATA_EVT, (tAVDT_SCB_EVT *) &p_buf);
} } else {
else
{
GKI_freebuf(p_buf); GKI_freebuf(p_buf);
AVDT_TRACE_ERROR(" avdt_ad_tc_data_ind buffer freed"); AVDT_TRACE_ERROR(" avdt_ad_tc_data_ind buffer freed");
} }
@ -544,8 +503,7 @@ void avdt_ad_open_req(UINT8 type, tAVDT_CCB *p_ccb, tAVDT_SCB *p_scb, UINT8 role
tAVDT_TC_TBL *p_tbl; tAVDT_TC_TBL *p_tbl;
UINT16 lcid; UINT16 lcid;
if((p_tbl = avdt_ad_tc_tbl_alloc(p_ccb)) == NULL) if ((p_tbl = avdt_ad_tc_tbl_alloc(p_ccb)) == NULL) {
{
AVDT_TRACE_ERROR("avdt_ad_open_req: Cannot allocate p_tbl"); AVDT_TRACE_ERROR("avdt_ad_open_req: Cannot allocate p_tbl");
return; return;
} }
@ -555,14 +513,11 @@ void avdt_ad_open_req(UINT8 type, tAVDT_CCB *p_ccb, tAVDT_SCB *p_scb, UINT8 role
AVDT_TRACE_DEBUG("avdt_ad_open_req: type: %d, role: %d, tcid:%d\n", AVDT_TRACE_DEBUG("avdt_ad_open_req: type: %d, role: %d, tcid:%d\n",
type, role, p_tbl->tcid); type, role, p_tbl->tcid);
if (type == AVDT_CHAN_SIG) if (type == AVDT_CHAN_SIG) {
{
/* if signaling, get mtu from registration control block */ /* if signaling, get mtu from registration control block */
p_tbl->my_mtu = avdt_cb.rcb.ctrl_mtu; p_tbl->my_mtu = avdt_cb.rcb.ctrl_mtu;
p_tbl->my_flush_to = L2CAP_DEFAULT_FLUSH_TO; p_tbl->my_flush_to = L2CAP_DEFAULT_FLUSH_TO;
} } else {
else
{
/* otherwise get mtu from scb */ /* otherwise get mtu from scb */
p_tbl->my_mtu = p_scb->cs.mtu; p_tbl->my_mtu = p_scb->cs.mtu;
p_tbl->my_flush_to = p_scb->cs.flush_to; p_tbl->my_flush_to = p_scb->cs.flush_to;
@ -575,18 +530,15 @@ void avdt_ad_open_req(UINT8 type, tAVDT_CCB *p_ccb, tAVDT_SCB *p_scb, UINT8 role
} }
/* if we're acceptor, we're done; just sit back and listen */ /* if we're acceptor, we're done; just sit back and listen */
if (role == AVDT_ACP) if (role == AVDT_ACP) {
{
p_tbl->state = AVDT_AD_ST_ACP; p_tbl->state = AVDT_AD_ST_ACP;
} }
/* else we're inititator, start the L2CAP connection */ /* else we're inititator, start the L2CAP connection */
else else {
{
p_tbl->state = AVDT_AD_ST_CONN; p_tbl->state = AVDT_AD_ST_CONN;
/* call l2cap connect req */ /* call l2cap connect req */
if ((lcid = L2CA_ConnectReq(AVDT_PSM, p_ccb->peer_addr)) != 0) if ((lcid = L2CA_ConnectReq(AVDT_PSM, p_ccb->peer_addr)) != 0) {
{
/* if connect req ok, store tcid in lcid table */ /* if connect req ok, store tcid in lcid table */
avdt_cb.ad.lcid_tbl[lcid - L2CAP_BASE_APPL_CID] = avdt_ad_tc_tbl_to_idx(p_tbl); avdt_cb.ad.lcid_tbl[lcid - L2CAP_BASE_APPL_CID] = avdt_ad_tc_tbl_to_idx(p_tbl);
AVDT_TRACE_DEBUG("avdt_cb.ad.lcid_tbl[%d] = %d\n", AVDT_TRACE_DEBUG("avdt_cb.ad.lcid_tbl[%d] = %d\n",
@ -596,9 +548,7 @@ void avdt_ad_open_req(UINT8 type, tAVDT_CCB *p_ccb, tAVDT_SCB *p_scb, UINT8 role
AVDT_TRACE_DEBUG("avdt_cb.ad.rt_tbl[%d][%d].lcid = 0x%x\n", AVDT_TRACE_DEBUG("avdt_cb.ad.rt_tbl[%d][%d].lcid = 0x%x\n",
avdt_ccb_to_idx(p_ccb), p_tbl->tcid, avdt_ccb_to_idx(p_ccb), p_tbl->tcid,
lcid); lcid);
} } else {
else
{
/* if connect req failed, call avdt_ad_tc_close_ind() */ /* if connect req failed, call avdt_ad_tc_close_ind() */
avdt_ad_tc_close_ind(p_tbl, 0); avdt_ad_tc_close_ind(p_tbl, 0);
} }
@ -625,8 +575,7 @@ void avdt_ad_close_req(UINT8 type, tAVDT_CCB *p_ccb, tAVDT_SCB *p_scb)
p_tbl = avdt_ad_tc_tbl_by_type(type, p_ccb, p_scb); p_tbl = avdt_ad_tc_tbl_by_type(type, p_ccb, p_scb);
AVDT_TRACE_DEBUG("avdt_ad_close_req state: %d\n", p_tbl->state); AVDT_TRACE_DEBUG("avdt_ad_close_req state: %d\n", p_tbl->state);
switch(p_tbl->state) switch (p_tbl->state) {
{
case AVDT_AD_ST_UNUSED: case AVDT_AD_ST_UNUSED:
/* probably for reporting */ /* probably for reporting */
break; break;

281
components/bt/bluedroid/stack/avdt/avdt_api.c Executable file → Normal file
View file

@ -59,8 +59,7 @@ void avdt_process_timeout(TIMER_LIST_ENT *p_tle)
UINT8 event = 0; UINT8 event = 0;
UINT8 err_code = AVDT_ERR_TIMEOUT; UINT8 err_code = AVDT_ERR_TIMEOUT;
switch (p_tle->event) switch (p_tle->event) {
{
case BTU_TTYPE_AVDT_CCB_RET: case BTU_TTYPE_AVDT_CCB_RET:
event = AVDT_CCB_RET_TOUT_EVT + AVDT_CCB_MKR; event = AVDT_CCB_RET_TOUT_EVT + AVDT_CCB_MKR;
break; break;
@ -81,13 +80,10 @@ void avdt_process_timeout(TIMER_LIST_ENT *p_tle)
break; break;
} }
if (event & AVDT_CCB_MKR) if (event & AVDT_CCB_MKR) {
{
avdt_ccb_event((tAVDT_CCB *) p_tle->param, (UINT8) (event & ~AVDT_CCB_MKR), avdt_ccb_event((tAVDT_CCB *) p_tle->param, (UINT8) (event & ~AVDT_CCB_MKR),
(tAVDT_CCB_EVT *) &err_code); (tAVDT_CCB_EVT *) &err_code);
} } else {
else
{
avdt_scb_event((tAVDT_SCB *) p_tle->param, event, NULL); avdt_scb_event((tAVDT_SCB *) p_tle->param, event, NULL);
} }
} }
@ -178,10 +174,8 @@ void AVDT_SINK_Activate()
int i; int i;
AVDT_TRACE_DEBUG("AVDT_SINK_Activate"); AVDT_TRACE_DEBUG("AVDT_SINK_Activate");
/* for all allocated scbs */ /* for all allocated scbs */
for (i = 0; i < AVDT_NUM_SEPS; i++, p_scb++) for (i = 0; i < AVDT_NUM_SEPS; i++, p_scb++) {
{ if ((p_scb->allocated) && (p_scb->cs.tsep == AVDT_TSEP_SNK)) {
if ((p_scb->allocated) && (p_scb->cs.tsep == AVDT_TSEP_SNK))
{
AVDT_TRACE_DEBUG("AVDT_SINK_Activate found scb"); AVDT_TRACE_DEBUG("AVDT_SINK_Activate found scb");
p_scb->sink_activated = TRUE; p_scb->sink_activated = TRUE;
/* update in_use */ /* update in_use */
@ -209,10 +203,8 @@ void AVDT_SINK_Deactivate()
int i; int i;
AVDT_TRACE_DEBUG("AVDT_SINK_Deactivate"); AVDT_TRACE_DEBUG("AVDT_SINK_Deactivate");
/* for all allocated scbs */ /* for all allocated scbs */
for (i = 0; i < AVDT_NUM_SEPS; i++, p_scb++) for (i = 0; i < AVDT_NUM_SEPS; i++, p_scb++) {
{ if ((p_scb->allocated) && (p_scb->cs.tsep == AVDT_TSEP_SNK)) {
if ((p_scb->allocated) && (p_scb->cs.tsep == AVDT_TSEP_SNK))
{
AVDT_TRACE_DEBUG("AVDT_SINK_Deactivate, found scb"); AVDT_TRACE_DEBUG("AVDT_SINK_Deactivate, found scb");
p_scb->sink_activated = FALSE; p_scb->sink_activated = FALSE;
/* update in_use */ /* update in_use */
@ -227,8 +219,7 @@ void AVDT_AbortReq(UINT8 handle)
AVDT_TRACE_ERROR("%s\n", __func__); AVDT_TRACE_ERROR("%s\n", __func__);
tAVDT_SCB *p_scb = avdt_scb_by_hdl(handle); tAVDT_SCB *p_scb = avdt_scb_by_hdl(handle);
if (p_scb != NULL) if (p_scb != NULL) {
{
avdt_scb_event(p_scb, AVDT_SCB_API_ABORT_REQ_EVT, NULL); avdt_scb_event(p_scb, AVDT_SCB_API_ABORT_REQ_EVT, NULL);
} else { } else {
AVDT_TRACE_ERROR("%s Improper SCB, can not abort the stream\n", __func__); AVDT_TRACE_ERROR("%s Improper SCB, can not abort the stream\n", __func__);
@ -255,17 +246,13 @@ UINT16 AVDT_CreateStream(UINT8 *p_handle, tAVDT_CS *p_cs)
tAVDT_SCB *p_scb; tAVDT_SCB *p_scb;
/* Verify parameters; if invalid, return failure */ /* Verify parameters; if invalid, return failure */
if (((p_cs->cfg.psc_mask & (~AVDT_PSC)) != 0) || (p_cs->p_ctrl_cback == NULL)) if (((p_cs->cfg.psc_mask & (~AVDT_PSC)) != 0) || (p_cs->p_ctrl_cback == NULL)) {
{
result = AVDT_BAD_PARAMS; result = AVDT_BAD_PARAMS;
} }
/* Allocate scb; if no scbs, return failure */ /* Allocate scb; if no scbs, return failure */
else if ((p_scb = avdt_scb_alloc(p_cs)) == NULL) else if ((p_scb = avdt_scb_alloc(p_cs)) == NULL) {
{
result = AVDT_NO_RESOURCES; result = AVDT_NO_RESOURCES;
} } else {
else
{
*p_handle = avdt_scb_to_hdl(p_scb); *p_handle = avdt_scb_to_hdl(p_scb);
} }
return result; return result;
@ -291,12 +278,9 @@ UINT16 AVDT_RemoveStream(UINT8 handle)
tAVDT_SCB *p_scb; tAVDT_SCB *p_scb;
/* look up scb */ /* look up scb */
if ((p_scb = avdt_scb_by_hdl(handle)) == NULL) if ((p_scb = avdt_scb_by_hdl(handle)) == NULL) {
{
result = AVDT_BAD_HANDLE; result = AVDT_BAD_HANDLE;
} } else {
else
{
/* send remove event to scb */ /* send remove event to scb */
avdt_scb_event(p_scb, AVDT_SCB_API_REMOVE_EVT, NULL); avdt_scb_event(p_scb, AVDT_SCB_API_REMOVE_EVT, NULL);
} }
@ -337,25 +321,20 @@ UINT16 AVDT_DiscoverReq(BD_ADDR bd_addr, tAVDT_SEP_INFO *p_sep_info,
tAVDT_CCB_EVT evt; tAVDT_CCB_EVT evt;
/* find channel control block for this bd addr; if none, allocate one */ /* find channel control block for this bd addr; if none, allocate one */
if ((p_ccb = avdt_ccb_by_bd(bd_addr)) == NULL) if ((p_ccb = avdt_ccb_by_bd(bd_addr)) == NULL) {
{ if ((p_ccb = avdt_ccb_alloc(bd_addr)) == NULL) {
if ((p_ccb = avdt_ccb_alloc(bd_addr)) == NULL)
{
/* could not allocate channel control block */ /* could not allocate channel control block */
result = AVDT_NO_RESOURCES; result = AVDT_NO_RESOURCES;
} }
} }
if (result == AVDT_SUCCESS) if (result == AVDT_SUCCESS) {
{
/* make sure no discovery or get capabilities req already in progress */ /* make sure no discovery or get capabilities req already in progress */
if (p_ccb->proc_busy) if (p_ccb->proc_busy) {
{
result = AVDT_BUSY; result = AVDT_BUSY;
} }
/* send event to ccb */ /* send event to ccb */
else else {
{
evt.discover.p_sep_info = p_sep_info; evt.discover.p_sep_info = p_sep_info;
evt.discover.num_seps = max_seps; evt.discover.num_seps = max_seps;
evt.discover.p_cback = p_cback; evt.discover.p_cback = p_cback;
@ -381,31 +360,25 @@ static UINT16 avdt_get_cap_req(BD_ADDR bd_addr, tAVDT_CCB_API_GETCAP *p_evt)
UINT16 result = AVDT_SUCCESS; UINT16 result = AVDT_SUCCESS;
/* verify SEID */ /* verify SEID */
if ((p_evt->single.seid < AVDT_SEID_MIN) || (p_evt->single.seid > AVDT_SEID_MAX)) if ((p_evt->single.seid < AVDT_SEID_MIN) || (p_evt->single.seid > AVDT_SEID_MAX)) {
{
AVDT_TRACE_ERROR("seid: %d\n", p_evt->single.seid); AVDT_TRACE_ERROR("seid: %d\n", p_evt->single.seid);
result = AVDT_BAD_PARAMS; result = AVDT_BAD_PARAMS;
} }
/* find channel control block for this bd addr; if none, allocate one */ /* find channel control block for this bd addr; if none, allocate one */
else if ((p_ccb = avdt_ccb_by_bd(bd_addr)) == NULL) else if ((p_ccb = avdt_ccb_by_bd(bd_addr)) == NULL) {
{ if ((p_ccb = avdt_ccb_alloc(bd_addr)) == NULL) {
if ((p_ccb = avdt_ccb_alloc(bd_addr)) == NULL)
{
/* could not allocate channel control block */ /* could not allocate channel control block */
result = AVDT_NO_RESOURCES; result = AVDT_NO_RESOURCES;
} }
} }
if (result == AVDT_SUCCESS) if (result == AVDT_SUCCESS) {
{
/* make sure no discovery or get capabilities req already in progress */ /* make sure no discovery or get capabilities req already in progress */
if (p_ccb->proc_busy) if (p_ccb->proc_busy) {
{
result = AVDT_BUSY; result = AVDT_BUSY;
} }
/* send event to ccb */ /* send event to ccb */
else else {
{
avdt_ccb_event(p_ccb, AVDT_CCB_API_GETCAP_REQ_EVT, (tAVDT_CCB_EVT *)p_evt); avdt_ccb_event(p_ccb, AVDT_CCB_API_GETCAP_REQ_EVT, (tAVDT_CCB_EVT *)p_evt);
} }
} }
@ -500,11 +473,9 @@ UINT16 AVDT_DelayReport(UINT8 handle, UINT8 seid, UINT16 delay)
tAVDT_SCB_EVT evt; tAVDT_SCB_EVT evt;
/* map handle to scb */ /* map handle to scb */
if ((p_scb = avdt_scb_by_hdl(handle)) == NULL) if ((p_scb = avdt_scb_by_hdl(handle)) == NULL) {
{
result = AVDT_BAD_HANDLE; result = AVDT_BAD_HANDLE;
} } else
else
/* send event to scb */ /* send event to scb */
{ {
evt.apidelay.hdr.seid = seid; evt.apidelay.hdr.seid = seid;
@ -536,28 +507,23 @@ UINT16 AVDT_OpenReq(UINT8 handle, BD_ADDR bd_addr, UINT8 seid, tAVDT_CFG *p_cfg)
tAVDT_SCB_EVT evt; tAVDT_SCB_EVT evt;
/* verify SEID */ /* verify SEID */
if ((seid < AVDT_SEID_MIN) || (seid > AVDT_SEID_MAX)) if ((seid < AVDT_SEID_MIN) || (seid > AVDT_SEID_MAX)) {
{
result = AVDT_BAD_PARAMS; result = AVDT_BAD_PARAMS;
} }
/* map handle to scb */ /* map handle to scb */
else if ((p_scb = avdt_scb_by_hdl(handle)) == NULL) else if ((p_scb = avdt_scb_by_hdl(handle)) == NULL) {
{
result = AVDT_BAD_HANDLE; result = AVDT_BAD_HANDLE;
} }
/* find channel control block for this bd addr; if none, allocate one */ /* find channel control block for this bd addr; if none, allocate one */
else if ((p_ccb = avdt_ccb_by_bd(bd_addr)) == NULL) else if ((p_ccb = avdt_ccb_by_bd(bd_addr)) == NULL) {
{ if ((p_ccb = avdt_ccb_alloc(bd_addr)) == NULL) {
if ((p_ccb = avdt_ccb_alloc(bd_addr)) == NULL)
{
/* could not allocate channel control block */ /* could not allocate channel control block */
result = AVDT_NO_RESOURCES; result = AVDT_NO_RESOURCES;
} }
} }
/* send event to scb */ /* send event to scb */
if (result == AVDT_SUCCESS) if (result == AVDT_SUCCESS) {
{
evt.msg.config_cmd.hdr.seid = seid; evt.msg.config_cmd.hdr.seid = seid;
evt.msg.config_cmd.hdr.ccb_idx = avdt_ccb_to_idx(p_ccb); evt.msg.config_cmd.hdr.ccb_idx = avdt_ccb_to_idx(p_ccb);
evt.msg.config_cmd.int_seid = handle; evt.msg.config_cmd.int_seid = handle;
@ -587,29 +553,23 @@ UINT16 AVDT_ConfigRsp(UINT8 handle, UINT8 label, UINT8 error_code, UINT8 categor
UINT8 event_code; UINT8 event_code;
/* map handle to scb */ /* map handle to scb */
if ((p_scb = avdt_scb_by_hdl(handle)) == NULL) if ((p_scb = avdt_scb_by_hdl(handle)) == NULL) {
{
result = AVDT_BAD_HANDLE; result = AVDT_BAD_HANDLE;
} }
/* handle special case when this function is called but peer has not send /* handle special case when this function is called but peer has not send
** a configuration cmd; ignore and return error result ** a configuration cmd; ignore and return error result
*/ */
else if (!p_scb->in_use) else if (!p_scb->in_use) {
{
result = AVDT_BAD_HANDLE; result = AVDT_BAD_HANDLE;
} }
/* send event to scb */ /* send event to scb */
else else {
{
evt.msg.hdr.err_code = error_code; evt.msg.hdr.err_code = error_code;
evt.msg.hdr.err_param = category; evt.msg.hdr.err_param = category;
evt.msg.hdr.label = label; evt.msg.hdr.label = label;
if (error_code == 0) if (error_code == 0) {
{
event_code = AVDT_SCB_API_SETCONFIG_RSP_EVT; event_code = AVDT_SCB_API_SETCONFIG_RSP_EVT;
} } else {
else
{
event_code = AVDT_SCB_API_SETCONFIG_REJ_EVT; event_code = AVDT_SCB_API_SETCONFIG_REJ_EVT;
} }
avdt_scb_event(p_scb, event_code, &evt); avdt_scb_event(p_scb, event_code, &evt);
@ -639,31 +599,22 @@ UINT16 AVDT_StartReq(UINT8 *p_handles, UINT8 num_handles)
UINT16 result = AVDT_SUCCESS; UINT16 result = AVDT_SUCCESS;
int i; int i;
if ((num_handles == 0) || (num_handles > AVDT_NUM_SEPS)) if ((num_handles == 0) || (num_handles > AVDT_NUM_SEPS)) {
{
result = AVDT_BAD_PARAMS; result = AVDT_BAD_PARAMS;
} } else {
else
{
/* verify handles */ /* verify handles */
for (i = 0; i < num_handles; i++) for (i = 0; i < num_handles; i++) {
{ if ((p_scb = avdt_scb_by_hdl(p_handles[i])) == NULL) {
if ((p_scb = avdt_scb_by_hdl(p_handles[i])) == NULL)
{
result = AVDT_BAD_HANDLE; result = AVDT_BAD_HANDLE;
break; break;
} }
} }
} }
if (result == AVDT_SUCCESS) if (result == AVDT_SUCCESS) {
{ if (p_scb->p_ccb == NULL) {
if (p_scb->p_ccb == NULL)
{
result = AVDT_BAD_HANDLE; result = AVDT_BAD_HANDLE;
} } else {
else
{
/* send event to ccb */ /* send event to ccb */
memcpy(evt.msg.multi.seid_list, p_handles, num_handles); memcpy(evt.msg.multi.seid_list, p_handles, num_handles);
evt.msg.multi.num_seps = num_handles; evt.msg.multi.num_seps = num_handles;
@ -695,31 +646,22 @@ UINT16 AVDT_SuspendReq(UINT8 *p_handles, UINT8 num_handles)
UINT16 result = AVDT_SUCCESS; UINT16 result = AVDT_SUCCESS;
int i; int i;
if ((num_handles == 0) || (num_handles > AVDT_NUM_SEPS)) if ((num_handles == 0) || (num_handles > AVDT_NUM_SEPS)) {
{
result = AVDT_BAD_PARAMS; result = AVDT_BAD_PARAMS;
} } else {
else
{
/* verify handles */ /* verify handles */
for (i = 0; i < num_handles; i++) for (i = 0; i < num_handles; i++) {
{ if ((p_scb = avdt_scb_by_hdl(p_handles[i])) == NULL) {
if ((p_scb = avdt_scb_by_hdl(p_handles[i])) == NULL)
{
result = AVDT_BAD_HANDLE; result = AVDT_BAD_HANDLE;
break; break;
} }
} }
} }
if (result == AVDT_SUCCESS) if (result == AVDT_SUCCESS) {
{ if (p_scb->p_ccb == NULL) {
if (p_scb->p_ccb == NULL)
{
result = AVDT_BAD_HANDLE; result = AVDT_BAD_HANDLE;
} } else {
else
{
/* send event to ccb */ /* send event to ccb */
memcpy(evt.msg.multi.seid_list, p_handles, num_handles); memcpy(evt.msg.multi.seid_list, p_handles, num_handles);
evt.msg.multi.num_seps = num_handles; evt.msg.multi.num_seps = num_handles;
@ -750,11 +692,9 @@ UINT16 AVDT_CloseReq(UINT8 handle)
UINT16 result = AVDT_SUCCESS; UINT16 result = AVDT_SUCCESS;
/* map handle to scb */ /* map handle to scb */
if ((p_scb = avdt_scb_by_hdl(handle)) == NULL) if ((p_scb = avdt_scb_by_hdl(handle)) == NULL) {
{
result = AVDT_BAD_HANDLE; result = AVDT_BAD_HANDLE;
} } else
else
/* send event to scb */ /* send event to scb */
{ {
avdt_scb_event(p_scb, AVDT_SCB_API_CLOSE_REQ_EVT, NULL); avdt_scb_event(p_scb, AVDT_SCB_API_CLOSE_REQ_EVT, NULL);
@ -786,13 +726,11 @@ UINT16 AVDT_ReconfigReq(UINT8 handle, tAVDT_CFG *p_cfg)
tAVDT_SCB_EVT evt; tAVDT_SCB_EVT evt;
/* map handle to scb */ /* map handle to scb */
if ((p_scb = avdt_scb_by_hdl(handle)) == NULL) if ((p_scb = avdt_scb_by_hdl(handle)) == NULL) {
{
result = AVDT_BAD_HANDLE; result = AVDT_BAD_HANDLE;
} }
/* send event to scb */ /* send event to scb */
else else {
{
/* force psc_mask to zero */ /* force psc_mask to zero */
p_cfg->psc_mask = 0; p_cfg->psc_mask = 0;
@ -821,13 +759,11 @@ UINT16 AVDT_ReconfigRsp(UINT8 handle, UINT8 label, UINT8 error_code, UINT8 categ
UINT16 result = AVDT_SUCCESS; UINT16 result = AVDT_SUCCESS;
/* map handle to scb */ /* map handle to scb */
if ((p_scb = avdt_scb_by_hdl(handle)) == NULL) if ((p_scb = avdt_scb_by_hdl(handle)) == NULL) {
{
result = AVDT_BAD_HANDLE; result = AVDT_BAD_HANDLE;
} }
/* send event to scb */ /* send event to scb */
else else {
{
evt.msg.hdr.err_code = error_code; evt.msg.hdr.err_code = error_code;
evt.msg.hdr.err_param = category; evt.msg.hdr.err_param = category;
evt.msg.hdr.label = label; evt.msg.hdr.label = label;
@ -858,13 +794,11 @@ UINT16 AVDT_SecurityReq(UINT8 handle, UINT8 *p_data, UINT16 len)
tAVDT_SCB_EVT evt; tAVDT_SCB_EVT evt;
/* map handle to scb */ /* map handle to scb */
if ((p_scb = avdt_scb_by_hdl(handle)) == NULL) if ((p_scb = avdt_scb_by_hdl(handle)) == NULL) {
{
result = AVDT_BAD_HANDLE; result = AVDT_BAD_HANDLE;
} }
/* send event to scb */ /* send event to scb */
else else {
{
evt.msg.security_rsp.p_data = p_data; evt.msg.security_rsp.p_data = p_data;
evt.msg.security_rsp.len = len; evt.msg.security_rsp.len = len;
avdt_scb_event(p_scb, AVDT_SCB_API_SECURITY_REQ_EVT, &evt); avdt_scb_event(p_scb, AVDT_SCB_API_SECURITY_REQ_EVT, &evt);
@ -894,13 +828,11 @@ UINT16 AVDT_SecurityRsp(UINT8 handle, UINT8 label, UINT8 error_code,
tAVDT_SCB_EVT evt; tAVDT_SCB_EVT evt;
/* map handle to scb */ /* map handle to scb */
if ((p_scb = avdt_scb_by_hdl(handle)) == NULL) if ((p_scb = avdt_scb_by_hdl(handle)) == NULL) {
{
result = AVDT_BAD_HANDLE; result = AVDT_BAD_HANDLE;
} }
/* send event to scb */ /* send event to scb */
else else {
{
evt.msg.security_rsp.hdr.err_code = error_code; evt.msg.security_rsp.hdr.err_code = error_code;
evt.msg.security_rsp.hdr.label = label; evt.msg.security_rsp.hdr.label = label;
evt.msg.security_rsp.p_data = p_data; evt.msg.security_rsp.p_data = p_data;
@ -953,12 +885,9 @@ UINT16 AVDT_WriteReqOpt(UINT8 handle, BT_HDR *p_pkt, UINT32 time_stamp, UINT8 m_
UINT16 result = AVDT_SUCCESS; UINT16 result = AVDT_SUCCESS;
/* map handle to scb */ /* map handle to scb */
if ((p_scb = avdt_scb_by_hdl(handle)) == NULL) if ((p_scb = avdt_scb_by_hdl(handle)) == NULL) {
{
result = AVDT_BAD_HANDLE; result = AVDT_BAD_HANDLE;
} } else {
else
{
evt.apiwrite.p_buf = p_pkt; evt.apiwrite.p_buf = p_pkt;
evt.apiwrite.time_stamp = time_stamp; evt.apiwrite.time_stamp = time_stamp;
evt.apiwrite.m_pt = m_pt; evt.apiwrite.m_pt = m_pt;
@ -1032,24 +961,19 @@ UINT16 AVDT_ConnectReq(BD_ADDR bd_addr, UINT8 sec_mask, tAVDT_CTRL_CBACK *p_cbac
tAVDT_CCB_EVT evt; tAVDT_CCB_EVT evt;
/* find channel control block for this bd addr; if none, allocate one */ /* find channel control block for this bd addr; if none, allocate one */
if ((p_ccb = avdt_ccb_by_bd(bd_addr)) == NULL) if ((p_ccb = avdt_ccb_by_bd(bd_addr)) == NULL) {
{ if ((p_ccb = avdt_ccb_alloc(bd_addr)) == NULL) {
if ((p_ccb = avdt_ccb_alloc(bd_addr)) == NULL)
{
/* could not allocate channel control block */ /* could not allocate channel control block */
result = AVDT_NO_RESOURCES; result = AVDT_NO_RESOURCES;
} }
} } else if (p_ccb->ll_opened == FALSE) {
else if (p_ccb->ll_opened == FALSE)
{
AVDT_TRACE_WARNING("AVDT_ConnectReq: CCB LL is in the middle of opening"); AVDT_TRACE_WARNING("AVDT_ConnectReq: CCB LL is in the middle of opening");
/* ccb was already allocated for the incoming signalling. */ /* ccb was already allocated for the incoming signalling. */
result = AVDT_BUSY; result = AVDT_BUSY;
} }
if (result == AVDT_SUCCESS) if (result == AVDT_SUCCESS) {
{
/* send event to ccb */ /* send event to ccb */
evt.connect.p_cback = p_cback; evt.connect.p_cback = p_cback;
evt.connect.sec_mask = sec_mask; evt.connect.sec_mask = sec_mask;
@ -1077,13 +1001,11 @@ UINT16 AVDT_DisconnectReq(BD_ADDR bd_addr, tAVDT_CTRL_CBACK *p_cback)
tAVDT_CCB_EVT evt; tAVDT_CCB_EVT evt;
/* find channel control block for this bd addr; if none, error */ /* find channel control block for this bd addr; if none, error */
if ((p_ccb = avdt_ccb_by_bd(bd_addr)) == NULL) if ((p_ccb = avdt_ccb_by_bd(bd_addr)) == NULL) {
{
result = AVDT_BAD_PARAMS; result = AVDT_BAD_PARAMS;
} }
if (result == AVDT_SUCCESS) if (result == AVDT_SUCCESS) {
{
/* send event to ccb */ /* send event to ccb */
evt.disconnect.p_cback = p_cback; evt.disconnect.p_cback = p_cback;
avdt_ccb_event(p_ccb, AVDT_CCB_API_DISCONNECT_REQ_EVT, &evt); avdt_ccb_event(p_ccb, AVDT_CCB_API_DISCONNECT_REQ_EVT, &evt);
@ -1109,8 +1031,7 @@ UINT16 AVDT_GetL2CapChannel(UINT8 handle)
/* map handle to scb */ /* map handle to scb */
if (((p_scb = avdt_scb_by_hdl(handle)) != NULL) if (((p_scb = avdt_scb_by_hdl(handle)) != NULL)
&& ((p_ccb = p_scb->p_ccb) != NULL)) && ((p_ccb = p_scb->p_ccb) != NULL)) {
{
/* get tcid from type, scb */ /* get tcid from type, scb */
tcid = avdt_ad_type_to_tcid(AVDT_CHAN_MEDIA, p_scb); tcid = avdt_ad_type_to_tcid(AVDT_CHAN_MEDIA, p_scb);
@ -1138,12 +1059,9 @@ UINT16 AVDT_GetSignalChannel(UINT8 handle, BD_ADDR bd_addr)
/* map handle to scb */ /* map handle to scb */
if (((p_scb = avdt_scb_by_hdl(handle)) != NULL) if (((p_scb = avdt_scb_by_hdl(handle)) != NULL)
&& ((p_ccb = p_scb->p_ccb) != NULL)) && ((p_ccb = p_scb->p_ccb) != NULL)) {
{
lcid = avdt_cb.ad.rt_tbl[avdt_ccb_to_idx(p_ccb)][tcid].lcid; lcid = avdt_cb.ad.rt_tbl[avdt_ccb_to_idx(p_ccb)][tcid].lcid;
} } else if ((p_ccb = avdt_ccb_by_bd(bd_addr)) != NULL) {
else if ((p_ccb = avdt_ccb_by_bd(bd_addr)) != NULL)
{
lcid = avdt_cb.ad.rt_tbl[avdt_ccb_to_idx(p_ccb)][tcid].lcid; lcid = avdt_cb.ad.rt_tbl[avdt_ccb_to_idx(p_ccb)][tcid].lcid;
} }
@ -1180,17 +1098,14 @@ extern UINT16 AVDT_WriteDataReq(UINT8 handle, UINT8 *p_data, UINT32 data_len,
tAVDT_SCB_EVT evt; tAVDT_SCB_EVT evt;
UINT16 result = AVDT_SUCCESS; UINT16 result = AVDT_SUCCESS;
do do {
{
/* check length of media frame */ /* check length of media frame */
if(data_len > AVDT_MAX_MEDIA_SIZE) if (data_len > AVDT_MAX_MEDIA_SIZE) {
{
result = AVDT_BAD_PARAMS; result = AVDT_BAD_PARAMS;
break; break;
} }
/* map handle to scb */ /* map handle to scb */
if ((p_scb = avdt_scb_by_hdl(handle)) == NULL) if ((p_scb = avdt_scb_by_hdl(handle)) == NULL) {
{
result = AVDT_BAD_HANDLE; result = AVDT_BAD_HANDLE;
break; break;
} }
@ -1200,8 +1115,7 @@ extern UINT16 AVDT_WriteDataReq(UINT8 handle, UINT8 *p_data, UINT32 data_len,
|| p_scb->p_ccb == NULL || p_scb->p_ccb == NULL
|| !GKI_queue_is_empty(&p_scb->frag_q) || !GKI_queue_is_empty(&p_scb->frag_q)
|| p_scb->frag_off != 0 || p_scb->frag_off != 0
|| p_scb->curr_cfg.mux_tsid_media == 0) || p_scb->curr_cfg.mux_tsid_media == 0) {
{
result = AVDT_ERR_BAD_STATE; result = AVDT_ERR_BAD_STATE;
AVDT_TRACE_WARNING("p_scb->p_pkt=%p, p_scb->p_ccb=%p, IsQueueEmpty=%x, p_scb->frag_off=%x\n", AVDT_TRACE_WARNING("p_scb->p_pkt=%p, p_scb->p_ccb=%p, IsQueueEmpty=%x, p_scb->frag_off=%x\n",
p_scb->p_pkt, p_scb->p_ccb, GKI_queue_is_empty(&p_scb->frag_q), p_scb->frag_off); p_scb->p_pkt, p_scb->p_ccb, GKI_queue_is_empty(&p_scb->frag_q), p_scb->frag_off);
@ -1214,8 +1128,7 @@ extern UINT16 AVDT_WriteDataReq(UINT8 handle, UINT8 *p_data, UINT32 data_len,
/* compose fragments from media payload and put fragments into gueue */ /* compose fragments from media payload and put fragments into gueue */
avdt_scb_queue_frags(p_scb, &p_data, &data_len, &evt.apiwrite.frag_q); avdt_scb_queue_frags(p_scb, &p_data, &data_len, &evt.apiwrite.frag_q);
if(GKI_queue_is_empty(&evt.apiwrite.frag_q)) if (GKI_queue_is_empty(&evt.apiwrite.frag_q)) {
{
AVDT_TRACE_WARNING("AVDT_WriteDataReq out of GKI buffers"); AVDT_TRACE_WARNING("AVDT_WriteDataReq out of GKI buffers");
result = AVDT_ERR_RESOURCE; result = AVDT_ERR_RESOURCE;
break; break;
@ -1230,8 +1143,7 @@ extern UINT16 AVDT_WriteDataReq(UINT8 handle, UINT8 *p_data, UINT32 data_len,
} while (0); } while (0);
#if (BT_USE_TRACES == TRUE) #if (BT_USE_TRACES == TRUE)
if(result != AVDT_SUCCESS) if (result != AVDT_SUCCESS) {
{
AVDT_TRACE_WARNING("*** AVDT_WriteDataReq failed result=%d\n", result); AVDT_TRACE_WARNING("*** AVDT_WriteDataReq failed result=%d\n", result);
} }
#endif #endif
@ -1264,16 +1176,12 @@ extern UINT16 AVDT_SetMediaBuf(UINT8 handle, UINT8 *p_buf, UINT32 buf_len)
UINT16 result = AVDT_SUCCESS; UINT16 result = AVDT_SUCCESS;
/* map handle to scb */ /* map handle to scb */
if ((p_scb = avdt_scb_by_hdl(handle)) == NULL) if ((p_scb = avdt_scb_by_hdl(handle)) == NULL) {
{
result = AVDT_BAD_HANDLE; result = AVDT_BAD_HANDLE;
} } else {
else if (p_buf && p_scb->cs.p_media_cback == NULL) {
{
if(p_buf && p_scb->cs.p_media_cback == NULL)
result = AVDT_NO_RESOURCES; result = AVDT_NO_RESOURCES;
else } else {
{
p_scb->p_media_buf = p_buf; p_scb->p_media_buf = p_buf;
p_scb->media_buf_len = buf_len; p_scb->media_buf_len = buf_len;
} }
@ -1314,20 +1222,17 @@ UINT16 AVDT_SendReport(UINT8 handle, AVDT_REPORT_TYPE type,
&& (p_scb->p_ccb != NULL) && (p_scb->p_ccb != NULL)
&& (((type == AVDT_RTCP_PT_SR) && (p_scb->cs.tsep == AVDT_TSEP_SRC)) || && (((type == AVDT_RTCP_PT_SR) && (p_scb->cs.tsep == AVDT_TSEP_SRC)) ||
((type == AVDT_RTCP_PT_RR) && (p_scb->cs.tsep == AVDT_TSEP_SNK)) || ((type == AVDT_RTCP_PT_RR) && (p_scb->cs.tsep == AVDT_TSEP_SNK)) ||
(type == AVDT_RTCP_PT_SDES)) ) (type == AVDT_RTCP_PT_SDES)) ) {
{
result = AVDT_NO_RESOURCES; result = AVDT_NO_RESOURCES;
/* build SR - assume fit in one packet */ /* build SR - assume fit in one packet */
p_tbl = avdt_ad_tc_tbl_by_type(AVDT_CHAN_REPORT, p_scb->p_ccb, p_scb); p_tbl = avdt_ad_tc_tbl_by_type(AVDT_CHAN_REPORT, p_scb->p_ccb, p_scb);
if ((p_tbl->state == AVDT_AD_ST_OPEN) && if ((p_tbl->state == AVDT_AD_ST_OPEN) &&
(p_pkt = (BT_HDR *)GKI_getbuf(p_tbl->peer_mtu)) != NULL) (p_pkt = (BT_HDR *)GKI_getbuf(p_tbl->peer_mtu)) != NULL) {
{
p_pkt->offset = L2CAP_MIN_OFFSET; p_pkt->offset = L2CAP_MIN_OFFSET;
p = (UINT8 *)(p_pkt + 1) + p_pkt->offset; p = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
#if AVDT_MULTIPLEXING == TRUE #if AVDT_MULTIPLEXING == TRUE
if(p_scb->curr_cfg.psc_mask & AVDT_PSC_MUX) if (p_scb->curr_cfg.psc_mask & AVDT_PSC_MUX) {
{
/* Adaptation Layer header later */ /* Adaptation Layer header later */
p_al = p; p_al = p;
p += 2; p += 2;
@ -1342,8 +1247,7 @@ UINT16 AVDT_SendReport(UINT8 handle, AVDT_REPORT_TYPE type,
ssrc = avdt_scb_gen_ssrc(p_scb); ssrc = avdt_scb_gen_ssrc(p_scb);
UINT32_TO_BE_STREAM(p, ssrc); UINT32_TO_BE_STREAM(p, ssrc);
switch(type) switch (type) {
{
case AVDT_RTCP_PT_SR: /* Sender Report */ case AVDT_RTCP_PT_SR: /* Sender Report */
*pm1 = AVDT_MEDIA_OCTET1; *pm1 = AVDT_MEDIA_OCTET1;
UINT32_TO_BE_STREAM(p, p_data->sr.ntp_sec); UINT32_TO_BE_STREAM(p, p_data->sr.ntp_sec);
@ -1368,8 +1272,9 @@ UINT16 AVDT_SendReport(UINT8 handle, AVDT_REPORT_TYPE type,
case AVDT_RTCP_PT_SDES: /* Source Description */ case AVDT_RTCP_PT_SDES: /* Source Description */
*p++ = AVDT_RTCP_SDES_CNAME; *p++ = AVDT_RTCP_SDES_CNAME;
len = strlen((char *)p_data->cname); len = strlen((char *)p_data->cname);
if(len > AVDT_MAX_CNAME_SIZE) if (len > AVDT_MAX_CNAME_SIZE) {
len = AVDT_MAX_CNAME_SIZE; len = AVDT_MAX_CNAME_SIZE;
}
*p++ = (UINT8)len; *p++ = (UINT8)len;
BCM_STRNCPY_S((char *)p, len + 1, (char *)p_data->cname, len + 1); BCM_STRNCPY_S((char *)p, len + 1, (char *)p_data->cname, len + 1);
p += len; p += len;
@ -1380,8 +1285,7 @@ UINT16 AVDT_SendReport(UINT8 handle, AVDT_REPORT_TYPE type,
UINT16_TO_BE_STREAM(plen, len); UINT16_TO_BE_STREAM(plen, len);
#if AVDT_MULTIPLEXING == TRUE #if AVDT_MULTIPLEXING == TRUE
if(p_scb->curr_cfg.psc_mask & AVDT_PSC_MUX) if (p_scb->curr_cfg.psc_mask & AVDT_PSC_MUX) {
{
/* Adaptation Layer header */ /* Adaptation Layer header */
p = p_al; p = p_al;
len++; len++;
@ -1389,18 +1293,20 @@ UINT16 AVDT_SendReport(UINT8 handle, AVDT_REPORT_TYPE type,
/* TSID, no-fragment bit and coding of length(9-bit length field) */ /* TSID, no-fragment bit and coding of length(9-bit length field) */
u = *p; u = *p;
*p = (p_scb->curr_cfg.mux_tsid_report << 3) | AVDT_ALH_LCODE_9BITM0; *p = (p_scb->curr_cfg.mux_tsid_report << 3) | AVDT_ALH_LCODE_9BITM0;
if(u) if (u) {
*p |= AVDT_ALH_LCODE_9BITM1; *p |= AVDT_ALH_LCODE_9BITM1;
} }
}
#endif #endif
/* set the actual payload length */ /* set the actual payload length */
p_pkt->len = p_end - p; p_pkt->len = p_end - p;
/* send the packet */ /* send the packet */
if(L2CAP_DW_FAILED != avdt_ad_write_req(AVDT_CHAN_REPORT, p_scb->p_ccb, p_scb, p_pkt)) if (L2CAP_DW_FAILED != avdt_ad_write_req(AVDT_CHAN_REPORT, p_scb->p_ccb, p_scb, p_pkt)) {
result = AVDT_SUCCESS; result = AVDT_SUCCESS;
} }
} }
}
return result; return result;
} }
@ -1429,8 +1335,9 @@ UINT16 AVDT_SendReport(UINT8 handle, AVDT_REPORT_TYPE type,
******************************************************************************/ ******************************************************************************/
UINT8 AVDT_SetTraceLevel (UINT8 new_level) UINT8 AVDT_SetTraceLevel (UINT8 new_level)
{ {
if (new_level != 0xFF) if (new_level != 0xFF) {
avdt_cb.trace_level = new_level; avdt_cb.trace_level = new_level;
}
return (avdt_cb.trace_level); return (avdt_cb.trace_level);
} }

35
components/bt/bluedroid/stack/avdt/avdt_ccb.c Executable file → Normal file
View file

@ -316,14 +316,10 @@ void avdt_ccb_event(tAVDT_CCB *p_ccb, UINT8 event, tAVDT_CCB_EVT *p_data)
} }
/* execute action functions */ /* execute action functions */
for (i = 0; i < AVDT_CCB_ACTIONS; i++) for (i = 0; i < AVDT_CCB_ACTIONS; i++) {
{ if ((action = state_table[event][i]) != AVDT_CCB_IGNORE) {
if ((action = state_table[event][i]) != AVDT_CCB_IGNORE)
{
(*avdt_cb.p_ccb_act[action])(p_ccb, p_data); (*avdt_cb.p_ccb_act[action])(p_ccb, p_data);
} } else {
else
{
break; break;
} }
} }
@ -345,17 +341,14 @@ tAVDT_CCB *avdt_ccb_by_bd(BD_ADDR bd_addr)
tAVDT_CCB *p_ccb = &avdt_cb.ccb[0]; tAVDT_CCB *p_ccb = &avdt_cb.ccb[0];
int i; int i;
for (i = 0; i < AVDT_NUM_LINKS; i++, p_ccb++) for (i = 0; i < AVDT_NUM_LINKS; i++, p_ccb++) {
{
/* if allocated ccb has matching ccb */ /* if allocated ccb has matching ccb */
if (p_ccb->allocated && (!memcmp(p_ccb->peer_addr, bd_addr, BD_ADDR_LEN))) if (p_ccb->allocated && (!memcmp(p_ccb->peer_addr, bd_addr, BD_ADDR_LEN))) {
{
break; break;
} }
} }
if (i == AVDT_NUM_LINKS) if (i == AVDT_NUM_LINKS) {
{
/* if no ccb found */ /* if no ccb found */
p_ccb = NULL; p_ccb = NULL;
@ -380,10 +373,8 @@ tAVDT_CCB *avdt_ccb_alloc(BD_ADDR bd_addr)
tAVDT_CCB *p_ccb = &avdt_cb.ccb[0]; tAVDT_CCB *p_ccb = &avdt_cb.ccb[0];
int i; int i;
for (i = 0; i < AVDT_NUM_LINKS; i++, p_ccb++) for (i = 0; i < AVDT_NUM_LINKS; i++, p_ccb++) {
{ if (!p_ccb->allocated) {
if (!p_ccb->allocated)
{
p_ccb->allocated = TRUE; p_ccb->allocated = TRUE;
memcpy(p_ccb->peer_addr, bd_addr, BD_ADDR_LEN); memcpy(p_ccb->peer_addr, bd_addr, BD_ADDR_LEN);
GKI_init_q(&p_ccb->cmd_q); GKI_init_q(&p_ccb->cmd_q);
@ -394,8 +385,7 @@ tAVDT_CCB *avdt_ccb_alloc(BD_ADDR bd_addr)
} }
} }
if (i == AVDT_NUM_LINKS) if (i == AVDT_NUM_LINKS) {
{
/* out of ccbs */ /* out of ccbs */
p_ccb = NULL; p_ccb = NULL;
AVDT_TRACE_WARNING("Out of ccbs"); AVDT_TRACE_WARNING("Out of ccbs");
@ -453,12 +443,9 @@ tAVDT_CCB *avdt_ccb_by_idx(UINT8 idx)
tAVDT_CCB *p_ccb; tAVDT_CCB *p_ccb;
/* verify index */ /* verify index */
if (idx < AVDT_NUM_LINKS) if (idx < AVDT_NUM_LINKS) {
{
p_ccb = &avdt_cb.ccb[idx]; p_ccb = &avdt_cb.ccb[idx];
} } else {
else
{
p_ccb = NULL; p_ccb = NULL;
AVDT_TRACE_WARNING("No ccb for idx %d\n", idx); AVDT_TRACE_WARNING("No ccb for idx %d\n", idx);
} }

177
components/bt/bluedroid/stack/avdt/avdt_ccb_act.c Executable file → Normal file
View file

@ -56,22 +56,19 @@ static void avdt_ccb_clear_ccb(tAVDT_CCB *p_ccb)
p_ccb->ret_count = 0; p_ccb->ret_count = 0;
/* free message being fragmented */ /* free message being fragmented */
if (p_ccb->p_curr_msg != NULL) if (p_ccb->p_curr_msg != NULL) {
{
GKI_freebuf(p_ccb->p_curr_msg); GKI_freebuf(p_ccb->p_curr_msg);
p_ccb->p_curr_msg = NULL; p_ccb->p_curr_msg = NULL;
} }
/* free message being reassembled */ /* free message being reassembled */
if (p_ccb->p_rx_msg != NULL) if (p_ccb->p_rx_msg != NULL) {
{
GKI_freebuf(p_ccb->p_rx_msg); GKI_freebuf(p_ccb->p_rx_msg);
p_ccb->p_rx_msg = NULL; p_ccb->p_rx_msg = NULL;
} }
/* clear out response queue */ /* clear out response queue */
while ((p_buf = (BT_HDR *) GKI_dequeue(&p_ccb->rsp_q)) != NULL) while ((p_buf = (BT_HDR *) GKI_dequeue(&p_ccb->rsp_q)) != NULL) {
{
GKI_freebuf(p_buf); GKI_freebuf(p_buf);
} }
} }
@ -132,17 +129,14 @@ void avdt_ccb_chk_close(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data)
UNUSED(p_data); UNUSED(p_data);
/* see if there are any active scbs associated with this ccb */ /* see if there are any active scbs associated with this ccb */
for (i = 0; i < AVDT_NUM_SEPS; i++, p_scb++) for (i = 0; i < AVDT_NUM_SEPS; i++, p_scb++) {
{ if ((p_scb->allocated) && (p_scb->p_ccb == p_ccb)) {
if ((p_scb->allocated) && (p_scb->p_ccb == p_ccb))
{
break; break;
} }
} }
/* if no active scbs start idle timer */ /* if no active scbs start idle timer */
if (i == AVDT_NUM_SEPS) if (i == AVDT_NUM_SEPS) {
{
btu_start_timer(&p_ccb->timer_entry, BTU_TTYPE_AVDT_CCB_IDLE, avdt_cb.rcb.idle_tout); btu_start_timer(&p_ccb->timer_entry, BTU_TTYPE_AVDT_CCB_IDLE, avdt_cb.rcb.idle_tout);
} }
} }
@ -170,10 +164,8 @@ void avdt_ccb_hdl_discover_cmd(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data)
p_data->msg.discover_rsp.num_seps = 0; p_data->msg.discover_rsp.num_seps = 0;
/* for all allocated scbs */ /* for all allocated scbs */
for (i = 0; i < AVDT_NUM_SEPS; i++, p_scb++) for (i = 0; i < AVDT_NUM_SEPS; i++, p_scb++) {
{ if (p_scb->allocated) {
if (p_scb->allocated)
{
/* copy sep info */ /* copy sep info */
sep_info[p_data->msg.discover_rsp.num_seps].in_use = p_scb->in_use; sep_info[p_data->msg.discover_rsp.num_seps].in_use = p_scb->in_use;
sep_info[p_data->msg.discover_rsp.num_seps].seid = i + 1; sep_info[p_data->msg.discover_rsp.num_seps].seid = i + 1;
@ -277,8 +269,7 @@ void avdt_ccb_hdl_start_cmd(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data)
/* verify all streams in the right state */ /* verify all streams in the right state */
UINT8 seid = avdt_scb_verify(p_ccb, AVDT_VERIFY_START, p_data->msg.multi.seid_list, UINT8 seid = avdt_scb_verify(p_ccb, AVDT_VERIFY_START, p_data->msg.multi.seid_list,
p_data->msg.multi.num_seps, &err_code); p_data->msg.multi.num_seps, &err_code);
if (seid == 0 && err_code == 0) if (seid == 0 && err_code == 0) {
{
/* we're ok, send response */ /* we're ok, send response */
avdt_ccb_event(p_ccb, AVDT_CCB_API_START_RSP_EVT, p_data); avdt_ccb_event(p_ccb, AVDT_CCB_API_START_RSP_EVT, p_data);
} else { } else {
@ -317,10 +308,8 @@ void avdt_ccb_hdl_start_rsp(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data)
p = (UINT8 *)(p_ccb->p_curr_cmd + 1); p = (UINT8 *)(p_ccb->p_curr_cmd + 1);
/* little trick here; length of current command equals number of streams */ /* little trick here; length of current command equals number of streams */
for (i = 0; i < p_ccb->p_curr_cmd->len; i++) for (i = 0; i < p_ccb->p_curr_cmd->len; i++) {
{ if ((p_scb = avdt_scb_by_hdl(p[i])) != NULL) {
if ((p_scb = avdt_scb_by_hdl(p[i])) != NULL)
{
avdt_scb_event(p_scb, event, (tAVDT_SCB_EVT *) &p_data->msg); avdt_scb_event(p_scb, event, (tAVDT_SCB_EVT *) &p_data->msg);
} }
} }
@ -348,13 +337,10 @@ void avdt_ccb_hdl_suspend_cmd(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data)
/* verify all streams in the right state */ /* verify all streams in the right state */
if ((seid = avdt_scb_verify(p_ccb, AVDT_VERIFY_SUSPEND, p_data->msg.multi.seid_list, if ((seid = avdt_scb_verify(p_ccb, AVDT_VERIFY_SUSPEND, p_data->msg.multi.seid_list,
p_data->msg.multi.num_seps, &err_code)) == 0 && p_data->msg.multi.num_seps, &err_code)) == 0 &&
err_code == 0) err_code == 0) {
{
/* we're ok, send response */ /* we're ok, send response */
avdt_ccb_event(p_ccb, AVDT_CCB_API_SUSPEND_RSP_EVT, p_data); avdt_ccb_event(p_ccb, AVDT_CCB_API_SUSPEND_RSP_EVT, p_data);
} } else {
else
{
/* not ok, send reject */ /* not ok, send reject */
p_data->msg.hdr.err_code = err_code; p_data->msg.hdr.err_code = err_code;
p_data->msg.hdr.err_param = seid; p_data->msg.hdr.err_param = seid;
@ -391,10 +377,8 @@ void avdt_ccb_hdl_suspend_rsp(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data)
p = (UINT8 *)(p_ccb->p_curr_cmd + 1); p = (UINT8 *)(p_ccb->p_curr_cmd + 1);
/* little trick here; length of current command equals number of streams */ /* little trick here; length of current command equals number of streams */
for (i = 0; i < p_ccb->p_curr_cmd->len; i++) for (i = 0; i < p_ccb->p_curr_cmd->len; i++) {
{ if ((p_scb = avdt_scb_by_hdl(p[i])) != NULL) {
if ((p_scb = avdt_scb_by_hdl(p[i])) != NULL)
{
avdt_scb_event(p_scb, event, (tAVDT_SCB_EVT *) &p_data->msg); avdt_scb_event(p_scb, event, (tAVDT_SCB_EVT *) &p_data->msg);
} }
} }
@ -470,8 +454,9 @@ void avdt_ccb_snd_getcap_cmd(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data)
p_ccb->proc_busy = TRUE; p_ccb->proc_busy = TRUE;
/* build and queue discover req */ /* build and queue discover req */
if (p_data->msg.hdr.sig_id == AVDT_SIG_GET_ALLCAP) if (p_data->msg.hdr.sig_id == AVDT_SIG_GET_ALLCAP) {
sig_id = AVDT_SIG_GET_ALLCAP; sig_id = AVDT_SIG_GET_ALLCAP;
}
avdt_msg_send_cmd(p_ccb, NULL, sig_id, (tAVDT_MSG *) &p_data->getcap.single); avdt_msg_send_cmd(p_ccb, NULL, sig_id, (tAVDT_MSG *) &p_data->getcap.single);
} }
@ -492,8 +477,9 @@ void avdt_ccb_snd_getcap_rsp(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data)
{ {
UINT8 sig_id = AVDT_SIG_GETCAP; UINT8 sig_id = AVDT_SIG_GETCAP;
if (p_data->msg.hdr.sig_id == AVDT_SIG_GET_ALLCAP) if (p_data->msg.hdr.sig_id == AVDT_SIG_GET_ALLCAP) {
sig_id = AVDT_SIG_GET_ALLCAP; sig_id = AVDT_SIG_GET_ALLCAP;
}
/* send response */ /* send response */
avdt_msg_send_rsp(p_ccb, sig_id, &p_data->msg); avdt_msg_send_rsp(p_ccb, sig_id, &p_data->msg);
@ -524,21 +510,16 @@ void avdt_ccb_snd_start_cmd(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data)
/* verify all streams in the right state */ /* verify all streams in the right state */
if ((avdt_msg.hdr.err_param = avdt_scb_verify(p_ccb, AVDT_VERIFY_OPEN, p_data->msg.multi.seid_list, if ((avdt_msg.hdr.err_param = avdt_scb_verify(p_ccb, AVDT_VERIFY_OPEN, p_data->msg.multi.seid_list,
p_data->msg.multi.num_seps, &avdt_msg.hdr.err_code)) == 0) p_data->msg.multi.num_seps, &avdt_msg.hdr.err_code)) == 0) {
{
/* set peer seid list in messsage */ /* set peer seid list in messsage */
avdt_scb_peer_seid_list(&p_data->msg.multi); avdt_scb_peer_seid_list(&p_data->msg.multi);
/* send command */ /* send command */
avdt_msg_send_cmd(p_ccb, seid_list, AVDT_SIG_START, &p_data->msg); avdt_msg_send_cmd(p_ccb, seid_list, AVDT_SIG_START, &p_data->msg);
} } else {
else
{
/* failed; send ourselves a reject for each stream */ /* failed; send ourselves a reject for each stream */
for (i = 0; i < p_data->msg.multi.num_seps; i++) for (i = 0; i < p_data->msg.multi.num_seps; i++) {
{ if ((p_scb = avdt_scb_by_hdl(seid_list[i])) != NULL) {
if ((p_scb = avdt_scb_by_hdl(seid_list[i])) != NULL)
{
avdt_scb_event(p_scb, AVDT_SCB_MSG_START_REJ_EVT, (tAVDT_SCB_EVT *) &avdt_msg.hdr); avdt_scb_event(p_scb, AVDT_SCB_MSG_START_REJ_EVT, (tAVDT_SCB_EVT *) &avdt_msg.hdr);
} }
} }
@ -567,10 +548,8 @@ void avdt_ccb_snd_start_rsp(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data)
avdt_msg_send_rsp(p_ccb, AVDT_SIG_START, &p_data->msg); avdt_msg_send_rsp(p_ccb, AVDT_SIG_START, &p_data->msg);
/* send start event to each scb */ /* send start event to each scb */
for (i = 0; i < p_data->msg.multi.num_seps; i++) for (i = 0; i < p_data->msg.multi.num_seps; i++) {
{ if ((p_scb = avdt_scb_by_hdl(p_data->msg.multi.seid_list[i])) != NULL) {
if ((p_scb = avdt_scb_by_hdl(p_data->msg.multi.seid_list[i])) != NULL)
{
avdt_scb_event(p_scb, AVDT_SCB_MSG_START_CMD_EVT, NULL); avdt_scb_event(p_scb, AVDT_SCB_MSG_START_CMD_EVT, NULL);
} }
} }
@ -602,21 +581,16 @@ void avdt_ccb_snd_suspend_cmd(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data)
/* verify all streams in the right state */ /* verify all streams in the right state */
if ((avdt_msg.hdr.err_param = avdt_scb_verify(p_ccb, AVDT_VERIFY_STREAMING, p_data->msg.multi.seid_list, if ((avdt_msg.hdr.err_param = avdt_scb_verify(p_ccb, AVDT_VERIFY_STREAMING, p_data->msg.multi.seid_list,
p_data->msg.multi.num_seps, &avdt_msg.hdr.err_code)) == 0) p_data->msg.multi.num_seps, &avdt_msg.hdr.err_code)) == 0) {
{
/* set peer seid list in messsage */ /* set peer seid list in messsage */
avdt_scb_peer_seid_list(&p_data->msg.multi); avdt_scb_peer_seid_list(&p_data->msg.multi);
/* send command */ /* send command */
avdt_msg_send_cmd(p_ccb, seid_list, AVDT_SIG_SUSPEND, &p_data->msg); avdt_msg_send_cmd(p_ccb, seid_list, AVDT_SIG_SUSPEND, &p_data->msg);
} } else {
else
{
/* failed; send ourselves a reject for each stream */ /* failed; send ourselves a reject for each stream */
for (i = 0; i < p_data->msg.multi.num_seps; i++) for (i = 0; i < p_data->msg.multi.num_seps; i++) {
{ if ((p_scb = avdt_scb_by_hdl(seid_list[i])) != NULL) {
if ((p_scb = avdt_scb_by_hdl(seid_list[i])) != NULL)
{
avdt_scb_event(p_scb, AVDT_SCB_MSG_SUSPEND_REJ_EVT, (tAVDT_SCB_EVT *) &avdt_msg.hdr); avdt_scb_event(p_scb, AVDT_SCB_MSG_SUSPEND_REJ_EVT, (tAVDT_SCB_EVT *) &avdt_msg.hdr);
} }
} }
@ -645,10 +619,8 @@ void avdt_ccb_snd_suspend_rsp(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data)
avdt_msg_send_rsp(p_ccb, AVDT_SIG_SUSPEND, &p_data->msg); avdt_msg_send_rsp(p_ccb, AVDT_SIG_SUSPEND, &p_data->msg);
/* send start event to each scb */ /* send start event to each scb */
for (i = 0; i < p_data->msg.multi.num_seps; i++) for (i = 0; i < p_data->msg.multi.num_seps; i++) {
{ if ((p_scb = avdt_scb_by_hdl(p_data->msg.multi.seid_list[i])) != NULL) {
if ((p_scb = avdt_scb_by_hdl(p_data->msg.multi.seid_list[i])) != NULL)
{
avdt_scb_event(p_scb, AVDT_SCB_MSG_SUSPEND_CMD_EVT, NULL); avdt_scb_event(p_scb, AVDT_SCB_MSG_SUSPEND_CMD_EVT, NULL);
} }
} }
@ -682,8 +654,7 @@ void avdt_ccb_clear_cmds(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data)
** to handle the case where there is a command on deck in p_curr_cmd, ** to handle the case where there is a command on deck in p_curr_cmd,
** plus we need to clear out the queue ** plus we need to clear out the queue
*/ */
do do {
{
/* we know p_curr_cmd = NULL after this */ /* we know p_curr_cmd = NULL after this */
avdt_ccb_cmd_fail(p_ccb, (tAVDT_CCB_EVT *) &err_code); avdt_ccb_cmd_fail(p_ccb, (tAVDT_CCB_EVT *) &err_code);
@ -693,10 +664,8 @@ void avdt_ccb_clear_cmds(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data)
} while (p_ccb->p_curr_cmd != NULL); } while (p_ccb->p_curr_cmd != NULL);
/* send a CC_CLOSE_EVT any active scbs associated with this ccb */ /* send a CC_CLOSE_EVT any active scbs associated with this ccb */
for (i = 0; i < AVDT_NUM_SEPS; i++, p_scb++) for (i = 0; i < AVDT_NUM_SEPS; i++, p_scb++) {
{ if ((p_scb->allocated) && (p_scb->p_ccb == p_ccb)) {
if ((p_scb->allocated) && (p_scb->p_ccb == p_ccb))
{
avdt_scb_event(p_scb, AVDT_SCB_CC_CLOSE_EVT, NULL); avdt_scb_event(p_scb, AVDT_SCB_CC_CLOSE_EVT, NULL);
} }
} }
@ -720,8 +689,7 @@ void avdt_ccb_cmd_fail(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data)
UINT8 evt; UINT8 evt;
tAVDT_SCB *p_scb; tAVDT_SCB *p_scb;
if (p_ccb->p_curr_cmd != NULL) if (p_ccb->p_curr_cmd != NULL) {
{
/* set up data */ /* set up data */
msg.hdr.err_code = p_data->err_code; msg.hdr.err_code = p_data->err_code;
msg.hdr.err_param = 0; msg.hdr.err_param = 0;
@ -730,16 +698,12 @@ void avdt_ccb_cmd_fail(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data)
/* pretend that we received a rej message */ /* pretend that we received a rej message */
evt = avdt_msg_rej_2_evt[p_ccb->p_curr_cmd->event - 1]; evt = avdt_msg_rej_2_evt[p_ccb->p_curr_cmd->event - 1];
if (evt & AVDT_CCB_MKR) if (evt & AVDT_CCB_MKR) {
{
avdt_ccb_event(p_ccb, (UINT8) (evt & ~AVDT_CCB_MKR), (tAVDT_CCB_EVT *) &msg); avdt_ccb_event(p_ccb, (UINT8) (evt & ~AVDT_CCB_MKR), (tAVDT_CCB_EVT *) &msg);
} } else {
else
{
/* we get the scb out of the current cmd */ /* we get the scb out of the current cmd */
p_scb = avdt_scb_by_hdl(*((UINT8 *)(p_ccb->p_curr_cmd + 1))); p_scb = avdt_scb_by_hdl(*((UINT8 *)(p_ccb->p_curr_cmd + 1)));
if (p_scb != NULL) if (p_scb != NULL) {
{
avdt_scb_event(p_scb, evt, (tAVDT_SCB_EVT *) &msg); avdt_scb_event(p_scb, evt, (tAVDT_SCB_EVT *) &msg);
} }
} }
@ -764,8 +728,7 @@ void avdt_ccb_free_cmd(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data)
{ {
UNUSED(p_data); UNUSED(p_data);
if (p_ccb->p_curr_cmd != NULL) if (p_ccb->p_curr_cmd != NULL) {
{
GKI_freebuf(p_ccb->p_curr_cmd); GKI_freebuf(p_ccb->p_curr_cmd);
p_ccb->p_curr_cmd = NULL; p_ccb->p_curr_cmd = NULL;
} }
@ -806,23 +769,18 @@ void avdt_ccb_ret_cmd(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data)
BT_HDR *p_msg; BT_HDR *p_msg;
p_ccb->ret_count++; p_ccb->ret_count++;
if (p_ccb->ret_count == AVDT_RET_MAX) if (p_ccb->ret_count == AVDT_RET_MAX) {
{
/* command failed */ /* command failed */
p_ccb->ret_count = 0; p_ccb->ret_count = 0;
avdt_ccb_cmd_fail(p_ccb, (tAVDT_CCB_EVT *) &err_code); avdt_ccb_cmd_fail(p_ccb, (tAVDT_CCB_EVT *) &err_code);
/* go to next queued command */ /* go to next queued command */
avdt_ccb_snd_cmd(p_ccb, p_data); avdt_ccb_snd_cmd(p_ccb, p_data);
} } else {
else
{
/* if command pending and we're not congested and not sending a fragment */ /* if command pending and we're not congested and not sending a fragment */
if ((!p_ccb->cong) && (p_ccb->p_curr_msg == NULL) && (p_ccb->p_curr_cmd != NULL)) if ((!p_ccb->cong) && (p_ccb->p_curr_msg == NULL) && (p_ccb->p_curr_cmd != NULL)) {
{
/* make copy of message in p_curr_cmd and send it */ /* make copy of message in p_curr_cmd and send it */
if ((p_msg = (BT_HDR *) GKI_getpoolbuf(AVDT_CMD_POOL_ID)) != NULL) if ((p_msg = (BT_HDR *) GKI_getpoolbuf(AVDT_CMD_POOL_ID)) != NULL) {
{
memcpy(p_msg, p_ccb->p_curr_cmd, memcpy(p_msg, p_ccb->p_curr_cmd,
(sizeof(BT_HDR) + p_ccb->p_curr_cmd->offset + p_ccb->p_curr_cmd->len)); (sizeof(BT_HDR) + p_ccb->p_curr_cmd->offset + p_ccb->p_curr_cmd->len));
avdt_msg_send(p_ccb, p_msg); avdt_msg_send(p_ccb, p_msg);
@ -853,13 +811,10 @@ void avdt_ccb_snd_cmd(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data)
/* do we have commands to send? send next command; make sure we're clear; /* do we have commands to send? send next command; make sure we're clear;
** not congested, not sending fragment, not waiting for response ** not congested, not sending fragment, not waiting for response
*/ */
if ((!p_ccb->cong) && (p_ccb->p_curr_msg == NULL) && (p_ccb->p_curr_cmd == NULL)) if ((!p_ccb->cong) && (p_ccb->p_curr_msg == NULL) && (p_ccb->p_curr_cmd == NULL)) {
{ if ((p_msg = (BT_HDR *) GKI_dequeue(&p_ccb->cmd_q)) != NULL) {
if ((p_msg = (BT_HDR *) GKI_dequeue(&p_ccb->cmd_q)) != NULL)
{
/* make a copy of buffer in p_curr_cmd */ /* make a copy of buffer in p_curr_cmd */
if ((p_ccb->p_curr_cmd = (BT_HDR *) GKI_getpoolbuf(AVDT_CMD_POOL_ID)) != NULL) if ((p_ccb->p_curr_cmd = (BT_HDR *) GKI_getpoolbuf(AVDT_CMD_POOL_ID)) != NULL) {
{
memcpy(p_ccb->p_curr_cmd, p_msg, (sizeof(BT_HDR) + p_msg->offset + p_msg->len)); memcpy(p_ccb->p_curr_cmd, p_msg, (sizeof(BT_HDR) + p_msg->offset + p_msg->len));
avdt_msg_send(p_ccb, p_msg); avdt_msg_send(p_ccb, p_msg);
@ -884,20 +839,15 @@ void avdt_ccb_snd_msg(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data)
UNUSED(p_data); UNUSED(p_data);
/* if not congested */ /* if not congested */
if (!p_ccb->cong) if (!p_ccb->cong) {
{
/* are we sending a fragmented message? continue sending fragment */ /* are we sending a fragmented message? continue sending fragment */
if (p_ccb->p_curr_msg != NULL) if (p_ccb->p_curr_msg != NULL) {
{
avdt_msg_send(p_ccb, NULL); avdt_msg_send(p_ccb, NULL);
} }
/* do we have responses to send? send them */ /* do we have responses to send? send them */
else if (!GKI_queue_is_empty(&p_ccb->rsp_q)) else if (!GKI_queue_is_empty(&p_ccb->rsp_q)) {
{ while ((p_msg = (BT_HDR *) GKI_dequeue(&p_ccb->rsp_q)) != NULL) {
while ((p_msg = (BT_HDR *) GKI_dequeue(&p_ccb->rsp_q)) != NULL) if (avdt_msg_send(p_ccb, p_msg) == TRUE) {
{
if (avdt_msg_send(p_ccb, p_msg) == TRUE)
{
/* break out if congested */ /* break out if congested */
break; break;
} }
@ -962,8 +912,7 @@ void avdt_ccb_chk_reconn(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data)
UINT8 err_code = AVDT_ERR_CONNECT; UINT8 err_code = AVDT_ERR_CONNECT;
UNUSED(p_data); UNUSED(p_data);
if (p_ccb->reconn) if (p_ccb->reconn) {
{
p_ccb->reconn = FALSE; p_ccb->reconn = FALSE;
/* clear out ccb */ /* clear out ccb */
@ -974,9 +923,7 @@ void avdt_ccb_chk_reconn(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data)
/* reopen the signaling channel */ /* reopen the signaling channel */
avdt_ccb_event(p_ccb, AVDT_CCB_UL_OPEN_EVT, NULL); avdt_ccb_event(p_ccb, AVDT_CCB_UL_OPEN_EVT, NULL);
} } else {
else
{
avdt_ccb_ll_closed(p_ccb, NULL); avdt_ccb_ll_closed(p_ccb, NULL);
} }
} }
@ -996,8 +943,7 @@ void avdt_ccb_chk_timer(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data)
{ {
UNUSED(p_data); UNUSED(p_data);
if (p_ccb->timer_entry.event == BTU_TTYPE_AVDT_CCB_IDLE) if (p_ccb->timer_entry.event == BTU_TTYPE_AVDT_CCB_IDLE) {
{
btu_stop_timer(&p_ccb->timer_entry); btu_stop_timer(&p_ccb->timer_entry);
} }
} }
@ -1039,9 +985,10 @@ void avdt_ccb_set_disconn(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data)
p_ccb->p_conn_cback, p_data->disconnect.p_cback); p_ccb->p_conn_cback, p_data->disconnect.p_cback);
*/ */
/* save callback */ /* save callback */
if (p_data->disconnect.p_cback) if (p_data->disconnect.p_cback) {
p_ccb->p_conn_cback = p_data->disconnect.p_cback; p_ccb->p_conn_cback = p_data->disconnect.p_cback;
} }
}
/******************************************************************************* /*******************************************************************************
** **
@ -1087,8 +1034,9 @@ void avdt_ccb_ll_closed(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data)
/* save callback pointer, bd addr */ /* save callback pointer, bd addr */
p_cback = p_ccb->p_conn_cback; p_cback = p_ccb->p_conn_cback;
if (!p_cback) if (!p_cback) {
p_cback = avdt_cb.p_conn_cback; p_cback = avdt_cb.p_conn_cback;
}
memcpy(bd_addr, p_ccb->peer_addr, BD_ADDR_LEN); memcpy(bd_addr, p_ccb->peer_addr, BD_ADDR_LEN);
disc_rsn = p_ccb->disc_rsn; disc_rsn = p_ccb->disc_rsn;
@ -1097,8 +1045,7 @@ void avdt_ccb_ll_closed(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data)
avdt_ccb_dealloc(p_ccb, NULL); avdt_ccb_dealloc(p_ccb, NULL);
/* call callback */ /* call callback */
if (p_cback) if (p_cback) {
{
avdt_ctrl.hdr.err_code = 0; avdt_ctrl.hdr.err_code = 0;
avdt_ctrl.hdr.err_param = disc_rsn; avdt_ctrl.hdr.err_param = disc_rsn;
@ -1122,12 +1069,12 @@ void avdt_ccb_ll_opened(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data)
p_ccb->ll_opened = TRUE; p_ccb->ll_opened = TRUE;
if (!p_ccb->p_conn_cback) if (!p_ccb->p_conn_cback) {
p_ccb->p_conn_cback = avdt_cb.p_conn_cback; p_ccb->p_conn_cback = avdt_cb.p_conn_cback;
}
/* call callback */ /* call callback */
if (p_ccb->p_conn_cback) if (p_ccb->p_conn_cback) {
{
avdt_ctrl.hdr.err_code = 0; avdt_ctrl.hdr.err_code = 0;
avdt_ctrl.hdr.err_param = p_data->msg.hdr.err_param; avdt_ctrl.hdr.err_param = p_data->msg.hdr.err_param;
(*p_ccb->p_conn_cback)(0, p_ccb->peer_addr, AVDT_CONNECT_IND_EVT, &avdt_ctrl); (*p_ccb->p_conn_cback)(0, p_ccb->peer_addr, AVDT_CONNECT_IND_EVT, &avdt_ctrl);

130
components/bt/bluedroid/stack/avdt/avdt_l2c.c Executable file → Normal file
View file

@ -80,8 +80,7 @@ static void avdt_sec_check_complete_term (BD_ADDR bd_addr, tBT_TRANSPORT transpo
UNUSED(p_ref_data); UNUSED(p_ref_data);
AVDT_TRACE_DEBUG("avdt_sec_check_complete_term res: %d\n", res); AVDT_TRACE_DEBUG("avdt_sec_check_complete_term res: %d\n", res);
if (!bd_addr) if (!bd_addr) {
{
AVDT_TRACE_WARNING("avdt_sec_check_complete_term: NULL BD_ADDR"); AVDT_TRACE_WARNING("avdt_sec_check_complete_term: NULL BD_ADDR");
return; return;
@ -89,11 +88,11 @@ static void avdt_sec_check_complete_term (BD_ADDR bd_addr, tBT_TRANSPORT transpo
p_ccb = avdt_ccb_by_bd(bd_addr); p_ccb = avdt_ccb_by_bd(bd_addr);
p_tbl = avdt_ad_tc_tbl_by_st(AVDT_CHAN_SIG, p_ccb, AVDT_AD_ST_SEC_ACP); p_tbl = avdt_ad_tc_tbl_by_st(AVDT_CHAN_SIG, p_ccb, AVDT_AD_ST_SEC_ACP);
if (p_tbl == NULL) if (p_tbl == NULL) {
return; return;
}
if (res == BTM_SUCCESS) if (res == BTM_SUCCESS) {
{
/* Send response to the L2CAP layer. */ /* Send response to the L2CAP layer. */
L2CA_ConnectRsp (bd_addr, p_tbl->id, p_tbl->lcid, L2CAP_CONN_OK, L2CAP_CONN_OK); L2CA_ConnectRsp (bd_addr, p_tbl->id, p_tbl->lcid, L2CAP_CONN_OK, L2CAP_CONN_OK);
@ -111,9 +110,7 @@ static void avdt_sec_check_complete_term (BD_ADDR bd_addr, tBT_TRANSPORT transpo
cfg.flush_to_present = TRUE; cfg.flush_to_present = TRUE;
cfg.flush_to = p_tbl->my_flush_to; cfg.flush_to = p_tbl->my_flush_to;
L2CA_ConfigReq(p_tbl->lcid, &cfg); L2CA_ConfigReq(p_tbl->lcid, &cfg);
} } else {
else
{
L2CA_ConnectRsp (bd_addr, p_tbl->id, p_tbl->lcid, L2CAP_CONN_SECURITY_BLOCK, L2CAP_CONN_OK); L2CA_ConnectRsp (bd_addr, p_tbl->id, p_tbl->lcid, L2CAP_CONN_SECURITY_BLOCK, L2CAP_CONN_OK);
avdt_ad_tc_close_ind(p_tbl, L2CAP_CONN_SECURITY_BLOCK); avdt_ad_tc_close_ind(p_tbl, L2CAP_CONN_SECURITY_BLOCK);
} }
@ -138,14 +135,15 @@ static void avdt_sec_check_complete_orig (BD_ADDR bd_addr, tBT_TRANSPORT trasnpo
UNUSED(p_ref_data); UNUSED(p_ref_data);
AVDT_TRACE_DEBUG("avdt_sec_check_complete_orig res: %d\n", res); AVDT_TRACE_DEBUG("avdt_sec_check_complete_orig res: %d\n", res);
if (bd_addr) if (bd_addr) {
p_ccb = avdt_ccb_by_bd(bd_addr); p_ccb = avdt_ccb_by_bd(bd_addr);
}
p_tbl = avdt_ad_tc_tbl_by_st(AVDT_CHAN_SIG, p_ccb, AVDT_AD_ST_SEC_INT); p_tbl = avdt_ad_tc_tbl_by_st(AVDT_CHAN_SIG, p_ccb, AVDT_AD_ST_SEC_INT);
if(p_tbl == NULL) if (p_tbl == NULL) {
return; return;
}
if( res == BTM_SUCCESS ) if ( res == BTM_SUCCESS ) {
{
/* set channel state */ /* set channel state */
p_tbl->state = AVDT_AD_ST_CFG; p_tbl->state = AVDT_AD_ST_CFG;
@ -156,9 +154,7 @@ static void avdt_sec_check_complete_orig (BD_ADDR bd_addr, tBT_TRANSPORT trasnpo
cfg.flush_to_present = TRUE; cfg.flush_to_present = TRUE;
cfg.flush_to = p_tbl->my_flush_to; cfg.flush_to = p_tbl->my_flush_to;
L2CA_ConfigReq(p_tbl->lcid, &cfg); L2CA_ConfigReq(p_tbl->lcid, &cfg);
} } else {
else
{
L2CA_DisconnectReq (p_tbl->lcid); L2CA_DisconnectReq (p_tbl->lcid);
avdt_ad_tc_close_ind(p_tbl, L2CAP_CONN_SECURITY_BLOCK); avdt_ad_tc_close_ind(p_tbl, L2CAP_CONN_SECURITY_BLOCK);
} }
@ -183,16 +179,12 @@ void avdt_l2c_connect_ind_cback(BD_ADDR bd_addr, UINT16 lcid, UINT16 psm, UINT8
UNUSED(psm); UNUSED(psm);
/* do we already have a control channel for this peer? */ /* do we already have a control channel for this peer? */
if ((p_ccb = avdt_ccb_by_bd(bd_addr)) == NULL) if ((p_ccb = avdt_ccb_by_bd(bd_addr)) == NULL) {
{
/* no, allocate ccb */ /* no, allocate ccb */
if ((p_ccb = avdt_ccb_alloc(bd_addr)) == NULL) if ((p_ccb = avdt_ccb_alloc(bd_addr)) == NULL) {
{
/* no ccb available, reject L2CAP connection */ /* no ccb available, reject L2CAP connection */
result = L2CAP_CONN_NO_RESOURCES; result = L2CAP_CONN_NO_RESOURCES;
} } else {
else
{
/* allocate and set up entry; first channel is always signaling */ /* allocate and set up entry; first channel is always signaling */
p_tbl = avdt_ad_tc_tbl_alloc(p_ccb); p_tbl = avdt_ad_tc_tbl_alloc(p_ccb);
p_tbl->my_mtu = avdt_cb.rcb.ctrl_mtu; p_tbl->my_mtu = avdt_cb.rcb.ctrl_mtu;
@ -208,24 +200,21 @@ void avdt_l2c_connect_ind_cback(BD_ADDR bd_addr, UINT16 lcid, UINT16 psm, UINT8
FALSE, BTM_SEC_PROTO_AVDT, FALSE, BTM_SEC_PROTO_AVDT,
AVDT_CHAN_SIG, AVDT_CHAN_SIG,
&avdt_sec_check_complete_term, NULL); &avdt_sec_check_complete_term, NULL);
if(rc == BTM_CMD_STARTED) if (rc == BTM_CMD_STARTED) {
{
L2CA_ConnectRsp (p_ccb->peer_addr, p_tbl->id, lcid, L2CAP_CONN_PENDING, L2CAP_CONN_OK); L2CA_ConnectRsp (p_ccb->peer_addr, p_tbl->id, lcid, L2CAP_CONN_PENDING, L2CAP_CONN_OK);
} }
return; return;
} }
} }
/* deal with simultaneous control channel connect case */ /* deal with simultaneous control channel connect case */
else if ((p_tbl = avdt_ad_tc_tbl_by_st(AVDT_CHAN_SIG, p_ccb, AVDT_AD_ST_CONN)) != NULL) else if ((p_tbl = avdt_ad_tc_tbl_by_st(AVDT_CHAN_SIG, p_ccb, AVDT_AD_ST_CONN)) != NULL) {
{
/* reject their connection */ /* reject their connection */
result = L2CAP_CONN_NO_RESOURCES; result = L2CAP_CONN_NO_RESOURCES;
} }
/* this must be a traffic channel; are we accepting a traffic channel /* this must be a traffic channel; are we accepting a traffic channel
** for this ccb? ** for this ccb?
*/ */
else if ((p_tbl = avdt_ad_tc_tbl_by_st(AVDT_CHAN_MEDIA, p_ccb, AVDT_AD_ST_ACP)) != NULL) else if ((p_tbl = avdt_ad_tc_tbl_by_st(AVDT_CHAN_MEDIA, p_ccb, AVDT_AD_ST_ACP)) != NULL) {
{
/* yes; proceed with connection */ /* yes; proceed with connection */
result = L2CAP_CONN_OK; result = L2CAP_CONN_OK;
} }
@ -233,15 +222,13 @@ void avdt_l2c_connect_ind_cback(BD_ADDR bd_addr, UINT16 lcid, UINT16 psm, UINT8
/* this must be a reporting channel; are we accepting a reporting channel /* this must be a reporting channel; are we accepting a reporting channel
** for this ccb? ** for this ccb?
*/ */
else if ((p_tbl = avdt_ad_tc_tbl_by_st(AVDT_CHAN_REPORT, p_ccb, AVDT_AD_ST_ACP)) != NULL) else if ((p_tbl = avdt_ad_tc_tbl_by_st(AVDT_CHAN_REPORT, p_ccb, AVDT_AD_ST_ACP)) != NULL) {
{
/* yes; proceed with connection */ /* yes; proceed with connection */
result = L2CAP_CONN_OK; result = L2CAP_CONN_OK;
} }
#endif #endif
/* else we're not listening for traffic channel; reject */ /* else we're not listening for traffic channel; reject */
else else {
{
result = L2CAP_CONN_NO_PSM; result = L2CAP_CONN_NO_PSM;
} }
@ -249,8 +236,7 @@ void avdt_l2c_connect_ind_cback(BD_ADDR bd_addr, UINT16 lcid, UINT16 psm, UINT8
L2CA_ConnectRsp(bd_addr, id, lcid, result, 0); L2CA_ConnectRsp(bd_addr, id, lcid, result, 0);
/* if result ok, proceed with connection */ /* if result ok, proceed with connection */
if (result == L2CAP_CONN_OK) if (result == L2CAP_CONN_OK) {
{
/* store idx in LCID table, store LCID in routing table */ /* store idx in LCID table, store LCID in routing table */
avdt_cb.ad.lcid_tbl[lcid - L2CAP_BASE_APPL_CID] = avdt_ad_tc_tbl_to_idx(p_tbl); avdt_cb.ad.lcid_tbl[lcid - L2CAP_BASE_APPL_CID] = avdt_ad_tc_tbl_to_idx(p_tbl);
avdt_cb.ad.rt_tbl[avdt_ccb_to_idx(p_ccb)][p_tbl->tcid].lcid = lcid; avdt_cb.ad.rt_tbl[avdt_ccb_to_idx(p_ccb)][p_tbl->tcid].lcid = lcid;
@ -287,16 +273,12 @@ void avdt_l2c_connect_cfm_cback(UINT16 lcid, UINT16 result)
AVDT_TRACE_DEBUG("avdt_l2c_connect_cfm_cback lcid: %d, result: %d\n", AVDT_TRACE_DEBUG("avdt_l2c_connect_cfm_cback lcid: %d, result: %d\n",
lcid, result); lcid, result);
/* look up info for this channel */ /* look up info for this channel */
if ((p_tbl = avdt_ad_tc_tbl_by_lcid(lcid)) != NULL) if ((p_tbl = avdt_ad_tc_tbl_by_lcid(lcid)) != NULL) {
{
/* if in correct state */ /* if in correct state */
if (p_tbl->state == AVDT_AD_ST_CONN) if (p_tbl->state == AVDT_AD_ST_CONN) {
{
/* if result successful */ /* if result successful */
if (result == L2CAP_CONN_OK) if (result == L2CAP_CONN_OK) {
{ if (p_tbl->tcid != AVDT_CHAN_SIG) {
if(p_tbl->tcid != AVDT_CHAN_SIG)
{
/* set channel state */ /* set channel state */
p_tbl->state = AVDT_AD_ST_CFG; p_tbl->state = AVDT_AD_ST_CFG;
@ -307,16 +289,11 @@ void avdt_l2c_connect_cfm_cback(UINT16 lcid, UINT16 result)
cfg.flush_to_present = TRUE; cfg.flush_to_present = TRUE;
cfg.flush_to = p_tbl->my_flush_to; cfg.flush_to = p_tbl->my_flush_to;
L2CA_ConfigReq(lcid, &cfg); L2CA_ConfigReq(lcid, &cfg);
} } else {
else
{
p_ccb = avdt_ccb_by_idx(p_tbl->ccb_idx); p_ccb = avdt_ccb_by_idx(p_tbl->ccb_idx);
if(p_ccb == NULL) if (p_ccb == NULL) {
{
result = L2CAP_CONN_NO_RESOURCES; result = L2CAP_CONN_NO_RESOURCES;
} } else {
else
{
/* set channel state */ /* set channel state */
p_tbl->state = AVDT_AD_ST_SEC_INT; p_tbl->state = AVDT_AD_ST_SEC_INT;
p_tbl->lcid = lcid; p_tbl->lcid = lcid;
@ -332,8 +309,7 @@ void avdt_l2c_connect_cfm_cback(UINT16 lcid, UINT16 result)
} }
/* failure; notify adaption that channel closed */ /* failure; notify adaption that channel closed */
if (result != L2CAP_CONN_OK) if (result != L2CAP_CONN_OK) {
{
avdt_ad_tc_close_ind(p_tbl, result); avdt_ad_tc_close_ind(p_tbl, result);
} }
} }
@ -355,28 +331,23 @@ void avdt_l2c_config_cfm_cback(UINT16 lcid, tL2CAP_CFG_INFO *p_cfg)
tAVDT_TC_TBL *p_tbl; tAVDT_TC_TBL *p_tbl;
/* look up info for this channel */ /* look up info for this channel */
if ((p_tbl = avdt_ad_tc_tbl_by_lcid(lcid)) != NULL) if ((p_tbl = avdt_ad_tc_tbl_by_lcid(lcid)) != NULL) {
{
p_tbl->lcid = lcid; p_tbl->lcid = lcid;
/* if in correct state */ /* if in correct state */
if (p_tbl->state == AVDT_AD_ST_CFG) if (p_tbl->state == AVDT_AD_ST_CFG) {
{
/* if result successful */ /* if result successful */
if (p_cfg->result == L2CAP_CONN_OK) if (p_cfg->result == L2CAP_CONN_OK) {
{
/* update cfg_flags */ /* update cfg_flags */
p_tbl->cfg_flags |= AVDT_L2C_CFG_CFM_DONE; p_tbl->cfg_flags |= AVDT_L2C_CFG_CFM_DONE;
/* if configuration complete */ /* if configuration complete */
if (p_tbl->cfg_flags & AVDT_L2C_CFG_IND_DONE) if (p_tbl->cfg_flags & AVDT_L2C_CFG_IND_DONE) {
{
avdt_ad_tc_open_ind(p_tbl); avdt_ad_tc_open_ind(p_tbl);
} }
} }
/* else failure */ /* else failure */
else else {
{
/* Send L2CAP disconnect req */ /* Send L2CAP disconnect req */
L2CA_DisconnectReq(lcid); L2CA_DisconnectReq(lcid);
} }
@ -399,15 +370,11 @@ void avdt_l2c_config_ind_cback(UINT16 lcid, tL2CAP_CFG_INFO *p_cfg)
tAVDT_TC_TBL *p_tbl; tAVDT_TC_TBL *p_tbl;
/* look up info for this channel */ /* look up info for this channel */
if ((p_tbl = avdt_ad_tc_tbl_by_lcid(lcid)) != NULL) if ((p_tbl = avdt_ad_tc_tbl_by_lcid(lcid)) != NULL) {
{
/* store the mtu in tbl */ /* store the mtu in tbl */
if (p_cfg->mtu_present) if (p_cfg->mtu_present) {
{
p_tbl->peer_mtu = p_cfg->mtu; p_tbl->peer_mtu = p_cfg->mtu;
} } else {
else
{
p_tbl->peer_mtu = L2CAP_DEFAULT_MTU; p_tbl->peer_mtu = L2CAP_DEFAULT_MTU;
} }
AVDT_TRACE_DEBUG("peer_mtu: %d, lcid: x%x\n", p_tbl->peer_mtu, lcid); AVDT_TRACE_DEBUG("peer_mtu: %d, lcid: x%x\n", p_tbl->peer_mtu, lcid);
@ -418,14 +385,12 @@ void avdt_l2c_config_ind_cback(UINT16 lcid, tL2CAP_CFG_INFO *p_cfg)
L2CA_ConfigRsp(lcid, p_cfg); L2CA_ConfigRsp(lcid, p_cfg);
/* if first config ind */ /* if first config ind */
if ((p_tbl->cfg_flags & AVDT_L2C_CFG_IND_DONE) == 0) if ((p_tbl->cfg_flags & AVDT_L2C_CFG_IND_DONE) == 0) {
{
/* update cfg_flags */ /* update cfg_flags */
p_tbl->cfg_flags |= AVDT_L2C_CFG_IND_DONE; p_tbl->cfg_flags |= AVDT_L2C_CFG_IND_DONE;
/* if configuration complete */ /* if configuration complete */
if (p_tbl->cfg_flags & AVDT_L2C_CFG_CFM_DONE) if (p_tbl->cfg_flags & AVDT_L2C_CFG_CFM_DONE) {
{
avdt_ad_tc_open_ind(p_tbl); avdt_ad_tc_open_ind(p_tbl);
} }
} }
@ -449,10 +414,8 @@ void avdt_l2c_disconnect_ind_cback(UINT16 lcid, BOOLEAN ack_needed)
AVDT_TRACE_DEBUG("avdt_l2c_disconnect_ind_cback lcid: %d, ack_needed: %d\n", AVDT_TRACE_DEBUG("avdt_l2c_disconnect_ind_cback lcid: %d, ack_needed: %d\n",
lcid, ack_needed); lcid, ack_needed);
/* look up info for this channel */ /* look up info for this channel */
if ((p_tbl = avdt_ad_tc_tbl_by_lcid(lcid)) != NULL) if ((p_tbl = avdt_ad_tc_tbl_by_lcid(lcid)) != NULL) {
{ if (ack_needed) {
if (ack_needed)
{
/* send L2CAP disconnect response */ /* send L2CAP disconnect response */
L2CA_DisconnectRsp(lcid); L2CA_DisconnectRsp(lcid);
} else { } else {
@ -480,8 +443,7 @@ void avdt_l2c_disconnect_cfm_cback(UINT16 lcid, UINT16 result)
AVDT_TRACE_DEBUG("avdt_l2c_disconnect_cfm_cback lcid: %d, result: %d\n", AVDT_TRACE_DEBUG("avdt_l2c_disconnect_cfm_cback lcid: %d, result: %d\n",
lcid, result); lcid, result);
/* look up info for this channel */ /* look up info for this channel */
if ((p_tbl = avdt_ad_tc_tbl_by_lcid(lcid)) != NULL) if ((p_tbl = avdt_ad_tc_tbl_by_lcid(lcid)) != NULL) {
{
avdt_ad_tc_close_ind(p_tbl, result); avdt_ad_tc_close_ind(p_tbl, result);
} }
} }
@ -501,8 +463,7 @@ void avdt_l2c_congestion_ind_cback(UINT16 lcid, BOOLEAN is_congested)
tAVDT_TC_TBL *p_tbl; tAVDT_TC_TBL *p_tbl;
/* look up info for this channel */ /* look up info for this channel */
if ((p_tbl = avdt_ad_tc_tbl_by_lcid(lcid)) != NULL) if ((p_tbl = avdt_ad_tc_tbl_by_lcid(lcid)) != NULL) {
{
avdt_ad_tc_cong_ind(p_tbl, is_congested); avdt_ad_tc_cong_ind(p_tbl, is_congested);
} }
} }
@ -522,12 +483,11 @@ void avdt_l2c_data_ind_cback(UINT16 lcid, BT_HDR *p_buf)
tAVDT_TC_TBL *p_tbl; tAVDT_TC_TBL *p_tbl;
/* look up info for this channel */ /* look up info for this channel */
if ((p_tbl = avdt_ad_tc_tbl_by_lcid(lcid)) != NULL) if ((p_tbl = avdt_ad_tc_tbl_by_lcid(lcid)) != NULL) {
{
avdt_ad_tc_data_ind(p_tbl, p_buf); avdt_ad_tc_data_ind(p_tbl, p_buf);
} } else { /* prevent buffer leak */
else /* prevent buffer leak */
GKI_freebuf(p_buf); GKI_freebuf(p_buf);
} }
}
#endif /* #if (defined(AVDT_INCLUDED) && AVDT_INCLUDED == TRUE) */ #endif /* #if (defined(AVDT_INCLUDED) && AVDT_INCLUDED == TRUE) */

461
components/bt/bluedroid/stack/avdt/avdt_msg.c Executable file → Normal file

File diff suppressed because it is too large Load diff

69
components/bt/bluedroid/stack/avdt/avdt_scb.c Executable file → Normal file
View file

@ -545,14 +545,10 @@ void avdt_scb_event(tAVDT_SCB *p_scb, UINT8 event, tAVDT_SCB_EVT *p_data)
} }
/* execute action functions */ /* execute action functions */
for (i = 0; i < AVDT_SCB_ACTIONS; i++) for (i = 0; i < AVDT_SCB_ACTIONS; i++) {
{ if ((action = state_table[event][i]) != AVDT_SCB_IGNORE) {
if ((action = state_table[event][i]) != AVDT_SCB_IGNORE)
{
(*avdt_cb.p_scb_act[action])(p_scb, p_data); (*avdt_cb.p_scb_act[action])(p_scb, p_data);
} } else {
else
{
break; break;
} }
} }
@ -592,17 +588,14 @@ tAVDT_SCB *avdt_scb_alloc(tAVDT_CS *p_cs)
int i; int i;
/* find available scb */ /* find available scb */
for (i = 0; i < AVDT_NUM_SEPS; i++, p_scb++) for (i = 0; i < AVDT_NUM_SEPS; i++, p_scb++) {
{ if (!p_scb->allocated) {
if (!p_scb->allocated)
{
memset(p_scb, 0, sizeof(tAVDT_SCB)); memset(p_scb, 0, sizeof(tAVDT_SCB));
p_scb->allocated = TRUE; p_scb->allocated = TRUE;
p_scb->p_ccb = NULL; p_scb->p_ccb = NULL;
/* initialize sink as activated */ /* initialize sink as activated */
if (p_cs->tsep == AVDT_TSEP_SNK) if (p_cs->tsep == AVDT_TSEP_SNK) {
{
p_scb->sink_activated = TRUE; p_scb->sink_activated = TRUE;
} }
@ -611,12 +604,10 @@ tAVDT_SCB *avdt_scb_alloc(tAVDT_CS *p_cs)
/* initialize fragments gueue */ /* initialize fragments gueue */
GKI_init_q(&p_scb->frag_q); GKI_init_q(&p_scb->frag_q);
if(p_cs->cfg.psc_mask & AVDT_PSC_MUX) if (p_cs->cfg.psc_mask & AVDT_PSC_MUX) {
{
p_scb->cs.cfg.mux_tcid_media = avdt_ad_type_to_tcid(AVDT_CHAN_MEDIA, p_scb); p_scb->cs.cfg.mux_tcid_media = avdt_ad_type_to_tcid(AVDT_CHAN_MEDIA, p_scb);
#if AVDT_REPORTING == TRUE #if AVDT_REPORTING == TRUE
if(p_cs->cfg.psc_mask & AVDT_PSC_REPORT) if (p_cs->cfg.psc_mask & AVDT_PSC_REPORT) {
{
p_scb->cs.cfg.mux_tcid_report = avdt_ad_type_to_tcid(AVDT_CHAN_REPORT, p_scb); p_scb->cs.cfg.mux_tcid_report = avdt_ad_type_to_tcid(AVDT_CHAN_REPORT, p_scb);
} }
#endif #endif
@ -628,8 +619,7 @@ tAVDT_SCB *avdt_scb_alloc(tAVDT_CS *p_cs)
} }
} }
if (i == AVDT_NUM_SEPS) if (i == AVDT_NUM_SEPS) {
{
/* out of ccbs */ /* out of ccbs */
p_scb = NULL; p_scb = NULL;
AVDT_TRACE_WARNING("Out of scbs"); AVDT_TRACE_WARNING("Out of scbs");
@ -660,8 +650,9 @@ void avdt_scb_dealloc(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
#if AVDT_MULTIPLEXING == TRUE #if AVDT_MULTIPLEXING == TRUE
/* free fragments we're holding, if any; it shouldn't happen */ /* free fragments we're holding, if any; it shouldn't happen */
while ((p_buf = GKI_dequeue (&p_scb->frag_q)) != NULL) while ((p_buf = GKI_dequeue (&p_scb->frag_q)) != NULL) {
GKI_freebuf(p_buf); GKI_freebuf(p_buf);
}
#endif #endif
memset(p_scb, 0, sizeof(tAVDT_SCB)); memset(p_scb, 0, sizeof(tAVDT_SCB));
@ -698,19 +689,15 @@ tAVDT_SCB *avdt_scb_by_hdl(UINT8 hdl)
tAVDT_SCB *p_scb; tAVDT_SCB *p_scb;
/* verify index */ /* verify index */
if ((hdl > 0) && (hdl <= AVDT_NUM_SEPS)) if ((hdl > 0) && (hdl <= AVDT_NUM_SEPS)) {
{
p_scb = &avdt_cb.scb[hdl - 1]; p_scb = &avdt_cb.scb[hdl - 1];
/* verify scb is allocated */ /* verify scb is allocated */
if (!p_scb->allocated) if (!p_scb->allocated) {
{
p_scb = NULL; p_scb = NULL;
AVDT_TRACE_WARNING("scb hdl %d not allocated\n", hdl); AVDT_TRACE_WARNING("scb hdl %d not allocated\n", hdl);
} }
} } else {
else
{
p_scb = NULL; p_scb = NULL;
AVDT_TRACE_WARNING("scb hdl %d out of range\n", hdl); AVDT_TRACE_WARNING("scb hdl %d out of range\n", hdl);
} }
@ -738,36 +725,38 @@ UINT8 avdt_scb_verify(tAVDT_CCB *p_ccb, UINT8 state, UINT8 *p_seid, UINT16 num_s
/* set nonsupported command mask */ /* set nonsupported command mask */
/* translate public state into private state */ /* translate public state into private state */
nsc_mask = 0; nsc_mask = 0;
if (state == AVDT_VERIFY_SUSPEND) if (state == AVDT_VERIFY_SUSPEND) {
nsc_mask = AVDT_NSC_SUSPEND; nsc_mask = AVDT_NSC_SUSPEND;
}
/* verify every scb */ /* verify every scb */
for (i = 0, *p_err_code = 0; (i < num_seid) && (*p_err_code == 0) && (i < AVDT_NUM_SEPS); i++) for (i = 0, *p_err_code = 0; (i < num_seid) && (*p_err_code == 0) && (i < AVDT_NUM_SEPS); i++) {
{ if ((p_scb = avdt_scb_by_hdl(p_seid[i])) == NULL) {
if ((p_scb = avdt_scb_by_hdl(p_seid[i])) == NULL)
*p_err_code = AVDT_ERR_BAD_STATE; *p_err_code = AVDT_ERR_BAD_STATE;
else if (p_scb->p_ccb != p_ccb) } else if (p_scb->p_ccb != p_ccb) {
*p_err_code = AVDT_ERR_BAD_STATE; *p_err_code = AVDT_ERR_BAD_STATE;
else if (p_scb->cs.nsc_mask & nsc_mask) } else if (p_scb->cs.nsc_mask & nsc_mask) {
*p_err_code = AVDT_ERR_NSC; *p_err_code = AVDT_ERR_NSC;
}
switch (state) { switch (state) {
case AVDT_VERIFY_OPEN: case AVDT_VERIFY_OPEN:
case AVDT_VERIFY_START: case AVDT_VERIFY_START:
if (p_scb->state != AVDT_SCB_OPEN_ST && p_scb->state != AVDT_SCB_STREAM_ST) if (p_scb->state != AVDT_SCB_OPEN_ST && p_scb->state != AVDT_SCB_STREAM_ST) {
*p_err_code = AVDT_ERR_BAD_STATE; *p_err_code = AVDT_ERR_BAD_STATE;
}
break; break;
case AVDT_VERIFY_SUSPEND: case AVDT_VERIFY_SUSPEND:
case AVDT_VERIFY_STREAMING: case AVDT_VERIFY_STREAMING:
if (p_scb->state != AVDT_SCB_STREAM_ST) if (p_scb->state != AVDT_SCB_STREAM_ST) {
*p_err_code = AVDT_ERR_BAD_STATE; *p_err_code = AVDT_ERR_BAD_STATE;
}
break; break;
} }
} }
if ((i != num_seid) && (i < AVDT_NUM_SEPS)) if ((i != num_seid) && (i < AVDT_NUM_SEPS)) {
{
ret = p_seid[i]; ret = p_seid[i];
} }
@ -790,10 +779,8 @@ void avdt_scb_peer_seid_list(tAVDT_MULTI *p_multi)
int i; int i;
tAVDT_SCB *p_scb; tAVDT_SCB *p_scb;
for (i = 0; i < p_multi->num_seps; i++) for (i = 0; i < p_multi->num_seps; i++) {
{ if ((p_scb = avdt_scb_by_hdl(p_multi->seid_list[i])) != NULL) {
if ((p_scb = avdt_scb_by_hdl(p_multi->seid_list[i])) != NULL)
{
p_multi->seid_list[i] = p_scb->peer_seid; p_multi->seid_list[i] = p_scb->peer_seid;
} }
} }

340
components/bt/bluedroid/stack/avdt/avdt_scb_act.c Executable file → Normal file
View file

@ -268,8 +268,7 @@ void avdt_scb_hdl_pkt_no_frag(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
p += o_cc * 4; p += o_cc * 4;
/* check for and skip over extension header */ /* check for and skip over extension header */
if (o_x) if (o_x) {
{
p += 2; p += 2;
BE_STREAM_TO_UINT16(ex_len, p); BE_STREAM_TO_UINT16(ex_len, p);
p += ex_len * 4; p += ex_len * 4;
@ -279,38 +278,31 @@ void avdt_scb_hdl_pkt_no_frag(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
offset = (UINT16) (p - p_start); offset = (UINT16) (p - p_start);
/* adjust length for any padding at end of packet */ /* adjust length for any padding at end of packet */
if (o_p) if (o_p) {
{
/* padding length in last byte of packet */ /* padding length in last byte of packet */
pad_len = *(p_start + p_data->p_pkt->len); pad_len = *(p_start + p_data->p_pkt->len);
} }
/* do sanity check */ /* do sanity check */
if ((offset > p_data->p_pkt->len) || ((pad_len + offset) > p_data->p_pkt->len)) if ((offset > p_data->p_pkt->len) || ((pad_len + offset) > p_data->p_pkt->len)) {
{
AVDT_TRACE_WARNING("Got bad media packet"); AVDT_TRACE_WARNING("Got bad media packet");
GKI_freebuf(p_data->p_pkt); GKI_freebuf(p_data->p_pkt);
} }
/* adjust offset and length and send it up */ /* adjust offset and length and send it up */
else else {
{
p_data->p_pkt->len -= (offset + pad_len); p_data->p_pkt->len -= (offset + pad_len);
p_data->p_pkt->offset += offset; p_data->p_pkt->offset += offset;
if (p_scb->cs.p_data_cback != NULL) if (p_scb->cs.p_data_cback != NULL) {
{
/* report sequence number */ /* report sequence number */
p_data->p_pkt->layer_specific = seq; p_data->p_pkt->layer_specific = seq;
(*p_scb->cs.p_data_cback)(avdt_scb_to_hdl(p_scb), p_data->p_pkt, (*p_scb->cs.p_data_cback)(avdt_scb_to_hdl(p_scb), p_data->p_pkt,
time_stamp, (UINT8)(m_pt | (marker << 7))); time_stamp, (UINT8)(m_pt | (marker << 7)));
} } else {
else
{
#if AVDT_MULTIPLEXING == TRUE #if AVDT_MULTIPLEXING == TRUE
if ((p_scb->cs.p_media_cback != NULL) if ((p_scb->cs.p_media_cback != NULL)
&& (p_scb->p_media_buf != NULL) && (p_scb->p_media_buf != NULL)
&& (p_scb->media_buf_len > p_data->p_pkt->len)) && (p_scb->media_buf_len > p_data->p_pkt->len)) {
{
/* media buffer enough length is assigned by application. Lets use it*/ /* media buffer enough length is assigned by application. Lets use it*/
memcpy(p_scb->p_media_buf, (UINT8 *)(p_data->p_pkt + 1) + p_data->p_pkt->offset, memcpy(p_scb->p_media_buf, (UINT8 *)(p_data->p_pkt + 1) + p_data->p_pkt->offset,
p_data->p_pkt->len); p_data->p_pkt->len);
@ -343,8 +335,7 @@ UINT8 * avdt_scb_hdl_report(tAVDT_SCB *p_scb, UINT8 *p, UINT16 len)
tAVDT_REPORT_DATA report, *p_rpt; tAVDT_REPORT_DATA report, *p_rpt;
AVDT_TRACE_DEBUG( "avdt_scb_hdl_report"); AVDT_TRACE_DEBUG( "avdt_scb_hdl_report");
if(p_scb->cs.p_report_cback) if (p_scb->cs.p_report_cback) {
{
p_rpt = &report; p_rpt = &report;
/* parse report packet header */ /* parse report packet header */
AVDT_MSG_PRS_RPT_OCTET1(p, o_v, o_p, o_cc); AVDT_MSG_PRS_RPT_OCTET1(p, o_v, o_p, o_cc);
@ -355,8 +346,7 @@ UINT8 * avdt_scb_hdl_report(tAVDT_SCB *p_scb, UINT8 *p, UINT16 len)
UNUSED(o_p); UNUSED(o_p);
UNUSED(o_v); UNUSED(o_v);
switch(pt) switch (pt) {
{
case AVDT_RTCP_PT_SR: /* the packet type - SR (Sender Report) */ case AVDT_RTCP_PT_SR: /* the packet type - SR (Sender Report) */
BE_STREAM_TO_UINT32(report.sr.ntp_sec, p); BE_STREAM_TO_UINT32(report.sr.ntp_sec, p);
BE_STREAM_TO_UINT32(report.sr.ntp_frac, p); BE_STREAM_TO_UINT32(report.sr.ntp_frac, p);
@ -376,12 +366,9 @@ UINT8 * avdt_scb_hdl_report(tAVDT_SCB *p_scb, UINT8 *p, UINT16 len)
break; break;
case AVDT_RTCP_PT_SDES: /* the packet type - SDES (Source Description) */ case AVDT_RTCP_PT_SDES: /* the packet type - SDES (Source Description) */
if(*p == AVDT_RTCP_SDES_CNAME) if (*p == AVDT_RTCP_SDES_CNAME) {
{
p_rpt = (tAVDT_REPORT_DATA *)(p + 2); p_rpt = (tAVDT_REPORT_DATA *)(p + 2);
} } else {
else
{
AVDT_TRACE_WARNING( " - SDES SSRC=0x%08x sc=%d %d len=%d %s\n", AVDT_TRACE_WARNING( " - SDES SSRC=0x%08x sc=%d %d len=%d %s\n",
ssrc, o_cc, *p, *(p + 1), p + 2); ssrc, o_cc, *p, *(p + 1), p + 2);
result = AVDT_BUSY; result = AVDT_BUSY;
@ -393,8 +380,9 @@ UINT8 * avdt_scb_hdl_report(tAVDT_SCB *p_scb, UINT8 *p, UINT16 len)
result = AVDT_BAD_PARAMS; result = AVDT_BAD_PARAMS;
} }
if(result == AVDT_SUCCESS) if (result == AVDT_SUCCESS) {
(*p_scb->cs.p_report_cback)(avdt_scb_to_hdl(p_scb), pt, p_rpt); (*p_scb->cs.p_report_cback)(avdt_scb_to_hdl(p_scb), pt, p_rpt);
}
} }
p_start += len; p_start += len;
@ -436,10 +424,8 @@ void avdt_scb_hdl_pkt_frag(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
p = (UINT8 *)(p_data->p_pkt + 1) + p_data->p_pkt->offset; p = (UINT8 *)(p_data->p_pkt + 1) + p_data->p_pkt->offset;
p_end = p + p_data->p_pkt->len; p_end = p + p_data->p_pkt->len;
/* parse all fragments */ /* parse all fragments */
while(p < p_end) while (p < p_end) {
{ if (p_end - p < 4) { /* length check. maximum length of AL header = 4 */
if (p_end - p < 4) /* length check. maximum length of AL header = 4 */
{
AVDT_TRACE_WARNING("p_end: %p - p:%p < 4\n", p_end, p); AVDT_TRACE_WARNING("p_end: %p - p:%p < 4\n", p_end, p);
break; break;
} }
@ -451,12 +437,12 @@ void avdt_scb_hdl_pkt_frag(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
/* in case of TSID=00000, a second AL header byte, before the length field, /* in case of TSID=00000, a second AL header byte, before the length field,
** is expected and contains the actual TSID, aligned with MSB */ ** is expected and contains the actual TSID, aligned with MSB */
if(al_tsid == 0) if (al_tsid == 0) {
al_tsid = *p++; al_tsid = *p++;
}
/* get remaining media length on base of lcode */ /* get remaining media length on base of lcode */
switch(al_lcode) switch (al_lcode) {
{
case AVDT_ALH_LCODE_NONE: /* No length field present. Take length from l2cap */ case AVDT_ALH_LCODE_NONE: /* No length field present. Take length from l2cap */
al_len = (UINT16)(p_end - p); al_len = (UINT16)(p_end - p);
break; break;
@ -473,21 +459,19 @@ void avdt_scb_hdl_pkt_frag(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
/* max fragment length */ /* max fragment length */
frag_len = (UINT16)(p_end - p); frag_len = (UINT16)(p_end - p);
/* if it isn't last fragment */ /* if it isn't last fragment */
if(frag_len >= al_len) if (frag_len >= al_len) {
frag_len = al_len; frag_len = al_len;
}
/* check TSID corresponds to config */ /* check TSID corresponds to config */
if (al_tsid != p_scb->curr_cfg.mux_tsid_media) if (al_tsid != p_scb->curr_cfg.mux_tsid_media) {
{
#if AVDT_REPORTING == TRUE #if AVDT_REPORTING == TRUE
if ((p_scb->curr_cfg.psc_mask & AVDT_PSC_REPORT) && if ((p_scb->curr_cfg.psc_mask & AVDT_PSC_REPORT) &&
(al_tsid == p_scb->curr_cfg.mux_tsid_report)) (al_tsid == p_scb->curr_cfg.mux_tsid_report)) {
{
/* parse reporting packet */ /* parse reporting packet */
p = avdt_scb_hdl_report(p_scb, p, frag_len); p = avdt_scb_hdl_report(p_scb, p, frag_len);
continue; continue;
} } else
else
#endif #endif
{ {
AVDT_TRACE_WARNING("bad tsid: %d, mux_tsid_media:%d\n", al_tsid, p_scb->curr_cfg.mux_tsid_media); AVDT_TRACE_WARNING("bad tsid: %d, mux_tsid_media:%d\n", al_tsid, p_scb->curr_cfg.mux_tsid_media);
@ -495,48 +479,40 @@ void avdt_scb_hdl_pkt_frag(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
} }
} }
/* check are buffer for assembling and related callback set */ /* check are buffer for assembling and related callback set */
else if ((p_scb->p_media_buf == NULL) || (p_scb->cs.p_media_cback == NULL)) else if ((p_scb->p_media_buf == NULL) || (p_scb->cs.p_media_cback == NULL)) {
{
AVDT_TRACE_WARNING("NULL p_media_buf or p_media_cback"); AVDT_TRACE_WARNING("NULL p_media_buf or p_media_cback");
break; break;
} }
/* it is media fragment beginning */ /* it is media fragment beginning */
if(!al_frag) /* is it first fragment of original media packet */ if (!al_frag) { /* is it first fragment of original media packet */
{
AVDT_TRACE_DEBUG("al:%d media:%d\n", AVDT_TRACE_DEBUG("al:%d media:%d\n",
al_len, p_scb->media_buf_len); al_len, p_scb->media_buf_len);
p_scb->frag_off = 0; p_scb->frag_off = 0;
p_scb->frag_org_len = al_len; /* total length of original media packet */ p_scb->frag_org_len = al_len; /* total length of original media packet */
/* length check: minimum length of media header is 12 */ /* length check: minimum length of media header is 12 */
if (p_scb->frag_org_len < 12) if (p_scb->frag_org_len < 12) {
{
AVDT_TRACE_WARNING("bad al_len: %d(<12)\n", al_len); AVDT_TRACE_WARNING("bad al_len: %d(<12)\n", al_len);
break; break;
} }
/* check that data fit into buffer */ /* check that data fit into buffer */
if (al_len > p_scb->media_buf_len) if (al_len > p_scb->media_buf_len) {
{
AVDT_TRACE_WARNING("bad al_len: %d(>%d)\n", al_len, p_scb->media_buf_len); AVDT_TRACE_WARNING("bad al_len: %d(>%d)\n", al_len, p_scb->media_buf_len);
break; break;
} }
/* make sure it is the last fragment in l2cap packet */ /* make sure it is the last fragment in l2cap packet */
if (p + al_len < p_end) if (p + al_len < p_end) {
{
AVDT_TRACE_WARNING("bad al_len: %d(>%d)\n", al_len, p_scb->media_buf_len); AVDT_TRACE_WARNING("bad al_len: %d(>%d)\n", al_len, p_scb->media_buf_len);
break; break;
} }
} } else {
else
{
AVDT_TRACE_DEBUG("al:%d media:%d frag_org_len:%d frag_off:%d\n", AVDT_TRACE_DEBUG("al:%d media:%d frag_org_len:%d frag_off:%d\n",
al_len, p_scb->media_buf_len, p_scb->frag_org_len, p_scb->frag_off); al_len, p_scb->media_buf_len, p_scb->frag_org_len, p_scb->frag_off);
/* check that remaining length from AL header equals to original len - length of already received fragments */ /* check that remaining length from AL header equals to original len - length of already received fragments */
if(al_len != p_scb->frag_org_len - p_scb->frag_off) if (al_len != p_scb->frag_org_len - p_scb->frag_off) {
{
AVDT_TRACE_WARNING("al_len:%d != (frag_org_len:%d - frag_off:%d) %d\n", AVDT_TRACE_WARNING("al_len:%d != (frag_org_len:%d - frag_off:%d) %d\n",
al_len, p_scb->frag_org_len, p_scb->frag_off, al_len, p_scb->frag_org_len, p_scb->frag_off,
(p_scb->frag_org_len - p_scb->frag_off)); (p_scb->frag_org_len - p_scb->frag_off));
@ -544,15 +520,13 @@ void avdt_scb_hdl_pkt_frag(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
} }
/* do sanity check */ /* do sanity check */
if (p_scb->frag_off == 0) if (p_scb->frag_off == 0) {
{
AVDT_TRACE_WARNING("frag_off=0"); AVDT_TRACE_WARNING("frag_off=0");
break; break;
} }
} }
/* do common sanity check */ /* do common sanity check */
if((p_scb->frag_org_len <= p_scb->frag_off) || (p_scb->frag_org_len >= p_scb->media_buf_len)) if ((p_scb->frag_org_len <= p_scb->frag_off) || (p_scb->frag_org_len >= p_scb->media_buf_len)) {
{
AVDT_TRACE_WARNING("common sanity frag_off:%d frag_org_len:%d media_buf_len:%d\n", AVDT_TRACE_WARNING("common sanity frag_off:%d frag_org_len:%d media_buf_len:%d\n",
p_scb->frag_off, p_scb->frag_org_len, p_scb->media_buf_len); p_scb->frag_off, p_scb->frag_org_len, p_scb->media_buf_len);
break; break;
@ -567,8 +541,7 @@ void avdt_scb_hdl_pkt_frag(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
/* move to the next fragment */ /* move to the next fragment */
p += frag_len; p += frag_len;
/* if it is last fragment in original media packet then process total media pocket */ /* if it is last fragment in original media packet then process total media pocket */
if(p_scb->frag_off == p_scb->frag_org_len) if (p_scb->frag_off == p_scb->frag_org_len) {
{
p_payload = p_scb->p_media_buf; p_payload = p_scb->p_media_buf;
/* media header */ /* media header */
@ -585,10 +558,8 @@ void avdt_scb_hdl_pkt_frag(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
p_payload += o_cc * 4; p_payload += o_cc * 4;
/* check for and skip over extension header */ /* check for and skip over extension header */
if (o_x) if (o_x) {
{ if (p_scb->p_media_buf + p_scb->frag_off - p_payload < 4) {
if(p_scb->p_media_buf + p_scb->frag_off - p_payload < 4)
{
AVDT_TRACE_WARNING("length check frag_off:%d p_media_buf:%p p_payload:%p\n", AVDT_TRACE_WARNING("length check frag_off:%d p_media_buf:%p p_payload:%p\n",
p_scb->frag_off, p_scb->p_media_buf, p_payload); p_scb->frag_off, p_scb->p_media_buf, p_payload);
break;/* length check */ break;/* length check */
@ -598,21 +569,19 @@ void avdt_scb_hdl_pkt_frag(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
p_payload += ex_len * 4; p_payload += ex_len * 4;
} }
if(p_payload >= p_scb->p_media_buf + p_scb->frag_off) if (p_payload >= p_scb->p_media_buf + p_scb->frag_off) {
{
AVDT_TRACE_WARNING("length check2 frag_off:%d p_media_buf:%p p_payload:%p\n", AVDT_TRACE_WARNING("length check2 frag_off:%d p_media_buf:%p p_payload:%p\n",
p_scb->frag_off, p_scb->p_media_buf, p_payload); p_scb->frag_off, p_scb->p_media_buf, p_payload);
break;/* length check */ break;/* length check */
} }
/* adjust length for any padding at end of packet */ /* adjust length for any padding at end of packet */
if (o_p) if (o_p) {
{
/* padding length in last byte of packet */ /* padding length in last byte of packet */
pad_len = *(p_scb->p_media_buf + p_scb->frag_off - 1); pad_len = *(p_scb->p_media_buf + p_scb->frag_off - 1);
} } else {
else
pad_len = 0; pad_len = 0;
}
/* payload length */ /* payload length */
payload_len = (UINT32)(p_scb->p_media_buf + p_scb->frag_off - pad_len - p_payload); payload_len = (UINT32)(p_scb->p_media_buf + p_scb->frag_off - pad_len - p_payload);
@ -620,16 +589,14 @@ void avdt_scb_hdl_pkt_frag(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
p_payload - p_scb->p_media_buf, payload_len); p_payload - p_scb->p_media_buf, payload_len);
/* send total media packet up */ /* send total media packet up */
if (p_scb->cs.p_media_cback != NULL) if (p_scb->cs.p_media_cback != NULL) {
{
(*p_scb->cs.p_media_cback)(avdt_scb_to_hdl(p_scb), p_payload, (*p_scb->cs.p_media_cback)(avdt_scb_to_hdl(p_scb), p_payload,
payload_len, time_stamp, seq, m_pt, marker); payload_len, time_stamp, seq, m_pt, marker);
} }
} }
} /* while(p < p_end) */ } /* while(p < p_end) */
if(p < p_end) if (p < p_end) {
{
AVDT_TRACE_WARNING("*** Got bad media packet"); AVDT_TRACE_WARNING("*** Got bad media packet");
} }
GKI_freebuf(p_data->p_pkt); GKI_freebuf(p_data->p_pkt);
@ -653,20 +620,16 @@ void avdt_scb_hdl_pkt(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
#if AVDT_MULTIPLEXING == TRUE #if AVDT_MULTIPLEXING == TRUE
/* select right function in dependance of is fragmentation supported or not */ /* select right function in dependance of is fragmentation supported or not */
if( 0 != (p_scb->curr_cfg.psc_mask & AVDT_PSC_MUX)) if ( 0 != (p_scb->curr_cfg.psc_mask & AVDT_PSC_MUX)) {
{
avdt_scb_hdl_pkt_frag(p_scb, p_data); avdt_scb_hdl_pkt_frag(p_scb, p_data);
} } else
else
#endif #endif
#if AVDT_REPORTING == TRUE #if AVDT_REPORTING == TRUE
if(p_data->p_pkt->layer_specific == AVDT_CHAN_REPORT) if (p_data->p_pkt->layer_specific == AVDT_CHAN_REPORT) {
{
p = (UINT8 *)(p_data->p_pkt + 1) + p_data->p_pkt->offset; p = (UINT8 *)(p_data->p_pkt + 1) + p_data->p_pkt->offset;
avdt_scb_hdl_report(p_scb, p, p_data->p_pkt->len); avdt_scb_hdl_report(p_scb, p, p_data->p_pkt->len);
GKI_freebuf(p_data->p_pkt); GKI_freebuf(p_data->p_pkt);
} } else
else
#endif #endif
avdt_scb_hdl_pkt_no_frag(p_scb, p_data); avdt_scb_hdl_pkt_no_frag(p_scb, p_data);
} }
@ -702,15 +665,12 @@ void avdt_scb_drop_pkt(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
void avdt_scb_hdl_reconfig_cmd(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data) void avdt_scb_hdl_reconfig_cmd(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
{ {
/* if command not supported */ /* if command not supported */
if (p_scb->cs.nsc_mask & AVDT_NSC_RECONFIG) if (p_scb->cs.nsc_mask & AVDT_NSC_RECONFIG) {
{
/* send reject */ /* send reject */
p_data->msg.hdr.err_code = AVDT_ERR_NSC; p_data->msg.hdr.err_code = AVDT_ERR_NSC;
p_data->msg.hdr.err_param = 0; p_data->msg.hdr.err_param = 0;
avdt_scb_event(p_scb, AVDT_SCB_API_RECONFIG_RSP_EVT, p_data); avdt_scb_event(p_scb, AVDT_SCB_API_RECONFIG_RSP_EVT, p_data);
} } else {
else
{
/* store requested configuration */ /* store requested configuration */
memcpy(&p_scb->req_cfg, p_data->msg.reconfig_cmd.p_cfg, sizeof(tAVDT_CFG)); memcpy(&p_scb->req_cfg, p_data->msg.reconfig_cmd.p_cfg, sizeof(tAVDT_CFG));
@ -734,16 +694,13 @@ void avdt_scb_hdl_reconfig_cmd(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
*******************************************************************************/ *******************************************************************************/
void avdt_scb_hdl_reconfig_rsp(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data) void avdt_scb_hdl_reconfig_rsp(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
{ {
if (p_data->msg.hdr.err_code == 0) if (p_data->msg.hdr.err_code == 0) {
{
/* store new configuration */ /* store new configuration */
if (p_scb->req_cfg.num_codec > 0) if (p_scb->req_cfg.num_codec > 0) {
{
p_scb->curr_cfg.num_codec = p_scb->req_cfg.num_codec; p_scb->curr_cfg.num_codec = p_scb->req_cfg.num_codec;
memcpy(p_scb->curr_cfg.codec_info, p_scb->req_cfg.codec_info, AVDT_CODEC_SIZE); memcpy(p_scb->curr_cfg.codec_info, p_scb->req_cfg.codec_info, AVDT_CODEC_SIZE);
} }
if (p_scb->req_cfg.num_protect > 0) if (p_scb->req_cfg.num_protect > 0) {
{
p_scb->curr_cfg.num_protect = p_scb->req_cfg.num_protect; p_scb->curr_cfg.num_protect = p_scb->req_cfg.num_protect;
memcpy(p_scb->curr_cfg.protect_info, p_scb->req_cfg.protect_info, AVDT_PROTECT_SIZE); memcpy(p_scb->curr_cfg.protect_info, p_scb->req_cfg.protect_info, AVDT_PROTECT_SIZE);
} }
@ -771,14 +728,11 @@ void avdt_scb_hdl_reconfig_rsp(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
void avdt_scb_hdl_security_cmd(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data) void avdt_scb_hdl_security_cmd(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
{ {
/* if command not supported */ /* if command not supported */
if (p_scb->cs.nsc_mask & AVDT_NSC_SECURITY) if (p_scb->cs.nsc_mask & AVDT_NSC_SECURITY) {
{
/* send reject */ /* send reject */
p_data->msg.hdr.err_code = AVDT_ERR_NSC; p_data->msg.hdr.err_code = AVDT_ERR_NSC;
avdt_scb_event(p_scb, AVDT_SCB_API_SECURITY_RSP_EVT, p_data); avdt_scb_event(p_scb, AVDT_SCB_API_SECURITY_RSP_EVT, p_data);
} } else {
else
{
/* call application callback */ /* call application callback */
(*p_scb->cs.p_ctrl_cback)(avdt_scb_to_hdl(p_scb), (*p_scb->cs.p_ctrl_cback)(avdt_scb_to_hdl(p_scb),
NULL, NULL,
@ -821,11 +775,9 @@ void avdt_scb_hdl_setconfig_cmd(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
{ {
tAVDT_CFG *p_cfg; tAVDT_CFG *p_cfg;
if (!p_scb->in_use) if (!p_scb->in_use) {
{
p_cfg = p_data->msg.config_cmd.p_cfg; p_cfg = p_data->msg.config_cmd.p_cfg;
if(p_scb->cs.cfg.codec_info[AVDT_CODEC_TYPE_INDEX] == p_cfg->codec_info[AVDT_CODEC_TYPE_INDEX]) if (p_scb->cs.cfg.codec_info[AVDT_CODEC_TYPE_INDEX] == p_cfg->codec_info[AVDT_CODEC_TYPE_INDEX]) {
{
/* set sep as in use */ /* set sep as in use */
p_scb->in_use = TRUE; p_scb->in_use = TRUE;
@ -838,17 +790,13 @@ void avdt_scb_hdl_setconfig_cmd(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
p_scb->p_ccb ? p_scb->p_ccb->peer_addr : NULL, p_scb->p_ccb ? p_scb->p_ccb->peer_addr : NULL,
AVDT_CONFIG_IND_EVT, AVDT_CONFIG_IND_EVT,
(tAVDT_CTRL *) &p_data->msg.config_cmd); (tAVDT_CTRL *) &p_data->msg.config_cmd);
} } else {
else
{
p_data->msg.hdr.err_code = AVDT_ERR_UNSUP_CFG; p_data->msg.hdr.err_code = AVDT_ERR_UNSUP_CFG;
p_data->msg.hdr.err_param = 0; p_data->msg.hdr.err_param = 0;
avdt_msg_send_rej(avdt_ccb_by_idx(p_data->msg.hdr.ccb_idx), avdt_msg_send_rej(avdt_ccb_by_idx(p_data->msg.hdr.ccb_idx),
p_data->msg.hdr.sig_id, &p_data->msg); p_data->msg.hdr.sig_id, &p_data->msg);
} }
} } else {
else
{
avdt_scb_rej_in_use(p_scb, p_data); avdt_scb_rej_in_use(p_scb, p_data);
} }
} }
@ -893,8 +841,7 @@ void avdt_scb_hdl_setconfig_rsp(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
tAVDT_EVT_HDR single; tAVDT_EVT_HDR single;
UNUSED(p_data); UNUSED(p_data);
if (p_scb->p_ccb != NULL) if (p_scb->p_ccb != NULL) {
{
/* save configuration */ /* save configuration */
memcpy(&p_scb->curr_cfg, &p_scb->req_cfg, sizeof(tAVDT_CFG)); memcpy(&p_scb->curr_cfg, &p_scb->req_cfg, sizeof(tAVDT_CFG));
@ -1017,8 +964,7 @@ void avdt_scb_hdl_tc_close(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
p_scb->cong = FALSE; p_scb->cong = FALSE;
/* free pkt we're holding, if any */ /* free pkt we're holding, if any */
if (p_scb->p_pkt != NULL) if (p_scb->p_pkt != NULL) {
{
GKI_freebuf(p_scb->p_pkt); GKI_freebuf(p_scb->p_pkt);
p_scb->p_pkt = NULL; p_scb->p_pkt = NULL;
} }
@ -1026,16 +972,14 @@ void avdt_scb_hdl_tc_close(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
/* stop transport channel timer */ /* stop transport channel timer */
btu_stop_timer(&p_scb->timer_entry); btu_stop_timer(&p_scb->timer_entry);
if ((p_scb->role == AVDT_CLOSE_INT) || (p_scb->role == AVDT_OPEN_INT)) if ((p_scb->role == AVDT_CLOSE_INT) || (p_scb->role == AVDT_OPEN_INT)) {
{
/* tell ccb we're done with signaling channel */ /* tell ccb we're done with signaling channel */
avdt_ccb_event(p_ccb, AVDT_CCB_UL_CLOSE_EVT, NULL); avdt_ccb_event(p_ccb, AVDT_CCB_UL_CLOSE_EVT, NULL);
} }
event = (p_scb->role == AVDT_CLOSE_INT) ? AVDT_CLOSE_CFM_EVT : AVDT_CLOSE_IND_EVT; event = (p_scb->role == AVDT_CLOSE_INT) ? AVDT_CLOSE_CFM_EVT : AVDT_CLOSE_IND_EVT;
p_scb->role = AVDT_CLOSE_ACP; p_scb->role = AVDT_CLOSE_ACP;
if (p_scb->remove) if (p_scb->remove) {
{
avdt_scb_dealloc(p_scb, NULL); avdt_scb_dealloc(p_scb, NULL);
} }
@ -1075,11 +1019,12 @@ void avdt_scb_hdl_delay_rpt_cmd (tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
AVDT_DELAY_REPORT_EVT, AVDT_DELAY_REPORT_EVT,
(tAVDT_CTRL *) &p_data->msg.hdr); (tAVDT_CTRL *) &p_data->msg.hdr);
if (p_scb->p_ccb) if (p_scb->p_ccb) {
avdt_msg_send_rsp(p_scb->p_ccb, AVDT_SIG_DELAY_RPT, &p_data->msg); avdt_msg_send_rsp(p_scb->p_ccb, AVDT_SIG_DELAY_RPT, &p_data->msg);
else } else {
avdt_scb_rej_not_in_use(p_scb, p_data); avdt_scb_rej_not_in_use(p_scb, p_data);
} }
}
/******************************************************************************* /*******************************************************************************
** **
@ -1114,12 +1059,10 @@ void avdt_scb_hdl_tc_close_sto(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
{ {
tAVDT_CTRL avdt_ctrl; tAVDT_CTRL avdt_ctrl;
/* AVDT_CHAN_SIG does not visit this action */ /* AVDT_CHAN_SIG does not visit this action */
if(p_data && p_data->close.type != AVDT_CHAN_MEDIA) if (p_data && p_data->close.type != AVDT_CHAN_MEDIA) {
{
/* it's reporting or recovery channel, /* it's reporting or recovery channel,
* the channel close in open state means the peer does not support it */ * the channel close in open state means the peer does not support it */
if(p_data->close.old_tc_state == AVDT_AD_ST_OPEN) if (p_data->close.old_tc_state == AVDT_AD_ST_OPEN) {
{
avdt_ctrl.hdr.err_code = 0; avdt_ctrl.hdr.err_code = 0;
avdt_ctrl.hdr.err_param = 0; avdt_ctrl.hdr.err_param = 0;
/* call app callback */ /* call app callback */
@ -1127,9 +1070,7 @@ void avdt_scb_hdl_tc_close_sto(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
p_scb->p_ccb ? p_scb->p_ccb->peer_addr : NULL, p_scb->p_ccb ? p_scb->p_ccb->peer_addr : NULL,
AVDT_REPORT_DISCONN_EVT, &avdt_ctrl); AVDT_REPORT_DISCONN_EVT, &avdt_ctrl);
} }
} } else {
else
{
/* must be in OPEN state. need to go back to idle */ /* must be in OPEN state. need to go back to idle */
avdt_scb_event(p_scb, AVDT_SCB_MSG_ABORT_RSP_EVT, NULL); avdt_scb_event(p_scb, AVDT_SCB_MSG_ABORT_RSP_EVT, NULL);
avdt_scb_hdl_tc_close(p_scb, p_data); avdt_scb_hdl_tc_close(p_scb, p_data);
@ -1165,8 +1106,7 @@ void avdt_scb_hdl_tc_open(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
AVDT_TRACE_DEBUG("psc_mask: cfg: 0x%x, req:0x%x, cur: 0x%x\n", AVDT_TRACE_DEBUG("psc_mask: cfg: 0x%x, req:0x%x, cur: 0x%x\n",
p_scb->cs.cfg.psc_mask, p_scb->req_cfg.psc_mask, p_scb->curr_cfg.psc_mask); p_scb->cs.cfg.psc_mask, p_scb->req_cfg.psc_mask, p_scb->curr_cfg.psc_mask);
#if AVDT_REPORTING == TRUE #if AVDT_REPORTING == TRUE
if(p_scb->curr_cfg.psc_mask & AVDT_PSC_REPORT) if (p_scb->curr_cfg.psc_mask & AVDT_PSC_REPORT) {
{
/* open the reporting channel, if both devices support it */ /* open the reporting channel, if both devices support it */
role = (p_scb->role == AVDT_OPEN_INT) ? AVDT_INT : AVDT_ACP; role = (p_scb->role == AVDT_OPEN_INT) ? AVDT_INT : AVDT_ACP;
avdt_ad_open_req(AVDT_CHAN_REPORT, p_scb->p_ccb, p_scb, role); avdt_ad_open_req(AVDT_CHAN_REPORT, p_scb->p_ccb, p_scb, role);
@ -1199,8 +1139,7 @@ void avdt_scb_hdl_tc_open_sto(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
/* open reporting channel here, when it is implemented */ /* open reporting channel here, when it is implemented */
/* call app callback */ /* call app callback */
if(p_data->open.hdr.err_code == AVDT_CHAN_REPORT) if (p_data->open.hdr.err_code == AVDT_CHAN_REPORT) {
{
avdt_ctrl.hdr.err_code = 0; avdt_ctrl.hdr.err_code = 0;
avdt_ctrl.hdr.err_param = 1; avdt_ctrl.hdr.err_param = 1;
(*p_scb->cs.p_ctrl_cback)(avdt_scb_to_hdl(p_scb), (*p_scb->cs.p_ctrl_cback)(avdt_scb_to_hdl(p_scb),
@ -1227,8 +1166,7 @@ void avdt_scb_hdl_write_req_no_frag(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
UINT32 ssrc; UINT32 ssrc;
/* free packet we're holding, if any; to be replaced with new */ /* free packet we're holding, if any; to be replaced with new */
if (p_scb->p_pkt != NULL) if (p_scb->p_pkt != NULL) {
{
GKI_freebuf(p_scb->p_pkt); GKI_freebuf(p_scb->p_pkt);
/* this shouldn't be happening */ /* this shouldn't be happening */
@ -1237,8 +1175,7 @@ void avdt_scb_hdl_write_req_no_frag(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
/* build a media packet */ /* build a media packet */
/* Add RTP header if required */ /* Add RTP header if required */
if ( !(p_data->apiwrite.opt & AVDT_DATA_OPT_NO_RTP) ) if ( !(p_data->apiwrite.opt & AVDT_DATA_OPT_NO_RTP) ) {
{
ssrc = avdt_scb_gen_ssrc(p_scb); ssrc = avdt_scb_gen_ssrc(p_scb);
p_data->apiwrite.p_buf->len += AVDT_MEDIA_HDR_SIZE; p_data->apiwrite.p_buf->len += AVDT_MEDIA_HDR_SIZE;
@ -1275,10 +1212,10 @@ void avdt_scb_hdl_write_req_frag(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
BT_HDR *p_frag; BT_HDR *p_frag;
/* free fragments we're holding, if any; it shouldn't happen */ /* free fragments we're holding, if any; it shouldn't happen */
if (!GKI_queue_is_empty(&p_scb->frag_q)) if (!GKI_queue_is_empty(&p_scb->frag_q)) {
{ while ((p_frag = (BT_HDR *)GKI_dequeue (&p_scb->frag_q)) != NULL) {
while((p_frag = (BT_HDR*)GKI_dequeue (&p_scb->frag_q)) != NULL)
GKI_freebuf(p_frag); GKI_freebuf(p_frag);
}
/* this shouldn't be happening */ /* this shouldn't be happening */
AVDT_TRACE_WARNING("*** Dropped media packet; congested"); AVDT_TRACE_WARNING("*** Dropped media packet; congested");
@ -1311,8 +1248,7 @@ void avdt_scb_hdl_write_req_frag(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
UINT32_TO_BE_STREAM(p, ssrc); UINT32_TO_BE_STREAM(p, ssrc);
p_scb->media_seq++; p_scb->media_seq++;
while((p_frag = (BT_HDR*)GKI_getnext (p_frag)) != NULL) while ((p_frag = (BT_HDR *)GKI_getnext (p_frag)) != NULL) {
{
/* posit on Adaptation Layer header */ /* posit on Adaptation Layer header */
p_frag->len += AVDT_AL_HDR_SIZE; p_frag->len += AVDT_AL_HDR_SIZE;
p_frag->offset -= AVDT_AL_HDR_SIZE; p_frag->offset -= AVDT_AL_HDR_SIZE;
@ -1348,8 +1284,9 @@ void avdt_scb_hdl_write_req(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
#endif #endif
avdt_scb_hdl_write_req_no_frag(p_scb, p_data); avdt_scb_hdl_write_req_no_frag(p_scb, p_data);
#if AVDT_MULTIPLEXING == TRUE #if AVDT_MULTIPLEXING == TRUE
else else {
avdt_scb_hdl_write_req_frag(p_scb, p_data); avdt_scb_hdl_write_req_frag(p_scb, p_data);
}
#endif #endif
} }
@ -1367,8 +1304,7 @@ void avdt_scb_snd_abort_req(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
tAVDT_EVT_HDR hdr; tAVDT_EVT_HDR hdr;
UNUSED(p_data); UNUSED(p_data);
if (p_scb->p_ccb != NULL) if (p_scb->p_ccb != NULL) {
{
p_scb->role = AVDT_CLOSE_INT; p_scb->role = AVDT_CLOSE_INT;
hdr.seid = p_scb->peer_seid; hdr.seid = p_scb->peer_seid;
@ -1432,19 +1368,20 @@ void avdt_scb_snd_stream_close(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
AVDT_TRACE_WARNING("avdt_scb_snd_stream_close c:%d, off:%d\n", AVDT_TRACE_WARNING("avdt_scb_snd_stream_close c:%d, off:%d\n",
GKI_queue_length(&p_scb->frag_q), p_scb->frag_off); GKI_queue_length(&p_scb->frag_q), p_scb->frag_off);
/* clean fragments queue */ /* clean fragments queue */
while((p_frag = (BT_HDR*)GKI_dequeue (&p_scb->frag_q)) != NULL) while ((p_frag = (BT_HDR *)GKI_dequeue (&p_scb->frag_q)) != NULL) {
GKI_freebuf(p_frag); GKI_freebuf(p_frag);
}
p_scb->frag_off = 0; p_scb->frag_off = 0;
#endif #endif
if (p_scb->p_pkt) if (p_scb->p_pkt) {
{
GKI_freebuf(p_scb->p_pkt); GKI_freebuf(p_scb->p_pkt);
p_scb->p_pkt = NULL; p_scb->p_pkt = NULL;
} }
#if 0 #if 0
if(p_scb->cong) if (p_scb->cong) {
p_scb->cong = FALSE; p_scb->cong = FALSE;
}
/* p_scb->curr_cfg.mux_tsid_media == 0 */ /* p_scb->curr_cfg.mux_tsid_media == 0 */
#endif #endif
@ -1570,25 +1507,20 @@ void avdt_scb_snd_reconfig_req(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
*******************************************************************************/ *******************************************************************************/
void avdt_scb_snd_reconfig_rsp(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data) void avdt_scb_snd_reconfig_rsp(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
{ {
if (p_data->msg.hdr.err_code == 0) if (p_data->msg.hdr.err_code == 0) {
{
/* store new configuration */ /* store new configuration */
if (p_scb->req_cfg.num_codec > 0) if (p_scb->req_cfg.num_codec > 0) {
{
p_scb->curr_cfg.num_codec = p_scb->req_cfg.num_codec; p_scb->curr_cfg.num_codec = p_scb->req_cfg.num_codec;
memcpy(p_scb->curr_cfg.codec_info, p_scb->req_cfg.codec_info, AVDT_CODEC_SIZE); memcpy(p_scb->curr_cfg.codec_info, p_scb->req_cfg.codec_info, AVDT_CODEC_SIZE);
} }
if (p_scb->req_cfg.num_protect > 0) if (p_scb->req_cfg.num_protect > 0) {
{
p_scb->curr_cfg.num_protect = p_scb->req_cfg.num_protect; p_scb->curr_cfg.num_protect = p_scb->req_cfg.num_protect;
memcpy(p_scb->curr_cfg.protect_info, p_scb->req_cfg.protect_info, AVDT_PROTECT_SIZE); memcpy(p_scb->curr_cfg.protect_info, p_scb->req_cfg.protect_info, AVDT_PROTECT_SIZE);
} }
/* send response */ /* send response */
avdt_msg_send_rsp(p_scb->p_ccb, AVDT_SIG_RECONFIG, &p_data->msg); avdt_msg_send_rsp(p_scb->p_ccb, AVDT_SIG_RECONFIG, &p_data->msg);
} } else {
else
{
/* send reject */ /* send reject */
avdt_msg_send_rej(p_scb->p_ccb, AVDT_SIG_RECONFIG, &p_data->msg); avdt_msg_send_rej(p_scb->p_ccb, AVDT_SIG_RECONFIG, &p_data->msg);
} }
@ -1620,12 +1552,9 @@ void avdt_scb_snd_security_req(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
*******************************************************************************/ *******************************************************************************/
void avdt_scb_snd_security_rsp(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data) void avdt_scb_snd_security_rsp(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
{ {
if (p_data->msg.hdr.err_code == 0) if (p_data->msg.hdr.err_code == 0) {
{
avdt_msg_send_rsp(p_scb->p_ccb, AVDT_SIG_SECURITY, &p_data->msg); avdt_msg_send_rsp(p_scb->p_ccb, AVDT_SIG_SECURITY, &p_data->msg);
} } else {
else
{
avdt_msg_send_rej(p_scb->p_ccb, AVDT_SIG_SECURITY, &p_data->msg); avdt_msg_send_rej(p_scb->p_ccb, AVDT_SIG_SECURITY, &p_data->msg);
} }
} }
@ -1642,8 +1571,7 @@ void avdt_scb_snd_security_rsp(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
*******************************************************************************/ *******************************************************************************/
void avdt_scb_snd_setconfig_rej(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data) void avdt_scb_snd_setconfig_rej(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
{ {
if (p_scb->p_ccb != NULL) if (p_scb->p_ccb != NULL) {
{
avdt_msg_send_rej(p_scb->p_ccb, AVDT_SIG_SETCONFIG, &p_data->msg); avdt_msg_send_rej(p_scb->p_ccb, AVDT_SIG_SETCONFIG, &p_data->msg);
/* clear scb variables */ /* clear scb variables */
@ -1676,8 +1604,7 @@ void avdt_scb_snd_setconfig_req(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
#if AVDT_MULTIPLEXING == TRUE #if AVDT_MULTIPLEXING == TRUE
p_req->mux_tsid_media = p_cfg->mux_tsid_media; p_req->mux_tsid_media = p_cfg->mux_tsid_media;
p_req->mux_tcid_media = p_cfg->mux_tcid_media; p_req->mux_tcid_media = p_cfg->mux_tcid_media;
if(p_req->psc_mask & AVDT_PSC_REPORT) if (p_req->psc_mask & AVDT_PSC_REPORT) {
{
p_req->mux_tsid_report = p_cfg->mux_tsid_report; p_req->mux_tsid_report = p_cfg->mux_tsid_report;
p_req->mux_tcid_report = p_cfg->mux_tcid_report; p_req->mux_tcid_report = p_cfg->mux_tcid_report;
} }
@ -1703,8 +1630,7 @@ void avdt_scb_snd_setconfig_req(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
*******************************************************************************/ *******************************************************************************/
void avdt_scb_snd_setconfig_rsp(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data) void avdt_scb_snd_setconfig_rsp(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
{ {
if (p_scb->p_ccb != NULL) if (p_scb->p_ccb != NULL) {
{
memcpy(&p_scb->curr_cfg, &p_scb->req_cfg, sizeof(tAVDT_CFG)); memcpy(&p_scb->curr_cfg, &p_scb->req_cfg, sizeof(tAVDT_CFG));
avdt_msg_send_rsp(p_scb->p_ccb, AVDT_SIG_SETCONFIG, &p_data->msg); avdt_msg_send_rsp(p_scb->p_ccb, AVDT_SIG_SETCONFIG, &p_data->msg);
@ -1726,8 +1652,9 @@ void avdt_scb_snd_tc_close(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
UNUSED(p_data); UNUSED(p_data);
#if AVDT_REPORTING == TRUE #if AVDT_REPORTING == TRUE
if(p_scb->curr_cfg.psc_mask & AVDT_PSC_REPORT) if (p_scb->curr_cfg.psc_mask & AVDT_PSC_REPORT) {
avdt_ad_close_req(AVDT_CHAN_REPORT, p_scb->p_ccb, p_scb); avdt_ad_close_req(AVDT_CHAN_REPORT, p_scb->p_ccb, p_scb);
}
#endif #endif
avdt_ad_close_req(AVDT_CHAN_MEDIA, p_scb->p_ccb, p_scb); avdt_ad_close_req(AVDT_CHAN_MEDIA, p_scb->p_ccb, p_scb);
} }
@ -1870,13 +1797,15 @@ void avdt_scb_free_pkt(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
avdt_ctrl.hdr.err_param = 0; avdt_ctrl.hdr.err_param = 0;
/* p_buf can be NULL in case using of fragments queue frag_q */ /* p_buf can be NULL in case using of fragments queue frag_q */
if(p_data->apiwrite.p_buf) if (p_data->apiwrite.p_buf) {
GKI_freebuf(p_data->apiwrite.p_buf); GKI_freebuf(p_data->apiwrite.p_buf);
}
#if AVDT_MULTIPLEXING == TRUE #if AVDT_MULTIPLEXING == TRUE
/* clean fragments queue */ /* clean fragments queue */
while((p_frag = (BT_HDR*)GKI_dequeue (&p_data->apiwrite.frag_q)) != NULL) while ((p_frag = (BT_HDR *)GKI_dequeue (&p_data->apiwrite.frag_q)) != NULL) {
GKI_freebuf(p_frag); GKI_freebuf(p_frag);
}
#endif #endif
AVDT_TRACE_WARNING("Dropped media packet"); AVDT_TRACE_WARNING("Dropped media packet");
@ -1910,8 +1839,7 @@ void avdt_scb_clr_pkt(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
avdt_ctrl.hdr.err_code = AVDT_ERR_BAD_STATE; avdt_ctrl.hdr.err_code = AVDT_ERR_BAD_STATE;
avdt_ctrl.hdr.err_param = 0; avdt_ctrl.hdr.err_param = 0;
/* flush the media data queued at L2CAP */ /* flush the media data queued at L2CAP */
if((p_ccb = p_scb->p_ccb) != NULL) if ((p_ccb = p_scb->p_ccb) != NULL) {
{
/* get tcid from type, scb */ /* get tcid from type, scb */
tcid = avdt_ad_type_to_tcid(AVDT_CHAN_MEDIA, p_scb); tcid = avdt_ad_type_to_tcid(AVDT_CHAN_MEDIA, p_scb);
@ -1919,8 +1847,7 @@ void avdt_scb_clr_pkt(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
L2CA_FlushChannel (lcid, L2CAP_FLUSH_CHANS_ALL); L2CA_FlushChannel (lcid, L2CAP_FLUSH_CHANS_ALL);
} }
if (p_scb->p_pkt != NULL) if (p_scb->p_pkt != NULL) {
{
GKI_freebuf(p_scb->p_pkt); GKI_freebuf(p_scb->p_pkt);
p_scb->p_pkt = NULL; p_scb->p_pkt = NULL;
@ -1931,12 +1858,12 @@ void avdt_scb_clr_pkt(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
&avdt_ctrl); &avdt_ctrl);
} }
#if AVDT_MULTIPLEXING == TRUE #if AVDT_MULTIPLEXING == TRUE
else if(!GKI_queue_is_empty (&p_scb->frag_q)) else if (!GKI_queue_is_empty (&p_scb->frag_q)) {
{
AVDT_TRACE_DEBUG("Dropped fragments queue"); AVDT_TRACE_DEBUG("Dropped fragments queue");
/* clean fragments queue */ /* clean fragments queue */
while((p_frag = (BT_HDR*)GKI_dequeue (&p_scb->frag_q)) != NULL) while ((p_frag = (BT_HDR *)GKI_dequeue (&p_scb->frag_q)) != NULL) {
GKI_freebuf(p_frag); GKI_freebuf(p_frag);
}
p_scb->frag_off = 0; p_scb->frag_off = 0;
@ -1973,10 +1900,8 @@ void avdt_scb_chk_snd_pkt(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
avdt_ctrl.hdr.err_code = 0; avdt_ctrl.hdr.err_code = 0;
if (!p_scb->cong) if (!p_scb->cong) {
{ if (p_scb->p_pkt != NULL) {
if (p_scb->p_pkt != NULL)
{
p_pkt = p_scb->p_pkt; p_pkt = p_scb->p_pkt;
p_scb->p_pkt = NULL; p_scb->p_pkt = NULL;
avdt_ad_write_req(AVDT_CHAN_MEDIA, p_scb->p_ccb, p_scb, p_pkt); avdt_ad_write_req(AVDT_CHAN_MEDIA, p_scb->p_ccb, p_scb, p_pkt);
@ -1984,21 +1909,18 @@ void avdt_scb_chk_snd_pkt(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
(*p_scb->cs.p_ctrl_cback)(avdt_scb_to_hdl(p_scb), NULL, AVDT_WRITE_CFM_EVT, &avdt_ctrl); (*p_scb->cs.p_ctrl_cback)(avdt_scb_to_hdl(p_scb), NULL, AVDT_WRITE_CFM_EVT, &avdt_ctrl);
} }
#if AVDT_MULTIPLEXING == TRUE #if AVDT_MULTIPLEXING == TRUE
else else {
{
#if 0 #if 0
AVDT_TRACE_DEBUG("num_q=%d\n", AVDT_TRACE_DEBUG("num_q=%d\n",
L2CA_FlushChannel(avdt_cb.ad.rt_tbl[avdt_ccb_to_idx(p_scb->p_ccb)][avdt_ad_type_to_tcid(AVDT_CHAN_MEDIA, p_scb)].lcid), L2CA_FlushChannel(avdt_cb.ad.rt_tbl[avdt_ccb_to_idx(p_scb->p_ccb)][avdt_ad_type_to_tcid(AVDT_CHAN_MEDIA, p_scb)].lcid),
L2CAP_FLUSH_CHANS_GET); L2CAP_FLUSH_CHANS_GET);
#endif #endif
while((p_pkt = (BT_HDR*)GKI_dequeue (&p_scb->frag_q)) != NULL) while ((p_pkt = (BT_HDR *)GKI_dequeue (&p_scb->frag_q)) != NULL) {
{
sent = TRUE; sent = TRUE;
AVDT_TRACE_DEBUG("Send fragment len=%d\n", p_pkt->len); AVDT_TRACE_DEBUG("Send fragment len=%d\n", p_pkt->len);
/* fragments queue contains fragment to send */ /* fragments queue contains fragment to send */
res = avdt_ad_write_req(AVDT_CHAN_MEDIA, p_scb->p_ccb, p_scb, p_pkt); res = avdt_ad_write_req(AVDT_CHAN_MEDIA, p_scb->p_ccb, p_scb, p_pkt);
if(AVDT_AD_CONGESTED == res) if (AVDT_AD_CONGESTED == res) {
{
p_scb->cong = TRUE; p_scb->cong = TRUE;
AVDT_TRACE_DEBUG("avdt/l2c congested!!"); AVDT_TRACE_DEBUG("avdt/l2c congested!!");
break;/* exit loop if channel became congested */ break;/* exit loop if channel became congested */
@ -2006,14 +1928,11 @@ void avdt_scb_chk_snd_pkt(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
} }
AVDT_TRACE_DEBUG("res=%d left=%d\n", res, p_scb->frag_off); AVDT_TRACE_DEBUG("res=%d left=%d\n", res, p_scb->frag_off);
if(p_scb->frag_off) if (p_scb->frag_off) {
{ if (AVDT_AD_SUCCESS == res || GKI_queue_is_empty (&p_scb->frag_q)) {
if(AVDT_AD_SUCCESS == res || GKI_queue_is_empty (&p_scb->frag_q))
{
/* all buffers were sent to L2CAP, compose more to queue */ /* all buffers were sent to L2CAP, compose more to queue */
avdt_scb_queue_frags(p_scb, &p_scb->p_next_frag, &p_scb->frag_off, &p_scb->frag_q); avdt_scb_queue_frags(p_scb, &p_scb->p_next_frag, &p_scb->frag_off, &p_scb->frag_q);
if(!GKI_queue_is_empty (&p_scb->frag_q)) if (!GKI_queue_is_empty (&p_scb->frag_q)) {
{
data.llcong = p_scb->cong; data.llcong = p_scb->cong;
avdt_scb_event(p_scb, AVDT_SCB_TC_CONG_EVT, &data); avdt_scb_event(p_scb, AVDT_SCB_TC_CONG_EVT, &data);
} }
@ -2021,8 +1940,7 @@ void avdt_scb_chk_snd_pkt(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
} }
/* Send event AVDT_WRITE_CFM_EVT if it was last fragment */ /* Send event AVDT_WRITE_CFM_EVT if it was last fragment */
else if (sent && GKI_queue_is_empty (&p_scb->frag_q)) else if (sent && GKI_queue_is_empty (&p_scb->frag_q)) {
{
(*p_scb->cs.p_ctrl_cback)(avdt_scb_to_hdl(p_scb), NULL, AVDT_WRITE_CFM_EVT, &avdt_ctrl); (*p_scb->cs.p_ctrl_cback)(avdt_scb_to_hdl(p_scb), NULL, AVDT_WRITE_CFM_EVT, &avdt_ctrl);
} }
} }
@ -2061,12 +1979,9 @@ void avdt_scb_clr_vars(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
{ {
UNUSED(p_data); UNUSED(p_data);
if ((p_scb->cs.tsep == AVDT_TSEP_SNK) && (!p_scb->sink_activated)) if ((p_scb->cs.tsep == AVDT_TSEP_SNK) && (!p_scb->sink_activated)) {
{
p_scb->in_use = TRUE; p_scb->in_use = TRUE;
} } else {
else
{
p_scb->in_use = FALSE; p_scb->in_use = FALSE;
} }
p_scb->p_ccb = NULL; p_scb->p_ccb = NULL;
@ -2101,25 +2016,19 @@ void avdt_scb_queue_frags(tAVDT_SCB *p_scb, UINT8 **pp_data, UINT32 *p_data_len,
tcid = avdt_ad_type_to_tcid(AVDT_CHAN_MEDIA, p_scb); tcid = avdt_ad_type_to_tcid(AVDT_CHAN_MEDIA, p_scb);
lcid = avdt_cb.ad.rt_tbl[avdt_ccb_to_idx(p_scb->p_ccb)][tcid].lcid; lcid = avdt_cb.ad.rt_tbl[avdt_ccb_to_idx(p_scb->p_ccb)][tcid].lcid;
if( p_scb->frag_off != 0) if ( p_scb->frag_off != 0) {
{
/* continuing process is usually triggered by un-congest event. /* continuing process is usually triggered by un-congest event.
* the number of buffers at L2CAP is very small (if not 0). * the number of buffers at L2CAP is very small (if not 0).
* we do not need to L2CA_FlushChannel() */ * we do not need to L2CA_FlushChannel() */
offset = cont_offset; offset = cont_offset;
al_hdr = TRUE; al_hdr = TRUE;
num_frag = AVDT_MAX_FRAG_COUNT; num_frag = AVDT_MAX_FRAG_COUNT;
} } else {
else
{
num_frag = L2CA_FlushChannel(lcid, L2CAP_FLUSH_CHANS_GET); num_frag = L2CA_FlushChannel(lcid, L2CAP_FLUSH_CHANS_GET);
AVDT_TRACE_DEBUG("num_q=%d lcid=%d\n", num_frag, lcid); AVDT_TRACE_DEBUG("num_q=%d lcid=%d\n", num_frag, lcid);
if(num_frag >= AVDT_MAX_FRAG_COUNT) if (num_frag >= AVDT_MAX_FRAG_COUNT) {
{
num_frag = 0; num_frag = 0;
} } else {
else
{
num_frag = AVDT_MAX_FRAG_COUNT - num_frag; num_frag = AVDT_MAX_FRAG_COUNT - num_frag;
} }
} }
@ -2130,16 +2039,15 @@ void avdt_scb_queue_frags(tAVDT_SCB *p_scb, UINT8 **pp_data, UINT32 *p_data_len,
AVDT_TRACE_DEBUG("peer_mtu: %d, buf_size: %d num_frag=%d\n", AVDT_TRACE_DEBUG("peer_mtu: %d, buf_size: %d num_frag=%d\n",
p_tbl->peer_mtu, buf_size, num_frag); p_tbl->peer_mtu, buf_size, num_frag);
if(buf_size > AVDT_DATA_POOL_SIZE) if (buf_size > AVDT_DATA_POOL_SIZE) {
buf_size = AVDT_DATA_POOL_SIZE; buf_size = AVDT_DATA_POOL_SIZE;
}
mtu_used = buf_size - BT_HDR_SIZE; mtu_used = buf_size - BT_HDR_SIZE;
while(*p_data_len && num_frag) while (*p_data_len && num_frag) {
{
/* allocate buffer for fragment */ /* allocate buffer for fragment */
if(NULL == (p_frag = (BT_HDR*)GKI_getbuf(buf_size))) if (NULL == (p_frag = (BT_HDR *)GKI_getbuf(buf_size))) {
{
AVDT_TRACE_WARNING("avdt_scb_queue_frags len=%d(out of GKI buffers)\n", *p_data_len); AVDT_TRACE_WARNING("avdt_scb_queue_frags len=%d(out of GKI buffers)\n", *p_data_len);
break; break;
} }
@ -2150,15 +2058,15 @@ void avdt_scb_queue_frags(tAVDT_SCB *p_scb, UINT8 **pp_data, UINT32 *p_data_len,
offset = cont_offset; offset = cont_offset;
p_frag->len = mtu_used - p_frag->offset; p_frag->len = mtu_used - p_frag->offset;
if(p_frag->len > *p_data_len) if (p_frag->len > *p_data_len) {
p_frag->len = *p_data_len; p_frag->len = *p_data_len;
}
memcpy((UINT8 *)(p_frag + 1) + p_frag->offset, *pp_data, p_frag->len); memcpy((UINT8 *)(p_frag + 1) + p_frag->offset, *pp_data, p_frag->len);
*pp_data += p_frag->len; *pp_data += p_frag->len;
*p_data_len -= p_frag->len; *p_data_len -= p_frag->len;
AVDT_TRACE_DEBUG("Prepared fragment len=%d\n", p_frag->len); AVDT_TRACE_DEBUG("Prepared fragment len=%d\n", p_frag->len);
if(al_hdr) if (al_hdr) {
{
/* Adaptation Layer header */ /* Adaptation Layer header */
p_frag->len += AVDT_AL_HDR_SIZE; p_frag->len += AVDT_AL_HDR_SIZE;
p_frag->offset -= AVDT_AL_HDR_SIZE; p_frag->offset -= AVDT_AL_HDR_SIZE;

295
components/bt/bluedroid/stack/avrc/avrc_api.c Executable file → Normal file
View file

@ -42,8 +42,7 @@
#define MAX(a, b) ((a) > (b) ? (a) : (b)) #define MAX(a, b) ((a) > (b) ? (a) : (b))
#endif #endif
static const UINT8 avrc_ctrl_event_map[] = static const UINT8 avrc_ctrl_event_map[] = {
{
AVRC_OPEN_IND_EVT, /* AVCT_CONNECT_CFM_EVT */ AVRC_OPEN_IND_EVT, /* AVCT_CONNECT_CFM_EVT */
AVRC_OPEN_IND_EVT, /* AVCT_CONNECT_IND_EVT */ AVRC_OPEN_IND_EVT, /* AVCT_CONNECT_IND_EVT */
AVRC_CLOSE_IND_EVT, /* AVCT_DISCONNECT_CFM_EVT */ AVRC_CLOSE_IND_EVT, /* AVCT_DISCONNECT_CFM_EVT */
@ -80,14 +79,13 @@ static void avrc_ctrl_cback(UINT8 handle, UINT8 event, UINT16 result,
{ {
UINT8 avrc_event; UINT8 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].p_ctrl_cback) {
{
avrc_event = avrc_ctrl_event_map[event]; avrc_event = avrc_ctrl_event_map[event];
if (event == AVCT_CONNECT_CFM_EVT) if (event == AVCT_CONNECT_CFM_EVT) {
{ if (result != 0) { /* failed */
if (result != 0) /* failed */
avrc_event = AVRC_CLOSE_IND_EVT; avrc_event = AVRC_CLOSE_IND_EVT;
} }
}
(*avrc_cb.ccb[handle].p_ctrl_cback)(handle, avrc_event, result, peer_addr); (*avrc_cb.ccb[handle].p_ctrl_cback)(handle, avrc_event, result, peer_addr);
} }
/* else drop the unknown event*/ /* else drop the unknown event*/
@ -199,13 +197,11 @@ static void avrc_send_continue_frag(UINT8 handle, UINT8 label)
AVRC_TRACE_DEBUG("%s handle = %u label = %u len = %d", AVRC_TRACE_DEBUG("%s handle = %u label = %u len = %d",
__func__, handle, label, p_pkt->len); __func__, handle, label, p_pkt->len);
if (p_pkt->len > AVRC_MAX_CTRL_DATA_LEN) if (p_pkt->len > AVRC_MAX_CTRL_DATA_LEN) {
{
int offset_len = MAX(AVCT_MSG_OFFSET, p_pkt->offset); int offset_len = MAX(AVCT_MSG_OFFSET, p_pkt->offset);
p_pkt_old = p_fcb->p_fmsg; p_pkt_old = p_fcb->p_fmsg;
p_pkt = (BT_HDR *)GKI_getbuf((UINT16)(AVRC_PACKET_LEN + offset_len + BT_HDR_SIZE)); p_pkt = (BT_HDR *)GKI_getbuf((UINT16)(AVRC_PACKET_LEN + offset_len + BT_HDR_SIZE));
if (p_pkt) if (p_pkt) {
{
p_pkt->len = AVRC_MAX_CTRL_DATA_LEN; p_pkt->len = AVRC_MAX_CTRL_DATA_LEN;
p_pkt->offset = AVCT_MSG_OFFSET; p_pkt->offset = AVCT_MSG_OFFSET;
p_pkt->layer_specific = p_pkt_old->layer_specific; p_pkt->layer_specific = p_pkt_old->layer_specific;
@ -222,9 +218,7 @@ static void avrc_send_continue_frag(UINT8 handle, UINT8 label)
/* prepare the left over for as an end fragment */ /* prepare the left over for as an end fragment */
avrc_prep_end_frag (handle); avrc_prep_end_frag (handle);
} } else {
else
{
/* use the current GKI buffer to send Internal error status */ /* use the current GKI buffer to send Internal error status */
p_pkt = p_fcb->p_fmsg; p_pkt = p_fcb->p_fmsg;
p_fcb->p_fmsg = NULL; p_fcb->p_fmsg = NULL;
@ -240,9 +234,7 @@ static void avrc_send_continue_frag(UINT8 handle, UINT8 label)
AVRC_BldResponse( handle, (tAVRC_RESPONSE *)&rej_rsp, &p_pkt); AVRC_BldResponse( handle, (tAVRC_RESPONSE *)&rej_rsp, &p_pkt);
cr = AVCT_RSP; cr = AVCT_RSP;
} }
} } else {
else
{
/* end fragment. clean the control block */ /* end fragment. clean the control block */
p_fcb->frag_enabled = FALSE; p_fcb->frag_enabled = FALSE;
p_fcb->p_fmsg = NULL; p_fcb->p_fmsg = NULL;
@ -274,33 +266,26 @@ static BT_HDR * avrc_proc_vendor_command(UINT8 handle, UINT8 label,
p_data = p_begin + AVRC_VENDOR_HDR_SIZE; p_data = p_begin + AVRC_VENDOR_HDR_SIZE;
pkt_type = *(p_data + 1) & AVRC_PKT_TYPE_MASK; pkt_type = *(p_data + 1) & AVRC_PKT_TYPE_MASK;
if (pkt_type != AVRC_PKT_SINGLE) if (pkt_type != AVRC_PKT_SINGLE) {
{
/* reject - commands can only be in single packets at AVRCP level */ /* reject - commands can only be in single packets at AVRCP level */
AVRC_TRACE_ERROR ("commands must be in single packet pdu:0x%x", *p_data ); AVRC_TRACE_ERROR ("commands must be in single packet pdu:0x%x", *p_data );
/* use the current GKI buffer to send the reject */ /* use the current GKI buffer to send the reject */
status = AVRC_STS_BAD_CMD; status = AVRC_STS_BAD_CMD;
} }
/* check if there are fragments waiting to be sent */ /* check if there are fragments waiting to be sent */
else if (avrc_cb.fcb[handle].frag_enabled) else if (avrc_cb.fcb[handle].frag_enabled) {
{
p_fcb = &avrc_cb.fcb[handle]; p_fcb = &avrc_cb.fcb[handle];
if (p_msg->company_id == AVRC_CO_METADATA) if (p_msg->company_id == AVRC_CO_METADATA) {
{ switch (*p_data) {
switch (*p_data)
{
case AVRC_PDU_ABORT_CONTINUATION_RSP: case AVRC_PDU_ABORT_CONTINUATION_RSP:
/* aborted by CT - send accept response */ /* aborted by CT - send accept response */
abort_frag = TRUE; abort_frag = TRUE;
p_begin = (UINT8 *)(p_pkt + 1) + p_pkt->offset; p_begin = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
*p_begin = (AVRC_RSP_ACCEPT & AVRC_CTYPE_MASK); *p_begin = (AVRC_RSP_ACCEPT & AVRC_CTYPE_MASK);
if (*(p_data + 4) != p_fcb->frag_pdu) if (*(p_data + 4) != p_fcb->frag_pdu) {
{
*p_begin = (AVRC_RSP_REJ & AVRC_CTYPE_MASK); *p_begin = (AVRC_RSP_REJ & AVRC_CTYPE_MASK);
*(p_data + 4) = AVRC_STS_BAD_PARAM; *(p_data + 4) = AVRC_STS_BAD_PARAM;
} } else {
else
{
p_data = (p_begin + AVRC_VENDOR_HDR_SIZE + 2); p_data = (p_begin + AVRC_VENDOR_HDR_SIZE + 2);
UINT16_TO_BE_STREAM(p_data, 0); UINT16_TO_BE_STREAM(p_data, 0);
p_pkt->len = (p_data - p_begin); p_pkt->len = (p_data - p_begin);
@ -310,13 +295,10 @@ static BT_HDR * avrc_proc_vendor_command(UINT8 handle, UINT8 label,
break; break;
case AVRC_PDU_REQUEST_CONTINUATION_RSP: case AVRC_PDU_REQUEST_CONTINUATION_RSP:
if (*(p_data + 4) == p_fcb->frag_pdu) if (*(p_data + 4) == p_fcb->frag_pdu) {
{
avrc_send_continue_frag(handle, label); avrc_send_continue_frag(handle, label);
p_msg->hdr.opcode = AVRC_OP_DROP_N_FREE; p_msg->hdr.opcode = AVRC_OP_DROP_N_FREE;
} } else {
else
{
/* the pdu id does not match - reject the command using the current GKI buffer */ /* the pdu id does not match - reject the command using the current GKI buffer */
AVRC_TRACE_ERROR("avrc_proc_vendor_command continue pdu: 0x%x does not match \ AVRC_TRACE_ERROR("avrc_proc_vendor_command continue pdu: 0x%x does not match \
current re-assembly pdu: 0x%x", current re-assembly pdu: 0x%x",
@ -330,24 +312,21 @@ static BT_HDR * avrc_proc_vendor_command(UINT8 handle, UINT8 label,
/* implicit abort */ /* implicit abort */
abort_frag = TRUE; abort_frag = TRUE;
} }
} } else {
else
{
abort_frag = TRUE; abort_frag = TRUE;
/* implicit abort */ /* implicit abort */
} }
if (abort_frag) if (abort_frag) {
{ if (p_fcb->p_fmsg) {
if (p_fcb->p_fmsg)
GKI_freebuf(p_fcb->p_fmsg); GKI_freebuf(p_fcb->p_fmsg);
}
p_fcb->p_fmsg = NULL; p_fcb->p_fmsg = NULL;
p_fcb->frag_enabled = FALSE; p_fcb->frag_enabled = FALSE;
} }
} }
if (status != AVRC_STS_NO_ERROR) if (status != AVRC_STS_NO_ERROR) {
{
/* use the current GKI buffer to build/send the reject message */ /* use the current GKI buffer to build/send the reject message */
p_data = (UINT8 *)(p_pkt + 1) + p_pkt->offset; p_data = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
*p_data++ = AVRC_RSP_REJ; *p_data++ = AVRC_RSP_REJ;
@ -395,29 +374,23 @@ static UINT8 avrc_proc_far_msg(UINT8 handle, UINT8 label, UINT8 cr, BT_HDR **pp_
pkt_type = *(p_data + 1) & AVRC_PKT_TYPE_MASK; pkt_type = *(p_data + 1) & AVRC_PKT_TYPE_MASK;
AVRC_TRACE_DEBUG ("pkt_type %d", pkt_type ); AVRC_TRACE_DEBUG ("pkt_type %d", pkt_type );
p_rcb = &avrc_cb.rcb[handle]; p_rcb = &avrc_cb.rcb[handle];
if (p_msg->company_id == AVRC_CO_METADATA) if (p_msg->company_id == AVRC_CO_METADATA) {
{
/* check if the message needs to be re-assembled */ /* check if the message needs to be re-assembled */
if (pkt_type == AVRC_PKT_SINGLE || pkt_type == AVRC_PKT_START) if (pkt_type == AVRC_PKT_SINGLE || pkt_type == AVRC_PKT_START) {
{
/* previous fragments need to be dropped, when received another new message */ /* previous fragments need to be dropped, when received another new message */
p_rcb->rasm_offset = 0; p_rcb->rasm_offset = 0;
if (p_rcb->p_rmsg) if (p_rcb->p_rmsg) {
{
GKI_freebuf(p_rcb->p_rmsg); GKI_freebuf(p_rcb->p_rmsg);
p_rcb->p_rmsg = NULL; p_rcb->p_rmsg = NULL;
} }
} }
if (pkt_type != AVRC_PKT_SINGLE && cr == AVCT_RSP) if (pkt_type != AVRC_PKT_SINGLE && cr == AVCT_RSP) {
{
/* not a single response packet - need to re-assemble metadata messages */ /* not a single response packet - need to re-assemble metadata messages */
if (pkt_type == AVRC_PKT_START) if (pkt_type == AVRC_PKT_START) {
{
/* Allocate buffer for re-assembly */ /* Allocate buffer for re-assembly */
p_rcb->rasm_pdu = *p_data; p_rcb->rasm_pdu = *p_data;
if ((p_rcb->p_rmsg = (BT_HDR *)GKI_getbuf(GKI_MAX_BUF_SIZE)) != NULL) if ((p_rcb->p_rmsg = (BT_HDR *)GKI_getbuf(GKI_MAX_BUF_SIZE)) != NULL) {
{
/* Copy START packet to buffer for re-assembling fragments*/ /* Copy START packet to buffer for re-assembling fragments*/
memcpy(p_rcb->p_rmsg, p_pkt, sizeof(BT_HDR)); /* Copy bt hdr */ memcpy(p_rcb->p_rmsg, p_pkt, sizeof(BT_HDR)); /* Copy bt hdr */
@ -431,9 +404,7 @@ static UINT8 avrc_proc_far_msg(UINT8 handle, UINT8 label, UINT8 cr, BT_HDR **pp_
/* Free original START packet, replace with pointer to reassembly buffer */ /* Free original START packet, replace with pointer to reassembly buffer */
GKI_freebuf(p_pkt); GKI_freebuf(p_pkt);
*pp_pkt = p_rcb->p_rmsg; *pp_pkt = p_rcb->p_rmsg;
} } else {
else
{
/* Unable to allocate buffer for fragmented avrc message. Reuse START /* Unable to allocate buffer for fragmented avrc message. Reuse START
buffer for reassembly (re-assembled message may fit into ACL buf) */ buffer for reassembly (re-assembled message may fit into ACL buf) */
AVRC_TRACE_DEBUG ("Unable to allocate buffer for fragmented avrc message, \ AVRC_TRACE_DEBUG ("Unable to allocate buffer for fragmented avrc message, \
@ -445,9 +416,7 @@ static UINT8 avrc_proc_far_msg(UINT8 handle, UINT8 label, UINT8 cr, BT_HDR **pp_
/* set offset to point to where to copy next - use the same re-asm logic as AVCT */ /* set offset to point to where to copy next - use the same re-asm logic as AVCT */
p_rcb->p_rmsg->offset += p_rcb->p_rmsg->len; p_rcb->p_rmsg->offset += p_rcb->p_rmsg->len;
req_continue = TRUE; req_continue = TRUE;
} } else if (p_rcb->p_rmsg == NULL) {
else if (p_rcb->p_rmsg == NULL)
{
/* Received a CONTINUE/END, but no corresponding START /* Received a CONTINUE/END, but no corresponding START
(or previous fragmented response was dropped) */ (or previous fragmented response was dropped) */
AVRC_TRACE_DEBUG ("Received a CONTINUE/END without no corresponding START \ AVRC_TRACE_DEBUG ("Received a CONTINUE/END without no corresponding START \
@ -455,17 +424,14 @@ static UINT8 avrc_proc_far_msg(UINT8 handle, UINT8 label, UINT8 cr, BT_HDR **pp_
drop_code = 5; drop_code = 5;
GKI_freebuf(p_pkt); GKI_freebuf(p_pkt);
*pp_pkt = NULL; *pp_pkt = NULL;
} } else {
else
{
/* get size of buffer holding assembled message */ /* get size of buffer holding assembled message */
buf_len = GKI_get_buf_size (p_rcb->p_rmsg) - sizeof(BT_HDR); buf_len = GKI_get_buf_size (p_rcb->p_rmsg) - sizeof(BT_HDR);
/* adjust offset and len of fragment for header byte */ /* adjust offset and len of fragment for header byte */
p_pkt->offset += (AVRC_VENDOR_HDR_SIZE + AVRC_MIN_META_HDR_SIZE); p_pkt->offset += (AVRC_VENDOR_HDR_SIZE + AVRC_MIN_META_HDR_SIZE);
p_pkt->len -= (AVRC_VENDOR_HDR_SIZE + AVRC_MIN_META_HDR_SIZE); p_pkt->len -= (AVRC_VENDOR_HDR_SIZE + AVRC_MIN_META_HDR_SIZE);
/* verify length */ /* verify length */
if ((p_rcb->p_rmsg->offset + p_pkt->len) > buf_len) if ((p_rcb->p_rmsg->offset + p_pkt->len) > buf_len) {
{
AVRC_TRACE_WARNING("Fragmented message too big! - report the partial message"); AVRC_TRACE_WARNING("Fragmented message too big! - report the partial message");
p_pkt->len = buf_len - p_rcb->p_rmsg->offset; p_pkt->len = buf_len - p_rcb->p_rmsg->offset;
pkt_type = AVRC_PKT_END; pkt_type = AVRC_PKT_END;
@ -475,8 +441,7 @@ static UINT8 avrc_proc_far_msg(UINT8 handle, UINT8 label, UINT8 cr, BT_HDR **pp_
memcpy((UINT8 *)(p_rcb->p_rmsg + 1) + p_rcb->p_rmsg->offset, memcpy((UINT8 *)(p_rcb->p_rmsg + 1) + p_rcb->p_rmsg->offset,
(UINT8 *)(p_pkt + 1) + p_pkt->offset, p_pkt->len); (UINT8 *)(p_pkt + 1) + p_pkt->offset, p_pkt->len);
if (pkt_type == AVRC_PKT_END) if (pkt_type == AVRC_PKT_END) {
{
p_rcb->p_rmsg->offset = p_rcb->rasm_offset; p_rcb->p_rmsg->offset = p_rcb->rasm_offset;
p_rcb->p_rmsg->len += p_pkt->len; p_rcb->p_rmsg->len += p_pkt->len;
p_pkt_new = p_rcb->p_rmsg; p_pkt_new = p_rcb->p_rmsg;
@ -492,9 +457,7 @@ static UINT8 avrc_proc_far_msg(UINT8 handle, UINT8 label, UINT8 cr, BT_HDR **pp_
UINT16_TO_BE_STREAM(p_data, (p_msg->vendor_len - AVRC_MIN_META_HDR_SIZE)); UINT16_TO_BE_STREAM(p_data, (p_msg->vendor_len - AVRC_MIN_META_HDR_SIZE));
AVRC_TRACE_DEBUG("end frag:%d, total len:%d, offset:%d", p_pkt->len, AVRC_TRACE_DEBUG("end frag:%d, total len:%d, offset:%d", p_pkt->len,
p_pkt_new->len, p_pkt_new->offset); p_pkt_new->len, p_pkt_new->offset);
} } else {
else
{
p_rcb->p_rmsg->offset += p_pkt->len; p_rcb->p_rmsg->offset += p_pkt->len;
p_rcb->p_rmsg->len += p_pkt->len; p_rcb->p_rmsg->len += p_pkt->len;
p_pkt_new = NULL; p_pkt_new = NULL;
@ -505,29 +468,22 @@ static UINT8 avrc_proc_far_msg(UINT8 handle, UINT8 label, UINT8 cr, BT_HDR **pp_
} }
} }
if (cr == AVCT_CMD) if (cr == AVCT_CMD) {
{
p_rsp = avrc_proc_vendor_command(handle, label, *pp_pkt, p_msg); p_rsp = avrc_proc_vendor_command(handle, label, *pp_pkt, p_msg);
if (p_rsp) if (p_rsp) {
{
AVCT_MsgReq( handle, label, AVCT_RSP, p_rsp); AVCT_MsgReq( handle, label, AVCT_RSP, p_rsp);
drop_code = 3; drop_code = 3;
} } else if (p_msg->hdr.opcode == AVRC_OP_DROP) {
else if (p_msg->hdr.opcode == AVRC_OP_DROP)
{
drop_code = 1; drop_code = 1;
} } else if (p_msg->hdr.opcode == AVRC_OP_DROP_N_FREE) {
else if (p_msg->hdr.opcode == AVRC_OP_DROP_N_FREE)
drop_code = 4; drop_code = 4;
} }
else if (cr == AVCT_RSP && req_continue == TRUE)
{ } else if (cr == AVCT_RSP && req_continue == TRUE) {
avrc_cmd.pdu = AVRC_PDU_REQUEST_CONTINUATION_RSP; avrc_cmd.pdu = AVRC_PDU_REQUEST_CONTINUATION_RSP;
avrc_cmd.status = AVRC_STS_NO_ERROR; avrc_cmd.status = AVRC_STS_NO_ERROR;
avrc_cmd.target_pdu = p_rcb->rasm_pdu; avrc_cmd.target_pdu = p_rcb->rasm_pdu;
if (AVRC_BldCommand ((tAVRC_COMMAND *)&avrc_cmd, &p_cmd) == AVRC_STS_NO_ERROR) if (AVRC_BldCommand ((tAVRC_COMMAND *)&avrc_cmd, &p_cmd) == AVRC_STS_NO_ERROR) {
{
drop_code = 2; drop_code = 2;
AVRC_MsgReq (handle, (UINT8)(label), AVRC_CMD_CTRL, p_cmd); AVRC_MsgReq (handle, (UINT8)(label), AVRC_CMD_CTRL, p_cmd);
} }
@ -567,8 +523,7 @@ static void avrc_msg_cback(UINT8 handle, UINT8 label, UINT8 cr,
tAVRC_MSG_VENDOR *p_msg = &msg.vendor; tAVRC_MSG_VENDOR *p_msg = &msg.vendor;
if (cr == AVCT_CMD && if (cr == AVCT_CMD &&
(p_pkt->layer_specific & AVCT_DATA_CTRL && AVRC_PACKET_LEN < sizeof(p_pkt->len))) (p_pkt->layer_specific & AVCT_DATA_CTRL && AVRC_PACKET_LEN < sizeof(p_pkt->len))) {
{
/* Ignore the invalid AV/C command frame */ /* Ignore the invalid AV/C command frame */
#if (BT_USE_TRACES == TRUE) #if (BT_USE_TRACES == TRUE)
p_drop_msg = "dropped - too long AV/C cmd frame size"; p_drop_msg = "dropped - too long AV/C cmd frame size";
@ -577,8 +532,7 @@ static void avrc_msg_cback(UINT8 handle, UINT8 label, UINT8 cr,
return; return;
} }
if (cr == AVCT_REJ) if (cr == AVCT_REJ) {
{
/* The peer thinks that this PID is no longer open - remove this handle */ /* The peer thinks that this PID is no longer open - remove this handle */
/* */ /* */
GKI_freebuf(p_pkt); GKI_freebuf(p_pkt);
@ -598,14 +552,11 @@ static void avrc_msg_cback(UINT8 handle, UINT8 label, UINT8 cr,
} }
if ( ((avrc_cb.ccb[handle].control & AVRC_CT_TARGET) && (cr == AVCT_CMD)) || if ( ((avrc_cb.ccb[handle].control & AVRC_CT_TARGET) && (cr == AVCT_CMD)) ||
((avrc_cb.ccb[handle].control & AVRC_CT_CONTROL) && (cr == AVCT_RSP)) ) ((avrc_cb.ccb[handle].control & AVRC_CT_CONTROL) && (cr == AVCT_RSP)) ) {
{
switch(opcode) switch (opcode) {
{
case AVRC_OP_UNIT_INFO: case AVRC_OP_UNIT_INFO:
if (cr == AVCT_CMD) if (cr == AVCT_CMD) {
{
/* send the response to the peer */ /* send the response to the peer */
p_rsp = avrc_copy_packet(p_pkt, AVRC_OP_UNIT_INFO_RSP_LEN); p_rsp = avrc_copy_packet(p_pkt, AVRC_OP_UNIT_INFO_RSP_LEN);
p_rsp_data = avrc_get_data_ptr(p_rsp); p_rsp_data = avrc_get_data_ptr(p_rsp);
@ -623,9 +574,7 @@ static void avrc_msg_cback(UINT8 handle, UINT8 label, UINT8 cr,
#if (BT_USE_TRACES == TRUE) #if (BT_USE_TRACES == TRUE)
p_drop_msg = "auto respond"; p_drop_msg = "auto respond";
#endif #endif
} } else {
else
{
/* parse response */ /* parse response */
p_data += 4; /* 3 bytes: ctype, subunit*, opcode + octet 3 (is 7)*/ p_data += 4; /* 3 bytes: ctype, subunit*, opcode + octet 3 (is 7)*/
msg.unit.unit_type = (*p_data & AVRC_SUBTYPE_MASK) >> AVRC_SUBTYPE_SHIFT; msg.unit.unit_type = (*p_data & AVRC_SUBTYPE_MASK) >> AVRC_SUBTYPE_SHIFT;
@ -636,8 +585,7 @@ static void avrc_msg_cback(UINT8 handle, UINT8 label, UINT8 cr,
break; break;
case AVRC_OP_SUB_INFO: case AVRC_OP_SUB_INFO:
if (cr == AVCT_CMD) if (cr == AVCT_CMD) {
{
/* send the response to the peer */ /* send the response to the peer */
p_rsp = avrc_copy_packet(p_pkt, AVRC_OP_SUB_UNIT_INFO_RSP_LEN); p_rsp = avrc_copy_packet(p_pkt, AVRC_OP_SUB_UNIT_INFO_RSP_LEN);
p_rsp_data = avrc_get_data_ptr(p_rsp); p_rsp_data = avrc_get_data_ptr(p_rsp);
@ -654,18 +602,16 @@ static void avrc_msg_cback(UINT8 handle, UINT8 label, UINT8 cr,
#if (BT_USE_TRACES == TRUE) #if (BT_USE_TRACES == TRUE)
p_drop_msg = "auto responded"; p_drop_msg = "auto responded";
#endif #endif
} } else {
else
{
/* parse response */ /* parse response */
p_data += AVRC_AVC_HDR_SIZE; /* 3 bytes: ctype, subunit*, opcode */ p_data += AVRC_AVC_HDR_SIZE; /* 3 bytes: ctype, subunit*, opcode */
msg.sub.page = (*p_data++ >> AVRC_SUB_PAGE_SHIFT) & AVRC_SUB_PAGE_MASK; msg.sub.page = (*p_data++ >> AVRC_SUB_PAGE_SHIFT) & AVRC_SUB_PAGE_MASK;
xx = 0; xx = 0;
while (*p_data != AVRC_CMD_OPRND_PAD && xx<AVRC_SUB_TYPE_LEN) while (*p_data != AVRC_CMD_OPRND_PAD && xx < AVRC_SUB_TYPE_LEN) {
{
msg.sub.subunit_type[xx] = *p_data++ >> AVRC_SUBTYPE_SHIFT; msg.sub.subunit_type[xx] = *p_data++ >> AVRC_SUBTYPE_SHIFT;
if (msg.sub.subunit_type[xx] == AVRC_SUB_PANEL) if (msg.sub.subunit_type[xx] == AVRC_SUB_PANEL) {
msg.sub.panel = TRUE; msg.sub.panel = TRUE;
}
xx++; xx++;
} }
} }
@ -674,12 +620,12 @@ static void avrc_msg_cback(UINT8 handle, UINT8 label, UINT8 cr,
case AVRC_OP_VENDOR: case AVRC_OP_VENDOR:
p_data = (UINT8 *)(p_pkt + 1) + p_pkt->offset; p_data = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
p_begin = p_data; p_begin = p_data;
if (p_pkt->len < AVRC_VENDOR_HDR_SIZE) /* 6 = ctype, subunit*, opcode & CO_ID */ if (p_pkt->len < AVRC_VENDOR_HDR_SIZE) { /* 6 = ctype, subunit*, opcode & CO_ID */
{ if (cr == AVCT_CMD) {
if (cr == AVCT_CMD)
reject = TRUE; reject = TRUE;
else } else {
drop = TRUE; drop = TRUE;
}
break; break;
} }
p_data += AVRC_AVC_HDR_SIZE; /* skip the first 3 bytes: ctype, subunit*, opcode */ p_data += AVRC_AVC_HDR_SIZE; /* skip the first 3 bytes: ctype, subunit*, opcode */
@ -689,30 +635,29 @@ static void avrc_msg_cback(UINT8 handle, UINT8 label, UINT8 cr,
#if (AVRC_METADATA_INCLUDED == TRUE) #if (AVRC_METADATA_INCLUDED == TRUE)
UINT8 drop_code = 0; UINT8 drop_code = 0;
if (p_msg->company_id == AVRC_CO_METADATA) if (p_msg->company_id == AVRC_CO_METADATA) {
{
/* Validate length for metadata message */ /* Validate length for metadata message */
if (p_pkt->len < (AVRC_VENDOR_HDR_SIZE + AVRC_MIN_META_HDR_SIZE)) if (p_pkt->len < (AVRC_VENDOR_HDR_SIZE + AVRC_MIN_META_HDR_SIZE)) {
{ if (cr == AVCT_CMD) {
if (cr == AVCT_CMD)
reject = TRUE; reject = TRUE;
else } else {
drop = TRUE; drop = TRUE;
}
break; break;
} }
/* Check+handle fragmented messages */ /* Check+handle fragmented messages */
drop_code = avrc_proc_far_msg(handle, label, cr, &p_pkt, p_msg); drop_code = avrc_proc_far_msg(handle, label, cr, &p_pkt, p_msg);
if (drop_code > 0) if (drop_code > 0) {
drop = TRUE; drop = TRUE;
} }
if (drop_code > 0) }
{ if (drop_code > 0) {
if (drop_code != 4) if (drop_code != 4) {
do_free = FALSE; do_free = FALSE;
}
#if (BT_USE_TRACES == TRUE) #if (BT_USE_TRACES == TRUE)
switch (drop_code) switch (drop_code) {
{
case 1: case 1:
p_drop_msg = "sent_frag"; p_drop_msg = "sent_frag";
break; break;
@ -734,48 +679,47 @@ static void avrc_msg_cback(UINT8 handle, UINT8 label, UINT8 cr,
break; break;
case AVRC_OP_PASS_THRU: case AVRC_OP_PASS_THRU:
if (p_pkt->len < 5) /* 3 bytes: ctype, subunit*, opcode & op_id & len */ if (p_pkt->len < 5) { /* 3 bytes: ctype, subunit*, opcode & op_id & len */
{ if (cr == AVCT_CMD) {
if (cr == AVCT_CMD)
reject = TRUE; reject = TRUE;
else } else {
drop = TRUE; drop = TRUE;
}
break; break;
} }
p_data += AVRC_AVC_HDR_SIZE; /* skip the first 3 bytes: ctype, subunit*, opcode */ p_data += AVRC_AVC_HDR_SIZE; /* skip the first 3 bytes: ctype, subunit*, opcode */
msg.pass.op_id = (AVRC_PASS_OP_ID_MASK & *p_data); msg.pass.op_id = (AVRC_PASS_OP_ID_MASK & *p_data);
if (AVRC_PASS_STATE_MASK & *p_data) if (AVRC_PASS_STATE_MASK & *p_data) {
msg.pass.state = TRUE; msg.pass.state = TRUE;
else } else {
msg.pass.state = FALSE; msg.pass.state = FALSE;
}
p_data++; p_data++;
msg.pass.pass_len = *p_data++; msg.pass.pass_len = *p_data++;
if (msg.pass.pass_len != p_pkt->len - 5) if (msg.pass.pass_len != p_pkt->len - 5) {
msg.pass.pass_len = p_pkt->len - 5; msg.pass.pass_len = p_pkt->len - 5;
if (msg.pass.pass_len) }
if (msg.pass.pass_len) {
msg.pass.p_pass_data = p_data; msg.pass.p_pass_data = p_data;
else } else {
msg.pass.p_pass_data = NULL; msg.pass.p_pass_data = NULL;
}
break; break;
default: default:
if ((avrc_cb.ccb[handle].control & AVRC_CT_TARGET) && (cr == AVCT_CMD)) if ((avrc_cb.ccb[handle].control & AVRC_CT_TARGET) && (cr == AVCT_CMD)) {
{
/* reject unsupported opcode */ /* reject unsupported opcode */
reject = TRUE; reject = TRUE;
} }
drop = TRUE; drop = TRUE;
break; break;
} }
} } else { /* drop the event */
else /* drop the event */
{
drop = TRUE; drop = TRUE;
} }
if (reject) if (reject) {
{
/* reject unsupported opcode */ /* reject unsupported opcode */
p_rsp = avrc_copy_packet(p_pkt, AVRC_OP_REJ_MSG_LEN); p_rsp = avrc_copy_packet(p_pkt, AVRC_OP_REJ_MSG_LEN);
p_rsp_data = avrc_get_data_ptr(p_rsp); p_rsp_data = avrc_get_data_ptr(p_rsp);
@ -787,21 +731,18 @@ static void avrc_msg_cback(UINT8 handle, UINT8 label, UINT8 cr,
drop = TRUE; drop = TRUE;
} }
if (p_rsp) if (p_rsp) {
{
/* set to send response right away */ /* set to send response right away */
AVCT_MsgReq( handle, label, cr, p_rsp); AVCT_MsgReq( handle, label, cr, p_rsp);
drop = TRUE; drop = TRUE;
} }
if (drop == FALSE) if (drop == FALSE) {
{
msg.hdr.opcode = opcode; msg.hdr.opcode = opcode;
(*avrc_cb.ccb[handle].p_msg_cback)(handle, label, opcode, &msg); (*avrc_cb.ccb[handle].p_msg_cback)(handle, label, opcode, &msg);
} }
#if (BT_USE_TRACES == TRUE) #if (BT_USE_TRACES == TRUE)
else else {
{
AVRC_TRACE_WARNING("avrc_msg_cback %s msg handle:%d, control:%d, cr:%d, opcode:x%x", AVRC_TRACE_WARNING("avrc_msg_cback %s msg handle:%d, control:%d, cr:%d, opcode:x%x",
p_drop_msg, p_drop_msg,
handle, avrc_cb.ccb[handle].control, cr, opcode); handle, avrc_cb.ccb[handle].control, cr, opcode);
@ -809,9 +750,10 @@ static void avrc_msg_cback(UINT8 handle, UINT8 label, UINT8 cr,
#endif #endif
if (do_free) if (do_free) {
GKI_freebuf(p_pkt); GKI_freebuf(p_pkt);
} }
}
@ -840,8 +782,7 @@ static BT_HDR * avrc_pass_msg(tAVRC_MSG_PASS *p_msg)
assert(p_msg != NULL); assert(p_msg != NULL);
assert(AVRC_CMD_POOL_SIZE > (AVRC_MIN_CMD_LEN + p_msg->pass_len)); assert(AVRC_CMD_POOL_SIZE > (AVRC_MIN_CMD_LEN + p_msg->pass_len));
if ((p_cmd = (BT_HDR *) GKI_getpoolbuf(AVRC_CMD_POOL_ID)) != NULL) if ((p_cmd = (BT_HDR *) GKI_getpoolbuf(AVRC_CMD_POOL_ID)) != NULL) {
{
p_cmd->offset = AVCT_MSG_OFFSET; p_cmd->offset = AVCT_MSG_OFFSET;
p_cmd->layer_specific = AVCT_DATA_CTRL; p_cmd->layer_specific = AVCT_DATA_CTRL;
p_data = (UINT8 *)(p_cmd + 1) + p_cmd->offset; p_data = (UINT8 *)(p_cmd + 1) + p_cmd->offset;
@ -849,21 +790,18 @@ static BT_HDR * avrc_pass_msg(tAVRC_MSG_PASS *p_msg)
*p_data++ = (AVRC_SUB_PANEL << AVRC_SUBTYPE_SHIFT); /* Panel subunit & id=0 */ *p_data++ = (AVRC_SUB_PANEL << AVRC_SUBTYPE_SHIFT); /* Panel subunit & id=0 */
*p_data++ = AVRC_OP_PASS_THRU; *p_data++ = AVRC_OP_PASS_THRU;
*p_data = (AVRC_PASS_OP_ID_MASK & p_msg->op_id); *p_data = (AVRC_PASS_OP_ID_MASK & p_msg->op_id);
if (p_msg->state) if (p_msg->state) {
*p_data |= AVRC_PASS_STATE_MASK; *p_data |= AVRC_PASS_STATE_MASK;
}
p_data++; p_data++;
if (p_msg->op_id == AVRC_ID_VENDOR) if (p_msg->op_id == AVRC_ID_VENDOR) {
{
*p_data++ = p_msg->pass_len; *p_data++ = p_msg->pass_len;
if (p_msg->pass_len && p_msg->p_pass_data) if (p_msg->pass_len && p_msg->p_pass_data) {
{
memcpy(p_data, p_msg->p_pass_data, p_msg->pass_len); memcpy(p_data, p_msg->p_pass_data, p_msg->pass_len);
p_data += p_msg->pass_len; p_data += p_msg->pass_len;
} }
} } else { /* set msg len to 0 for other op_id */
else /* set msg len to 0 for other op_id */
{
/* set msg len to 0 for other op_id */ /* set msg len to 0 for other op_id */
*p_data++ = 0; *p_data++ = 0;
} }
@ -929,8 +867,7 @@ UINT16 AVRC_Open(UINT8 *p_handle, tAVRC_CONN_CB *p_ccb, BD_ADDR_PTR peer_addr)
cc.control = p_ccb->control; /* Control role (Control/Target) */ cc.control = p_ccb->control; /* Control role (Control/Target) */
status = AVCT_CreateConn(p_handle, &cc, peer_addr); status = AVCT_CreateConn(p_handle, &cc, peer_addr);
if (status == AVCT_SUCCESS) if (status == AVCT_SUCCESS) {
{
memcpy(&avrc_cb.ccb[*p_handle], p_ccb, sizeof(tAVRC_CONN_CB)); memcpy(&avrc_cb.ccb[*p_handle], p_ccb, sizeof(tAVRC_CONN_CB));
#if (AVRC_METADATA_INCLUDED == TRUE) #if (AVRC_METADATA_INCLUDED == TRUE)
memset(&avrc_cb.fcb[*p_handle], 0, sizeof(tAVRC_FRAG_CB)); memset(&avrc_cb.fcb[*p_handle], 0, sizeof(tAVRC_FRAG_CB));
@ -995,17 +932,18 @@ UINT16 AVRC_MsgReq (UINT8 handle, UINT8 label, UINT8 ctype, BT_HDR *p_pkt)
UINT16 len; UINT16 len;
BT_HDR *p_pkt_new; BT_HDR *p_pkt_new;
if (!p_pkt) if (!p_pkt) {
return AVRC_BAD_PARAM; return AVRC_BAD_PARAM;
}
AVRC_TRACE_DEBUG("%s handle = %u label = %u ctype = %u len = %d", AVRC_TRACE_DEBUG("%s handle = %u label = %u ctype = %u len = %d",
__func__, handle, label, ctype, p_pkt->len); __func__, handle, label, ctype, p_pkt->len);
if (ctype >= AVRC_RSP_NOT_IMPL) if (ctype >= AVRC_RSP_NOT_IMPL) {
cr = AVCT_RSP; cr = AVCT_RSP;
}
if (p_pkt->event == AVRC_OP_VENDOR) if (p_pkt->event == AVRC_OP_VENDOR) {
{
/* add AVRCP Vendor Dependent headers */ /* add AVRCP Vendor Dependent headers */
p_start = ((UINT8 *)(p_pkt + 1) + p_pkt->offset); p_start = ((UINT8 *)(p_pkt + 1) + p_pkt->offset);
p_pkt->offset -= AVRC_VENDOR_HDR_SIZE; p_pkt->offset -= AVRC_VENDOR_HDR_SIZE;
@ -1015,9 +953,7 @@ UINT16 AVRC_MsgReq (UINT8 handle, UINT8 label, UINT8 ctype, BT_HDR *p_pkt)
*p_data++ = (AVRC_SUB_PANEL << AVRC_SUBTYPE_SHIFT); *p_data++ = (AVRC_SUB_PANEL << AVRC_SUBTYPE_SHIFT);
*p_data++ = AVRC_OP_VENDOR; *p_data++ = AVRC_OP_VENDOR;
AVRC_CO_ID_TO_BE_STREAM(p_data, AVRC_CO_METADATA); AVRC_CO_ID_TO_BE_STREAM(p_data, AVRC_CO_METADATA);
} } else if (p_pkt->event == AVRC_OP_PASS_THRU) {
else if (p_pkt->event == AVRC_OP_PASS_THRU)
{
/* add AVRCP Pass Through headers */ /* add AVRCP Pass Through headers */
p_start = ((UINT8 *)(p_pkt + 1) + p_pkt->offset); p_start = ((UINT8 *)(p_pkt + 1) + p_pkt->offset);
p_pkt->offset -= AVRC_PASS_THRU_SIZE; p_pkt->offset -= AVRC_PASS_THRU_SIZE;
@ -1033,26 +969,23 @@ UINT16 AVRC_MsgReq (UINT8 handle, UINT8 label, UINT8 ctype, BT_HDR *p_pkt)
/* abandon previous fragments */ /* abandon previous fragments */
p_fcb = &avrc_cb.fcb[handle]; p_fcb = &avrc_cb.fcb[handle];
if (p_fcb->frag_enabled) if (p_fcb->frag_enabled) {
p_fcb->frag_enabled = FALSE; p_fcb->frag_enabled = FALSE;
}
if (p_fcb->p_fmsg) if (p_fcb->p_fmsg) {
{
GKI_freebuf(p_fcb->p_fmsg); GKI_freebuf(p_fcb->p_fmsg);
p_fcb->p_fmsg = NULL; p_fcb->p_fmsg = NULL;
} }
/* AVRCP spec has not defined any control channel commands that needs fragmentation at this level /* AVRCP spec has not defined any control channel commands that needs fragmentation at this level
* check for fragmentation only on the response */ * check for fragmentation only on the response */
if ((cr == AVCT_RSP) && (chk_frag == TRUE)) if ((cr == AVCT_RSP) && (chk_frag == TRUE)) {
{ if (p_pkt->len > AVRC_MAX_CTRL_DATA_LEN) {
if (p_pkt->len > AVRC_MAX_CTRL_DATA_LEN)
{
int offset_len = MAX(AVCT_MSG_OFFSET, p_pkt->offset); int offset_len = MAX(AVCT_MSG_OFFSET, p_pkt->offset);
p_pkt_new = (BT_HDR *)GKI_getbuf((UINT16)(AVRC_PACKET_LEN + offset_len p_pkt_new = (BT_HDR *)GKI_getbuf((UINT16)(AVRC_PACKET_LEN + offset_len
+ BT_HDR_SIZE)); + BT_HDR_SIZE));
if (p_pkt_new && (p_start != NULL)) if (p_pkt_new && (p_start != NULL)) {
{
p_fcb->frag_enabled = TRUE; p_fcb->frag_enabled = TRUE;
p_fcb->p_fmsg = p_pkt; p_fcb->p_fmsg = p_pkt;
p_fcb->frag_pdu = *p_start; p_fcb->frag_pdu = *p_start;
@ -1077,9 +1010,7 @@ UINT16 AVRC_MsgReq (UINT8 handle, UINT8 label, UINT8 ctype, BT_HDR *p_pkt)
avrc_prep_end_frag (handle); avrc_prep_end_frag (handle);
AVRC_TRACE_DEBUG ("%s p_pkt len:%d/%d, next len:%d", __func__, AVRC_TRACE_DEBUG ("%s p_pkt len:%d/%d, next len:%d", __func__,
p_pkt->len, len, p_fcb->p_fmsg->len ); p_pkt->len, len, p_fcb->p_fmsg->len );
} } else {
else
{
AVRC_TRACE_ERROR ("AVRC_MsgReq no buffers for fragmentation" ); AVRC_TRACE_ERROR ("AVRC_MsgReq no buffers for fragmentation" );
GKI_freebuf(p_pkt); GKI_freebuf(p_pkt);
return AVRC_NO_RESOURCES; return AVRC_NO_RESOURCES;
@ -1121,13 +1052,13 @@ UINT16 AVRC_PassCmd(UINT8 handle, UINT8 label, tAVRC_MSG_PASS *p_msg)
{ {
BT_HDR *p_buf; BT_HDR *p_buf;
assert(p_msg != NULL); assert(p_msg != NULL);
if (p_msg) if (p_msg) {
{
p_msg->hdr.ctype = AVRC_CMD_CTRL; p_msg->hdr.ctype = AVRC_CMD_CTRL;
p_buf = avrc_pass_msg(p_msg); p_buf = avrc_pass_msg(p_msg);
if (p_buf) if (p_buf) {
return AVCT_MsgReq( handle, label, AVCT_CMD, p_buf); return AVCT_MsgReq( handle, label, AVCT_CMD, p_buf);
} }
}
return AVRC_NO_RESOURCES; return AVRC_NO_RESOURCES;
} }
@ -1160,12 +1091,12 @@ UINT16 AVRC_PassRsp(UINT8 handle, UINT8 label, tAVRC_MSG_PASS *p_msg)
{ {
BT_HDR *p_buf; BT_HDR *p_buf;
assert(p_msg != NULL); assert(p_msg != NULL);
if (p_msg) if (p_msg) {
{
p_buf = avrc_pass_msg(p_msg); p_buf = avrc_pass_msg(p_msg);
if (p_buf) if (p_buf) {
return AVCT_MsgReq( handle, label, AVCT_RSP, p_buf); return AVCT_MsgReq( handle, label, AVCT_RSP, p_buf);
} }
}
return AVRC_NO_RESOURCES; return AVRC_NO_RESOURCES;
} }

30
components/bt/bluedroid/stack/avrc/avrc_bld_ct.c Executable file → Normal file
View file

@ -135,8 +135,7 @@ static BT_HDR *avrc_bld_init_cmd_buffer(tAVRC_COMMAND *p_cmd)
opcode = avrc_opcode_from_pdu(p_cmd->pdu); opcode = avrc_opcode_from_pdu(p_cmd->pdu);
AVRC_TRACE_API("avrc_bld_init_cmd_buffer: pdu=%x, opcode=%x", p_cmd->pdu, opcode); AVRC_TRACE_API("avrc_bld_init_cmd_buffer: pdu=%x, opcode=%x", p_cmd->pdu, opcode);
switch (opcode) switch (opcode) {
{
case AVRC_OP_PASS_THRU: case AVRC_OP_PASS_THRU:
offset = AVRC_MSG_PASS_THRU_OFFSET; offset = AVRC_MSG_PASS_THRU_OFFSET;
break; break;
@ -148,8 +147,7 @@ static BT_HDR *avrc_bld_init_cmd_buffer(tAVRC_COMMAND *p_cmd)
/* allocate and initialize the buffer */ /* allocate and initialize the buffer */
p_pkt = (BT_HDR *)GKI_getbuf(len); p_pkt = (BT_HDR *)GKI_getbuf(len);
if (p_pkt) if (p_pkt) {
{
UINT8 *p_data, *p_start; UINT8 *p_data, *p_start;
p_pkt->layer_specific = chnl; p_pkt->layer_specific = chnl;
@ -159,11 +157,11 @@ static BT_HDR *avrc_bld_init_cmd_buffer(tAVRC_COMMAND *p_cmd)
p_start = p_data; p_start = p_data;
/* pass thru - group navigation - has a two byte op_id, so dont do it here */ /* pass thru - group navigation - has a two byte op_id, so dont do it here */
if (opcode != AVRC_OP_PASS_THRU) if (opcode != AVRC_OP_PASS_THRU) {
*p_data++ = p_cmd->pdu; *p_data++ = p_cmd->pdu;
}
switch (opcode) switch (opcode) {
{
case AVRC_OP_VENDOR: case AVRC_OP_VENDOR:
/* reserved 0, packet_type 0 */ /* reserved 0, packet_type 0 */
UINT8_TO_BE_STREAM(p_data, 0); UINT8_TO_BE_STREAM(p_data, 0);
@ -197,17 +195,14 @@ tAVRC_STS AVRC_BldCommand( tAVRC_COMMAND *p_cmd, BT_HDR **pp_pkt)
BOOLEAN alloc = FALSE; BOOLEAN alloc = FALSE;
AVRC_TRACE_API("AVRC_BldCommand: pdu=%x status=%x", p_cmd->cmd.pdu, p_cmd->cmd.status); AVRC_TRACE_API("AVRC_BldCommand: pdu=%x status=%x", p_cmd->cmd.pdu, p_cmd->cmd.status);
if (!p_cmd || !pp_pkt) if (!p_cmd || !pp_pkt) {
{
AVRC_TRACE_API("AVRC_BldCommand. Invalid parameters passed. p_cmd=%p, pp_pkt=%p", AVRC_TRACE_API("AVRC_BldCommand. Invalid parameters passed. p_cmd=%p, pp_pkt=%p",
p_cmd, pp_pkt); p_cmd, pp_pkt);
return AVRC_STS_BAD_PARAM; return AVRC_STS_BAD_PARAM;
} }
if (*pp_pkt == NULL) if (*pp_pkt == NULL) {
{ if ((*pp_pkt = avrc_bld_init_cmd_buffer(p_cmd)) == NULL) {
if ((*pp_pkt = avrc_bld_init_cmd_buffer(p_cmd)) == NULL)
{
AVRC_TRACE_API("AVRC_BldCommand: Failed to initialize command buffer"); AVRC_TRACE_API("AVRC_BldCommand: Failed to initialize command buffer");
return AVRC_STS_INTERNAL_ERR; return AVRC_STS_INTERNAL_ERR;
} }
@ -216,8 +211,7 @@ tAVRC_STS AVRC_BldCommand( tAVRC_COMMAND *p_cmd, BT_HDR **pp_pkt)
status = AVRC_STS_NO_ERROR; status = AVRC_STS_NO_ERROR;
p_pkt = *pp_pkt; p_pkt = *pp_pkt;
switch (p_cmd->pdu) switch (p_cmd->pdu) {
{
case AVRC_PDU_REQUEST_CONTINUATION_RSP: /* 0x40 */ case AVRC_PDU_REQUEST_CONTINUATION_RSP: /* 0x40 */
status = avrc_bld_next_cmd(&p_cmd->continu, p_pkt); status = avrc_bld_next_cmd(&p_cmd->continu, p_pkt);
break; break;
@ -233,15 +227,15 @@ tAVRC_STS AVRC_BldCommand( tAVRC_COMMAND *p_cmd, BT_HDR **pp_pkt)
case AVRC_PDU_REGISTER_NOTIFICATION: /* 0x31 */ case AVRC_PDU_REGISTER_NOTIFICATION: /* 0x31 */
#if (AVRC_ADV_CTRL_INCLUDED == TRUE) #if (AVRC_ADV_CTRL_INCLUDED == TRUE)
if(AVRC_EVT_VOLUME_CHANGE==p_cmd->reg_notif.event_id) if (AVRC_EVT_VOLUME_CHANGE == p_cmd->reg_notif.event_id) {
status = avrc_bld_vol_change_notfn(p_pkt); status = avrc_bld_vol_change_notfn(p_pkt);
}
#endif #endif
break; break;
} }
if (alloc && (status != AVRC_STS_NO_ERROR) ) if (alloc && (status != AVRC_STS_NO_ERROR) ) {
{
GKI_freebuf(p_pkt); GKI_freebuf(p_pkt);
*pp_pkt = NULL; *pp_pkt = NULL;
} }

186
components/bt/bluedroid/stack/avrc/avrc_bld_tg.c Executable file → Normal file
View file

@ -49,8 +49,7 @@ static tAVRC_STS avrc_bld_get_capability_rsp (tAVRC_GET_CAPS_RSP *p_rsp, BT_HDR
UINT8 *p_event_id; UINT8 *p_event_id;
tAVRC_STS status = AVRC_STS_NO_ERROR; tAVRC_STS status = AVRC_STS_NO_ERROR;
if (!(AVRC_IS_VALID_CAP_ID(p_rsp->capability_id))) if (!(AVRC_IS_VALID_CAP_ID(p_rsp->capability_id))) {
{
AVRC_TRACE_ERROR("avrc_bld_get_capability_rsp bad parameter. p_rsp: %x", (int)p_rsp); AVRC_TRACE_ERROR("avrc_bld_get_capability_rsp bad parameter. p_rsp: %x", (int)p_rsp);
status = AVRC_STS_BAD_PARAM; status = AVRC_STS_BAD_PARAM;
return status; return status;
@ -65,35 +64,26 @@ static tAVRC_STS avrc_bld_get_capability_rsp (tAVRC_GET_CAPS_RSP *p_rsp, BT_HDR
UINT8_TO_BE_STREAM(p_data, p_rsp->capability_id); UINT8_TO_BE_STREAM(p_data, p_rsp->capability_id);
p_count = p_data; p_count = p_data;
if (len == 0) if (len == 0) {
{
*p_count = p_rsp->count; *p_count = p_rsp->count;
p_data++; p_data++;
len = 2; /* move past the capability_id and count */ len = 2; /* move past the capability_id and count */
} } else {
else
{
p_data = p_start + p_pkt->len; p_data = p_start + p_pkt->len;
*p_count += p_rsp->count; *p_count += p_rsp->count;
} }
if (p_rsp->capability_id == AVRC_CAP_COMPANY_ID) if (p_rsp->capability_id == AVRC_CAP_COMPANY_ID) {
{
p_company_id = p_rsp->param.company_id; p_company_id = p_rsp->param.company_id;
for (xx=0; xx< p_rsp->count; xx++) for (xx = 0; xx < p_rsp->count; xx++) {
{
UINT24_TO_BE_STREAM(p_data, p_company_id[xx]); UINT24_TO_BE_STREAM(p_data, p_company_id[xx]);
} }
len += p_rsp->count * 3; len += p_rsp->count * 3;
} } else {
else
{
p_event_id = p_rsp->param.event_id; p_event_id = p_rsp->param.event_id;
*p_count = 0; *p_count = 0;
for (xx=0; xx< p_rsp->count; xx++) for (xx = 0; xx < p_rsp->count; xx++) {
{ if (AVRC_IS_VALID_EVENT_ID(p_event_id[xx])) {
if (AVRC_IS_VALID_EVENT_ID(p_event_id[xx]))
{
(*p_count)++; (*p_count)++;
UINT8_TO_BE_STREAM(p_data, p_event_id[xx]); UINT8_TO_BE_STREAM(p_data, p_event_id[xx]);
} }
@ -131,21 +121,16 @@ static tAVRC_STS avrc_bld_list_app_settings_attr_rsp (tAVRC_LIST_APP_ATTR_RSP *p
BE_STREAM_TO_UINT16(len, p_data); BE_STREAM_TO_UINT16(len, p_data);
p_num = p_data; p_num = p_data;
if (len == 0) if (len == 0) {
{
/* first time initialize the attribute count */ /* first time initialize the attribute count */
*p_num = 0; *p_num = 0;
p_data++; p_data++;
} } else {
else
{
p_data = p_start + p_pkt->len; p_data = p_start + p_pkt->len;
} }
for (xx=0; xx<p_rsp->num_attr; xx++) for (xx = 0; xx < p_rsp->num_attr; xx++) {
{ if (AVRC_IsValidPlayerAttr(p_rsp->attrs[xx])) {
if(AVRC_IsValidPlayerAttr(p_rsp->attrs[xx]))
{
(*p_num)++; (*p_num)++;
UINT8_TO_BE_STREAM(p_data, p_rsp->attrs[xx]); UINT8_TO_BE_STREAM(p_data, p_rsp->attrs[xx]);
} }
@ -185,20 +170,16 @@ static tAVRC_STS avrc_bld_list_app_settings_values_rsp (tAVRC_LIST_APP_VALUES_RS
BE_STREAM_TO_UINT16(len, p_data); BE_STREAM_TO_UINT16(len, p_data);
p_num = p_data; p_num = p_data;
/* first time initialize the attribute count */ /* first time initialize the attribute count */
if (len == 0) if (len == 0) {
{
*p_num = p_rsp->num_val; *p_num = p_rsp->num_val;
p_data++; p_data++;
} } else {
else
{
p_data = p_start + p_pkt->len; p_data = p_start + p_pkt->len;
*p_num += p_rsp->num_val; *p_num += p_rsp->num_val;
} }
for (xx=0; xx<p_rsp->num_val; xx++) for (xx = 0; xx < p_rsp->num_val; xx++) {
{
UINT8_TO_BE_STREAM(p_data, p_rsp->vals[xx]); UINT8_TO_BE_STREAM(p_data, p_rsp->vals[xx]);
} }
@ -226,8 +207,7 @@ static tAVRC_STS avrc_bld_get_cur_app_setting_value_rsp (tAVRC_GET_CUR_APP_VALUE
UINT16 len; UINT16 len;
UINT8 xx; UINT8 xx;
if (!p_rsp->p_vals) if (!p_rsp->p_vals) {
{
AVRC_TRACE_ERROR("avrc_bld_get_cur_app_setting_value_rsp NULL parameter"); AVRC_TRACE_ERROR("avrc_bld_get_cur_app_setting_value_rsp NULL parameter");
return AVRC_STS_BAD_PARAM; return AVRC_STS_BAD_PARAM;
} }
@ -239,21 +219,16 @@ static tAVRC_STS avrc_bld_get_cur_app_setting_value_rsp (tAVRC_GET_CUR_APP_VALUE
BE_STREAM_TO_UINT16(len, p_data); BE_STREAM_TO_UINT16(len, p_data);
p_count = p_data; p_count = p_data;
if (len == 0) if (len == 0) {
{
/* first time initialize the attribute count */ /* first time initialize the attribute count */
*p_count = 0; *p_count = 0;
p_data++; p_data++;
} } else {
else
{
p_data = p_start + p_pkt->len; p_data = p_start + p_pkt->len;
} }
for (xx=0; xx<p_rsp->num_val; xx++) for (xx = 0; xx < p_rsp->num_val; xx++) {
{ if (avrc_is_valid_player_attrib_value(p_rsp->p_vals[xx].attr_id, p_rsp->p_vals[xx].attr_val)) {
if (avrc_is_valid_player_attrib_value(p_rsp->p_vals[xx].attr_id, p_rsp->p_vals[xx].attr_val))
{
(*p_count)++; (*p_count)++;
UINT8_TO_BE_STREAM(p_data, p_rsp->p_vals[xx].attr_id); UINT8_TO_BE_STREAM(p_data, p_rsp->p_vals[xx].attr_id);
UINT8_TO_BE_STREAM(p_data, p_rsp->p_vals[xx].attr_val); UINT8_TO_BE_STREAM(p_data, p_rsp->p_vals[xx].attr_val);
@ -306,8 +281,7 @@ static tAVRC_STS avrc_bld_app_setting_text_rsp (tAVRC_GET_APP_ATTR_TXT_RSP *p_rs
tAVRC_STS sts = AVRC_STS_NO_ERROR; tAVRC_STS sts = AVRC_STS_NO_ERROR;
UINT8 num_added = 0; UINT8 num_added = 0;
if (!p_rsp->p_attrs) if (!p_rsp->p_attrs) {
{
AVRC_TRACE_ERROR("avrc_bld_app_setting_text_rsp NULL parameter"); AVRC_TRACE_ERROR("avrc_bld_app_setting_text_rsp NULL parameter");
return AVRC_STS_BAD_PARAM; return AVRC_STS_BAD_PARAM;
} }
@ -319,28 +293,22 @@ static tAVRC_STS avrc_bld_app_setting_text_rsp (tAVRC_GET_APP_ATTR_TXT_RSP *p_rs
BE_STREAM_TO_UINT16(len, p_data); BE_STREAM_TO_UINT16(len, p_data);
p_count = p_data; p_count = p_data;
if (len == 0) if (len == 0) {
{
*p_count = 0; *p_count = 0;
p_data++; p_data++;
} } else {
else
{
p_data = p_start + p_pkt->len; p_data = p_start + p_pkt->len;
} }
for (xx=0; xx<p_rsp->num_attr; xx++) for (xx = 0; xx < p_rsp->num_attr; xx++) {
{ if (len_left < (p_rsp->p_attrs[xx].str_len + 4)) {
if (len_left < (p_rsp->p_attrs[xx].str_len + 4))
{
AVRC_TRACE_ERROR("avrc_bld_app_setting_text_rsp out of room %d(str_len:%d, left:%d)", AVRC_TRACE_ERROR("avrc_bld_app_setting_text_rsp out of room %d(str_len:%d, left:%d)",
xx, p_rsp->p_attrs[xx].str_len, len_left); xx, p_rsp->p_attrs[xx].str_len, len_left);
p_rsp->num_attr = num_added; p_rsp->num_attr = num_added;
sts = AVRC_STS_INTERNAL_ERR; sts = AVRC_STS_INTERNAL_ERR;
break; break;
} }
if ( !p_rsp->p_attrs[xx].str_len || !p_rsp->p_attrs[xx].p_str ) if ( !p_rsp->p_attrs[xx].str_len || !p_rsp->p_attrs[xx].p_str ) {
{
AVRC_TRACE_ERROR("avrc_bld_app_setting_text_rsp NULL attr text[%d]", xx); AVRC_TRACE_ERROR("avrc_bld_app_setting_text_rsp NULL attr text[%d]", xx);
continue; continue;
} }
@ -454,8 +422,7 @@ static tAVRC_STS avrc_bld_get_elem_attrs_rsp (tAVRC_GET_ELEM_ATTRS_RSP *p_rsp, B
UINT8 xx; UINT8 xx;
AVRC_TRACE_API("avrc_bld_get_elem_attrs_rsp"); AVRC_TRACE_API("avrc_bld_get_elem_attrs_rsp");
if (!p_rsp->p_attrs) if (!p_rsp->p_attrs) {
{
AVRC_TRACE_ERROR("avrc_bld_get_elem_attrs_rsp NULL parameter"); AVRC_TRACE_ERROR("avrc_bld_get_elem_attrs_rsp NULL parameter");
return AVRC_STS_BAD_PARAM; return AVRC_STS_BAD_PARAM;
} }
@ -467,25 +434,19 @@ static tAVRC_STS avrc_bld_get_elem_attrs_rsp (tAVRC_GET_ELEM_ATTRS_RSP *p_rsp, B
BE_STREAM_TO_UINT16(len, p_data); BE_STREAM_TO_UINT16(len, p_data);
p_count = p_data; p_count = p_data;
if (len == 0) if (len == 0) {
{
*p_count = 0; *p_count = 0;
p_data++; p_data++;
} } else {
else
{
p_data = p_start + p_pkt->len; p_data = p_start + p_pkt->len;
} }
for (xx=0; xx<p_rsp->num_attr; xx++) for (xx = 0; xx < p_rsp->num_attr; xx++) {
{ if (!AVRC_IS_VALID_MEDIA_ATTRIBUTE(p_rsp->p_attrs[xx].attr_id)) {
if (!AVRC_IS_VALID_MEDIA_ATTRIBUTE(p_rsp->p_attrs[xx].attr_id))
{
AVRC_TRACE_ERROR("avrc_bld_get_elem_attrs_rsp invalid attr id[%d]: %d", xx, p_rsp->p_attrs[xx].attr_id); AVRC_TRACE_ERROR("avrc_bld_get_elem_attrs_rsp invalid attr id[%d]: %d", xx, p_rsp->p_attrs[xx].attr_id);
continue; continue;
} }
if ( !p_rsp->p_attrs[xx].name.p_str ) if ( !p_rsp->p_attrs[xx].name.p_str ) {
{
p_rsp->p_attrs[xx].name.str_len = 0; p_rsp->p_attrs[xx].name.str_len = 0;
} }
UINT32_TO_BE_STREAM(p_data, p_rsp->p_attrs[xx].attr_id); UINT32_TO_BE_STREAM(p_data, p_rsp->p_attrs[xx].attr_id);
@ -554,18 +515,14 @@ static tAVRC_STS avrc_bld_notify_rsp (tAVRC_REG_NOTIF_RSP *p_rsp, BT_HDR *p_pkt)
p_data += 2; p_data += 2;
UINT8_TO_BE_STREAM(p_data, p_rsp->event_id); UINT8_TO_BE_STREAM(p_data, p_rsp->event_id);
switch (p_rsp->event_id) switch (p_rsp->event_id) {
{
case AVRC_EVT_PLAY_STATUS_CHANGE: /* 0x01 */ case AVRC_EVT_PLAY_STATUS_CHANGE: /* 0x01 */
/* p_rsp->param.play_status >= AVRC_PLAYSTATE_STOPPED is always TRUE */ /* p_rsp->param.play_status >= AVRC_PLAYSTATE_STOPPED is always TRUE */
if ((p_rsp->param.play_status <= AVRC_PLAYSTATE_REV_SEEK) || if ((p_rsp->param.play_status <= AVRC_PLAYSTATE_REV_SEEK) ||
(p_rsp->param.play_status == AVRC_PLAYSTATE_ERROR) ) (p_rsp->param.play_status == AVRC_PLAYSTATE_ERROR) ) {
{
UINT8_TO_BE_STREAM(p_data, p_rsp->param.play_status); UINT8_TO_BE_STREAM(p_data, p_rsp->param.play_status);
len = 2; len = 2;
} } else {
else
{
AVRC_TRACE_ERROR("bad play state"); AVRC_TRACE_ERROR("bad play state");
status = AVRC_STS_BAD_PARAM; status = AVRC_STS_BAD_PARAM;
} }
@ -587,58 +544,48 @@ static tAVRC_STS avrc_bld_notify_rsp (tAVRC_REG_NOTIF_RSP *p_rsp, BT_HDR *p_pkt)
break; break;
case AVRC_EVT_BATTERY_STATUS_CHANGE: /* 0x06 */ case AVRC_EVT_BATTERY_STATUS_CHANGE: /* 0x06 */
if (AVRC_IS_VALID_BATTERY_STATUS(p_rsp->param.battery_status)) if (AVRC_IS_VALID_BATTERY_STATUS(p_rsp->param.battery_status)) {
{
UINT8_TO_BE_STREAM(p_data, p_rsp->param.battery_status); UINT8_TO_BE_STREAM(p_data, p_rsp->param.battery_status);
len = 2; len = 2;
} } else {
else
{
AVRC_TRACE_ERROR("bad battery status"); AVRC_TRACE_ERROR("bad battery status");
status = AVRC_STS_BAD_PARAM; status = AVRC_STS_BAD_PARAM;
} }
break; break;
case AVRC_EVT_SYSTEM_STATUS_CHANGE: /* 0x07 */ case AVRC_EVT_SYSTEM_STATUS_CHANGE: /* 0x07 */
if (AVRC_IS_VALID_SYSTEM_STATUS(p_rsp->param.system_status)) if (AVRC_IS_VALID_SYSTEM_STATUS(p_rsp->param.system_status)) {
{
UINT8_TO_BE_STREAM(p_data, p_rsp->param.system_status); UINT8_TO_BE_STREAM(p_data, p_rsp->param.system_status);
len = 2; len = 2;
} } else {
else
{
AVRC_TRACE_ERROR("bad system status"); AVRC_TRACE_ERROR("bad system status");
status = AVRC_STS_BAD_PARAM; status = AVRC_STS_BAD_PARAM;
} }
break; break;
case AVRC_EVT_APP_SETTING_CHANGE: /* 0x08 */ case AVRC_EVT_APP_SETTING_CHANGE: /* 0x08 */
if (p_rsp->param.player_setting.num_attr > AVRC_MAX_APP_SETTINGS) if (p_rsp->param.player_setting.num_attr > AVRC_MAX_APP_SETTINGS) {
p_rsp->param.player_setting.num_attr = AVRC_MAX_APP_SETTINGS; p_rsp->param.player_setting.num_attr = AVRC_MAX_APP_SETTINGS;
}
if (p_rsp->param.player_setting.num_attr > 0) if (p_rsp->param.player_setting.num_attr > 0) {
{
UINT8_TO_BE_STREAM(p_data, p_rsp->param.player_setting.num_attr); UINT8_TO_BE_STREAM(p_data, p_rsp->param.player_setting.num_attr);
len = 2; len = 2;
for (xx=0; xx<p_rsp->param.player_setting.num_attr; xx++) for (xx = 0; xx < p_rsp->param.player_setting.num_attr; xx++) {
{
if (avrc_is_valid_player_attrib_value(p_rsp->param.player_setting.attr_id[xx], if (avrc_is_valid_player_attrib_value(p_rsp->param.player_setting.attr_id[xx],
p_rsp->param.player_setting.attr_value[xx])) p_rsp->param.player_setting.attr_value[xx])) {
{
UINT8_TO_BE_STREAM(p_data, p_rsp->param.player_setting.attr_id[xx]); UINT8_TO_BE_STREAM(p_data, p_rsp->param.player_setting.attr_id[xx]);
UINT8_TO_BE_STREAM(p_data, p_rsp->param.player_setting.attr_value[xx]); UINT8_TO_BE_STREAM(p_data, p_rsp->param.player_setting.attr_value[xx]);
} } else {
else
{
AVRC_TRACE_ERROR("bad player app seeting attribute or value"); AVRC_TRACE_ERROR("bad player app seeting attribute or value");
status = AVRC_STS_BAD_PARAM; status = AVRC_STS_BAD_PARAM;
break; break;
} }
len += 2; len += 2;
} }
} } else {
else
status = AVRC_STS_BAD_PARAM; status = AVRC_STS_BAD_PARAM;
}
break; break;
default: default:
@ -688,8 +635,7 @@ tAVRC_STS avrc_bld_group_navigation_rsp (UINT16 navi_id, BT_HDR *p_pkt)
{ {
UINT8 *p_data; UINT8 *p_data;
if (!AVRC_IS_VALID_GROUP(navi_id)) if (!AVRC_IS_VALID_GROUP(navi_id)) {
{
AVRC_TRACE_ERROR("avrc_bld_group_navigation_rsp bad navigation op id: %d", navi_id); AVRC_TRACE_ERROR("avrc_bld_group_navigation_rsp bad navigation op id: %d", navi_id);
return AVRC_STS_BAD_PARAM; return AVRC_STS_BAD_PARAM;
} }
@ -747,29 +693,27 @@ static BT_HDR *avrc_bld_init_rsp_buffer(tAVRC_RESPONSE *p_rsp)
AVRC_TRACE_API("avrc_bld_init_rsp_buffer: pdu=%x, opcode=%x/%x", p_rsp->pdu, opcode, AVRC_TRACE_API("avrc_bld_init_rsp_buffer: pdu=%x, opcode=%x/%x", p_rsp->pdu, opcode,
p_rsp->rsp.opcode); p_rsp->rsp.opcode);
if (opcode != p_rsp->rsp.opcode && p_rsp->rsp.status != AVRC_STS_NO_ERROR && if (opcode != p_rsp->rsp.opcode && p_rsp->rsp.status != AVRC_STS_NO_ERROR &&
avrc_is_valid_opcode(p_rsp->rsp.opcode)) avrc_is_valid_opcode(p_rsp->rsp.opcode)) {
{
opcode = p_rsp->rsp.opcode; opcode = p_rsp->rsp.opcode;
AVRC_TRACE_API("opcode=%x", opcode); AVRC_TRACE_API("opcode=%x", opcode);
} }
switch (opcode) switch (opcode) {
{
case AVRC_OP_PASS_THRU: case AVRC_OP_PASS_THRU:
offset = AVRC_MSG_PASS_THRU_OFFSET; offset = AVRC_MSG_PASS_THRU_OFFSET;
break; break;
case AVRC_OP_VENDOR: case AVRC_OP_VENDOR:
offset = AVRC_MSG_VENDOR_OFFSET; offset = AVRC_MSG_VENDOR_OFFSET;
if (p_rsp->pdu == AVRC_PDU_GET_ELEMENT_ATTR) if (p_rsp->pdu == AVRC_PDU_GET_ELEMENT_ATTR) {
len = AVRC_BROWSE_POOL_SIZE; len = AVRC_BROWSE_POOL_SIZE;
}
break; break;
} }
/* allocate and initialize the buffer */ /* allocate and initialize the buffer */
p_pkt = (BT_HDR *)GKI_getbuf(len); p_pkt = (BT_HDR *)GKI_getbuf(len);
if (p_pkt) if (p_pkt) {
{
UINT8 *p_data, *p_start; UINT8 *p_data, *p_start;
p_pkt->layer_specific = chnl; p_pkt->layer_specific = chnl;
@ -779,11 +723,11 @@ static BT_HDR *avrc_bld_init_rsp_buffer(tAVRC_RESPONSE *p_rsp)
p_start = p_data; p_start = p_data;
/* pass thru - group navigation - has a two byte op_id, so dont do it here */ /* pass thru - group navigation - has a two byte op_id, so dont do it here */
if (opcode != AVRC_OP_PASS_THRU) if (opcode != AVRC_OP_PASS_THRU) {
*p_data++ = p_rsp->pdu; *p_data++ = p_rsp->pdu;
}
switch (opcode) switch (opcode) {
{
case AVRC_OP_VENDOR: case AVRC_OP_VENDOR:
/* reserved 0, packet_type 0 */ /* reserved 0, packet_type 0 */
UINT8_TO_BE_STREAM(p_data, 0); UINT8_TO_BE_STREAM(p_data, 0);
@ -817,17 +761,14 @@ tAVRC_STS AVRC_BldResponse( UINT8 handle, tAVRC_RESPONSE *p_rsp, BT_HDR **pp_pkt
BOOLEAN alloc = FALSE; BOOLEAN alloc = FALSE;
UNUSED(handle); UNUSED(handle);
if (!p_rsp || !pp_pkt) if (!p_rsp || !pp_pkt) {
{
AVRC_TRACE_API("AVRC_BldResponse. Invalid parameters passed. p_rsp=%p, pp_pkt=%p", AVRC_TRACE_API("AVRC_BldResponse. Invalid parameters passed. p_rsp=%p, pp_pkt=%p",
p_rsp, pp_pkt); p_rsp, pp_pkt);
return AVRC_STS_BAD_PARAM; return AVRC_STS_BAD_PARAM;
} }
if (*pp_pkt == NULL) if (*pp_pkt == NULL) {
{ if ((*pp_pkt = avrc_bld_init_rsp_buffer(p_rsp)) == NULL) {
if ((*pp_pkt = avrc_bld_init_rsp_buffer(p_rsp)) == NULL)
{
AVRC_TRACE_API("AVRC_BldResponse: Failed to initialize response buffer"); AVRC_TRACE_API("AVRC_BldResponse: Failed to initialize response buffer");
return AVRC_STS_INTERNAL_ERR; return AVRC_STS_INTERNAL_ERR;
} }
@ -837,13 +778,11 @@ tAVRC_STS AVRC_BldResponse( UINT8 handle, tAVRC_RESPONSE *p_rsp, BT_HDR **pp_pkt
p_pkt = *pp_pkt; p_pkt = *pp_pkt;
AVRC_TRACE_API("AVRC_BldResponse: pdu=%x status=%x", p_rsp->rsp.pdu, p_rsp->rsp.status); AVRC_TRACE_API("AVRC_BldResponse: pdu=%x status=%x", p_rsp->rsp.pdu, p_rsp->rsp.status);
if (p_rsp->rsp.status != AVRC_STS_NO_ERROR) if (p_rsp->rsp.status != AVRC_STS_NO_ERROR) {
{
return ( avrc_bld_rejected_rsp(&p_rsp->rsp, p_pkt) ); return ( avrc_bld_rejected_rsp(&p_rsp->rsp, p_pkt) );
} }
switch (p_rsp->pdu) switch (p_rsp->pdu) {
{
case AVRC_PDU_NEXT_GROUP: case AVRC_PDU_NEXT_GROUP:
case AVRC_PDU_PREV_GROUP: case AVRC_PDU_PREV_GROUP:
status = avrc_bld_group_navigation_rsp(p_rsp->pdu, p_pkt); status = avrc_bld_group_navigation_rsp(p_rsp->pdu, p_pkt);
@ -906,8 +845,7 @@ tAVRC_STS AVRC_BldResponse( UINT8 handle, tAVRC_RESPONSE *p_rsp, BT_HDR **pp_pkt
break; break;
} }
if (alloc && (status != AVRC_STS_NO_ERROR) ) if (alloc && (status != AVRC_STS_NO_ERROR) ) {
{
GKI_freebuf(p_pkt); GKI_freebuf(p_pkt);
*pp_pkt = NULL; *pp_pkt = NULL;
} }

19
components/bt/bluedroid/stack/avrc/avrc_opt.c Executable file → Normal file
View file

@ -67,8 +67,7 @@ static BT_HDR * avrc_vendor_msg(tAVRC_MSG_VENDOR *p_msg)
*p_data++ = (p_msg->hdr.subunit_type << AVRC_SUBTYPE_SHIFT) | p_msg->hdr.subunit_id; *p_data++ = (p_msg->hdr.subunit_type << AVRC_SUBTYPE_SHIFT) | p_msg->hdr.subunit_id;
*p_data++ = AVRC_OP_VENDOR; *p_data++ = AVRC_OP_VENDOR;
AVRC_CO_ID_TO_BE_STREAM(p_data, p_msg->company_id); AVRC_CO_ID_TO_BE_STREAM(p_data, p_msg->company_id);
if(p_msg->vendor_len && p_msg->p_vendor_data) if (p_msg->vendor_len && p_msg->p_vendor_data) {
{
memcpy(p_data, p_msg->p_vendor_data, p_msg->vendor_len); memcpy(p_data, p_msg->p_vendor_data, p_msg->vendor_len);
} }
p_cmd->len = (UINT16) (p_data + p_msg->vendor_len - (UINT8 *)(p_cmd + 1) - p_cmd->offset); p_cmd->len = (UINT16) (p_data + p_msg->vendor_len - (UINT8 *)(p_cmd + 1) - p_cmd->offset);
@ -103,8 +102,7 @@ UINT16 AVRC_UnitCmd(UINT8 handle, UINT8 label)
BT_HDR *p_cmd; BT_HDR *p_cmd;
UINT8 *p_data; UINT8 *p_data;
if ((p_cmd = (BT_HDR *) GKI_getpoolbuf(AVRC_CMD_POOL_ID)) != NULL) if ((p_cmd = (BT_HDR *) GKI_getpoolbuf(AVRC_CMD_POOL_ID)) != NULL) {
{
p_cmd->offset = AVCT_MSG_OFFSET; p_cmd->offset = AVCT_MSG_OFFSET;
p_data = (UINT8 *)(p_cmd + 1) + p_cmd->offset; p_data = (UINT8 *)(p_cmd + 1) + p_cmd->offset;
*p_data++ = AVRC_CMD_STATUS; *p_data++ = AVRC_CMD_STATUS;
@ -148,8 +146,7 @@ UINT16 AVRC_SubCmd(UINT8 handle, UINT8 label, UINT8 page)
BT_HDR *p_cmd; BT_HDR *p_cmd;
UINT8 *p_data; UINT8 *p_data;
if ((p_cmd = (BT_HDR *) GKI_getpoolbuf(AVRC_CMD_POOL_ID)) != NULL) if ((p_cmd = (BT_HDR *) GKI_getpoolbuf(AVRC_CMD_POOL_ID)) != NULL) {
{
p_cmd->offset = AVCT_MSG_OFFSET; p_cmd->offset = AVCT_MSG_OFFSET;
p_data = (UINT8 *)(p_cmd + 1) + p_cmd->offset; p_data = (UINT8 *)(p_cmd + 1) + p_cmd->offset;
*p_data++ = AVRC_CMD_STATUS; *p_data++ = AVRC_CMD_STATUS;
@ -190,11 +187,12 @@ UINT16 AVRC_SubCmd(UINT8 handle, UINT8 label, UINT8 page)
UINT16 AVRC_VendorCmd(UINT8 handle, UINT8 label, tAVRC_MSG_VENDOR *p_msg) UINT16 AVRC_VendorCmd(UINT8 handle, UINT8 label, tAVRC_MSG_VENDOR *p_msg)
{ {
BT_HDR *p_buf = avrc_vendor_msg(p_msg); BT_HDR *p_buf = avrc_vendor_msg(p_msg);
if (p_buf) if (p_buf) {
return AVCT_MsgReq( handle, label, AVCT_CMD, p_buf); return AVCT_MsgReq( handle, label, AVCT_CMD, p_buf);
else } else {
return AVCT_NO_RESOURCES; return AVCT_NO_RESOURCES;
} }
}
/****************************************************************************** /******************************************************************************
@ -225,10 +223,11 @@ UINT16 AVRC_VendorCmd(UINT8 handle, UINT8 label, tAVRC_MSG_VENDOR *p_msg)
UINT16 AVRC_VendorRsp(UINT8 handle, UINT8 label, tAVRC_MSG_VENDOR *p_msg) UINT16 AVRC_VendorRsp(UINT8 handle, UINT8 label, tAVRC_MSG_VENDOR *p_msg)
{ {
BT_HDR *p_buf = avrc_vendor_msg(p_msg); BT_HDR *p_buf = avrc_vendor_msg(p_msg);
if (p_buf) if (p_buf) {
return AVCT_MsgReq( handle, label, AVCT_RSP, p_buf); return AVCT_MsgReq( handle, label, AVCT_RSP, p_buf);
else } else {
return AVCT_NO_RESOURCES; return AVCT_NO_RESOURCES;
} }
}
#endif /* #if (defined(AVRC_INCLUDED) && AVRC_INCLUDED == TRUE) */ #endif /* #if (defined(AVRC_INCLUDED) && AVRC_INCLUDED == TRUE) */

29
components/bt/bluedroid/stack/avrc/avrc_pars_ct.c Executable file → Normal file
View file

@ -50,33 +50,32 @@ static tAVRC_STS avrc_pars_vendor_rsp(tAVRC_MSG_VENDOR *p_msg, tAVRC_RESPONSE *p
UINT8 eventid = 0; UINT8 eventid = 0;
/* Check the vendor data */ /* Check the vendor data */
if (p_msg->vendor_len == 0) if (p_msg->vendor_len == 0) {
return AVRC_STS_NO_ERROR; return AVRC_STS_NO_ERROR;
if (p_msg->p_vendor_data == NULL) }
if (p_msg->p_vendor_data == NULL) {
return AVRC_STS_INTERNAL_ERR; return AVRC_STS_INTERNAL_ERR;
}
p = p_msg->p_vendor_data; p = p_msg->p_vendor_data;
BE_STREAM_TO_UINT8 (p_result->pdu, p); BE_STREAM_TO_UINT8 (p_result->pdu, p);
p++; /* skip the reserved/packe_type byte */ p++; /* skip the reserved/packe_type byte */
BE_STREAM_TO_UINT16 (len, p); BE_STREAM_TO_UINT16 (len, p);
AVRC_TRACE_DEBUG("avrc_pars_vendor_rsp() ctype:0x%x pdu:0x%x, len:%d/0x%x", p_msg->hdr.ctype, p_result->pdu, len, len); AVRC_TRACE_DEBUG("avrc_pars_vendor_rsp() ctype:0x%x pdu:0x%x, len:%d/0x%x", p_msg->hdr.ctype, p_result->pdu, len, len);
if (p_msg->hdr.ctype == AVRC_RSP_REJ) if (p_msg->hdr.ctype == AVRC_RSP_REJ) {
{
p_result->rsp.status = *p; p_result->rsp.status = *p;
return p_result->rsp.status; return p_result->rsp.status;
} }
switch (p_result->pdu) switch (p_result->pdu) {
{
/* case AVRC_PDU_REQUEST_CONTINUATION_RSP: 0x40 */ /* case AVRC_PDU_REQUEST_CONTINUATION_RSP: 0x40 */
/* case AVRC_PDU_ABORT_CONTINUATION_RSP: 0x41 */ /* case AVRC_PDU_ABORT_CONTINUATION_RSP: 0x41 */
#if (AVRC_ADV_CTRL_INCLUDED == TRUE) #if (AVRC_ADV_CTRL_INCLUDED == TRUE)
case AVRC_PDU_SET_ABSOLUTE_VOLUME: /* 0x50 */ case AVRC_PDU_SET_ABSOLUTE_VOLUME: /* 0x50 */
if (len != 1) if (len != 1) {
status = AVRC_STS_INTERNAL_ERR; status = AVRC_STS_INTERNAL_ERR;
else } else {
{
BE_STREAM_TO_UINT8 (p_result->volume.volume, p); BE_STREAM_TO_UINT8 (p_result->volume.volume, p);
} }
break; break;
@ -87,8 +86,7 @@ static tAVRC_STS avrc_pars_vendor_rsp(tAVRC_MSG_VENDOR *p_msg, tAVRC_RESPONSE *p
BE_STREAM_TO_UINT8 (eventid, p); BE_STREAM_TO_UINT8 (eventid, p);
if (AVRC_EVT_VOLUME_CHANGE == eventid if (AVRC_EVT_VOLUME_CHANGE == eventid
&& (AVRC_RSP_CHANGED == p_msg->hdr.ctype || AVRC_RSP_INTERIM == p_msg->hdr.ctype && (AVRC_RSP_CHANGED == p_msg->hdr.ctype || AVRC_RSP_INTERIM == p_msg->hdr.ctype
|| AVRC_RSP_REJ==p_msg->hdr.ctype || AVRC_RSP_NOT_IMPL==p_msg->hdr.ctype)) || AVRC_RSP_REJ == p_msg->hdr.ctype || AVRC_RSP_NOT_IMPL == p_msg->hdr.ctype)) {
{
p_result->reg_notif.status = p_msg->hdr.ctype; p_result->reg_notif.status = p_msg->hdr.ctype;
p_result->reg_notif.event_id = eventid; p_result->reg_notif.event_id = eventid;
BE_STREAM_TO_UINT8 (p_result->reg_notif.param.volume, p); BE_STREAM_TO_UINT8 (p_result->reg_notif.param.volume, p);
@ -122,18 +120,15 @@ tAVRC_STS AVRC_ParsResponse (tAVRC_MSG *p_msg, tAVRC_RESPONSE *p_result, UINT8 *
UNUSED(p_buf); UNUSED(p_buf);
UNUSED(buf_len); UNUSED(buf_len);
if (p_msg && p_result) if (p_msg && p_result) {
{ switch (p_msg->hdr.opcode) {
switch (p_msg->hdr.opcode)
{
case AVRC_OP_VENDOR: /* 0x00 Vendor-dependent commands */ case AVRC_OP_VENDOR: /* 0x00 Vendor-dependent commands */
status = avrc_pars_vendor_rsp(&p_msg->vendor, p_result); status = avrc_pars_vendor_rsp(&p_msg->vendor, p_result);
break; break;
case AVRC_OP_PASS_THRU: /* 0x7C panel subunit opcode */ case AVRC_OP_PASS_THRU: /* 0x7C panel subunit opcode */
status = avrc_pars_pass_thru(&p_msg->pass, &id); status = avrc_pars_pass_thru(&p_msg->pass, &id);
if (status == AVRC_STS_NO_ERROR) if (status == AVRC_STS_NO_ERROR) {
{
p_result->pdu = (UINT8)id; p_result->pdu = (UINT8)id;
} }
break; break;

150
components/bt/bluedroid/stack/avrc/avrc_pars_tg.c Executable file → Normal file
View file

@ -54,73 +54,74 @@ static tAVRC_STS avrc_pars_vendor_cmd(tAVRC_MSG_VENDOR *p_msg, tAVRC_COMMAND *p_
UINT16 size_needed; UINT16 size_needed;
/* Check the vendor data */ /* Check the vendor data */
if (p_msg->vendor_len == 0) if (p_msg->vendor_len == 0) {
return AVRC_STS_NO_ERROR; return AVRC_STS_NO_ERROR;
if (p_msg->p_vendor_data == NULL) }
if (p_msg->p_vendor_data == NULL) {
return AVRC_STS_INTERNAL_ERR; return AVRC_STS_INTERNAL_ERR;
}
p = p_msg->p_vendor_data; p = p_msg->p_vendor_data;
p_result->pdu = *p++; p_result->pdu = *p++;
AVRC_TRACE_DEBUG("avrc_pars_vendor_cmd() pdu:0x%x", p_result->pdu); AVRC_TRACE_DEBUG("avrc_pars_vendor_cmd() pdu:0x%x", p_result->pdu);
if (!AVRC_IsValidAvcType (p_result->pdu, p_msg->hdr.ctype)) if (!AVRC_IsValidAvcType (p_result->pdu, p_msg->hdr.ctype)) {
{
AVRC_TRACE_DEBUG("avrc_pars_vendor_cmd() detects wrong AV/C type!"); AVRC_TRACE_DEBUG("avrc_pars_vendor_cmd() detects wrong AV/C type!");
status = AVRC_STS_BAD_CMD; status = AVRC_STS_BAD_CMD;
} }
p++; /* skip the reserved byte */ p++; /* skip the reserved byte */
BE_STREAM_TO_UINT16 (len, p); BE_STREAM_TO_UINT16 (len, p);
if ((len+4) != (p_msg->vendor_len)) if ((len + 4) != (p_msg->vendor_len)) {
{
status = AVRC_STS_INTERNAL_ERR; status = AVRC_STS_INTERNAL_ERR;
} }
if (status != AVRC_STS_NO_ERROR) if (status != AVRC_STS_NO_ERROR) {
return status; return status;
}
switch (p_result->pdu) switch (p_result->pdu) {
{
case AVRC_PDU_GET_CAPABILITIES: /* 0x10 */ case AVRC_PDU_GET_CAPABILITIES: /* 0x10 */
p_result->get_caps.capability_id = *p++; p_result->get_caps.capability_id = *p++;
if (!AVRC_IS_VALID_CAP_ID(p_result->get_caps.capability_id)) if (!AVRC_IS_VALID_CAP_ID(p_result->get_caps.capability_id)) {
status = AVRC_STS_BAD_PARAM; status = AVRC_STS_BAD_PARAM;
else if (len != 1) } else if (len != 1) {
status = AVRC_STS_INTERNAL_ERR; status = AVRC_STS_INTERNAL_ERR;
}
break; break;
case AVRC_PDU_LIST_PLAYER_APP_ATTR: /* 0x11 */ case AVRC_PDU_LIST_PLAYER_APP_ATTR: /* 0x11 */
/* no additional parameters */ /* no additional parameters */
if (len != 0) if (len != 0) {
status = AVRC_STS_INTERNAL_ERR; status = AVRC_STS_INTERNAL_ERR;
}
break; break;
case AVRC_PDU_LIST_PLAYER_APP_VALUES: /* 0x12 */ case AVRC_PDU_LIST_PLAYER_APP_VALUES: /* 0x12 */
p_result->list_app_values.attr_id = *p++; p_result->list_app_values.attr_id = *p++;
if (!AVRC_IS_VALID_ATTRIBUTE(p_result->list_app_values.attr_id)) if (!AVRC_IS_VALID_ATTRIBUTE(p_result->list_app_values.attr_id)) {
status = AVRC_STS_BAD_PARAM; status = AVRC_STS_BAD_PARAM;
else if (len != 1) } else if (len != 1) {
status = AVRC_STS_INTERNAL_ERR; status = AVRC_STS_INTERNAL_ERR;
}
break; break;
case AVRC_PDU_GET_CUR_PLAYER_APP_VALUE: /* 0x13 */ case AVRC_PDU_GET_CUR_PLAYER_APP_VALUE: /* 0x13 */
case AVRC_PDU_GET_PLAYER_APP_ATTR_TEXT: /* 0x15 */ case AVRC_PDU_GET_PLAYER_APP_ATTR_TEXT: /* 0x15 */
BE_STREAM_TO_UINT8 (p_result->get_cur_app_val.num_attr, p); BE_STREAM_TO_UINT8 (p_result->get_cur_app_val.num_attr, p);
if (len != (p_result->get_cur_app_val.num_attr+1)) if (len != (p_result->get_cur_app_val.num_attr + 1)) {
{
status = AVRC_STS_INTERNAL_ERR; status = AVRC_STS_INTERNAL_ERR;
break; break;
} }
p_u8 = p_result->get_cur_app_val.attrs; p_u8 = p_result->get_cur_app_val.attrs;
for (xx=0, yy=0; xx< p_result->get_cur_app_val.num_attr; xx++) for (xx = 0, yy = 0; xx < p_result->get_cur_app_val.num_attr; xx++) {
{
/* only report the valid player app attributes */ /* only report the valid player app attributes */
if (AVRC_IsValidPlayerAttr(*p)) if (AVRC_IsValidPlayerAttr(*p)) {
p_u8[yy++] = *p; p_u8[yy++] = *p;
}
p++; p++;
} }
p_result->get_cur_app_val.num_attr = yy; p_result->get_cur_app_val.num_attr = yy;
if (yy == 0) if (yy == 0) {
{
status = AVRC_STS_BAD_PARAM; status = AVRC_STS_BAD_PARAM;
} }
break; break;
@ -128,53 +129,44 @@ static tAVRC_STS avrc_pars_vendor_cmd(tAVRC_MSG_VENDOR *p_msg, tAVRC_COMMAND *p_
case AVRC_PDU_SET_PLAYER_APP_VALUE: /* 0x14 */ case AVRC_PDU_SET_PLAYER_APP_VALUE: /* 0x14 */
BE_STREAM_TO_UINT8 (p_result->set_app_val.num_val, p); BE_STREAM_TO_UINT8 (p_result->set_app_val.num_val, p);
size_needed = sizeof(tAVRC_APP_SETTING); size_needed = sizeof(tAVRC_APP_SETTING);
if (p_buf && (len == ((p_result->set_app_val.num_val<<1) + 1))) if (p_buf && (len == ((p_result->set_app_val.num_val << 1) + 1))) {
{
p_result->set_app_val.p_vals = (tAVRC_APP_SETTING *)p_buf; p_result->set_app_val.p_vals = (tAVRC_APP_SETTING *)p_buf;
p_app_set = p_result->set_app_val.p_vals; p_app_set = p_result->set_app_val.p_vals;
for (xx=0; ((xx< p_result->set_app_val.num_val) && (buf_len > size_needed)); xx++) for (xx = 0; ((xx < p_result->set_app_val.num_val) && (buf_len > size_needed)); xx++) {
{
p_app_set[xx].attr_id = *p++; p_app_set[xx].attr_id = *p++;
p_app_set[xx].attr_val = *p++; p_app_set[xx].attr_val = *p++;
if (!avrc_is_valid_player_attrib_value(p_app_set[xx].attr_id, p_app_set[xx].attr_val)) if (!avrc_is_valid_player_attrib_value(p_app_set[xx].attr_id, p_app_set[xx].attr_val)) {
status = AVRC_STS_BAD_PARAM; status = AVRC_STS_BAD_PARAM;
} }
if (xx != p_result->set_app_val.num_val) }
{ if (xx != p_result->set_app_val.num_val) {
AVRC_TRACE_ERROR("AVRC_PDU_SET_PLAYER_APP_VALUE not enough room:%d orig num_val:%d", AVRC_TRACE_ERROR("AVRC_PDU_SET_PLAYER_APP_VALUE not enough room:%d orig num_val:%d",
xx, p_result->set_app_val.num_val); xx, p_result->set_app_val.num_val);
p_result->set_app_val.num_val = xx; p_result->set_app_val.num_val = xx;
} }
} } else {
else
{
AVRC_TRACE_ERROR("AVRC_PDU_SET_PLAYER_APP_VALUE NULL decode buffer or bad len"); AVRC_TRACE_ERROR("AVRC_PDU_SET_PLAYER_APP_VALUE NULL decode buffer or bad len");
status = AVRC_STS_INTERNAL_ERR; status = AVRC_STS_INTERNAL_ERR;
} }
break; break;
case AVRC_PDU_GET_PLAYER_APP_VALUE_TEXT:/* 0x16 */ case AVRC_PDU_GET_PLAYER_APP_VALUE_TEXT:/* 0x16 */
if (len < 3) if (len < 3) {
status = AVRC_STS_INTERNAL_ERR; status = AVRC_STS_INTERNAL_ERR;
else } else {
{
BE_STREAM_TO_UINT8 (p_result->get_app_val_txt.attr_id, p); BE_STREAM_TO_UINT8 (p_result->get_app_val_txt.attr_id, p);
if (!AVRC_IS_VALID_ATTRIBUTE(p_result->get_app_val_txt.attr_id)) if (!AVRC_IS_VALID_ATTRIBUTE(p_result->get_app_val_txt.attr_id)) {
status = AVRC_STS_BAD_PARAM; status = AVRC_STS_BAD_PARAM;
else } else {
{
BE_STREAM_TO_UINT8 (p_result->get_app_val_txt.num_val, p); BE_STREAM_TO_UINT8 (p_result->get_app_val_txt.num_val, p);
if ( (len - 2/* attr_id & num_val */) != p_result->get_app_val_txt.num_val) if ( (len - 2/* attr_id & num_val */) != p_result->get_app_val_txt.num_val) {
status = AVRC_STS_INTERNAL_ERR; status = AVRC_STS_INTERNAL_ERR;
else } else {
{
p_u8 = p_result->get_app_val_txt.vals; p_u8 = p_result->get_app_val_txt.vals;
for (xx=0; xx< p_result->get_app_val_txt.num_val; xx++) for (xx = 0; xx < p_result->get_app_val_txt.num_val; xx++) {
{
p_u8[xx] = *p++; p_u8[xx] = *p++;
if (!avrc_is_valid_player_attrib_value(p_result->get_app_val_txt.attr_id, if (!avrc_is_valid_player_attrib_value(p_result->get_app_val_txt.attr_id,
p_u8[xx])) p_u8[xx])) {
{
status = AVRC_STS_BAD_PARAM; status = AVRC_STS_BAD_PARAM;
break; break;
} }
@ -185,20 +177,18 @@ static tAVRC_STS avrc_pars_vendor_cmd(tAVRC_MSG_VENDOR *p_msg, tAVRC_COMMAND *p_
break; break;
case AVRC_PDU_INFORM_DISPLAY_CHARSET: /* 0x17 */ case AVRC_PDU_INFORM_DISPLAY_CHARSET: /* 0x17 */
if (len < 3) if (len < 3) {
status = AVRC_STS_INTERNAL_ERR; status = AVRC_STS_INTERNAL_ERR;
else } else {
{
BE_STREAM_TO_UINT8 (p_result->inform_charset.num_id, p); BE_STREAM_TO_UINT8 (p_result->inform_charset.num_id, p);
if ( (len - 1/* num_id */) != p_result->inform_charset.num_id * 2) if ( (len - 1/* num_id */) != p_result->inform_charset.num_id * 2) {
status = AVRC_STS_INTERNAL_ERR; status = AVRC_STS_INTERNAL_ERR;
else } else {
{
p_u16 = p_result->inform_charset.charsets; p_u16 = p_result->inform_charset.charsets;
if (p_result->inform_charset.num_id > AVRC_MAX_CHARSET_SIZE) if (p_result->inform_charset.num_id > AVRC_MAX_CHARSET_SIZE) {
p_result->inform_charset.num_id = AVRC_MAX_CHARSET_SIZE; p_result->inform_charset.num_id = AVRC_MAX_CHARSET_SIZE;
for (xx=0; xx< p_result->inform_charset.num_id; xx++) }
{ for (xx = 0; xx < p_result->inform_charset.num_id; xx++) {
BE_STREAM_TO_UINT16 (p_u16[xx], p); BE_STREAM_TO_UINT16 (p_u16[xx], p);
} }
} }
@ -206,64 +196,61 @@ static tAVRC_STS avrc_pars_vendor_cmd(tAVRC_MSG_VENDOR *p_msg, tAVRC_COMMAND *p_
break; break;
case AVRC_PDU_INFORM_BATTERY_STAT_OF_CT:/* 0x18 */ case AVRC_PDU_INFORM_BATTERY_STAT_OF_CT:/* 0x18 */
if (len != 1) if (len != 1) {
status = AVRC_STS_INTERNAL_ERR; status = AVRC_STS_INTERNAL_ERR;
else } else {
{
p_result->inform_battery_status.battery_status = *p++; p_result->inform_battery_status.battery_status = *p++;
if (!AVRC_IS_VALID_BATTERY_STATUS(p_result->inform_battery_status.battery_status)) if (!AVRC_IS_VALID_BATTERY_STATUS(p_result->inform_battery_status.battery_status)) {
status = AVRC_STS_BAD_PARAM; status = AVRC_STS_BAD_PARAM;
} }
}
break; break;
case AVRC_PDU_GET_ELEMENT_ATTR: /* 0x20 */ case AVRC_PDU_GET_ELEMENT_ATTR: /* 0x20 */
if (len < 9) /* UID/8 and num_attr/1 */ if (len < 9) { /* UID/8 and num_attr/1 */
status = AVRC_STS_INTERNAL_ERR; status = AVRC_STS_INTERNAL_ERR;
else } else {
{
BE_STREAM_TO_UINT32 (u32, p); BE_STREAM_TO_UINT32 (u32, p);
BE_STREAM_TO_UINT32 (u32_2, p); BE_STREAM_TO_UINT32 (u32_2, p);
if (u32== 0 && u32_2 == 0) if (u32 == 0 && u32_2 == 0) {
{
BE_STREAM_TO_UINT8 (p_result->get_elem_attrs.num_attr, p); BE_STREAM_TO_UINT8 (p_result->get_elem_attrs.num_attr, p);
if ( (len - 9/* UID/8 and num_attr/1 */) != (p_result->get_elem_attrs.num_attr * 4)) if ( (len - 9/* UID/8 and num_attr/1 */) != (p_result->get_elem_attrs.num_attr * 4)) {
status = AVRC_STS_INTERNAL_ERR; status = AVRC_STS_INTERNAL_ERR;
else } else {
{
p_u32 = p_result->get_elem_attrs.attrs; p_u32 = p_result->get_elem_attrs.attrs;
if (p_result->get_elem_attrs.num_attr > AVRC_MAX_ELEM_ATTR_SIZE) if (p_result->get_elem_attrs.num_attr > AVRC_MAX_ELEM_ATTR_SIZE) {
p_result->get_elem_attrs.num_attr = AVRC_MAX_ELEM_ATTR_SIZE; p_result->get_elem_attrs.num_attr = AVRC_MAX_ELEM_ATTR_SIZE;
for (xx=0; xx< p_result->get_elem_attrs.num_attr; xx++) }
{ for (xx = 0; xx < p_result->get_elem_attrs.num_attr; xx++) {
BE_STREAM_TO_UINT32 (p_u32[xx], p); BE_STREAM_TO_UINT32 (p_u32[xx], p);
} }
} }
} } else {
else
status = AVRC_STS_NOT_FOUND; status = AVRC_STS_NOT_FOUND;
} }
}
break; break;
case AVRC_PDU_GET_PLAY_STATUS: /* 0x30 */ case AVRC_PDU_GET_PLAY_STATUS: /* 0x30 */
/* no additional parameters */ /* no additional parameters */
if (len != 0) if (len != 0) {
status = AVRC_STS_INTERNAL_ERR; status = AVRC_STS_INTERNAL_ERR;
}
break; break;
case AVRC_PDU_REGISTER_NOTIFICATION: /* 0x31 */ case AVRC_PDU_REGISTER_NOTIFICATION: /* 0x31 */
if (len != 5) if (len != 5) {
status = AVRC_STS_INTERNAL_ERR; status = AVRC_STS_INTERNAL_ERR;
else } else {
{
BE_STREAM_TO_UINT8 (p_result->reg_notif.event_id, p); BE_STREAM_TO_UINT8 (p_result->reg_notif.event_id, p);
BE_STREAM_TO_UINT32 (p_result->reg_notif.param, p); BE_STREAM_TO_UINT32 (p_result->reg_notif.param, p);
} }
break; break;
case AVRC_PDU_SET_ABSOLUTE_VOLUME: case AVRC_PDU_SET_ABSOLUTE_VOLUME: {
{ if (len != 1) {
if(len!=1)
status = AVRC_STS_INTERNAL_ERR; status = AVRC_STS_INTERNAL_ERR;
}
break; break;
} }
@ -293,18 +280,15 @@ tAVRC_STS AVRC_ParsCommand (tAVRC_MSG *p_msg, tAVRC_COMMAND *p_result, UINT8 *p_
tAVRC_STS status = AVRC_STS_INTERNAL_ERR; tAVRC_STS status = AVRC_STS_INTERNAL_ERR;
UINT16 id; UINT16 id;
if (p_msg && p_result) if (p_msg && p_result) {
{ switch (p_msg->hdr.opcode) {
switch (p_msg->hdr.opcode)
{
case AVRC_OP_VENDOR: /* 0x00 Vendor-dependent commands */ case AVRC_OP_VENDOR: /* 0x00 Vendor-dependent commands */
status = avrc_pars_vendor_cmd(&p_msg->vendor, p_result, p_buf, buf_len); status = avrc_pars_vendor_cmd(&p_msg->vendor, p_result, p_buf, buf_len);
break; break;
case AVRC_OP_PASS_THRU: /* 0x7C panel subunit opcode */ case AVRC_OP_PASS_THRU: /* 0x7C panel subunit opcode */
status = avrc_pars_pass_thru(&p_msg->pass, &id); status = avrc_pars_pass_thru(&p_msg->pass, &id);
if (status == AVRC_STS_NO_ERROR) if (status == AVRC_STS_NO_ERROR) {
{
p_result->pdu = (UINT8)id; p_result->pdu = (UINT8)id;
} }
break; break;

44
components/bt/bluedroid/stack/avrc/avrc_sdp.c Executable file → Normal file
View file

@ -45,8 +45,7 @@ tAVRC_CB avrc_cb;
#endif #endif
/* update AVRC_NUM_PROTO_ELEMS if this constant is changed */ /* update AVRC_NUM_PROTO_ELEMS if this constant is changed */
const tSDP_PROTOCOL_ELEM avrc_proto_list [] = const tSDP_PROTOCOL_ELEM avrc_proto_list [] = {
{
{UUID_PROTOCOL_L2CAP, 1, {AVCT_PSM, 0} }, {UUID_PROTOCOL_L2CAP, 1, {AVCT_PSM, 0} },
#if SDP_AVCTP_1_4 == TRUE #if SDP_AVCTP_1_4 == TRUE
{UUID_PROTOCOL_AVCTP, 1, {AVCT_REV_1_4, 0} } {UUID_PROTOCOL_AVCTP, 1, {AVCT_REV_1_4, 0} }
@ -64,12 +63,14 @@ const tSDP_PROTOCOL_ELEM avrc_proto_list [] =
}; };
#if SDP_AVRCP_1_4 == TRUE #if SDP_AVRCP_1_4 == TRUE
const tSDP_PROTO_LIST_ELEM avrc_add_proto_list [] = const tSDP_PROTO_LIST_ELEM avrc_add_proto_list [] = {
{ {
{AVRC_NUM_PROTO_ELEMS, AVRC_NUM_PROTO_ELEMS,
{ {
{UUID_PROTOCOL_L2CAP, 1, {AVCT_BR_PSM, 0} }, {UUID_PROTOCOL_L2CAP, 1, {AVCT_BR_PSM, 0} },
{UUID_PROTOCOL_AVCTP, 1, {AVCT_REV_1_3, 0} }}} {UUID_PROTOCOL_AVCTP, 1, {AVCT_REV_1_3, 0} }
}
}
}; };
#endif #endif
@ -149,24 +150,26 @@ UINT16 AVRC_FindService(UINT16 service_uuid, BD_ADDR bd_addr,
ATTR_ID_BT_PROFILE_DESC_LIST, ATTR_ID_BT_PROFILE_DESC_LIST,
ATTR_ID_SERVICE_NAME, ATTR_ID_SERVICE_NAME,
ATTR_ID_SUPPORTED_FEATURES, ATTR_ID_SUPPORTED_FEATURES,
ATTR_ID_PROVIDER_NAME}; ATTR_ID_PROVIDER_NAME
};
AVRC_TRACE_API("AVRC_FindService uuid: %x", service_uuid); AVRC_TRACE_API("AVRC_FindService uuid: %x", service_uuid);
if ( (service_uuid != UUID_SERVCLASS_AV_REM_CTRL_TARGET && service_uuid != UUID_SERVCLASS_AV_REMOTE_CONTROL) || 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 || p_cback == NULL) {
return AVRC_BAD_PARAM; return AVRC_BAD_PARAM;
}
/* check if it is busy */ /* check if it is busy */
if ( avrc_cb.service_uuid == UUID_SERVCLASS_AV_REM_CTRL_TARGET || if ( avrc_cb.service_uuid == UUID_SERVCLASS_AV_REM_CTRL_TARGET ||
avrc_cb.service_uuid == UUID_SERVCLASS_AV_REMOTE_CONTROL) avrc_cb.service_uuid == UUID_SERVCLASS_AV_REMOTE_CONTROL) {
return AVRC_NO_RESOURCES; return AVRC_NO_RESOURCES;
}
/* set up discovery database */ /* set up discovery database */
uuid_list.len = LEN_UUID_16; uuid_list.len = LEN_UUID_16;
uuid_list.uu.uuid16 = service_uuid; uuid_list.uu.uuid16 = service_uuid;
if(p_db->p_attrs == NULL || p_db->num_attr == 0) if (p_db->p_attrs == NULL || p_db->num_attr == 0) {
{
p_db->p_attrs = a2d_attr_list; p_db->p_attrs = a2d_attr_list;
p_db->num_attr = AVRC_NUM_ATTR; p_db->num_attr = AVRC_NUM_ATTR;
} }
@ -174,8 +177,7 @@ UINT16 AVRC_FindService(UINT16 service_uuid, BD_ADDR bd_addr,
result = SDP_InitDiscoveryDb(p_db->p_db, p_db->db_len, 1, &uuid_list, p_db->num_attr, result = SDP_InitDiscoveryDb(p_db->p_db, p_db->db_len, 1, &uuid_list, p_db->num_attr,
p_db->p_attrs); p_db->p_attrs);
if (result == TRUE) if (result == TRUE) {
{
/* store service_uuid and discovery db pointer */ /* store service_uuid and discovery db pointer */
avrc_cb.p_db = p_db->p_db; avrc_cb.p_db = p_db->p_db;
avrc_cb.service_uuid = service_uuid; avrc_cb.service_uuid = service_uuid;
@ -232,21 +234,20 @@ UINT16 AVRC_AddRecord(UINT16 service_uuid, char *p_service_name,
AVRC_TRACE_API("AVRC_AddRecord uuid: %x", service_uuid); AVRC_TRACE_API("AVRC_AddRecord uuid: %x", service_uuid);
if( service_uuid != UUID_SERVCLASS_AV_REM_CTRL_TARGET && service_uuid != UUID_SERVCLASS_AV_REMOTE_CONTROL ) if ( service_uuid != UUID_SERVCLASS_AV_REM_CTRL_TARGET && service_uuid != UUID_SERVCLASS_AV_REMOTE_CONTROL ) {
return AVRC_BAD_PARAM; return AVRC_BAD_PARAM;
}
/* add service class id list */ /* add service class id list */
class_list[0] = service_uuid; class_list[0] = service_uuid;
#if SDP_AVCTP_1_4 == TRUE #if SDP_AVCTP_1_4 == TRUE
if( service_uuid == UUID_SERVCLASS_AV_REMOTE_CONTROL ) if ( service_uuid == UUID_SERVCLASS_AV_REMOTE_CONTROL ) {
{
class_list[1] = UUID_SERVCLASS_AV_REM_CTRL_CONTROL; class_list[1] = UUID_SERVCLASS_AV_REM_CTRL_CONTROL;
count = 2; count = 2;
} }
#else #else
#if SDP_AVRCP_1_4 == TRUE #if SDP_AVRCP_1_4 == TRUE
if( service_uuid == UUID_SERVCLASS_AV_REMOTE_CONTROL ) if ( service_uuid == UUID_SERVCLASS_AV_REMOTE_CONTROL ) {
{
class_list[1] = UUID_SERVCLASS_AV_REM_CTRL_CONTROL; class_list[1] = UUID_SERVCLASS_AV_REM_CTRL_CONTROL;
count = 2; count = 2;
} }
@ -278,15 +279,13 @@ UINT16 AVRC_AddRecord(UINT16 service_uuid, char *p_service_name,
(UINT32)2, (UINT8 *)temp); (UINT32)2, (UINT8 *)temp);
/* add provider name */ /* add provider name */
if (p_provider_name != NULL) if (p_provider_name != NULL) {
{
result &= SDP_AddAttribute(sdp_handle, ATTR_ID_PROVIDER_NAME, TEXT_STR_DESC_TYPE, result &= SDP_AddAttribute(sdp_handle, ATTR_ID_PROVIDER_NAME, TEXT_STR_DESC_TYPE,
(UINT32)(strlen(p_provider_name) + 1), (UINT8 *) p_provider_name); (UINT32)(strlen(p_provider_name) + 1), (UINT8 *) p_provider_name);
} }
/* add service name */ /* add service name */
if (p_service_name != NULL) if (p_service_name != NULL) {
{
result &= SDP_AddAttribute(sdp_handle, ATTR_ID_SERVICE_NAME, TEXT_STR_DESC_TYPE, result &= SDP_AddAttribute(sdp_handle, ATTR_ID_SERVICE_NAME, TEXT_STR_DESC_TYPE,
(UINT32)(strlen(p_service_name) + 1), (UINT8 *) p_service_name); (UINT32)(strlen(p_service_name) + 1), (UINT8 *) p_service_name);
} }
@ -324,8 +323,9 @@ UINT16 AVRC_AddRecord(UINT16 service_uuid, char *p_service_name,
******************************************************************************/ ******************************************************************************/
UINT8 AVRC_SetTraceLevel (UINT8 new_level) UINT8 AVRC_SetTraceLevel (UINT8 new_level)
{ {
if (new_level != 0xFF) if (new_level != 0xFF) {
avrc_cb.trace_level = new_level; avrc_cb.trace_level = new_level;
}
return (avrc_cb.trace_level); return (avrc_cb.trace_level);
} }

55
components/bt/bluedroid/stack/avrc/avrc_utils.c Executable file → Normal file
View file

@ -39,10 +39,8 @@ BOOLEAN AVRC_IsValidAvcType(UINT8 pdu_id, UINT8 avc_type)
{ {
BOOLEAN result = FALSE; BOOLEAN result = FALSE;
if (avc_type < AVRC_RSP_NOT_IMPL) /* command msg */ if (avc_type < AVRC_RSP_NOT_IMPL) { /* command msg */
{ switch (pdu_id) {
switch (pdu_id)
{
case AVRC_PDU_GET_CAPABILITIES: /* 0x10 */ case AVRC_PDU_GET_CAPABILITIES: /* 0x10 */
case AVRC_PDU_LIST_PLAYER_APP_ATTR: /* 0x11 */ case AVRC_PDU_LIST_PLAYER_APP_ATTR: /* 0x11 */
case AVRC_PDU_LIST_PLAYER_APP_VALUES: /* 0x12 */ case AVRC_PDU_LIST_PLAYER_APP_VALUES: /* 0x12 */
@ -51,8 +49,9 @@ BOOLEAN AVRC_IsValidAvcType(UINT8 pdu_id, UINT8 avc_type)
case AVRC_PDU_GET_PLAYER_APP_VALUE_TEXT: /* 0x16 */ case AVRC_PDU_GET_PLAYER_APP_VALUE_TEXT: /* 0x16 */
case AVRC_PDU_GET_ELEMENT_ATTR: /* 0x20 */ case AVRC_PDU_GET_ELEMENT_ATTR: /* 0x20 */
case AVRC_PDU_GET_PLAY_STATUS: /* 0x30 */ case AVRC_PDU_GET_PLAY_STATUS: /* 0x30 */
if (avc_type == AVRC_CMD_STATUS) if (avc_type == AVRC_CMD_STATUS) {
result = TRUE; result = TRUE;
}
break; break;
case AVRC_PDU_SET_PLAYER_APP_VALUE: /* 0x14 */ case AVRC_PDU_SET_PLAYER_APP_VALUE: /* 0x14 */
@ -60,22 +59,23 @@ BOOLEAN AVRC_IsValidAvcType(UINT8 pdu_id, UINT8 avc_type)
case AVRC_PDU_INFORM_BATTERY_STAT_OF_CT: /* 0x18 */ case AVRC_PDU_INFORM_BATTERY_STAT_OF_CT: /* 0x18 */
case AVRC_PDU_REQUEST_CONTINUATION_RSP: /* 0x40 */ case AVRC_PDU_REQUEST_CONTINUATION_RSP: /* 0x40 */
case AVRC_PDU_ABORT_CONTINUATION_RSP: /* 0x41 */ case AVRC_PDU_ABORT_CONTINUATION_RSP: /* 0x41 */
if (avc_type == AVRC_CMD_CTRL) if (avc_type == AVRC_CMD_CTRL) {
result = TRUE; result = TRUE;
}
break; break;
case AVRC_PDU_REGISTER_NOTIFICATION: /* 0x31 */ case AVRC_PDU_REGISTER_NOTIFICATION: /* 0x31 */
if (avc_type == AVRC_CMD_NOTIF) if (avc_type == AVRC_CMD_NOTIF) {
result = TRUE; result = TRUE;
}
break; break;
} }
} } else { /* response msg */
else /* response msg */
{
if (avc_type >= AVRC_RSP_NOT_IMPL && if (avc_type >= AVRC_RSP_NOT_IMPL &&
avc_type <= AVRC_RSP_INTERIM ) avc_type <= AVRC_RSP_INTERIM ) {
result = TRUE; result = TRUE;
} }
}
return result; return result;
} }
@ -93,30 +93,33 @@ BOOLEAN avrc_is_valid_player_attrib_value(UINT8 attrib, UINT8 value)
{ {
BOOLEAN result = FALSE; BOOLEAN result = FALSE;
switch(attrib) switch (attrib) {
{
case AVRC_PLAYER_SETTING_EQUALIZER: case AVRC_PLAYER_SETTING_EQUALIZER:
if ((value > 0) && if ((value > 0) &&
(value <= AVRC_PLAYER_VAL_ON)) (value <= AVRC_PLAYER_VAL_ON)) {
result = TRUE; result = TRUE;
}
break; break;
case AVRC_PLAYER_SETTING_REPEAT: case AVRC_PLAYER_SETTING_REPEAT:
if ((value > 0) && if ((value > 0) &&
(value <= AVRC_PLAYER_VAL_GROUP_REPEAT)) (value <= AVRC_PLAYER_VAL_GROUP_REPEAT)) {
result = TRUE; result = TRUE;
}
break; break;
case AVRC_PLAYER_SETTING_SHUFFLE: case AVRC_PLAYER_SETTING_SHUFFLE:
case AVRC_PLAYER_SETTING_SCAN: case AVRC_PLAYER_SETTING_SCAN:
if ((value > 0) && if ((value > 0) &&
(value <= AVRC_PLAYER_VAL_GROUP_SHUFFLE)) (value <= AVRC_PLAYER_VAL_GROUP_SHUFFLE)) {
result = TRUE; result = TRUE;
}
break; break;
} }
if (attrib >= AVRC_PLAYER_SETTING_LOW_MENU_EXT) if (attrib >= AVRC_PLAYER_SETTING_LOW_MENU_EXT) {
result = TRUE; result = TRUE;
}
if (!result) if (!result)
AVRC_TRACE_ERROR( AVRC_TRACE_ERROR(
@ -140,8 +143,7 @@ BOOLEAN AVRC_IsValidPlayerAttr(UINT8 attr)
BOOLEAN result = FALSE; BOOLEAN result = FALSE;
if ( (attr >= AVRC_PLAYER_SETTING_EQUALIZER && attr <= AVRC_PLAYER_SETTING_SCAN) || if ( (attr >= AVRC_PLAYER_SETTING_EQUALIZER && attr <= AVRC_PLAYER_SETTING_SCAN) ||
(attr >= AVRC_PLAYER_SETTING_LOW_MENU_EXT) ) (attr >= AVRC_PLAYER_SETTING_LOW_MENU_EXT) ) {
{
result = TRUE; result = TRUE;
} }
@ -168,15 +170,12 @@ tAVRC_STS avrc_pars_pass_thru(tAVRC_MSG_PASS *p_msg, UINT16 *p_vendor_unique_id)
UINT16 id; UINT16 id;
tAVRC_STS status = AVRC_STS_BAD_CMD; tAVRC_STS status = AVRC_STS_BAD_CMD;
if (p_msg->op_id == AVRC_ID_VENDOR && p_msg->pass_len == AVRC_PASS_THRU_GROUP_LEN) if (p_msg->op_id == AVRC_ID_VENDOR && p_msg->pass_len == AVRC_PASS_THRU_GROUP_LEN) {
{
p_data = p_msg->p_pass_data; p_data = p_msg->p_pass_data;
AVRC_BE_STREAM_TO_CO_ID (co_id, p_data); AVRC_BE_STREAM_TO_CO_ID (co_id, p_data);
if (co_id == AVRC_CO_METADATA) if (co_id == AVRC_CO_METADATA) {
{
BE_STREAM_TO_UINT16 (id, p_data); BE_STREAM_TO_UINT16 (id, p_data);
if (AVRC_IS_VALID_GROUP(id)) if (AVRC_IS_VALID_GROUP(id)) {
{
*p_vendor_unique_id = id; *p_vendor_unique_id = id;
status = AVRC_STS_NO_ERROR; status = AVRC_STS_NO_ERROR;
} }
@ -198,8 +197,7 @@ UINT8 avrc_opcode_from_pdu(UINT8 pdu)
{ {
UINT8 opcode = 0; UINT8 opcode = 0;
switch (pdu) switch (pdu) {
{
case AVRC_PDU_NEXT_GROUP: case AVRC_PDU_NEXT_GROUP:
case AVRC_PDU_PREV_GROUP: /* pass thru */ case AVRC_PDU_PREV_GROUP: /* pass thru */
opcode = AVRC_OP_PASS_THRU; opcode = AVRC_OP_PASS_THRU;
@ -225,8 +223,7 @@ UINT8 avrc_opcode_from_pdu(UINT8 pdu)
BOOLEAN avrc_is_valid_opcode(UINT8 opcode) BOOLEAN avrc_is_valid_opcode(UINT8 opcode)
{ {
BOOLEAN is_valid = FALSE; BOOLEAN is_valid = FALSE;
switch (opcode) switch (opcode) {
{
case AVRC_OP_BROWSE: case AVRC_OP_BROWSE:
case AVRC_OP_PASS_THRU: case AVRC_OP_PASS_THRU:
case AVRC_OP_VENDOR: case AVRC_OP_VENDOR:

9
components/bt/bluedroid/stack/avrc/include/avrc_int.h Executable file → Normal file
View file

@ -98,24 +98,21 @@
#if (AVRC_METADATA_INCLUDED == TRUE) #if (AVRC_METADATA_INCLUDED == TRUE)
/* type for Metadata fragmentation control block */ /* type for Metadata fragmentation control block */
typedef struct typedef struct {
{
BT_HDR *p_fmsg; /* the fragmented message */ BT_HDR *p_fmsg; /* the fragmented message */
UINT8 frag_pdu; /* the PDU ID for fragmentation */ UINT8 frag_pdu; /* the PDU ID for fragmentation */
BOOLEAN frag_enabled; /* fragmentation flag */ BOOLEAN frag_enabled; /* fragmentation flag */
} tAVRC_FRAG_CB; } tAVRC_FRAG_CB;
/* type for Metadata re-assembly control block */ /* type for Metadata re-assembly control block */
typedef struct typedef struct {
{
BT_HDR *p_rmsg; /* the received message */ BT_HDR *p_rmsg; /* the received message */
UINT16 rasm_offset; /* re-assembly flag, the offset of the start fragment */ UINT16 rasm_offset; /* re-assembly flag, the offset of the start fragment */
UINT8 rasm_pdu; /* the PDU ID for re-assembly */ UINT8 rasm_pdu; /* the PDU ID for re-assembly */
} tAVRC_RASM_CB; } tAVRC_RASM_CB;
#endif #endif
typedef struct typedef struct {
{
tAVRC_CONN_CB ccb[AVCT_NUM_CONN]; tAVRC_CONN_CB ccb[AVCT_NUM_CONN];
#if (AVRC_METADATA_INCLUDED == TRUE) #if (AVRC_METADATA_INCLUDED == TRUE)
tAVRC_FRAG_CB fcb[AVCT_NUM_CONN]; tAVRC_FRAG_CB fcb[AVCT_NUM_CONN];

6
components/bt/bluedroid/stack/include/a2d_api.h Executable file → Normal file
View file

@ -98,8 +98,7 @@ typedef UINT8 tA2D_STATUS;
/* This data type is used in A2D_FindService() to initialize the SDP database /* This data type is used in A2D_FindService() to initialize the SDP database
* to hold the result service search. */ * to hold the result service search. */
typedef struct typedef struct {
{
UINT32 db_len; /* Length, in bytes, of the discovery database */ UINT32 db_len; /* Length, in bytes, of the discovery database */
UINT16 num_attr;/* The number of attributes in p_attrs */ UINT16 num_attr;/* The number of attributes in p_attrs */
tSDP_DISCOVERY_DB *p_db; /* Pointer to the discovery database */ tSDP_DISCOVERY_DB *p_db; /* Pointer to the discovery database */
@ -110,8 +109,7 @@ typedef struct
} tA2D_SDP_DB_PARAMS; } tA2D_SDP_DB_PARAMS;
/* This data type is used in tA2D_FIND_CBACK to report the result of the SDP discovery process. */ /* This data type is used in tA2D_FIND_CBACK to report the result of the SDP discovery process. */
typedef struct typedef struct {
{
UINT16 service_len; /* Length, in bytes, of the service name */ UINT16 service_len; /* Length, in bytes, of the service name */
UINT16 provider_len; /* Length, in bytes, of the provider name */ UINT16 provider_len; /* Length, in bytes, of the provider name */
char *p_service_name; /* Pointer the service name. This character string may not be null terminated. char *p_service_name; /* Pointer the service name. This character string may not be null terminated.

3
components/bt/bluedroid/stack/include/a2d_sbc.h Executable file → Normal file
View file

@ -74,8 +74,7 @@
*****************************************************************************/ *****************************************************************************/
/* data type for the SBC Codec Information Element*/ /* data type for the SBC Codec Information Element*/
typedef struct typedef struct {
{
UINT8 samp_freq; /* Sampling frequency */ UINT8 samp_freq; /* Sampling frequency */
UINT8 ch_mode; /* Channel mode */ UINT8 ch_mode; /* Channel mode */
UINT8 block_len; /* Block length */ UINT8 block_len; /* Block length */

9
components/bt/bluedroid/stack/include/avdt_api.h Executable file → Normal file
View file

@ -210,8 +210,7 @@ typedef UINT8 AVDT_REPORT_TYPE;
** Type Definitions ** Type Definitions
*****************************************************************************/ *****************************************************************************/
typedef struct typedef struct {
{
UINT32 ntp_sec; /* NTP time: seconds relative to 0h UTC on 1 January 1900 */ UINT32 ntp_sec; /* NTP time: seconds relative to 0h UTC on 1 January 1900 */
UINT32 ntp_frac; /* NTP time: the fractional part */ UINT32 ntp_frac; /* NTP time: the fractional part */
UINT32 rtp_time; /* timestamp in RTP header */ UINT32 rtp_time; /* timestamp in RTP header */
@ -220,8 +219,7 @@ typedef struct
UINT32 octet_count; /* sender's octet count: same comment */ UINT32 octet_count; /* sender's octet count: same comment */
} tAVDT_SENDER_INFO; } tAVDT_SENDER_INFO;
typedef struct typedef struct {
{
UINT8 frag_lost; /* fraction lost since last RR */ UINT8 frag_lost; /* fraction lost since last RR */
UINT32 packet_lost; /* cumulative number of packets lost since the beginning */ UINT32 packet_lost; /* cumulative number of packets lost since the beginning */
UINT32 seq_num_rcvd; /* extended highest sequence number received */ UINT32 seq_num_rcvd; /* extended highest sequence number received */
@ -230,8 +228,7 @@ typedef struct
UINT32 dlsr; /* delay since last SR */ UINT32 dlsr; /* delay since last SR */
} tAVDT_REPORT_BLK; } tAVDT_REPORT_BLK;
typedef union typedef union {
{
tAVDT_SENDER_INFO sr; tAVDT_SENDER_INFO sr;
tAVDT_REPORT_BLK rr; tAVDT_REPORT_BLK rr;
UINT8 cname[AVDT_MAX_CNAME_SIZE + 1]; UINT8 cname[AVDT_MAX_CNAME_SIZE + 1];

6
components/bt/bluedroid/stack/include/avrc_api.h Executable file → Normal file
View file

@ -121,8 +121,7 @@
/* This data type is used in AVRC_FindService() to initialize the SDP database /* This data type is used in AVRC_FindService() to initialize the SDP database
* to hold the result service search. */ * to hold the result service search. */
typedef struct typedef struct {
{
UINT32 db_len; /* Length, in bytes, of the discovery database */ UINT32 db_len; /* Length, in bytes, of the discovery database */
tSDP_DISCOVERY_DB *p_db; /* Pointer to the discovery database */ tSDP_DISCOVERY_DB *p_db; /* Pointer to the discovery database */
UINT16 num_attr;/* The number of attributes in p_attrs */ UINT16 num_attr;/* The number of attributes in p_attrs */
@ -153,8 +152,7 @@ typedef void (tAVRC_CTRL_CBACK) (UINT8 handle, UINT8 event, UINT16 result,
typedef void (tAVRC_MSG_CBACK) (UINT8 handle, UINT8 label, UINT8 opcode, typedef void (tAVRC_MSG_CBACK) (UINT8 handle, UINT8 label, UINT8 opcode,
tAVRC_MSG *p_msg); tAVRC_MSG *p_msg);
typedef struct typedef struct {
{
tAVRC_CTRL_CBACK *p_ctrl_cback; /* pointer to application control callback */ tAVRC_CTRL_CBACK *p_ctrl_cback; /* pointer to application control callback */
tAVRC_MSG_CBACK *p_msg_cback; /* pointer to application message callback */ tAVRC_MSG_CBACK *p_msg_cback; /* pointer to application message callback */
UINT32 company_id; /* the company ID */ UINT32 company_id; /* the company ID */

171
components/bt/bluedroid/stack/include/avrc_defs.h Executable file → Normal file
View file

@ -754,8 +754,7 @@ typedef UINT8 tAVRC_UID[AVRC_UID_SIZE];
/* /*
This structure contains the header parameters of an AV/C message. This structure contains the header parameters of an AV/C message.
*/ */
typedef struct typedef struct {
{
UINT8 ctype; /* Command type. */ UINT8 ctype; /* Command type. */
UINT8 subunit_type; /* Subunit type. */ UINT8 subunit_type; /* Subunit type. */
UINT8 subunit_id; /* Subunit ID. This value is typically ignored in AVRCP, UINT8 subunit_id; /* Subunit ID. This value is typically ignored in AVRCP,
@ -765,8 +764,7 @@ typedef struct
} tAVRC_HDR; } tAVRC_HDR;
/* This structure contains a UNIT INFO message. */ /* This structure contains a UNIT INFO message. */
typedef struct typedef struct {
{
tAVRC_HDR hdr; /* Message header. */ tAVRC_HDR hdr; /* Message header. */
UINT32 company_id; /* Company identifier. */ UINT32 company_id; /* Company identifier. */
UINT8 unit_type; /* Unit type. Uses the same values as subunit type. */ UINT8 unit_type; /* Unit type. Uses the same values as subunit type. */
@ -774,8 +772,7 @@ typedef struct
} tAVRC_MSG_UNIT; } tAVRC_MSG_UNIT;
/* This structure contains a SUBUNIT INFO message. */ /* This structure contains a SUBUNIT INFO message. */
typedef struct typedef struct {
{
tAVRC_HDR hdr; /* Message header. */ tAVRC_HDR hdr; /* Message header. */
UINT8 subunit_type[AVRC_SUB_TYPE_LEN]; UINT8 subunit_type[AVRC_SUB_TYPE_LEN];
/* Array containing subunit type values. */ /* Array containing subunit type values. */
@ -787,8 +784,7 @@ typedef struct
} tAVRC_MSG_SUB; } tAVRC_MSG_SUB;
/* This structure contains a VENDOR DEPENDENT message. */ /* This structure contains a VENDOR DEPENDENT message. */
typedef struct typedef struct {
{
tAVRC_HDR hdr; /* Message header. */ tAVRC_HDR hdr; /* Message header. */
UINT32 company_id; /* Company identifier. */ UINT32 company_id; /* Company identifier. */
UINT8 *p_vendor_data;/* Pointer to vendor dependent data. */ UINT8 *p_vendor_data;/* Pointer to vendor dependent data. */
@ -796,8 +792,7 @@ typedef struct
} tAVRC_MSG_VENDOR; } tAVRC_MSG_VENDOR;
/* PASS THROUGH message structure */ /* PASS THROUGH message structure */
typedef struct typedef struct {
{
tAVRC_HDR hdr; /* hdr.ctype Unused. tAVRC_HDR hdr; /* hdr.ctype Unused.
* hdr.subunit_type Unused. * hdr.subunit_type Unused.
* hdr.subunit_id Unused. */ * hdr.subunit_id Unused. */
@ -814,8 +809,7 @@ typedef struct
#define AVRC_RSP AVCT_RSP /* Response message */ #define AVRC_RSP AVCT_RSP /* Response message */
/* Browsing channel message structure */ /* Browsing channel message structure */
typedef struct typedef struct {
{
tAVRC_HDR hdr; /* hdr.ctype AVRC_CMD or AVRC_RSP. tAVRC_HDR hdr; /* hdr.ctype AVRC_CMD or AVRC_RSP.
* hdr.subunit_type Unused. * hdr.subunit_type Unused.
* hdr.subunit_id Unused. */ * hdr.subunit_id Unused. */
@ -825,8 +819,7 @@ typedef struct
} tAVRC_MSG_BROWSE; } tAVRC_MSG_BROWSE;
/* This is a union of all message type structures. */ /* This is a union of all message type structures. */
typedef union typedef union {
{
tAVRC_HDR hdr; /* Message header. */ tAVRC_HDR hdr; /* Message header. */
tAVRC_MSG_UNIT unit; /* UNIT INFO message. */ tAVRC_MSG_UNIT unit; /* UNIT INFO message. */
tAVRC_MSG_SUB sub; /* SUBUNIT INFO message. */ tAVRC_MSG_SUB sub; /* SUBUNIT INFO message. */
@ -889,20 +882,17 @@ typedef struct {
#define AVRC_CAP_MAX_NUM_EVT_ID 16 #define AVRC_CAP_MAX_NUM_EVT_ID 16
#endif #endif
typedef union typedef union {
{
UINT32 company_id[AVRC_CAP_MAX_NUM_COMP_ID]; UINT32 company_id[AVRC_CAP_MAX_NUM_COMP_ID];
UINT8 event_id[AVRC_CAP_MAX_NUM_EVT_ID]; UINT8 event_id[AVRC_CAP_MAX_NUM_EVT_ID];
} tAVRC_CAPS_PARAM; } tAVRC_CAPS_PARAM;
typedef struct typedef struct {
{
UINT8 attr_id; UINT8 attr_id;
UINT8 attr_val; UINT8 attr_val;
} tAVRC_APP_SETTING; } tAVRC_APP_SETTING;
typedef struct typedef struct {
{
UINT8 attr_id; UINT8 attr_id;
UINT16 charset_id; UINT16 charset_id;
UINT8 str_len; UINT8 str_len;
@ -911,8 +901,7 @@ typedef struct
typedef UINT8 tAVRC_FEATURE_MASK[AVRC_FEATURE_MASK_SIZE]; typedef UINT8 tAVRC_FEATURE_MASK[AVRC_FEATURE_MASK_SIZE];
typedef struct typedef struct {
{
UINT16 player_id; /* A unique identifier for this media player.*/ UINT16 player_id; /* A unique identifier for this media player.*/
UINT8 major_type; /* Use AVRC_MJ_TYPE_AUDIO, AVRC_MJ_TYPE_VIDEO, AVRC_MJ_TYPE_BC_AUDIO, or AVRC_MJ_TYPE_BC_VIDEO.*/ UINT8 major_type; /* Use AVRC_MJ_TYPE_AUDIO, AVRC_MJ_TYPE_VIDEO, AVRC_MJ_TYPE_BC_AUDIO, or AVRC_MJ_TYPE_BC_VIDEO.*/
UINT32 sub_type; /* Use AVRC_SUB_TYPE_NONE, AVRC_SUB_TYPE_AUDIO_BOOK, or AVRC_SUB_TYPE_PODCAST*/ UINT32 sub_type; /* Use AVRC_SUB_TYPE_NONE, AVRC_SUB_TYPE_AUDIO_BOOK, or AVRC_SUB_TYPE_PODCAST*/
@ -922,8 +911,7 @@ typedef struct
tAVRC_FULL_NAME name; /* The player name, name length and character set id.*/ tAVRC_FULL_NAME name; /* The player name, name length and character set id.*/
} tAVRC_ITEM_PLAYER; } tAVRC_ITEM_PLAYER;
typedef struct typedef struct {
{
tAVRC_UID uid; /* The uid of this folder */ tAVRC_UID uid; /* The uid of this folder */
UINT8 type; /* Use AVRC_FOLDER_TYPE_MIXED, AVRC_FOLDER_TYPE_TITLES, UINT8 type; /* Use AVRC_FOLDER_TYPE_MIXED, AVRC_FOLDER_TYPE_TITLES,
AVRC_FOLDER_TYPE_ALNUMS, AVRC_FOLDER_TYPE_ARTISTS, AVRC_FOLDER_TYPE_GENRES, AVRC_FOLDER_TYPE_ALNUMS, AVRC_FOLDER_TYPE_ARTISTS, AVRC_FOLDER_TYPE_GENRES,
@ -932,16 +920,14 @@ typedef struct
tAVRC_FULL_NAME name; /* The folder name, name length and character set id. */ tAVRC_FULL_NAME name; /* The folder name, name length and character set id. */
} tAVRC_ITEM_FOLDER; } tAVRC_ITEM_FOLDER;
typedef struct typedef struct {
{
UINT32 attr_id; /* Use AVRC_MEDIA_ATTR_ID_TITLE, AVRC_MEDIA_ATTR_ID_ARTIST, AVRC_MEDIA_ATTR_ID_ALBUM, UINT32 attr_id; /* Use AVRC_MEDIA_ATTR_ID_TITLE, AVRC_MEDIA_ATTR_ID_ARTIST, AVRC_MEDIA_ATTR_ID_ALBUM,
AVRC_MEDIA_ATTR_ID_TRACK_NUM, AVRC_MEDIA_ATTR_ID_NUM_TRACKS, AVRC_MEDIA_ATTR_ID_TRACK_NUM, AVRC_MEDIA_ATTR_ID_NUM_TRACKS,
AVRC_MEDIA_ATTR_ID_GENRE, AVRC_MEDIA_ATTR_ID_PLAYING_TIME */ AVRC_MEDIA_ATTR_ID_GENRE, AVRC_MEDIA_ATTR_ID_PLAYING_TIME */
tAVRC_FULL_NAME name; /* The attribute value, value length and character set id. */ tAVRC_FULL_NAME name; /* The attribute value, value length and character set id. */
} tAVRC_ATTR_ENTRY; } tAVRC_ATTR_ENTRY;
typedef struct typedef struct {
{
tAVRC_UID uid; /* The uid of this media element item */ tAVRC_UID uid; /* The uid of this media element item */
UINT8 type; /* Use AVRC_MEDIA_TYPE_AUDIO or AVRC_MEDIA_TYPE_VIDEO. */ UINT8 type; /* Use AVRC_MEDIA_TYPE_AUDIO or AVRC_MEDIA_TYPE_VIDEO. */
tAVRC_FULL_NAME name; /* The media name, name length and character set id. */ tAVRC_FULL_NAME name; /* The media name, name length and character set id. */
@ -949,11 +935,9 @@ typedef struct
tAVRC_ATTR_ENTRY *p_attr_list; /* Attribute entry list. */ tAVRC_ATTR_ENTRY *p_attr_list; /* Attribute entry list. */
} tAVRC_ITEM_MEDIA; } tAVRC_ITEM_MEDIA;
typedef struct typedef struct {
{
UINT8 item_type; /* AVRC_ITEM_PLAYER, AVRC_ITEM_FOLDER, or AVRC_ITEM_MEDIA */ UINT8 item_type; /* AVRC_ITEM_PLAYER, AVRC_ITEM_FOLDER, or AVRC_ITEM_MEDIA */
union union {
{
tAVRC_ITEM_PLAYER player; /* The properties of a media player item.*/ tAVRC_ITEM_PLAYER player; /* The properties of a media player item.*/
tAVRC_ITEM_FOLDER folder; /* The properties of a folder item.*/ tAVRC_ITEM_FOLDER folder; /* The properties of a folder item.*/
tAVRC_ITEM_MEDIA media; /* The properties of a media item.*/ tAVRC_ITEM_MEDIA media; /* The properties of a media item.*/
@ -961,8 +945,7 @@ typedef struct
} tAVRC_ITEM; } tAVRC_ITEM;
/* GetCapability */ /* GetCapability */
typedef struct typedef struct {
{
UINT8 pdu; UINT8 pdu;
tAVRC_STS status; tAVRC_STS status;
UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */ UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */
@ -970,8 +953,7 @@ typedef struct
} tAVRC_GET_CAPS_CMD; } tAVRC_GET_CAPS_CMD;
/* ListPlayerAppValues */ /* ListPlayerAppValues */
typedef struct typedef struct {
{
UINT8 pdu; UINT8 pdu;
tAVRC_STS status; tAVRC_STS status;
UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */ UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */
@ -979,8 +961,7 @@ typedef struct
} tAVRC_LIST_APP_VALUES_CMD; } tAVRC_LIST_APP_VALUES_CMD;
/* GetCurAppValue */ /* GetCurAppValue */
typedef struct typedef struct {
{
UINT8 pdu; UINT8 pdu;
tAVRC_STS status; tAVRC_STS status;
UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */ UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */
@ -989,8 +970,7 @@ typedef struct
} tAVRC_GET_CUR_APP_VALUE_CMD; } tAVRC_GET_CUR_APP_VALUE_CMD;
/* SetAppValue */ /* SetAppValue */
typedef struct typedef struct {
{
UINT8 pdu; UINT8 pdu;
tAVRC_STS status; tAVRC_STS status;
UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */ UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */
@ -999,8 +979,7 @@ typedef struct
} tAVRC_SET_APP_VALUE_CMD; } tAVRC_SET_APP_VALUE_CMD;
/* GetAppAttrTxt */ /* GetAppAttrTxt */
typedef struct typedef struct {
{
UINT8 pdu; UINT8 pdu;
tAVRC_STS status; tAVRC_STS status;
UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */ UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */
@ -1009,8 +988,7 @@ typedef struct
} tAVRC_GET_APP_ATTR_TXT_CMD; } tAVRC_GET_APP_ATTR_TXT_CMD;
/* GetAppValueTxt */ /* GetAppValueTxt */
typedef struct typedef struct {
{
UINT8 pdu; UINT8 pdu;
tAVRC_STS status; tAVRC_STS status;
UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */ UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */
@ -1020,8 +998,7 @@ typedef struct
} tAVRC_GET_APP_VAL_TXT_CMD; } tAVRC_GET_APP_VAL_TXT_CMD;
/* InformCharset */ /* InformCharset */
typedef struct typedef struct {
{
UINT8 pdu; UINT8 pdu;
tAVRC_STS status; tAVRC_STS status;
UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */ UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */
@ -1030,8 +1007,7 @@ typedef struct
} tAVRC_INFORM_CHARSET_CMD; } tAVRC_INFORM_CHARSET_CMD;
/* InformBatteryStatus */ /* InformBatteryStatus */
typedef struct typedef struct {
{
UINT8 pdu; UINT8 pdu;
tAVRC_STS status; tAVRC_STS status;
UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */ UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */
@ -1039,8 +1015,7 @@ typedef struct
} tAVRC_BATTERY_STATUS_CMD; } tAVRC_BATTERY_STATUS_CMD;
/* GetElemAttrs */ /* GetElemAttrs */
typedef struct typedef struct {
{
UINT8 pdu; UINT8 pdu;
tAVRC_STS status; tAVRC_STS status;
UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */ UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */
@ -1049,8 +1024,7 @@ typedef struct
} tAVRC_GET_ELEM_ATTRS_CMD; } tAVRC_GET_ELEM_ATTRS_CMD;
/* RegNotify */ /* RegNotify */
typedef struct typedef struct {
{
UINT8 pdu; UINT8 pdu;
tAVRC_STS status; tAVRC_STS status;
UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */ UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */
@ -1059,8 +1033,7 @@ typedef struct
} tAVRC_REG_NOTIF_CMD; } tAVRC_REG_NOTIF_CMD;
/* SetAddrPlayer */ /* SetAddrPlayer */
typedef struct typedef struct {
{
UINT8 pdu; UINT8 pdu;
tAVRC_STS status; tAVRC_STS status;
UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */ UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */
@ -1068,8 +1041,7 @@ typedef struct
} tAVRC_SET_ADDR_PLAYER_CMD; } tAVRC_SET_ADDR_PLAYER_CMD;
/* SetBrowsedPlayer */ /* SetBrowsedPlayer */
typedef struct typedef struct {
{
UINT8 pdu; UINT8 pdu;
tAVRC_STS status; tAVRC_STS status;
UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */ UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */
@ -1077,8 +1049,7 @@ typedef struct
} tAVRC_SET_BR_PLAYER_CMD; } tAVRC_SET_BR_PLAYER_CMD;
/* SetAbsVolume */ /* SetAbsVolume */
typedef struct typedef struct {
{
UINT8 pdu; UINT8 pdu;
tAVRC_STS status; tAVRC_STS status;
UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */ UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */
@ -1086,8 +1057,7 @@ typedef struct
} tAVRC_SET_VOLUME_CMD; } tAVRC_SET_VOLUME_CMD;
/* GetFolderItems */ /* GetFolderItems */
typedef struct typedef struct {
{
UINT8 pdu; UINT8 pdu;
tAVRC_STS status; tAVRC_STS status;
UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */ UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */
@ -1099,8 +1069,7 @@ typedef struct
} tAVRC_GET_ITEMS_CMD; } tAVRC_GET_ITEMS_CMD;
/* ChangePath */ /* ChangePath */
typedef struct typedef struct {
{
UINT8 pdu; UINT8 pdu;
tAVRC_STS status; tAVRC_STS status;
UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */ UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */
@ -1110,8 +1079,7 @@ typedef struct
} tAVRC_CHG_PATH_CMD; } tAVRC_CHG_PATH_CMD;
/* GetItemAttrs */ /* GetItemAttrs */
typedef struct typedef struct {
{
UINT8 pdu; UINT8 pdu;
tAVRC_STS status; tAVRC_STS status;
UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */ UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */
@ -1123,8 +1091,7 @@ typedef struct
} tAVRC_GET_ATTRS_CMD; } tAVRC_GET_ATTRS_CMD;
/* Search */ /* Search */
typedef struct typedef struct {
{
UINT8 pdu; UINT8 pdu;
tAVRC_STS status; tAVRC_STS status;
UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */ UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */
@ -1132,8 +1099,7 @@ typedef struct
} tAVRC_SEARCH_CMD; } tAVRC_SEARCH_CMD;
/* PlayItem */ /* PlayItem */
typedef struct typedef struct {
{
UINT8 pdu; UINT8 pdu;
tAVRC_STS status; tAVRC_STS status;
UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */ UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */
@ -1143,8 +1109,7 @@ typedef struct
} tAVRC_PLAY_ITEM_CMD; } tAVRC_PLAY_ITEM_CMD;
/* AddToNowPlaying */ /* AddToNowPlaying */
typedef struct typedef struct {
{
UINT8 pdu; UINT8 pdu;
tAVRC_STS status; tAVRC_STS status;
UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */ UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */
@ -1153,24 +1118,21 @@ typedef struct
UINT16 uid_counter; UINT16 uid_counter;
} tAVRC_ADD_TO_PLAY_CMD; } tAVRC_ADD_TO_PLAY_CMD;
typedef struct typedef struct {
{
UINT8 pdu; UINT8 pdu;
tAVRC_STS status; tAVRC_STS status;
UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */ UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */
} tAVRC_CMD; } tAVRC_CMD;
/* Continue and Abort */ /* Continue and Abort */
typedef struct typedef struct {
{
UINT8 pdu; UINT8 pdu;
tAVRC_STS status; tAVRC_STS status;
UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */ UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */
UINT8 target_pdu; UINT8 target_pdu;
} tAVRC_NEXT_CMD; } tAVRC_NEXT_CMD;
typedef union typedef union {
{
UINT8 pdu; UINT8 pdu;
tAVRC_CMD cmd; tAVRC_CMD cmd;
tAVRC_GET_CAPS_CMD get_caps; /* GetCapability */ tAVRC_GET_CAPS_CMD get_caps; /* GetCapability */
@ -1200,8 +1162,7 @@ typedef union
} tAVRC_COMMAND; } tAVRC_COMMAND;
/* GetCapability */ /* GetCapability */
typedef struct typedef struct {
{
UINT8 pdu; UINT8 pdu;
tAVRC_STS status; tAVRC_STS status;
UINT8 opcode; /* Op Code (copied from avrc_cmd.opcode by AVRC_BldResponse user. invalid one to generate according to pdu) */ UINT8 opcode; /* Op Code (copied from avrc_cmd.opcode by AVRC_BldResponse user. invalid one to generate according to pdu) */
@ -1211,8 +1172,7 @@ typedef struct
} tAVRC_GET_CAPS_RSP; } tAVRC_GET_CAPS_RSP;
/* ListPlayerAppAttr */ /* ListPlayerAppAttr */
typedef struct typedef struct {
{
UINT8 pdu; UINT8 pdu;
tAVRC_STS status; tAVRC_STS status;
UINT8 opcode; /* Op Code (copied from avrc_cmd.opcode by AVRC_BldResponse user. invalid one to generate according to pdu) */ UINT8 opcode; /* Op Code (copied from avrc_cmd.opcode by AVRC_BldResponse user. invalid one to generate according to pdu) */
@ -1221,8 +1181,7 @@ typedef struct
} tAVRC_LIST_APP_ATTR_RSP; } tAVRC_LIST_APP_ATTR_RSP;
/* ListPlayerAppValues */ /* ListPlayerAppValues */
typedef struct typedef struct {
{
UINT8 pdu; UINT8 pdu;
tAVRC_STS status; tAVRC_STS status;
UINT8 opcode; /* Op Code (copied from avrc_cmd.opcode by AVRC_BldResponse user. invalid one to generate according to pdu) */ UINT8 opcode; /* Op Code (copied from avrc_cmd.opcode by AVRC_BldResponse user. invalid one to generate according to pdu) */
@ -1231,8 +1190,7 @@ typedef struct
} tAVRC_LIST_APP_VALUES_RSP; } tAVRC_LIST_APP_VALUES_RSP;
/* GetCurAppValue */ /* GetCurAppValue */
typedef struct typedef struct {
{
UINT8 pdu; UINT8 pdu;
tAVRC_STS status; tAVRC_STS status;
UINT8 opcode; /* Op Code (copied from avrc_cmd.opcode by AVRC_BldResponse user. invalid one to generate according to pdu) */ UINT8 opcode; /* Op Code (copied from avrc_cmd.opcode by AVRC_BldResponse user. invalid one to generate according to pdu) */
@ -1241,8 +1199,7 @@ typedef struct
} tAVRC_GET_CUR_APP_VALUE_RSP; } tAVRC_GET_CUR_APP_VALUE_RSP;
/* GetAppAttrTxt */ /* GetAppAttrTxt */
typedef struct typedef struct {
{
UINT8 pdu; UINT8 pdu;
tAVRC_STS status; tAVRC_STS status;
UINT8 opcode; /* Op Code (copied from avrc_cmd.opcode by AVRC_BldResponse user. invalid one to generate according to pdu) */ UINT8 opcode; /* Op Code (copied from avrc_cmd.opcode by AVRC_BldResponse user. invalid one to generate according to pdu) */
@ -1251,8 +1208,7 @@ typedef struct
} tAVRC_GET_APP_ATTR_TXT_RSP; } tAVRC_GET_APP_ATTR_TXT_RSP;
/* GetElemAttrs */ /* GetElemAttrs */
typedef struct typedef struct {
{
UINT8 pdu; UINT8 pdu;
tAVRC_STS status; tAVRC_STS status;
UINT8 opcode; /* Op Code (copied from avrc_cmd.opcode by AVRC_BldResponse user. invalid one to generate according to pdu) */ UINT8 opcode; /* Op Code (copied from avrc_cmd.opcode by AVRC_BldResponse user. invalid one to generate according to pdu) */
@ -1261,8 +1217,7 @@ typedef struct
} tAVRC_GET_ELEM_ATTRS_RSP; } tAVRC_GET_ELEM_ATTRS_RSP;
/* GetPlayStatus */ /* GetPlayStatus */
typedef struct typedef struct {
{
UINT8 pdu; UINT8 pdu;
tAVRC_STS status; tAVRC_STS status;
UINT8 opcode; /* Op Code (copied from avrc_cmd.opcode by AVRC_BldResponse user. invalid one to generate according to pdu) */ UINT8 opcode; /* Op Code (copied from avrc_cmd.opcode by AVRC_BldResponse user. invalid one to generate according to pdu) */
@ -1272,8 +1227,7 @@ typedef struct
} tAVRC_GET_PLAY_STATUS_RSP; } tAVRC_GET_PLAY_STATUS_RSP;
/* notification event parameter for AddressedPlayer change */ /* notification event parameter for AddressedPlayer change */
typedef struct typedef struct {
{
UINT16 player_id; UINT16 player_id;
UINT16 uid_counter; UINT16 uid_counter;
} tAVRC_ADDR_PLAYER_PARAM; } tAVRC_ADDR_PLAYER_PARAM;
@ -1283,15 +1237,13 @@ typedef struct
#endif #endif
/* notification event parameter for Player Application setting change */ /* notification event parameter for Player Application setting change */
typedef struct typedef struct {
{
UINT8 num_attr; UINT8 num_attr;
UINT8 attr_id[AVRC_MAX_APP_SETTINGS]; UINT8 attr_id[AVRC_MAX_APP_SETTINGS];
UINT8 attr_value[AVRC_MAX_APP_SETTINGS]; UINT8 attr_value[AVRC_MAX_APP_SETTINGS];
} tAVRC_PLAYER_APP_PARAM; } tAVRC_PLAYER_APP_PARAM;
typedef union typedef union {
{
tAVRC_PLAYSTATE play_status; tAVRC_PLAYSTATE play_status;
tAVRC_UID track; tAVRC_UID track;
UINT32 play_pos; UINT32 play_pos;
@ -1304,8 +1256,7 @@ typedef union
} tAVRC_NOTIF_RSP_PARAM; } tAVRC_NOTIF_RSP_PARAM;
/* RegNotify */ /* RegNotify */
typedef struct typedef struct {
{
UINT8 pdu; UINT8 pdu;
tAVRC_STS status; tAVRC_STS status;
UINT8 opcode; /* Op Code (copied from avrc_cmd.opcode by AVRC_BldResponse user. invalid one to generate according to pdu) */ UINT8 opcode; /* Op Code (copied from avrc_cmd.opcode by AVRC_BldResponse user. invalid one to generate according to pdu) */
@ -1314,8 +1265,7 @@ typedef struct
} tAVRC_REG_NOTIF_RSP; } tAVRC_REG_NOTIF_RSP;
/* SetAbsVolume */ /* SetAbsVolume */
typedef struct typedef struct {
{
UINT8 pdu; UINT8 pdu;
tAVRC_STS status; tAVRC_STS status;
UINT8 opcode; /* Op Code (copied from avrc_cmd.opcode by AVRC_BldResponse user. invalid one to generate according to pdu) */ UINT8 opcode; /* Op Code (copied from avrc_cmd.opcode by AVRC_BldResponse user. invalid one to generate according to pdu) */
@ -1323,8 +1273,7 @@ typedef struct
} tAVRC_SET_VOLUME_RSP; } tAVRC_SET_VOLUME_RSP;
/* SetBrowsedPlayer */ /* SetBrowsedPlayer */
typedef struct typedef struct {
{
UINT8 pdu; UINT8 pdu;
tAVRC_STS status; tAVRC_STS status;
UINT8 opcode; /* Op Code (copied from avrc_cmd.opcode by AVRC_BldResponse user. invalid one to generate according to pdu) */ UINT8 opcode; /* Op Code (copied from avrc_cmd.opcode by AVRC_BldResponse user. invalid one to generate according to pdu) */
@ -1336,8 +1285,7 @@ typedef struct
} tAVRC_SET_BR_PLAYER_RSP; } tAVRC_SET_BR_PLAYER_RSP;
/* GetFolderItems */ /* GetFolderItems */
typedef struct typedef struct {
{
UINT8 pdu; UINT8 pdu;
tAVRC_STS status; tAVRC_STS status;
UINT8 opcode; /* Op Code (copied from avrc_cmd.opcode by AVRC_BldResponse user. invalid one to generate according to pdu) */ UINT8 opcode; /* Op Code (copied from avrc_cmd.opcode by AVRC_BldResponse user. invalid one to generate according to pdu) */
@ -1347,8 +1295,7 @@ typedef struct
} tAVRC_GET_ITEMS_RSP; } tAVRC_GET_ITEMS_RSP;
/* ChangePath */ /* ChangePath */
typedef struct typedef struct {
{
UINT8 pdu; UINT8 pdu;
tAVRC_STS status; tAVRC_STS status;
UINT8 opcode; /* Op Code (copied from avrc_cmd.opcode by AVRC_BldResponse user. invalid one to generate according to pdu) */ UINT8 opcode; /* Op Code (copied from avrc_cmd.opcode by AVRC_BldResponse user. invalid one to generate according to pdu) */
@ -1356,8 +1303,7 @@ typedef struct
} tAVRC_CHG_PATH_RSP; } tAVRC_CHG_PATH_RSP;
/* GetItemAttrs */ /* GetItemAttrs */
typedef struct typedef struct {
{
UINT8 pdu; UINT8 pdu;
tAVRC_STS status; tAVRC_STS status;
UINT8 opcode; /* Op Code (copied from avrc_cmd.opcode by AVRC_BldResponse user. invalid one to generate according to pdu) */ UINT8 opcode; /* Op Code (copied from avrc_cmd.opcode by AVRC_BldResponse user. invalid one to generate according to pdu) */
@ -1366,8 +1312,7 @@ typedef struct
} tAVRC_GET_ATTRS_RSP; } tAVRC_GET_ATTRS_RSP;
/* Search */ /* Search */
typedef struct typedef struct {
{
UINT8 pdu; UINT8 pdu;
tAVRC_STS status; tAVRC_STS status;
UINT8 opcode; /* Op Code (copied from avrc_cmd.opcode by AVRC_BldResponse user. invalid one to generate according to pdu) */ UINT8 opcode; /* Op Code (copied from avrc_cmd.opcode by AVRC_BldResponse user. invalid one to generate according to pdu) */
@ -1376,15 +1321,13 @@ typedef struct
} tAVRC_SEARCH_RSP; } tAVRC_SEARCH_RSP;
typedef struct typedef struct {
{
UINT8 pdu; UINT8 pdu;
tAVRC_STS status; tAVRC_STS status;
UINT8 opcode; /* Op Code (copied from avrc_cmd.opcode by AVRC_BldResponse user. invalid one to generate according to pdu) */ UINT8 opcode; /* Op Code (copied from avrc_cmd.opcode by AVRC_BldResponse user. invalid one to generate according to pdu) */
} tAVRC_RSP; } tAVRC_RSP;
typedef union typedef union {
{
UINT8 pdu; UINT8 pdu;
tAVRC_RSP rsp; tAVRC_RSP rsp;
tAVRC_GET_CAPS_RSP get_caps; /* GetCapability */ tAVRC_GET_CAPS_RSP get_caps; /* GetCapability */