components/bt/host/bluedroid/btc/profile/std/a2dp/btc_a2dp_sink.c
static void btc_a2dp_sink_handle_decoder_reset_Aptx(tBTC_MEDIA_SINK_CFG_UPDATE *p_msg)
{
    tBTC_MEDIA_SINK_CFG_UPDATE *p_buf = p_msg;
    tA2D_STATUS a2d_status;
    tA2DP_APTX_CIE aptx_cie;
    OI_STATUS       status;
    UINT32          freq_multiple = 48 * 20; /* frequency multiple for 20ms of data , initialize with 48K*/
    //UINT32          num_blocks = 16;
    //UINT32          num_subbands = 8;

    //int freq = 48000;

    APPL_TRACE_EVENT("%s():#1", __FUNCTION__);
    APPL_TRACE_EVENT("\tp_codec_info[%x:%x:%x:%x:%x:%x:%x:%x:%x:%x]",
    				p_buf->codec_info[0],p_buf->codec_info[1], p_buf->codec_info[2], p_buf->codec_info[3],
                    p_buf->codec_info[4], p_buf->codec_info[5], p_buf->codec_info[6],
					p_buf->codec_info[7], p_buf->codec_info[8], p_buf->codec_info[9]);


    a2d_status = A2DP_ParseInfoAptx(&aptx_cie,p_buf->codec_info, FALSE,"btc_a2dp_sink_handle_decoder_reset_Aptx");
    if (a2d_status != A2D_SUCCESS) {
        APPL_TRACE_ERROR("ERROR dump_codec_info A2DP_ParseInfoAptx:%d\n", a2d_status);
        return;
    }

    // set sampleRate
    a2dp_sink_local_param.btc_aa_snk_cb.sample_rate = btc_a2dp_sink_get_track_frequency(p_buf->codec_info[2],aptx_cie.sampleRate);
    // set channelMode  stero/mono
    a2dp_sink_local_param.btc_aa_snk_cb.channel_count = btc_a2dp_sink_get_track_channel_count(p_buf->codec_info[2],aptx_cie.channelMode);
    // set codec_type
    a2dp_sink_local_param.btc_aa_snk_cb.codec_type = p_buf->codec_info[2];

    a2dp_sink_local_param.btc_aa_snk_cb.rx_flush = FALSE;

    APPL_TRACE_EVENT("Reset to sink role");
    status = OI_CODEC_SBC_DecoderReset(&a2dp_sink_local_param.context, a2dp_sink_local_param.contextData,
                                       sizeof(a2dp_sink_local_param.contextData), 2, 2, FALSE, FALSE);

    if (!OI_SUCCESS(status)) {
        APPL_TRACE_ERROR("OI_CODEC_SBC_DecoderReset failed with error code %d", status);
    }

    if(ctx!=NULL){
    	aptx_finish(ctx);
    	ctx=NULL;
    }
    // aptx decoder ������
    ctx=aptx_init(0);
    if (!ctx) {
        APPL_TRACE_ERROR("%s():#2 APTX DecoderReset failed", __func__);
        return;
    }

    btc_a2dp_control_set_datachnl_stat(TRUE);

    // sampleRate
    switch (aptx_cie.sampleRate) {
    case A2DP_APTX_SAMPLERATE_44100:
    	APPL_TRACE_EVENT("\tsamp_freq:%d (44100)", aptx_cie.sampleRate);
        freq_multiple = 441 * 2;
        break;
    case A2DP_APTX_SAMPLERATE_48000:
    	APPL_TRACE_EVENT("\tsamp_freq:%d (48000)", aptx_cie.sampleRate);
        freq_multiple = 48 * 20;
        break;
    default:
    	APPL_TRACE_EVENT("\tUnknown Frequency ");
        break;
    }

    // channelMode
    switch (aptx_cie.channelMode) {
    case A2DP_APTX_CHANNELS_MONO:
    	APPL_TRACE_EVENT("\tch_mode:%d (Mono)", aptx_cie.channelMode);
        break;
    case A2DP_APTX_CHANNELS_STEREO:
    	APPL_TRACE_EVENT("\tch_mode:%d (STEREO)", aptx_cie.channelMode);
        break;
    default:
    	APPL_TRACE_EVENT("\tUnknown Mode ");
        break;
    }


    //APPL_TRACE_EVENT("\tBit pool Min:%d Max:%d\n", sbc_cie.min_bitpool, sbc_cie.max_bitpool);

    //int frames_to_process = ((freq_multiple) / (num_blocks * num_subbands)) + 1;
    //APPL_TRACE_EVENT(" Frames to be processed in 20 ms %d\n", frames_to_process);
}
/*******************************************************************************
 **
 ** Function         btc_a2dp_sink_handle_decoder_reset for APTX
 **
 ** Description		add by nishi for APTX support 2019.1.22
 **
 ** Returns          void
 **
 *******************************************************************************/
Function         btc_a2dp_sink_handle_decoder_reset for APTX
Description         add by nishi for APTX support 2019.1.22

Returns          void
Function btc_a2dp_sink_handle_decoder_reset for APTX Description add by nishi for APTX support 2019 . 1 . 22 Returns void
static void btc_a2dp_sink_handle_decoder_reset_Aptx(tBTC_MEDIA_SINK_CFG_UPDATE *p_msg)
{
    tBTC_MEDIA_SINK_CFG_UPDATE *p_buf = p_msg;
    tA2D_STATUS a2d_status;
    tA2DP_APTX_CIE aptx_cie;
    OI_STATUS       status;
    UINT32          freq_multiple = 48 * 20; 
    APPL_TRACE_EVENT("%s():#1", __FUNCTION__);
    APPL_TRACE_EVENT("\tp_codec_info[%x:%x:%x:%x:%x:%x:%x:%x:%x:%x]",
    				p_buf->codec_info[0],p_buf->codec_info[1], p_buf->codec_info[2], p_buf->codec_info[3],
                    p_buf->codec_info[4], p_buf->codec_info[5], p_buf->codec_info[6],
					p_buf->codec_info[7], p_buf->codec_info[8], p_buf->codec_info[9]);
    a2d_status = A2DP_ParseInfoAptx(&aptx_cie,p_buf->codec_info, FALSE,"btc_a2dp_sink_handle_decoder_reset_Aptx");
    if (a2d_status != A2D_SUCCESS) {
        APPL_TRACE_ERROR("ERROR dump_codec_info A2DP_ParseInfoAptx:%d\n", a2d_status);
        return;
    }
    a2dp_sink_local_param.btc_aa_snk_cb.sample_rate = btc_a2dp_sink_get_track_frequency(p_buf->codec_info[2],aptx_cie.sampleRate);
    a2dp_sink_local_param.btc_aa_snk_cb.channel_count = btc_a2dp_sink_get_track_channel_count(p_buf->codec_info[2],aptx_cie.channelMode);
    a2dp_sink_local_param.btc_aa_snk_cb.codec_type = p_buf->codec_info[2];
    a2dp_sink_local_param.btc_aa_snk_cb.rx_flush = FALSE;
    APPL_TRACE_EVENT("Reset to sink role");
    status = OI_CODEC_SBC_DecoderReset(&a2dp_sink_local_param.context, a2dp_sink_local_param.contextData,
                                       sizeof(a2dp_sink_local_param.contextData), 2, 2, FALSE, FALSE);
    if (!OI_SUCCESS(status)) {
        APPL_TRACE_ERROR("OI_CODEC_SBC_DecoderReset failed with error code %d", status);
    }
    if(ctx!=NULL){
    	aptx_finish(ctx);
    	ctx=NULL;
    }
    ctx=aptx_init(0);
    if (!ctx) {
        APPL_TRACE_ERROR("%s():#2 APTX DecoderReset failed", __func__);
        return;
    }
    btc_a2dp_control_set_datachnl_stat(TRUE);
    switch (aptx_cie.sampleRate) {
    case A2DP_APTX_SAMPLERATE_44100:
    	APPL_TRACE_EVENT("\tsamp_freq:%d (44100)", aptx_cie.sampleRate);
        freq_multiple = 441 * 2;
        break;
    case A2DP_APTX_SAMPLERATE_48000:
    	APPL_TRACE_EVENT("\tsamp_freq:%d (48000)", aptx_cie.sampleRate);
        freq_multiple = 48 * 20;
        break;
    default:
    	APPL_TRACE_EVENT("\tUnknown Frequency ");
        break;
    }
    switch (aptx_cie.channelMode) {
    case A2DP_APTX_CHANNELS_MONO:
    	APPL_TRACE_EVENT("\tch_mode:%d (Mono)", aptx_cie.channelMode);
        break;
    case A2DP_APTX_CHANNELS_STEREO:
    	APPL_TRACE_EVENT("\tch_mode:%d (STEREO)", aptx_cie.channelMode);
        break;
    default:
    	APPL_TRACE_EVENT("\tUnknown Mode ");
        break;
    }
}
static void btc_a2dp_sink_handle_decoder_reset_Aptx ( tBTC_MEDIA_SINK_CFG_UPDATE * p_msg ) { tBTC_MEDIA_SINK_CFG_UPDATE * p_buf = p_msg ; tA2D_STATUS a2d_status ; tA2DP_APTX_CIE aptx_cie ; OI_STATUS status ; UINT32 freq_multiple = 48 * 20 ; APPL_TRACE_EVENT ( " " , __FUNCTION__ ) ; APPL_TRACE_EVENT ( " \t " , p_buf -> codec_info [ 0 ] , p_buf -> codec_info [ 1 ] , p_buf -> codec_info [ 2 ] , p_buf -> codec_info [ 3 ] , p_buf -> codec_info [ 4 ] , p_buf -> codec_info [ 5 ] , p_buf -> codec_info [ 6 ] , p_buf -> codec_info [ 7 ] , p_buf -> codec_info [ 8 ] , p_buf -> codec_info [ 9 ] ) ; a2d_status = A2DP_ParseInfoAptx ( & aptx_cie , p_buf -> codec_info , FALSE , " " ) ; if ( a2d_status != A2D_SUCCESS ) { APPL_TRACE_ERROR ( " \n " , a2d_status ) ; return ; } a2dp_sink_local_param . btc_aa_snk_cb . sample_rate = btc_a2dp_sink_get_track_frequency ( p_buf -> codec_info [ 2 ] , aptx_cie . sampleRate ) ; a2dp_sink_local_param . btc_aa_snk_cb . channel_count = btc_a2dp_sink_get_track_channel_count ( p_buf -> codec_info [ 2 ] , aptx_cie . channelMode ) ; a2dp_sink_local_param . btc_aa_snk_cb . codec_type = p_buf -> codec_info [ 2 ] ; a2dp_sink_local_param . btc_aa_snk_cb . rx_flush = FALSE ; APPL_TRACE_EVENT ( " " ) ; status = OI_CODEC_SBC_DecoderReset ( & a2dp_sink_local_param . context , a2dp_sink_local_param . contextData , sizeof ( a2dp_sink_local_param . contextData ) , 2 , 2 , FALSE , FALSE ) ; if ( ! OI_SUCCESS ( status ) ) { APPL_TRACE_ERROR ( " " , status ) ; } if ( ctx != NULL ) { aptx_finish ( ctx ) ; ctx = NULL ; } ctx = aptx_init ( 0 ) ; if ( ! ctx ) { APPL_TRACE_ERROR ( " " , __func__ ) ; return ; } btc_a2dp_control_set_datachnl_stat ( TRUE ) ; switch ( aptx_cie . sampleRate ) { case A2DP_APTX_SAMPLERATE_44100 : APPL_TRACE_EVENT ( " \t " , aptx_cie . sampleRate ) ; freq_multiple = 441 * 2 ; break ; case A2DP_APTX_SAMPLERATE_48000 : APPL_TRACE_EVENT ( " \t " , aptx_cie . sampleRate ) ; freq_multiple = 48 * 20 ; break ; default : APPL_TRACE_EVENT ( " \t " ) ; break ; } switch ( aptx_cie . channelMode ) { case A2DP_APTX_CHANNELS_MONO : APPL_TRACE_EVENT ( " \t " , aptx_cie . channelMode ) ; break ; case A2DP_APTX_CHANNELS_STEREO : APPL_TRACE_EVENT ( " \t " , aptx_cie . channelMode ) ; break ; default : APPL_TRACE_EVENT ( " \t " ) ; break ; } }
Function         btc_a2dp_sink_handle_decoder_reset for APTX
 Description         add by nishi for APTX support 2019.1.22
Function btc_a2dp_sink_handle_decoder_reset for APTX Description add by nishi for APTX support 2019 . 1 . 22
/* frequency multiple for 20ms of data , initialize with 48K*/ //UINT32          num_blocks = 16; //UINT32          num_subbands = 8; //int freq = 48000; // set sampleRate // set channelMode  stero/mono // set codec_type // aptx decoder ������ // sampleRate // channelMode //APPL_TRACE_EVENT("\tBit pool Min:%d Max:%d\n", sbc_cie.min_bitpool, sbc_cie.max_bitpool); //int frames_to_process = ((freq_multiple) / (num_blocks * num_subbands)) + 1; //APPL_TRACE_EVENT(" Frames to be processed in 20 ms %d\n", frames_to_process);