Add 1 16-bit word for EDMA padding for Input Driver
[processor-sdk/performance-audio-sr.git] / processor_audio_sdk_1_00_00_00 / pasdk / test_arm / framework / aspDecOpCircBuf_slave.c
index 750fe4df3eaaca4c0cc6072002462c4c04843483..ea6598d95a3d16ef933cb40a52b1c191090d2887 100644 (file)
@@ -45,6 +45,8 @@ All rights reserved.
 //#include "pafsp.h"
 #include "aspDecOpCircBuf_slave.h"
 
+extern UInt32 gSlaveDecDecodeCnt;
+
 // Initialize circular buffer control
 Int cbCtlInit(
     PAF_AST_DecOpCircBufCtl *pCbCtl,    // decoder output circular buffer control
@@ -100,6 +102,8 @@ Int cbWriteStart(
     Cache_inv(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0);
     Cache_wait();
     
+    Log_info1("cbWriteStart:afCb=0x%04x", (IArg)pCb->afCb);
+    
     // Invalidate AF circular buffer
     Cache_inv(pCb->afCb, pCb->maxNumAfCb*sizeof(PAF_AudioFrame), Cache_Type_ALLD, 0);
     for (n=0; n<pCb->maxNumAfCb; n++)
@@ -150,6 +154,8 @@ Int cbWriteStop(
     // Invalidate circular buffer configuration
     Cache_inv(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0);
     Cache_wait();
+
+    Log_info1("cbWriteStop:afCb=0x%04x", (IArg)pCb->afCb);
     
     // update flags
     pCb->writerActiveFlag = 0;
@@ -186,8 +192,11 @@ Int cbWriteAf(
     // Enter gate
     key = GateMP_enter(gateHandle);
 
+    Log_info2("cbWriteAf:gate enter, gateHandle=0x%04x, key=%d", (IArg)gateHandle, (IArg)key);
+    
     // Get circular buffer base pointer
     pCb = &((*pCbCtl->pXDecOpCb)[cbIdx]);
+    Log_info1("cbWriteAf:pCb=0x%04x", (IArg)pCb);
 
     // (***) FL: revisit
     // Invalidate circular buffer configuration.
@@ -195,6 +204,10 @@ Int cbWriteAf(
     Cache_inv(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0);
     Cache_wait();
     
+    Log_info1("cbWriteAf:afCb=0x%04x", (IArg)pCb->afCb);   
+
+    Log_info2("cbWriteAf:pCb->readerActiveFlag=%d, pCb->writerActiveFlag=%d", (IArg)pCb->readerActiveFlag, (IArg)pCb->writerActiveFlag);
+
     if (pCb->readerActiveFlag == 1)
     {
         //
@@ -217,6 +230,8 @@ Int cbWriteAf(
         }
 #endif        
 
+        Log_info2("cbWriteAf:pCb->numAfCb=%d, pCb->maxNumAfCb=%d", (IArg)pCb->readerActiveFlag, (IArg)pCb->maxNumAfCb);
+    
         // check overflow
         if (pCb->numAfCb >= pCb->maxNumAfCb)
         {
@@ -225,14 +240,21 @@ Int cbWriteAf(
             //SW_BREAKPOINT;
             Log_info1("cbWriteAf: ERROR: overflow, numAfCb=%d", pCb->numAfCb);
 
+            // Write back circular buffer configuration
+            Cache_wb(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0);
+
             // Leave the gate
             GateMP_leave(gateHandle, key);
 
+            Log_info2("cbWriteAf:gate leave, gateHandle=0x%04x, key=%d", (IArg)gateHandle, (IArg)key);
+            
             return ASP_DECOP_CB_WRITE_OVERFLOW;
         }
         
         // get pointer to current audio frame in circular buffer
+        Log_info2("cbWriteAf:afCb=0x%04x, pCb->afWrtIdx=%d", (IArg)pCb->afCb, (IArg)pCb->afWrtIdx);
         pAfCb = &pCb->afCb[pCb->afWrtIdx];
+        Log_info1("cbWriteAf:pAfCb=0x%04x", (IArg)pAfCb);
            
         // write audio frame information updated by decoder
         pAfCb->sampleDecode = pAfWrt->sampleDecode;
@@ -248,6 +270,14 @@ Int cbWriteAf(
         pAfCb->bsMetadata_offset   = pAfWrt->bsMetadata_offset;      /* offset into audio frame for change in bsMetadata_type field */
         // write PCM samples
         streamMask = pAfWrt->fxns->channelMask(pAfWrt, pAfCb->channelConfigurationStream);
+        Log_info1("cbWriteAf:streamMask=0x%04x", (IArg)streamMask);
+        Log_info1("cbWriteAf:pCb->decOpFrameLen=%d", (IArg)pCb->decOpFrameLen);
+        Log_info2("cbWriteAf:pAfCb->data.sample=0x%04x, pAfWrt->data.sample=0x%04x", (IArg)pAfCb->data.sample, (IArg)pAfWrt->data.sample);
+        Log_info2("cbWriteAf:pAfCb->data.samsiz=0x%04x, pAfWrt->data.samsiz=0x%04x", (IArg)pAfCb->data.samsiz, (IArg)pAfWrt->data.samsiz);
+        //if (gSlaveDecDecodeCnt == 7)
+        //{
+        //    Log_info1("gSlaveDecDecodeCnt=%d", (IArg)gSlaveDecDecodeCnt);
+        //}
         for (i = 0; i < ASP_DECOP_CB_MAX_NUM_PCM_CH; i++)
         {
             if ((streamMask >> i) & 0x1)
@@ -261,6 +291,7 @@ Int cbWriteAf(
             }
         }
         
+        Log_info1("cbWriteAf:pAfCb->numPrivateMetadata=%d", (IArg)pAfCb->numPrivateMetadata);
         // Write metadata to circular buffer
         for (i = 0; i < pAfCb->numPrivateMetadata; i++) // FL: only copy numPrivateMetadata
         {
@@ -270,14 +301,18 @@ Int cbWriteAf(
         }
         
         // update audio frame write index
+        Log_info2("cbWriteAf:pCb->afWrtIdx=%d, pCb->maxNumAfCb", (IArg)pCb->afWrtIdx, (IArg)pCb->maxNumAfCb);
         pCb->afWrtIdx++;
         if (pCb->afWrtIdx >= pCb->maxNumAfCb)
         {
             pCb->afWrtIdx = 0;
         }
+        Log_info2("cbWriteAf:pCb->afWrtIdx=%d, pCb->maxNumAfCb", (IArg)pCb->afWrtIdx, (IArg)pCb->maxNumAfCb);
         
         // update number of audio frames in circular buffer
+        Log_info1("cbWriteAf:pCb->numAfCb=%d", (IArg)pCb->numAfCb);
         pCb->numAfCb++;
+        Log_info1("cbWriteAf:pCb->numAfCb=%d", (IArg)pCb->numAfCb);
 
         // (***) FL: revisit
         // Write back circular buffer configuration
@@ -306,6 +341,8 @@ Int cbWriteAf(
     // Leave the gate
     GateMP_leave(gateHandle, key);
 
+    Log_info2("cbWriteAf:gate leave, gateHandle=0x%04x, key=%d", (IArg)gateHandle, (IArg)key);
+    
     return ASP_DECOP_CB_SOK;
 }