]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/performance-audio-sr.git/blobdiff - pasdk/test_dsp/framework/audioStreamInpProc.c
PASDK-218:Clean up
[processor-sdk/performance-audio-sr.git] / pasdk / test_dsp / framework / audioStreamInpProc.c
index cb0adfafc00233232d16927705ba80a98f667bf4..e5d4e40213a62d9ff969e8844631cd6e18c5d6da 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
-Copyright (c) 2016, Texas Instruments Incorporated - http://www.ti.com/
+Copyright (c) 2017, Texas Instruments Incorporated - http://www.ti.com/
 All rights reserved.
 
 * Redistribution and use in source and binary forms, with or without 
@@ -61,18 +61,22 @@ All rights reserved.
 #include "aspMsg_common.h"
 #include "aspMsg_master.h"
 #include "aspDecOpCircBuf_master.h"
+#include "aspOutInitSync_master.h"
 #include "audioStreamProc_common.h"
 #include "audioStreamProc_master.h"
 #include "audioStreamInpProc.h"
+#include "statusOp_common.h"
+
+#include "pfp/pfp.h"
+#include "pfp_app.h"        /* contains all PFP ID's */
+Int32 gNumPfpAsit1=0; // debug
+Int32 gNumPfpAsit2=0;
+
+
 
-// FL: porting
-#include "fwkSim.h"
-//#include "fwkPort.h"
 // FL: debug
 #include "dbgCapAf.h"
 
-#include "statusOp_common.h"
-
 
 // -----------------------------------------------------------------------------
 // Debugging Trace Control, local to this file.
@@ -243,6 +247,22 @@ All rights reserved.
 #include "audioStreamProc_config.h"
 #include "audioStreamInpProc.h"
 
+
+#include "dbgBenchmark.h" // PCM high-sampling rate + SRC + CAR benchmarking
+#ifdef _ENABLE_BENCHMARK_PCMHSR_SRC_CAR_
+//
+// Performing PCM high-sampling rate + SRC + CAR benchmarking
+//
+
+#define PROFILER
+#endif
+
+#ifdef PROFILER
+extern UInt32 start_profiling;
+#endif
+
+extern UInt32 gAspProfileEnable;
+
 //
 // Audio Stream Definitions
 //
@@ -286,12 +306,32 @@ All rights reserved.
 
 #define __TASK_NAME__  "TaskAsip"
 
+
+//
+// Audio Stream Input Task definitions
+//
+
+#define ASIP_FRAMELEN_SS_DEFAULT    ( 256 )
+// FL: pP->frameLength
+//#define ASIP_FRAMELEN_SS_PCM        ( FRAMELENGTH )
+// FL: (***) hard-coded
+#define ASIP_FRAMELEN_SS_DDP_AC3    ( 1536 )
+// FL: (***) hard-coded
+#define ASIP_FRAMELEN_SS_THD        ( 1536 )        //QIN FIX ME
+
+// Compute decoder frame length based on selected source
+static Int getFrameLengthSourceSel(
+    const PAF_ASIT_Params *pP, 
+    Int8 sourceSelect
+);
+
 LINNO_DEFN(TaskAsip); /* Line number macros */
 ERRNO_DEFN(TaskAsip); /* Error number macros */
 
 // ASIT configuration
 #pragma DATA_SECTION(gPAF_ASIT_config, ".globalSectionPafAsitConfig")
 PAF_ASIT_Config gPAF_ASIT_config = {
+    NULL,               // taskHandle
     NULL,               // acp
     &gPAF_ASPM_config,  // pAspmCfg, shared ASIT/ASOT configuration
     &gPAF_AST_config    // pAstCfg, shared ASIT/ASOT/ASDT configuration
@@ -306,12 +346,15 @@ UInt32 gAsipDecodeCnt           =0;
 UInt32 gAsipDecodeErrCnt        =0;
 UInt32 gAsipFinalCnt            =0;
 UInt32 gAsipQuitCnt             =0;
-UInt32 gIbReset_cnt             =0;
-UInt32 gcapIb_cnt               =0;
+UInt32 gAsipInfo1_PrimaryErrCnt =0;
+UInt32 gAsipInfo1_ErrCnt        =0;
 UInt32 gAsipInfo2_PrimaryErrCnt =0;
 UInt32 gAsipInfo2_ErrCnt        =0;
+UInt32 gCapIbReset_cnt          =0;
+UInt32 gCapIb_cnt               =0;
 // debug
-UInt32 gCbErrnoCnt              =0; // decoder circular buffer error count (write on ARM returned to DSP)
+UInt32 gCbWrtAfErrCnt           =0; // decoder output circular buffer write error count (returned from ARM to DSP)
+                                   
 
 #include "dbgDib.h" // debug
 
@@ -321,7 +364,6 @@ extern struct {
 } IACP_STD_BETA_TABLE;
 
 // FL: debug
-#include "evmc66x_pinmux.h"
 #include "evmc66x_gpio_dbg.h"
 
 /*
@@ -334,8 +376,8 @@ Void taskAsipFxn(
     const PAF_ASIT_Patchs *pQ
 )
 {
-    PAF_ASIT_Config *pC;            /* Local configuration pointer */
-    PAF_AST_Config *pAstCfg;        /* Common (shared) configuration pointer */
+    PAF_ASIT_Config *pAsitCfg;      /* ASIT configuration pointer */
+    PAF_AST_Config *pAstCfg;        /* AST Common (shared) configuration pointer */
     Int as;                         /* Audio Stream Number (1, 2, etc.) */
     Int z;                          /* input/encode/stream/decode/output counter */
     Int i;                          /* phase */
@@ -350,17 +392,11 @@ Void taskAsipFxn(
 #ifdef NON_CACHE_STATUS
     Int8 tempVar8;
 #endif
-    Task_Handle taskHandle;
 
     Log_info0("Enter taskAsipFxn()");
-    
-#ifdef SIMULATE_SIO
-    /* Start simulation */
-    simStart();
-#endif // SIMULATE_SIO
 
     //
-    // Audio Framework Parameters & Patch (*pP, *pQ)
+    // Audio Stream Input Task Parameters & Patch (*pP, *pQ)
     //
     if (!pP) 
     {
@@ -377,18 +413,17 @@ Void taskAsipFxn(
     }    
     
     //
-    // Audio Framework Configuration (*pC):
+    // Audio Stream Input Task Configuration (*pAsitCfg):
     //
-    pC = &gPAF_ASIT_config;
-    pAstCfg = pC->pAstCfg;
+    pAsitCfg = &gPAF_ASIT_config;       // initialize pointer to task configuration
+    pAsitCfg->taskHandle = Task_self(); // set task handle
+    pAstCfg = pAsitCfg->pAstCfg;        // get pointer to AST common (shared) configuration
 
     /* Set Audio Stream Number (1, 2, etc.) */
     as = gBetaPrimeValue + 1;
     pAstCfg->as = as;    
     TRACE_TERSE1("TaskAsip: Started with AS%d.", as);
 
-    taskHandle = Task_self();
-    
     //
     // Initialize message log trace and line number reporting
     //
@@ -434,7 +469,8 @@ Void taskAsipFxn(
         Int linno;
         if (pP->fxns->initPhase[i])
         {
-            if (linno = pP->fxns->initPhase[i](pP, pQ, pC)) 
+            linno = pP->fxns->initPhase[i](pP, pQ, pAsitCfg);
+            if (linno) 
             {
                 LINNO_RPRT(TaskAsip, linno);
                 return;
@@ -453,14 +489,14 @@ Void taskAsipFxn(
     //
     if (pP->fxns->memStatusPrint)
     {
-        pP->fxns->memStatusPrint(HEAP_INTERNAL, HEAP_INTERNAL1, HEAP_EXTERNAL, HEAP_INTERNAL1_SHM);
+        pP->fxns->memStatusPrint("ASIT MEMSTAT REPORT",
+            HEAP_INTERNAL, HEAP_INTERNAL1, HEAP_EXTERNAL, 
+            HEAP_INTERNAL1_SHM, HEAP_EXTERNAL_SHM, HEAP_EXTERNAL_NONCACHED_SHM);
     }
     
     // (***) FL: revisit
     // write back AST shared configuration
     Cache_wb(pAstCfg, sizeof(PAF_AST_Config), Cache_Type_ALLD, 0);
-    // FL: no need to share this pointer, can be local
-    //Cache_wb(&pC, sizeof(PAF_AST_Config *), Cache_Type_ALLD, 0);
     Cache_wait();
 
     // (***) FL: revisit
@@ -610,7 +646,7 @@ Void taskAsipFxn(
         TRACE_TIME((&TIME_MOD, "as1_f2... + %d = %d (begin Main loop)", dtime(), TSK_time()));
         
         // since not decoding indicate such
-        pP->fxns->sourceDecode(pP, pQ, pC, PAF_SOURCE_NONE);
+        pP->fxns->sourceDecode(pP, pQ, pAsitCfg, PAF_SOURCE_NONE);
 
         // any error forces idling of input
         if (errno) 
@@ -636,7 +672,8 @@ Void taskAsipFxn(
         Task_sleep(1);
 
         TRACE_GEN1("TaskAsip: AS%d: Input device selection ...", as+zMS);
-        if (errno = pP->fxns->selectDevices(pP, pQ, pC))
+        errno = pP->fxns->selectDevices(pP, pQ, pAsitCfg);
+        if (errno)
         {
             TRACE_TERSE2("TaskAsip: selectDevices returned errno = 0x%04x at line %d. AS%d", errno, as+zMS);
             continue;
@@ -660,7 +697,8 @@ Void taskAsipFxn(
         }
         
         // if here then we have a valid input so query its status
-        if (errno = pP->fxns->updateInputStatus(pAstCfg->xInp[zMI].hRxSio, &pAstCfg->xInp[zMI].inpBufStatus, &pAstCfg->xInp[zMI].inpBufConfig))
+        errno = pP->fxns->updateInputStatus(pAstCfg->xInp[zMI].hRxSio, &pAstCfg->xInp[zMI].inpBufStatus, &pAstCfg->xInp[zMI].inpBufConfig);
+        if (errno)
         {
             TRACE_VERBOSE1("TaskAsip: continue as updateInputStatus returns 0x%x", errno);
             continue;
@@ -734,10 +772,10 @@ Void taskAsipFxn(
             TRACE_VERBOSE1("TaskAsip: AS%d: Pass processing ...", as+zMS);
             pAstCfg->xDec[zMD].decodeStatus.sourceProgram = PAF_SOURCE_PASS;
 #endif
-            pP->fxns->sourceDecode(pP, pQ, pC, PAF_SOURCE_PASS);
+            pP->fxns->sourceDecode(pP, pQ, pAsitCfg, PAF_SOURCE_PASS);
             if (pP->fxns->passProcessing)
             {
-                errno = pP->fxns->passProcessing(pP, pQ, pC, NULL);                
+                errno = pP->fxns->passProcessing(pP, pQ, pAsitCfg, NULL);                
             }
             else 
             {
@@ -758,7 +796,15 @@ Void taskAsipFxn(
         // If no decoder selected then do nothing. Need to reset the sourceProgram, since
         // when no decoder is selected there are no calls to IB
         //if (errno = pP->fxns->autoProcessing(pP, pQ, pC, pC->xDec[zMD].decodeStatus.sourceSelect, pC->xDec[zMD].decAlg[PAF_SOURCE_PCM]))
-        if (errno = pP->fxns->autoProcessing(pP, pQ, pC, tempVar8, NULL)) // (***) FL: re-visit this, hard-coded to use PCM framelength inside function
+        
+        pfpBegin(PFP_ID_ASIT_1, pAsitCfg->taskHandle);  // PFP begin
+        gNumPfpAsit1++;
+        // (***) FL: re-visit, hard-coded to use FRAMELENGTH (pP->frameLength) inside function
+        errno = pP->fxns->autoProcessing(pP, pQ, pAsitCfg, tempVar8, NULL);
+        pfpEnd(PFP_ID_ASIT_1, PFP_FINISH_MEAS);         // PFP end
+        gNumPfpAsit1--;
+
+        if (errno)
         {
             TRACE_VERBOSE1("TaskAsip: autoProcessing returns 0x%x, continue", errno);
             continue;
@@ -768,8 +814,10 @@ Void taskAsipFxn(
         // At this point we have an enabled input and want to decode something.
         // If no decoder selected then do nothing. Need to reset the sourceProgram, since
         // when no decoder is selected there are no calls to IB
-        //if (errno = pP->fxns->autoProcessing(pP, pQ, pC, pC->xDec[zMD].decodeStatus.sourceSelect, pC->xDec[zMD].decAlg[PAF_SOURCE_PCM]))
-        if (errno = pP->fxns->autoProcessing(pP, pQ, pC, pAstCfg->xDec[zMD].decodeStatus.sourceSelect, NULL)) // (***) FL: re-visit this, hard-coded to use PCM framelength inside function
+        
+        //if (errno = pP->fxns->autoProcessing(pP, pQ, PC, pC->xDec[zMD].decodeStatus.sourceSelect, pC->xDec[zMD].decAlg[PAF_SOURCE_PCM]))
+        // (***) FL: re-visit this, hard-coded to use FRAMELENGTH (pP->frameLength) inside function
+        if (errno = pP->fxns->autoProcessing(pP, pQ, pAsitCfg, pAstCfg->xDec[zMD].decodeStatus.sourceSelect, NULL))
         {
             TRACE_VERBOSE1("TaskAsip: autoProcessing returns 0x%x, continue", errno);
             continue;
@@ -777,7 +825,8 @@ Void taskAsipFxn(
 #endif
         
         // query for input type
-        if (errno = SIO_ctrl(pAstCfg->xInp[zMI].hRxSio, PAF_SIO_CONTROL_GET_SOURCEPROGRAM, (Arg )&sourceProgram))
+        errno = SIO_ctrl(pAstCfg->xInp[zMI].hRxSio, PAF_SIO_CONTROL_GET_SOURCEPROGRAM, (Arg )&sourceProgram);
+        if (errno)
         {
             TRACE_TERSE2("TaskAsip: SIO_ctrl returns 0x%x, then 0x%x, continue", errno, ASPERR_AUTO_PROGRAM);
             errno = ASPERR_AUTO_PROGRAM;
@@ -886,7 +935,7 @@ Void taskAsipFxn(
 
         // FL: debug, reset IB capture buffer
         capIbReset();
-        gIbReset_cnt++;
+        gCapIbReset_cnt++;
         Log_info0("capIbReset()");
 
         // FL: send source select message to slave
@@ -931,15 +980,17 @@ Void taskAsipFxn(
         
         // set to unknown so that we can ensure, for IOS purposes, that sourceDecode = NONE
         // iff we are in this top level state machine and specifically not in decodeProcessing
-        pP->fxns->sourceDecode(pP, pQ, pC, PAF_SOURCE_UNKNOWN);
+        pP->fxns->sourceDecode(pP, pQ, pAsitCfg, PAF_SOURCE_UNKNOWN);
         
         TRACE_VERBOSE1(procName[sourceProgram], as+zMS);
 
         // Reduce priority level since autodetection complete
-        Task_setPri(taskHandle, Task_getPri(taskHandle)-1);
+        Task_setPri(pAsitCfg->taskHandle, Task_getPri(pAsitCfg->taskHandle)-1);
+        
+        gAspProfileEnable=1; // enable ASP profiling
         
         TRACE_VERBOSE0("TaskAsip: calling decodeProcessing.");
-        errno = pP->fxns->decodeProcessing(pP, pQ, pC, sourceSelect);
+        errno = pP->fxns->decodeProcessing(pP, pQ, pAsitCfg, sourceSelect);
         if (errno) 
         {
             TRACE_TERSE1("TaskAsip: decodeProcessing returns 0x%x, continue", errno);
@@ -949,8 +1000,10 @@ Void taskAsipFxn(
             TRACE_VERBOSE0("TaskAsip: decodeProcessing complete with no error.");
         }        
 
+        gAspProfileEnable=0; // disable ASP profiling
+        
         // Increase priority level since decoding complete
-        Task_setPri(taskHandle, Task_getPri(taskHandle)+1);
+        Task_setPri(pAsitCfg->taskHandle, Task_getPri(pAsitCfg->taskHandle)+1);
 
         // FL: send dec exit message to slave
         pAspMsg = (ASP_Msg *)MessageQ_alloc(hAspMsgMaster->heapId, hAspMsgMaster->msgSize); /* allocate message */
@@ -992,7 +1045,7 @@ Void taskAsipFxn(
         }
     } // End of main processing loop for (;;)
     
-    Log_info0("Exit taskAsipFxn()");
+    //Log_info0("Exit taskAsipFxn()");
 }
 
 // -----------------------------------------------------------------------------
@@ -1014,7 +1067,7 @@ Int
 PAF_ASIT_initPhaseMalloc(
     const PAF_ASIT_Params *pP, 
     const PAF_ASIT_Patchs *pQ, 
-    PAF_ASIT_Config *pC
+    PAF_ASIT_Config *pAsitCfg
 )
 {
     PAF_AST_Config *pAstCfg;
@@ -1022,7 +1075,7 @@ PAF_ASIT_initPhaseMalloc(
     Int zMS;
     Error_Block    eb;
 
-    pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
+    pAstCfg = pAsitCfg->pAstCfg; // get pointer to AST common (shared) configuration
     as = pAstCfg->as;
     zMS = pAstCfg->masterStr;
     
@@ -1039,7 +1092,7 @@ PAF_ASIT_initPhaseMalloc(
         SW_BREAKPOINT;
         return __LINE__;
     }
-    TRACE_TERSE3("PAF_ASIT_initPhaseMalloc. (pC->xInp) %d bytes from space %d at 0x%x.",
+    TRACE_TERSE3("PAF_ASIT_initPhaseMalloc. (pAstCfg->xInp) %d bytes from space %d at 0x%x.",
         INPUTN * sizeof (*pAstCfg->xInp),
         HEAP_ID_INTERNAL1_SHM, (IArg)pAstCfg->xInp);
 
@@ -1062,7 +1115,7 @@ PAF_ASIT_initPhaseMalloc(
         return __LINE__;
     }
 #endif
-    TRACE_TERSE3("PAF_ASIT_initPhaseMalloc. (pC->xDec) %d bytes from space %d at 0x%x.",
+    TRACE_TERSE3("PAF_ASIT_initPhaseMalloc. (pAstCfg->xDec) %d bytes from space %d at 0x%x.",
         DECODEN * sizeof (*pAstCfg->xDec),
         HEAP_ID_INTERNAL1_SHM, (IArg)pAstCfg->xDec);
                 
@@ -1088,7 +1141,7 @@ Int
 PAF_ASIT_initPhaseConfig(
     const PAF_ASIT_Params *pP, 
     const PAF_ASIT_Patchs *pQ, 
-    PAF_ASIT_Config *pC
+    PAF_ASIT_Config *pAsitCfg
 )
 {
     PAF_AST_Config *pAstCfg;
@@ -1096,7 +1149,7 @@ PAF_ASIT_initPhaseConfig(
     Int z;                     /* input/encode/stream/decode/output counter */
     Int zMS;
 
-    pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
+    pAstCfg = pAsitCfg->pAstCfg; // get pointer to AST common (shared) configuration
     as = pAstCfg->as;
     zMS = pAstCfg->masterStr;
     
@@ -1143,7 +1196,7 @@ Int
 PAF_ASIT_initPhaseAcpAlg(
     const PAF_ASIT_Params *pP, 
     const PAF_ASIT_Patchs *pQ, 
-    PAF_ASIT_Config *pC
+    PAF_ASIT_Config *pAsitCfg
 )
 {
     PAF_AST_Config *pAstCfg;
@@ -1154,7 +1207,7 @@ PAF_ASIT_initPhaseAcpAlg(
     Int zMS;
     Int zS, zX;
 
-    pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
+    pAstCfg = pAsitCfg->pAstCfg; // get pointer to AST common (shared) configuration
     as = pAstCfg->as;
     zMS = pAstCfg->masterStr;
     
@@ -1167,7 +1220,7 @@ PAF_ASIT_initPhaseAcpAlg(
         TRACE_TERSE1("PAF_ASIT_initPhaseAcpAlg: AS%d: ACP algorithm instance creation failed", as+zMS);
         return __LINE__;
     }
-    pC->acp = acp;
+    pAsitCfg->acp = acp;
 
     ((ALG_Handle)acp)->fxns->algControl((ALG_Handle) acp,
         ACP_GETBETAPRIMEOFFSET, (IALG_Status *)&betaPrimeOffset);
@@ -1216,7 +1269,7 @@ Int
 PAF_ASIT_initPhaseCommon(
     const PAF_ASIT_Params *pP, 
     const PAF_ASIT_Patchs *pQ, 
-    PAF_ASIT_Config *pC
+    PAF_ASIT_Config *pAsitCfg
 )
 {
     PAF_AST_Config *pAstCfg;
@@ -1226,8 +1279,8 @@ PAF_ASIT_initPhaseCommon(
     PAF_IALG_Config pafAlgConfig;
     IALG_MemRec common[3][PAF_IALG_COMMON_MEMN+1];
    
-    acp = pC->acp;
-    pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
+    acp = pAsitCfg->acp;
+    pAstCfg = pAsitCfg->pAstCfg; // get pointer to AST common (shared) configuration
     as = pAstCfg->as;
     
     TRACE_TERSE0("PAF_ASIT_initPhaseCommon: initialization phase - Common Memory");
@@ -1368,14 +1421,14 @@ Int
 PAF_ASIT_initPhaseAlgKey(
     const PAF_ASIT_Params *pP, 
     const PAF_ASIT_Patchs *pQ, 
-    PAF_ASIT_Config *pC
+    PAF_ASIT_Config *pAsitCfg
 )
 {
     PAF_AST_Config *pAstCfg;
     Int as;                    /* Audio Stream Number (1, 2, etc.) */
 
     
-    pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
+    pAstCfg = pAsitCfg->pAstCfg; // get pointer to AST common (shared) configuration
     as = pAstCfg->as;
     (void)as;  // clear compiler warning in case not used with tracing disabled
 
@@ -1421,7 +1474,7 @@ Int
 PAF_ASIT_initPhaseDevice(
     const PAF_ASIT_Params *pP, 
     const PAF_ASIT_Patchs *pQ, 
-    PAF_ASIT_Config *pC
+    PAF_ASIT_Config *pAsitCfg
 )
 {
     PAF_AST_Config *pAstCfg;
@@ -1432,7 +1485,7 @@ PAF_ASIT_initPhaseDevice(
     PAF_IALG_Config pafAlgConfig;
 
 
-    pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
+    pAstCfg = pAsitCfg->pAstCfg; // get pointer to AST common (shared) configuration
     as = pAstCfg->as;
     (void)as; // clear compiler warning in case not used with tracing disabled
 
@@ -1479,6 +1532,7 @@ PAF_ASIT_initPhaseDevice(
     return 0;
 } //PAF_ASIT_initPhaseDevice
 
+// (***) FL: move to ASOT
 // -----------------------------------------------------------------------------
 // ASIT Initialization Function - Decoder Output Circular Buffer
 //
@@ -1497,7 +1551,7 @@ Int
 PAF_ASIT_initPhaseDecOpCircBuf(
     const PAF_ASIT_Params *pP, 
     const PAF_ASIT_Patchs *pQ, 
-    PAF_ASIT_Config *pC
+    PAF_ASIT_Config *pAsitCfg
 )
 {
     PAF_AST_Config *pAstCfg;
@@ -1508,13 +1562,16 @@ PAF_ASIT_initPhaseDecOpCircBuf(
     Int errno;                          /* error number */
     Error_Block    eb;
     Int i;
+    ACP_Handle acp;
+    Int betaPrimeOffset;
+    Int zS;
 
     // FL: (***)revisit
-    pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
+    pAstCfg = pAsitCfg->pAstCfg; // get pointer to AST common (shared) configuration
     as = pAstCfg->as;
     zMS = pAstCfg->masterStr;
 
-    /* Decode output circular buffer memory */
+    // Decode output circular buffer memory
     if (!(pAstCfg->xDecOpCb = Memory_calloc((IHeap_Handle)HEAP_INTERNAL1_SHM, 
         DECODEN * sizeof (*pAstCfg->xDecOpCb), 4, &eb)))
     {
@@ -1523,10 +1580,10 @@ PAF_ASIT_initPhaseDecOpCircBuf(
         return __LINE__;
     }
 
-    TRACE_TERSE3("PAF_ASIT_initPhaseDecOpCircBuf. (pC->xDecOpCb) %d bytes from space %d at 0x%x.",
+    TRACE_TERSE3("PAF_ASIT_initPhaseDecOpCircBuf. (pAsitCfg->xDecOpCb) %d bytes from space %d at 0x%x.",
         DECODEN * sizeof (*pAstCfg->xDecOpCb),
         HEAP_ID_INTERNAL1_SHM, (IArg)pAstCfg->xDecOpCb);
-        
+
     for (z=DECODE1; z < DECODEN; z++)
     {
         pCb = &pAstCfg->xDecOpCb[z];
@@ -1558,15 +1615,62 @@ PAF_ASIT_initPhaseDecOpCircBuf(
             SW_BREAKPOINT;
         }
         pCb->pcmBufEnd = pCb->pcmBuf + ASP_DECOP_CB_PCM_BUF_SZ;
-        // allocate Metadata buffers //QIN
+        // allocate Metadata buffers
         if (!(pCb->metaBuf = Memory_calloc((IHeap_Handle)HEAP_EXTERNAL_SHM, ASP_DECOP_CB_MAX_NUM_AF * PAF_MAX_PRIVATE_MD_SZ * PAF_MAX_NUM_PRIVATE_MD * sizeof(Int8), 4, &eb)))
         {
             TRACE_TERSE1("PAF_ASIT_initPhaseDecOpCircBuf: AS%d: Memory_calloc failed", as+zMS);
             SW_BREAKPOINT;
         }
         pCb->metaBufEnd = pCb->metaBuf + (ASP_DECOP_CB_MAX_NUM_AF * PAF_MAX_PRIVATE_MD_SZ * PAF_MAX_NUM_PRIVATE_MD);
-        // (***) FL: revisit, here PCM is hard-coded for 256 sample dec op frame length        
-        // Initialize decoder output circular buffer for PCM
+
+        #ifdef CB_RW_OP_CAP_PP // debug
+        // allocate debug buffer
+        if (!(pCb->cb_samples_op = Memory_calloc((IHeap_Handle)HEAP_EXTERNAL_NONCACHED_SHM, CB_OP_COUNT_MAX * sizeof(UInt32), 4, &eb)))
+        {
+            TRACE_TERSE1("PAF_ASIT_initPhaseDecOpCircBuf: AS%d: Memory_calloc failed", as+zMS);
+            SW_BREAKPOINT;
+        }
+
+        // allocate debug buffer
+        if (!(pCb->cb_op_owner = Memory_calloc((IHeap_Handle)HEAP_EXTERNAL_NONCACHED_SHM, CB_OP_COUNT_MAX * sizeof(UInt8), 4, &eb)))
+        {
+            TRACE_TERSE1("PAF_ASIT_initPhaseDecOpCircBuf: AS%d: Memory_calloc failed", as+zMS);
+            SW_BREAKPOINT;
+        }
+
+        // allocate debug buffer
+        if (!(pCb->cb_afRdIdx = Memory_calloc((IHeap_Handle)HEAP_EXTERNAL_NONCACHED_SHM, CB_OP_COUNT_MAX * sizeof(UInt8), 4, &eb)))
+        {
+            TRACE_TERSE1("PAF_ASIT_initPhaseDecOpCircBuf: AS%d: Memory_calloc failed", as+zMS);
+            SW_BREAKPOINT;
+        }
+
+        // allocate debug buffer
+        if (!(pCb->cb_afWrtIdx = Memory_calloc((IHeap_Handle)HEAP_EXTERNAL_NONCACHED_SHM, CB_OP_COUNT_MAX * sizeof(UInt8), 4, &eb)))
+        {
+            TRACE_TERSE1("PAF_ASIT_initPhaseDecOpCircBuf: AS%d: Memory_calloc failed", as+zMS);
+            SW_BREAKPOINT;
+        }
+
+        // allocate debug buffer
+        if (!(pCb->cb_numAfCb = Memory_calloc((IHeap_Handle)HEAP_EXTERNAL_NONCACHED_SHM, CB_OP_COUNT_MAX * sizeof(UInt8), 4, &eb)))
+        {
+            TRACE_TERSE1("PAF_ASIT_initPhaseDecOpCircBuf: AS%d: Memory_calloc failed", as+zMS);
+            SW_BREAKPOINT;
+        }
+        #endif
+    }
+
+    for (z = DECODE1; z < DECODEN; z++)
+    {
+        //
+        // Initialize decoder output circular
+        //
+        
+        // Initialize status
+        pAstCfg->xDecOpCb[z].cbStatus = *pP->z_pDecOpCircBufStatus[z];
+        
+        // Default initialization
         errno = cbInit(pCb);
         if (errno)
         {
@@ -1574,11 +1678,81 @@ PAF_ASIT_initPhaseDecOpCircBuf(
             return errno;
         }
     }
-
+    
+    // Get ASIT ACP handle
+    acp = pAsitCfg->acp;
+    if (!acp)
+    {
+        TRACE_TERSE1("PAF_ASIT_initPhaseDecOpCircBuf: AS%d: ACP algorithm instance creation  failed", as+zMS);
+        return __LINE__;
+    }
+    
+    // Get Beta Prime offset
+    ((ALG_Handle)acp)->fxns->algControl((ALG_Handle) acp,
+        ACP_GETBETAPRIMEOFFSET, (IALG_Status *)&betaPrimeOffset);
+            
+    for (z = DECODE1; z < DECODEN; z++)
+    {
+        // ACP attach CB
+        zS = pP->streamsFromDecodes[z];
+        acp->fxns->attach(acp, ACP_SERIES_STD,
+            STD_BETA_DECOPCB + betaPrimeOffset * (as-1+zS),
+            (IALG_Status *)&pAstCfg->xDecOpCb[z].cbStatus);        
+    }
+            
     return 0;
 } //PAF_ASIT_initPhaseDecOpCircBuf
 
 
+// -----------------------------------------------------------------------------
+// ASIT Initialization Function - Output Init-Sync
+//
+//   Name:      PAF_ASIT_initPhaseOutIS
+//   Purpose:   Audio Stream Input Task Function for initialization of Output Init-Sync.
+//
+Int
+PAF_ASIT_initPhaseOutIS(
+    const PAF_ASIT_Params *pP, 
+    const PAF_ASIT_Patchs *pQ, 
+    PAF_ASIT_Config *pAsitCfg
+)
+{
+    PAF_AST_Config *pAstCfg;
+    Int as;                             /* Audio Stream Number (1, 2, etc.) */
+    Int z;                              /* decode counter */
+    PAF_AST_OutInitSyncInfo *pOutISI;
+    Error_Block    eb;
+    Int i;
+
+
+    pAstCfg = pAsitCfg->pAstCfg; // get pointer to AST common (shared) configuration
+    as = pAstCfg->as;
+    
+    /* Output Init-Sync memory */
+    if (!(pAstCfg->xOutIsi = Memory_calloc((IHeap_Handle)HEAP_EXTERNAL_NONCACHED_SHM, 
+        DECODEN * sizeof (*pAstCfg->xOutIsi), 4, &eb)))
+    {
+        TRACE_TERSE1("PAF_ASIT_initPhaseOutIS: AS%d: Memory_calloc failed", as);
+        SW_BREAKPOINT;
+        return __LINE__;
+    }
+
+    // Reset all decoder stage flags
+    for (z=DECODE1; z < DECODEN; z++)
+    {
+        // Get address of Output Init-Sync Info
+        pOutISI = &pAstCfg->xOutIsi[z];
+        for (i = 0; i < ASP_OUTIS_NUM_DEC_STAGES; i++)
+        {
+            // Reset flag value
+            pOutISI->decStageOutInitSyncInfo[i].decFlag = 0;
+        }
+    }    
+    
+    return 0;
+} // PAF_ASIT_initPhaseOutIS
+
+
 #if 0
 // -----------------------------------------------------------------------------
 // AST Processing Function - Pass-Through Processing
@@ -1867,7 +2041,7 @@ Int
 PAF_ASIT_autoProcessing(
     const PAF_ASIT_Params *pP, 
     const PAF_ASIT_Patchs *pQ, 
-    PAF_ASIT_Config *pC
+    PAF_ASIT_Config *pAsitCfg
     Int inputTypeSelect, 
     ALG_Handle pcmAlgMaster
 )
@@ -1881,7 +2055,7 @@ PAF_ASIT_autoProcessing(
     Int zMI;
     Int zMS;
     
-    pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
+    pAstCfg = pAsitCfg->pAstCfg; // get pointer to AST common (shared) configuration
     as = pAstCfg->as;
     zMD = pAstCfg->masterDec;
     zMS = pAstCfg->masterStr;    
@@ -1898,8 +2072,8 @@ PAF_ASIT_autoProcessing(
     }
     //frameLength = pP->fxns->computeFrameLength (pcmAlgMaster, FRAMELENGTH,
     //                                            pC->xDec[zMD].decodeStatus.bufferRatio);
-    frameLength = FRAMELENGTH; // FL: fix PCM frameLength for alpha release.
-
+    frameLength = FRAMELENGTH; // (***) FL: fix PCM frameLength
+    
     if (errno = SIO_ctrl(pAstCfg->xInp[zMI].hRxSio,
                          PAF_SIO_CONTROL_SET_PCMFRAMELENGTH, frameLength))
     {
@@ -1935,8 +2109,7 @@ PAF_ASIT_autoProcessing(
                 GPIOClearOutput(GPIO_PORT_0, GPIO_PIN_99);
             toggleState = ~(toggleState);
         }
-#endif        
-        
+#endif                
         TRACE_TERSE2("PAF_ASIT_autoProcessing: AS%d: SIO_reclaim returned 0x%x, ignoring", as+zMS, nbytes);
         return nbytes;
     }
@@ -2030,12 +2203,12 @@ Int
 PAF_ASIT_decodeProcessing(
     const PAF_ASIT_Params *pP, 
     const PAF_ASIT_Patchs *pQ, 
-    PAF_ASIT_Config *pC
+    PAF_ASIT_Config *pAsitCfg
     Int sourceSelect
 )
 {
     PAF_AST_Config *pAstCfg;
-    //Int as = pC->as;                    /* Audio Stream Number (1, 2, etc.) */
+    //Int as = pAsitCfg->as;              /* Audio Stream Number (1, 2, etc.) */
     Int z;                              /* decode counter */
     Int errno;                          /* error number */
     Int getVal;
@@ -2051,7 +2224,7 @@ PAF_ASIT_decodeProcessing(
     Int8 tempVar8, temp2Var8;
 #endif
     
-    pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
+    pAstCfg = pAsitCfg->pAstCfg; // get pointer to AST common (shared) configuration
     zMD = pAstCfg->masterDec;
     zMS = pAstCfg->masterStr;
         
@@ -2096,7 +2269,8 @@ PAF_ASIT_decodeProcessing(
         }
 
         // Process commands (decode)
-        if (getVal = pP->fxns->decodeCommand(pP, pQ, pC)) 
+        getVal = pP->fxns->decodeCommand(pP, pQ, pAsitCfg);
+        if (getVal) 
         {
             if (state != INIT)   // no need to restart/abort if not yet started
             {
@@ -2108,6 +2282,11 @@ PAF_ASIT_decodeProcessing(
                 else if (getVal == ASPERR_ABORT)
                 {
                     TRACE_VERBOSE0("PAF_ASIT_decodeProcessing. %d: return getVal");
+                    
+                    // PFP end -- outside of PFP for errors, EOS, or Input SIO change
+                    pfpEnd(PFP_ID_ASIT_2, PFP_FINISH_MEAS);
+                    gNumPfpAsit2--;
+                    
                     return getVal;
                 }
                 else
@@ -2126,55 +2305,15 @@ PAF_ASIT_decodeProcessing(
         {
             case INIT: // initial state
                 gAsipInitCnt++;
-                Log_info0("TaskAsip: state=INIT");
+                Log_info0("TaskAsip: state=INIT");               
 
-#if 0 // Not necessary since decoder status is in uncached memory
-                // status for shared beta units can change (e.g. at-boot or alpha)
-                
-                // write back Status structures for shared Beta Units
-                //size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_DECODE]->size;
-                //Cache_wb((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_DECODE]), size, Cache_Type_ALLD, 0);
-                size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM]->size;
-                Cache_wb((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM]), size, Cache_Type_ALLD, 0);
-                size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP]->size;
-                Cache_wb((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP]), size, Cache_Type_ALLD, 0);
-                size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_THD]->size;
-                Cache_wb((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_THD]), size, Cache_Type_ALLD, 0);
-                Cache_wait();
-#endif
-#if 0 // Not necessary since decoder status is in uncached memory
-                ////size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_DECODE]->size;
-                ////Cache_wbInv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_DECODE]), size, Cache_Type_ALLD, 0);
-                //size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM]->size;
-                //Cache_wbInv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM]), size, Cache_Type_ALLD, 0);
-                //size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP]->size;
-                //Cache_wbInv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP]), size, Cache_Type_ALLD, 0);
-                //Cache_wait();                
-#endif                
-                
-                if (errno = pP->fxns->decodeInit(pP, pQ, pC, sourceSelect))
+                errno = pP->fxns->decodeInit(pP, pQ, pAsitCfg, sourceSelect);
+                if (errno)
                 {
                     TRACE_VERBOSE1("PAF_ASIT_decodeProcessing: INIT, errno 0x%x.  break after decodeInit", errno);
                     break;
                 }
-                
-                //
-                // Not necessary since decoder status is in uncached memory
-                //
-               
-#if 0 // Not necessary since decoder status is in uncached memory
-                // invalidate Status structures for shared Beta Units
-                //size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_DECODE]->size;
-                //Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_DECODE]), size, Cache_Type_ALLD, 0);
-                size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM]->size;
-                Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM]), size, Cache_Type_ALLD, 0);
-                size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP]->size;
-                Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP]), size, Cache_Type_ALLD, 0);
-                size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_THD]->size;
-                Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_THD]), size, Cache_Type_ALLD, 0);
-                Cache_wait();
-#endif
-                
+                               
                 frame = 0;
                 block = 0;
 
@@ -2186,35 +2325,15 @@ PAF_ASIT_decodeProcessing(
                 gAsipInfo1Cnt++;
                 Log_info0("TaskAsip: state=INFO1");
                 
-#if 0
-                //// (***) FL: revisit
-                //// write back Inp configuration
-                //Cache_wb(&gPAF_AST_config.xInp[0], INPUTN*sizeof(PAF_AST_InpBuf), Cache_Type_ALLD, 0);
-                //// write back input data
-                //pIpBufConfig = &gPAF_AST_config.xInp[0].inpBufConfig;
-                //size = pIpBufConfig->frameLength * pIpBufConfig->sizeofElement;
-                //Cache_wb(pIpBufConfig->pntr.pLgInt, size, Cache_Type_ALLD, 0);
-                //// write back Dec configuration
-                //Cache_wb(&gPAF_AST_config.xDec[0], DECODEN*sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
-                //Cache_wait();            
-#endif                
-
                 // Establish primary timing
-                if (errno = pP->fxns->decodeInfo(pP, pQ, pC, frame, block))
+                errno = pP->fxns->decodeInfo(pP, pQ, pAsitCfg, frame, block);
+                if (errno)
                 {
-                    gProbe1Err++;
+                    gAsipInfo1_PrimaryErrCnt++;
                     TRACE_TERSE1("INFO1: errno 0x%x after decodeInfo, primary timing", errno);
                     break;
                 }
                 
-#if 0
-                //// (***) FL: revisit
-                //// invalidate Dec configuration
-                //Cache_inv(&gPAF_AST_config.xDec[0], DECODEN*sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
-                //Cache_wait();                            
-#endif                
-
-
 #ifdef NON_CACHE_STATUS
                 statusOp_read(&tempVar8,
                               &(pAstCfg->xDec[zMD].decodeStatus.sourceDecode),
@@ -2258,6 +2377,11 @@ PAF_ASIT_decodeProcessing(
                             {
                                 gProbe2Err++;
                                 TRACE_TERSE0("PAF_ASIT_decodeProcessing. %d: INFO1, return (ASPERR_ISSUE)");
+                                
+                                // PFP end -- outside of PFP for errors, EOS, or Input SIO change
+                                pfpEnd(PFP_ID_ASIT_2, PFP_FINISH_MEAS);
+                                gNumPfpAsit2--;
+                                
                                 return (ASPERR_ISSUE);
                             }
                         }
@@ -2271,9 +2395,11 @@ PAF_ASIT_decodeProcessing(
                 TRACE_VERBOSE1("PAF_ASIT_decodeProcessing: INFO1: frame %d, major access unit found", frame);
 
                 // Establish secondary timing
-                if (errno = pP->fxns->decodeInfo1(pP, pQ, pC, frame, block))
+                errno = pP->fxns->decodeInfo1(pP, pQ, pAsitCfg, frame, block);
+                if (errno)
                 {
                     TRACE_VERBOSE1("PAF_ASIT_decodeProcessing: INFO1, errno 0x%x.  break after decodeInfo1", errno);
+                    gAsipInfo1_ErrCnt++;
                     break;
                 }
 
@@ -2285,41 +2411,30 @@ PAF_ASIT_decodeProcessing(
                 gAsipInfo2Cnt++;
                 Log_info0("TaskAsip: state=INFO2");
 
-#if 0            
-                //// (***) FL: revisit
-                //// write back Inp configuration
-                //Cache_wb(&gPAF_AST_config.xInp[0], INPUTN*sizeof(PAF_AST_InpBuf), Cache_Type_ALLD, 0);
-                //// write back input data
-                //pIpBufConfig = &gPAF_AST_config.xInp[0].inpBufConfig;
-                //size = pIpBufConfig->frameLength * pIpBufConfig->sizeofElement;
-                //Cache_wb(pIpBufConfig->pntr.pLgInt, size, Cache_Type_ALLD, 0);
-                //// write back Dec configuration
-                //Cache_wb(&gPAF_AST_config.xDec[0], DECODEN*sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
-                //Cache_wait();
-#endif                
-
                 // Establish primary timing
-                if (errno = pP->fxns->decodeInfo(pP, pQ, pC, frame, block))
+                errno = pP->fxns->decodeInfo(pP, pQ, pAsitCfg, frame, block);
+                if (errno)
                 {
                     TRACE_TERSE1("PAF_ASIT_decodeProcessing: INFO2 break on decodeInfo. errno 0x%x", errno);
                     gAsipInfo2_PrimaryErrCnt++;
                     break;
                 }
-
-#if 0            
-                //// (***) FL: revisit
-                //// invalidate Dec configuration
-                //Cache_inv(&gPAF_AST_config.xDec[0], DECODEN*sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
-                //Cache_wait();                                            
-#endif                
-                
-                if (errno = pP->fxns->decodeInfo2(pP, pQ, pC, frame, block))
+                                
+                // Measure cycles in decode processing loop.
+                // Only measures cycles spent in loop.
+                pfpEnd(PFP_ID_ASIT_2, PFP_FINISH_MEAS);         // PFP end
+                gNumPfpAsit2--;
+                pfpBegin(PFP_ID_ASIT_2, pAsitCfg->taskHandle);  // PFP begin
+                gNumPfpAsit2++;
+
+                errno = pP->fxns->decodeInfo2(pP, pQ, pAsitCfg, frame, block);
+                if (errno)
                 {
                     TRACE_TERSE1("PAF_ASIT_decodeProcessing. %d: INFO2 break on decodeInfo2. errno 0x%x", errno);
                     gAsipInfo2_ErrCnt++;
                     break;
                 }
-
+               
                 TRACE_VERBOSE0("PAF_ASIT_decodeProcessing: state: INFO2->DECODE");
                 state = DECODE;
                 continue;
@@ -2328,26 +2443,13 @@ PAF_ASIT_decodeProcessing(
                 gAsipDecodeCnt++;
                 Log_info0("TaskAsip: state=DECODE");
 
-#if 0
-                //// (***) FL: revisit
-                //// write back Dec configuration
-                //Cache_wb(&gPAF_AST_config.xDec[0], DECODEN*sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
-                //Cache_wait();                        
-#endif
-            
-                if (errno = pP->fxns->decodeDecode(pP, pQ, pC, sourceSelect, frame, block))
+                errno = pP->fxns->decodeDecode(pP, pQ, pAsitCfg, sourceSelect, frame, block);
+                if (errno)
                 {
-                       gAsipDecodeErrCnt++;
-                       TRACE_TERSE1("PAF_ASIT_decodeProcessing: state: DECODE.  decodeDecode err 0x%04x", errno);
+                    gAsipDecodeErrCnt++;
+                    TRACE_TERSE1("PAF_ASIT_decodeProcessing: state: DECODE.  decodeDecode err 0x%04x", errno);
                     break;
                 }
-      
-#if 0      
-                //// (***) FL: revisit
-                //// invalidate Dec configuration
-                //Cache_inv(&gPAF_AST_config.xDec[0], DECODEN*sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
-                //Cache_wait();                                            
-#endif                
                 
                 TRACE_VERBOSE0("PAF_ASIT_decodeProcessing: state: DECODE->FINAL");
                 state = FINAL;
@@ -2359,7 +2461,7 @@ PAF_ASIT_decodeProcessing(
 
                 // Check for final frame, and if indicated:
                 // - Exit state machine to "complete" processing.
-                if (pP->fxns->decodeFinalTest(pP, pQ, pC, frame, block)) 
+                if (pP->fxns->decodeFinalTest(pP, pQ, pAsitCfg, frame, block)) 
                 {
                     break;
                 }
@@ -2393,15 +2495,26 @@ PAF_ASIT_decodeProcessing(
         }  // End of switch (state).
 
         TRACE_VERBOSE0("PAF_ASIT_decodeProcessing: Calling decode complete");
-        if (pP->fxns->decodeComplete(pP, pQ, pC, alg, frame, block))
+        if (pP->fxns->decodeComplete(pP, pQ, pAsitCfg, alg, frame, block))
         {
             /* ignored? */;
         }
-
+        
         TRACE_TIME((&TIME_MOD, "as1-f2: ... + %d = ?? (final? %d)", dtime(), state == FINAL));
 
-        return errno;
+        // PFP end -- outside of PFP for errors, EOS, or Input SIO change
+        //pfpEnd(PFP_ID_ASIT_2, PFP_FINISH_MEAS);
+        //gNumPfpAsit2--;
+        
+        //return errno;
+        break;
     }  // End of for (;;) to Receive, process, and transmit the data.
+    
+    // PFP end -- outside of PFP for errors, EOS, or Input SIO change
+    pfpEnd(PFP_ID_ASIT_2, PFP_FINISH_MEAS);
+    gNumPfpAsit2--;
+    
+    return errno;
 } //PAF_ASIT_decodeProcessing
 
 // -----------------------------------------------------------------------------
@@ -2421,7 +2534,7 @@ Int
 PAF_ASIT_decodeCommand(
     const PAF_ASIT_Params *pP, 
     const PAF_ASIT_Patchs *pQ, 
-    PAF_ASIT_Config *pC
+    PAF_ASIT_Config *pAsitCfg
 )
 {
     PAF_AST_Config *pAstCfg;
@@ -2432,7 +2545,7 @@ PAF_ASIT_decodeCommand(
     Int8 tempVar8;
 #endif
 
-    pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
+    pAstCfg = pAsitCfg->pAstCfg; // get pointer to AST common (shared) configuration
     as = pAstCfg->as;
 
     for (z=DECODE1; z < DECODEN; z++) 
@@ -2516,12 +2629,12 @@ Int
 PAF_ASIT_decodeInit(
     const PAF_ASIT_Params *pP, 
     const PAF_ASIT_Patchs *pQ, 
-    PAF_ASIT_Config *pC
+    PAF_ASIT_Config *pAsitCfg
     Int sourceSelect
 )
 {
     PAF_AST_Config *pAstCfg;
-    PAF_AST_DecOpCircBufCtl *pCbCtl;    /* Decoder output circular buffer control */
+    //PAF_AST_DecOpCircBufCtl *pCbCtl;    /* Decoder output circular buffer control */
     Int as;                             /* Audio Stream Number (1, 2, etc.) */
     Int z;                              /* decode/encode counter */
     Int errno;                          /* error number */
@@ -2530,19 +2643,19 @@ PAF_ASIT_decodeInit(
     Int zMI;
     ASP_Msg* pAspMsg;                   /* Messaging */
     Int argIdx;
-    Int decErrno;
     Int status;
 #ifdef NON_CACHE_STATUS
     Int8 tempVar8;
+    Int tempVar;
 #endif
     
-    pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
+    pAstCfg = pAsitCfg->pAstCfg; // get pointer to AST common (shared) configuration
     as = pAstCfg->as;
     zMD = pAstCfg->masterDec;
     zMI = pP->zone.master;
     (void)as;  // clear compiler warning in case not used with tracing disabled
     
-    pCbCtl = &pC->pAspmCfg->decOpCircBufCtl; // get pointer to circular buffer control
+    //pCbCtl = &pAsitCfg->pAspmCfg->decOpCircBufCtl; // get pointer to circular buffer control
 
 #ifdef NON_CACHE_STATUS
     // reset frameCount
@@ -2554,10 +2667,10 @@ PAF_ASIT_decodeInit(
                       GATEMP_INDEX_DEC);
         if (tempVar8)
         {
-            tempVar8 = 0;
+            tempVar = 0;
             statusOp_write(&(pAstCfg->xDec[z].decodeStatus.frameCount),
-                          &tempVar8,
-                          sizeof(tempVar8),
+                          &tempVar,
+                          sizeof(tempVar),
                           GATEMP_INDEX_DEC);
         }
     }
@@ -2690,14 +2803,13 @@ PAF_ASIT_decodeInit(
                 TRACE_MSG1("decErrno=%d", pAspMsg->buf[0]);
 
                 argIdx = 0; // get decErrno
-                decErrno = *(Int32 *)&pAspMsg->buf[argIdx];
-                if (decErrno != 0)
-                {
-                    return decErrno;
-                }
+                errno = *(Int32 *)&pAspMsg->buf[argIdx];
             }
             else
             {
+                //
+                // Invalid message received
+                //
                 TRACE_TERSE3("ERROR: Rx ASP message: procId=%d, cmd=%d, messageId=0x%04x", pAspMsg->procId, pAspMsg->cmd, pAspMsg->messageId);
                 SW_BREAKPOINT; // temporary
                 return -1; // temporary
@@ -2708,7 +2820,7 @@ PAF_ASIT_decodeInit(
             {
                 SW_BREAKPOINT;
             }
-
+            
             // (***) FL: revisit
             // invalidate Dec configuration
             Cache_inv(&pAstCfg->xDec[z], sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
@@ -2720,6 +2832,10 @@ PAF_ASIT_decodeInit(
                                               &pC->xDec[z].decodeControl, &pC->xDec[z].decodeStatus)))
                 return errno;
 #endif
+            if (errno != 0)
+            {
+                return errno;
+            }
             
 #ifdef NON_CACHE_STATUS
             gear = 0;  // due to size difference
@@ -2742,47 +2858,30 @@ PAF_ASIT_decodeInit(
                 FRAMELENGTH,
                 pC->xDec[z].decodeStatus.bufferRatio);
 #endif
-#if 0 // (***) FL: revisit. Bypass computeFrameLength().
+#if 0 // (***) FL: revisit. Bypass decoder computeFrameLength() function.
             frameLength = pP->fxns->computeFrameLength(z, 
                 FRAMELENGTH, 
                 pC->xDec[z].decodeStatus.bufferRatio);
 #else
-            if (sourceSelect == PAF_SOURCE_PCM)
-            {
-                frameLength = 256;
-            }
-            else if ((sourceSelect == PAF_SOURCE_DDP) || (sourceSelect == PAF_SOURCE_AC3))
-            {
-                frameLength = 1536;
-            }
-            else if (sourceSelect == PAF_SOURCE_THD)
-            {
-                frameLength = 1536; //QIN FIX ME
-            }
-            else
-            {
-                frameLength = 256;
-            }
+            // Compute decoder frame length based on source selection
+            frameLength = getFrameLengthSourceSel(pP, sourceSelect);
 #endif    
             
             pAstCfg->xDec[z].decodeControl.frameLength = frameLength;
             pAstCfg->xDec[z].decodeInStruct.sampleCount = frameLength;
             pAstCfg->xDec[z].decodeControl.sampleRate = PAF_SAMPLERATE_UNKNOWN;
-            
-            // (***) FL: revisit. Count samples for DDP.
-            // Add framework frame length and running sample count to decoder control.
-            //pC->xDec[z].decodeControl.pafFrameLength = FRAMELENGTH;
-            //pC->xDec[z].decodeControl.rdSampleCount = 0;
-
+          
+#if 0 // FL: Moved to ARM:ASDT:INFO
             // Initialize decoder output circular buffer for selected source
             errno = cbInitSourceSel(pCbCtl, z, sourceSelect, frameLength, FRAMELENGTH, 0);
             if (errno)
             {
-                SW_BREAKPOINT; // FL: debug
+                SW_BREAKPOINT; // debug
                 return errno;
             }
-            // FL: debug
+            // debug
             cbLog(pCbCtl, z, 1, "PAF_ASIT_decodeInit:cbInitSourceSel");
+#endif
             
             if (z != zMD) 
             {
@@ -2852,7 +2951,7 @@ Int
 PAF_ASIT_decodeInfo(
     const PAF_ASIT_Params *pP, 
     const PAF_ASIT_Patchs *pQ, 
-    PAF_ASIT_Config *pC
+    PAF_ASIT_Config *pAsitCfg
     Int frame, 
     Int block
 )
@@ -2878,7 +2977,7 @@ PAF_ASIT_decodeInfo(
     //Int size;
     //PAF_InpBufConfig *pIpBufConfig;
 
-    pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
+    pAstCfg = pAsitCfg->pAstCfg; // get pointer to AST common (shared) configuration
     as = pAstCfg->as;
     zMD = pAstCfg->masterDec;
     zMS = pAstCfg->masterStr;
@@ -2897,7 +2996,17 @@ PAF_ASIT_decodeInfo(
                 break;
             }
         }
-
+#ifdef PROFILER
+            // modify for different sampling rate
+            if (pAstCfg->xInp[z].inpBufStatus.sampleRateStatus == PAF_SAMPLERATE_96000HZ)
+            {
+                start_profiling = 1;
+            }
+            else
+            {
+                start_profiling = 0;
+            }
+#endif
         if (pAstCfg->xInp[z].hRxSio) 
         {
             //determine associated decoder
@@ -2953,11 +3062,12 @@ PAF_ASIT_decodeInfo(
             return ASPERR_RECLAIM;
         }
         
-        // FL: debug, capture input buffer
-        capIb(pAstCfg->xInp[zMI].pInpBuf);
-        gcapIb_cnt++;
+        //// FL: debug, capture input buffer
+        //capIb(pAstCfg->xInp[zMI].pInpBuf);
+        //gCapIb_cnt++;
         
-#if 1 // (***) FL: shows timing of Input Rx SIO reclaim after decoding has started (autodet complete)
+#if 0 // (***) FL: shows timing of Input Rx SIO reclaim after decoding has started (autodet complete)
+        // (***) debug // B5
         {
             static Uint8 toggleState = 0;
             if (toggleState == 0)
@@ -2977,7 +3087,7 @@ PAF_ASIT_decodeInfo(
         //System_printf("System time in TaskAsipFxn Rx audio = %lu\n", (ULong)curTime);        
         //Log_info1("System time in TaskAsipFxn Rx audio = %u", curTime);
         //Log_info1("decodeInfo():Rx SIO reclaim(), system time = %u", curTime);
-    } //pC->xInp[zMI].hRxSio
+    } //pAstCfg->xInp[zMI].hRxSio
 
     // Decode info
     for (z=DECODE1; z < DECODEN; z++) 
@@ -3009,10 +3119,6 @@ PAF_ASIT_decodeInfo(
             // (***) FL: revisit
             // write back Inp configuration
             Cache_wb(&pAstCfg->xInp[zI], sizeof(PAF_AST_InpBuf), Cache_Type_ALLD, 0);
-            // write back input data //  (***) GJ: don't need this for 1xI2S HDMI/SPDIF. Maybe need this for 4xI2S HDMI.
-            //pIpBufConfig = &gPAF_AST_config.xInp[zI].inpBufConfig;
-            //size = pIpBufConfig->frameLength * pIpBufConfig->sizeofElement;
-            //Cache_wb((Ptr)pIpBufConfig->pntr.pSmInt, size, Cache_Type_ALLD, 0);
             // write back Dec configuration
             Cache_wb(&pAstCfg->xDec[z], sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
             Cache_wait();
@@ -3048,15 +3154,26 @@ PAF_ASIT_decodeInfo(
                 SW_BREAKPOINT;
                 return -1; // temporary
             }
-            if ((pAspMsg->procId != hAspMsgMaster->slaveProcId) || 
-                (pAspMsg->cmd != ASP_MASTER_DEC_INFO_DONE) || 
-                (pAspMsg->messageId != (hAspMsgMaster->messageId | ((UInt32)1<<31))))
+            if ((pAspMsg->procId == hAspMsgMaster->slaveProcId) &&
+                (pAspMsg->cmd == ASP_MASTER_DEC_INFO_DONE) && 
+                (pAspMsg->messageId == (hAspMsgMaster->messageId | ((UInt32)1<<31))))
+            {
+                hAspMsgMaster->messageId = (hAspMsgMaster->messageId + 1) & ~(1<<31);
+                TRACE_TERSE3("Rx ASP message: procId=%d, cmd=%d, messageId=0x%04x", pAspMsg->procId, pAspMsg->cmd, pAspMsg->messageId);
+                TRACE_MSG1("decErrno=%d", pAspMsg->buf[0]);
+                
+                argIdx = 0; // get decErrno
+                errno = *(Int32 *)&pAspMsg->buf[argIdx];
+            }
+            else
             {
+                //
+                // Invalid message received
+                //
                 TRACE_TERSE3("ERROR: Rx ASP message: procId=%d, cmd=%d, messageId=0x%04x", pAspMsg->procId, pAspMsg->cmd, pAspMsg->messageId);
                 SW_BREAKPOINT; // temporary
-            }           
-            hAspMsgMaster->messageId = (hAspMsgMaster->messageId + 1) & ~(1<<31);
-            TRACE_MSG3("Rx ASP message: procId=%d, cmd=%d, messageId=0x%04x", pAspMsg->procId, pAspMsg->cmd, pAspMsg->messageId);
+                return -1; // temporary
+            }
             // free the message
             status = MessageQ_free((MessageQ_Msg)pAspMsg); /* free the message */
             if (status != MessageQ_S_SUCCESS)
@@ -3081,6 +3198,7 @@ PAF_ASIT_decodeInfo(
                 TRACE_TERSE1("return error errno 0x%x.", errno);
                 return errno;
             }
+
 #ifdef NON_CACHE_STATUS
             statusOp_read(&tempVar,
                           &(pAstCfg->xDec[z].decodeStatus.frameCount),
@@ -3230,7 +3348,7 @@ Int
 PAF_ASIT_decodeInfo1(
     const PAF_ASIT_Params *pP, 
     const PAF_ASIT_Patchs *pQ, 
-    PAF_ASIT_Config *pC
+    PAF_ASIT_Config *pAsitCfg
     Int frame, 
     Int block
 )
@@ -3254,7 +3372,7 @@ Int
 PAF_ASIT_decodeInfo2(
     const PAF_ASIT_Params *pP, 
     const PAF_ASIT_Patchs *pQ, 
-    PAF_ASIT_Config *pC
+    PAF_ASIT_Config *pAsitCfg
     Int frame, 
     Int block
 )
@@ -3262,6 +3380,7 @@ PAF_ASIT_decodeInfo2(
     return 0;
 } //PAF_ASIT_decodeInfo2
 
+#if 0
 // -----------------------------------------------------------------------------
 // AST Decoding Function - Continuation Processing
 //
@@ -3281,7 +3400,7 @@ Int
 PAF_AST_decodeCont(
     const PAF_ASIT_Params *pP, 
     const PAF_ASIT_Patchs *pQ, 
-    PAF_ASIT_Config *pC
+    PAF_ASIT_Config *pAsitCfg
     ALG_Handle decAlg[], 
     Int frame, 
     Int block
@@ -3297,7 +3416,7 @@ PAF_AST_decodeCont(
 #endif
 
     
-    pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
+    pAstCfg = pAsitCfg->pAstCfg; // get pointer to AST common (shared) configuration
     as = pAstCfg->as;
     zMD = pAstCfg->masterDec;
     (void)as;  // clear compiler warning in case not used with tracing disabled
@@ -3331,6 +3450,7 @@ PAF_AST_decodeCont(
 
     return 0;
 } //PAF_AST_decodeCont
+#endif
 
 // -----------------------------------------------------------------------------
 // ASIT Decoding Function - Decode Processing
@@ -3349,7 +3469,7 @@ Int
 PAF_ASIT_decodeDecode(
     const PAF_ASIT_Params *pP, 
     const PAF_ASIT_Patchs *pQ, 
-    PAF_ASIT_Config *pC
+    PAF_ASIT_Config *pAsitCfg
     Int sourceSelect, 
     Int frame, 
     Int block
@@ -3366,7 +3486,7 @@ PAF_ASIT_decodeDecode(
     Int cbErrno;
     Int frameLength;    
 
-    pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
+    pAstCfg = pAsitCfg->pAstCfg; // get pointer to AST common (shared) configuration
     as = pAstCfg->as;
     (void)as; // clear compiler warning in case not used with tracing disabled
 
@@ -3441,19 +3561,22 @@ PAF_ASIT_decodeDecode(
                 hAspMsgMaster->messageId = (hAspMsgMaster->messageId + 1) & ~(1<<31);
                 TRACE_MSG3("Rx ASP message: procId=%d, cmd=%d, messageId=0x%04x", pAspMsg->procId, pAspMsg->cmd, pAspMsg->messageId);
                 
-                argIdx = 0;
+                argIdx = 0; // get decErrno
                 errno = *(Int32 *)&pAspMsg->buf[argIdx];
-                argIdx += sizeof(Int32);
+                argIdx += sizeof(Int32); // get cbErrno
                 cbErrno = *(Int32 *)&pAspMsg->buf[argIdx];
                 if (cbErrno != 0)
                 {
-                    gCbErrnoCnt++;
+                    gCbWrtAfErrCnt++;
                     TRACE_TERSE1("CB write error=%d", cbErrno);
                     //SW_BREAKPOINT; // temporary
                 }
             }
             else
             {
+                //
+                // Invalid message received
+                //
                 TRACE_TERSE3("ERROR: Rx ASP message: procId=%d, cmd=%d, messageId=0x%04x", pAspMsg->procId, pAspMsg->cmd, pAspMsg->messageId);
                 SW_BREAKPOINT; // temporary
             }
@@ -3489,28 +3612,28 @@ PAF_ASIT_decodeDecode(
                 FRAMELENGTH, 
                 pC->xDec[z].decodeStatus.bufferRatio);
 #endif
-#if 0 // (***) FL: revisit. Bypass computeFrameLength().
+#if 0 // (***) FL: revisit. Bypass decoder computeFrameLength() function.
             frameLength = pP->fxns->computeFrameLength(z, 
                 FRAMELENGTH, 
                 pC->xDec[z].decodeStatus.bufferRatio);
 #else
-            if (sourceSelect == PAF_SOURCE_PCM)
-            {
-                frameLength = 256;
-            }
-            else if ((sourceSelect == PAF_SOURCE_DDP) || (sourceSelect == PAF_SOURCE_AC3))
-            {
-                frameLength = 1536;
-            }
-            else if (sourceSelect == PAF_SOURCE_THD)
-            {
-                frameLength = 1536; //QIN FIX ME
-            }
-            else
-            {
-                frameLength = 256;
-            }
-#endif                    
+            // Compute decoder frame length based on source selection
+            frameLength = getFrameLengthSourceSel(pP, sourceSelect);
+#endif
+
+
+//#ifdef PROFILER
+//            // modify for different decoders
+//            if (sourceSelect == PAF_SOURCE_THD)
+//            {
+//                start_profiling = 1;
+//            }
+//            else
+//            {
+//                start_profiling = 0;
+//            }
+//#endif
+
 
 // ............................................................................
 
@@ -3585,7 +3708,7 @@ Int
 PAF_ASIT_decodeFinalTest(
     const PAF_ASIT_Params *pP, 
     const PAF_ASIT_Patchs *pQ, 
-    PAF_ASIT_Config *pC
+    PAF_ASIT_Config *pAsitCfg
     Int frame, 
     Int block
 )
@@ -3598,7 +3721,7 @@ PAF_ASIT_decodeFinalTest(
     Int8 tempVar8, temp2Var8;
 #endif
 
-    pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
+    pAstCfg = pAsitCfg->pAstCfg; // get pointer to AST common (shared) configuration
     zMD = pAstCfg->masterDec;
 
 #ifdef NON_CACHE_STATUS
@@ -3688,7 +3811,7 @@ Int
 PAF_ASIT_decodeComplete(
     const PAF_ASIT_Params *pP, 
     const PAF_ASIT_Patchs *pQ, 
-    PAF_ASIT_Config *pC
+    PAF_ASIT_Config *pAsitCfg
     ALG_Handle decAlg[], 
     Int frame, 
     Int block
@@ -3706,7 +3829,7 @@ PAF_ASIT_decodeComplete(
 #endif
 
     
-    pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
+    pAstCfg = pAsitCfg->pAstCfg; // get pointer to AST common (shared) configuration
     as = pAstCfg->as;
     (void)as;  // clear compiler warning in case not used with tracing disabled
 
@@ -3811,7 +3934,7 @@ Int
 PAF_ASIT_selectDevices(
     const PAF_ASIT_Params *pP, 
     const PAF_ASIT_Patchs *pQ, 
-    PAF_ASIT_Config *pC
+    PAF_ASIT_Config *pAsitCfg
 )
 {
     PAF_AST_Config *pAstCfg;
@@ -3822,7 +3945,7 @@ PAF_ASIT_selectDevices(
     Int device;
     Int zMD;
 
-    pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
+    pAstCfg = pAsitCfg->pAstCfg; // get pointer to AST common (shared) configuration
     as = pAstCfg->as;
     zMD = pAstCfg->masterDec;
     (void)as;  // clear compiler warning in case not used with tracing disabled
@@ -3889,7 +4012,7 @@ Int
 PAF_ASIT_sourceDecode(
     const PAF_ASIT_Params *pP, 
     const PAF_ASIT_Patchs *pQ, 
-    PAF_ASIT_Config *pC
+    PAF_ASIT_Config *pAsitCfg
     Int x
 )
 {
@@ -3899,7 +4022,7 @@ PAF_ASIT_sourceDecode(
     Int8 tempVar8;
 #endif
 
-    pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
+    pAstCfg = pAsitCfg->pAstCfg; // get pointer to AST common (shared) configuration
 
     for (z=DECODE1; z < DECODEN; z++)
     {
@@ -4016,3 +4139,31 @@ void as_traceChannels(PAF_AST_Config *pC, int z)
     }
 }
 #endif
+
+// Compute decoder frame length based on selected source
+static Int getFrameLengthSourceSel(
+    const PAF_ASIT_Params *pP, 
+    Int8 sourceSelect
+)
+{
+    Int frameLength;
+    
+    switch(sourceSelect)
+    {
+        case PAF_SOURCE_PCM:
+            frameLength = FRAMELENGTH;
+            break;
+        case PAF_SOURCE_AC3: 
+        case PAF_SOURCE_DDP: 
+            frameLength = ASIP_FRAMELEN_SS_DDP_AC3;
+            break;
+        case PAF_SOURCE_THD:
+            frameLength = ASIP_FRAMELEN_SS_THD;
+            break;
+        default:
+            frameLength = ASIP_FRAMELEN_SS_DEFAULT;
+            break;
+    }
+    
+    return frameLength;
+}