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

📄 aud_audio.c

📁 最新MTK手机软件源码
💻 C
📖 第 1 页 / 共 5 页
字号:
                aud_mic_set_device(custom_cfg_hw_aud_input_path(AUDIO_DEVICE_MIC1));
            #endif 
            }

        #ifndef __MED_CTM_MOD__
            /* set mic volume */
            volume = aud_get_volume_gain(VOL_NORMAL, AUD_VOLUME_MIC, aud_get_volume_level(VOL_NORMAL, AUD_VOLUME_MIC));
            aud_mic_set_volume(volume, volume);
        #endif /* __MED_CTM_MOD__ */ 
            /* set speech volume */
            volume = aud_get_volume_gain(VOL_NORMAL, AUD_VOLUME_SPH, speech_volume_level);
        #ifndef __MED_CTM_MOD__
            aud_speech_set_output_volume(volume, 0);
        #endif 
            L1SP_SetSpeechVolumeLevel(speech_volume_level);
            /* set general tone volume, use keypad tone volume level */
            if (!aud_context_p->speech_on)
            {
                volume = aud_get_volume_gain(VOL_NORMAL, AUD_VOLUME_CTN, aud_get_volume_level(VOL_NORMAL, AUD_VOLUME_KEY));
            }
            aud_tone_set_output_volume(volume, 0);
            /* set key tone volume */
            volume = aud_get_volume_gain(VOL_NORMAL, AUD_VOLUME_KEY, aud_get_volume_level(VOL_NORMAL, AUD_VOLUME_KEY));
            aud_keytone_set_output_volume(volume, 0);
            /* set loopback volume */
            volume = aud_get_volume_gain(VOL_NORMAL, AUD_VOLUME_SID, aud_get_volume_level(VOL_NORMAL, AUD_VOLUME_SID));
            aud_side_tone_set_volume(volume, 0);
            /* set fm radio volume */
        #if defined(TV_OUT_SUPPORT)
            if (audio_tv_cable_in &&   /* TV out is on, and audio output to TV only */
                !audio_tv_loud_speaker &&
                aud_context_p->melody_output_device != AUDIO_DEVICE_SPEAKER_BOTH)
            {
                volume = aud_get_volume_gain(VOL_NORMAL, AUD_VOLUME_TVO, current_playing_fmradio_volume_level);
            }
            else
        #endif /* TV_OUT_SUPPORT */
            {
                volume = aud_get_volume_gain(VOL_NORMAL, AUD_VOLUME_FMR, current_playing_fmradio_volume_level);
            }
            aud_fmr_set_volume(volume);
            /* set media volume, use playing melody volume level */
        #if defined(TV_OUT_SUPPORT)
            if (audio_tv_cable_in &&   /* TV out is on, and audio output to TV only */
                !audio_tv_loud_speaker &&
                aud_context_p->melody_output_device != AUDIO_DEVICE_SPEAKER_BOTH)
            {
                aud_set_melody_volume(VOL_TV_OUT, current_playing_melody_volume_level);
            }
            else
        #endif /* TV_OUT_SUPPORT */
            {
                aud_set_melody_volume(VOL_NORMAL, current_playing_melody_volume_level);
            }

        #ifndef __MED_CTM_MOD__
            /* Set speech FIR coefficient */
            L1SP_Write_Audio_Coefficients(
                param_p->FIR_input_coeff[0],
                param_p->FIR_output_coeff[param_p->selected_FIR_output_index]);
            aud_speech_set_fir(KAL_TRUE);
        #endif /* __MED_CTM_MOD__ */ 
            L1SP_SetSpeechMode(speech_mode, aud_context_p->audio_param.speech_mode_para[speech_mode]);
            break;
        }

        /*---------------------- Headset Mode -----------------------*/
        case AUD_MODE_HEADSET:

            /* Set output device */
    #ifndef __MED_CTM_MOD__
            aud_speech_set_output_device(custom_cfg_hw_aud_output_path(AUDIO_DEVICE_SPEAKER2));
    #endif 
            aud_keytone_set_output_device(custom_cfg_hw_aud_output_path(AUDIO_DEVICE_SPEAKER2));
            aud_tone_set_output_device(custom_cfg_hw_aud_output_path(AUDIO_DEVICE_SPEAKER2));
    #ifdef __MED_BT_A2DP_MOD__
    #if defined(__BTMTK__)
            if (!aud_bt_a2dp_is_mute_phone())
    #elif defined(__BTVCSR_HCI_BCHS__)
            if (!aud_bt_a2dp_is_media_output_on())
    #endif
    #endif 
                aud_melody_set_output_device(custom_cfg_hw_aud_output_path(aud_context_p->melody_output_device));
            aud_fmr_set_output_device(custom_cfg_hw_aud_output_path(aud_context_p->melody_output_device));
    #ifdef __MED_SND_MOD__
            aud_snd_set_output_device(custom_cfg_hw_aud_output_path(aud_context_p->melody_output_device));
    #endif 

            /* For FM record, not use default input device during record phase, so don't apply input path right away */
            if ((AUD_IN_STATE(AUD_MEDIA_RECORD) || AUD_IN_STATE(AUD_MEDIA_RECORD_PAUSED))
                && !aud_context_p->use_default_input)
            {
                aud_mic_set_device_no_apply(custom_cfg_hw_aud_input_path(AUDIO_DEVICE_MIC2));
            }
            else
            {
            #ifndef __MED_CTM_MOD__
                aud_mic_set_device(custom_cfg_hw_aud_input_path(AUDIO_DEVICE_MIC2));
            #endif 
            }

        #ifndef __MED_CTM_MOD__
            /* set mic volume */
            volume = aud_get_volume_gain(VOL_HEADSET, AUD_VOLUME_MIC, aud_get_volume_level(VOL_HEADSET, AUD_VOLUME_MIC));
            aud_mic_set_volume(volume, volume);
        #endif /* __MED_CTM_MOD__ */ 
            /* set speech volume */
            volume = aud_get_volume_gain(VOL_HEADSET, AUD_VOLUME_SPH, speech_volume_level);
        #ifndef __MED_CTM_MOD__
            aud_speech_set_output_volume(volume, 0);
        #endif 
            L1SP_SetSpeechVolumeLevel(speech_volume_level);
            /* set general tone volume, use key tone volume level */
            if (!aud_context_p->speech_on)
            {
                volume = aud_get_volume_gain(
                            VOL_HEADSET,
                            AUD_VOLUME_CTN,
                            aud_get_volume_level(VOL_HEADSET, AUD_VOLUME_KEY));
            }
            aud_tone_set_output_volume(volume, 0);
            /* set key tone volume */
            volume = aud_get_volume_gain(VOL_HEADSET, AUD_VOLUME_KEY, aud_get_volume_level(VOL_HEADSET, AUD_VOLUME_KEY));
            aud_keytone_set_output_volume(volume, 0);
            /* set loopback volume */
            volume = aud_get_volume_gain(VOL_HEADSET, AUD_VOLUME_SID, aud_get_volume_level(VOL_HEADSET, AUD_VOLUME_SID));
            aud_side_tone_set_volume(volume, 0);
            /* if it's headset mode and output to both earphone & loud speaker, use normal mode gain value */
            if (aud_context_p->melody_output_device == AUDIO_DEVICE_SPEAKER_BOTH)
            {
                gain_audio_mode = VOL_NORMAL;
            }
            else
            {
                gain_audio_mode = VOL_HEADSET;
            }

            /* set media volume, use playing melody volume level */
            aud_set_melody_volume(gain_audio_mode, current_playing_melody_volume_level);

            /* set fm radio volume, use playing fm radio volume level */
            volume = aud_get_volume_gain(gain_audio_mode, AUD_VOLUME_FMR, current_playing_fmradio_volume_level);
            aud_fmr_set_volume(volume);

        #ifndef __MED_CTM_MOD__
            /* Set speech FIR coefficient */
            L1SP_Write_Audio_Coefficients(param_p->FIR_input_coeff[1], param_p->FIR_output_coeff[6]);
            aud_speech_set_fir(KAL_TRUE);
        #endif /* __MED_CTM_MOD__ */ 
            L1SP_SetSpeechMode(speech_mode, aud_context_p->audio_param.speech_mode_para[speech_mode]);
            break;

        /*------------------------ Loud Speaker --------------------------------*/
        case AUD_MODE_LOUDSPK:

            /* To slove mute flag cleared by speech off */
        #ifdef __MED_CTM_MOD__
            if (!tty_on)
        #endif 
            {
                mute = L1SP_IsMicrophoneMuted();
                L1SP_Speech_Off();
                kal_sleep_task(20);
                L1SP_MuteMicrophone(mute);
            }
            /* Set output device */
        #ifndef __MED_CTM_MOD__
            aud_speech_set_output_device(custom_cfg_hw_aud_output_path(AUDIO_DEVICE_LOUDSPEAKER));
        #endif 
            aud_keytone_set_output_device(custom_cfg_hw_aud_output_path(AUDIO_DEVICE_LOUDSPEAKER));
            aud_tone_set_output_device(custom_cfg_hw_aud_output_path(AUDIO_DEVICE_LOUDSPEAKER));
        #ifdef __MED_BT_A2DP_MOD__
        #if defined(__BTMTK__)
            if (!aud_bt_a2dp_is_mute_phone())
        #elif defined(__BTVCSR_HCI_BCHS__)
            if (!aud_bt_a2dp_is_media_output_on())
        #endif
        #endif 
            {
            #if defined(TV_OUT_SUPPORT)
                if (audio_tv_cable_in)
                {
                    if(audio_tv_loud_speaker)  /* Set output path to both TV out and mobile device */
                    {
                        aud_melody_set_output_device(custom_cfg_hw_aud_output_path(AUDIO_DEVICE_SPEAKER_BOTH));
                    }
                    else  /* Set output path to earphone to let it play through TV only. */
                    {
                        aud_melody_set_output_device(custom_cfg_hw_aud_output_path(AUDIO_DEVICE_SPEAKER2));
                    }
                }
                else
            #endif /* TV_OUT_SUPPORT */
                {
                    aud_melody_set_output_device(custom_cfg_hw_aud_output_path(AUDIO_DEVICE_LOUDSPEAKER));
                }
            }

        #if defined(TV_OUT_SUPPORT)
            if (audio_tv_cable_in)
            {
                if(audio_tv_loud_speaker)  /* Set output path to both TV out and mobile device */
                {
                    aud_fmr_set_output_device(custom_cfg_hw_aud_output_path(AUDIO_DEVICE_SPEAKER_BOTH));
                }
                else  /* Set output path to earphone to let it play through TV only. */
                {
                    aud_fmr_set_output_device(custom_cfg_hw_aud_output_path(AUDIO_DEVICE_SPEAKER2));
                }            
            }
            else
        #endif /* TV_OUT_SUPPORT */
            {
                aud_fmr_set_output_device(custom_cfg_hw_aud_output_path(AUDIO_DEVICE_LOUDSPEAKER));
            }

        #ifdef __MED_SND_MOD__
            #if defined(TV_OUT_SUPPORT)
                if (audio_tv_cable_in)  /* Set output path to earphone to let it play through TV only. */
                {
                    if(audio_tv_loud_speaker)  /* Set output path to both TV out and mobile device */
                    {
                        aud_snd_set_output_device(custom_cfg_hw_aud_output_path(AUDIO_DEVICE_SPEAKER_BOTH));
                    }
                    else  /* Set output path to earphone to let it play through TV only. */
                    {
                        aud_snd_set_output_device(custom_cfg_hw_aud_output_path(AUDIO_DEVICE_SPEAKER2));
                    }            
                }
                else
            #endif /* TV_OUT_SUPPORT */
                {
                    aud_snd_set_output_device(custom_cfg_hw_aud_output_path(AUDIO_DEVICE_LOUDSPEAKER));
                }        
        #endif /* __MED_SND_MOD__ */

            /* For FM record, not use default input device during record phase, so don't apply input path right away */
            if ((AUD_IN_STATE(AUD_MEDIA_RECORD) || AUD_IN_STATE(AUD_MEDIA_RECORD_PAUSED))
                && !aud_context_p->use_default_input)
            {
                aud_mic_set_device_no_apply(custom_cfg_hw_aud_input_path(AUDIO_DEVICE_MIC1));
            }
            else
            {
            #ifndef __MED_CTM_MOD__
                aud_mic_set_device(custom_cfg_hw_aud_input_path(AUDIO_DEVICE_MIC1));
            #endif 
            }

        #ifndef __MED_CTM_MOD__
            /* set mic volume */
            volume = aud_get_volume_gain(VOL_HANDFREE, AUD_VOLUME_MIC, aud_get_volume_level(VOL_HANDFREE, AUD_VOLUME_MIC));
            aud_mic_set_volume(volume, volume);
        #endif /* __MED_CTM_MOD__ */ 
            /* set speech volume */
            volume = aud_get_volume_gain(VOL_HANDFREE, AUD_VOLUME_SPH, speech_volume_level);
        #ifndef __MED_CTM_MOD__
            aud_speech_set_output_volume(volume, 0);
        #endif 
            L1SP_SetSpeechVolumeLevel(speech_volume_level);
            /* set general tone volume, use key tone volume level */
            if (!aud_context_p->speech_on)
            {
                volume = aud_get_volume_gain(
                            VOL_HANDFREE,
                            AUD_VOLUME_CTN,
                            aud_get_volume_level(VOL_HANDFREE, AUD_VOLUME_KEY));
            }
            aud_tone_set_output_volume(volume, 0);
            /* set key tone volume */
            volume = aud_get_volume_gain(VOL_HANDFREE, AUD_VOLUME_KEY, aud_get_volume_level(VOL_HANDFREE, AUD_VOLUME_KEY));
            aud_keytone_set_output_volume(volume, 0);
            /* set volume when play */
            /* set loopback volume */
            volume = aud_get_volume_gain(VOL_HANDFREE, AUD_VOLUME_SID, aud_get_volume_level(VOL_HANDFREE, AUD_VOLUME_SID));
            aud_side_tone_set_volume(volume, 0);
            /* set fm radio volume */
        #if defined(TV_OUT_SUPPORT)
            if (audio_tv_cable_in &&   /* TV out is on, and audio output to TV only */
                !audio_tv_loud_speaker &&
                aud_context_p->melody_output_device != AUDIO_DEVICE_SPEAKER_BOTH)
            {
                volume = aud_get_volume_gain(VOL_HANDFREE, AUD_VOLUME_TVO, current_playing_fmradio_volume_level);
            }
            else
        #endif /* TV_OUT_SUPPORT */
            {
                volume = aud_get_volume_gain(VOL_HANDFREE, AUD_VOLUME_FMR, current_playing_fmradio_volume_level);
            }
            aud_fmr_set_volume(volume);
            /* set media volume, use playing melody volume level */
        #if defined(TV_OUT_SUPPORT)
            if (audio_tv_cable_in &&    /* TV out is on, and audio output to TV only */
                !audio_tv_loud_speaker &&
                aud_context_p->melody_output_device != AUDIO_DEVICE_SPEAKER_BOTH)
            {
                aud_set_melody_volume(VOL_TV_OUT, current_playing_melody_volume_level);
            }
            else
        #endif /* TV_OUT_SUPPORT */
            {
                aud_set_melody_volume(VOL_HANDFREE, current_playing_melody_volume_level);
            }

        #ifndef __MED_CTM_MOD__
            /* Set speech FIR coefficient */
            L1SP_Write_Audio_Coefficients(param_p->FIR_input_coeff[0], param_p->FIR_output_coeff[5]);
            aud_speech_set_fir(KAL_TRUE);
        #endif /* __MED_CTM_MOD__ */ 
            L1SP_SetSpeechMode(speech_mode, aud_context_p->audio_param.speech_mode_para[speech_mode]);

            /* If the speech shall be turned on, turn it on */
        #ifdef __MED_CTM_MOD__
            if (!tty_on)
        #endif 
            {
                if (aud_context_p->speech_on)
                {
                    L1SP_Speech_On();
                }
            }
            break;

    }
}


#if defined(TV_OUT_SUPPORT)
/*****************************************************************************
 * FUNCTION
 *  aud_set_tv_out_aud_path
 * DESCRIPTION
 *  
 * PARAMETERS
 *  tv_on       [IN]        
 * RETURNS
 *  void
 *****************************************************************************/
void aud_set_tv_out_aud_path(kal_uint8 tv_on)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    kal_uint8 volume;
    kal_uint8 gain_audio_mode;
    kal_uint8 output_path;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/

⌨️ 快捷键说明

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