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

📄 aud_interface.c

📁 Motorola synergy audio component
💻 C
📖 第 1 页 / 共 3 页
字号:
ARGUMENTS PASSED:    W_CHAR *filename; - Filename of the audio data to be read from the FDI and played out the speakerRETURN VALUE:   NonePRE-CONDITIONS:   NonePOST-CONDITIONS:   Return Message to VR SP: AUD_PLAY_AUDIO_FLASH_CNF_ID when the playback session has startedIMPORTANT NOTES:   None==================================================================================================*/void aud_play_audio_from_flash_req(W_CHAR *filename){    BOOL                error = TRUE;    DL_FS_HANDLE_T      file_handle;    DL_FS_RESULT_T      result;    UINT8*              mallocPtr;    UINT32              mallocSize;    UINT32              bytesRead;    SU_PORT_HANDLE      dest_phandle;    if ( audVstParams.abort_activity == TRUE )    {        void* msgptr;        dest_phandle = (SU_PORT_HANDLE)suFindName(DL_PORT_NAME_MEDIA_VR_SP,                                                  SU_WAIT_FOREVER,                                                  NULL);        msgptr =  suCreateMessage((UINT32)0, AM_VR_UNAVAILABLE_IND, SU_INVALID_HANDLE, NULL);        suSendMessage(msgptr, dest_phandle, NULL);    }    else    {    mallocSize  = 0;    // Try to open the file for reading    file_handle = DL_FsOpenFile(filename, DL_FS_READ_MODE, DL_FS_OWNER_AUDIO);    if (file_handle != DL_INVALID_FILE_HANDLE)    {        // get the file size        mallocSize = DL_FsGetFileSize(file_handle);        if (mallocSize != 0)        {            // malloc memory where all the buffers are to be copied to...            mallocPtr = (UINT8*)suAllocMem(mallocSize, NULL);            if (mallocPtr != NULL)            {                result = DL_FsReadFile(mallocPtr, 1, mallocSize, file_handle, &bytesRead);                if (result == DL_FS_RESULT_READ_SUCCESS)                {                    if ( bytesRead == mallocSize )                    {                        error = FALSE;                    }                }            } // end of if (mallocPtr != NULL)        } // end of if (mallocSize != 0)        (void)DL_FsCloseFile(file_handle);    }    if (error == FALSE)    {        audVstParams.activity = AUD_VST_PLAYBACK_FROM_FILE;        audVstParams.audio_data_address = mallocPtr;        audVstParams.audio_data_size = mallocSize;        aud_va_command_req(TD_VA_COMMAND_START_PLAY,                           DL_MEDIA_VA_MESSAGE_INVALID,                           DL_MEDIA_VA_INVALID_GROUP);    }    else    // an error was detected above...    {        AUD_PLAY_AUDIO_FLASH_CNF_T* msg;        msg = (AUD_PLAY_AUDIO_FLASH_CNF_T*)suCreateMessage((UINT32)sizeof(AUD_PLAY_AUDIO_FLASH_CNF_T),                                                           (UINT32)AUD_PLAY_AUDIO_FLASH_CNF_ID,                                                           SU_INVALID_HANDLE,                                                           NULL);        msg->status_code = DL_MEDIA_ERROR;        dest_phandle = (SU_PORT_HANDLE)suFindName(DL_PORT_NAME_MEDIA_VR_SP,                                                  SU_WAIT_FOREVER,                                                  NULL);        suSendMessage(msg, dest_phandle, NULL);        if (mallocPtr != 0)        {            suFreeMem(mallocPtr);        }    } // end of else (error == FALSE)}}/*==================================================================================================FUNCTION: aud_play_audio_from_buffer_reqDESCRIPTION:Concatenates all of the buffers described by the input arguments to a single RAM buffer and then calls the audio manager to play the data out of the speaker. ARGUMENTS PASSED:UINT8   audio_buffer_num - number of audio buffers to playvoid    *audio_data_address - pointer to an array of pointers describing the location of the buffersvoid    *audio_data_size  - pointer to an array describing the size of the playback buffersRETURN VALUE:   NonePRE-CONDITIONS:   NonePOST-CONDITIONS:   Return Message to VR SP: AUD_PLAY_AUDIO_BUFFER_CNF_ID when the playback session has startedIMPORTANT NOTES:   None==================================================================================================*/void aud_play_audio_from_buffer_req( UINT8   audio_buffer_num,                                     void    *audio_data_address,                                     void    *audio_data_size ){    BOOL                         error = TRUE;    UINT16**                     audioAddr;    UINT32*                      audioSize;    UINT8*                       mallocPtr;    UINT8*                       mallocAddr;    UINT32                       mallocSize;    UINT32                       copiedSize;    UINT8                        index;    SU_PORT_HANDLE               dest_phandle;    if ( audVstParams.abort_activity == TRUE )    {        void* msgptr;        dest_phandle = (SU_PORT_HANDLE)suFindName(DL_PORT_NAME_MEDIA_VR_SP,                                                  SU_WAIT_FOREVER,                                                  NULL);        msgptr =  suCreateMessage((UINT32)0, AM_VR_UNAVAILABLE_IND, SU_INVALID_HANDLE, NULL);        suSendMessage(msgptr, dest_phandle, NULL);    }    else    {    mallocSize  = 0;    audioSize  = (UINT32*)audio_data_size;    // get total size of all buffers to play...    for (index = 0; index < audio_buffer_num; index++)    {        mallocSize += *audioSize;        audioSize++;    }    if (mallocSize != 0)    {        // malloc memory where all the buffers are to be copied to...        mallocPtr = (UINT8*)suAllocMem(mallocSize, NULL);        if (mallocPtr != NULL)        {            mallocAddr = mallocPtr;            audioAddr  = (UINT16**)audio_data_address;            audioSize  = (UINT32*)audio_data_size;            copiedSize = 0;            // copy each buffer to malloc'd buffer...            for (index = 0; index < audio_buffer_num; index++)            {                // check to make sure memory outside malloc'd area is not written                //  to...debug...                if ( (copiedSize + *audioSize) <= mallocSize)                {                    memcpy(mallocAddr, *audioAddr, *audioSize);                    mallocAddr += *audioSize;                    copiedSize += *audioSize;                    audioAddr++;                    audioSize++;                    error = FALSE;                }                else                {                    error = TRUE;                    break;                }            } // end of for (index = 0; ...)        } // end of if (mallocPtr != NULL)    } // end of if (mallocSize != 0)    if (error == FALSE)    {        audVstParams.activity = AUD_VST_PLAYBACK_FROM_BUFFER;        audVstParams.audio_data_address = mallocPtr;        audVstParams.audio_data_size = mallocSize;        aud_va_command_req(TD_VA_COMMAND_START_PLAY,                           DL_MEDIA_VA_MESSAGE_INVALID,                           DL_MEDIA_VA_INVALID_GROUP);    }    else    // an error was detected above...    {        AUD_PLAY_AUDIO_BUFFER_CNF_T*    msg;        msg = suCreateMessage((UINT32)sizeof(AUD_PLAY_AUDIO_BUFFER_CNF_T),                              (UINT32)AUD_PLAY_AUDIO_BUFFER_CNF_ID,                              SU_INVALID_HANDLE,                              NULL);        msg->status_code = DL_MEDIA_ERROR;        dest_phandle = (SU_PORT_HANDLE)suFindName(DL_PORT_NAME_MEDIA_VR_SP,                                                  SU_WAIT_FOREVER,                                                  NULL);        suSendMessage(msg, dest_phandle, NULL);        if (mallocPtr != 0)        {            suFreeMem(mallocPtr);        }    } // end of else (error == FALSE)}}/*==================================================================================================FUNCTION:  aud_stop_audio_playback_reqDESCRIPTION:Stops a currently active audio playback session.  If session has already completed, the confirmationis sent immediately.ARGUMENTS PASSED:   NoneRETURN VALUE:   NonePRE-CONDITIONS:   NonePOST-CONDITIONS:   Return Message to VR SP: AUD_STOP_AUDIO_PLAYBACK_CNF_ID when the playback has been stoppedIMPORTANT NOTES:   None==================================================================================================*/void aud_stop_audio_playback_req(void){    AUD_STOP_AUDIO_PLAYBACK_CNF_T* msgptr;    SU_PORT_HANDLE dest_phandle = (SU_PORT_HANDLE)suFindName(DL_PORT_NAME_MEDIA_VR_SP,                                                             SU_WAIT_FOREVER,                                                             NULL);    if ( audVstParams.abort_activity == TRUE)    {        void * msg;        msg =  suCreateMessage((UINT32)0, AM_VR_UNAVAILABLE_IND, SU_INVALID_HANDLE, NULL);        suSendMessage(msg, dest_phandle, NULL);    }    else if ( audVstParams.activity == AUD_VST_IDLE )    {        /* Confirm the receipt of the message from VST */        msgptr = (AUD_STOP_AUDIO_PLAYBACK_CNF_T*)suCreateMessage((UINT32)sizeof(AUD_STOP_AUDIO_PLAYBACK_CNF_T),                                                                 (UINT32)AUD_STOP_AUDIO_PLAYBACK_CNF_ID,                                                                 SU_INVALID_HANDLE,                                                                 NULL);        msgptr->status_code = DL_MEDIA_OK;        /* send message */        suSendMessage(msgptr, dest_phandle, NULL);    }    else    {	audVstParams.activity = AUD_VST_STOP_PLAYBACK;	aud_va_command_req(TD_VA_COMMAND_STOP_PLAY,                       DL_MEDIA_VA_MESSAGE_INVALID,                       DL_MEDIA_VA_INVALID_GROUP);}}/*==================================================================================================FUNCTION:  aud_vst_vr_recorded_data_ready_reqDESCRIPTION:Called from the GINT ISR, this function makes a request to the AM to read the vocoded and PCM audio data from the shared memory between the MCU and DSP. Reads data from ISR right away to speed upreading from hapi queue.ARGUMENTS PASSED:   NoneRETURN VALUE:   NonePRE-CONDITIONS:   NonePOST-CONDITIONS:   4 AUD_AUDIO_SAMPLES_READY_IND_ID messages are sent to the VR SP.IMPORTANT NOTES:   None==================================================================================================*/void aud_vst_vr_recorded_data_ready_req(void){    AUD_RECORDED_DATA_READY_REQ_T * msgptr = NULL;    msgptr = (AUD_RECORDED_DATA_READY_REQ_T *) suCreateMessage((UINT32)sizeof(AUD_RECORDED_DATA_READY_REQ_T),                                                                     (UINT32)AUD_RECORDED_DATA_READY_REQ_ID,                                                                     SU_INVALID_HANDLE,                                                                     NULL);    //  read whole queue and store into message to send to audio manager    HAPI_MDI_QUEUE_read(DSP_MCU_AUDIO_DATA, (UINT16*)msgptr);    AM_SendMessage((char *)msgptr);}/*================================================================================================*/ void audio_wake(){    /* free the low power semaphone */   suReleaseSem(sem_low_power, NULL);}void aud_set_tcmd_msg_routing(BOOL route_to_tcmd){    replies_to_tcmd = route_to_tcmd;} /*============================================================================================   For AMR dynamic Noise Suppression allow/disallow. This is called by the GSM stack. TRUE is   to allow it and FALSE is to disallow it============================================================================================*/void aud_amr_ns_allow(BOOL allow_ns){    BOOL * msgptr = NULL;      msgptr =  suCreateMessage((UINT32)sizeof(BOOL), (UINT32) AUD_AMR_ALLOW_NOISE_SUP, SU_INVALID_HANDLE, NULL);    *msgptr = allow_ns;    AM_SendMessage((char *) msgptr);}#ifdef __cplusplus}#endif

⌨️ 快捷键说明

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