• Home
  • Raw
  • Download

Lines Matching refs:p_scb

85 static void bta_av_offload_codec_builder(tBTA_AV_SCB* p_scb,
172 static uint8_t bta_av_get_scb_handle(tBTA_AV_SCB* p_scb, uint8_t local_sep) { in bta_av_get_scb_handle() argument
174 if ((p_scb->seps[i].tsep == local_sep) && in bta_av_get_scb_handle()
175 A2DP_CodecTypeEquals(p_scb->seps[i].codec_info, in bta_av_get_scb_handle()
176 p_scb->cfg.codec_info)) { in bta_av_get_scb_handle()
177 return (p_scb->seps[i].av_handle); in bta_av_get_scb_handle()
193 static uint8_t bta_av_get_scb_sep_type(tBTA_AV_SCB* p_scb, in bta_av_get_scb_sep_type() argument
196 if (p_scb->seps[i].av_handle == tavdt_handle) return (p_scb->seps[i].tsep); in bta_av_get_scb_sep_type()
212 static void bta_av_save_addr(tBTA_AV_SCB* p_scb, const RawAddress& bd_addr) { in bta_av_save_addr() argument
214 bd_addr.ToString().c_str(), p_scb->recfg_sup, in bta_av_save_addr()
215 p_scb->suspend_sup); in bta_av_save_addr()
216 if (p_scb->PeerAddress() != bd_addr) { in bta_av_save_addr()
218 p_scb->PeerAddress().ToString().c_str(), in bta_av_save_addr()
221 p_scb->recfg_sup = true; in bta_av_save_addr()
222 p_scb->suspend_sup = true; in bta_av_save_addr()
227 p_scb->OnConnected(bd_addr); in bta_av_save_addr()
240 static void notify_start_failed(tBTA_AV_SCB* p_scb) { in notify_start_failed() argument
242 p_scb->PeerAddress().ToString().c_str(), p_scb->role, p_scb->chnl, in notify_start_failed()
243 p_scb->hndl); in notify_start_failed()
246 p_scb->role &= ~BTA_AV_ROLE_START_INT; in notify_start_failed()
247 start.chnl = p_scb->chnl; in notify_start_failed()
250 start.hndl = p_scb->hndl; in notify_start_failed()
268 void bta_av_st_rc_timer(tBTA_AV_SCB* p_scb, UNUSED_ATTR tBTA_AV_DATA* p_data) { in bta_av_st_rc_timer() argument
269 APPL_TRACE_DEBUG("%s: rc_handle:%d, use_rc: %d", __func__, p_scb->rc_handle, in bta_av_st_rc_timer()
270 p_scb->use_rc); in bta_av_st_rc_timer()
272 if ((p_scb->rc_handle == BTA_AV_RC_HANDLE_NONE) && in bta_av_st_rc_timer()
274 (p_scb->use_rc || (p_scb->role & BTA_AV_ROLE_AD_ACP))) { in bta_av_st_rc_timer()
275 if ((p_scb->wait & BTA_AV_WAIT_ROLE_SW_BITS) == 0) { in bta_av_st_rc_timer()
276 bta_sys_start_timer(p_scb->avrc_ct_timer, BTA_AV_RC_DISC_TIME_VAL, in bta_av_st_rc_timer()
277 BTA_AV_AVRC_TIMER_EVT, p_scb->hndl); in bta_av_st_rc_timer()
279 p_scb->wait |= BTA_AV_WAIT_CHECK_RC; in bta_av_st_rc_timer()
294 static bool bta_av_next_getcap(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) { in bta_av_next_getcap() argument
297 uint16_t uuid_int = p_scb->uuid_int; in bta_av_next_getcap()
305 for (i = p_scb->sep_info_idx; i < p_scb->num_seps; i++) { in bta_av_next_getcap()
307 if ((!p_scb->sep_info[i].in_use) && in bta_av_next_getcap()
308 (p_scb->sep_info[i].tsep == sep_requested) && in bta_av_next_getcap()
309 (p_scb->sep_info[i].media_type == p_scb->media_type)) { in bta_av_next_getcap()
310 p_scb->sep_info_idx = i; in bta_av_next_getcap()
313 bool get_all_cap = (p_scb->AvdtpVersion() >= AVDT_VERSION_1_3) && in bta_av_next_getcap()
315 AVDT_GetCapReq(p_scb->PeerAddress(), p_scb->hdi, p_scb->sep_info[i].seid, in bta_av_next_getcap()
316 &p_scb->peer_cap, &bta_av_proc_stream_evt, get_all_cap); in bta_av_next_getcap()
325 p_scb->PeerAddress().ToString().c_str()); in bta_av_next_getcap()
326 bta_av_ssm_execute(p_scb, BTA_AV_STR_GETCAP_FAIL_EVT, p_data); in bta_av_next_getcap()
345 tBTA_AV_SCB* p_scb = bta_av_cb.p_scb[scb_index]; in bta_av_proc_stream_evt() local
350 __func__, bd_addr.ToString().c_str(), handle, event, scb_index, p_scb); in bta_av_proc_stream_evt()
364 if (p_scb) { in bta_av_proc_stream_evt()
403 p_scb->recfg_sup = true; in bta_av_proc_stream_evt()
404 p_scb->suspend_sup = true; in bta_av_proc_stream_evt()
425 p_scb->hndl, handle); in bta_av_proc_stream_evt()
426 p_msg->hdr.layer_specific = p_scb->hndl; in bta_av_proc_stream_evt()
451 tBTA_AV_SCB* p_scb; in bta_av_sink_data_cback() local
459 p_scb = bta_av_cb.p_scb[index]; in bta_av_sink_data_cback()
460 if ((p_scb->avdt_handle == handle) && in bta_av_sink_data_cback()
461 (p_scb->seps[p_scb->sep_idx].tsep == AVDT_TSEP_SNK)) { in bta_av_sink_data_cback()
471 p_scb->seps[p_scb->sep_idx].p_app_sink_data_cback( in bta_av_sink_data_cback()
472 p_scb->PeerAddress(), BTA_AV_SINK_MEDIA_DATA_EVT, (tBTA_AV_MEDIA*)p_pkt); in bta_av_sink_data_cback()
491 tBTA_AV_SCB* p_scb = NULL; in bta_av_a2dp_sdp_cback() local
493 p_scb = bta_av_addr_to_scb(peer_address); in bta_av_a2dp_sdp_cback()
495 if (p_scb == NULL) { in bta_av_a2dp_sdp_cback()
496 p_scb = bta_av_hndl_to_scb(bta_av_cb.handle); in bta_av_a2dp_sdp_cback()
498 if (p_scb == NULL) { in bta_av_a2dp_sdp_cback()
503 if (bta_av_cb.handle != p_scb->hndl) { in bta_av_a2dp_sdp_cback()
505 __func__, bta_av_cb.handle, p_scb->hndl); in bta_av_a2dp_sdp_cback()
510 p_scb->PeerAddress().ToString().c_str()); in bta_av_a2dp_sdp_cback()
513 p_scb->PeerAddress().ToString().c_str(), in bta_av_a2dp_sdp_cback()
523 p_scb->PeerAddress().ToString().c_str()); in bta_av_a2dp_sdp_cback()
526 p_scb->SetAvdtpVersion(p_service->avdt_version); in bta_av_a2dp_sdp_cback()
528 if (btif_config_set_bin(p_scb->PeerAddress().ToString(), in bta_av_a2dp_sdp_cback()
535 __func__, p_scb->PeerAddress().ToString().c_str()); in bta_av_a2dp_sdp_cback()
539 p_scb->SetAvdtpVersion(0); in bta_av_a2dp_sdp_cback()
541 p_msg->hdr.layer_specific = p_scb->hndl; in bta_av_a2dp_sdp_cback()
555 static void bta_av_adjust_seps_idx(tBTA_AV_SCB* p_scb, uint8_t avdt_handle) { in bta_av_adjust_seps_idx() argument
557 A2DP_CodecName(p_scb->cfg.codec_info)); in bta_av_adjust_seps_idx()
560 p_scb->seps[i].av_handle, in bta_av_adjust_seps_idx()
561 A2DP_CodecName(p_scb->seps[i].codec_info)); in bta_av_adjust_seps_idx()
562 if (p_scb->seps[i].av_handle && (p_scb->seps[i].av_handle == avdt_handle) && in bta_av_adjust_seps_idx()
563 A2DP_CodecTypeEquals(p_scb->seps[i].codec_info, in bta_av_adjust_seps_idx()
564 p_scb->cfg.codec_info)) { in bta_av_adjust_seps_idx()
565 p_scb->sep_idx = i; in bta_av_adjust_seps_idx()
566 p_scb->avdt_handle = p_scb->seps[i].av_handle; in bta_av_adjust_seps_idx()
582 void bta_av_switch_role(tBTA_AV_SCB* p_scb, UNUSED_ATTR tBTA_AV_DATA* p_data) { in bta_av_switch_role() argument
584 tBTA_AV_API_OPEN* p_buf = &p_scb->q_info.open; in bta_av_switch_role()
587 p_scb->PeerAddress().ToString().c_str(), p_scb->wait); in bta_av_switch_role()
588 if (p_scb->wait & BTA_AV_WAIT_ROLE_SW_RES_START) in bta_av_switch_role()
589 p_scb->wait |= BTA_AV_WAIT_ROLE_SW_RETRY; in bta_av_switch_role()
592 p_scb->wait &= in bta_av_switch_role()
595 if (p_scb->q_tag == BTA_AV_Q_TAG_OPEN) { in bta_av_switch_role()
596 if (bta_av_switch_if_needed(p_scb) || in bta_av_switch_role()
597 !bta_av_link_role_ok(p_scb, A2DP_SET_MULTL_BIT)) { in bta_av_switch_role()
598 p_scb->wait |= BTA_AV_WAIT_ROLE_SW_RES_OPEN; in bta_av_switch_role()
607 p_scb->PeerAddress().ToString().c_str(), p_scb->wait); in bta_av_switch_role()
612 if (bta_av_cb.rs_idx == (p_scb->hdi + 1)) { in bta_av_switch_role()
615 p_scb->wait &= ~BTA_AV_WAIT_ROLE_SW_RETRY; in bta_av_switch_role()
616 p_scb->q_tag = 0; in bta_av_switch_role()
618 bta_av_do_disc_a2dp(p_scb, (tBTA_AV_DATA*)p_buf); in bta_av_switch_role()
632 void bta_av_role_res(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) { in bta_av_role_res() argument
636 p_scb->PeerAddress().ToString().c_str(), p_scb->q_tag, in bta_av_role_res()
637 p_scb->wait, p_scb->role); in bta_av_role_res()
638 if (p_scb->role & BTA_AV_ROLE_START_INT) initiator = true; in bta_av_role_res()
640 if (p_scb->q_tag == BTA_AV_Q_TAG_START) { in bta_av_role_res()
641 if (p_scb->wait & BTA_AV_WAIT_ROLE_SW_STARTED) { in bta_av_role_res()
642 p_scb->wait &= ~BTA_AV_WAIT_ROLE_SW_BITS; in bta_av_role_res()
644 p_scb->role &= ~BTA_AV_ROLE_START_INT; in bta_av_role_res()
645 bta_sys_idle(BTA_ID_AV, bta_av_cb.audio_open_cnt, p_scb->PeerAddress()); in bta_av_role_res()
648 start.chnl = p_scb->chnl; in bta_av_role_res()
650 start.hndl = p_scb->hndl; in bta_av_role_res()
656 bta_av_start_ok(p_scb, p_data); in bta_av_role_res()
658 } else if (p_scb->wait & BTA_AV_WAIT_ROLE_SW_RES_START) in bta_av_role_res()
659 p_scb->wait |= BTA_AV_WAIT_ROLE_SW_FAILED; in bta_av_role_res()
660 } else if (p_scb->q_tag == BTA_AV_Q_TAG_OPEN) { in bta_av_role_res()
661 if (p_scb->wait & BTA_AV_WAIT_ROLE_SW_RES_OPEN) { in bta_av_role_res()
662 p_scb->role &= ~BTA_AV_ROLE_START_INT; in bta_av_role_res()
663 p_scb->wait &= ~BTA_AV_WAIT_ROLE_SW_BITS; in bta_av_role_res()
668 av_open.bd_addr = p_scb->PeerAddress(); in bta_av_role_res()
669 av_open.chnl = p_scb->chnl; in bta_av_role_res()
670 av_open.hndl = p_scb->hndl; in bta_av_role_res()
672 if (p_scb->seps[p_scb->sep_idx].tsep == AVDT_TSEP_SRC) { in bta_av_role_res()
674 } else if (p_scb->seps[p_scb->sep_idx].tsep == AVDT_TSEP_SNK) { in bta_av_role_res()
682 p_scb->q_info.open.switch_res = BTA_AV_RS_DONE; in bta_av_role_res()
683 bta_av_do_disc_a2dp(p_scb, (tBTA_AV_DATA*)&(p_scb->q_info.open)); in bta_av_role_res()
688 __func__, p_scb->PeerAddress().ToString().c_str(), p_scb->q_tag, in bta_av_role_res()
689 p_scb->wait); in bta_av_role_res()
694 p_scb->PeerAddress().ToString().c_str(), p_scb->wait, in bta_av_role_res()
695 p_scb->role); in bta_av_role_res()
708 void bta_av_delay_co(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) { in bta_av_delay_co() argument
710 p_scb->PeerAddress().ToString().c_str(), p_scb->hndl, in bta_av_delay_co()
712 p_scb->p_cos->delay(p_scb->hndl, p_scb->PeerAddress(), in bta_av_delay_co()
725 void bta_av_do_disc_a2dp(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) { in bta_av_do_disc_a2dp() argument
738 memcpy(&(p_scb->open_api), &(p_data->api_open), sizeof(tBTA_AV_API_OPEN)); in bta_av_do_disc_a2dp()
742 if (bta_av_switch_if_needed(p_scb) || in bta_av_do_disc_a2dp()
743 !bta_av_link_role_ok(p_scb, A2DP_SET_MULTL_BIT)) { in bta_av_do_disc_a2dp()
745 memcpy(&p_scb->q_info.open, &p_data->api_open, in bta_av_do_disc_a2dp()
747 p_scb->wait |= BTA_AV_WAIT_ROLE_SW_RES_OPEN; in bta_av_do_disc_a2dp()
748 p_scb->q_tag = BTA_AV_Q_TAG_OPEN; in bta_av_do_disc_a2dp()
756 p_scb->open_status = BTA_AV_FAIL_ROLE; in bta_av_do_disc_a2dp()
758 p_scb->PeerAddress().ToString().c_str()); in bta_av_do_disc_a2dp()
759 bta_av_ssm_execute(p_scb, BTA_AV_SDP_DISC_FAIL_EVT, NULL); in bta_av_do_disc_a2dp()
763 p_data = (tBTA_AV_DATA*)&p_scb->q_info.open; in bta_av_do_disc_a2dp()
765 if (bta_av_link_role_ok(p_scb, A2DP_SET_MULTL_BIT)) { in bta_av_do_disc_a2dp()
768 p_scb->wait |= BTA_AV_WAIT_ROLE_SW_RES_OPEN; in bta_av_do_disc_a2dp()
778 ok_continue, p_scb->wait, p_scb->q_tag); in bta_av_do_disc_a2dp()
782 p_scb->wait &= ~BTA_AV_WAIT_ROLE_SW_BITS; in bta_av_do_disc_a2dp()
784 if (p_scb->wait & BTA_AV_WAIT_CHECK_RC) { in bta_av_do_disc_a2dp()
785 p_scb->wait &= ~BTA_AV_WAIT_CHECK_RC; in bta_av_do_disc_a2dp()
786 bta_sys_start_timer(p_scb->avrc_ct_timer, BTA_AV_RC_DISC_TIME_VAL, in bta_av_do_disc_a2dp()
787 BTA_AV_AVRC_TIMER_EVT, p_scb->hndl); in bta_av_do_disc_a2dp()
791 bta_av_save_addr(p_scb, p_data->api_open.bd_addr); in bta_av_do_disc_a2dp()
792 p_scb->use_rc = p_data->api_open.use_rc; in bta_av_do_disc_a2dp()
794 bta_sys_app_open(BTA_ID_AV, p_scb->app_id, p_scb->PeerAddress()); in bta_av_do_disc_a2dp()
800 p_scb->uuid_int = p_data->api_open.uuid; in bta_av_do_disc_a2dp()
801 p_scb->sdp_discovery_started = true; in bta_av_do_disc_a2dp()
802 if (p_scb->uuid_int == UUID_SERVCLASS_AUDIO_SINK) in bta_av_do_disc_a2dp()
804 else if (p_scb->uuid_int == UUID_SERVCLASS_AUDIO_SOURCE) in bta_av_do_disc_a2dp()
810 __func__, p_scb->PeerAddress().ToString().c_str(), p_scb->uuid_int, in bta_av_do_disc_a2dp()
813 sdp_uuid, p_scb->PeerAddress(), &db_params, bta_av_a2dp_sdp_cback); in bta_av_do_disc_a2dp()
818 __func__, p_scb->PeerAddress().ToString().c_str(), p_scb->uuid_int, in bta_av_do_disc_a2dp()
820 bta_av_a2dp_sdp_cback(false, nullptr, p_scb->PeerAddress()); in bta_av_do_disc_a2dp()
823 bta_av_cb.handle = p_scb->hndl; in bta_av_do_disc_a2dp()
836 void bta_av_cleanup(tBTA_AV_SCB* p_scb, UNUSED_ATTR tBTA_AV_DATA* p_data) { in bta_av_cleanup() argument
840 LOG_INFO("%s peer %s", __func__, p_scb->PeerAddress().ToString().c_str()); in bta_av_cleanup()
843 p_scb->sdp_discovery_started = false; in bta_av_cleanup()
844 p_scb->SetAvdtpVersion(0); in bta_av_cleanup()
847 p_scb->open_status = BTA_AV_SUCCESS; in bta_av_cleanup()
850 msg.hdr.layer_specific = p_scb->hndl; in bta_av_cleanup()
851 p_scb->started = false; in bta_av_cleanup()
852 p_scb->offload_started = false; in bta_av_cleanup()
853 p_scb->use_rtp_header_marker_bit = false; in bta_av_cleanup()
854 p_scb->cong = false; in bta_av_cleanup()
855 p_scb->role = role; in bta_av_cleanup()
856 p_scb->cur_psc_mask = 0; in bta_av_cleanup()
857 p_scb->wait = 0; in bta_av_cleanup()
858 p_scb->num_disc_snks = 0; in bta_av_cleanup()
859 p_scb->coll_mask = 0; in bta_av_cleanup()
860 alarm_cancel(p_scb->avrc_ct_timer); in bta_av_cleanup()
861 alarm_cancel(p_scb->link_signalling_timer); in bta_av_cleanup()
862 alarm_cancel(p_scb->accept_signalling_timer); in bta_av_cleanup()
875 p_scb->offload_start_pending = false; in bta_av_cleanup()
877 if (p_scb->deregistering) { in bta_av_cleanup()
880 if (p_scb->seps[i].av_handle) AVDT_RemoveStream(p_scb->seps[i].av_handle); in bta_av_cleanup()
881 p_scb->seps[i].av_handle = 0; in bta_av_cleanup()
888 msg.peer_addr = p_scb->PeerAddress(); in bta_av_cleanup()
902 void bta_av_free_sdb(tBTA_AV_SCB* p_scb, UNUSED_ATTR tBTA_AV_DATA* p_data) { in bta_av_free_sdb() argument
903 p_scb->sdp_discovery_started = false; in bta_av_free_sdb()
915 void bta_av_config_ind(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) { in bta_av_config_ind() argument
919 uint8_t psc_mask = (p_evt_cfg->psc_mask | p_scb->cfg.psc_mask); in bta_av_config_ind()
924 local_sep = bta_av_get_scb_sep_type(p_scb, p_msg->handle); in bta_av_config_ind()
925 p_scb->avdt_label = p_data->str_msg.msg.hdr.label; in bta_av_config_ind()
928 p_scb->PeerAddress().ToString().c_str(), p_scb->hndl, in bta_av_config_ind()
933 memcpy(p_scb->cfg.codec_info, p_evt_cfg->codec_info, AVDT_CODEC_SIZE); in bta_av_config_ind()
934 bta_av_save_addr(p_scb, p_data->str_msg.bd_addr); in bta_av_config_ind()
937 p_scb->coll_mask = 0; in bta_av_config_ind()
938 alarm_cancel(p_scb->accept_signalling_timer); in bta_av_config_ind()
943 ((psc_mask != p_scb->cfg.psc_mask) && in bta_av_config_ind()
944 (psc_mask != (p_scb->cfg.psc_mask & ~AVDT_PSC_DELAY_RPT)))) { in bta_av_config_ind()
945 setconfig.hndl = p_scb->hndl; /* we may not need this */ in bta_av_config_ind()
947 bta_av_ssm_execute(p_scb, BTA_AV_CI_SETCONFIG_FAIL_EVT, in bta_av_config_ind()
950 p_info = &p_scb->sep_info[0]; in bta_av_config_ind()
952 p_info->media_type = p_scb->media_type; in bta_av_config_ind()
961 p_scb->role |= BTA_AV_ROLE_AD_ACP; in bta_av_config_ind()
962 p_scb->cur_psc_mask = p_evt_cfg->psc_mask; in bta_av_config_ind()
964 p_scb->use_rc = true; in bta_av_config_ind()
966 p_scb->use_rc = false; in bta_av_config_ind()
968 p_scb->num_seps = 1; in bta_av_config_ind()
969 p_scb->sep_info_idx = 0; in bta_av_config_ind()
971 p_info->seid, p_scb->use_rc, p_scb->cur_psc_mask); in bta_av_config_ind()
975 p_scb->p_cos->setcfg(p_scb->hndl, p_scb->PeerAddress(), in bta_av_config_ind()
980 p_scb->p_cos->setcfg(p_scb->hndl, p_scb->PeerAddress(), in bta_av_config_ind()
997 void bta_av_disconnect_req(tBTA_AV_SCB* p_scb, in bta_av_disconnect_req() argument
1002 bta_av_cb.conn_lcb, p_scb->PeerAddress().ToString().c_str()); in bta_av_disconnect_req()
1004 alarm_cancel(p_scb->link_signalling_timer); in bta_av_disconnect_req()
1005 alarm_cancel(p_scb->accept_signalling_timer); in bta_av_disconnect_req()
1006 alarm_cancel(p_scb->avrc_ct_timer); in bta_av_disconnect_req()
1010 if ((bta_av_cb.conn_lcb & (1 << p_scb->hdi)) != 0) { in bta_av_disconnect_req()
1011 p_rcb = bta_av_get_rcb_by_shdl((uint8_t)(p_scb->hdi + 1)); in bta_av_disconnect_req()
1013 AVDT_DisconnectReq(p_scb->PeerAddress(), &bta_av_proc_stream_evt); in bta_av_disconnect_req()
1016 __func__, bta_av_cb.conn_lcb, p_scb->hndl, p_scb->hdi); in bta_av_disconnect_req()
1017 bta_av_ssm_execute(p_scb, BTA_AV_AVDT_DISCONNECT_EVT, NULL); in bta_av_disconnect_req()
1030 void bta_av_security_req(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) { in bta_av_security_req() argument
1032 AVDT_SecurityReq(p_scb->avdt_handle, p_data->api_protect_req.p_data, in bta_av_security_req()
1046 void bta_av_security_rsp(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) { in bta_av_security_rsp() argument
1048 AVDT_SecurityRsp(p_scb->avdt_handle, p_scb->avdt_label, in bta_av_security_rsp()
1053 AVDT_SecurityRsp(p_scb->avdt_handle, p_scb->avdt_label, AVDT_ERR_NSC, NULL, in bta_av_security_rsp()
1067 void bta_av_setconfig_rsp(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) { in bta_av_setconfig_rsp() argument
1075 local_sep = bta_av_get_scb_sep_type(p_scb, avdt_handle); in bta_av_setconfig_rsp()
1076 bta_av_adjust_seps_idx(p_scb, avdt_handle); in bta_av_setconfig_rsp()
1079 __func__, p_scb->PeerAddress().ToString().c_str(), p_scb->hndl, in bta_av_setconfig_rsp()
1080 p_scb->avdt_handle, p_scb->sep_idx, p_scb->cur_psc_mask); in bta_av_setconfig_rsp()
1084 (p_scb->seps[p_scb->sep_idx].p_app_sink_data_cback != NULL)) { in bta_av_setconfig_rsp()
1086 av_sink_codec_info.avk_config.bd_addr = p_scb->PeerAddress(); in bta_av_setconfig_rsp()
1087 av_sink_codec_info.avk_config.codec_info = p_scb->cfg.codec_info; in bta_av_setconfig_rsp()
1088 p_scb->seps[p_scb->sep_idx].p_app_sink_data_cback( in bta_av_setconfig_rsp()
1089 p_scb->PeerAddress(), BTA_AV_SINK_MEDIA_CFG_EVT, &av_sink_codec_info); in bta_av_setconfig_rsp()
1092 AVDT_ConfigRsp(p_scb->avdt_handle, p_scb->avdt_label, in bta_av_setconfig_rsp()
1095 alarm_cancel(p_scb->link_signalling_timer); in bta_av_setconfig_rsp()
1098 p_scb->wait = BTA_AV_WAIT_ACP_CAPS_ON; in bta_av_setconfig_rsp()
1100 p_scb->role |= BTA_AV_ROLE_SUSPEND_OPT; in bta_av_setconfig_rsp()
1102 p_data->ci_setconfig.recfg_needed, p_scb->role, num); in bta_av_setconfig_rsp()
1105 p_scb->num_seps = num; in bta_av_setconfig_rsp()
1107 if (p_scb->cur_psc_mask & AVDT_PSC_DELAY_RPT) in bta_av_setconfig_rsp()
1108 p_scb->SetAvdtpVersion(AVDT_VERSION_1_3); in bta_av_setconfig_rsp()
1110 if (A2DP_GetCodecType(p_scb->cfg.codec_info) == A2DP_MEDIA_CT_SBC || in bta_av_setconfig_rsp()
1118 p_scb->p_cos->disc_res(p_scb->hndl, p_scb->PeerAddress(), num, num, 0, in bta_av_setconfig_rsp()
1123 if (p_scb->uuid_int == 0) p_scb->uuid_int = p_scb->open_api.uuid; in bta_av_setconfig_rsp()
1124 bta_av_discover_req(p_scb, NULL); in bta_av_setconfig_rsp()
1131 p_scb->sep_info[i].in_use = false; in bta_av_setconfig_rsp()
1132 p_scb->sep_info[i].tsep = AVDT_TSEP_SNK; in bta_av_setconfig_rsp()
1133 p_scb->sep_info[i].media_type = p_scb->media_type; in bta_av_setconfig_rsp()
1134 p_scb->sep_info[i].seid = p_seid[i - 1]; in bta_av_setconfig_rsp()
1141 if (p_scb->uuid_int == 0) p_scb->uuid_int = p_scb->open_api.uuid; in bta_av_setconfig_rsp()
1142 bta_av_next_getcap(p_scb, p_data); in bta_av_setconfig_rsp()
1156 void bta_av_str_opened(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) { in bta_av_str_opened() argument
1162 p_scb->PeerAddress().ToString().c_str(), p_scb->hndl); in bta_av_str_opened()
1164 msg.hdr.layer_specific = p_scb->hndl; in bta_av_str_opened()
1166 msg.peer_addr = p_scb->PeerAddress(); in bta_av_str_opened()
1167 p_scb->l2c_cid = AVDT_GetL2CapChannel(p_scb->avdt_handle); in bta_av_str_opened()
1170 p_scb->cong = true; in bta_av_str_opened()
1171 p_scb->offload_start_pending = false; in bta_av_str_opened()
1173 btif_storage_get_stored_remote_name(p_scb->PeerAddress(), remote_name); in bta_av_str_opened()
1176 &p_scb->PeerAddress())) { in bta_av_str_opened()
1178 __func__, remote_name, p_scb->PeerAddress().ToString().c_str()); in bta_av_str_opened()
1179 p_scb->suspend_sup = false; in bta_av_str_opened()
1182 p_scb->stream_mtu = in bta_av_str_opened()
1184 APPL_TRACE_DEBUG("%s: l2c_cid: 0x%x stream_mtu: %d", __func__, p_scb->l2c_cid, in bta_av_str_opened()
1185 p_scb->stream_mtu); in bta_av_str_opened()
1188 L2CA_SetTxPriority(p_scb->l2c_cid, L2CAP_CHNL_PRIORITY_HIGH); in bta_av_str_opened()
1189 L2CA_SetChnlFlushability(p_scb->l2c_cid, true); in bta_av_str_opened()
1191 bta_sys_conn_open(BTA_ID_AV, p_scb->app_id, p_scb->PeerAddress()); in bta_av_str_opened()
1192 memset(&p_scb->q_info, 0, sizeof(tBTA_AV_Q_INFO)); in bta_av_str_opened()
1194 p_scb->l2c_bufs = 0; in bta_av_str_opened()
1195 p_scb->p_cos->open(p_scb->hndl, p_scb->PeerAddress(), p_scb->stream_mtu); in bta_av_str_opened()
1209 open.bd_addr = p_scb->PeerAddress(); in bta_av_str_opened()
1210 open.chnl = p_scb->chnl; in bta_av_str_opened()
1211 open.hndl = p_scb->hndl; in bta_av_str_opened()
1214 p = BTM_ReadRemoteFeatures(p_scb->PeerAddress()); in bta_av_str_opened()
1219 &p_scb->PeerAddress())) { in bta_av_str_opened()
1224 bta_ar_avdt_conn(BTA_ID_AV, open.bd_addr, p_scb->hdi); in bta_av_str_opened()
1225 if (p_scb->seps[p_scb->sep_idx].tsep == AVDT_TSEP_SRC) { in bta_av_str_opened()
1228 } else if (p_scb->seps[p_scb->sep_idx].tsep == AVDT_TSEP_SNK) { in bta_av_str_opened()
1229 open.starting = bta_av_chk_start(p_scb); in bta_av_str_opened()
1237 bta_av_ssm_execute(p_scb, BTA_AV_AP_START_EVT, NULL); in bta_av_str_opened()
1246 AVDT_AbortReq(p_scb->avdt_handle); in bta_av_str_opened()
1259 void bta_av_security_ind(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) { in bta_av_security_ind() argument
1260 p_scb->avdt_label = p_data->str_msg.msg.hdr.label; in bta_av_security_ind()
1264 protect_req.chnl = p_scb->chnl; in bta_av_security_ind()
1265 protect_req.hndl = p_scb->hndl; in bta_av_security_ind()
1275 AVDT_SecurityRsp(p_scb->avdt_handle, p_scb->avdt_label, AVDT_ERR_NSC, NULL, in bta_av_security_ind()
1289 void bta_av_security_cfm(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) { in bta_av_security_cfm() argument
1292 protect_rsp.chnl = p_scb->chnl; in bta_av_security_cfm()
1293 protect_rsp.hndl = p_scb->hndl; in bta_av_security_cfm()
1313 void bta_av_do_close(tBTA_AV_SCB* p_scb, UNUSED_ATTR tBTA_AV_DATA* p_data) { in bta_av_do_close() argument
1314 APPL_TRACE_DEBUG("%s: p_scb->co_started=%d", __func__, p_scb->co_started); in bta_av_do_close()
1317 if (p_scb->co_started) { in bta_av_do_close()
1318 bta_av_str_stopped(p_scb, NULL); in bta_av_do_close()
1320 alarm_cancel(p_scb->link_signalling_timer); in bta_av_do_close()
1323 p_scb->started = false; in bta_av_do_close()
1324 p_scb->use_rtp_header_marker_bit = false; in bta_av_do_close()
1327 L2CA_FlushChannel(p_scb->l2c_cid, L2CAP_FLUSH_CHANS_ALL); in bta_av_do_close()
1329 AVDT_CloseReq(p_scb->avdt_handle); in bta_av_do_close()
1335 bta_sys_start_timer(p_scb->avrc_ct_timer, BTA_AV_CLOSE_REQ_TIME_VAL, in bta_av_do_close()
1336 BTA_AV_API_CLOSE_EVT, p_scb->hndl); in bta_av_do_close()
1348 void bta_av_connect_req(tBTA_AV_SCB* p_scb, UNUSED_ATTR tBTA_AV_DATA* p_data) { in bta_av_connect_req() argument
1350 p_scb->PeerAddress().ToString().c_str(), p_scb->coll_mask); in bta_av_connect_req()
1351 p_scb->sdp_discovery_started = false; in bta_av_connect_req()
1352 if (p_scb->coll_mask & BTA_AV_COLL_INC_TMR) { in bta_av_connect_req()
1356 p_scb->coll_mask); in bta_av_connect_req()
1357 p_scb->coll_mask |= BTA_AV_COLL_API_CALLED; in bta_av_connect_req()
1359 p_scb->coll_mask); in bta_av_connect_req()
1363 AVDT_ConnectReq(p_scb->PeerAddress(), p_scb->hdi, &bta_av_proc_stream_evt); in bta_av_connect_req()
1375 void bta_av_sdp_failed(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) { in bta_av_sdp_failed() argument
1377 p_scb->PeerAddress().ToString().c_str(), p_scb->open_status); in bta_av_sdp_failed()
1379 if (p_scb->open_status == BTA_AV_SUCCESS) { in bta_av_sdp_failed()
1380 p_scb->open_status = BTA_AV_FAIL_SDP; in bta_av_sdp_failed()
1383 p_scb->sdp_discovery_started = false; in bta_av_sdp_failed()
1384 bta_av_str_closed(p_scb, p_data); in bta_av_sdp_failed()
1398 void bta_av_disc_results(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) { in bta_av_disc_results() argument
1401 uint16_t uuid_int = p_scb->uuid_int; in bta_av_disc_results()
1404 p_scb->PeerAddress().ToString().c_str(), p_scb->hndl, in bta_av_disc_results()
1408 p_scb->num_seps = p_data->str_msg.msg.discover_cfm.num_seps; in bta_av_disc_results()
1410 for (i = 0; i < p_scb->num_seps; i++) { in bta_av_disc_results()
1412 if ((!p_scb->sep_info[i].in_use) && in bta_av_disc_results()
1413 (p_scb->sep_info[i].media_type == p_scb->media_type)) { in bta_av_disc_results()
1414 if ((p_scb->sep_info[i].tsep == AVDT_TSEP_SNK) && in bta_av_disc_results()
1418 if ((p_scb->sep_info[i].tsep == AVDT_TSEP_SRC) && in bta_av_disc_results()
1424 p_scb->p_cos->disc_res(p_scb->hndl, p_scb->PeerAddress(), p_scb->num_seps, in bta_av_disc_results()
1426 p_scb->num_disc_snks = num_snks; in bta_av_disc_results()
1427 p_scb->num_disc_srcs = num_srcs; in bta_av_disc_results()
1430 if (p_scb->num_seps > 0) { in bta_av_disc_results()
1432 p_scb->sep_info_idx = 0; in bta_av_disc_results()
1435 bta_av_next_getcap(p_scb, p_data); in bta_av_disc_results()
1440 p_scb->PeerAddress().ToString().c_str()); in bta_av_disc_results()
1441 bta_av_ssm_execute(p_scb, BTA_AV_STR_DISC_FAIL_EVT, p_data); in bta_av_disc_results()
1456 void bta_av_disc_res_as_acp(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) { in bta_av_disc_res_as_acp() argument
1460 p_scb->PeerAddress().ToString().c_str(), p_scb->hndl); in bta_av_disc_res_as_acp()
1463 p_scb->num_seps = p_data->str_msg.msg.discover_cfm.num_seps; in bta_av_disc_res_as_acp()
1465 for (i = 0; i < p_scb->num_seps; i++) { in bta_av_disc_res_as_acp()
1467 if ((p_scb->sep_info[i].tsep == AVDT_TSEP_SNK) && in bta_av_disc_res_as_acp()
1468 (p_scb->sep_info[i].media_type == p_scb->media_type)) { in bta_av_disc_res_as_acp()
1469 p_scb->sep_info[i].in_use = false; in bta_av_disc_res_as_acp()
1473 p_scb->p_cos->disc_res(p_scb->hndl, p_scb->PeerAddress(), p_scb->num_seps, in bta_av_disc_res_as_acp()
1475 p_scb->num_disc_snks = num_snks; in bta_av_disc_res_as_acp()
1476 p_scb->num_disc_srcs = 0; in bta_av_disc_res_as_acp()
1479 if (p_scb->num_seps > 0) { in bta_av_disc_res_as_acp()
1481 p_scb->sep_info_idx = 0; in bta_av_disc_res_as_acp()
1484 bta_av_next_getcap(p_scb, p_data); in bta_av_disc_res_as_acp()
1489 p_scb->PeerAddress().ToString().c_str()); in bta_av_disc_res_as_acp()
1490 bta_av_ssm_execute(p_scb, BTA_AV_STR_DISC_FAIL_EVT, p_data); in bta_av_disc_res_as_acp()
1503 void bta_av_save_caps(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) { in bta_av_save_caps() argument
1505 tAVDT_SEP_INFO* p_info = &p_scb->sep_info[p_scb->sep_info_idx]; in bta_av_save_caps()
1506 uint8_t old_wait = p_scb->wait; in bta_av_save_caps()
1511 __func__, p_scb->PeerAddress().ToString().c_str(), p_scb->hndl, in bta_av_save_caps()
1512 p_scb->num_seps, p_scb->sep_info_idx, p_scb->wait); in bta_av_save_caps()
1514 A2DP_CodecInfoString(p_scb->peer_cap.codec_info).c_str()); in bta_av_save_caps()
1516 cfg = p_scb->peer_cap; in bta_av_save_caps()
1518 if (p_scb->p_cos->getcfg(p_scb->hndl, p_scb->PeerAddress(), cfg.codec_info, in bta_av_save_caps()
1519 &p_scb->sep_info_idx, p_info->seid, &cfg.num_protect, in bta_av_save_caps()
1521 p_scb->sep_info_idx++; in bta_av_save_caps()
1523 p_scb->sep_info_idx); in bta_av_save_caps()
1528 p_scb->sep_info_idx); in bta_av_save_caps()
1533 if (p_scb->num_seps > p_scb->sep_info_idx && !getcap_done) { in bta_av_save_caps()
1538 if (!bta_av_next_getcap(p_scb, p_data)) getcap_done = true; in bta_av_save_caps()
1545 __func__, p_scb->num_seps, p_scb->sep_info_idx, in bta_av_save_caps()
1546 p_scb->wait); in bta_av_save_caps()
1547 p_scb->wait &= ~(BTA_AV_WAIT_ACP_CAPS_ON | BTA_AV_WAIT_ACP_CAPS_STARTED); in bta_av_save_caps()
1549 bta_av_start_ok(p_scb, NULL); in bta_av_save_caps()
1563 void bta_av_set_use_rc(tBTA_AV_SCB* p_scb, UNUSED_ATTR tBTA_AV_DATA* p_data) { in bta_av_set_use_rc() argument
1564 p_scb->use_rc = true; in bta_av_set_use_rc()
1576 void bta_av_cco_close(tBTA_AV_SCB* p_scb, UNUSED_ATTR tBTA_AV_DATA* p_data) { in bta_av_cco_close() argument
1578 p_scb->PeerAddress().ToString().c_str(), p_scb->hndl); in bta_av_cco_close()
1579 p_scb->p_cos->close(p_scb->hndl, p_scb->PeerAddress()); in bta_av_cco_close()
1591 void bta_av_open_failed(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) { in bta_av_open_failed() argument
1597 p_scb->PeerAddress().ToString().c_str()); in bta_av_open_failed()
1598 p_scb->open_status = BTA_AV_FAIL_STREAM; in bta_av_open_failed()
1599 bta_av_cco_close(p_scb, p_data); in bta_av_open_failed()
1604 p_opened_scb = bta_av_cb.p_scb[idx]; in bta_av_open_failed()
1606 (p_opened_scb->PeerAddress() == p_scb->PeerAddress())) in bta_av_open_failed()
1615 open.bd_addr = p_scb->PeerAddress(); in bta_av_open_failed()
1616 open.chnl = p_scb->chnl; in bta_av_open_failed()
1617 open.hndl = p_scb->hndl; in bta_av_open_failed()
1619 open.starting = bta_av_chk_start(p_scb); in bta_av_open_failed()
1622 bta_av_set_scb_sst_init(p_scb); in bta_av_open_failed()
1624 if (p_scb->seps[p_scb->sep_idx].tsep == AVDT_TSEP_SRC) { in bta_av_open_failed()
1626 } else if (p_scb->seps[p_scb->sep_idx].tsep == AVDT_TSEP_SNK) { in bta_av_open_failed()
1640 AVDT_DisconnectReq(p_scb->PeerAddress(), &bta_av_proc_stream_evt); in bta_av_open_failed()
1655 void bta_av_getcap_results(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) { in bta_av_getcap_results() argument
1656 AvdtpSepConfig cfg = p_scb->cfg; in bta_av_getcap_results()
1657 uint8_t media_type = A2DP_GetMediaType(p_scb->peer_cap.codec_info); in bta_av_getcap_results()
1658 tAVDT_SEP_INFO* p_info = &p_scb->sep_info[p_scb->sep_info_idx]; in bta_av_getcap_results()
1661 cfg.num_protect = p_scb->peer_cap.num_protect; in bta_av_getcap_results()
1662 memcpy(cfg.codec_info, p_scb->peer_cap.codec_info, AVDT_CODEC_SIZE); in bta_av_getcap_results()
1663 memcpy(cfg.protect_info, p_scb->peer_cap.protect_info, AVDT_PROTECT_SIZE); in bta_av_getcap_results()
1666 __func__, p_scb->PeerAddress().ToString().c_str(), in bta_av_getcap_results()
1667 p_scb->hndl, p_scb->peer_cap.num_codec, p_scb->cfg.psc_mask); in bta_av_getcap_results()
1669 p_scb->media_type); in bta_av_getcap_results()
1671 A2DP_CodecInfoString(p_scb->cfg.codec_info).c_str()); in bta_av_getcap_results()
1674 if ((p_scb->peer_cap.num_codec != 0) && (media_type == p_scb->media_type) && in bta_av_getcap_results()
1675 (p_scb->p_cos->getcfg(p_scb->hndl, p_scb->PeerAddress(), cfg.codec_info, in bta_av_getcap_results()
1676 &p_scb->sep_info_idx, p_info->seid, in bta_av_getcap_results()
1680 uint16_t uuid_int = p_scb->uuid_int; in bta_av_getcap_results()
1683 p_scb->cfg = cfg; in bta_av_getcap_results()
1686 p_scb->sep_info_idx); in bta_av_getcap_results()
1688 A2DP_CodecInfoString(p_scb->cfg.codec_info).c_str()); in bta_av_getcap_results()
1692 bta_av_adjust_seps_idx(p_scb, in bta_av_getcap_results()
1693 bta_av_get_scb_handle(p_scb, AVDT_TSEP_SRC)); in bta_av_getcap_results()
1695 bta_av_adjust_seps_idx(p_scb, in bta_av_getcap_results()
1696 bta_av_get_scb_handle(p_scb, AVDT_TSEP_SNK)); in bta_av_getcap_results()
1698 p_scb->sep_idx, p_scb->avdt_handle, p_scb->hndl); in bta_av_getcap_results()
1701 cfg.psc_mask &= p_scb->peer_cap.psc_mask; in bta_av_getcap_results()
1702 p_scb->cur_psc_mask = cfg.psc_mask; in bta_av_getcap_results()
1706 __func__, p_scb->PeerAddress().ToString().c_str(), p_scb->hndl, in bta_av_getcap_results()
1707 p_scb->sep_idx, p_scb->sep_info_idx, p_scb->cur_psc_mask); in bta_av_getcap_results()
1710 (p_scb->seps[p_scb->sep_idx].p_app_sink_data_cback != NULL)) { in bta_av_getcap_results()
1713 av_sink_codec_info.avk_config.bd_addr = p_scb->PeerAddress(); in bta_av_getcap_results()
1714 av_sink_codec_info.avk_config.codec_info = p_scb->cfg.codec_info; in bta_av_getcap_results()
1715 p_scb->seps[p_scb->sep_idx].p_app_sink_data_cback( in bta_av_getcap_results()
1716 p_scb->PeerAddress(), BTA_AV_SINK_MEDIA_CFG_EVT, &av_sink_codec_info); in bta_av_getcap_results()
1724 AVDT_OpenReq(p_scb->seps[p_scb->sep_idx].av_handle, p_scb->PeerAddress(), in bta_av_getcap_results()
1725 p_scb->hdi, p_scb->sep_info[p_scb->sep_info_idx].seid, &cfg); in bta_av_getcap_results()
1728 p_scb->sep_info_idx++; in bta_av_getcap_results()
1729 bta_av_next_getcap(p_scb, p_data); in bta_av_getcap_results()
1742 void bta_av_setconfig_rej(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) { in bta_av_setconfig_rej() argument
1746 bta_av_adjust_seps_idx(p_scb, avdt_handle); in bta_av_setconfig_rej()
1748 p_scb->sep_idx, p_scb->avdt_handle, p_scb->hndl); in bta_av_setconfig_rej()
1749 AVDT_ConfigRsp(p_scb->avdt_handle, p_scb->avdt_label, AVDT_ERR_UNSUP_CFG, 0); in bta_av_setconfig_rej()
1752 reject.hndl = p_scb->hndl; in bta_av_setconfig_rej()
1768 void bta_av_discover_req(tBTA_AV_SCB* p_scb, UNUSED_ATTR tBTA_AV_DATA* p_data) { in bta_av_discover_req() argument
1771 AVDT_DiscoverReq(p_scb->PeerAddress(), p_scb->hdi, p_scb->sep_info, in bta_av_discover_req()
1784 void bta_av_conn_failed(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) { in bta_av_conn_failed() argument
1786 p_scb->PeerAddress().ToString().c_str(), p_scb->open_status); in bta_av_conn_failed()
1788 p_scb->open_status = BTA_AV_FAIL_STREAM; in bta_av_conn_failed()
1789 bta_av_str_closed(p_scb, p_data); in bta_av_conn_failed()
1801 void bta_av_do_start(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) { in bta_av_do_start() argument
1805 PRIVATE_ADDRESS(p_scb->PeerAddress()), in bta_av_do_start()
1806 logbool(bta_av_cb.sco_occupied).c_str(), p_scb->role, in bta_av_do_start()
1807 logbool(p_scb->started).c_str(), p_scb->wait); in bta_av_do_start()
1810 bta_av_start_failed(p_scb, p_data); in bta_av_do_start()
1818 if ((BTM_GetRole(p_scb->PeerAddress(), &cur_role) == BTM_SUCCESS) && in bta_av_do_start()
1820 BTM_block_role_switch_for(p_scb->PeerAddress()); in bta_av_do_start()
1822 BTM_block_sniff_mode_for(p_scb->PeerAddress()); in bta_av_do_start()
1824 if (p_scb->started) { in bta_av_do_start()
1825 p_scb->role |= BTA_AV_ROLE_START_INT; in bta_av_do_start()
1826 if (p_scb->wait != 0) { in bta_av_do_start()
1830 __func__, p_scb->PeerAddress().ToString().c_str(), in bta_av_do_start()
1831 logbool(bta_av_cb.sco_occupied).c_str(), p_scb->role, in bta_av_do_start()
1832 logbool(p_scb->started).c_str(), p_scb->wait); in bta_av_do_start()
1835 if (p_scb->role & BTA_AV_ROLE_SUSPEND) { in bta_av_do_start()
1836 notify_start_failed(p_scb); in bta_av_do_start()
1838 bta_av_start_ok(p_scb, NULL); in bta_av_do_start()
1843 if ((p_scb->role & BTA_AV_ROLE_START_INT) != 0) { in bta_av_do_start()
1847 __func__, p_scb->PeerAddress().ToString().c_str(), in bta_av_do_start()
1848 logbool(bta_av_cb.sco_occupied).c_str(), p_scb->role, in bta_av_do_start()
1849 logbool(p_scb->started).c_str(), p_scb->wait); in bta_av_do_start()
1853 p_scb->role |= BTA_AV_ROLE_START_INT; in bta_av_do_start()
1854 bta_sys_busy(BTA_ID_AV, bta_av_cb.audio_open_cnt, p_scb->PeerAddress()); in bta_av_do_start()
1855 uint16_t result = AVDT_StartReq(&p_scb->avdt_handle, 1); in bta_av_do_start()
1858 p_scb->PeerAddress().ToString().c_str(), result); in bta_av_do_start()
1859 bta_av_start_failed(p_scb, p_data); in bta_av_do_start()
1864 __func__, p_scb->PeerAddress().ToString().c_str(), in bta_av_do_start()
1865 logbool(bta_av_cb.sco_occupied).c_str(), p_scb->role, in bta_av_do_start()
1866 logbool(p_scb->started).c_str(), p_scb->wait); in bta_av_do_start()
1878 void bta_av_str_stopped(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) { in bta_av_str_stopped() argument
1880 uint8_t start = p_scb->started; in bta_av_str_stopped()
1886 __func__, p_scb->PeerAddress().ToString().c_str(), p_scb->hndl, in bta_av_str_stopped()
1889 bta_sys_idle(BTA_ID_AV, bta_av_cb.audio_open_cnt, p_scb->PeerAddress()); in bta_av_str_stopped()
1890 BTM_unblock_role_switch_for(p_scb->PeerAddress()); in bta_av_str_stopped()
1891 BTM_unblock_sniff_mode_for(p_scb->PeerAddress()); in bta_av_str_stopped()
1893 if (p_scb->co_started) { in bta_av_str_stopped()
1894 if (p_scb->offload_started) { in bta_av_str_stopped()
1896 p_scb->offload_started = false; in bta_av_str_stopped()
1899 bta_av_stream_chg(p_scb, false); in bta_av_str_stopped()
1900 p_scb->co_started = false; in bta_av_str_stopped()
1902 p_scb->p_cos->stop(p_scb->hndl, p_scb->PeerAddress()); in bta_av_str_stopped()
1906 if (BTA_AV_CHNL_AUDIO == p_scb->chnl) { in bta_av_str_stopped()
1907 while (!list_is_empty(p_scb->a2dp_list)) { in bta_av_str_stopped()
1908 p_buf = (BT_HDR*)list_front(p_scb->a2dp_list); in bta_av_str_stopped()
1909 list_remove(p_scb->a2dp_list, p_buf); in bta_av_str_stopped()
1915 L2CA_FlushChannel(p_scb->l2c_cid, L2CAP_FLUSH_CHANS_ALL); in bta_av_str_stopped()
1918 suspend_rsp.chnl = p_scb->chnl; in bta_av_str_stopped()
1919 suspend_rsp.hndl = p_scb->hndl; in bta_av_str_stopped()
1923 p_scb->PeerAddress().ToString().c_str(), start, in bta_av_str_stopped()
1924 p_scb->suspend_sup); in bta_av_str_stopped()
1925 if ((start) && (p_scb->suspend_sup)) { in bta_av_str_stopped()
1927 p_scb->l2c_bufs = 0; in bta_av_str_stopped()
1928 AVDT_SuspendReq(&p_scb->avdt_handle, 1); in bta_av_str_stopped()
1933 if ((sus_evt) && (p_scb->state != BTA_AV_RCFG_SST)) { in bta_av_str_stopped()
1948 if (p_scb->state != BTA_AV_RCFG_SST || in bta_av_str_stopped()
1968 void bta_av_reconfig(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) { in bta_av_reconfig() argument
1973 APPL_TRACE_DEBUG("%s: r:%d, s:%d idx: %d (o:%d)", __func__, p_scb->recfg_sup, in bta_av_reconfig()
1974 p_scb->suspend_sup, p_scb->rcfg_idx, p_scb->sep_info_idx); in bta_av_reconfig()
1976 p_scb->num_recfg = 0; in bta_av_reconfig()
1978 p_cfg = &p_scb->cfg; in bta_av_reconfig()
1980 alarm_cancel(p_scb->avrc_ct_timer); in bta_av_reconfig()
1983 p_scb->sep_info_idx, p_scb->rcfg_idx, p_rcfg->sep_info_idx); in bta_av_reconfig()
1985 A2DP_CodecInfoString(p_scb->peer_cap.codec_info).c_str()); in bta_av_reconfig()
1987 A2DP_CodecInfoString(p_scb->cfg.codec_info).c_str()); in bta_av_reconfig()
1992 kBtmLogTag, p_scb->PeerAddress(), "Codec reconfig", in bta_av_reconfig()
1993 base::StringPrintf("%s => %s", A2DP_CodecName(p_scb->cfg.codec_info), in bta_av_reconfig()
1999 p_scb->rcfg_idx = p_rcfg->sep_info_idx; in bta_av_reconfig()
2000 p_cfg->psc_mask = p_scb->cur_psc_mask; in bta_av_reconfig()
2006 if ((p_scb->rcfg_idx == p_scb->sep_info_idx) && p_rcfg->suspend && in bta_av_reconfig()
2007 p_scb->recfg_sup && p_scb->suspend_sup) { in bta_av_reconfig()
2008 if (p_scb->started) { in bta_av_reconfig()
2013 bta_av_str_stopped(p_scb, (tBTA_AV_DATA*)&stop); in bta_av_reconfig()
2018 A2DP_CodecInfoString(p_scb->cfg.codec_info).c_str()); in bta_av_reconfig()
2019 AVDT_ReconfigReq(p_scb->avdt_handle, &p_scb->cfg); in bta_av_reconfig()
2020 p_scb->cfg.psc_mask = p_scb->cur_psc_mask; in bta_av_reconfig()
2025 __func__, p_scb->started, p_scb->state, in bta_av_reconfig()
2027 if (p_scb->started) { in bta_av_reconfig()
2029 if ((p_scb->rcfg_idx != p_scb->sep_info_idx) && p_scb->recfg_sup) { in bta_av_reconfig()
2035 bta_av_str_stopped(p_scb, (tBTA_AV_DATA*)&stop); in bta_av_reconfig()
2037 bta_av_str_stopped(p_scb, NULL); in bta_av_reconfig()
2039 p_scb->started = false; in bta_av_reconfig()
2042 bta_av_str_stopped(p_scb, NULL); in bta_av_reconfig()
2045 L2CA_FlushChannel(p_scb->l2c_cid, L2CAP_FLUSH_CHANS_ALL); in bta_av_reconfig()
2046 AVDT_CloseReq(p_scb->avdt_handle); in bta_av_reconfig()
2059 void bta_av_data_path(tBTA_AV_SCB* p_scb, UNUSED_ATTR tBTA_AV_DATA* p_data) { in bta_av_data_path() argument
2066 if (!p_scb->started) return; in bta_av_data_path()
2068 if (p_scb->cong) return; in bta_av_data_path()
2070 if (p_scb->use_rtp_header_marker_bit) { in bta_av_data_path()
2075 p_scb->l2c_bufs = in bta_av_data_path()
2076 (uint8_t)L2CA_FlushChannel(p_scb->l2c_cid, L2CAP_FLUSH_CHANS_GET); in bta_av_data_path()
2078 if (!list_is_empty(p_scb->a2dp_list)) { in bta_av_data_path()
2079 p_buf = (BT_HDR*)list_front(p_scb->a2dp_list); in bta_av_data_path()
2080 list_remove(p_scb->a2dp_list, p_buf); in bta_av_data_path()
2086 p_buf = p_scb->p_cos->data(p_scb->cfg.codec_info, &timestamp); in bta_av_data_path()
2093 bta_av_dup_audio_buf(p_scb, p_buf); in bta_av_data_path()
2098 if (p_scb->l2c_bufs < (BTA_AV_QUEUE_DATA_CHK_NUM)) { in bta_av_data_path()
2106 if (p_scb->no_rtp_header) { in bta_av_data_path()
2116 extra_fragments_n = (p_buf->len / p_scb->stream_mtu) + in bta_av_data_path()
2117 ((p_buf->len % p_scb->stream_mtu) ? 1 : 0) - 1; in bta_av_data_path()
2125 data_begin += p_scb->stream_mtu; in bta_av_data_path()
2127 if (fragment_len > p_scb->stream_mtu) fragment_len = p_scb->stream_mtu; in bta_av_data_path()
2145 AVDT_WriteReqOpt(p_scb->avdt_handle, p_buf, timestamp, m_pt, opt); in bta_av_data_path()
2152 AVDT_WriteReqOpt(p_scb->avdt_handle, p_buf2, timestamp, m_pt, opt); in bta_av_data_path()
2154 p_scb->cong = true; in bta_av_data_path()
2160 list_append(p_scb->a2dp_list, p_buf); in bta_av_data_path()
2163 if (list_length(p_scb->a2dp_list) < 3) { in bta_av_data_path()
2165 list_prepend(p_scb->a2dp_list, p_buf); in bta_av_data_path()
2168 bta_av_co_audio_drop(p_scb->hndl, p_scb->PeerAddress()); in bta_av_data_path()
2185 void bta_av_start_ok(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) { in bta_av_start_ok() argument
2188 uint8_t new_role = p_scb->role; in bta_av_start_ok()
2191 uint8_t local_tsep = p_scb->seps[p_scb->sep_idx].tsep; in bta_av_start_ok()
2194 __func__, p_scb->PeerAddress().ToString().c_str(), p_scb->hndl, in bta_av_start_ok()
2195 p_scb->wait, p_scb->role, local_tsep); in bta_av_start_ok()
2197 p_scb->started = true; in bta_av_start_ok()
2202 bta_av_get_a2dp_peer_current_codec(p_scb->PeerAddress()); in bta_av_start_ok()
2204 p_scb->use_rtp_header_marker_bit = codec_config->useRtpHeaderMarkerBit(); in bta_av_start_ok()
2207 if (p_scb->sco_suspend) { in bta_av_start_ok()
2208 p_scb->sco_suspend = false; in bta_av_start_ok()
2214 if ((p_scb->avdt_handle == p_scb->seps[p_scb->sep_idx].av_handle) && in bta_av_start_ok()
2216 p_scb->wait &= ~(BTA_AV_WAIT_ACP_CAPS_ON); in bta_av_start_ok()
2218 p_scb->wait); in bta_av_start_ok()
2220 if (p_scb->wait & BTA_AV_WAIT_ROLE_SW_FAILED) { in bta_av_start_ok()
2224 __func__, p_scb->PeerAddress().ToString().c_str(), p_scb->hndl, in bta_av_start_ok()
2225 p_scb->wait, p_scb->role); in bta_av_start_ok()
2226 p_scb->wait &= ~BTA_AV_WAIT_ROLE_SW_FAILED; in bta_av_start_ok()
2231 __func__, p_scb->PeerAddress().ToString().c_str(), in bta_av_start_ok()
2232 p_scb->wait, in bta_av_start_ok()
2233 (p_scb->use_rtp_header_marker_bit) ? "true" : "false"); in bta_av_start_ok()
2236 p_scb->wait &= ~BTA_AV_WAIT_ROLE_SW_BITS; in bta_av_start_ok()
2238 bta_sys_idle(BTA_ID_AV, bta_av_cb.audio_open_cnt, p_scb->PeerAddress()); in bta_av_start_ok()
2240 start.chnl = p_scb->chnl; in bta_av_start_ok()
2242 start.hndl = p_scb->hndl; in bta_av_start_ok()
2251 if (!bta_av_link_role_ok(p_scb, A2DP_SET_ONE_BIT)) in bta_av_start_ok()
2252 p_scb->q_tag = BTA_AV_Q_TAG_START; in bta_av_start_ok()
2260 p_scb->wait &= ~BTA_AV_WAIT_ROLE_SW_BITS; in bta_av_start_ok()
2263 if (p_scb->wait & in bta_av_start_ok()
2265 p_scb->wait |= BTA_AV_WAIT_ROLE_SW_STARTED; in bta_av_start_ok()
2266 p_scb->q_tag = BTA_AV_Q_TAG_START; in bta_av_start_ok()
2269 if (p_scb->wait) { in bta_av_start_ok()
2271 p_scb->PeerAddress().ToString().c_str(), p_scb->wait, in bta_av_start_ok()
2272 p_scb->q_tag); in bta_av_start_ok()
2280 p_scb->wait &= ~BTA_AV_WAIT_ACP_CAPS_ON; in bta_av_start_ok()
2284 bta_sys_conn_open(BTA_ID_AV, p_scb->app_id, p_scb->PeerAddress()); in bta_av_start_ok()
2286 bta_sys_busy(BTA_ID_AV, bta_av_cb.audio_open_cnt, p_scb->PeerAddress()); in bta_av_start_ok()
2288 if (p_scb->media_type == AVDT_MEDIA_TYPE_AUDIO) { in bta_av_start_ok()
2295 p_scb->co_started = bta_av_cb.audio_open_cnt; in bta_av_start_ok()
2299 p_scb->cong = false; in bta_av_start_ok()
2309 p_scb->q_tag = BTA_AV_Q_TAG_STREAM; in bta_av_start_ok()
2310 bta_av_stream_chg(p_scb, true); in bta_av_start_ok()
2320 if ((BTM_GetRole(p_scb->PeerAddress(), &cur_role) == BTM_SUCCESS) && in bta_av_start_ok()
2322 BTM_block_role_switch_for(p_scb->PeerAddress()); in bta_av_start_ok()
2326 p_scb->role = new_role; in bta_av_start_ok()
2327 p_scb->role &= ~BTA_AV_ROLE_AD_ACP; in bta_av_start_ok()
2328 p_scb->role &= ~BTA_AV_ROLE_SUSPEND_OPT; in bta_av_start_ok()
2330 p_scb->no_rtp_header = false; in bta_av_start_ok()
2331 p_scb->p_cos->start(p_scb->hndl, p_scb->PeerAddress(), in bta_av_start_ok()
2332 p_scb->cfg.codec_info, &p_scb->no_rtp_header); in bta_av_start_ok()
2333 p_scb->co_started = true; in bta_av_start_ok()
2336 p_scb->PeerAddress().ToString().c_str(), suspend, in bta_av_start_ok()
2337 p_scb->role, initiator); in bta_av_start_ok()
2342 start.chnl = p_scb->chnl; in bta_av_start_ok()
2344 start.hndl = p_scb->hndl; in bta_av_start_ok()
2351 p_scb->role |= BTA_AV_ROLE_SUSPEND; in bta_av_start_ok()
2352 p_scb->cong = true; /* do not allow the media data to go through */ in bta_av_start_ok()
2354 p_scb->p_cos->stop(p_scb->hndl, p_scb->PeerAddress()); in bta_av_start_ok()
2355 p_scb->co_started = false; in bta_av_start_ok()
2359 bta_av_ssm_execute(p_scb, BTA_AV_AP_STOP_EVT, (tBTA_AV_DATA*)&stop); in bta_av_start_ok()
2373 void bta_av_start_failed(tBTA_AV_SCB* p_scb, UNUSED_ATTR tBTA_AV_DATA* p_data) { in bta_av_start_failed() argument
2376 __func__, p_scb->PeerAddress().ToString().c_str(), p_scb->hndl, in bta_av_start_failed()
2377 bta_av_cb.audio_open_cnt, logbool(p_scb->started).c_str(), in bta_av_start_failed()
2378 p_scb->co_started); in bta_av_start_failed()
2380 if (!p_scb->started && !p_scb->co_started) { in bta_av_start_failed()
2381 bta_sys_idle(BTA_ID_AV, bta_av_cb.audio_open_cnt, p_scb->PeerAddress()); in bta_av_start_failed()
2382 notify_start_failed(p_scb); in bta_av_start_failed()
2385 BTM_unblock_role_switch_for(p_scb->PeerAddress()); in bta_av_start_failed()
2386 BTM_unblock_sniff_mode_for(p_scb->PeerAddress()); in bta_av_start_failed()
2387 p_scb->sco_suspend = false; in bta_av_start_failed()
2399 void bta_av_str_closed(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) { in bta_av_str_closed() argument
2405 __func__, p_scb->PeerAddress().ToString().c_str(), p_scb->hndl, in bta_av_str_closed()
2406 p_scb->open_status, p_scb->chnl, p_scb->co_started); in bta_av_str_closed()
2408 BTM_unblock_role_switch_for(p_scb->PeerAddress()); in bta_av_str_closed()
2409 BTM_unblock_sniff_mode_for(p_scb->PeerAddress()); in bta_av_str_closed()
2414 if (p_scb->open_status != BTA_AV_SUCCESS) { in bta_av_str_closed()
2416 data.open.bd_addr = p_scb->PeerAddress(); in bta_av_str_closed()
2417 data.open.status = p_scb->open_status; in bta_av_str_closed()
2418 data.open.chnl = p_scb->chnl; in bta_av_str_closed()
2419 data.open.hndl = p_scb->hndl; in bta_av_str_closed()
2421 if (p_scb->seps[p_scb->sep_idx].tsep == AVDT_TSEP_SRC) in bta_av_str_closed()
2423 else if (p_scb->seps[p_scb->sep_idx].tsep == AVDT_TSEP_SNK) in bta_av_str_closed()
2427 p_scb->open_status = BTA_AV_SUCCESS; in bta_av_str_closed()
2429 bta_sys_conn_close(BTA_ID_AV, p_scb->app_id, p_scb->PeerAddress()); in bta_av_str_closed()
2430 bta_av_cleanup(p_scb, p_data); in bta_av_str_closed()
2434 if (p_scb->co_started) { in bta_av_str_closed()
2435 bta_av_str_stopped(p_scb, NULL); in bta_av_str_closed()
2439 p_scb->p_cos->close(p_scb->hndl, p_scb->PeerAddress()); in bta_av_str_closed()
2440 data.close.chnl = p_scb->chnl; in bta_av_str_closed()
2441 data.close.hndl = p_scb->hndl; in bta_av_str_closed()
2444 bta_sys_conn_close(BTA_ID_AV, p_scb->app_id, p_scb->PeerAddress()); in bta_av_str_closed()
2445 bta_av_cleanup(p_scb, p_data); in bta_av_str_closed()
2460 void bta_av_clr_cong(tBTA_AV_SCB* p_scb, UNUSED_ATTR tBTA_AV_DATA* p_data) { in bta_av_clr_cong() argument
2462 if (p_scb->co_started) { in bta_av_clr_cong()
2463 p_scb->cong = false; in bta_av_clr_cong()
2476 void bta_av_suspend_cfm(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) { in bta_av_suspend_cfm() argument
2481 __func__, p_scb->PeerAddress().ToString().c_str(), in bta_av_suspend_cfm()
2482 p_scb->hndl, bta_av_cb.audio_open_cnt, err_code); in bta_av_suspend_cfm()
2484 if (!p_scb->started) { in bta_av_suspend_cfm()
2501 bta_av_ssm_execute(p_scb, BTA_AV_API_CLOSE_EVT, NULL); in bta_av_suspend_cfm()
2504 p_scb->started = false; in bta_av_suspend_cfm()
2507 if (p_scb->role & BTA_AV_ROLE_SUSPEND) { in bta_av_suspend_cfm()
2508 p_scb->role &= ~BTA_AV_ROLE_SUSPEND; in bta_av_suspend_cfm()
2509 p_scb->cong = false; in bta_av_suspend_cfm()
2512 bta_sys_idle(BTA_ID_AV, bta_av_cb.audio_open_cnt, p_scb->PeerAddress()); in bta_av_suspend_cfm()
2513 BTM_unblock_role_switch_for(p_scb->PeerAddress()); in bta_av_suspend_cfm()
2514 BTM_unblock_sniff_mode_for(p_scb->PeerAddress()); in bta_av_suspend_cfm()
2517 if (p_scb->co_started) { in bta_av_suspend_cfm()
2518 if (p_scb->offload_started) { in bta_av_suspend_cfm()
2520 p_scb->offload_started = false; in bta_av_suspend_cfm()
2522 bta_av_stream_chg(p_scb, false); in bta_av_suspend_cfm()
2525 p_scb->co_started = false; in bta_av_suspend_cfm()
2526 p_scb->p_cos->stop(p_scb->hndl, p_scb->PeerAddress()); in bta_av_suspend_cfm()
2531 suspend_rsp.chnl = p_scb->chnl; in bta_av_suspend_cfm()
2532 suspend_rsp.hndl = p_scb->hndl; in bta_av_suspend_cfm()
2549 void bta_av_rcfg_str_ok(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) { in bta_av_rcfg_str_ok() argument
2550 p_scb->l2c_cid = AVDT_GetL2CapChannel(p_scb->avdt_handle); in bta_av_rcfg_str_ok()
2552 p_scb->PeerAddress().ToString().c_str(), p_scb->hndl, in bta_av_rcfg_str_ok()
2553 p_scb->l2c_cid); in bta_av_rcfg_str_ok()
2557 p_scb->stream_mtu = in bta_av_rcfg_str_ok()
2560 p_scb->l2c_cid, p_scb->stream_mtu); in bta_av_rcfg_str_ok()
2561 p_scb->p_cos->update_mtu(p_scb->hndl, p_scb->PeerAddress(), in bta_av_rcfg_str_ok()
2562 p_scb->stream_mtu); in bta_av_rcfg_str_ok()
2566 bta_av_st_rc_timer(p_scb, NULL); in bta_av_rcfg_str_ok()
2569 p_scb->role &= ~BTA_AV_ROLE_AD_ACP; in bta_av_rcfg_str_ok()
2570 p_scb->role &= ~BTA_AV_ROLE_SUSPEND_OPT; in bta_av_rcfg_str_ok()
2571 p_scb->role &= ~BTA_AV_ROLE_START_INT; in bta_av_rcfg_str_ok()
2577 reconfig.chnl = p_scb->chnl; in bta_av_rcfg_str_ok()
2578 reconfig.hndl = p_scb->hndl; in bta_av_rcfg_str_ok()
2594 void bta_av_rcfg_failed(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) { in bta_av_rcfg_failed() argument
2596 p_scb->num_recfg, bta_av_cb.conn_lcb, in bta_av_rcfg_failed()
2597 p_scb->PeerAddress().ToString().c_str()); in bta_av_rcfg_failed()
2599 if (p_scb->num_recfg > BTA_AV_RECONFIG_RETRY) { in bta_av_rcfg_failed()
2600 bta_av_cco_close(p_scb, p_data); in bta_av_rcfg_failed()
2604 reconfig.chnl = p_scb->chnl; in bta_av_rcfg_failed()
2605 reconfig.hndl = p_scb->hndl; in bta_av_rcfg_failed()
2610 bta_av_ssm_execute(p_scb, BTA_AV_API_CLOSE_EVT, NULL); in bta_av_rcfg_failed()
2613 p_scb->num_recfg++; in bta_av_rcfg_failed()
2616 if ((bta_av_cb.conn_lcb & (1 << p_scb->hdi)) != 0) { in bta_av_rcfg_failed()
2617 AVDT_DisconnectReq(p_scb->PeerAddress(), &bta_av_proc_stream_evt); in bta_av_rcfg_failed()
2620 __func__, bta_av_cb.conn_lcb, p_scb->hndl, p_scb->hdi); in bta_av_rcfg_failed()
2621 bta_av_connect_req(p_scb, NULL); in bta_av_rcfg_failed()
2635 void bta_av_rcfg_connect(tBTA_AV_SCB* p_scb, UNUSED_ATTR tBTA_AV_DATA* p_data) { in bta_av_rcfg_connect() argument
2638 p_scb->cong = false; in bta_av_rcfg_connect()
2639 p_scb->num_recfg++; in bta_av_rcfg_connect()
2640 APPL_TRACE_DEBUG("%s: num_recfg: %d", __func__, p_scb->num_recfg); in bta_av_rcfg_connect()
2641 if (p_scb->num_recfg > BTA_AV_RECONFIG_RETRY) { in bta_av_rcfg_connect()
2643 bta_av_rcfg_failed(p_scb, NULL); in bta_av_rcfg_connect()
2645 AVDT_ConnectReq(p_scb->PeerAddress(), p_scb->hdi, &bta_av_proc_stream_evt); in bta_av_rcfg_connect()
2658 void bta_av_rcfg_discntd(tBTA_AV_SCB* p_scb, UNUSED_ATTR tBTA_AV_DATA* p_data) { in bta_av_rcfg_discntd() argument
2660 p_scb->num_recfg, bta_av_cb.conn_lcb, in bta_av_rcfg_discntd()
2661 p_scb->PeerAddress().ToString().c_str()); in bta_av_rcfg_discntd()
2663 p_scb->num_recfg++; in bta_av_rcfg_discntd()
2664 if (p_scb->num_recfg > BTA_AV_RECONFIG_RETRY) { in bta_av_rcfg_discntd()
2668 reconfig.chnl = p_scb->chnl; in bta_av_rcfg_discntd()
2669 reconfig.hndl = p_scb->hndl; in bta_av_rcfg_discntd()
2674 bta_av_ssm_execute(p_scb, BTA_AV_STR_DISC_FAIL_EVT, NULL); in bta_av_rcfg_discntd()
2676 AVDT_ConnectReq(p_scb->PeerAddress(), p_scb->hdi, &bta_av_proc_stream_evt); in bta_av_rcfg_discntd()
2690 void bta_av_suspend_cont(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) { in bta_av_suspend_cont() argument
2695 p_scb->started = false; in bta_av_suspend_cont()
2696 p_scb->cong = false; in bta_av_suspend_cont()
2706 p_scb->PeerAddress().ToString().c_str()); in bta_av_suspend_cont()
2707 bta_av_ssm_execute(p_scb, BTA_AV_STR_DISC_FAIL_EVT, NULL); in bta_av_suspend_cont()
2711 L2CA_FlushChannel(p_scb->l2c_cid, L2CAP_FLUSH_CHANS_ALL); in bta_av_suspend_cont()
2713 AVDT_CloseReq(p_scb->avdt_handle); in bta_av_suspend_cont()
2720 A2DP_CodecInfoString(p_scb->cfg.codec_info).c_str()); in bta_av_suspend_cont()
2721 AVDT_ReconfigReq(p_scb->avdt_handle, &p_scb->cfg); in bta_av_suspend_cont()
2722 p_scb->cfg.psc_mask = p_scb->cur_psc_mask; in bta_av_suspend_cont()
2736 void bta_av_rcfg_cfm(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) { in bta_av_rcfg_cfm() argument
2745 if (btif_storage_get_stored_remote_name(p_scb->PeerAddress(), in bta_av_rcfg_cfm()
2749 (const RawAddress*)&p_scb->PeerAddress())) { in bta_av_rcfg_cfm()
2753 __func__, remote_name, p_scb->PeerAddress().ToString().c_str()); in bta_av_rcfg_cfm()
2764 p_scb->recfg_sup = false; in bta_av_rcfg_cfm()
2768 L2CA_FlushChannel(p_scb->l2c_cid, L2CAP_FLUSH_CHANS_ALL); in bta_av_rcfg_cfm()
2769 AVDT_CloseReq(p_scb->avdt_handle); in bta_av_rcfg_cfm()
2774 A2DP_CodecName(p_scb->cfg.codec_info), in bta_av_rcfg_cfm()
2776 memcpy(p_scb->cfg.codec_info, in bta_av_rcfg_cfm()
2779 bta_av_ssm_execute(p_scb, BTA_AV_STR_OPEN_OK_EVT, NULL); in bta_av_rcfg_cfm()
2793 void bta_av_rcfg_open(tBTA_AV_SCB* p_scb, UNUSED_ATTR tBTA_AV_DATA* p_data) { in bta_av_rcfg_open() argument
2795 p_scb->PeerAddress().ToString().c_str(), p_scb->hndl, in bta_av_rcfg_open()
2796 p_scb->num_disc_snks); in bta_av_rcfg_open()
2798 if (p_scb->num_disc_snks == 0) { in bta_av_rcfg_open()
2800 p_scb->p_cos->stop(p_scb->hndl, p_scb->PeerAddress()); in bta_av_rcfg_open()
2803 AVDT_DiscoverReq(p_scb->PeerAddress(), p_scb->hdi, p_scb->sep_info, in bta_av_rcfg_open()
2808 A2DP_CodecInfoString(p_scb->cfg.codec_info).c_str()); in bta_av_rcfg_open()
2812 bta_av_adjust_seps_idx(p_scb, bta_av_get_scb_handle(p_scb, AVDT_TSEP_SRC)); in bta_av_rcfg_open()
2814 p_scb->sep_idx, p_scb->avdt_handle, p_scb->hndl); in bta_av_rcfg_open()
2817 p_scb->sep_info_idx = p_scb->rcfg_idx; in bta_av_rcfg_open()
2818 AVDT_OpenReq(p_scb->avdt_handle, p_scb->PeerAddress(), p_scb->hdi, in bta_av_rcfg_open()
2819 p_scb->sep_info[p_scb->sep_info_idx].seid, &p_scb->cfg); in bta_av_rcfg_open()
2832 void bta_av_security_rej(tBTA_AV_SCB* p_scb, UNUSED_ATTR tBTA_AV_DATA* p_data) { in bta_av_security_rej() argument
2833 AVDT_SecurityRsp(p_scb->avdt_handle, p_scb->avdt_label, AVDT_ERR_BAD_STATE, in bta_av_security_rej()
2848 void bta_av_chk_2nd_start(tBTA_AV_SCB* p_scb, in bta_av_chk_2nd_start() argument
2853 __func__, p_scb->PeerAddress().ToString().c_str(), p_scb->chnl, in bta_av_chk_2nd_start()
2854 bta_av_cb.audio_open_cnt, p_scb->role, bta_av_cb.features); in bta_av_chk_2nd_start()
2856 if ((p_scb->chnl == BTA_AV_CHNL_AUDIO) && (bta_av_cb.audio_open_cnt >= 2) && in bta_av_chk_2nd_start()
2857 (((p_scb->role & BTA_AV_ROLE_AD_ACP) == 0) || // Outgoing connection or in bta_av_chk_2nd_start()
2860 if (!(p_scb->role & BTA_AV_ROLE_SUSPEND_OPT)) { in bta_av_chk_2nd_start()
2865 tBTA_AV_SCB* p_scbi = bta_av_cb.p_scb[i]; in bta_av_chk_2nd_start()
2866 if (p_scb == p_scbi) { in bta_av_chk_2nd_start()
2876 __func__, p_scb->PeerAddress().ToString().c_str(), in bta_av_chk_2nd_start()
2878 bta_av_ssm_execute(p_scb, BTA_AV_AP_START_EVT, NULL); in bta_av_chk_2nd_start()
2899 void bta_av_open_rc(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) { in bta_av_open_rc() argument
2901 p_scb->use_rc, p_scb->wait, p_scb->role); in bta_av_open_rc()
2902 if ((p_scb->wait & BTA_AV_WAIT_ROLE_SW_BITS) && in bta_av_open_rc()
2903 (p_scb->q_tag == BTA_AV_Q_TAG_START)) { in bta_av_open_rc()
2905 if (!bta_av_link_role_ok(p_scb, A2DP_SET_ONE_BIT)) { in bta_av_open_rc()
2909 alarm_cancel(p_scb->avrc_ct_timer); in bta_av_open_rc()
2912 start.chnl = p_scb->chnl; in bta_av_open_rc()
2915 start.hndl = p_scb->hndl; in bta_av_open_rc()
2916 p_scb->wait &= ~BTA_AV_WAIT_ROLE_SW_BITS; in bta_av_open_rc()
2925 bta_av_start_ok(p_scb, p_data); in bta_av_open_rc()
2930 if (p_scb->use_rc || (p_scb->role & BTA_AV_ROLE_AD_ACP)) { in bta_av_open_rc()
2933 if (p_scb->rc_handle == BTA_AV_RC_HANDLE_NONE) { in bta_av_open_rc()
2935 if ((p_scb->wait & BTA_AV_WAIT_ROLE_SW_BITS) == 0) { in bta_av_open_rc()
2936 bta_sys_start_timer(p_scb->avrc_ct_timer, BTA_AV_RC_DISC_TIME_VAL, in bta_av_open_rc()
2937 BTA_AV_AVRC_TIMER_EVT, p_scb->hndl); in bta_av_open_rc()
2939 p_scb->wait |= BTA_AV_WAIT_CHECK_RC; in bta_av_open_rc()
2947 p_scb->PeerAddress()); in bta_av_open_rc()
2949 bta_av_rc_disc((uint8_t)(p_scb->hdi + 1)); in bta_av_open_rc()
2953 if (BTA_AV_RC_HANDLE_NONE != p_scb->rc_handle) { in bta_av_open_rc()
2956 AVRC_Close(p_scb->rc_handle); in bta_av_open_rc()
2971 void bta_av_open_at_inc(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) { in bta_av_open_at_inc() argument
2972 memcpy(&(p_scb->open_api), &(p_data->api_open), sizeof(tBTA_AV_API_OPEN)); in bta_av_open_at_inc()
2975 p_scb->PeerAddress().ToString().c_str(), p_scb->coll_mask); in bta_av_open_at_inc()
2977 if (p_scb->coll_mask & BTA_AV_COLL_INC_TMR) { in bta_av_open_at_inc()
2978 p_scb->coll_mask |= BTA_AV_COLL_API_CALLED; in bta_av_open_at_inc()
2985 p_scb->coll_mask = 0; in bta_av_open_at_inc()
2986 bta_av_set_scb_sst_init(p_scb); in bta_av_open_at_inc()
2990 memcpy(p_buf, &(p_scb->open_api), sizeof(tBTA_AV_API_OPEN)); in bta_av_open_at_inc()
3024 void bta_av_vendor_offload_start(tBTA_AV_SCB* p_scb, in bta_av_vendor_offload_start() argument
3045 p_scb->offload_started = true; in bta_av_vendor_offload_start()
3067 void bta_av_offload_req(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) { in bta_av_offload_req() argument
3072 p_scb->started ? "STARTED" : "STOPPED", in bta_av_offload_req()
3076 if (p_scb->started != true) { in bta_av_offload_req()
3079 bta_av_offload_codec_builder(p_scb, &offload_start); in bta_av_offload_req()
3080 bta_av_vendor_offload_start(p_scb, &offload_start); in bta_av_offload_req()
3135 void bta_av_offload_rsp(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) { in bta_av_offload_rsp() argument
3139 p_scb->started ? "STARTED" : "STOPPED", in bta_av_offload_rsp()
3143 if (status == BTA_AV_SUCCESS && p_scb->started != true) { in bta_av_offload_rsp()
3147 p_scb->offload_start_pending = false; in bta_av_offload_rsp()
3153 static void bta_av_offload_codec_builder(tBTA_AV_SCB* p_scb, in bta_av_offload_codec_builder() argument
3157 A2DP_SourceCodecIndex(p_scb->cfg.codec_info); in bta_av_offload_codec_builder()
3159 uint16_t mtu = p_scb->stream_mtu; in bta_av_offload_codec_builder()
3164 if (A2DP_GetMaxBitpoolSbc(p_scb->cfg.codec_info) <= in bta_av_offload_codec_builder()
3193 p_scb->PeerAddress(), BT_TRANSPORT_BR_EDR); in bta_av_offload_codec_builder()
3195 p_scb->p_cos->get_scmst_info(p_scb->PeerAddress()); in bta_av_offload_codec_builder()
3203 switch (A2DP_GetTrackSampleRate(p_scb->cfg.codec_info)) { in bta_av_offload_codec_builder()
3217 if (L2CA_GetRemoteCid(p_scb->l2c_cid, &p_a2dp_offload->l2c_rcid) == false) { in bta_av_offload_codec_builder()
3232 p_a2dp_offload->ch_mode = A2DP_GetTrackChannelCount(p_scb->cfg.codec_info); in bta_av_offload_codec_builder()