]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/performance-audio-sr.git/blobdiff - pasdk/test_arm/framework/audioStreamDecodeProc.c
Build #38: remove GPIO debug
[processor-sdk/performance-audio-sr.git] / pasdk / test_arm / framework / audioStreamDecodeProc.c
index d945fd21e674fefde62b062eaaf2e9584a4e5008..12c4e8b6902badc2a36011662f9458661ed2d025 100644 (file)
@@ -101,9 +101,11 @@ PAF_AudioData  *gDecAudioFrameChannelPointers[PAF_MAXNUMCHAN_AF];
 PAF_AudioSize  gDecAudioFrameChannelSizes[PAF_MAXNUMCHAN_AF];
 PAF_AudioData  *gDecOrigAudioFrameChannelPointers[PAF_MAXNUMCHAN_AF];
 
-// Underflow threshold before returning error to Top-Level FSM
+// Overflow threshold before circular buffer reset and return error to Top-Level FSM
 #define DEC_OP_CB_WRTAF_OVR_THR  ( 20 ) // FL: arbitrary setting
-UInt32 gDecOpCbWrtAfOvr  =0; // decoder output circular buffer overflow count
+UInt32 gCbWrtAfErrCnt           =0; // decoder output circular buffer write error count, not including overflows
+UInt32 gDecOpCbWrtAfOvr         =0; // decoder output circular buffer overflow count
+UInt32 gMaxDecOpCbWrtAfOvr      =0; // max (consecutive) decoder output circular buffer overflow count
 
 // Global debug counters */
 UInt32 gSlaveStartErrCnt        =0;
@@ -119,6 +121,10 @@ UInt32 gSlaveDecDecodeCnt       =0;
 UInt32 gSlaveDecDeactivateCnt   =0;
 
 
+// FL: (***) debug
+#include "evmc66x_gpio_dbg.h"
+
+
 /*
  *  ======== taskAsdpFxn ========
  *  Audio Stream Decode Processing task function
@@ -304,6 +310,8 @@ Void taskAsdpFxn(
     Cache_wb((Ptr)(&IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM2]), sizeof(IALG_Status *), Cache_Type_ALLD, 0);
     Cache_wb((Ptr)(&IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP]), sizeof(IALG_Status *), Cache_Type_ALLD, 0);
     Cache_wb((Ptr)(&IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP2]), sizeof(IALG_Status *), Cache_Type_ALLD, 0);
+    Cache_wb((Ptr)(&IACP_STD_BETA_TABLE.pStatus[STD_BETA_THD]), sizeof(IALG_Status *), Cache_Type_ALLD, 0);
+    Cache_wb((Ptr)(&IACP_STD_BETA_TABLE.pStatus[STD_BETA_THD2]), sizeof(IALG_Status *), Cache_Type_ALLD, 0);
     Cache_wait();
     
     // (***) FL: revisit
@@ -491,6 +499,9 @@ Void taskAsdpFxn(
                     {
                         SW_BREAKPOINT;
                     }
+                    gCbWrtAfErrCnt=0;       // reset write circular buffer error count
+                    gDecOpCbWrtAfOvr=0;     // reset decoder output circular buffer overflow count
+                    gMaxDecOpCbWrtAfOvr=0;  // reset max decoder output circular buffer overflow count
                     // FL: debug, log circular buffer control variables
                     cbLog(pCbCtl, z, 1, "cbWriteStart");
                     // Reset audio frame
@@ -527,7 +538,7 @@ Void taskAsdpFxn(
                     }
 
                     // write back Dec configuration
-                    Cache_wbInv(&pAstCfg->xDec[z], sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
+                    Cache_wb(&pAstCfg->xDec[z], sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
                     Cache_wait();            
 
                     // (***) FL: revisit
@@ -566,7 +577,7 @@ Void taskAsdpFxn(
                     TRACE_TERSE2("slaveCmd=%d,decIdx=%d", slaveCmd, z);
                     // Get input associated w/ decoder
                     zI = pP->inputsFromDecodes[z];
-                    
+
                     // (***) FL: revisit
                     // invalidate Inp configuration
                     Cache_inv(&pAstCfg->xInp[zI], sizeof(PAF_AST_InpBuf), Cache_Type_ALLD, 0);
@@ -592,8 +603,8 @@ Void taskAsdpFxn(
                     wrapSize = size - chunkSize;
                     // invalidate input data
                     Cache_inv((Ptr)pIpBufConfig->pntr.pSmInt, chunkSize, Cache_Type_ALLD, 0);
-                    TRACE_MSG2("IBUF : pIpBufConfig->pntr.pSmInt: 0x%x and chunkSize: %d", pIpBufConfig->pntr.pSmInt, chunkSize);
                     // invalidate Dec configuration
+                    TRACE_MSG2("IBUF : pIpBufConfig->pntr.pSmInt: 0x%x and chunkSize: %d", (IArg)pIpBufConfig->pntr.pSmInt, chunkSize);
                     Cache_inv(&pAstCfg->xDec[z], sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
                     // status for selected decoder should be invalidated
                     Cache_wait();
@@ -604,7 +615,7 @@ Void taskAsdpFxn(
                     {
                         // invalidate input data
                         Cache_inv((Ptr)pIpBufConfig->base.pSmInt, wrapSize, Cache_Type_ALLD, 0);
-                        TRACE_MSG2("IBUF : pIpBufConfig->base.pSmInt: 0x%x and wrapSize: %d",pIpBufConfig->base.pSmInt, wrapSize);
+                        TRACE_MSG2("IBUF : pIpBufConfig->base.pSmInt: 0x%x and wrapSize: %d", (IArg)pIpBufConfig->base.pSmInt, wrapSize);
                         // status for selected decoder should be invalidated
                         Cache_wait();
                     }
@@ -618,7 +629,7 @@ Void taskAsdpFxn(
                     }
                     
                     // write back Dec configuration
-                    Cache_wbInv(&pAstCfg->xDec[z], sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
+                    Cache_wb(&pAstCfg->xDec[z], sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
                     Cache_wait();            
                     
 #ifdef NON_CACHE_STATUS
@@ -689,7 +700,7 @@ Void taskAsdpFxn(
                         errno = dec->fxns->decode(dec, NULL, &pAstCfg->xDec[z].decodeInStruct, &pAstCfg->xDec[z].decodeOutStruct);
                         if (errno < 0)
                         {
-                            SW_BREAKPOINT;
+                            //SW_BREAKPOINT;
                         }
                         TRACE_TERSE0("Dec:decode done");
                         
@@ -708,34 +719,59 @@ Void taskAsdpFxn(
                         //}                        
 
                         cbErrno = cbWriteAf(pCbCtl, z, pAfWrt);
-                        if (cbErrno < 0)
+                        if ((cbErrno < 0) && (cbErrno != ASP_DECOP_CB_WRITE_OVERFLOW))
                         {
+                            gCbWrtAfErrCnt++;
                             //SW_BREAKPOINT; // FL: debug
-                            
-                            if (cbErrno == ASP_DECOP_CB_WRITE_OVERFLOW)
+                        }
+                        
+                        // Handle overflows
+                        if (cbErrno == ASP_DECOP_CB_WRITE_OVERFLOW)
+                        {
+                            gDecOpCbWrtAfOvr++; // increment circular buffer overflow count
+                            if (gDecOpCbWrtAfOvr >= DEC_OP_CB_WRTAF_OVR_THR)
                             {
+                                gMaxDecOpCbWrtAfOvr = DEC_OP_CB_WRTAF_OVR_THR; // update max overflow count
+                                gDecOpCbWrtAfOvr = 0; // reset overflow count
+                                
                                 // Reset circular buffer
                                 cbReset(pCbCtl, z);
-                                // Update overflow count, return if above threshold
-                                gDecOpCbWrtAfOvr++;
-                                if (gDecOpCbWrtAfOvr < DEC_OP_CB_WRTAF_OVR_THR)
-                                {
-                                    cbErrno = 0;
-                                }
-                                else 
-                                {
-                                    gDecOpCbWrtAfOvr = 0;
-                                }
                             }
                         }
+                        else if ((cbErrno == ASP_DECOP_CB_SOK) && (gDecOpCbWrtAfOvr > 0))
+                        {
+                            // No overflow detected.
+                            // update max overflow count,
+                            // reset overflow count
+                            
+                            if (gDecOpCbWrtAfOvr > gMaxDecOpCbWrtAfOvr)
+                            {
+                                gMaxDecOpCbWrtAfOvr = gDecOpCbWrtAfOvr;
+                            }
+                            gDecOpCbWrtAfOvr = 0; // reset circular buffer overflow count
+                            
+                            cbErrno = 0; // don't return error condition
+                        }
                         TRACE_TERSE0("Dec:cbWriteAf() complete");
                         
+#if 0 // (***) FL: shows timing of CB write
+                        // (***) debug // B9
+                        {
+                            static Uint8 toggleState = 0;
+                            if (toggleState == 0)
+                                GPIOSetOutput(GPIO_PORT_0, GPIO_PIN_107);
+                            else
+                                GPIOClearOutput(GPIO_PORT_0, GPIO_PIN_107);
+                            toggleState = ~(toggleState);
+                        }
+#endif        
+                        
                         // FL: debug, log circular buffer control variables
                         cbLog(pCbCtl, z, 1, "cbWriteAf");
                     }
                     
                     // write back Dec configuration
-                    Cache_wbInv(&pAstCfg->xDec[z], sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
+                    Cache_wb(&pAstCfg->xDec[z], sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
                     Cache_wait();
                     
 #ifdef NON_CACHE_STATUS
@@ -1477,6 +1513,9 @@ Int resetAf(
         case PAF_SOURCE_DDP:
             pAudioFrame->data.nSamples = 1536;
             break;
+        case PAF_SOURCE_THD:
+            pAudioFrame->data.nSamples = 5120; //QIN FIX ME
+            break;
         default:  
             pAudioFrame->data.nSamples = FRAMELENGTH;
             break;