⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 aud_vm.c

📁 最新MTK手机软件源码
💻 C
📖 第 1 页 / 共 5 页
字号:
            aud_send_vm_pause_cnf(cnf_result, aud_context_p->current_file_name);
            break;
        }
        case AUD_VM_PLAY:
        case AUD_VM_PLAY_FINISH:
        {
            /* Stop voice memo recording process */
            Media_Stop();

            /* send confirm message to L4 */
            aud_send_vm_pause_cnf(MED_RES_OK, aud_context_p->current_file_name);

            /* enter AUD_VM_PLAY_PAUSED state */
            AUD_ENTER_STATE(AUD_VM_PLAY_PAUSED);
            break;
        }
        default:
        {
            /* send confirm message to L4 */
            aud_send_vm_pause_cnf(MED_RES_FAIL, NULL);
            break;
        }

    }

}


/*****************************************************************************
 * FUNCTION
 *  aud_vm_resume_req_hdlr
 * DESCRIPTION
 *  
 * PARAMETERS
 *  ilm_ptr     [?]     
 * RETURNS
 *  void
 *****************************************************************************/
void aud_vm_resume_req_hdlr(ilm_struct *ilm_ptr)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    l4aud_vm_resume_req_struct *msg_p = NULL;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    AUD_FUNC_ENTRY(AUD_VM_RESUME_REQ_HDLR) aud_context_p->src_mod = ilm_ptr->src_mod_id;

    msg_p = (l4aud_vm_resume_req_struct*) ilm_ptr->local_para_ptr;

    aud_context_p->src_id = msg_p->src_id;

    /* If the media is playing, return busy */
    if (aud_context_p->media_playing)
    {
        /* send confirm message to L4 */
        aud_send_vm_resume_cnf(MED_RES_BUSY);
        return;
    }

    switch (aud_context_p->state)
    {
        case AUD_VM_RECORD_PAUSED:
        {

            /* call L1AUD to set buffer */
            Media_SetBuffer(aud_context_p->ring_buf, AUD_RING_BUFFER_LEN);

            /* start to record */
            Media_Record((Media_Format) aud_context_p->vm_sp_type, aud_vm_record_callback, NULL);
            aud_send_vm_resume_cnf(MED_RES_OK);

            /* enter AUD_VM_RECORD state */
            AUD_ENTER_STATE(AUD_VM_RECORD);
            break;
        }
        case AUD_VM_PLAY_PAUSED:
        {

            /* follow ring tone volume */
        #ifdef SET_VOLUME_WHEN_PLAY
            aud_set_active_ring_tone_volume();
        #endif 
            /* start to play */
            Media_Play((Media_Format) aud_context_p->vm_sp_type, aud_vm_play_callback, MEDIA_VMP_AS_RINGTONE);

            /* send confirm message to L4 */
            aud_send_vm_resume_cnf(MED_RES_OK);

            /* play as memo */
            aud_context_p->play_mode = AUD_VM_PLAY_AS_MEMO;

            /* enter AUD_VM_PLAY state */
            AUD_ENTER_STATE(AUD_VM_PLAY);

            break;
        }
        default:
        {

            aud_send_vm_resume_cnf(MED_RES_FAIL);
            break;
        }

    }

}


/*****************************************************************************
 * FUNCTION
 *  aud_vm_append_req_hdlr
 * DESCRIPTION
 *  
 * PARAMETERS
 *  ilm_ptr     [?]     
 * RETURNS
 *  void
 *****************************************************************************/
void aud_vm_append_req_hdlr(ilm_struct *ilm_ptr)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    kal_uint8 cnf_result;
    l4aud_vm_append_req_struct *msg_p;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    AUD_FUNC_ENTRY(AUD_VM_APPEND_REQ_HDLR) aud_context_p->src_mod = ilm_ptr->src_mod_id;

    msg_p = (l4aud_vm_append_req_struct*) ilm_ptr->local_para_ptr;

    aud_context_p->src_id = msg_p->src_id;

    if (aud_context_p->media_playing)
    {
        /* send confirm message to L4 */
        aud_send_vm_play_cnf(MED_RES_BUSY);
        return;
    }

    if (aud_context_p->state == AUD_VM_IDLE)
    {
        if (aud_context_p->disc_full)
        {
            /* send confirm message to l4 */
            cnf_result = MED_RES_DISC_FULL;
        }
        else if (aud_vm_check_existing_file_name((kal_wchar*) msg_p->file_name))
        {
            /* open the file */
            kal_wchar full_name[FULL_NAME_LEN];

            kal_wsprintf(full_name, "%w\\%w", VM_DIR, (kal_wchar*) msg_p->file_name);
            aud_context_p->current_file_handle = FS_Open(full_name, FS_READ_WRITE | FS_OPEN_NO_DIR);

            if (aud_context_p->current_file_handle >= 0)
            {
                FS_GetFileSize(aud_context_p->current_file_handle, &aud_context_p->offset);
                /* seek to end of file */
                FS_Seek(aud_context_p->current_file_handle, 0, FS_FILE_END);

                /* call L1AUD to set buffer */
                Media_SetBuffer(aud_context_p->ring_buf, AUD_RING_BUFFER_LEN);

                /* start to record */
                Media_Record((Media_Format) aud_context_p->vm_sp_type, aud_vm_record_callback, NULL);

                cnf_result = MED_RES_OK;

                /* enter AUD_VM_RECORD state */
                AUD_ENTER_STATE(AUD_VM_RECORD);

            }
            else if (aud_context_p->disc_full || aud_context_p->current_file_handle == FS_DISK_FULL)
            {
                aud_context_p->disc_full = KAL_TRUE;
                /* send confirm message to l4 */
                cnf_result = MED_RES_DISC_FULL;
            }
            else if (aud_context_p->current_file_handle == FS_TOO_MANY_FILES)
            {
                cnf_result = MED_RES_BUSY;
            }
            else
            {
                cnf_result = MED_RES_OPEN_FILE_FAIL;
            }
        }
        else
        {
            cnf_result = MED_RES_OPEN_FILE_FAIL;
        }
    }
    else
    {
        cnf_result = MED_RES_BUSY;
    }
    /* send confirm message to l4 */
    aud_send_vm_append_cnf(cnf_result);

}


/*****************************************************************************
 * FUNCTION
 *  aud_vm_rename_req_hdlr
 * DESCRIPTION
 *  
 * PARAMETERS
 *  ilm_ptr     [?]     
 * RETURNS
 *  void
 *****************************************************************************/
void aud_vm_rename_req_hdlr(ilm_struct *ilm_ptr)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    kal_uint8 cnf_result;

    l4aud_vm_rename_req_struct *msg_p;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    AUD_FUNC_ENTRY(AUD_VM_RENAME_REQ_HDLR) aud_context_p->src_mod = ilm_ptr->src_mod_id;

    msg_p = (l4aud_vm_rename_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:
        {
            /* refresh file list */
            aud_vm_scan_file();

            cnf_result = aud_vm_change_file_name((kal_wchar*) msg_p->old_file_name, (kal_wchar*) msg_p->new_file_name);
            break;
        }
        default:
            cnf_result = MED_RES_BUSY;
    }
    /* send confirm message to L4 */
    aud_send_vm_rename_cnf(cnf_result);
}


/*****************************************************************************
 * FUNCTION
 *  aud_vm_get_info_req_hdlr
 * DESCRIPTION
 *  
 * PARAMETERS
 *  ilm_ptr     [?]     
 * RETURNS
 *  void
 *****************************************************************************/
void aud_vm_get_info_req_hdlr(ilm_struct *ilm_ptr)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    l4aud_vm_get_info_req_struct *msg_p = NULL;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    AUD_FUNC_ENTRY(AUD_VM_GET_INFO_REQ_HDLR) aud_context_p->src_mod = ilm_ptr->src_mod_id;

    msg_p = (l4aud_vm_get_info_req_struct*) ilm_ptr->local_para_ptr;

    aud_context_p->src_id = msg_p->src_id;

    /* scan all vm files in FS */
    aud_vm_scan_file();

    /* send confirm message to L4 */
    aud_send_vm_get_info_cnf();

}

#ifndef VM_LOG


/*****************************************************************************
 * FUNCTION
 *  aud_vm_read_data_ind_hdlr
 * DESCRIPTION
 *  
 * PARAMETERS
 *  ilm_ptr     [?]     
 * RETURNS
 *  void
 *****************************************************************************/
void aud_vm_read_data_ind_hdlr(ilm_struct *ilm_ptr)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    kal_uint32 len;
    kal_int32 result;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    AUD_FUNC_ENTRY(AUD_VM_READ_DATA_IND_HDLR)
        Media_GetReadBuffer(&(aud_context_p->buf_p), (kal_uint32*) & (aud_context_p->buf_len));

#ifdef _WIN32
    aud_context_p->buf_len = 200;
#endif 

    ASSERT(aud_context_p->buf_p != NULL);

    switch (aud_context_p->state)
    {
        case AUD_VM_RECORD:
        {
            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)
            {
                aud_context_p->buf_len = (kal_uint32) (len >> 1);
                Media_ReadDataDone(aud_context_p->buf_len);
            }
            else
            {
                /* inform L1AUD to stop recording process */
                Media_Stop();

                result = 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)
                    if (aud_context_p->offset == 0)
                {
                    result = FS_Delete(aud_context_p->current_file_name);
                    /* send indication message to L4 */
                    aud_send_vm_record_finish_ind(MED_RES_DISC_FULL, aud_context_p->current_file_name);
                }
                else
                    /* send indication message to L4 */
                {
                    aud_send_vm_record_finish_ind(MED_RES_DISC_FULL, 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)
                    /* reset current vm id */
                    aud_context_p->current_file_handle = -1;
                /* set disc full to TRUE */
                aud_context_p->disc_full = KAL_TRUE;
            }
            break;
        }
        default:
        {
            break;
        }
    }

}
#e

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -