[processor-sdk/performance-audio-sr.git] / processor_audio_sdk_1_00_00_00 / pasdk / common / aspDecOpCircBuf_common.c
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 aab3e8cfc6ef870a3184b53740575e4b39490dfc..b127faff89125cedcbbe5ea65c2e7b5c699c6cd2 100644 (file)
*
*/
*
*/
+#include <string.h> // for memset()
#include <xdc/std.h>
#include <xdc/runtime/Log.h>
#include <ti/sysbios/hal/Cache.h>
#include <xdc/std.h>
#include <xdc/runtime/Log.h>
#include <ti/sysbios/hal/Cache.h>
#include "aspDecOpCircBuf_common.h"
#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; n<pCb->maxNumAfCb; n++)
+ {
+ pAfCb = &pCb->afCb[n];
+
+ // clear PCM data
+ for (i=0; i<ASP_DECOP_CB_MAX_NUM_PCM_CH; i++)
+ {
+ memset(pAfCb->data.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; n<pCb->maxNumAfCb; n++)
+ {
+ pAfCb = &pCb->afCb[n];
+ for (i=0; i<ASP_DECOP_CB_MAX_NUM_PCM_CH; i++)
+ {
+ Cache_wb(pAfCb->data.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,
// Output log of circular buffer control variables (debug)
Int cbLog(
PAF_AST_DecOpCircBufCtl *pCbCtl,