📄 aud_media.c
字号:
* This function is ....
* PARAMETERS
* res [?]
* RETURNS
* void
*****************************************************************************/
kal_bool aud_media_pause_file_stream(kal_uint8 *res)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
Media_Status result;
media_ctrl_func_ptr pauseFunc, closeFunc;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
switch (aud_context_p->current_format)
{
case MED_TYPE_AMR:
case MED_TYPE_AMR_WB:
case MED_TYPE_GSM_EFR:
case MED_TYPE_VR:
case MED_TYPE_PCM_8K:
case MED_TYPE_PCM_16K:
case MED_TYPE_DVI_ADPCM:
case MED_TYPE_DAF:
case MED_TYPE_WAV:
case MED_TYPE_WAV_ALAW:
case MED_TYPE_WAV_ULAW:
case MED_TYPE_WAV_DVI_ADPCM:
case MED_TYPE_AU:
case MED_TYPE_AIFF:
case MED_TYPE_AAC:
case MED_TYPE_WMA:
case MED_TYPE_M4A:
break;
default:
return KAL_FALSE;
}
pauseFunc = aud_context_p->last_mhdl_handle->Pause;
closeFunc = aud_context_p->last_mhdl_handle->Close;
result = pauseFunc(aud_context_p->last_mhdl_handle);
if (result == MEDIA_SUCCESS)
{
*res = MED_RES_OK;
AUD_ENTER_STATE(AUD_MEDIA_PLAY_PAUSED);
#if defined(__BTVCSR_HCI_BCHS__) && defined(__MED_BT_A2DP_MOD__)
aud_bt_a2dp_media_pause_hdlr();
#endif
}
else if (result == MEDIA_UNSUPPORTED_OPERATION)
{
*res = MED_RES_UNSUPPORTED_OPERATION;
}
else
{
/* close handle */
closeFunc(aud_context_p->last_mhdl_handle);
aud_media_close_file_handle();
aud_context_p->last_mhdl_handle = NULL;
AUD_ENTER_STATE(AUD_MEDIA_IDLE);
/* stop volume crescendo timer */
med_stop_timer(AUD_TIMER_CRESCENDO);
*res = aud_get_res((kal_uint8) result);
#if defined(__BTVCSR_HCI_BCHS__) && defined(__MED_BT_A2DP_MOD__)
aud_bt_a2dp_media_stop_hdlr();
#endif
aud_context_p->last_mhdl_handle = NULL;
}
return KAL_TRUE;
}
/*****************************************************************************
* FUNCTION
* aud_media_resume_file_stream
* DESCRIPTION
* This function is ....
* PARAMETERS
* res [?]
* RETURNS
* void
*****************************************************************************/
kal_bool aud_media_resume_file_stream(kal_uint8 *res)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
Media_Status result;
media_ctrl_func_ptr resumeFunc, closeFunc;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
switch (aud_context_p->current_format)
{
case MED_TYPE_AMR:
case MED_TYPE_AMR_WB:
case MED_TYPE_GSM_EFR:
case MED_TYPE_VR:
case MED_TYPE_PCM_8K:
case MED_TYPE_PCM_16K:
case MED_TYPE_DVI_ADPCM:
case MED_TYPE_DAF:
case MED_TYPE_WAV:
case MED_TYPE_WAV_ALAW:
case MED_TYPE_WAV_ULAW:
case MED_TYPE_WAV_DVI_ADPCM:
case MED_TYPE_AU:
case MED_TYPE_AIFF:
case MED_TYPE_AAC:
case MED_TYPE_WMA:
case MED_TYPE_M4A:
break;
default:
return KAL_FALSE;
}
/* Seek while paused state, need to replay again for resume */
if (aud_context_p->state == AUD_MEDIA_SEEK_PAUSED)
{
*res = aud_media_replay_by_handle(0, KAL_FALSE);
#if defined(__BTVCSR_HCI_BCHS__) && defined(__MED_BT_A2DP_MOD__)
if (*res == MED_RES_OK)
{
aud_bt_a2dp_media_resume_hdlr();
}
#endif /* __BTVCSR_HCI_BCHS__ && __MED_BT_A2DP_MOD__ */
return KAL_TRUE;
}
#if defined(__BTMTK__) && defined(__MED_BT_A2DP_MOD__)
aud_bt_a2dp_open_codec();
#endif
/* Resume from paused state */
resumeFunc = aud_context_p->last_mhdl_handle->Resume;
closeFunc = aud_context_p->last_mhdl_handle->Close;
result = resumeFunc(aud_context_p->last_mhdl_handle);
if (result == MEDIA_SUCCESS)
{
*res = MED_RES_OK;
AUD_ENTER_STATE(AUD_MEDIA_PLAY);
#if defined(__BTVCSR_HCI_BCHS__) && defined(__MED_BT_A2DP_MOD__)
aud_bt_a2dp_media_resume_hdlr();
#endif
}
else
{
/* close handle */
closeFunc(aud_context_p->last_mhdl_handle);
aud_media_close_file_handle();
aud_context_p->last_mhdl_handle = NULL;
AUD_ENTER_STATE(AUD_MEDIA_IDLE);
/* stop volume crescendo timer */
med_stop_timer(AUD_TIMER_CRESCENDO);
*res = aud_get_res((kal_uint8) result);
}
return KAL_TRUE;
}
/*****************************************************************************
* FUNCTION
* aud_media_process_file_stream
* DESCRIPTION
* This function is ....
* PARAMETERS
* ilm_ptr [?]
* RETURNS
* void
*****************************************************************************/
kal_bool aud_media_process_file_stream(ilm_struct *ilm_ptr)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
Media_Event result;
kal_uint8 replay_result = MED_RES_FAIL;
media_proc_func_ptr procFunc;
media_ctrl_func_ptr stopFunc, closeFunc;
kal_uint8 res;
aud_media_play_stream_event_ind_struct *ind_p = (aud_media_play_stream_event_ind_struct*) ilm_ptr->local_para_ptr;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (aud_context_p->last_seq_no != ind_p->seq_no ||
(aud_context_p->state != AUD_MEDIA_PLAY && aud_context_p->state != AUD_MEDIA_PLAY_PAUSED))
{
AUD_VALUE_TRACE(ind_p->seq_no, aud_context_p->last_seq_no, aud_context_p->state);
return KAL_FALSE;
}
switch (aud_context_p->current_format)
{
case MED_TYPE_AMR:
case MED_TYPE_AMR_WB:
case MED_TYPE_GSM_EFR:
case MED_TYPE_VR:
case MED_TYPE_PCM_8K:
case MED_TYPE_PCM_16K:
case MED_TYPE_DVI_ADPCM:
case MED_TYPE_DAF:
case MED_TYPE_WAV:
case MED_TYPE_WAV_ALAW:
case MED_TYPE_WAV_ULAW:
case MED_TYPE_WAV_DVI_ADPCM:
case MED_TYPE_AU:
case MED_TYPE_AIFF:
case MED_TYPE_AAC:
case MED_TYPE_WMA:
case MED_TYPE_M4A:
break;
default:
return KAL_FALSE;
}
procFunc = aud_context_p->last_mhdl_handle->Process;
stopFunc = aud_context_p->last_mhdl_handle->Stop;
closeFunc = aud_context_p->last_mhdl_handle->Close;
if (aud_context_p->state == AUD_MEDIA_PLAY)
{
result = procFunc(aud_context_p->last_mhdl_handle, (Media_Event) ind_p->event);
if (result != MEDIA_NONE)
{
/* Enter AUD_MEDIA_IDLE state */
AUD_ENTER_STATE(AUD_MEDIA_IDLE);
/* Stop volume crescendo timer */
med_stop_timer(AUD_TIMER_CRESCENDO);
/* Stop play */
temp_last_time = aud_context_p->last_mhdl_handle->GetCurrentTime(aud_context_p->last_mhdl_handle);
stopFunc(aud_context_p->last_mhdl_handle);
aud_context_p->last_seq_no++;
/* Play again */
if ((result == MEDIA_END) && (aud_context_p->play_style != DEVICE_AUDIO_PLAY_ONCE))
{
replay_result = aud_media_replay_by_handle(aud_context_p->play_style, KAL_TRUE);
}
else /* No replay, clost it */
{
closeFunc(aud_context_p->last_mhdl_handle);
aud_media_close_file_handle();
aud_context_p->last_mhdl_handle = NULL;
}
AUD_VALUE_TRACE(result, replay_result, aud_context_p->play_style);
/* No replay or replay fail, send finish indication message */
if (replay_result != MED_RES_OK)
{
#if defined(__BTVCSR_HCI_BCHS__) && defined(__MED_BT_A2DP_MOD__)
aud_bt_a2dp_media_stop_hdlr();
#endif
if ((result == MEDIA_END) && (aud_context_p->play_style == DEVICE_AUDIO_PLAY_ONCE))
{
res = MED_RES_END_OF_FILE;
}
else
{
res = MED_RES_ERROR;
}
if (aud_context_p->play_mode == AUD_MEDIA_PLAY_AS_RING)
{
aud_send_audio_play_finish_ind(res);
}
else
{
aud_send_media_play_finish_ind(res);
}
}
}
}
return KAL_TRUE;
}
/*****************************************************************************
* FUNCTION
* aud_media_play_req_hdlr
* DESCRIPTION
* This function is to handle the audio play request.
* PARAMETERS
* ilm_ptr [?]
* RETURNS
* void
*****************************************************************************/
void aud_media_play_req_hdlr(ilm_struct *ilm_ptr)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
kal_uint8 result;
l4aud_media_play_req_struct *msg_p = NULL;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
AUD_FUNC_ENTRY(AUD_MEDIA_PLAY_REQ_HDLR);
aud_context_p->src_mod = ilm_ptr->src_mod_id;
msg_p = (l4aud_media_play_req_struct*) ilm_ptr->local_para_ptr;
aud_context_p->src_id = msg_p->src_id;
if (aud_context_p->speech_on
#if defined(__MED_VID_MOD__) || defined (__MED_MJPG_MOD__)
|| !vid_is_audio_channel_available()
#endif
)
{
aud_set_result(MED_RES_BUSY);
AUD_SET_EVENT(AUD_EVT_PLAY);
if (aud_context_p->src_mod != MOD_MMI)
{
aud_send_media_play_cnf(MED_RES_BUSY);
}
}
else
{
/* if keytone is playing, stop it */
aud_keytone_stop();
/* if tone is playing, stop it */
if (aud_context_p->tone_playing)
{
aud_tone_stop();
}
#ifdef __MED_MMA_MOD__
/* close all mma tasks */
aud_mma_close_all();
#endif /* __MED_MMA_MOD__ */
if (!(aud_context_p->state == AUD_MEDIA_RECORD ||
aud_context_p->state == AUD_MEDIA_RECORD_PAUSED ||
aud_context_p->state == AUD_VM_RECORD || aud_context_p->state == AUD_VM_RECORD_PAUSED))
{
aud_stop_unfinished_process();
aud_context_p->play_mode = AUD_MEDIA_PLAY_AS_SONG;
/* set volume and path */
#if defined(__BTVCSR_HCI_BCHS__) && defined(__MED_BT_A2DP_MOD__)
aud_bt_a2dp_set_output_on((kal_bool) (msg_p->output_path & 8));
msg_p->output_path &= MAX_AUDIO_DEVICE_NUM;
#endif /* __BTVCSR_HCI_BCHS__ && __MED_BT_A2DP_MOD__ */
SET_CURRENT_VOLUME_LEVEL(AUD_VOLUME_MEDIA, msg_p->volume);
aud_context_p->melody_output_device = msg_p->output_path;
aud_get_active_device_path_by_mode(msg_p->output_path,aud_melody_set_output_device);
aud_context_p->current_format = med_get_media_type(msg_p->file_name);
aud_context_p->identifier = msg_p->identifier;
aud_context_p->start_offset = msg_p->start_offset;
aud_context_p->end_offset = msg_p->end_offset;
switch (aud_context_p->current_format)
{
case MED_TYPE_SMF:
case MED_TYPE_SMF_SND:
case MED_TYPE_IMELODY:
case MED_TYPE_MMF:
result = aud_melody_play_by_name(msg_p->file_name, msg_p->play_style, 0);
break;
#ifdef DAF_DECODE
case MED_TYPE_DAF:
#endif
#ifdef AMR_DECODE
case MED_TYPE_AMR:
#ifdef AMRWB_DECODE
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -