/* 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->offload_start_pending = false;
-
if (p_scb->deregistering) {
/* remove stream */
for (int i = 0; i < BTAV_A2DP_CODEC_INDEX_MAX; i++) {
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) ||
(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) {
+ if (bta_av_cb.offload_started_hndl == p_scb->hndl) {
+ bta_av_vendor_offload_stop();
+ bta_av_cb.offload_started_hndl = 0;
+ } else if (bta_av_cb.offload_start_pending_hndl == p_scb->hndl) {
+ 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_hndl = 0;
}
bta_av_stream_chg(p_scb, false);
}
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) {
+ if (bta_av_cb.offload_started_hndl == p_scb->hndl) {
bta_av_vendor_offload_stop();
- p_scb->offload_started = false;
+ bta_av_cb.offload_started_hndl = 0;
+ } else if (bta_av_cb.offload_start_pending_hndl == p_scb->hndl) {
+ APPL_TRACE_WARNING("%s: Stop pending offload start command", __func__);
+ bta_av_vendor_offload_stop();
+ bta_av_cb.offload_start_pending_hndl = 0;
}
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_hndl) {
+ APPL_TRACE_DEBUG("%s: VS_HCI_START_A2DP_MEDIA successful", __func__);
+ bta_av_cb.offload_started_hndl = bta_av_cb.offload_start_pending_hndl;
+ bta_av_cb.offload_start_pending_hndl = 0;
+ } 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_hndl = 0;
(*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_hndl = p_scb->hndl;
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_hndl ||
+ bta_av_cb.offload_started_hndl) {
+ 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_hndl = 0;
tBTA_AV bta_av_data;
bta_av_data.status = status;
(*bta_av_cb.p_cback)(BTA_AV_OFFLOAD_START_RSP_EVT, &bta_av_data);