📄 aud_post_process.c
字号:
/* Stop 3D effect before using time stretch */
aud_3d_pause_effect();
/* Set time stretch mode and turn on it */
ts_result = AudioPP_SetTS(mode);
if (ts_result == MEDIA_SUCCESS)
{
aud_app_cntx_p->state_stretch = AUD_EFFECT_ON;
set_result = MED_RES_OK;
}
else
{
set_result = MED_RES_FAIL;
/* resume 3D effect because time stretch set fail */
aud_3d_resume_effect();
}
}
/* Unsupport speed mode */
else
{
set_result = MED_RES_PARAM_ERROR;
}
return set_result;
}
/*****************************************************************************
* FUNCTION
* aud_stretch_close_req_hdlr
* DESCRIPTION
* This function is the request handler of turning off play speed and play as normal speed
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
void aud_stretch_close_req_hdlr(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
aud_stretch_close();
aud_app_set_result(MED_RES_OK);
EFFECT_SET_EVENT(TS_EVT_CLOSE);
}
/*****************************************************************************
* FUNCTION
* aud_stretch_close
* DESCRIPTION
* This function is the interface of turning off play speed for media task
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
void aud_stretch_close(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (aud_app_cntx_p->state_stretch == AUD_EFFECT_ON)
{
AudioPP_CloseTS();
}
/* resume 3D effect if is is on */
aud_3d_resume_effect();
aud_app_cntx_p->state_stretch = AUD_EFFECT_OFF;
}
/*****************************************************************************
* FUNCTION
* aud_stretch_get_mode_from_speed
* DESCRIPTION
* This function is to convert play speed to the mode provide by l1 audio
* PARAMETERS
* speed [IN]
* RETURNS
* void
*****************************************************************************/
static kal_uint16 aud_stretch_get_mode_from_speed(kal_uint16 speed)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
kal_uint16 mode = 0;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
switch (speed)
{
case 50:
mode = 1;
break;
case 80:
mode = 2;
break;
case 125:
case 128:
mode = 3;
break;
case 160:
mode = 4;
break;
default:
break;
}
return mode;
}
/*****************************************************************************
* FUNCTION
* aud_3d_set_coeff_req_hdlr
* DESCRIPTION
* This function is to set the 3D effect coefficient
* PARAMETERS
* ilm_ptr [?]
* RETURNS
* void
*****************************************************************************/
void aud_3d_set_coeff_req_hdlr(ilm_struct *ilm_ptr)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
media_3d_set_coeff_req_struct *msg_p;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
msg_p = (media_3d_set_coeff_req_struct*) ilm_ptr->local_para_ptr;
AudioPP_Set3D(msg_p->coeff_table_ptr);
/* First time set parameter. If not first time set, keep current state */
if (aud_app_cntx_p->state_3d == AUD_EFFECT_UNSET)
{
aud_app_cntx_p->state_3d = AUD_EFFECT_OFF;
}
aud_app_set_result(MED_RES_OK);
EFFECT_SET_EVENT(A3D_EVT_SET);
}
/*****************************************************************************
* FUNCTION
* aud_3d_turn_on_effect_req_hdlr
* DESCRIPTION
* This function is to turn on 3D sound effect
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
void aud_3d_turn_on_effect_req_hdlr(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
Media_Status result;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
/* Parameter is not set */
if (aud_app_cntx_p->state_3d == AUD_EFFECT_UNSET)
{
aud_app_set_result(MED_RES_FAIL);
}
/* Already turn on, call L1 fuction again to apply new parameter */
else if (aud_app_cntx_p->state_3d == AUD_EFFECT_ON)
{
result = AudioPP_TurnOn3D();
aud_app_set_result((kal_int32) aud_get_res((kal_uint8) result));
if (result != MEDIA_SUCCESS)
{
aud_app_cntx_p->state_3d = AUD_EFFECT_OFF;
}
}
/* Parameter is already set but not turn on or being interrupted by time stretch feature. */
else if (aud_app_cntx_p->state_3d == AUD_EFFECT_OFF || aud_app_cntx_p->state_3d == AUD_EFFECT_INT)
{
/* If time stretch is on, change state to interrupt, and resume when time stretch close */
if (aud_app_cntx_p->state_stretch == AUD_EFFECT_ON)
{
aud_app_cntx_p->state_3d = AUD_EFFECT_INT;
aud_app_set_result(MED_RES_OK);
}
else
{
result = AudioPP_TurnOn3D();
aud_app_set_result((kal_int32) aud_get_res((kal_uint8) result));
aud_app_cntx_p->state_3d = AUD_EFFECT_ON;
}
}
else
{
ASSERT(KAL_FALSE);
}
EFFECT_SET_EVENT(A3D_EVT_ON);
}
/*****************************************************************************
* FUNCTION
* aud_3d_turn_off_effect_req_hdlr
* DESCRIPTION
* This function is to turn off 3D sound effect
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
void aud_3d_turn_off_effect_req_hdlr(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (aud_app_cntx_p->state_3d == AUD_EFFECT_ON)
{
AudioPP_TurnOff3D();
}
/* If 3D effect is not set, do not change its state. */
if (aud_app_cntx_p->state_3d != AUD_EFFECT_UNSET)
{
aud_app_cntx_p->state_3d = AUD_EFFECT_OFF;
}
aud_app_set_result(MED_RES_OK);
EFFECT_SET_EVENT(A3D_EVT_OFF);
}
/*****************************************************************************
* FUNCTION
* aud_3d_pause_effect
* DESCRIPTION
* This function is to pause 3D sound effect when turn on time stretch
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
static void aud_3d_pause_effect(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (aud_app_cntx_p->state_3d == AUD_EFFECT_ON)
{
/* Close audio 3D sound effect */
AudioPP_TurnOff3D();
aud_app_cntx_p->state_3d = AUD_EFFECT_INT;
}
}
/*****************************************************************************
* FUNCTION
* aud_3d_resume_effect
* DESCRIPTION
* This function is to resume 3D sound effect when turn off time stretch
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
static void aud_3d_resume_effect(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
Media_Status result;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (aud_app_cntx_p->state_3d == AUD_EFFECT_INT)
{
/* Turn on audio 3D sound effect after time stretch finish */
result = AudioPP_TurnOn3D();
if (result == MEDIA_SUCCESS)
{
aud_app_cntx_p->state_3d = AUD_EFFECT_ON;
}
else
{
aud_app_cntx_p->state_3d = AUD_EFFECT_OFF;
}
}
}
#endif /* __MED_APP_MOD__ */
#endif /* MED_NOT_PRESENT */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -