/* ACL quota we are letting FW use for A2DP Offload Tx. */
#define BTA_AV_A2DP_OFFLOAD_XMIT_QUOTA 4
-#define BTIF_A2DP_MAX_BITPOOL_MQ 35
-
static void bta_av_offload_codec_builder(tBTA_AV_SCB* p_scb,
tBT_A2DP_OFFLOAD* p_a2dp_offload);
BTA_AV_AVDT_RPT_CONN_EVT, /* AVDT_REPORT_CONN_EVT */
BTA_AV_AVDT_RPT_CONN_EVT, /* AVDT_REPORT_DISCONN_EVT */
BTA_AV_AVDT_DELAY_RPT_EVT, /* AVDT_DELAY_REPORT_EVT */
- 0 /* AVDT_DELAY_REPORT_CFM_EVT */
+ BTA_AV_AVDT_DELAY_RPT_CFM_EVT, /* AVDT_DELAY_REPORT_CFM_EVT */
};
static const uint16_t bta_av_stream_evt_fail[] = {
BTA_AV_AVDT_RPT_CONN_EVT, /* AVDT_REPORT_CONN_EVT */
BTA_AV_AVDT_RPT_CONN_EVT, /* AVDT_REPORT_DISCONN_EVT */
BTA_AV_AVDT_DELAY_RPT_EVT, /* AVDT_DELAY_REPORT_EVT */
- 0 /* AVDT_DELAY_REPORT_CFM_EVT */
+ BTA_AV_AVDT_DELAY_RPT_CFM_EVT, /* AVDT_DELAY_REPORT_CFM_EVT */
};
/***********************************************
/* if de-registering shut everything down */
msg.hdr.layer_specific = p_scb->hndl;
p_scb->started = false;
- p_scb->offload_started = false;
p_scb->use_rtp_header_marker_bit = false;
p_scb->cong = false;
p_scb->role = role;
p_scb->num_disc_snks = 0;
p_scb->coll_mask = 0;
alarm_cancel(p_scb->avrc_ct_timer);
+ alarm_cancel(p_scb->link_signalling_timer);
+ alarm_cancel(p_scb->accept_signalling_timer);
/* TODO(eisenbach): RE-IMPLEMENT USING VSC OR HAL EXTENSION
vendor_get_interface()->send_command(
}
*/
- p_scb->offload_start_pending = false;
-
if (p_scb->deregistering) {
/* remove stream */
for (int i = 0; i < BTAV_A2DP_CODEC_INDEX_MAX; i++) {
/* Clear collision mask */
p_scb->coll_mask = 0;
- alarm_cancel(bta_av_cb.accept_signalling_timer);
+ alarm_cancel(p_scb->accept_signalling_timer);
/* if no codec parameters in configuration, fail */
if ((p_evt_cfg->num_codec == 0) ||
APPL_TRACE_API("%s: conn_lcb: 0x%x peer_addr: %s", __func__,
bta_av_cb.conn_lcb, p_scb->PeerAddress().ToString().c_str());
- alarm_cancel(bta_av_cb.link_signalling_timer);
+ alarm_cancel(p_scb->link_signalling_timer);
+ alarm_cancel(p_scb->accept_signalling_timer);
alarm_cancel(p_scb->avrc_ct_timer);
// conn_lcb is the index bitmask of all used LCBs, and since LCB and SCB use
AVDT_ConfigRsp(p_scb->avdt_handle, p_scb->avdt_label,
p_data->ci_setconfig.err_code, p_data->ci_setconfig.category);
- alarm_cancel(bta_av_cb.link_signalling_timer);
+ alarm_cancel(p_scb->link_signalling_timer);
if (p_data->ci_setconfig.err_code == AVDT_SUCCESS) {
p_scb->wait = BTA_AV_WAIT_ACP_CAPS_ON;
bta_av_conn_chg((tBTA_AV_DATA*)&msg);
/* set the congestion flag, so AV would not send media packets by accident */
p_scb->cong = true;
- p_scb->offload_start_pending = false;
// Don't use AVDTP SUSPEND for restrict listed devices
btif_storage_get_stored_remote_name(p_scb->PeerAddress(), remote_name);
if (interop_match_name(INTEROP_DISABLE_AVDTP_SUSPEND, remote_name) ||
if (p_scb->co_started) {
bta_av_str_stopped(p_scb, NULL);
}
- alarm_cancel(bta_av_cb.link_signalling_timer);
+ alarm_cancel(p_scb->link_signalling_timer);
/* close stream */
p_scb->started = false;
(cur_role == HCI_ROLE_CENTRAL)) {
BTM_block_role_switch_for(p_scb->PeerAddress());
}
+ BTM_block_sniff_mode_for(p_scb->PeerAddress());
if (p_scb->started) {
p_scb->role |= BTA_AV_ROLE_START_INT;
bta_sys_idle(BTA_ID_AV, bta_av_cb.audio_open_cnt, p_scb->PeerAddress());
BTM_unblock_role_switch_for(p_scb->PeerAddress());
+ BTM_unblock_sniff_mode_for(p_scb->PeerAddress());
if (p_scb->co_started) {
- if (p_scb->offload_started) {
+ uint16_t handle = get_btm_client_interface().lifecycle.BTM_GetHCIConnHandle(
+ p_scb->PeerAddress(), BT_TRANSPORT_BR_EDR);
+ if (bta_av_cb.offload_started_acl_hdl == handle) {
bta_av_vendor_offload_stop();
- p_scb->offload_started = false;
+ bta_av_cb.offload_started_acl_hdl = HCI_INVALID_HANDLE;
+ } else if (bta_av_cb.offload_start_pending_acl_hdl == handle) {
+ APPL_TRACE_WARNING("%s: Stop pending offload start command", __func__);
+ bta_av_vendor_offload_stop();
+ bta_av_cb.offload_start_pending_acl_hdl = HCI_INVALID_HANDLE;
}
bta_av_stream_chg(p_scb, false);
bool initiator = false;
bool suspend = false;
uint8_t new_role = p_scb->role;
- BT_HDR hdr;
+ BT_HDR_RIGID hdr;
tHCI_ROLE cur_role;
uint8_t local_tsep = p_scb->seps[p_scb->sep_idx].tsep;
}
BTM_unblock_role_switch_for(p_scb->PeerAddress());
+ BTM_unblock_sniff_mode_for(p_scb->PeerAddress());
p_scb->sco_suspend = false;
}
p_scb->open_status, p_scb->chnl, p_scb->co_started);
BTM_unblock_role_switch_for(p_scb->PeerAddress());
+ BTM_unblock_sniff_mode_for(p_scb->PeerAddress());
if (bta_av_cb.audio_open_cnt <= 1) {
BTM_default_unblock_role_switch();
}
bta_sys_idle(BTA_ID_AV, bta_av_cb.audio_open_cnt, p_scb->PeerAddress());
BTM_unblock_role_switch_for(p_scb->PeerAddress());
+ BTM_unblock_sniff_mode_for(p_scb->PeerAddress());
/* in case that we received suspend_ind, we may need to call co_stop here */
if (p_scb->co_started) {
- if (p_scb->offload_started) {
+ uint16_t handle = get_btm_client_interface().lifecycle.BTM_GetHCIConnHandle(
+ p_scb->PeerAddress(), BT_TRANSPORT_BR_EDR);
+ if (bta_av_cb.offload_started_acl_hdl == handle) {
+ bta_av_vendor_offload_stop();
+ bta_av_cb.offload_started_acl_hdl = HCI_INVALID_HANDLE;
+ } else if (bta_av_cb.offload_start_pending_acl_hdl == handle) {
+ APPL_TRACE_WARNING("%s: Stop pending offload start command", __func__);
bta_av_vendor_offload_stop();
- p_scb->offload_started = false;
+ bta_av_cb.offload_start_pending_acl_hdl = HCI_INVALID_HANDLE;
}
bta_av_stream_chg(p_scb, false);
APPL_TRACE_DEBUG("%s: VS_HCI_STOP_A2DP_MEDIA successful", __func__);
break;
case VS_HCI_A2DP_OFFLOAD_START:
+ if (bta_av_cb.offload_start_pending_acl_hdl != HCI_INVALID_HANDLE) {
+ bta_av_cb.offload_started_acl_hdl =
+ bta_av_cb.offload_start_pending_acl_hdl;
+ bta_av_cb.offload_start_pending_acl_hdl = HCI_INVALID_HANDLE;
+ } else {
+ LOG_INFO("%s: No pending start command due to AVDTP suspend immediately", __func__);
+ }
(*bta_av_cb.p_cback)(BTA_AV_OFFLOAD_START_RSP_EVT, &value);
break;
default:
} else {
APPL_TRACE_DEBUG("%s: Offload failed for subopcode= %d", __func__,
sub_opcode);
- if (param->opcode != VS_HCI_A2DP_OFFLOAD_STOP)
+ if (param->opcode != VS_HCI_A2DP_OFFLOAD_STOP) {
+ bta_av_cb.offload_start_pending_acl_hdl = HCI_INVALID_HANDLE;
(*bta_av_cb.p_cback)(BTA_AV_OFFLOAD_START_RSP_EVT, &value);
+ }
}
}
UINT16_TO_STREAM(p_param, offload_start->mtu);
ARRAY_TO_STREAM(p_param, offload_start->codec_info,
(int8_t)sizeof(offload_start->codec_info));
- p_scb->offload_started = true;
+ bta_av_cb.offload_start_pending_acl_hdl = offload_start->acl_hdl;
BTM_VendorSpecificCommand(HCI_CONTROLLER_A2DP, p_param - param,
param, offload_vendor_callback);
}
/* Support offload if only one audio source stream is open. */
if (p_scb->started != true) {
status = BTA_AV_FAIL_STREAM;
+ } else if (bta_av_cb.offload_start_pending_acl_hdl != HCI_INVALID_HANDLE ||
+ bta_av_cb.offload_started_acl_hdl != HCI_INVALID_HANDLE) {
+ APPL_TRACE_WARNING("%s: offload already started, ignore request", __func__);
+ return;
} else {
bta_av_offload_codec_builder(p_scb, &offload_start);
bta_av_vendor_offload_start(p_scb, &offload_start);
status = BTA_AV_FAIL_STREAM;
}
- p_scb->offload_start_pending = false;
+ bta_av_cb.offload_start_pending_acl_hdl = HCI_INVALID_HANDLE;
tBTA_AV bta_av_data;
bta_av_data.status = status;
(*bta_av_cb.p_cback)(BTA_AV_OFFLOAD_START_RSP_EVT, &bta_av_data);
case BTAV_A2DP_CODEC_INDEX_SOURCE_SBC:
codec_type = BTA_AV_CODEC_TYPE_SBC;
if (A2DP_GetMaxBitpoolSbc(p_scb->cfg.codec_info) <=
- BTIF_A2DP_MAX_BITPOOL_MQ) {
+ A2DP_SBC_BITPOOL_MIDDLE_QUALITY) {
APPL_TRACE_WARNING("%s: Restricting streaming MTU size for MQ Bitpool",
__func__);
mtu = MAX_2MBPS_AVDTP_MTU;