📄 aud_media.c
字号:
case MED_TYPE_GSM_FR:
case MED_TYPE_GSM_HR:
case MED_TYPE_GSM_EFR:
vpFormat.mediaType = aud_context_p->current_format;
vpFormat.vmParam = (kal_uint32) MEDIA_VMP_AS_RINGTONE;
param = &vpFormat;
openFunc = VM_Open;
break;
case MED_TYPE_PCM_8K:
case MED_TYPE_PCM_16K:
case MED_TYPE_G711_ALAW:
case MED_TYPE_G711_ULAW:
case MED_TYPE_DVI_ADPCM:
vpFormat.mediaType = aud_context_p->current_format;
vpFormat.vmParam = 0;
param = &vpFormat;
openFunc = PCM_Open;
break;
#ifdef AMR_DECODE
case MED_TYPE_AMR:
#ifdef AMRWB_DECODE
case MED_TYPE_AMR_WB:
#endif
vpFormat.mediaType = aud_context_p->current_format;
vpFormat.vmParam = (kal_uint32) MEDIA_VMP_AS_RINGTONE;
param = &vpFormat;
openFunc = AMR_Open;
break;
#endif /* AMR_DECODE */
#ifdef DAF_DECODE
case MED_TYPE_DAF:
openFunc = DAF_Open;
break;
#endif /* DAF_DECODE */
case MED_TYPE_WAV:
case MED_TYPE_WAV_ALAW:
case MED_TYPE_WAV_ULAW:
case MED_TYPE_WAV_DVI_ADPCM:
openFunc = WAV_Open;
break;
case MED_TYPE_AU:
openFunc = AU_Open;
break;
case MED_TYPE_AIFF:
openFunc = AIFF_Open;
break;
#ifdef WMA_DECODE
case MED_TYPE_WMA:
openFunc = WMA_Open;
break;
#endif /* WMA_DECODE */
#ifdef AAC_DECODE
case MED_TYPE_AAC:
openFunc = AAC_Open;
break;
#endif /* AAC_DECODE */
#if defined(MP4_CODEC) && defined(AAC_DECODE)
case MED_TYPE_M4A:
openFunc = M4A_Open;
break;
#endif /* defined(MP4_CODEC) && defined(AAC_DECODE) */
default:
ASSERT(0);
}
/* No need to set buffer for ROM file */
FSAL_SetBuffer(¤t_file_stream, 0, NULL);
if ((aud_context_p->last_mhdl_handle = openFunc(aud_media_play_stream_event_callback, ¤t_file_stream, param)) == NULL)
{
aud_media_close_file_handle();
return MED_RES_BAD_FORMAT;
}
closeFunc = aud_context_p->last_mhdl_handle->Close;
playFunc = aud_context_p->last_mhdl_handle->Play;
setBufFunc = aud_context_p->last_mhdl_handle->SetBuffer;
/* call L1AUD to set buffer */
setBufFunc(aud_context_p->last_mhdl_handle, (kal_uint8*) aud_context_p->ring_buf, AUD_RING_BUFFER_LEN * 2);
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 ((result = playFunc(aud_context_p->last_mhdl_handle)) != MEDIA_SUCCESS)
{
closeFunc(aud_context_p->last_mhdl_handle);
aud_media_close_file_handle();
/* 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
return aud_get_res(result);
}
result = MED_RES_OK;
AUD_ENTER_STATE(AUD_MEDIA_PLAY);
#if defined(__BTVCSR_HCI_BCHS__) && defined(__MED_BT_A2DP_MOD__)
aud_bt_a2dp_media_play_hdlr();
#endif
}
return result;
#endif /* !defined(__MTK_TARGET__) */ /* #if !defined(__MTK_TARGET__) */
}
/*****************************************************************************
* FUNCTION
* aud_media_play_file_stream
* DESCRIPTION
* This function is ....
* PARAMETERS
* file_name [?]
* play_style [IN]
* first_time [IN]
* resume [IN]
* cache_p [IN]
* RETURNS
* void
*****************************************************************************/
kal_uint8 aud_media_play_file_stream(
kal_wchar *file_name,
kal_uint8 play_style,
kal_uint8 first_time,
kal_bool resume,
void* cache_p)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
FSAL_Status eFSALRet;
kal_uint8 result;
media_open_func_ptr openFunc = NULL;
media_ctrl_func_ptr closeFunc, playFunc;
media_set_buf_func_ptr setBufFunc;
media_set_time_func_ptr setStartTimeFunc, setStopTimeFunc;
Media_VM_PCM_Param vpFormat;
void *param = NULL;
kal_uint8 *pbFSALBuf;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
ASSERT(aud_context_p->state == AUD_MEDIA_IDLE);
#if !defined(__MTK_TARGET__) /* MODIS */
return MED_RES_OK;
#else /* !defined(__MTK_TARGET__) */
/* open file for playing */
if ((eFSALRet = FSAL_Open(¤t_file_stream, file_name, FSAL_READ)) != FSAL_OK)
{
result = MED_RES_OPEN_FILE_FAIL;
}
else
{
switch (aud_context_p->current_format)
{
case MED_TYPE_GSM_EFR:
case MED_TYPE_VR:
vpFormat.mediaType = aud_context_p->current_format;
vpFormat.vmParam = (kal_uint32) MEDIA_VMP_AS_RINGTONE;
param = &vpFormat;
openFunc = VM_Open;
break;
case MED_TYPE_PCM_8K:
case MED_TYPE_PCM_16K:
case MED_TYPE_DVI_ADPCM:
vpFormat.mediaType = aud_context_p->current_format;
vpFormat.vmParam = 0;
param = &vpFormat;
openFunc = PCM_Open;
break;
#ifdef AMR_DECODE
case MED_TYPE_AMR:
#ifdef AMRWB_DECODE
case MED_TYPE_AMR_WB:
#endif
vpFormat.mediaType = aud_context_p->current_format;
vpFormat.vmParam = (kal_uint32) MEDIA_VMP_AS_RINGTONE;
param = &vpFormat;
openFunc = AMR_Open;
break;
#endif /* AMR_DECODE */
#ifdef DAF_DECODE
case MED_TYPE_DAF:
openFunc = DAF_Open;
break;
#endif /* DAF_DECODE */
case MED_TYPE_WAV:
case MED_TYPE_WAV_DVI_ADPCM:
openFunc = WAV_Open;
break;
case MED_TYPE_AU:
openFunc = AU_Open;
break;
case MED_TYPE_AIFF:
openFunc = AIFF_Open;
break;
#ifdef WMA_DECODE
case MED_TYPE_WMA:
openFunc = WMA_Open;
break;
#endif /* WMA_DECODE */
#ifdef AAC_DECODE
case MED_TYPE_AAC:
openFunc = AAC_Open;
break;
#endif /* AAC_DECODE */
#if defined(MP4_CODEC) && defined(AAC_DECODE)
case MED_TYPE_M4A:
openFunc = M4A_Open;
break;
#endif /* defined(MP4_CODEC) && defined(AAC_DECODE) */
default:
ASSERT(0);
}
/* Set Buffer for file */
#if defined(AUD_PROC_USE_EXT_MEM)
//pbFSALBuf = (kal_uint8*) med_alloc_ext_mem(sizeof(kal_uint8) * AUD_PROC_BUF_SIZE);
pbFSALBuf = &med_aud_fasl_buf[0];
#else
pbFSALBuf = (kal_uint8*) get_ctrl_buffer(sizeof(kal_uint8) * AUD_PROC_BUF_SIZE);
#endif
FSAL_SetBuffer(¤t_file_stream, AUD_PROC_BUF_SIZE, pbFSALBuf);
if ((aud_context_p->last_mhdl_handle = openFunc(aud_media_play_stream_event_callback, ¤t_file_stream, param)) == NULL)
{
aud_media_close_file_handle();
return MED_RES_BAD_FORMAT;
}
if( cache_p != NULL )
aud_context_p->last_mhdl_handle->SetCacheTbl(
aud_context_p->last_mhdl_handle, cache_p, NULL );
closeFunc = aud_context_p->last_mhdl_handle->Close;
playFunc = aud_context_p->last_mhdl_handle->Play;
setBufFunc = aud_context_p->last_mhdl_handle->SetBuffer;
setStartTimeFunc = aud_context_p->last_mhdl_handle->SetStartTime;
setStopTimeFunc = aud_context_p->last_mhdl_handle->SetStopTime;
/* call L1AUD to set buffer */
setBufFunc(aud_context_p->last_mhdl_handle, (kal_uint8*) aud_context_p->ring_buf, AUD_RING_BUFFER_LEN * 2);
if (first_time)
{
/* follow ring tone volume */
aud_set_active_ring_tone_volume();
/* To start ascending timer */
aud_melody_play_style_convert(play_style);
}
if (resume)
{
/* Use file offset directly to just to fast restore*/
aud_context_p->last_mhdl_handle->SetStoreFlag(aud_context_p->last_mhdl_handle, KAL_TRUE);
setStartTimeFunc(aud_context_p->last_mhdl_handle, aud_context_p->last_time);
}
else /* Play file portion */
{
/* Not a restore action, need to seek again.*/
aud_context_p->last_mhdl_handle->SetStoreFlag(aud_context_p->last_mhdl_handle, KAL_FALSE);
if (aud_context_p->start_offset != 0)
{
setStartTimeFunc(aud_context_p->last_mhdl_handle, aud_context_p->start_offset);
}
if (aud_context_p->end_offset != 0)
{
setStopTimeFunc(aud_context_p->last_mhdl_handle, aud_context_p->end_offset);
}
}
#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__ */
result = playFunc(aud_context_p->last_mhdl_handle);
if (result != MEDIA_SUCCESS /* && result != MEDIA_SEEK_FAIL */ )
{
closeFunc(aud_context_p->last_mhdl_handle);
aud_media_close_file_handle();
/* 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
return aud_get_res(result);
}
result = MED_RES_OK;
AUD_ENTER_STATE(AUD_MEDIA_PLAY);
#if defined(__BTVCSR_HCI_BCHS__) && defined(__MED_BT_A2DP_MOD__)
aud_bt_a2dp_media_play_hdlr();
#endif
}
return result;
#endif /* !defined(__MTK_TARGET__) */ /* #if !defined(__MTK_TARGET__) */
}
/*****************************************************************************
* FUNCTION
* aud_media_replay_by_handle
* DESCRIPTION
* This function is ....
* PARAMETERS
* play_style [IN]
* replay [IN]
* RETURNS
* void
*****************************************************************************/
kal_uint8 aud_media_replay_by_handle(kal_uint8 play_style, kal_bool replay)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
kal_uint8 result;
media_ctrl_func_ptr closeFunc, playFunc;
media_set_time_func_ptr setStartTimeFunc, setStopTimeFunc;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
closeFunc = aud_context_p->last_mhdl_handle->Close;
playFunc = aud_context_p->last_mhdl_handle->Play;
setStartTimeFunc = aud_context_p->last_mhdl_handle->SetStartTime;
setStopTimeFunc = aud_context_p->last_mhdl_handle->SetStopTime;
if (replay)
{
/* follow ring tone volume */
aud_set_active_ring_tone_volume();
/* To start ascending timer */
aud_melody_start_crescendo(play_style);
setStartTimeFunc(aud_context_p->last_mhdl_handle, aud_context_p->start_offset);
if (aud_context_p->end_offset != 0)
{
setStopTimeFunc(aud_context_p->last_mhdl_handle, aud_context_p->end_offset);
}
}
result = playFunc(aud_context_p->last_mhdl_handle);
if (result != MEDIA_SUCCESS /* && result != MEDIA_SEEK_FAIL */ )
{
closeFunc(aud_context_p->last_mhdl_handle);
aud_media_close_file_handle();
/* stop volume crescendo timer */
med_stop_timer(AUD_TIMER_CRESCENDO);
return aud_get_res(result);
}
AUD_ENTER_STATE(AUD_MEDIA_PLAY);
return MED_RES_OK;
}
/*****************************************************************************
* FUNCTION
* aud_media_pause_file_stream
* DESCRIPTION
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -