📄 aud_mma.c
字号:
case MEDIA_LED_OFF:
aud_melody_imy_led_hdlr(KAL_FALSE);
return;
case MEDIA_VIBRATOR_ON:
#ifdef __J2ME__
if (jam_get_vib_on())
#endif
aud_melody_imy_vibrator_hdlr(KAL_TRUE);
return;
case MEDIA_VIBRATOR_OFF:
#ifdef __J2ME__
if (jam_get_vib_on())
#endif
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;
case MEDIA_ERROR:
case MEDIA_END:
aud_melody_stop_driver();
break;
default:
break;
}
/* send indication message to L4 */
ind_p = (media_mma_play_event_ind_struct*) construct_local_para(sizeof(media_mma_play_event_ind_struct), TD_CTRL);
ind_p->handle = (kal_int32) handle;
ind_p->event = (kal_uint8) event;
aud_send_ilm(MOD_MED, MSG_ID_MEDIA_MMA_PLAY_EVENT_IND, ind_p, NULL);
}
/*****************************************************************************
* FUNCTION
* aud_mma_event_callback_1
* DESCRIPTION
* This function is to handle play event callback.
* PARAMETERS
* event [IN]
* Media_Handle *handle(?)
* RETURNS
* void
*****************************************************************************/
void aud_mma_event_callback_1(Media_Event event)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
media_mma_play_event_ind_struct *ind_p = NULL;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
switch (event)
{
case MEDIA_LED_ON:
case MEDIA_LED_OFF:
case MEDIA_VIBRATOR_ON:
case MEDIA_VIBRATOR_OFF:
case MEDIA_BACKLIGHT_ON:
case MEDIA_BACKLIGHT_OFF:
case MEDIA_REPEATED:
case MEDIA_TERMINATED:
return;
case MEDIA_ERROR:
case MEDIA_END:
aud_melody_stop_driver();
break;
default:
break;
}
/* send indication message to L4 */
ind_p = (media_mma_play_event_ind_struct*) construct_local_para(sizeof(media_mma_play_event_ind_struct), TD_CTRL);
ind_p->handle = (kal_int32) aud_context_p->current_file_handle;
ind_p->event = (kal_uint8) event;
aud_send_ilm(MOD_MED, MSG_ID_MEDIA_MMA_PLAY_EVENT_IND, ind_p, NULL);
}
/*****************************************************************************
* FUNCTION
* aud_mma_play_event_ind_hdlr
* DESCRIPTION
* This function is to handle play event indication.
* PARAMETERS
* ilm_ptr [?]
* RETURNS
* void
*****************************************************************************/
void aud_mma_play_event_ind_hdlr(ilm_struct *ilm_ptr)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
kal_uint8 i;
kal_int32 handle;
media_mma_play_event_ind_struct *ind_p;
med_handler handler;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
ind_p = (media_mma_play_event_ind_struct*) ilm_ptr->local_para_ptr;
handle = ind_p->handle;
switch (ind_p->event)
{
case MEDIA_END:
case MEDIA_ERROR:
case MEDIA_TERMINATED:
case MEDIA_DATA_REQUEST:
case MEDIA_DATA_NOTIFICATION:
if (handle != NULL)
{
aud_player_struct *player_p;
for (i = 0; i < MMA_NO_OF_PLAYER; i++)
{
player_p = &(aud_context_p->player[i]);
if (player_p->used && player_p->handle == handle)
{
handler = (med_handler) player_p->handler_func;
if (handler)
{
handler(handle, ind_p->event);
}
break;
}
}
}
break;
default:
break;
}
}
/*****************************************************************************
* FUNCTION
* aud_mma_open_req_hdlr
* DESCRIPTION
* This function is to open media handle.
* PARAMETERS
* ilm_ptr [?]
* RETURNS
* void
*****************************************************************************/
void aud_mma_open_req_hdlr(ilm_struct *ilm_ptr)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
media_mma_open_req_struct *req_p;
Media_Handle *handle = NULL;
aud_player_struct *player_p;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
req_p = (media_mma_open_req_struct*) ilm_ptr->local_para_ptr;
if (aud_context_p->access_mod != ilm_ptr->src_mod_id)
{
mma_set_handle(NULL);
MMA_SET_EVENT(MMA_EVT_OPEN);
return;
}
if (aud_context_p->speech_on)
{
mma_set_handle(NULL);
MMA_SET_EVENT(MMA_EVT_OPEN);
return;
}
/* stop playing tasks before open any multiple play task */
if (AUD_IN_STATE(AUD_MEDIA_PLAY) || AUD_IN_STATE(AUD_MEDIA_PLAY_PAUSED) || AUD_IN_STATE(AUD_MEDIA_PLAY_FINISH))
{
aud_stop_unfinished_process();
}
ASSERT(aud_context_p->state == AUD_MEDIA_IDLE);
switch (req_p->media_type)
{
case MMA_TYPE_MIDI:
{
kal_uint8 i;
for (i = MMA_PLAYER_SMF_1; i <= MMA_PLAYER_SMF_4; i++)
{
player_p = &(aud_context_p->player[i]);
if (!player_p->used)
{
Media_SMF_Param *smf_param_p;
aud_mma_close_all_single_player();
player_p->handler_func = req_p->handler;
if ((handle = JSmf_Open(aud_mma_event_callback, (Media_SMF_Param **) & smf_param_p)) != NULL)
{
player_p->handle = (kal_int32) handle;
smf_param_p->smffile = (const kal_uint8*)req_p->data;
smf_param_p->filesize = (kal_int32) req_p->size;
smf_param_p->repeats = (kal_int16) req_p->repeats;
player_p->used = KAL_TRUE;
}
break;
}
}
break;
}
case MMA_TYPE_TONE:
{
kal_uint8 i;
for (i = MMA_PLAYER_TONE_S1; i <= MMA_PLAYER_TONE_S4; i++)
{
player_p = &(aud_context_p->player[i]);
if (!player_p->used)
{
aud_mma_close_all_single_player();
player_p->handler_func = req_p->handler;
if ((handle = JTone_Open(aud_mma_event_callback, (Media_ToneSeq_Param **) & player_p->param_p)) != NULL)
{
player_p->handle = (kal_int32) handle;
player_p->used = KAL_TRUE;
}
break;
}
}
break;
}
case MMA_TYPE_WAV:
{
kal_uint8 i;
for (i = MMA_PLAYER_WAV_1; i <= MMA_PLAYER_WAV_3; i++)
{
player_p = &(aud_context_p->player[i]);
if (!player_p->used)
{
kal_uint32 buf_len;
Media_Status status = MEDIA_FAIL;
Media_Wav_Param *wav_param_p;
aud_mma_close_all_single_player();
player_p->handler_func = req_p->handler;
if ((handle = JWav_Open(aud_mma_event_callback, (Media_Wav_Param **) & wav_param_p)) != NULL)
{
player_p->handle = (kal_int32) handle;
wav_param_p->wavefile = (const kal_uint8*)req_p->data;
wav_param_p->filesize = req_p->size;
wav_param_p->repeats = req_p->repeats;
if ((status = JWav_Load(handle, &buf_len)) != MEDIA_SUCCESS)
{
JWav_Close(handle);
AUD_VALUE_TRACE(status, req_p->size, buf_len);
handle = NULL;
break;
}
if ((player_p->buf_p = (kal_int16*) med_alloc_ext_mem(buf_len * sizeof(kal_uint16))) != NULL)
{
JWav_SetBuffer(handle, player_p->buf_p, buf_len);
}
else
{
JWav_Close(handle);
AUD_VALUE_TRACE(status, req_p->size, buf_len);
handle = NULL;
ASSERT(player_p->buf_p != NULL);
break;
}
player_p->used = KAL_TRUE;
}
break;
}
}
break;
}
case MMA_TYPE_IMY:
{
Media_iMelody_Param *imy_param_p;
player_p = &(aud_context_p->player[MMA_PLAYER_IMY]);
if (!player_p->used)
{
aud_mma_close_all_single_player();
player_p->handler_func = req_p->handler;
if ((handle = JImy_Open(aud_mma_event_callback, (Media_iMelody_Param **) & imy_param_p)) != NULL)
{
player_p->handle = (kal_int32) handle;
imy_param_p->imyfile = (const kal_uint8*)req_p->data;
imy_param_p->filesize = (kal_int32) req_p->size;
imy_param_p->repeats = (kal_int16) req_p->repeats;
imy_param_p->default_instrument = IMY_DEFAULT_INSTRUMENT;
player_p->used = KAL_TRUE;
}
}
break;
}
/* single player, can't play with other players simultaneously */
#ifdef MMA_AMR_SUPPORT
case MMA_TYPE_AMR:
{
Media_AMR_Param *amr_param_p;
player_p = &(aud_context_p->player[MMA_PLAYER_AMR]);
if (!player_p->used)
{
aud_mma_close_all_multi_player();
player_p->handler_func = req_p->handler;
if ((handle = JAmr_Open(aud_mma_event_callback, (Media_AMR_Param **) & amr_param_p)) != NULL)
{
player_p->handle = (kal_int32) handle;
amr_param_p->amrfile = (const kal_uint8*)req_p->data;
amr_param_p->filesize = (kal_int32) req_p->size;
amr_param_p->repeats = (kal_int16) req_p->repeats;
player_p->used = KAL_TRUE;
}
}
break;
}
#endif /* MMA_AMR_SUPPORT */
#ifdef DAF_DECODE
case MMA_TYPE_DAF:
{
player_p = &(aud_context_p->player[MMA_PLAYER_DAF]);
if (!player_p->used)
{
aud_mma_close_all_multi_player();
player_p->handler_func = req_p->handler;
aud_context_p->current_file_handle = MMA_PLAYER_DAF;
handle = (Media_Handle*) MMA_PLAYER_DAF;
player_p->handle = (kal_int32) aud_context_p->current_file_handle;
Media_SetBuffer((kal_uint16*) req_p->data, (kal_uint32) ((req_p->size >> 1) + 1));
Media_WriteDataDone(req_p->size >> 1);
Media_DataFinished();
player_p->used = KAL_TRUE;
}
break;
}
#endif /* DAF_DECODE */
#ifdef AAC_DECODE
case MMA_TYPE_AAC:
{
player_p = &(aud_context_p->player[MMA_PLAYER_AAC]);
if (!player_p->used)
{
aud_mma_close_all_multi_player();
player_p->handler_func = req_p->handler;
aud_context_p->current_file_handle = MMA_PLAYER_AAC;
handle = (Media_Handle*) MMA_PLAYER_AAC;
player_p->handle = (kal_int32) aud_context_p->current_file_handle;
Media_SetBuffer((kal_uint16*) req_p->data, (kal_uint32) ((req_p->size >> 1) + 1));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -