⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 aud_speech.c

📁 最新MTK手机软件源码
💻 C
📖 第 1 页 / 共 2 页
字号:
 *  fir_on      [IN]        
 * RETURNS
 *  void
 *****************************************************************************/
void aud_speech_set_fir(kal_bool fir_on)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    L1SP_SetFIR(fir_on);

}

#ifdef __BT_SUPPORT__


/*****************************************************************************
 * FUNCTION
 *  aud_set_bt_path_req_hdlr
 * DESCRIPTION
 *  
 * PARAMETERS
 *  ilm_ptr     [?]     
 * RETURNS
 *  void
 *****************************************************************************/
void aud_set_bt_path_req_hdlr(ilm_struct *ilm_ptr)
{
#ifdef __BTVCSR_HP__
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    l4aud_sp_set_bt_path_req_struct *req_p = (l4aud_sp_set_bt_path_req_struct*) ilm_ptr->local_para_ptr;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    if (audio_bluetooth_on != req_p->bluetooth_on)
    {
        audio_bluetooth_on = req_p->bluetooth_on;
        L1SP_Speech_Off();
        if (audio_bluetooth_on)
        {
            L1SP_SetSpeechMode(SPH_MODE_BT_EARPHONE, aud_context_p->audio_param.speech_mode_para[SPH_MODE_BT_EARPHONE]);
        }
        else
        {
            L1SP_SetSpeechMode(
                aud_context_p->audio_mode,
                aud_context_p->audio_param.speech_mode_para[aud_context_p->audio_mode]);
        }
        if (aud_context_p->speech_on)
        {
            L1SP_Speech_On();
        }
    }
#ifdef DUMMY_CNF
    {
        kal_uint16 cnf_msg_id;
        l4aud_sp_set_bt_path_cnf_struct *cnf_p = NULL;

        cnf_msg_id = MSG_ID_L4AUD_SP_SET_BT_PATH_CNF;
        cnf_p = (l4aud_sp_set_bt_path_cnf_struct*)
            construct_local_para(sizeof(l4aud_sp_set_bt_path_cnf_struct), TD_CTRL);

        cnf_p->result = MED_RES_OK;

        aud_send_ilm(ilm_ptr->src_mod_id, cnf_msg_id, cnf_p, NULL);
    }
#endif /* DUMMY_CNF */ 
#endif /* __BTVCSR_HP__ */ 
}
#endif /* __BT_SUPPORT__ */ 


/*****************************************************************************
 * FUNCTION
 *  aud_speech_set_mode_req_hdlr
 * DESCRIPTION
 *  
 * PARAMETERS
 *  ilm_ptr     [?]     
 * RETURNS
 *  void
 *****************************************************************************/
void aud_speech_set_mode_req_hdlr(ilm_struct *ilm_ptr)
{
#ifdef DUMMY_CNF
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    kal_uint16 cnf_msg_id;
    l4aud_sp_set_mode_cnf_struct *cnf_p = NULL;
#endif /* DUMMY_CNF */ 
    l4aud_sp_set_mode_req_struct *req_p;
    kal_uint8 volume;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    req_p = (l4aud_sp_set_mode_req_struct*) ilm_ptr->local_para_ptr;

    /* call L1AUD to set speech mode */
    AUD_VALUE_TRACE(req_p->speech_on, -1, -1)
        /* if keytone is playing, stop it */
        aud_keytone_stop();

    /* if tone is playing, stop it */
    /* Remove in case that busy tone is stopped by speech off */
    //if (aud_context_p->tone_playing)
    //aud_tone_stop();

#ifdef __MED_MMA_MOD__
    /* close all mma tasks */
    aud_mma_close_all();
#endif /* __MED_MMA_MOD__ */ 

#if defined(__MED_VID_MOD__) || defined(__MED_MJPG_MOD__)
    vid_stop_unfinished_task();
#endif 

    if (aud_context_p->state != AUD_IDLE)
    {
        aud_stop_unfinished_process();
    }

    /* set general tone volume */
    if (req_p->speech_on)
        /* use speech volume for tone */
    {
        volume = aud_get_volume_gain(
                    aud_context_p->audio_mode,
                    AUD_VOLUME_SPH,
                    aud_get_volume_level(aud_context_p->audio_mode, AUD_VOLUME_SPH));
    }
    else
        /* reset tone volume level, use key tone volume level */
    {
        volume = aud_get_volume_gain(
                    aud_context_p->audio_mode,
                    AUD_VOLUME_CTN,
                    aud_get_volume_level(aud_context_p->audio_mode, AUD_VOLUME_KEY));
    }
    aud_tone_set_output_volume(volume, 0);

    if (req_p->speech_on)
    {
        L1SP_Speech_On();
        aud_context_p->speech_on = KAL_TRUE;
    #ifdef VM_LOG
        aud_vm_start_logging();
    #endif 
    }
    else
    {
    #ifdef VM_LOG
        aud_vm_stop_logging();
    #endif 
        L1SP_Speech_Off();
        aud_context_p->speech_on = KAL_FALSE;
    }
#ifdef DUMMY_CNF
    cnf_msg_id = MSG_ID_L4AUD_SP_SET_MODE_CNF;
    cnf_p = (l4aud_sp_set_mode_cnf_struct*) construct_local_para(sizeof(l4aud_sp_set_mode_cnf_struct), TD_CTRL);

    cnf_p->result = MED_RES_OK;

    aud_send_ilm(ilm_ptr->src_mod_id, cnf_msg_id, cnf_p, NULL);
#endif /* DUMMY_CNF */ 
}

#ifdef __MED_POC_MOD__

typedef void (*media_handler) (Media_Handle *handle, Media_Event event);


/*****************************************************************************
 * FUNCTION
 *  aud_speech_amr_encode_start
 * DESCRIPTION
 *  
 * PARAMETERS
 *  vocoder             [IN]        
 *  media_handler       [IN]        
 *  frame_threshold     [IN]        
 *  buffer_size         [IN]        
 * RETURNS
 *  
 *****************************************************************************/
kal_int32 aud_speech_amr_encode_start(
            kal_uint8 vocoder,
            void (*media_handler) (void),
            kal_int32 frame_threshold,
            kal_uint32 buffer_size)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    Media_Status result;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    ASSERT(buffer_size <= AUD_RING_BUFFER_LEN);

#ifndef __MTK_TARGET__
    {
        extern kal_int32 poc_encode_start(void);

        result = poc_encode_start();
    }
#else /* __MTK_TARGET__ */ 
    PoC_AMR_SetBuffer(aud_context_p->ring_buf, buffer_size);
    result = PoC_AMR_EncodeStart(vocoder, media_handler, frame_threshold);
#endif /* __MTK_TARGET__ */ 

    return (kal_int32) result;
}


/*****************************************************************************
 * FUNCTION
 *  aud_speech_amr_encode_get_payload
 * DESCRIPTION
 *  
 * PARAMETERS
 *  buf             [?]         
 *  max_len         [IN]        
 *  frame_thres     [IN]        
 *  len_p           [?]         
 * RETURNS
 *  
 *****************************************************************************/
kal_int32 aud_speech_amr_encode_get_payload(
            kal_uint8 *buf,
            kal_int32 max_len,
            kal_int32 frame_thres,
            kal_int32 *len_p)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    kal_int32 frames;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
#ifndef __MTK_TARGET__
    *len_p = 42;
    {
        const kal_uint8 test_rtp_payload[] = 
        {
            0x80, 0xed, 0x03, 0x0a, 0x00, 0x00, 0x49, 0xf4, 0x00, 0x00, 0x00, 0xff, 0x31, 0x32, 0x33, 0x34,
            0x35, 0x36, 0x37, 0x38, 0x39, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30,
            0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30
        };

        memcpy(buf, test_rtp_payload, sizeof(test_rtp_payload));
    }
#else /* __MTK_TARGET__ */ 
    frames = PoC_AMR_GetFrameCount();
    kal_wap_trace(stack_get_active_module_id(), TRACE_INFO, "PoC GetPayload: Frames remain = %d", frames);
    kal_wap_trace(stack_get_active_module_id(), TRACE_INFO, "PoC GetPayload: Frames got = %d", frame_thres);
    /* *len_p = PoC_AMR_GetPayload( buf, max_len, frames ); */
    *len_p = PoC_AMR_GetPayload(buf, max_len, frame_thres);
#endif /* __MTK_TARGET__ */ 

    return MED_SUCCESS;
}


/*****************************************************************************
 * FUNCTION
 *  aud_speech_amr_encode_stop
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  
 *****************************************************************************/
kal_int32 aud_speech_amr_encode_stop(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    Media_Status result;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
#ifndef __MTK_TARGET__
    {
        extern kal_int32 poc_encode_stop(void);

        result = poc_encode_stop();
    }
#else /* __MTK_TARGET__ */ 
    result = PoC_AMR_EncodeStop();
#endif /* __MTK_TARGET__ */ 

    return (kal_int32) result;
}


/*****************************************************************************
 * FUNCTION
 *  aud_speech_amr_decode_start
 * DESCRIPTION
 *  
 * PARAMETERS
 *  buffer_size     [IN]        
 * RETURNS
 *  
 *****************************************************************************/
kal_int32 aud_speech_amr_decode_start(kal_uint32 buffer_size)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    Media_Status result;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    ASSERT(buffer_size <= AUD_RING_BUFFER_LEN);

#ifndef __MTK_TARGET__
    result = 0;
#else /* __MTK_TARGET__ */ 
    PoC_AMR_SetBuffer(aud_context_p->ring_buf, buffer_size);
    result = PoC_AMR_DecodeStart();
#endif /* __MTK_TARGET__ */ 

    return (kal_int32) result;
}


/*****************************************************************************
 * FUNCTION
 *  aud_speech_amr_decode_put_payload
 * DESCRIPTION
 *  
 * PARAMETERS
 *  buf     [?]         
 *  len     [IN]        
 * RETURNS
 *  
 *****************************************************************************/
kal_int32 aud_speech_amr_decode_put_payload(kal_uint8 *buf, kal_int32 len)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    Media_Status result;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
#ifndef __MTK_TARGET__
    result = 0;
#else 
    result = PoC_AMR_PutPayload(buf, len);
#endif 

    return (kal_int32) result;
}


/*****************************************************************************
 * FUNCTION
 *  aud_speech_amr_decode_stop
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  
 *****************************************************************************/
kal_int32 aud_speech_amr_decode_stop(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    Media_Status result;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
#ifndef __MTK_TARGET__
    result = 0;
#else 
    result = PoC_AMR_DecodeStop();
#endif 

    return (kal_int32) result;
}

#endif /* __MED_POC_MOD__ */ 

#endif /* MED_NOT_PRESENT */ 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -