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

📄 aud_melody.c

📁 最新MTK手机软件源码
💻 C
📖 第 1 页 / 共 5 页
字号:
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    aud_context_p->vibrator_on_stored = aud_context_p->vibrator_on;

#ifdef __MMI_SUPPORT_LED_SYNC__
    kal_take_mutex(led_ctrl_mutex);
    aud_context_p->led_on_stored = aud_context_p->led_on;
    kal_give_mutex(led_ctrl_mutex);
#else /* __MMI_SUPPORT_LED_SYNC__ */ 
    aud_context_p->led_on_stored = aud_context_p->led_on;
#endif /* __MMI_SUPPORT_LED_SYNC__ */ 

#ifdef __MMI_SUPPORT_BACKLIGHT_SYNC__
    kal_take_mutex(backlight_ctrl_mutex);
    aud_context_p->backlight_on_stored = aud_context_p->backlight_on;
    kal_give_mutex(backlight_ctrl_mutex);
#else /* __MMI_SUPPORT_BACKLIGHT_SYNC__ */ 
    aud_context_p->backlight_on_stored = aud_context_p->backlight_on;
#endif /* __MMI_SUPPORT_BACKLIGHT_SYNC__ */ 
}


/*****************************************************************************
 * FUNCTION
 *  aud_restore_driver_status
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void aud_restore_driver_status(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    aud_melody_imy_vibrator_hdlr(aud_context_p->vibrator_on_stored);
    aud_melody_imy_led_hdlr(aud_context_p->led_on_stored);
    aud_melody_imy_backlight_hdlr(aud_context_p->backlight_on_stored);
}


/*****************************************************************************
 * FUNCTION
 *  aud_melody_create_folder
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void aud_melody_create_folder(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    FS_HANDLE file_handle;
    kal_int32 result;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    /* if the dir exists, open it ,otherwise create it */
    file_handle = FS_Open(L"z:\\def_sound", FS_OPEN_DIR | FS_READ_ONLY);
    if (file_handle < 0)
    {
        result = FS_CreateDir(L"z:\\def_sound");
        ASSERT(result >= 0);
    }
    else
    {
        FS_Close(file_handle);
    }

    /* if the dir exists, open it ,otherwise create it */
    file_handle = FS_Open(L"z:\\def_sound\\imelody", FS_OPEN_DIR | FS_READ_ONLY);
    if (file_handle < 0)
    {
        result = FS_CreateDir(L"z:\\def_sound\\imelody");
        ASSERT(result >= 0);
    }
    else
    {
        FS_Close(file_handle);
    }

    /* if the dir exists, open it ,otherwise create it */
    file_handle = FS_Open(L"z:\\def_sound\\other", FS_OPEN_DIR | FS_READ_ONLY);
    if (file_handle < 0)
    {
        result = FS_CreateDir(L"z:\\def_sound\\other");
        ASSERT(result >= 0);
    }
    else
    {
        FS_Close(file_handle);
    }

}


/*****************************************************************************
 * FUNCTION
 *  aud_melody_startup
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  
 *****************************************************************************/
kal_bool aud_melody_startup(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    /* aud_melody_create_folder(); */
    return KAL_TRUE;
}


/*****************************************************************************
 * FUNCTION
 *  aud_melody_set_max_swing
 * DESCRIPTION
 *  
 * PARAMETERS
 *  max_swing       [IN]        
 * RETURNS
 *  void
 *****************************************************************************/
void aud_melody_set_max_swing(kal_uint16 max_swing)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    AUD_VALUE_TRACE(max_swing, -1, -1);
    Media_Control(MEDIA_CTRL_MAX_SWING, max_swing);

}


/*****************************************************************************
 * FUNCTION
 *  aud_melody_set_output_device
 * DESCRIPTION
 *  
 * PARAMETERS
 *  device      [IN]        
 * RETURNS
 *  void
 *****************************************************************************/
void aud_melody_set_output_device(kal_uint8 device)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    AUD_TRACE_PATH(AUD_TYPE_MELODY, device, -1);
    Media_SetOutputDevice(device);
}


/*****************************************************************************
 * FUNCTION
 *  aud_melody_set_volume
 * DESCRIPTION
 *  
 * PARAMETERS
 *  volume1                 [IN]        
 *  digital_gain_index      [IN]        
 * RETURNS
 *  void
 *****************************************************************************/
void aud_melody_set_volume(kal_uint8 volume1, kal_int8 digital_gain_index)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    AUD_TRACE_VOLUME(AUD_VOLUME_MEDIA, volume1, digital_gain_index);
    Media_SetOutputVolume(volume1, digital_gain_index);

}


/*****************************************************************************
 * FUNCTION
 *  aud_melody_set_output_volume
 * DESCRIPTION
 *  
 * PARAMETERS
 *  volume1                 [IN]        
 *  digital_gain_index      [IN]        
 * RETURNS
 *  void
 *****************************************************************************/
void aud_melody_set_output_volume(kal_uint8 volume1, kal_int8 digital_gain_index)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    max_melody_volume1 = (kal_uint16) volume1;
    /* /max_melody_volume2 = (kal_uint16)volume2; */
    aud_melody_set_volume(volume1, digital_gain_index);
}


/*****************************************************************************
 * FUNCTION
 *  aud_set_active_ring_tone_volume
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void aud_set_active_ring_tone_volume(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    /* incoming call ring, alarm, message use the same volume */
    kal_uint8 gain_audio_mode;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    /* store playing melody volume level */
    current_playing_melody_volume_level = aud_get_volume_level(aud_context_p->audio_mode, AUD_VOLUME_MEDIA);
    /* if it's headset mode and output to both earphone & loud speaker, use normal mode gain value */
    if (aud_context_p->audio_mode == AUD_MODE_HEADSET &&
        aud_context_p->melody_output_device == AUDIO_DEVICE_SPEAKER_BOTH)
    {
        gain_audio_mode = VOL_NORMAL;
    }
#if defined(TV_OUT_SUPPORT)
    /* TV out is on, and audio output to TV only */
    else if (audio_tv_cable_in && 
             !audio_tv_loud_speaker &&
             aud_context_p->melody_output_device != AUDIO_DEVICE_SPEAKER_BOTH)
    {
        gain_audio_mode = VOL_TV_OUT;
    }
#endif
    else
    {
        gain_audio_mode = aud_context_p->audio_mode;
    }


    aud_set_melody_volume(gain_audio_mode, current_playing_melody_volume_level);
}


/*****************************************************************************
 * FUNCTION
 *  aud_set_active_sound_volume
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void aud_set_active_sound_volume(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    /* power on/off, cover on/off use the same volume */
    /* the volume gain is for sound, but the volume level is tied with keytone's */
    kal_uint8 volume;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    volume = aud_get_volume_gain(
                aud_context_p->audio_mode,
                AUD_VOLUME_FMR,
                aud_get_volume_level(aud_context_p->audio_mode, VOL_TYPE_GMI));
    aud_melody_set_volume(volume, 0);

}


/*****************************************************************************
 * FUNCTION
 *  aud_get_active_device_path_by_mode
 * DESCRIPTION
 *  
 * PARAMETERS
 *  request_path      [IN]        
 * RETURNS
 *  void
 *****************************************************************************/
void aud_get_active_device_path_by_mode(kal_uint8 request_path, void (*set_path_func)(kal_uint8))
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    kal_uint8 device;
    kal_uint8 output_path;
    
    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    ASSERT(set_path_func != NULL);
    
    if (aud_context_p->audio_mode == AUD_MODE_HEADSET)
    {
        device = custom_cfg_hw_aud_output_path(request_path);
        set_path_func(device);
    }
#if defined(TV_OUT_SUPPORT)
    else /* AUD_MODE_NORMAL, AUD_MODE_LOUDSPK */
    {
    #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 /* __MED_BT_A2DP_MOD__ */ 
        {
            if (audio_tv_cable_in)
            {
                /* Set output path to both TV out and mobile device */
                if(audio_tv_loud_speaker || request_path == AUDIO_DEVICE_SPEAKER_BOTH)
                {
                    output_path = AUDIO_DEVICE_SPEAKER_BOTH;
                }
                else  /* Set output path to earphone to let it play through TV only. */
                {
                    output_path = AUDIO_DEVICE_SPEAKER2;
                }
            }
            else
            {

⌨️ 快捷键说明

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