/******************************************************************************* ** ** Function btc_a2dp_sink_enque_buf ** ** Description This function is called by the av_co to fill A2DP Sink Queue ** ** ** Returns size of the queue *******************************************************************************/ UINT8 btc_a2dp_sink_enque_buf(BT_HDR *p_pkt) { tBT_SBC_HDR *p_msg; if (btc_aa_snk_cb.rx_flush == TRUE) { /* Flush enabled, do not enque*/ return fixed_queue_length(btc_aa_snk_cb.RxSbcQ); } if (fixed_queue_length(btc_aa_snk_cb.RxSbcQ) >= MAX_OUTPUT_A2DP_SNK_FRAME_QUEUE_SZ) { APPL_TRACE_WARNING("Pkt dropped\n"); return fixed_queue_length(btc_aa_snk_cb.RxSbcQ); } APPL_TRACE_DEBUG("btc_a2dp_sink_enque_buf + "); /* allocate and Queue this buffer */ if ((p_msg = (tBT_SBC_HDR *) osi_malloc(sizeof(tBT_SBC_HDR) + p_pkt->offset + p_pkt->len)) != NULL) { memcpy(p_msg, p_pkt, (sizeof(BT_HDR) + p_pkt->offset + p_pkt->len)); p_msg->num_frames_to_be_processed = (*((UINT8 *)(p_msg + 1) + p_msg->offset)) & 0x0f; APPL_TRACE_VERBOSE("btc_a2dp_sink_enque_buf %d + \n", p_msg->num_frames_to_be_processed); fixed_queue_enqueue(btc_aa_snk_cb.RxSbcQ, p_msg); btc_a2dp_sink_data_post(BTC_A2DP_SINK_DATA_EVT); } else { /* let caller deal with a failed allocation */ APPL_TRACE_WARNING("btc_a2dp_sink_enque_buf No Buffer left - "); } return fixed_queue_length(btc_aa_snk_cb.RxSbcQ); }
/******************************************************************************* ** ** Function BTA_HdSendReport ** ** Description This function is called when report is to be sent ** ** Returns void ** *******************************************************************************/ extern void BTA_HdSendReport(tBTA_HD_REPORT *p_report) { tBTA_HD_SEND_REPORT *p_buf; APPL_TRACE_VERBOSE("%s", __FUNCTION__); if ((p_buf = (tBTA_HD_SEND_REPORT *) GKI_getbuf(sizeof(tBTA_HD_SEND_REPORT))) != NULL) { p_buf->hdr.event = BTA_HD_API_SEND_REPORT_EVT; p_buf->use_intr = p_report->use_intr; p_buf->type = p_report->type; p_buf->id = p_report->id; p_buf->len = p_report->len; memcpy(p_buf->data, p_report->p_data, p_report->len); bta_sys_sendmsg(p_buf); } }
/******************************************************************************* ** ** Function register_app ** ** Description Registers HID Device application ** ** Returns bt_status_t ** *******************************************************************************/ static bt_status_t send_report(bthd_report_type_t type, uint8_t id, uint16_t len, uint8_t *p_data) { tBTA_HD_REPORT report; APPL_TRACE_VERBOSE("%s: type=%d id=%d len=%d", __FUNCTION__, type, id, len); if (!btif_hd_cb.app_registered) { BTIF_TRACE_WARNING("%s: application not yet registered", __FUNCTION__); return BT_STATUS_NOT_READY; } if (btif_hd_cb.status != BTIF_HD_ENABLED) { BTIF_TRACE_WARNING("%s: BT-HD not enabled, status=%d", __FUNCTION__, btif_hd_cb.status); return BT_STATUS_NOT_READY; } if (type == BTHD_REPORT_TYPE_INTRDATA) { report.type = BTHD_REPORT_TYPE_INPUT; report.use_intr = TRUE; } else { report.type = (type & 0x03); report.use_intr = FALSE; } report.id = id; report.len = len; report.p_data = p_data; BTA_HdSendReport(&report); return BT_STATUS_SUCCESS; }