X-Git-Url: https://git.ti.com/gitweb?p=processor-sdk%2Fperformance-audio-sr.git;a=blobdiff_plain;f=processor_audio_sdk_1_00_00_00%2Fpasdk%2Fcommon%2FaspDecOpCircBuf_common.c;h=b127faff89125cedcbbe5ea65c2e7b5c699c6cd2;hp=aab3e8cfc6ef870a3184b53740575e4b39490dfc;hb=6d29937bcc4e795e4a416f01c9a9cfe5fa2c541c;hpb=e1c84d0a8c17d5d3276a4174b2256b787c54c2ac;ds=sidebyside diff --git a/processor_audio_sdk_1_00_00_00/pasdk/common/aspDecOpCircBuf_common.c b/processor_audio_sdk_1_00_00_00/pasdk/common/aspDecOpCircBuf_common.c index aab3e8cf..b127faff 100644 --- a/processor_audio_sdk_1_00_00_00/pasdk/common/aspDecOpCircBuf_common.c +++ b/processor_audio_sdk_1_00_00_00/pasdk/common/aspDecOpCircBuf_common.c @@ -33,6 +33,7 @@ All rights reserved. * */ +#include // for memset() #include #include #include @@ -40,6 +41,88 @@ All rights reserved. #include "aspDecOpCircBuf_common.h" +// Reset circular buffer +Int cbReset( + PAF_AST_DecOpCircBufCtl *pCbCtl, + Int8 cbIdx +) +{ + IArg key; + GateMP_Handle gateHandle; + PAF_AST_DecOpCircBuf *pCb; + PAF_AudioFrame *pAfCb; + Int8 n; + Int8 i; + + // Get gate handle + gateHandle = pCbCtl->gateHandle; + // Enter gate + key = GateMP_enter(gateHandle); + + // Get circular buffer base pointer + pCb = &((*pCbCtl->pXDecOpCb)[cbIdx]); + + // Invalidate circular buffer configuration + Cache_inv(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0); + Cache_wait(); + + if (pCb->sourceSel == PAF_SOURCE_PCM) + { + // 2*256 in behind + pCb->afWrtIdx = ASP_DECOP_CB_INIT_WRTIDX_PCM; + pCb->afRdIdx = ASP_DECOP_CB_INIT_RDIDX_PCM; + pCb->pcmRdIdx = 0; + } + else if (pCb->sourceSel == PAF_SOURCE_DDP) + { + // 4*256 in behind + pCb->afWrtIdx = ASP_DECOP_CB_INIT_WRTIDX_DDP; + pCb->afRdIdx = ASP_DECOP_CB_INIT_RDIDX_DDP; + pCb->pcmRdIdx = pCb->decOpFrameLen - ASP_DECOP_CB_INIT_LAG_DDP*pCb->strFrameLen; + } + + // initialize circular buffer current number of frames + pCb->numAfCb = pCb->afWrtIdx - pCb->afRdIdx; + + for (n=0; nmaxNumAfCb; n++) + { + pAfCb = &pCb->afCb[n]; + + // clear PCM data + for (i=0; idata.sample[i], pCb->decOpFrameLen, 0); + } + + // clear metadata + pAfCb->numPrivateMetadata = 0; + } + + // reset error counts + pCb->errUndCnt = 0; + pCb->errOvrCnt = 0; + + // Write back circular buffer configuration + Cache_wb(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0); + + // Write back AF circular buffer + Cache_wb(pCb->afCb, pCb->maxNumAfCb*sizeof(PAF_AudioFrame), Cache_Type_ALLD, 0); + for (n=0; nmaxNumAfCb; n++) + { + pAfCb = &pCb->afCb[n]; + for (i=0; idata.sample[i], pCb->decOpFrameLen*sizeof(PAF_AudioData), Cache_Type_ALLD, 0); + } + } + Cache_wait(); + + // Leave the gate + GateMP_leave(gateHandle, key); + + return ASP_DECOP_CB_SOK; +} + // Output log of circular buffer control variables (debug) Int cbLog( PAF_AST_DecOpCircBufCtl *pCbCtl,