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

📄 aud_melody.c

📁 最新MTK手机软件源码
💻 C
📖 第 1 页 / 共 5 页
字号:
    switch (event)
    {
        case MEDIA_LED_ON:
            aud_melody_imy_led_hdlr(KAL_TRUE);
            return;
        case MEDIA_LED_OFF:
            aud_melody_imy_led_hdlr(KAL_FALSE);
            return;
        case MEDIA_VIBRATOR_ON:
            aud_melody_imy_vibrator_hdlr(KAL_TRUE);
            return;
        case MEDIA_VIBRATOR_OFF:
            aud_melody_imy_vibrator_hdlr(KAL_FALSE);
            return;
        case MEDIA_BACKLIGHT_ON:
            aud_melody_imy_backlight_hdlr(KAL_TRUE);
            return;
        case MEDIA_BACKLIGHT_OFF:
            aud_melody_imy_backlight_hdlr(KAL_FALSE);
            return;
        case MEDIA_REPEATED:
            aud_melody_stop_driver();
            return;
        case MEDIA_TERMINATED:
            return;
        default:
            break;
    }
    ind_p = (aud_media_play_event_ind_struct*) construct_local_para(sizeof(aud_media_play_event_ind_struct), TD_CTRL);

    ind_p->src_id = aud_context_p->src_id;
    ind_p->event = event;
    ind_p->seq_no = aud_context_p->last_seq_no;

    aud_send_ilm(MOD_MED, MSG_ID_AUD_MEDIA_PLAY_EVENT_IND, ind_p, NULL);
}


/*****************************************************************************
 * FUNCTION
 *  aud_melody_play_imy
 * DESCRIPTION
 *  
 * PARAMETERS
 *  data            [?]         
 *  len             [IN]        
 *  play_style      [IN]        
 * RETURNS
 *  
 *****************************************************************************/
kal_int32 aud_melody_play_imy(kal_uint8 *data, kal_uint32 len, kal_uint8 play_style)
{
#ifdef __MED_MMA_MOD__
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    Media_iMelody_Param *imy_param_p;
    Media_Status status = MEDIA_FAIL;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    if ((aud_context_p->last_handle = JImy_Open(aud_media_ievent_callback, &imy_param_p)) != NULL)
    {
        imy_param_p->imyfile = (const kal_uint8*)data;
        imy_param_p->filesize = len;
        imy_param_p->repeats = aud_melody_play_style_convert(play_style);
        imy_param_p->default_instrument = IMY_DEFAULT_INSTRUMENT;
    #ifdef __MED_BT_A2DP_MOD__
    #if defined(__BTMTK__)
	    aud_bt_a2dp_open_codec();
    #elif defined(__BTVCSR_HCI_BCHS__)
	    aud_bt_a2dp_media_output_hdlr(KAL_TRUE);
    #endif
    #endif /* __MED_BT_A2DP_MOD__ */
        if ((status = JImy_Play(aud_context_p->last_handle)) == MEDIA_SUCCESS)
        {
            /* enter AUD_MEDIA_PLAY state */
            AUD_ENTER_STATE(AUD_MEDIA_PLAY);
        #if defined(__BTVCSR_HCI_BCHS__) && defined(__MED_BT_A2DP_MOD__)
            aud_bt_a2dp_media_play_hdlr();
        #endif 
        }
        else
        {
            JImy_Close(aud_context_p->last_handle);
            aud_context_p->last_handle = NULL;
            /* stop volume crescendo timer */
            med_stop_timer(AUD_TIMER_CRESCENDO);
        #if defined(__BTVCSR_HCI_BCHS__) && defined(__MED_BT_A2DP_MOD__)
            aud_bt_a2dp_media_output_hdlr(KAL_FALSE);
        #endif 
        }
    }
    else
    {
        /* stop volume crescendo timer */
        med_stop_timer(AUD_TIMER_CRESCENDO);
    }
#else /* __MED_MMA_MOD__ */ 
    Media_iMelody_Param msp;
    Media_Status status = MEDIA_FAIL;

    msp.imyfile = (const kal_uint8*)data;
    msp.filesize = len;
    msp.repeats = aud_melody_play_style_convert(play_style);
    msp.default_instrument = IMY_DEFAULT_INSTRUMENT;

    Media_SetBuffer(aud_context_p->ring_buf, AUD_RING_BUFFER_LEN);
    if ((status = Media_Play((Media_Format) MED_TYPE_IMELODY, aud_media_event_callback, &msp)) == MEDIA_SUCCESS)
    {
        /* enter AUD_MEDIA_PLAY state */
        AUD_ENTER_STATE(AUD_MEDIA_PLAY);
    }
    else
    {
        /* stop volume crescendo timer */
        med_stop_timer(AUD_TIMER_CRESCENDO);
    }
#endif /* __MED_MMA_MOD__ */ 

    AUD_VALUE_TRACE(status, -1, -1);

    return aud_get_res((kal_uint8) status);
}


/*****************************************************************************
 * FUNCTION
 *  aud_melody_play_smf
 * DESCRIPTION
 *  
 * PARAMETERS
 *  data            [?]         
 *  len             [IN]        
 *  play_style      [IN]        
 * RETURNS
 *  
 *****************************************************************************/
kal_int32 aud_melody_play_smf(kal_uint8 *data, kal_uint32 len, kal_uint8 play_style)
{
#ifdef __MED_MMA_MOD__
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    Media_SMF_Param *smf_param_p;
    Media_Status status = MEDIA_FAIL;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    if ((aud_context_p->last_handle = JSmf_Open(aud_media_ievent_callback, &smf_param_p)) != NULL)
    {
        smf_param_p->smffile = (const kal_uint8*)data;
        smf_param_p->filesize = len;
        smf_param_p->repeats = aud_melody_play_style_convert(play_style);
    #ifdef __MED_BT_A2DP_MOD__
    #if defined(__BTMTK__)
	    aud_bt_a2dp_open_codec();
    #elif defined(__BTVCSR_HCI_BCHS__)
	    aud_bt_a2dp_media_output_hdlr(KAL_TRUE);
    #endif
    #endif /* __MED_BT_A2DP_MOD__ */ 
        if ((status = JSmf_Play(aud_context_p->last_handle)) == MEDIA_SUCCESS)
        {
            /* enter AUD_MEDIA_PLAY state */
            AUD_ENTER_STATE(AUD_MEDIA_PLAY);
        #if defined(__BTVCSR_HCI_BCHS__) && defined(__MED_BT_A2DP_MOD__)
            aud_bt_a2dp_media_play_hdlr();
        #endif 
        }
        else
        {
            JSmf_Close(aud_context_p->last_handle);
            aud_context_p->last_handle = NULL;
            /* stop volume crescendo timer */
            med_stop_timer(AUD_TIMER_CRESCENDO);
        #if defined(__BTVCSR_HCI_BCHS__) && defined(__MED_BT_A2DP_MOD__)
            aud_bt_a2dp_media_output_hdlr(KAL_FALSE);
        #endif 
        }
    }
    else    /* free file buffer */
    {
        /* stop volume crescendo timer */
        med_stop_timer(AUD_TIMER_CRESCENDO);
    }
#else /* __MED_MMA_MOD__ */ 
    Media_SMF_Param msp;
    Media_Status status = MEDIA_FAIL;

    msp.smffile = (const kal_uint8*)data;
    msp.filesize = len;
    msp.repeats = aud_melody_play_style_convert(play_style);

    Media_SetBuffer(aud_context_p->ring_buf, AUD_RING_BUFFER_LEN);
    if ((status = Media_Play((Media_Format) MED_TYPE_SMF, aud_media_event_callback, &msp)) == MEDIA_SUCCESS)
    {
        /* enter AUD_MEDIA_PLAY state */
        AUD_ENTER_STATE(AUD_MEDIA_PLAY);
    }
    else
    {
        /* stop volume crescendo timer */
        med_stop_timer(AUD_TIMER_CRESCENDO);
    }
#endif /* __MED_MMA_MOD__ */ 

    AUD_VALUE_TRACE(status, -1, -1);

    return aud_get_res((kal_uint8) status);
}


/*****************************************************************************
 * FUNCTION
 *  aud_melody_play_mmf
 * DESCRIPTION
 *  
 * PARAMETERS
 *  data            [?]         
 *  len             [IN]        
 *  play_style      [IN]        
 * RETURNS
 *  
 *****************************************************************************/
kal_int32 aud_melody_play_mmf(kal_uint8 *data, kal_uint32 len, kal_uint8 play_style)
{
#if defined(__MED_MMA_MOD__) && defined(MMF_DECODE)
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    Media_MMF_Param *mmf_param_p;
    Media_Status status = MEDIA_FAIL;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    if ((aud_context_p->last_handle = JMmf_Open(aud_media_ievent_callback, &mmf_param_p)) != NULL)
    {
        mmf_param_p->mmffile = (const kal_uint8*)data;
        mmf_param_p->filesize = len;
        mmf_param_p->repeats = aud_melody_play_style_convert(play_style);
    #ifdef __MED_BT_A2DP_MOD__
    #if defined(__BTMTK__)
	    aud_bt_a2dp_open_codec();
    #elif defined(__BTVCSR_HCI_BCHS__)
	    aud_bt_a2dp_media_output_hdlr(KAL_TRUE);
    #endif
    #endif /* __MED_BT_A2DP_MOD__ */ 
        if ((status = JMmf_Play(aud_context_p->last_handle)) == MEDIA_SUCCESS)
        {
            /* enter AUD_MEDIA_PLAY state */
            AUD_ENTER_STATE(AUD_MEDIA_PLAY);
        #if defined(__BTVCSR_HCI_BCHS__) && defined(__MED_BT_A2DP_MOD__)
            aud_bt_a2dp_media_play_hdlr();
        #endif 
        }
        else
        {
            JMmf_Close(aud_context_p->last_handle);
            aud_context_p->last_handle = NULL;
            /* stop volume crescendo timer */
            med_stop_timer(AUD_TIMER_CRESCENDO);
        #if defined(__BTVCSR_HCI_BCHS__) && defined(__MED_BT_A2DP_MOD__)
            aud_bt_a2dp_media_output_hdlr(KAL_FALSE);
        #endif 
        }
    }
    else    /* free file buffer */
    {
        /* stop volume crescendo timer */
        med_stop_timer(AUD_TIMER_CRESCENDO);
    }
#else /* defined(__MED_MMA_MOD__) && defined(MMF_DECODE) */ 
    Media_MMF_Param msp;
    Media_Status status = MEDIA_FAIL;

    msp.mmffile = (const kal_uint8*)data;
    msp.filesize = len;
    msp.repeats = aud_melody_play_style_convert(play_style);

    // #ifdef SW_SYN_16K
    Media_SetBuffer(aud_context_p->ring_buf, AUD_RING_BUFFER_LEN);
    // #endif
    if ((status = Media_Play((Media_Format) MED_TYPE_MMF, aud_media_event_callback, &msp)) == MEDIA_SUCCESS)
    {
        /* enter AUD_MEDIA_PLAY state */
        AUD_ENTER_STATE(AUD_MEDIA_PLAY);
    }
    else
    {
        /* stop volume crescendo timer */
        med_stop_timer(AUD_TIMER_CRESCENDO);
    }
#endif /* defined(__MED_MMA_MOD__) && defined(MMF_DECODE) */ 

    AUD_VALUE_TRACE(status, -1, -1);

    return aud_get_res((kal_uint8) status);
}


/*****************************************************************************
 * FUNCTION
 *  aud_melody_play_by_id
 * DESCRIPTION
 *  
 * PARAMETERS
 *  audio_id                [IN]        
 *  play_style              [IN]        
 *  audio_out_device        [IN]        
 * RETURNS
 *  void
 *****************************************************************************/
void aud_melody_play_by_id(kal_uint8 audio_id, kal_uint8 play_style, kal_uint8 audio_out_device)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    kal_uint8 rel_audio_id;
    kal_int32 res;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    aud_context_p->source_type = AUD_ID;
    aud_context_p->audio_id = audio_id;
    aud_context_p->play_style = play_style;

    /* set to the volume of ringtone */
    aud_set_active_ring_tone_volume();
    /* long imelody for incoming call and alarm */
    if ((audio_id >= aud_context_p->min_fixed_imy_id) && (audio_id <= aud_context_p->max_fixed_imy_id))
    {
        rel_audio_id = audio_id - aud_context_p->min_fixed_imy_id;
        aud_context_p->current_format = resource_imelodys[rel_audio_id].format;
        aud_context_p->string_p = (kal_uint8*) resource_imelodys[rel_audio_id].data;
        aud_context_p->buf_len = resource_imelodys[rel_audio_id].len;
    }
    /* long midi for incoming call and alarm */
    else if ((audio_id >= aud_context_p->min_fixed_midi_id) && (audio_id <= aud_context_p->max_fixed_midi_id))
    {
        rel_audio_id = audio_id - aud_context_p->min_fixed_midi_id;
        aud_context_p->current_format = resource_midis[rel_audio_id].format;
        aud_context_p->string_p = (kal_uint8*) resource_midis[rel_audio_id].data;
        aud_context_p->buf_len = resource_midis[rel_audio_id].len;
    }
    /* short sound for cover open/close, power on/off */
    else if ((audio_id >= aud_context_p->min_fixed_sound_id) && (audio_id <= aud_context_p->max_fixed_sound_id))
    {
        rel_audio_id = audio_id - aud_context_p->min_fixed_sound_id;
        aud_context_p->current_format = resource_sounds[rel_audio_id].format;
        aud_context_p->string_p = (kal_uint8*) resource_sounds[rel_audio_id].data;
        aud_context_p->buf_len = resource_sounds[rel_audio_id].len;
    }
    /* short sound for message */
    else if ((audio_id >= aud_context_p->min_fixed_message_sound_id) &&
             (audio_id <= aud_context_p->max_fixed_message_sound_id))
    {

        rel_audio_id = audio_id - aud_context_p->min_fixed_message_sound_id;
        aud_context_p->current_format = resource_message_sounds[rel_audio_id].format;
        aud_context_p->string_p = (kal_uint8*) resource_message_sounds[rel_audio_id].data;
        aud_context_p

⌨️ 快捷键说明

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