Lines Matching refs:p_scb
135 tBTA_AG_SCB* p_scb = &bta_ag_cb.scb[0]; in bta_ag_scb_alloc() local
138 for (i = 0; i < BTA_AG_MAX_NUM_CLIENTS; i++, p_scb++) { in bta_ag_scb_alloc()
139 if (!p_scb->in_use) { in bta_ag_scb_alloc()
141 p_scb->in_use = true; in bta_ag_scb_alloc()
142 p_scb->sco_idx = BTM_INVALID_SCO_INDEX; in bta_ag_scb_alloc()
143 p_scb->received_at_bac = false; in bta_ag_scb_alloc()
144 p_scb->codec_updated = false; in bta_ag_scb_alloc()
145 p_scb->codec_fallback = false; in bta_ag_scb_alloc()
146 p_scb->peer_codecs = BTA_AG_CODEC_CVSD; in bta_ag_scb_alloc()
147 p_scb->sco_codec = BTA_AG_CODEC_CVSD; in bta_ag_scb_alloc()
148 p_scb->peer_version = HFP_HSP_VERSION_UNKNOWN; in bta_ag_scb_alloc()
149 p_scb->hsp_version = HSP_VERSION_1_2; in bta_ag_scb_alloc()
150 p_scb->peer_sdp_features = 0; in bta_ag_scb_alloc()
152 p_scb->ring_timer = alarm_new("bta_ag.scb_ring_timer"); in bta_ag_scb_alloc()
153 p_scb->collision_timer = alarm_new("bta_ag.scb_collision_timer"); in bta_ag_scb_alloc()
154 p_scb->codec_negotiation_timer = in bta_ag_scb_alloc()
157 p_scb->codec_msbc_settings = BTA_AG_SCO_MSBC_SETTINGS_T2; in bta_ag_scb_alloc()
158 APPL_TRACE_DEBUG("bta_ag_scb_alloc %d", bta_ag_scb_to_idx(p_scb)); in bta_ag_scb_alloc()
165 p_scb = nullptr; in bta_ag_scb_alloc()
168 return p_scb; in bta_ag_scb_alloc()
181 void bta_ag_scb_dealloc(tBTA_AG_SCB* p_scb) { in bta_ag_scb_dealloc() argument
185 APPL_TRACE_DEBUG("bta_ag_scb_dealloc %d", bta_ag_scb_to_idx(p_scb)); in bta_ag_scb_dealloc()
188 alarm_free(p_scb->ring_timer); in bta_ag_scb_dealloc()
189 alarm_free(p_scb->codec_negotiation_timer); in bta_ag_scb_dealloc()
190 alarm_free(p_scb->collision_timer); in bta_ag_scb_dealloc()
193 *p_scb = {}; in bta_ag_scb_dealloc()
194 p_scb->sco_idx = BTM_INVALID_SCO_INDEX; in bta_ag_scb_dealloc()
221 uint16_t bta_ag_scb_to_idx(tBTA_AG_SCB* p_scb) { in bta_ag_scb_to_idx() argument
223 return static_cast<uint16_t>(p_scb - bta_ag_cb.scb + 1); in bta_ag_scb_to_idx()
237 tBTA_AG_SCB* p_scb; in bta_ag_scb_by_idx() local
241 p_scb = &bta_ag_cb.scb[idx - 1]; in bta_ag_scb_by_idx()
242 if (!p_scb->in_use) { in bta_ag_scb_by_idx()
243 p_scb = nullptr; in bta_ag_scb_by_idx()
247 p_scb = nullptr; in bta_ag_scb_by_idx()
250 return p_scb; in bta_ag_scb_by_idx()
282 tBTA_AG_SCB* p_scb = &bta_ag_cb.scb[0]; in bta_ag_idx_by_bdaddr() local
284 for (uint16_t i = 0; i < BTA_AG_MAX_NUM_CLIENTS; i++, p_scb++) { in bta_ag_idx_by_bdaddr()
285 if (p_scb->in_use && *peer_addr == p_scb->peer_addr) { in bta_ag_idx_by_bdaddr()
307 tBTA_AG_SCB* p_scb = &bta_ag_cb.scb[0]; in bta_ag_other_scb_open() local
308 for (int i = 0; i < BTA_AG_MAX_NUM_CLIENTS; i++, p_scb++) { in bta_ag_other_scb_open()
309 if (p_scb->in_use && p_scb != p_curr_scb && in bta_ag_other_scb_open()
310 p_scb->state == BTA_AG_OPEN_ST) { in bta_ag_other_scb_open()
349 tBTA_AG_SCB* p_scb = bta_ag_scb_by_idx(handle); in bta_ag_collision_cback() local
351 if (p_scb && (p_scb->state == BTA_AG_OPENING_ST)) { in bta_ag_collision_cback()
362 bta_ag_sm_execute(p_scb, BTA_AG_COLLISION_EVT, tBTA_AG_DATA::kEmpty); in bta_ag_collision_cback()
376 void bta_ag_resume_open(tBTA_AG_SCB* p_scb) { in bta_ag_resume_open() argument
377 if (p_scb->state == BTA_AG_INIT_ST) { in bta_ag_resume_open()
378 LOG(INFO) << __func__ << ": Resume connection to " << p_scb->peer_addr in bta_ag_resume_open()
379 << ", handle" << bta_ag_scb_to_idx(p_scb); in bta_ag_resume_open()
380 tBTA_AG_DATA open_data = {.api_open = {.bd_addr = p_scb->peer_addr}}; in bta_ag_resume_open()
381 bta_ag_sm_execute(p_scb, BTA_AG_API_OPEN_EVT, open_data); in bta_ag_resume_open()
383 VLOG(1) << __func__ << ": device " << p_scb->peer_addr in bta_ag_resume_open()
384 << " is already in state " << std::to_string(p_scb->state); in bta_ag_resume_open()
431 tBTA_AG_SCB* p_scb = &bta_ag_cb.scb[0]; in bta_ag_api_disable() local
443 for (i = 0; i < BTA_AG_MAX_NUM_CLIENTS; i++, p_scb++) { in bta_ag_api_disable()
444 if (p_scb->in_use) { in bta_ag_api_disable()
445 bta_ag_sm_execute(p_scb, BTA_AG_API_DEREGISTER_EVT, tBTA_AG_DATA::kEmpty); in bta_ag_api_disable()
471 tBTA_AG_SCB* p_scb = bta_ag_scb_alloc(); in bta_ag_api_register() local
472 if (p_scb) { in bta_ag_api_register()
473 APPL_TRACE_DEBUG("bta_ag_api_register: p_scb 0x%08x ", p_scb); in bta_ag_api_register()
486 bta_ag_sm_execute(p_scb, BTA_AG_API_REGISTER_EVT, data); in bta_ag_api_register()
509 tBTA_AG_SCB* p_scb; in bta_ag_api_result() local
511 p_scb = bta_ag_scb_by_idx(handle); in bta_ag_api_result()
512 if (p_scb) { in bta_ag_api_result()
514 p_scb->ToString().c_str()); in bta_ag_api_result()
515 bta_ag_sm_execute(p_scb, static_cast<uint16_t>(BTA_AG_API_RESULT_EVT), in bta_ag_api_result()
525 for (i = 0, p_scb = &bta_ag_cb.scb[0]; i < BTA_AG_MAX_NUM_CLIENTS; in bta_ag_api_result()
526 i++, p_scb++) { in bta_ag_api_result()
527 if (p_scb->in_use && p_scb->svc_conn) { in bta_ag_api_result()
529 p_scb->ToString().c_str()); in bta_ag_api_result()
530 bta_ag_sm_execute(p_scb, static_cast<uint16_t>(BTA_AG_API_RESULT_EVT), in bta_ag_api_result()
537 static void bta_ag_better_state_machine(tBTA_AG_SCB* p_scb, uint16_t event, in bta_ag_better_state_machine() argument
539 switch (p_scb->state) { in bta_ag_better_state_machine()
543 bta_ag_register(p_scb, data); in bta_ag_better_state_machine()
546 bta_ag_deregister(p_scb, data); in bta_ag_better_state_machine()
549 p_scb->state = BTA_AG_OPENING_ST; in bta_ag_better_state_machine()
550 bta_ag_start_open(p_scb, data); in bta_ag_better_state_machine()
553 p_scb->state = BTA_AG_OPEN_ST; in bta_ag_better_state_machine()
554 bta_ag_rfc_acp_open(p_scb, data); in bta_ag_better_state_machine()
555 bta_ag_sco_listen(p_scb, data); in bta_ag_better_state_machine()
558 bta_ag_sco_conn_open(p_scb, data); in bta_ag_better_state_machine()
561 bta_ag_sco_conn_close(p_scb, data); in bta_ag_better_state_machine()
564 bta_ag_free_db(p_scb, data); in bta_ag_better_state_machine()
567 LOG_ERROR("unknown event %d at state %d", event, p_scb->state); in bta_ag_better_state_machine()
574 p_scb->state = BTA_AG_CLOSING_ST; in bta_ag_better_state_machine()
575 bta_ag_rfc_do_close(p_scb, data); in bta_ag_better_state_machine()
576 bta_ag_start_dereg(p_scb, data); in bta_ag_better_state_machine()
579 bta_ag_open_fail(p_scb, data); in bta_ag_better_state_machine()
582 p_scb->state = BTA_AG_CLOSING_ST; in bta_ag_better_state_machine()
583 bta_ag_rfc_do_close(p_scb, data); in bta_ag_better_state_machine()
586 p_scb->state = BTA_AG_OPEN_ST; in bta_ag_better_state_machine()
587 bta_ag_rfc_open(p_scb, data); in bta_ag_better_state_machine()
588 bta_ag_sco_listen(p_scb, data); in bta_ag_better_state_machine()
591 p_scb->state = BTA_AG_INIT_ST; in bta_ag_better_state_machine()
592 bta_ag_rfc_fail(p_scb, data); in bta_ag_better_state_machine()
595 bta_ag_sco_conn_open(p_scb, data); in bta_ag_better_state_machine()
598 bta_ag_sco_conn_close(p_scb, data); in bta_ag_better_state_machine()
601 bta_ag_disc_int_res(p_scb, data); in bta_ag_better_state_machine()
604 bta_ag_rfc_do_open(p_scb, data); in bta_ag_better_state_machine()
607 p_scb->state = BTA_AG_INIT_ST; in bta_ag_better_state_machine()
608 bta_ag_disc_fail(p_scb, data); in bta_ag_better_state_machine()
611 p_scb->state = BTA_AG_INIT_ST; in bta_ag_better_state_machine()
612 bta_ag_handle_collision(p_scb, data); in bta_ag_better_state_machine()
615 LOG_ERROR("unknown event %d at state %d", event, p_scb->state); in bta_ag_better_state_machine()
622 p_scb->state = BTA_AG_CLOSING_ST; in bta_ag_better_state_machine()
623 bta_ag_start_close(p_scb, data); in bta_ag_better_state_machine()
624 bta_ag_start_dereg(p_scb, data); in bta_ag_better_state_machine()
627 bta_ag_open_fail(p_scb, data); in bta_ag_better_state_machine()
630 p_scb->state = BTA_AG_CLOSING_ST; in bta_ag_better_state_machine()
631 bta_ag_start_close(p_scb, data); in bta_ag_better_state_machine()
634 bta_ag_sco_open(p_scb, data); in bta_ag_better_state_machine()
637 bta_ag_sco_close(p_scb, data); in bta_ag_better_state_machine()
640 bta_ag_result(p_scb, data); in bta_ag_better_state_machine()
643 bta_ag_setcodec(p_scb, data); in bta_ag_better_state_machine()
646 p_scb->state = BTA_AG_INIT_ST; in bta_ag_better_state_machine()
647 bta_ag_rfc_close(p_scb, data); in bta_ag_better_state_machine()
650 bta_ag_rfc_data(p_scb, data); in bta_ag_better_state_machine()
653 bta_ag_sco_conn_open(p_scb, data); in bta_ag_better_state_machine()
654 bta_ag_post_sco_open(p_scb, data); in bta_ag_better_state_machine()
657 bta_ag_sco_conn_close(p_scb, data); in bta_ag_better_state_machine()
658 bta_ag_post_sco_close(p_scb, data); in bta_ag_better_state_machine()
661 bta_ag_disc_acp_res(p_scb, data); in bta_ag_better_state_machine()
664 bta_ag_send_ring(p_scb, data); in bta_ag_better_state_machine()
667 p_scb->state = BTA_AG_CLOSING_ST; in bta_ag_better_state_machine()
668 bta_ag_start_close(p_scb, data); in bta_ag_better_state_machine()
671 LOG_ERROR("unknown event %d at state %d", event, p_scb->state); in bta_ag_better_state_machine()
678 bta_ag_start_dereg(p_scb, data); in bta_ag_better_state_machine()
681 bta_ag_open_fail(p_scb, data); in bta_ag_better_state_machine()
684 p_scb->state = BTA_AG_INIT_ST; in bta_ag_better_state_machine()
685 bta_ag_rfc_close(p_scb, data); in bta_ag_better_state_machine()
688 bta_ag_sco_conn_open(p_scb, data); in bta_ag_better_state_machine()
691 bta_ag_sco_conn_close(p_scb, data); in bta_ag_better_state_machine()
692 bta_ag_post_sco_close(p_scb, data); in bta_ag_better_state_machine()
695 bta_ag_free_db(p_scb, data); in bta_ag_better_state_machine()
698 p_scb->state = BTA_AG_INIT_ST; in bta_ag_better_state_machine()
699 bta_ag_free_db(p_scb, data); in bta_ag_better_state_machine()
702 LOG_ERROR("unknown event %d at state %d", event, p_scb->state); in bta_ag_better_state_machine()
719 void bta_ag_sm_execute(tBTA_AG_SCB* p_scb, uint16_t event, in bta_ag_sm_execute() argument
722 uint8_t previous_state = p_scb->state; in bta_ag_sm_execute()
727 bta_ag_scb_to_idx(p_scb), PRIVATE_ADDRESS(p_scb->peer_addr), in bta_ag_sm_execute()
728 bta_ag_state_str(p_scb->state), p_scb->state, bta_ag_evt_str(event), in bta_ag_sm_execute()
731 bta_ag_better_state_machine(p_scb, event, data); in bta_ag_sm_execute()
733 if (p_scb->state != previous_state) { in bta_ag_sm_execute()
738 bta_ag_scb_to_idx(p_scb), PRIVATE_ADDRESS(p_scb->peer_addr), in bta_ag_sm_execute()
740 bta_ag_state_str(p_scb->state), p_scb->state, in bta_ag_sm_execute()
748 tBTA_AG_SCB* p_scb = bta_ag_scb_by_idx(handle); in bta_ag_sm_execute_by_handle() local
749 if (p_scb) { in bta_ag_sm_execute_by_handle()
752 bta_ag_sm_execute(p_scb, event, data); in bta_ag_sm_execute_by_handle()