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

📄 aud_melody.c

📁 最新MTK手机软件源码
💻 C
📖 第 1 页 / 共 5 页
字号:
/*****************************************************************************
*  Copyright Statement:
*  --------------------
*  This software is protected by Copyright and the information contained
*  herein is confidential. The software may not be copied and the information
*  contained herein may not be used or disclosed except with the written
*  permission of MediaTek Inc. (C) 2005
*
*  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
*  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
*  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
*  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
*  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
*  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
*  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
*  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
*  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
*  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
*  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
*  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
*  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
*  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
*  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
*  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
*  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. 
*
*  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
*  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
*  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
*  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
*  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/

/*******************************************************************************
 * Filename:
 * ---------
 * aud_melody.c
 *
 * Project:
 * --------
 *   Maui
 *
 * Description:
 * ------------
 *   This file includes voice memo related functions of audio manager task.
 *
 * Author:
 * -------
 * -------
 *
 *==============================================================================
 *             HISTORY
 * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! 
 *------------------------------------------------------------------------------
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 *------------------------------------------------------------------------------
 * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! 
 *==============================================================================
 *******************************************************************************/

/******************************************************************
 * MODULE
 *    AUD_VM
 * DESCRIPTION
 *    This module defines the voice memo related function for Audio Manager.
 *  
 ******************************************************************/

#ifndef MED_NOT_PRESENT

/*==== INCLUDES =======*/

#include "kal_release.h"
#include "kal_trace.h"
#include "stack_common.h"
#include "stack_msgs.h"
#include "app_ltlcom.h" /* Task message communiction */
#include "syscomp_config.h"
#include "task_config.h"        /* Task creation */
#include "stacklib.h"   /* Basic type for dll, evshed, stacktimer */
#include "event_shed.h" /* Event scheduler */
#include "stack_timer.h"        /* Stack timer */

/* global includes */
#include "l1audio.h"
#include "gpio_sw.h"
#include "alerter_sw.h"
#include "device.h"
#include "resource_audio.h"
#include "custom_equipment.h"
#include "nvram_enums.h"
#include "nvram_struct.h"
#include "nvram_user_defs.h"
#include "nvram_data_items.h"
#include "custom_nvram_editor_data_item.h"
/* for FAT FS */
#include "fat_fs.h"
/* DRM_REPLACE */
#include "drm_gprot.h"

/* local includes */
#include "med_global.h"
#include "aud_defs.h"
#include "med_struct.h"
#include "med_api.h"
#include "med_context.h"
#include "med_utility.h"
#include "med_main.h"
#include "aud_main.h"

#ifdef __AUD_TRACE_ON__
#include "med_trc.h"
#endif 

#ifdef __MMI_SUPPORT_BACKLIGHT_SYNC__
/* -- added for turn on/off backlight by MMI task -- */
#include "mmiapi_struct.h"
#endif /* __MMI_SUPPORT_BACKLIGHT_SYNC__ */ 

#include "aud_daf_parser.h"

/*==== IMPORTS =======*/
#define AMR_HEADER   "#!AMR\n"
#define AWB_HEADER   "#!AMR-WB\n"

#define MAX_MELODY_DIR 20
#define MELODY_FULL_NAME (MAX_MELODY_FILE_NAME+MAX_MELODY_DIR)
#define CRESCENDO_STEPS  4

static kal_uint16 max_melody_volume1;

/* /static kal_uint16 max_melody_volume2; */
static kal_uint16 current_melody_volume1;

/* /static kal_uint16 current_melody_volume2; */
static kal_uint16 melody_volume_step1;

/* /static kal_uint16 melody_volume_step2; */

#ifdef __MMI_SUPPORT_BACKLIGHT_SYNC__
/* -- added for turn on/off backlight by MMI task -- */
#define CTRL_BACKLIGHT_REQ_IDLE 0
#define CTRL_BACKLIGHT_REQ_WAIT 1
#define CTRL_BACKLIGHT_REQ_WAIT_CLOSE 2
#define CTRL_BACKLIGHT_REQ_CLOSE 3
static kal_uint8 backlight_ctrl_state = CTRL_BACKLIGHT_REQ_IDLE;
static kal_bool backlight_ctrl_in_use = KAL_FALSE;
static volatile kal_mutexid backlight_ctrl_mutex;
#endif /* __MMI_SUPPORT_BACKLIGHT_SYNC__ */ 

#ifdef __MMI_SUPPORT_LED_SYNC__
/* -- added for turn on/off led by MMI task -- */
static kal_uint8 wait_for_led_ctrl_rsp = 0;
static volatile kal_mutexid led_ctrl_mutex;
#endif /* __MMI_SUPPORT_LED_SYNC__ */ 

kal_uint8 current_playing_melody_volume_level = 0;  /* this variable will keep track of current playing melody volume level */

#if defined(TV_OUT_SUPPORT)
extern kal_bool audio_tv_cable_in;
extern kal_bool audio_tv_loud_speaker;
#endif

#ifdef __MED_BT_A2DP_MOD__
#if defined(__BTMTK__)
extern void aud_bt_a2dp_open_codec(void);
extern kal_bool aud_bt_a2dp_is_mute_phone(void);
#elif defined(__BTVCSR_HCI_BCHS__)
extern void aud_bt_a2dp_media_output_hdlr(kal_bool on);
extern void aud_bt_a2dp_media_play_hdlr(void);
extern void aud_bt_a2dp_media_pause_hdlr(void);
extern void aud_bt_a2dp_media_resume_hdlr(void);
extern void aud_bt_a2dp_media_stop_hdlr(void);
extern kal_bool aud_bt_a2dp_is_media_output_on(void);
#endif
#endif /* __MED_BT_A2DP_MOD__ */ 


/*****************************************************************************
 * FUNCTION
 *  aud_melody_init
 * DESCRIPTION
 *  This function is used to init aud_melody module
 * PARAMETERS
 *  void
 * RETURNS
 *  
 *****************************************************************************/
kal_bool aud_melody_init(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    aud_context_p->vibrator_enabled = KAL_TRUE;
    aud_context_p->vibrator_on = KAL_FALSE;
    aud_context_p->led_on = KAL_FALSE;
    aud_context_p->backlight_on = KAL_TRUE;

    aud_context_p->vibrator_on_stored = KAL_FALSE;
    aud_context_p->led_on_stored = KAL_FALSE;
    aud_context_p->backlight_on_stored = KAL_TRUE;

    aud_context_p->source_type = AUD_UNKNOWN_SOURCE_TYPE;
    aud_context_p->media_playing = KAL_FALSE;
    aud_context_p->audio_id = 255;
    aud_context_p->string_p = NULL;

    custom_get_fixed_imelody_range(&aud_context_p->min_fixed_imy_id, &aud_context_p->max_fixed_imy_id);
    custom_get_fixed_midi_range(&aud_context_p->min_fixed_midi_id, &aud_context_p->max_fixed_midi_id);
    custom_get_fixed_sound_range(&aud_context_p->min_fixed_sound_id, &aud_context_p->max_fixed_sound_id);
    custom_get_fixed_message_sound_range(
        &aud_context_p->min_fixed_message_sound_id,
        &aud_context_p->max_fixed_message_sound_id);

    /* create the a semaphore */
    aud_context_p->media_sem = kal_create_sem("MEDIA SEM", 1);

#ifdef __MMI_SUPPORT_BACKLIGHT_SYNC__
    backlight_ctrl_mutex = kal_create_mutex("backlight_ctrl_mutex");
#endif 
#ifdef __MMI_SUPPORT_LED_SYNC__
    led_ctrl_mutex = kal_create_mutex("led_ctrl_mutex");
#endif 
    return KAL_TRUE;
}


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

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    if (aud_context_p->melody_string_p)
    {
        med_free_ext_mem((void **)&aud_context_p->melody_string_p);
    }
}


/*****************************************************************************
 * FUNCTION
 *  aud_set_vibrator_enabled_req_hdlr
 * DESCRIPTION
 *  
 * PARAMETERS
 *  ilm_ptr     [?]     
 * RETURNS
 *  void
 *****************************************************************************/
void aud_set_vibrator_enabled_req_hdlr(ilm_struct *ilm_ptr)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    media_aud_set_vibrator_enabled_req_struct *msg_p =
        (media_aud_set_vibrator_enabled_req_struct*) ilm_ptr->local_para_ptr;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    aud_context_p->vibrator_enabled = (kal_bool) msg_p->enabled;
}

#ifdef __MMI_SUPPORT_BACKLIGHT_SYNC__
/* -- added for turn on/off backlight by MMI task -- */


/*****************************************************************************
 * FUNCTION
 *  aud_backlight_ctrl_rsp_hdlr
 * DESCRIPTION
 *  
 * PARAMETERS
 *  ilm_ptr     [?]     

⌨️ 快捷键说明

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