/******************************************************************************* ** ** Function avdt_ccb_clear_cmds ** ** Description This function is called when the signaling channel is ** closed to clean up any pending commands. For each pending ** command in the command queue, it frees the command and ** calls the application callback function indicating failure. ** Certain CCB variables are also initialized. ** ** ** Returns void. ** *******************************************************************************/ void avdt_ccb_clear_cmds(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data) { int i; tAVDT_SCB *p_scb = &avdt_cb.scb[0]; UINT8 err_code = AVDT_ERR_CONNECT; UNUSED(p_data); /* clear the ccb */ avdt_ccb_clear_ccb(p_ccb); /* clear out command queue; this is a little tricky here; we need ** to handle the case where there is a command on deck in p_curr_cmd, ** plus we need to clear out the queue */ do { /* we know p_curr_cmd = NULL after this */ avdt_ccb_cmd_fail(p_ccb, (tAVDT_CCB_EVT *) &err_code); /* set up next message */ p_ccb->p_curr_cmd = (BT_HDR *) GKI_dequeue(&p_ccb->cmd_q); } while (p_ccb->p_curr_cmd != NULL); /* send a CC_CLOSE_EVT any active scbs associated with this ccb */ for (i = 0; i < AVDT_NUM_SEPS; i++, p_scb++) { if ((p_scb->allocated) && (p_scb->p_ccb == p_ccb)) { avdt_scb_event(p_scb, AVDT_SCB_CC_CLOSE_EVT, NULL); } } }
/******************************************************************************* ** ** Function avdt_ccb_ret_cmd ** ** Description This function is called to retransmit the currently ** pending command. The retransmission count is incremented. ** If the count reaches the maximum number of retransmissions, ** the event is treated as a response timeout. ** ** ** Returns void. ** *******************************************************************************/ void avdt_ccb_ret_cmd(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data) { UINT8 err_code = AVDT_ERR_TIMEOUT; BT_HDR *p_msg; p_ccb->ret_count++; if (p_ccb->ret_count == AVDT_RET_MAX) { /* command failed */ p_ccb->ret_count = 0; avdt_ccb_cmd_fail(p_ccb, (tAVDT_CCB_EVT *) &err_code); /* go to next queued command */ avdt_ccb_snd_cmd(p_ccb, p_data); } else { /* if command pending and we're not congested and not sending a fragment */ if ((!p_ccb->cong) && (p_ccb->p_curr_msg == NULL) && (p_ccb->p_curr_cmd != NULL)) { /* make copy of message in p_curr_cmd and send it */ if ((p_msg = (BT_HDR *) GKI_getpoolbuf(AVDT_CMD_POOL_ID)) != NULL) { memcpy(p_msg, p_ccb->p_curr_cmd, (sizeof(BT_HDR) + p_ccb->p_curr_cmd->offset + p_ccb->p_curr_cmd->len)); avdt_msg_send(p_ccb, p_msg); } } /* restart timer */ btu_start_timer(&p_ccb->timer_entry, BTU_TTYPE_AVDT_CCB_RET, avdt_cb.rcb.ret_tout); } }
/******************************************************************************* ** ** Function avdt_ccb_chk_reconn ** ** Description This function is called to check if a reconnect attempt ** is enabled. If enabled, it sends an AVDT_CCB_UL_OPEN_EVT ** to the CCB. If disabled, the CCB is deallocated. ** ** ** Returns void. ** *******************************************************************************/ void avdt_ccb_chk_reconn(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data) { UINT8 err_code = AVDT_ERR_CONNECT; UNUSED(p_data); if (p_ccb->reconn) { p_ccb->reconn = FALSE; /* clear out ccb */ avdt_ccb_clear_ccb(p_ccb); /* clear out current command, if any */ avdt_ccb_cmd_fail(p_ccb, (tAVDT_CCB_EVT *) &err_code); /* reopen the signaling channel */ avdt_ccb_event(p_ccb, AVDT_CCB_UL_OPEN_EVT, NULL); } else { avdt_ccb_ll_closed(p_ccb, NULL); } }