kopia lustrzana https://github.com/espressif/esp-idf
Merge branch 'bugfix/a2dp_error_code_v4.4' into 'release/v4.4'
bt:Fixed the use of invalid configuration when the peer device configures the stream, and returned an incorrect error code(v4.4) See merge request espressif/esp-idf!21623pull/10984/head
commit
f46b03fd91
|
@ -1897,7 +1897,7 @@ void bta_av_setconfig_rej (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
|
|||
|
||||
bta_av_adjust_seps_idx(p_scb, avdt_handle);
|
||||
APPL_TRACE_DEBUG("bta_av_setconfig_rej: sep_idx: %d", p_scb->sep_idx);
|
||||
AVDT_ConfigRsp(p_scb->avdt_handle, p_scb->avdt_label, AVDT_ERR_UNSUP_CFG, 0);
|
||||
AVDT_ConfigRsp(p_scb->avdt_handle, p_scb->avdt_label, p_data->ci_setconfig.err_code, 0);
|
||||
|
||||
bdcpy(reject.bd_addr, p_data->str_msg.bd_addr);
|
||||
reject.hndl = p_scb->hndl;
|
||||
|
|
|
@ -117,8 +117,8 @@ static void bta_av_co_audio_peer_reset_config(tBTA_AV_CO_PEER *p_peer);
|
|||
static BOOLEAN bta_av_co_cp_is_scmst(const UINT8 *p_protectinfo);
|
||||
static BOOLEAN bta_av_co_audio_sink_has_scmst(const tBTA_AV_CO_SINK *p_sink);
|
||||
static BOOLEAN bta_av_co_audio_peer_supports_codec(tBTA_AV_CO_PEER *p_peer, UINT8 *p_snk_index);
|
||||
static BOOLEAN bta_av_co_audio_media_supports_config(UINT8 codec_type, const UINT8 *p_codec_cfg);
|
||||
static BOOLEAN bta_av_co_audio_sink_supports_config(UINT8 codec_type, const UINT8 *p_codec_cfg);
|
||||
static UINT8 bta_av_co_audio_media_supports_config(UINT8 codec_type, const UINT8 *p_codec_cfg);
|
||||
static UINT8 bta_av_co_audio_sink_supports_config(UINT8 codec_type, const UINT8 *p_codec_cfg);
|
||||
static BOOLEAN bta_av_co_audio_peer_src_supports_codec(tBTA_AV_CO_PEER *p_peer, UINT8 *p_src_index);
|
||||
|
||||
|
||||
|
@ -660,7 +660,7 @@ void bta_av_co_audio_setconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
|
|||
UINT8 status = A2D_SUCCESS;
|
||||
UINT8 category = A2D_SUCCESS;
|
||||
BOOLEAN recfg_needed = FALSE;
|
||||
BOOLEAN codec_cfg_supported = FALSE;
|
||||
UINT8 codec_cfg_status = A2D_SUCCESS;
|
||||
UNUSED(seid);
|
||||
UNUSED(addr);
|
||||
|
||||
|
@ -709,15 +709,15 @@ void bta_av_co_audio_setconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
|
|||
#endif
|
||||
if (status == A2D_SUCCESS) {
|
||||
if (AVDT_TSEP_SNK == t_local_sep) {
|
||||
codec_cfg_supported = bta_av_co_audio_sink_supports_config(codec_type, p_codec_info);
|
||||
codec_cfg_status = bta_av_co_audio_sink_supports_config(codec_type, p_codec_info);
|
||||
APPL_TRACE_DEBUG(" Peer is A2DP SRC ");
|
||||
}
|
||||
if (AVDT_TSEP_SRC == t_local_sep) {
|
||||
codec_cfg_supported = bta_av_co_audio_media_supports_config(codec_type, p_codec_info);
|
||||
codec_cfg_status = bta_av_co_audio_media_supports_config(codec_type, p_codec_info);
|
||||
APPL_TRACE_DEBUG(" Peer is A2DP SINK ");
|
||||
}
|
||||
/* Check if codec configuration is supported */
|
||||
if (codec_cfg_supported) {
|
||||
if (codec_cfg_status == A2D_SUCCESS) {
|
||||
|
||||
/* Protect access to bta_av_co_cb.codec_cfg */
|
||||
osi_mutex_global_lock();
|
||||
|
@ -757,15 +757,15 @@ void bta_av_co_audio_setconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
|
|||
osi_mutex_global_unlock();
|
||||
} else {
|
||||
category = AVDT_ASC_CODEC;
|
||||
status = A2D_WRONG_CODEC;
|
||||
status = A2D_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
if (status != A2D_SUCCESS) {
|
||||
APPL_TRACE_DEBUG("bta_av_co_audio_setconfig reject s=%d c=%d", status, category);
|
||||
APPL_TRACE_DEBUG("bta_av_co_audio_setconfig reject s=%d c=%d", codec_cfg_status, category);
|
||||
|
||||
/* Call call-in rejecting the configuration */
|
||||
bta_av_ci_setconfig(hndl, status, category, 0, NULL, FALSE, avdt_handle);
|
||||
bta_av_ci_setconfig(hndl, codec_cfg_status, category, 0, NULL, FALSE, avdt_handle);
|
||||
} else {
|
||||
/* Mark that this is an acceptor peer */
|
||||
p_peer->acp = TRUE;
|
||||
|
@ -1273,24 +1273,26 @@ static BOOLEAN bta_av_co_audio_peer_src_supports_codec(tBTA_AV_CO_PEER *p_peer,
|
|||
** Returns TRUE if the media source supports this config, FALSE otherwise
|
||||
**
|
||||
*******************************************************************************/
|
||||
static BOOLEAN bta_av_co_audio_sink_supports_config(UINT8 codec_type, const UINT8 *p_codec_cfg)
|
||||
static UINT8 bta_av_co_audio_sink_supports_config(UINT8 codec_type, const UINT8 *p_codec_cfg)
|
||||
{
|
||||
FUNC_TRACE();
|
||||
UINT8 status = A2D_BAD_CODEC_TYPE;
|
||||
|
||||
switch (codec_type) {
|
||||
case BTA_AV_CODEC_SBC:
|
||||
if (bta_av_sbc_cfg_in_cap((UINT8 *)p_codec_cfg, (tA2D_SBC_CIE *)&bta_av_co_sbc_sink_caps)) {
|
||||
return FALSE;
|
||||
}
|
||||
status = bta_av_sbc_cfg_in_cap((UINT8 *)p_codec_cfg, (tA2D_SBC_CIE *)&bta_av_co_sbc_sink_caps);
|
||||
break;
|
||||
case BTA_AV_CODEC_M12:
|
||||
case BTA_AV_CODEC_M24:
|
||||
case BTA_AV_CODEC_ATRAC:
|
||||
status = A2D_NS_CODEC_TYPE;
|
||||
APPL_TRACE_ERROR("bta_av_co_audio_sink_supports_config unsupported codec type %d", codec_type);
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
APPL_TRACE_ERROR("bta_av_co_audio_media_supports_config unsupported codec type %d", codec_type);
|
||||
return FALSE;
|
||||
APPL_TRACE_ERROR("bta_av_co_audio_sink_supports_config invalid codec type %d", codec_type);
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
return status;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
|
@ -1302,24 +1304,26 @@ static BOOLEAN bta_av_co_audio_sink_supports_config(UINT8 codec_type, const UINT
|
|||
** Returns TRUE if the media source supports this config, FALSE otherwise
|
||||
**
|
||||
*******************************************************************************/
|
||||
static BOOLEAN bta_av_co_audio_media_supports_config(UINT8 codec_type, const UINT8 *p_codec_cfg)
|
||||
static UINT8 bta_av_co_audio_media_supports_config(UINT8 codec_type, const UINT8 *p_codec_cfg)
|
||||
{
|
||||
FUNC_TRACE();
|
||||
UINT8 status = A2D_BAD_CODEC_TYPE;
|
||||
|
||||
switch (codec_type) {
|
||||
case BTA_AV_CODEC_SBC:
|
||||
if (bta_av_sbc_cfg_in_cap((UINT8 *)p_codec_cfg, (tA2D_SBC_CIE *)&bta_av_co_sbc_caps)) {
|
||||
return FALSE;
|
||||
}
|
||||
status = bta_av_sbc_cfg_in_cap((UINT8 *)p_codec_cfg, (tA2D_SBC_CIE *)&bta_av_co_sbc_caps);
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
case BTA_AV_CODEC_M12:
|
||||
case BTA_AV_CODEC_M24:
|
||||
case BTA_AV_CODEC_ATRAC:
|
||||
status = A2D_NS_CODEC_TYPE;
|
||||
APPL_TRACE_ERROR("bta_av_co_audio_media_supports_config unsupported codec type %d", codec_type);
|
||||
return FALSE;
|
||||
break;
|
||||
default:
|
||||
APPL_TRACE_ERROR("bta_av_co_audio_media_supports_config invalid codec type %d", codec_type);
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
return status;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
|
|
|
@ -105,7 +105,7 @@ tA2D_STATUS A2D_BldSbcInfo(UINT8 media_type, tA2D_SBC_CIE *p_ie, UINT8 *p_result
|
|||
******************************************************************************/
|
||||
tA2D_STATUS A2D_ParsSbcInfo(tA2D_SBC_CIE *p_ie, UINT8 *p_info, BOOLEAN for_caps)
|
||||
{
|
||||
tA2D_STATUS status;
|
||||
tA2D_STATUS status = A2D_SUCCESS;
|
||||
UINT8 losc;
|
||||
|
||||
if ( p_ie == NULL || p_info == NULL) {
|
||||
|
@ -127,7 +127,6 @@ tA2D_STATUS A2D_ParsSbcInfo(tA2D_SBC_CIE *p_ie, UINT8 *p_info, BOOLEAN for_caps)
|
|||
p_info++;
|
||||
p_ie->min_bitpool = *p_info++;
|
||||
p_ie->max_bitpool = *p_info;
|
||||
status = A2D_SUCCESS;
|
||||
if (p_ie->min_bitpool < A2D_SBC_IE_MIN_BITPOOL || p_ie->min_bitpool > A2D_SBC_IE_MAX_BITPOOL ) {
|
||||
status = A2D_BAD_MIN_BITPOOL;
|
||||
}
|
||||
|
@ -140,17 +139,13 @@ tA2D_STATUS A2D_ParsSbcInfo(tA2D_SBC_CIE *p_ie, UINT8 *p_info, BOOLEAN for_caps)
|
|||
if (for_caps == FALSE) {
|
||||
if (A2D_BitsSet(p_ie->samp_freq) != A2D_SET_ONE_BIT) {
|
||||
status = A2D_BAD_SAMP_FREQ;
|
||||
}
|
||||
if (A2D_BitsSet(p_ie->ch_mode) != A2D_SET_ONE_BIT) {
|
||||
} else if (A2D_BitsSet(p_ie->ch_mode) != A2D_SET_ONE_BIT) {
|
||||
status = A2D_BAD_CH_MODE;
|
||||
}
|
||||
if (A2D_BitsSet(p_ie->block_len) != A2D_SET_ONE_BIT) {
|
||||
} else if (A2D_BitsSet(p_ie->block_len) != A2D_SET_ONE_BIT) {
|
||||
status = A2D_BAD_BLOCK_LEN;
|
||||
}
|
||||
if (A2D_BitsSet(p_ie->num_subbands) != A2D_SET_ONE_BIT) {
|
||||
} else if (A2D_BitsSet(p_ie->num_subbands) != A2D_SET_ONE_BIT) {
|
||||
status = A2D_BAD_SUBBANDS;
|
||||
}
|
||||
if (A2D_BitsSet(p_ie->alloc_mthd) != A2D_SET_ONE_BIT) {
|
||||
} else if (A2D_BitsSet(p_ie->alloc_mthd) != A2D_SET_ONE_BIT) {
|
||||
status = A2D_BAD_ALLOC_MTHD;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -788,25 +788,18 @@ void avdt_scb_hdl_setconfig_cmd(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
|
|||
|
||||
if (!p_scb->in_use) {
|
||||
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]) {
|
||||
/* set sep as in use */
|
||||
p_scb->in_use = TRUE;
|
||||
/* set sep as in use */
|
||||
p_scb->in_use = TRUE;
|
||||
|
||||
/* copy info to scb */
|
||||
p_scb->p_ccb = avdt_ccb_by_idx(p_data->msg.config_cmd.hdr.ccb_idx);
|
||||
p_scb->peer_seid = p_data->msg.config_cmd.int_seid;
|
||||
memcpy(&p_scb->req_cfg, p_cfg, sizeof(tAVDT_CFG));
|
||||
/* call app callback */
|
||||
(*p_scb->cs.p_ctrl_cback)(avdt_scb_to_hdl(p_scb), /* handle of scb- which is same as sep handle of bta_av_cb.p_scb*/
|
||||
p_scb->p_ccb ? p_scb->p_ccb->peer_addr : NULL,
|
||||
AVDT_CONFIG_IND_EVT,
|
||||
(tAVDT_CTRL *) &p_data->msg.config_cmd);
|
||||
} else {
|
||||
p_data->msg.hdr.err_code = AVDT_ERR_UNSUP_CFG;
|
||||
p_data->msg.hdr.err_param = 0;
|
||||
avdt_msg_send_rej(avdt_ccb_by_idx(p_data->msg.hdr.ccb_idx),
|
||||
p_data->msg.hdr.sig_id, &p_data->msg);
|
||||
}
|
||||
/* copy info to scb */
|
||||
p_scb->p_ccb = avdt_ccb_by_idx(p_data->msg.config_cmd.hdr.ccb_idx);
|
||||
p_scb->peer_seid = p_data->msg.config_cmd.int_seid;
|
||||
memcpy(&p_scb->req_cfg, p_cfg, sizeof(tAVDT_CFG));
|
||||
/* call app callback */
|
||||
(*p_scb->cs.p_ctrl_cback)(avdt_scb_to_hdl(p_scb), /* handle of scb- which is same as sep handle of bta_av_cb.p_scb*/
|
||||
p_scb->p_ccb ? p_scb->p_ccb->peer_addr : NULL,
|
||||
AVDT_CONFIG_IND_EVT,
|
||||
(tAVDT_CTRL *) &p_data->msg.config_cmd);
|
||||
} else {
|
||||
avdt_scb_rej_in_use(p_scb, p_data);
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue