📄 aud_vm.c
字号:
}
}
break;
}
}
}
/*****************************************************************************
* FUNCTION
* aud_vm_stop
* DESCRIPTION
*
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
void aud_vm_stop(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
switch (aud_context_p->state)
{
case AUD_VM_PLAY:
{
/* Stop voice memo recording process */
Media_Stop();
/* close the file */
FS_Close(aud_context_p->current_file_handle);
/* enter AUD_VM_IDLE state */
aud_context_p->state = AUD_VM_IDLE;
AUD_STATE_TRACE(aud_context_p->state) break;
}
}
}
/*****************************************************************************
* FUNCTION
* aud_vm_stop_req_hdlr
* DESCRIPTION
*
* PARAMETERS
* ilm_ptr [?]
* RETURNS
* void
*****************************************************************************/
void aud_vm_stop_req_hdlr(ilm_struct *ilm_ptr)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
kal_uint32 len;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
AUD_FUNC_ENTRY(AUD_VM_STOP_REQ_HDLR) aud_context_p->src_mod = ilm_ptr->src_mod_id;
switch (aud_context_p->state)
{
case AUD_VM_RECORD:
{
kal_uint8 cnf_result;
/* Stop voice memo recording process */
Media_Stop();
FS_Write(aud_context_p->current_file_handle, aud_context_p->buf_p, aud_context_p->buf_len * 2, &len);
/* update offset */
aud_context_p->offset += len;
AUD_VALUE_TRACE(aud_context_p->offset, aud_context_p->buf_len, len >> 1) cnf_result = MED_RES_OK;
FS_Close(aud_context_p->current_file_handle);
/* send confirm message to L4 */
aud_send_vm_stop_cnf(cnf_result, aud_context_p->current_file_name);
/* change to AUD_VM_IDLE state */
AUD_ENTER_STATE(AUD_VM_IDLE);
break;
}
case AUD_VM_PLAY:
{
/* Stop voice memo recording process */
Media_Stop();
/* close the file */
FS_Close(aud_context_p->current_file_handle);
/* send confirm message to L4 */
aud_send_vm_stop_cnf(MED_RES_OK, aud_context_p->current_file_name);
/* enter AUD_VM_IDLE state */
AUD_ENTER_STATE(AUD_VM_IDLE);
break;
}
case AUD_VM_RECORD_PAUSED:
{
/* close the file */
FS_Close(aud_context_p->current_file_handle);
/* send confirm message to L4 */
aud_send_vm_stop_cnf(MED_RES_OK, aud_context_p->current_file_name);
/* enter AUD_VM_IDLE state */
AUD_ENTER_STATE(AUD_VM_IDLE);
break;
}
case AUD_VM_PLAY_PAUSED:
{
/* close the file */
FS_Close(aud_context_p->current_file_handle);
/* send confirm message to L4 */
aud_send_vm_stop_cnf(MED_RES_OK, aud_context_p->current_file_name);
/* enter AUD_VM_IDLE state */
AUD_ENTER_STATE(AUD_VM_IDLE);
break;
}
case AUD_VM_PLAY_FINISH:
{
/* Stop voice memo playing process */
Media_Stop();
/* send confirm message to L4 */
aud_send_vm_stop_cnf(MED_RES_OK, aud_context_p->current_file_name);
/* enter AUD_VM_IDLE state */
AUD_ENTER_STATE(AUD_VM_IDLE);
break;
}
default:
{
/* send confirm message to L4 */
aud_send_vm_stop_cnf(MED_RES_FAIL, NULL);
/* enter AUD_VM_IDLE state */
AUD_ENTER_STATE(AUD_VM_IDLE);
break;
}
}
}
/*****************************************************************************
* FUNCTION
* aud_vm_delete_req_hdlr
* DESCRIPTION
*
* PARAMETERS
* ilm_ptr [?]
* RETURNS
* void
*****************************************************************************/
void aud_vm_delete_req_hdlr(ilm_struct *ilm_ptr)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
kal_uint8 cnf_result;
l4aud_vm_delete_req_struct *msg_p;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
AUD_FUNC_ENTRY(AUD_VM_DELETE_REQ_HDLR) aud_context_p->src_mod = ilm_ptr->src_mod_id;
msg_p = (l4aud_vm_delete_req_struct*) ilm_ptr->local_para_ptr;
aud_context_p->src_id = msg_p->src_id;
switch (aud_context_p->state)
{
case AUD_VM_IDLE:
{
if (msg_p->delete_all)
{
/* delete all file from FS */
cnf_result = aud_vm_remove_all_file_from_list();
}
else
{
/* delete the file from FS */
cnf_result = aud_vm_remove_file_from_list((kal_wchar*) msg_p->file_name);
}
break;
}
default:
cnf_result = MED_RES_BUSY;
}
aud_send_vm_delete_cnf(cnf_result);
}
/*****************************************************************************
* FUNCTION
* aud_vm_abort_req_hdlr
* DESCRIPTION
*
* PARAMETERS
* ilm_ptr [?]
* RETURNS
* void
*****************************************************************************/
void aud_vm_abort_req_hdlr(ilm_struct *ilm_ptr)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
kal_uint8 cnf_result;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
AUD_FUNC_ENTRY(AUD_VM_ABORT_REQ_HDLR) aud_context_p->src_mod = ilm_ptr->src_mod_id;
switch (aud_context_p->state)
{
case AUD_VM_RECORD:
{
/* Stop voice memo recording process */
Media_Stop();
/* close the file */
FS_Close(aud_context_p->current_file_handle);
/* Delete the file */
cnf_result = aud_vm_remove_file_from_list(aud_context_p->current_file_name);
/* enter AUD_VM_IDLE state */
aud_context_p->state = AUD_VM_IDLE;
AUD_STATE_TRACE(aud_context_p->state) break;
}
case AUD_VM_PLAY:
{
/* Stop voice memo recording process */
Media_Stop();
/* close the file */
FS_Close(aud_context_p->current_file_handle);
cnf_result = MED_RES_OK;
/* enter AUD_VM_IDLE state */
aud_context_p->state = AUD_VM_IDLE;
AUD_STATE_TRACE(aud_context_p->state) break;
}
case AUD_VM_RECORD_PAUSED:
{
/* close the file */
FS_Close(aud_context_p->current_file_handle);
/* Delete the file */
cnf_result = aud_vm_remove_file_from_list(aud_context_p->current_file_name);
/* enter AUD_VM_IDLE state */
aud_context_p->state = AUD_VM_IDLE;
AUD_STATE_TRACE(aud_context_p->state) break;
}
case AUD_VM_PLAY_PAUSED:
{
/* close the file */
FS_Close(aud_context_p->current_file_handle);
cnf_result = MED_RES_OK;
/* enter AUD_VM_IDLE state */
aud_context_p->state = AUD_VM_IDLE;
AUD_STATE_TRACE(aud_context_p->state) break;
}
default:
{
cnf_result = MED_RES_FAIL;
break;
}
}
aud_send_vm_abort_cnf(cnf_result);
}
/*****************************************************************************
* FUNCTION
* aud_vm_pause_req_hdlr
* DESCRIPTION
*
* PARAMETERS
* ilm_ptr [?]
* RETURNS
* void
*****************************************************************************/
void aud_vm_pause_req_hdlr(ilm_struct *ilm_ptr)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
kal_int32 result;
kal_uint32 len;
l4aud_vm_pause_req_struct *msg_p = NULL;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
AUD_FUNC_ENTRY(AUD_VM_PAUSE_REQ_HDLR) aud_context_p->src_mod = ilm_ptr->src_mod_id;
msg_p = (l4aud_vm_pause_req_struct*) ilm_ptr->local_para_ptr;
aud_context_p->src_id = msg_p->src_id;
switch (aud_context_p->state)
{
case AUD_VM_RECORD:
{
kal_uint8 cnf_result;
/* Stop voice memo recording process */
Media_Stop();
result = FS_Write(
aud_context_p->current_file_handle,
aud_context_p->buf_p,
aud_context_p->buf_len * 2,
&len);
/* update offset */
aud_context_p->offset += len;
AUD_VALUE_TRACE(aud_context_p->offset, aud_context_p->buf_len, len >> 1)
if (result == FS_NO_ERROR && aud_context_p->offset < aud_context_p->vm_info.free_space)
{
cnf_result = MED_RES_OK;
/* change to AUD_VM_RECORD_PAUSED state */
AUD_ENTER_STATE(AUD_VM_RECORD_PAUSED);
}
else if (result == FS_DISK_FULL || aud_context_p->offset >= aud_context_p->vm_info.free_space)
{
cnf_result = MED_RES_DISC_FULL;
/* close current file */
FS_Close(aud_context_p->current_file_handle);
AUD_VALUE_TRACE(aud_context_p->offset, aud_context_p->vm_info.free_space, aud_context_p->disc_full)
/* set disc full to TRUE */
aud_context_p->disc_full = KAL_TRUE;
/* change to AUD_VM_IDLE state */
AUD_ENTER_STATE(AUD_VM_IDLE);
}
else
{
cnf_result = MED_RES_FAIL;
/* close current file */
FS_Close(aud_context_p->current_file_handle);
AUD_VALUE_TRACE(aud_context_p->offset, aud_context_p->vm_info.free_space, aud_context_p->disc_full)
/* decrease the free space */
aud_context_p->vm_info.free_space -= aud_context_p->offset;
/* change to AUD_VM_IDLE state */
AUD_ENTER_STATE(AUD_VM_IDLE);
}
/* send confirm message to L4 */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -