//=========================================================== // // Function Name: AUDDRV_VoiceRender_Init // // Description: Shut down voice render driver, free internal variables and task queue. // //================================================================== Result_t AUDDRV_VoiceRender_Shutdown( VORENDER_TYPE_t type ) { VORENDER_Drv_t *audDrv = NULL; audDrv = GetDriverByType (type); if (audDrv == NULL) return RESULT_ERROR; if (audDrv->isRunning == FALSE) return RESULT_OK; // destroy the audio ringbuffer queue AUDQUE_Destroy (audDrv->audQueue); OSHEAP_Delete(audDrv->ringBuffer); OSTASK_Destroy(audDrv->task); OSQUEUE_Destroy(audDrv->msgQueue); OSSEMAPHORE_Destroy (audDrv->stopSema); OSSEMAPHORE_Destroy (audDrv->addBufSema); OSSEMAPHORE_Destroy (audDrv->stopDspAmrWbSema); audDrv->isRunning = FALSE; Log_DebugPrintf(LOGID_AUDIO, "AUDDRV_VoiceRender_Shutdown::Exit.\n"); return RESULT_OK; }
// =================================================================== // // Function Name: ConfigAudDrv // // Description: Configure the driver. // // ==================================================================== static Result_t ConfigAudDrv (VOCAPTURE_Drv_t *audDrv, VOCAPTURE_Configure_t *config) { ////////////////////////////////////////////////////////////////////////////////////////////////////// // callbackThreshold is not required now. // If the interruptInterval is set to non-0 through _SetTransferParameters() API, // the numBlocks and blockSize will set according to the user's requirement. // Otherwise, we use default values. /////////////////////////////////////////////////////////////////////////////////////////////////////// // This is not done for AMRWB yet because the DSP interface is asynchronous. // if (audDrv->interruptInterval == 0) { // use default audDrv->numFramesPerInterrupt = 4; } else { audDrv->numFramesPerInterrupt = audDrv->interruptInterval / DSP_RECORD_FRAME_DURATION; if (audDrv->numFramesPerInterrupt == 0) audDrv->numFramesPerInterrupt = 1; } memcpy (&audDrv->config, config, sizeof(VOCAPTURE_Configure_t)); OSHEAP_Delete(config); switch (audDrv->drvType) { case VOCAPTURE_TYPE_AMRNB: // totally to queue about 1 second of amr_nb data, 50 frames audDrv->bufferSize = sizeof(VR_Frame_AMR_t) * audDrv->numFramesPerInterrupt; audDrv->bufferNum = 50/audDrv->numFramesPerInterrupt; break; case VOCAPTURE_TYPE_PCM: // totally to queue about 1 second of amr_nb data, 50 frames audDrv->bufferSize = LIN_PCM_FRAME_SIZE*sizeof(UInt16)*audDrv->numFramesPerInterrupt; //320 bytes if (audDrv->config.speechMode == VP_SPEECH_MODE_LINEAR_PCM_16K) audDrv->bufferSize = WB_LIN_PCM_FRAME_SIZE*sizeof(UInt16)*audDrv->numFramesPerInterrupt; audDrv->bufferNum = 50/audDrv->numFramesPerInterrupt; break; case VOCAPTURE_TYPE_AMRWB: audDrv->bufferSize = 0x48;//0x21c; //in bytes audDrv->bufferNum = AUDIO_SIZE_PER_PAGE/audDrv->bufferSize*8; break; default: Log_DebugPrintf(LOGID_AUDIO, "ConfigAudDrv:: Doesn't support audio driver type drvType = 0x%x\n", audDrv->drvType); break; } audDrv->ringBuffer = (UInt8 *)OSHEAP_Alloc (audDrv->bufferNum*audDrv->bufferSize); audDrv->audQueue = AUDQUE_Create (audDrv->ringBuffer, audDrv->bufferNum, audDrv->bufferSize); Log_DebugPrintf(LOGID_AUDIO, " : ConfigAudDrv::\n"); return RESULT_OK; }
/** Delete context from tid. @param tid (in) tid **/ void RPC_SyncDeleteCbkFromTid(UInt32 tid) { RPC_SyncContext_t *ctx = (RPC_SyncContext_t *) tid; assert(ctx != NULL); _DBG_(RPC_TRACE ("RPC_SyncDeleteCbkFromTid tid %d sig=%lx \r\n", (int)tid, ctx->sig)); if (ctx->sig == 0xBABEFACE && ctx->val != 0) { ctx->sig = 0; ctx->val = 0; OSHEAP_Delete(ctx); } else { _DBG_(RPC_TRACE ("RPC_SyncDeleteCbkFromTid ERROR tid %d sig=%lx \r\n", (int)tid, ctx->sig)); xassert(0, tid); } }
void RPC_SyncReleaseToHeap(void *inBuf) { if (inBuf) OSHEAP_Delete(inBuf); }
// ============================================================================== // Function Name: ConfigAudDrv // // Description: Configure the voice render driver with the passed in configuration. // ================================================================================ static Result_t ConfigAudDrv (VORENDER_Drv_t *audDrv, VORENDER_Configure_t *config) { UInt32 ringBufferFrames; memcpy (&audDrv->config, config, sizeof(VORENDER_Configure_t)); OSHEAP_Delete(config); ////////////////////////////////////////////////////////////////////////////////////////////////////// // If the callbackThreshold and interruptInterval is set to non-0 through _SetTransferParameters() API, // the numBlocks and blockSize will set according to the user's requirement. // Otherwise, we use default values. /////////////////////////////////////////////////////////////////////////////////////////////////////// // This is not done for AMRWB yet because the DSP interface is asynchronous. // if (audDrv->callbackThreshold == 0 || audDrv->interruptInterval == 0) { // use default audDrv->numFramesPerInterrupt = 4; // totally to queue about 1 second of amr_nb data, 50 frames ringBufferFrames = 50; } else { audDrv->numFramesPerInterrupt = audDrv->interruptInterval / DSP_RENDER_FRAME_DURATION; if (audDrv->numFramesPerInterrupt == 0) audDrv->numFramesPerInterrupt = 1; ringBufferFrames = audDrv->callbackThreshold / DSP_RENDER_FRAME_DURATION; if (ringBufferFrames == 0) ringBufferFrames = 1; } switch (audDrv->drvType) { case VORENDER_TYPE_AMRNB: // totally to queue about 1 second of amr_nb data, 50 frames audDrv->bufferSize = sizeof(VR_Frame_AMR_t)*audDrv->numFramesPerInterrupt; audDrv->bufferNum = ringBufferFrames/audDrv->numFramesPerInterrupt + 1; break; case VORENDER_TYPE_PCM_VPU: // totally to queue about 1 second of amr_nb data, 50 frames audDrv->bufferSize = (LIN_PCM_FRAME_SIZE*sizeof(UInt16))*audDrv->numFramesPerInterrupt; //320 bytes audDrv->bufferNum = ringBufferFrames/audDrv->numFramesPerInterrupt + 1; break; case VORENDER_TYPE_PCM_ARM2SP: case VORENDER_TYPE_PCM_ARM2SP2: // totally to queue about 1 second of amr_nb data, 50 frames audDrv->bufferSize = (ARM2SP_INPUT_SIZE/4)*audDrv->numFramesPerInterrupt; //1280 bytes, 4 frames if (audDrv->config.samplingRate == AUDIO_SAMPLING_RATE_16000) audDrv->bufferSize *= 2; audDrv->bufferNum = ringBufferFrames/audDrv->numFramesPerInterrupt + 1; // arm2p is always 4 frames, not configurable. break; case VORENDER_TYPE_AMRWB: // size we dump data to shared mem when we got ripisr from dsp or data from omx audDrv->bufferSize = 0x400; // double the size of the dsp threshold audDrv->bufferNum = AUDIO_SIZE_PER_PAGE/audDrv->bufferSize*4; break; default: Log_DebugPrintf(LOGID_AUDIO, "ConfigAudDrv:: Doesn't support audio driver type drvType = 0x%x\n", audDrv->drvType); break; } audDrv->ringBuffer = (UInt8 *)OSHEAP_Alloc (audDrv->bufferNum*audDrv->bufferSize); audDrv->audQueue = AUDQUE_Create (audDrv->ringBuffer, audDrv->bufferNum, audDrv->bufferSize); Log_DebugPrintf(LOGID_AUDIO, " ConfigAudDrv::audio driver type drvType = 0x%x, bufferSize = 0x%x, bufferNum = 0x%x\n", audDrv->drvType, audDrv->bufferSize, audDrv->bufferNum); return RESULT_OK; }