components/bt/host/bluedroid/btc/profile/std/a2dp/btc_a2dp_sink.c
UINT8 btc_a2dp_sink_enque_buf(BT_HDR *p_pkt)
{
    tBT_SBC_HDR *p_msg;
    int32_t e_id;
    if (btc_a2dp_sink_state != BTC_A2DP_SINK_STATE_ON){
        return 0;
    }

    if (a2dp_sink_local_param.btc_aa_snk_cb.rx_flush == TRUE) { /* Flush enabled, do not enque*/
        return fixed_queue_length(a2dp_sink_local_param.btc_aa_snk_cb.RxSbcQ);
    }

    if (fixed_queue_length(a2dp_sink_local_param.btc_aa_snk_cb.RxSbcQ) >= MAX_OUTPUT_A2DP_SNK_FRAME_QUEUE_SZ) {
        APPL_TRACE_WARNING("Pkt dropped\n");
        return fixed_queue_length(a2dp_sink_local_param.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(a2dp_sink_local_param.btc_aa_snk_cb.RxSbcQ, p_msg, FIXED_QUEUE_MAX_TIMEOUT);

        if (fixed_queue_length(a2dp_sink_local_param.btc_aa_snk_cb.RxSbcQ) >= JITTER_BUFFER_WATER_LEVEL) {
            e_id = 0;
            if(xQueueSend(btc_aa_snk_data_queue,&e_id,0)!= pdTRUE){
                APPL_TRACE_DEBUG("%s():#5 xQueueSend error!",__func__);
            }
//            if (osi_sem_take(&a2dp_sink_local_param.btc_aa_snk_cb.post_sem, 0) == 0) {
//                btc_a2dp_sink_data_post();
//            }
        }
    } else {
        /* let caller deal with a failed allocation */
        APPL_TRACE_WARNING("btc_a2dp_sink_enque_buf No Buffer left - ");
    }
    return fixed_queue_length(a2dp_sink_local_param.btc_aa_snk_cb.RxSbcQ);
}
/*******************************************************************************
 **
 ** 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
 *******************************************************************************/
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
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;
    int32_t e_id;
    if (btc_a2dp_sink_state != BTC_A2DP_SINK_STATE_ON){
        return 0;
    }
    if (a2dp_sink_local_param.btc_aa_snk_cb.rx_flush == TRUE) { 
        return fixed_queue_length(a2dp_sink_local_param.btc_aa_snk_cb.RxSbcQ);
    }
    if (fixed_queue_length(a2dp_sink_local_param.btc_aa_snk_cb.RxSbcQ) >= MAX_OUTPUT_A2DP_SNK_FRAME_QUEUE_SZ) {
        APPL_TRACE_WARNING("Pkt dropped\n");
        return fixed_queue_length(a2dp_sink_local_param.btc_aa_snk_cb.RxSbcQ);
    }
    APPL_TRACE_DEBUG("btc_a2dp_sink_enque_buf + ");
    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(a2dp_sink_local_param.btc_aa_snk_cb.RxSbcQ, p_msg, FIXED_QUEUE_MAX_TIMEOUT);
        if (fixed_queue_length(a2dp_sink_local_param.btc_aa_snk_cb.RxSbcQ) >= JITTER_BUFFER_WATER_LEVEL) {
            e_id = 0;
            if(xQueueSend(btc_aa_snk_data_queue,&e_id,0)!= pdTRUE){
                APPL_TRACE_DEBUG("%s():#5 xQueueSend error!",__func__);
            }
        }
    } else {
        APPL_TRACE_WARNING("btc_a2dp_sink_enque_buf No Buffer left - ");
    }
    return fixed_queue_length(a2dp_sink_local_param.btc_aa_snk_cb.RxSbcQ);
}
UINT8 btc_a2dp_sink_enque_buf ( BT_HDR * p_pkt ) { tBT_SBC_HDR * p_msg ; int32_t e_id ; if ( btc_a2dp_sink_state != BTC_A2DP_SINK_STATE_ON ) { return 0 ; } if ( a2dp_sink_local_param . btc_aa_snk_cb . rx_flush == TRUE ) { return fixed_queue_length ( a2dp_sink_local_param . btc_aa_snk_cb . RxSbcQ ) ; } if ( fixed_queue_length ( a2dp_sink_local_param . btc_aa_snk_cb . RxSbcQ ) >= MAX_OUTPUT_A2DP_SNK_FRAME_QUEUE_SZ ) { APPL_TRACE_WARNING ( " \n " ) ; return fixed_queue_length ( a2dp_sink_local_param . btc_aa_snk_cb . RxSbcQ ) ; } APPL_TRACE_DEBUG ( " " ) ; 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 ( " \n " , p_msg -> num_frames_to_be_processed ) ; fixed_queue_enqueue ( a2dp_sink_local_param . btc_aa_snk_cb . RxSbcQ , p_msg , FIXED_QUEUE_MAX_TIMEOUT ) ; if ( fixed_queue_length ( a2dp_sink_local_param . btc_aa_snk_cb . RxSbcQ ) >= JITTER_BUFFER_WATER_LEVEL ) { e_id = 0 ; if ( xQueueSend ( btc_aa_snk_data_queue , & e_id , 0 ) != pdTRUE ) { APPL_TRACE_DEBUG ( " " , __func__ ) ; } } } else { APPL_TRACE_WARNING ( " " ) ; } return fixed_queue_length ( a2dp_sink_local_param . btc_aa_snk_cb . RxSbcQ ) ; }
Function         btc_a2dp_sink_enque_buf
 Description      This function is called by the av_co to fill A2DP Sink Queue
Function btc_a2dp_sink_enque_buf Description This function is called by the av_co to fill A2DP Sink Queue
/* Flush enabled, do not enque*/ /* allocate and Queue this buffer */ //            if (osi_sem_take(&a2dp_sink_local_param.btc_aa_snk_cb.post_sem, 0) == 0) { //                btc_a2dp_sink_data_post(); //            } /* let caller deal with a failed allocation */