]> 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-432:Add code to check for null pointer in shared Beta table
[processor-sdk/performance-audio-sr.git] / pasdk / test_dsp / framework / audioStreamInpProc.c
index ab3bf34466c3998dd6e2c5aa71bc3731ce044e2c..e39d3b90ff2755366a8c8e46c6e3625e5d5e1886 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,19 +61,21 @@ 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"
 
-// FL: porting
-#include "fwkSim.h"
-//#include "fwkPort.h"
-// FL: debug
-#include "dbgCapAf.h"
+#include "pfp/pfp.h"
+#include "pfp_app.h"        /* contains all PFP ID's */
+Int32 gNumPfpAsit1=0; // debug
+Int32 gNumPfpAsit2=0;
 
-#include "statusOp_common.h"
 
-#define CACHE_COHERENCE
+
+// FL: debug
+#include "dbgCapAf.h"
 
 
 // -----------------------------------------------------------------------------
@@ -87,7 +89,7 @@ All rights reserved.
 #define TR_MOD  trace
 
 // Allow a developer to selectively enable tracing.
-#define CURRENT_TRACE_MASK      0x21
+#define CURRENT_TRACE_MASK      0x27
 
 #define TRACE_MASK_TERSE        0x01   // only flag errors and show init
 #define TRACE_MASK_GENERAL      0x02   // half dozen lines per frame
@@ -245,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
 //
@@ -288,32 +306,70 @@ 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 )        
+
+#define ASIP_FRAMELEN_SS_DTS        ( 512 )         
+
+// 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
 };
 
 // Global debug counters */
-UInt32 gTaskAsipCnt=0; // debug
-UInt32 gAsipInitCnt     =0;
-UInt32 gAsipInfo1Cnt    =0;
-UInt32 gAsipInfo2Cnt    =0;
-UInt32 gAsipDecodeCnt   =0;
-UInt32 gAsipFinalCnt    =0;
-UInt32 gAsipQuitCnt     =0;
-#include "dbgDib.h"
+UInt32 gAsipRxSioReclaimCnt     =0;
+UInt32 gAsipInitCnt             =0;
+UInt32 gAsipInfo1Cnt            =0;
+UInt32 gAsipInfo2Cnt            =0;
+UInt32 gAsipDecodeCnt           =0;
+UInt32 gAsipDecodeErrCnt        =0;
+UInt32 gAsipFinalCnt            =0;
+UInt32 gAsipQuitCnt             =0;
+UInt32 gAsipInfo1_PrimaryErrCnt =0;
+UInt32 gAsipInfo1_ErrCnt        =0;
+UInt32 gAsipInfo2_PrimaryErrCnt =0;
+UInt32 gAsipInfo2_ErrCnt        =0;
+// debug
+UInt32 gCapIbReset_cnt          =0;
+UInt32 gCapIb_cnt               =0;
+UInt32 gCbWrtAfErrCnt           =0; // decoder output circular buffer write error count (returned from ARM to DSP)
+                                   
+// For writeDECCommandRestart
+volatile UInt32 gCommandOutputTask_SYNC   =0;
+volatile UInt32 gCommandOutputTask_ACK    =0;
+
+#include "dbgDib.h" // debug
 
 extern struct {
     Int size;
     IALG_Status *pStatus[512];
 } IACP_STD_BETA_TABLE;
 
+// FL: debug
+#include "evmc66x_gpio_dbg.h"
 
 /*
  *  ======== taskAsipFxn ========
@@ -325,32 +381,25 @@ 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 */
     Int errno;                      /* error number */
     Int zMD, zMI, zMS, zX;
     Int loopCount = 0;  // used to stop trace to see startup behavior.        
-    UInt32 curTime;
     Int size;
     // Messaging
     ASP_Msg *pAspMsg;              
     Int status;
-#ifdef CACHE_COHERENCE
     Int8 tempVar8;
-#endif
+    char asipMsgBuf[ASP_MSG_BUF_LEN];
 
     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) 
     {
@@ -367,10 +416,11 @@ 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;
@@ -414,7 +464,7 @@ Void taskAsipFxn(
     //      - AlgKey: Dec/Enc chain to Array Initialization
     //      - Device: I/O Device Initialization
     //      - DecOpCircBuf: Decoder Output Circular Buffer
-    //      - Unused: (available)
+    //      - OutIS: Output Init-Sync
     //
     LINNO_RPRT(TaskAsip, -2);
     for (i=0; i < lengthof(pP->fxns->initPhase); i++)
@@ -422,7 +472,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;
@@ -441,14 +492,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
@@ -501,32 +552,120 @@ Void taskAsipFxn(
     Cache_inv((Ptr)(&IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM2]), sizeof(IALG_Status *), Cache_Type_ALLD, 0);
     Cache_inv((Ptr)(&IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP]), sizeof(IALG_Status *), Cache_Type_ALLD, 0);
     Cache_inv((Ptr)(&IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP2]), sizeof(IALG_Status *), Cache_Type_ALLD, 0);
+    Cache_inv((Ptr)(&IACP_STD_BETA_TABLE.pStatus[STD_BETA_THD]), sizeof(IALG_Status *), Cache_Type_ALLD, 0);
+    Cache_inv((Ptr)(&IACP_STD_BETA_TABLE.pStatus[STD_BETA_THD2]), sizeof(IALG_Status *), Cache_Type_ALLD, 0);
+    Cache_inv((Ptr)(&IACP_STD_BETA_TABLE.pStatus[STD_BETA_DTSUHDA]), sizeof(IALG_Status *), Cache_Type_ALLD, 0);
+    Cache_inv((Ptr)(&IACP_STD_BETA_TABLE.pStatus[STD_BETA_AAC]), sizeof(IALG_Status *), Cache_Type_ALLD, 0);
+    Cache_inv((Ptr)(&IACP_STD_BETA_TABLE.pStatus[STD_BETA_AAC2]), sizeof(IALG_Status *), Cache_Type_ALLD, 0);
     Cache_wait();
-    if (!IACP_STD_BETA_TABLE.pStatus[STD_BETA_DECODE]) Log_info0("ERROR: beta unit for Dec==NULL");
-    if (!IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM]) Log_info0("ERROR: beta unit for Dec==NULL");
-    if (!IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM2]) Log_info0("ERROR: beta unit for Dec==NULL");
-    if (!IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP]) Log_info0("ERROR: beta unit for Dec==NULL");
-    if (!IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP2]) Log_info0("ERROR: beta unit for Dec==NULL");
+    if (!IACP_STD_BETA_TABLE.pStatus[STD_BETA_DECODE]) Log_info0("WARNING: beta unit for Dec==NULL");
+    if (!IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM]) Log_info0("WARNING: beta unit for Dec==NULL");
+    if (!IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM2]) Log_info0("WARNING: beta unit for Dec==NULL");
+    if (!IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP]) Log_info0("WARNING: beta unit for Dec==NULL");
+    if (!IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP2]) Log_info0("WARNING: beta unit for Dec==NULL");
+    if (!IACP_STD_BETA_TABLE.pStatus[STD_BETA_THD]) Log_info0("WARNING: beta unit for Dec==NULL");
+    if (!IACP_STD_BETA_TABLE.pStatus[STD_BETA_THD2]) Log_info0("WARNING: beta unit for Dec==NULL");
+    if (!IACP_STD_BETA_TABLE.pStatus[STD_BETA_DTSUHDA]) Log_info0("WARNING: beta unit for Dec==NULL");
+    if (!IACP_STD_BETA_TABLE.pStatus[STD_BETA_AAC]) Log_info0("WARNING: beta unit for Dec==NULL");
+    if (!IACP_STD_BETA_TABLE.pStatus[STD_BETA_AAC2]) Log_info0("WARNING: beta unit for Dec==NULL");
     
     // (***) FL: revisit
     // invalidate Status structures for Beta Units initialized on Slave
-    Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_DECODE]), sizeof(Int), Cache_Type_ALLD, 0);
-    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);
-    Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM]), sizeof(Int), 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);
-    Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM2]), sizeof(Int), Cache_Type_ALLD, 0);
-    size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM2]->size;
-    Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM2]), size, Cache_Type_ALLD, 0);
-    Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP]), sizeof(Int), 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);
-    Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP2]), sizeof(Int), Cache_Type_ALLD, 0);
-    size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP2]->size;
-    Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP2]), size, Cache_Type_ALLD, 0);
-    Cache_wait();
+    //
+    if (IACP_STD_BETA_TABLE.pStatus[STD_BETA_DECODE] != NULL)
+    {
+        Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_DECODE]), sizeof(Int), Cache_Type_ALLD, 0);
+        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);
+        Cache_wait();
+    }
+    if (IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM] != NULL)
+    {
+        Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM]), sizeof(Int), 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);
+        Cache_wait();
+    }
+    if (IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM2] != NULL)
+    {
+        Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM2]), sizeof(Int), Cache_Type_ALLD, 0);
+        size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM2]->size;
+        Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM2]), size, Cache_Type_ALLD, 0);
+        Cache_wait();
+    }
+    if (IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP] != NULL)
+    {
+        Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP]), sizeof(Int), 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);
+        Cache_wait();
+    }
+    if (IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP2] != NULL)
+    {
+        Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP2]), sizeof(Int), Cache_Type_ALLD, 0);
+        size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP2]->size;
+        Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP2]), size, Cache_Type_ALLD, 0);
+        Cache_wait();
+    }
+    if (IACP_STD_BETA_TABLE.pStatus[STD_BETA_THD] != NULL)
+    {
+        Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_THD]), sizeof(Int), 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();
+    }
+    if (IACP_STD_BETA_TABLE.pStatus[STD_BETA_THD2] != NULL)
+    {
+        Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_THD2]), sizeof(Int), Cache_Type_ALLD, 0);
+        size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_THD2]->size;
+        Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_THD2]), size, Cache_Type_ALLD, 0);
+        Cache_wait();
+    }
+    if (IACP_STD_BETA_TABLE.pStatus[STD_BETA_DTSUHDA] != NULL)
+    {
+        Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_DTSUHDA]), sizeof(Int), Cache_Type_ALLD, 0);
+        size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_DTSUHDA]->size;
+        Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_DTSUHDA]), size, Cache_Type_ALLD, 0);
+        Cache_wait();
+    }
+    if (IACP_STD_BETA_TABLE.pStatus[STD_BETA_AAC] != NULL)
+    {
+        Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_AAC]), sizeof(Int), Cache_Type_ALLD, 0);
+        size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_AAC]->size;
+        Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_AAC]), size, Cache_Type_ALLD, 0);
+        Cache_wait();
+    }
+    if (IACP_STD_BETA_TABLE.pStatus[STD_BETA_AAC2] != NULL)
+    {
+        Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_AAC2]), sizeof(Int), Cache_Type_ALLD, 0);
+        size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_AAC2]->size;
+        Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_AAC2]), size, Cache_Type_ALLD, 0);
+        Cache_wait();
+    }
     
+#ifdef NON_CACHE_STATUS
+    // Get the shared status structure GateMP handles. Initialized at slave.
+    if (statusOp_Init(GATEMP_INDEX_DEC) == STATUSOP_INIT_FAIL)
+    {
+        Log_info1("TaskAfp: Gate Index %d:Open status GateMP Fail.", GATEMP_INDEX_DEC);
+    }
+    if (statusOp_Init(GATEMP_INDEX_DDP) == STATUSOP_INIT_FAIL)
+    {
+        Log_info1("TaskAfp: Gate Index %d:Open status GateMP Fail.", GATEMP_INDEX_DDP);
+    }
+    if (statusOp_Init(GATEMP_INDEX_PCM) == STATUSOP_INIT_FAIL)
+    {
+        Log_info1("TaskAfp: Gate Index %d:Open status GateMP Fail.", GATEMP_INDEX_PCM);
+    }
+    if (statusOp_Init(GATEMP_INDEX_THD) == STATUSOP_INIT_FAIL)
+    {
+        Log_info1("TaskAfp: Gate Index %d:Open status GateMP Fail.", GATEMP_INDEX_THD);
+    }
+    if (statusOp_Init(GATEMP_INDEX_DTS) == STATUSOP_INIT_FAIL)
+    {
+        Log_info1("TaskAfp: Gate Index %d:Open status GateMP Fail.", GATEMP_INDEX_DTS);
+    }
+#endif
     // (***) FL: revisit
     // invalidate Dec configuration
     Cache_inv(&gPAF_AST_config.xDec[0], DECODEN*sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
@@ -568,11 +707,23 @@ 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) 
         {
+            // If gCommandOutputTask_SYNC invoked by writeDECCommandRestart, wait for output task in sync ...
+            if (gCommandOutputTask_SYNC) {
+                TRACE_VERBOSE1("TaskAsip: writeDECCommandRestart issued ... Wait for ack from output task side (errno=%d)", errno);
+                // Wait for ack
+                while (gCommandOutputTask_ACK == 0) {
+                    Task_sleep(1);
+                }
+                TRACE_VERBOSE0("TaskAsip: writeDECCommandRestart issued ... Sync-ed! Startover the process");
+                gCommandOutputTask_ACK = 0;
+                gCommandOutputTask_SYNC = 0;
+            }
+            
             for (z=INPUT1; z < INPUTN; z++)
             {
                 if (pAstCfg->xInp[z].hRxSio)
@@ -594,7 +745,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;
@@ -604,92 +756,54 @@ Void taskAsipFxn(
         // so set to unknown and skip any remaining processing
         if (!pAstCfg->xInp[zMI].hRxSio)
         {
-#ifdef CACHE_COHERENCE
-            tempVar8 = PAF_SOURCE_UNKNOWN;
-            statusOp_write(&(pAstCfg->xDec[zMD].decodeStatus.sourceProgram),
-                           &tempVar8,
-                           sizeof(tempVar8));
-#else
-            pAstCfg->xDec[zMD].decodeStatus.sourceProgram = PAF_SOURCE_UNKNOWN;
-#endif
+            sharedMemWriteInt8(&(pAstCfg->xDec[zMD].decodeStatus.sourceProgram), 
+                               (Int8)PAF_SOURCE_UNKNOWN, GATEMP_INDEX_DEC);
+
             TRACE_VERBOSE1("TaskAsip: AS%d: No input selected...", as+zMS);
             continue;
         }
         
         // 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;
         }
-        
-#ifdef CACHE_COHERENCE
-        statusOp_read(&tempVar8,
-                      &(pAstCfg->xDec[zMD].decodeStatus.mode),
-                      sizeof(tempVar8));
+
         // If master decoder is not enabled, or the input is unlocked, then do nothing
+        tempVar8 = sharedMemReadInt8(&(pAstCfg->xDec[zMD].decodeStatus.mode), 
+                                     GATEMP_INDEX_DEC);
         if (!tempVar8 || !pAstCfg->xInp[zMI].inpBufStatus.lock)
         {
             TRACE_VERBOSE0("TaskAsip: Not locked, continue");
             continue;
         }
-#else
-        // If master decoder is not enabled, or the input is unlocked, then do nothing
-        if (!pAstCfg->xDec[zMD].decodeStatus.mode || !pAstCfg->xInp[zMI].inpBufStatus.lock)
-        {
-            TRACE_VERBOSE0("TaskAsip: Not locked, continue");
-            continue;
-        }
-#endif
         
-#ifdef CACHE_COHERENCE
-        statusOp_read(&tempVar8,
-                      &(pAstCfg->xDec[zMD].decodeStatus.sourceSelect),
-                      sizeof(tempVar8));
         // If no source selected then do nothing
+        tempVar8 = sharedMemReadInt8(&(pAstCfg->xDec[zMD].decodeStatus.sourceSelect), 
+                                     GATEMP_INDEX_DEC);
         if (tempVar8 == PAF_SOURCE_NONE)
         {
-            tempVar8 = PAF_SOURCE_NONE;
-            statusOp_write(&(pAstCfg->xDec[zMD].decodeStatus.sourceProgram),
-                           &tempVar8,
-                           sizeof(tempVar8));
-            TRACE_VERBOSE1("TaskAsip: AS%d: no source selected, continue", as+zMS);
-            continue;
-        }
-#else
-        // If no source selected then do nothing
-        if (pAstCfg->xDec[zMD].decodeStatus.sourceSelect == PAF_SOURCE_NONE) 
-        {
-            pAstCfg->xDec[zMD].decodeStatus.sourceProgram = PAF_SOURCE_NONE;
+            sharedMemWriteInt8(&(pAstCfg->xDec[zMD].decodeStatus.sourceProgram), 
+                               (Int8)PAF_SOURCE_NONE, GATEMP_INDEX_DEC);
             TRACE_VERBOSE1("TaskAsip: AS%d: no source selected, continue", as+zMS);
             continue;
         }
-#endif
 
-#ifdef CACHE_COHERENCE
-        statusOp_read(&tempVar8,
-                      &(pAstCfg->xDec[zMD].decodeStatus.sourceSelect),
-                      sizeof(tempVar8));
         // If we want pass processing then proceed directly
+        tempVar8 = sharedMemReadInt8(&(pAstCfg->xDec[zMD].decodeStatus.sourceSelect), 
+                                     GATEMP_INDEX_DEC);
         if (tempVar8 == PAF_SOURCE_PASS)
         {
             TRACE_VERBOSE1("TaskAsip: AS%d: Pass processing ...", as+zMS);
+            sharedMemWriteInt8(&(pAstCfg->xDec[zMD].decodeStatus.sourceProgram), 
+                               (Int8)PAF_SOURCE_PASS, GATEMP_INDEX_DEC);
 
-            tempVar8 = PAF_SOURCE_PASS;
-            statusOp_write(&(pAstCfg->xDec[zMD].decodeStatus.sourceProgram),
-                           &tempVar8,
-                           sizeof(tempVar8));
-#else
-        // If we want pass processing then proceed directly
-        if (pAstCfg->xDec[zMD].decodeStatus.sourceSelect == PAF_SOURCE_PASS) 
-        {
-            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 
             {
@@ -700,47 +814,37 @@ Void taskAsipFxn(
             continue;
         }
 
-#ifdef CACHE_COHERENCE
-        statusOp_read(&tempVar8,
-                      &(pAstCfg->xDec[zMD].decodeStatus.sourceSelect),
-                      sizeof(tempVar8));
-        // .....................................................................
-        // 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, tempVar8, NULL)) // (***) FL: re-visit this, hard-coded to use PCM framelength inside function
-        {
-            TRACE_VERBOSE1("TaskAsip: autoProcessing returns 0x%x, continue", errno);
-            continue;
-        }
-#else
         // .....................................................................
         // 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
+        tempVar8 = sharedMemReadInt8(&(pAstCfg->xDec[zMD].decodeStatus.sourceSelect), 
+                                     GATEMP_INDEX_DEC);
+        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;
         }
-#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;
             continue;
         }
-#ifdef CACHE_COHERENCE
-        statusOp_write(&(pAstCfg->xDec[zMD].decodeStatus.sourceProgram),
-                      &(sourceProgram),
-                      sizeof(sourceProgram));
-#else
-        pAstCfg->xDec[zMD].decodeStatus.sourceProgram = sourceProgram;
-#endif
+
+        sharedMemWriteInt8(&(pAstCfg->xDec[zMD].decodeStatus.sourceProgram), 
+                           sourceProgram, GATEMP_INDEX_DEC);
 
         // if input is unclassifiable then do nothing
         if (sourceProgram == PAF_SOURCE_UNKNOWN)
@@ -753,16 +857,10 @@ Void taskAsipFxn(
         // input frame, we determine whether or not to call decodeProcessing and with
         // what decAlg.
         sourceSelect = PAF_SOURCE_NONE;
-#ifdef CACHE_COHERENCE
-        statusOp_read(&tempVar8,
-                      &(pAstCfg->xDec[zMD].decodeStatus.sourceSelect),
-                      sizeof(tempVar8));
+        tempVar8 = sharedMemReadInt8(&(pAstCfg->xDec[zMD].decodeStatus.sourceSelect), 
+                                     GATEMP_INDEX_DEC);
         switch (tempVar8)
         {
-#else
-        switch (pAstCfg->xDec[zMD].decodeStatus.sourceSelect) 
-        {
-#endif
             // If autodetecting, decoding everything, and input is something
             // (i.e. bitstream or PCM) then decode.
             case PAF_SOURCE_AUTO:
@@ -807,14 +905,8 @@ Void taskAsipFxn(
             // If user made specific selection then program must match select.
             // (NB: this compare relies on ordering of PAF_SOURCE)
             default:
-#ifdef CACHE_COHERENCE
-                sourceSelect = 0; // due to size difference
-                statusOp_read(&sourceSelect,
-                              &(pAstCfg->xDec[zMD].decodeStatus.sourceSelect),
-                              sizeof(Int8));
-#else
-                sourceSelect = pAstCfg->xDec[zMD].decodeStatus.sourceSelect;
-#endif
+                sourceSelect = (Int)sharedMemReadInt8(&(pAstCfg->xDec[zMD].decodeStatus.sourceSelect),
+                                                             GATEMP_INDEX_DEC);
                 if ((sourceSelect >= PAF_SOURCE_PCM) && (sourceSelect <= PAF_SOURCE_N))
                 {
                     if (sourceProgram != sourceSelect)
@@ -832,58 +924,34 @@ Void taskAsipFxn(
             continue;
         }
 
-        // FL: debug, reset IB capture buffer
-        //capIbReset();
-        //Log_info0("capIbReset()");
-        
-        // FL: send source select message to slave
-        pAspMsg = (ASP_Msg *)MessageQ_alloc(hAspMsgMaster->heapId, hAspMsgMaster->msgSize); /* allocate message */
-        MessageQ_setReplyQueue(hAspMsgMaster->masterQue, (MessageQ_Msg)pAspMsg);            /* set the return address in the message header */
-        pAspMsg->cmd = ASP_SLAVE_DEC_SOURCE_SELECT;                                         /* fill in message payload */
-        pAspMsg->procId = hAspMsgMaster->masterProcId;
-        pAspMsg->messageId = hAspMsgMaster->messageId & ~(1<<31);
-        pAspMsg->expectResp = TRUE;
-        *(Int32 *)&pAspMsg->buf[0] = sourceSelect;
-        TRACE_MSG3("Tx ASP message: procId=%d, cmd=%d, messageId=0x%04x", pAspMsg->procId, pAspMsg->cmd, pAspMsg->messageId);
-        TRACE_MSG1("sourceSelect=%d", pAspMsg->buf[0]);
-        status = MessageQ_put(hAspMsgMaster->slaveQue, (MessageQ_Msg)pAspMsg);              /* send message */
-        if (status != MessageQ_S_SUCCESS)
-        {
-            SW_BREAKPOINT;
-        }
-        // wait for source select complete message from slave
-        //do {
-        //    status = MessageQ_get(hAspMsgMaster->masterQue, (MessageQ_Msg *)&pAspMsg, MessageQ_FOREVER);
-        //} while (status != MessageQ_S_SUCCESS);
-        status = MessageQ_get(hAspMsgMaster->masterQue, (MessageQ_Msg *)&pAspMsg, MessageQ_FOREVER);
-        if (status != MessageQ_S_SUCCESS)
-        {
-            TRACE_TERSE0("MessageQ_get() failure.");
-            SW_BREAKPOINT; // temporary
-        }
-        if ((pAspMsg->procId != hAspMsgMaster->slaveProcId) ||
-            (pAspMsg->cmd != ASP_MASTER_DEC_SOURCE_SELECT_DONE) ||
-            (pAspMsg->messageId != (hAspMsgMaster->messageId | ((UInt32)1<<31))))
-        {
-            TRACE_TERSE3("ERROR: Rx ASP message: procId=%d, cmd=%d, messageId=0x%04x", pAspMsg->procId, pAspMsg->cmd, pAspMsg->messageId);
-            SW_BREAKPOINT;
-        }
-        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);
-        status = MessageQ_free((MessageQ_Msg)pAspMsg); /* free the message */
-        if (status != MessageQ_S_SUCCESS)
+#if 0 // debug, reset IB capture buffer
+        capIbReset();
+        gCapIbReset_cnt++;
+        Log_info0("capIbReset()");
+#endif
+
+        // send source select message to slave
+        *(Int32 *)&asipMsgBuf[0] = sourceSelect;
+        if(AspMsgSend(ASP_SLAVE_DEC_SOURCE_SELECT, ASP_MASTER_DEC_SOURCE_SELECT_DONE,
+                      asipMsgBuf, NULL) != ASP_MSG_NO_ERR)
         {
+            TRACE_VERBOSE0("TaskAsip: error in sending SOURCE_SELECT message");
             SW_BREAKPOINT;
         }
         
         // 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(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);
@@ -893,47 +961,22 @@ Void taskAsipFxn(
             TRACE_VERBOSE0("TaskAsip: decodeProcessing complete with no error.");
         }        
 
+        gAspProfileEnable=0; // disable ASP profiling
+        
+        // Increase priority level since decoding complete
+        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 */
-        MessageQ_setReplyQueue(hAspMsgMaster->masterQue, (MessageQ_Msg)pAspMsg);            /* set the return address in the message header */
-        pAspMsg->cmd = ASP_SLAVE_DEC_EXIT;                                                  /* fill in message payload */
-        pAspMsg->procId = hAspMsgMaster->masterProcId;
-        pAspMsg->messageId = hAspMsgMaster->messageId & ~(1<<31);
-        pAspMsg->expectResp = TRUE;
-        TRACE_MSG2("Tx ASP message: procId=%d, cmd=%d.", pAspMsg->procId, pAspMsg->cmd);
-        status = MessageQ_put(hAspMsgMaster->slaveQue, (MessageQ_Msg)pAspMsg);              /* send message */
-        if (status != MessageQ_S_SUCCESS)
-        {
-            SW_BREAKPOINT;
-        }
-        // wait for dec exit complete message from slave
-        //do {
-        //    status = MessageQ_get(hAspMsgMaster->masterQue, (MessageQ_Msg *)&pAspMsg, MessageQ_FOREVER);
-        //} while ((status < 0) || (pAspMsg->cmd != ASP_MASTER_DEC_EXIT_DONE));
-        status = MessageQ_get(hAspMsgMaster->masterQue, (MessageQ_Msg *)&pAspMsg, MessageQ_FOREVER);
-        if (status != MessageQ_S_SUCCESS)
-        {
-            TRACE_TERSE0("MessageQ_get() failure.");
-            SW_BREAKPOINT; // temporary
-        }
-        if ((pAspMsg->procId != hAspMsgMaster->slaveProcId) || 
-            (pAspMsg->cmd != ASP_MASTER_DEC_EXIT_DONE) ||
-            (pAspMsg->messageId != (hAspMsgMaster->messageId | ((UInt32)1<<31))))
-        {
-            TRACE_TERSE3("ERROR: Rx ASP message: procId=%d, cmd=%d, messageId=0x%04x", pAspMsg->procId, pAspMsg->cmd, pAspMsg->messageId);
-            SW_BREAKPOINT;
-        }
-        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);
-        // free the message
-        status = MessageQ_free((MessageQ_Msg)pAspMsg); /* free the message */
-        if (status != MessageQ_S_SUCCESS)
+        if( AspMsgSend(ASP_SLAVE_DEC_EXIT, ASP_MASTER_DEC_EXIT_DONE, NULL, NULL)
+            != ASP_MSG_NO_ERR)
         {
-            SW_BREAKPOINT;
+            TRACE_VERBOSE0("TaskAsip: error in sending DEC_EXIT message");
+            SW_BREAKPOINT;                
         }
+
     } // End of main processing loop for (;;)
     
-    Log_info0("Exit taskAsipFxn()");
+    //Log_info0("Exit taskAsipFxn()");
 }
 
 // -----------------------------------------------------------------------------
@@ -955,15 +998,16 @@ 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;
     Int as;                    /* Audio Stream Number (1, 2, etc.) */
     Int zMS;
     Error_Block    eb;
+       IHeap_Handle   decHeapHandle;
 
-    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;
     
@@ -980,19 +1024,25 @@ 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);
 
     /* Decode memory */
-    if (!(pAstCfg->xDec = Memory_calloc((IHeap_Handle)HEAP_INTERNAL1_SHM, 
+#ifdef NON_CACHE_STATUS
+    decHeapHandle = (IHeap_Handle)HEAP_EXTERNAL_NONCACHED_SHM;
+#else 
+    decHeapHandle = (IHeap_Handle)HEAP_INTERNAL1_SHM;
+#endif
+    if (!(pAstCfg->xDec = Memory_calloc(decHeapHandle,
         DECODEN * sizeof (*pAstCfg->xDec), 4, &eb)))
     {
         TRACE_TERSE1("PAF_ASIT_initPhaseMalloc: AS%d: Memory_calloc failed", as+zMS);
         SW_BREAKPOINT;
         return __LINE__;
     }
-    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);
                 
@@ -1018,7 +1068,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;
@@ -1026,7 +1076,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;
     
@@ -1073,7 +1123,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;
@@ -1084,7 +1134,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;
     
@@ -1097,7 +1147,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);
@@ -1146,7 +1196,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;
@@ -1156,8 +1206,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");
@@ -1298,14 +1348,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
 
@@ -1351,7 +1401,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;
@@ -1362,7 +1412,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
 
@@ -1409,6 +1459,7 @@ PAF_ASIT_initPhaseDevice(
     return 0;
 } //PAF_ASIT_initPhaseDevice
 
+// (***) FL: move to ASOT
 // -----------------------------------------------------------------------------
 // ASIT Initialization Function - Decoder Output Circular Buffer
 //
@@ -1427,7 +1478,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;
@@ -1438,13 +1489,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)))
     {
@@ -1452,10 +1506,11 @@ PAF_ASIT_initPhaseDecOpCircBuf(
         SW_BREAKPOINT;
         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];
@@ -1469,32 +1524,80 @@ PAF_ASIT_initPhaseDecOpCircBuf(
         // allocate audio frame PCM sample pointer array
         for (i = 0; i<ASP_DECOP_CB_MAX_NUM_AF; i++)
         {
-            if (!(pCb->afCb[i].data.sample = Memory_calloc((IHeap_Handle)HEAP_INTERNAL1_SHM, ASP_DECOP_CB_MAX_NUM_PCM_CH * sizeof(PAF_AudioData *), 4, &eb)))
+            if (!(pCb->afCb[i].data.sample = Memory_calloc((IHeap_Handle)HEAP_INTERNAL1_SHM, ASP_DECOP_CB_MAX_NUM_PCM_CH_MAT * sizeof(PAF_AudioData *), 4, &eb)))
             {
                 TRACE_TERSE1("PAF_ASIT_initPhaseDecOpCircBuf: AS%d: Memory_calloc failed", as+zMS);
                 SW_BREAKPOINT;
             }
-            if (!(pCb->afCb[i].data.samsiz = Memory_calloc((IHeap_Handle)HEAP_INTERNAL1_SHM, ASP_DECOP_CB_MAX_NUM_PCM_CH * sizeof(PAF_AudioSize), 4, &eb)))
+            if (!(pCb->afCb[i].data.samsiz = Memory_calloc((IHeap_Handle)HEAP_INTERNAL1_SHM, ASP_DECOP_CB_MAX_NUM_PCM_CH_MAT * sizeof(PAF_AudioSize), 4, &eb)))
             {
                 TRACE_TERSE1("PAF_ASIT_initPhaseDecOpCircBuf: AS%d: Memory_calloc failed", as+zMS);
                 SW_BREAKPOINT;
             }                
         }
         // allocate PCM sample buffer
-        if (!(pCb->pcmBuf = Memory_calloc((IHeap_Handle)HEAP_INTERNAL1_SHM, ASP_DECOP_CB_PCM_BUF_SZ * sizeof(PAF_AudioData), 4, &eb)))
+        if (!(pCb->pcmBuf = Memory_calloc((IHeap_Handle)HEAP_EXTERNAL_SHM, ASP_DECOP_CB_PCM_BUF_SZ * sizeof(PAF_AudioData), 4, &eb)))
+        {
+            TRACE_TERSE1("PAF_ASIT_initPhaseDecOpCircBuf: AS%d: Memory_calloc failed", as+zMS);
+            SW_BREAKPOINT;
+        }
+        pCb->pcmBufEnd = pCb->pcmBuf + ASP_DECOP_CB_PCM_BUF_SZ;
+        // 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);
+
+        #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 Metadata buffers //QIN
-        if (!(pCb->metaBuf = Memory_calloc((IHeap_Handle)HEAP_INTERNAL1_SHM, ASP_DECOP_CB_MAX_NUM_AF * PAF_MAX_PRIVATE_MD_SZ * PAF_MAX_NUM_PRIVATE_MD * sizeof(Int8), 4, &eb)))
+
+        // 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
+        //
         
-        // (***) FL: revisit, here PCM is hard-coded for 256 sample dec op frame length        
-        // Initialize decoder output circular buffer for PCM
+        // Initialize status
+        pAstCfg->xDecOpCb[z].cbStatus = *pP->z_pDecOpCircBufStatus[z];
+        
+        // Default initialization
         errno = cbInit(pCb);
         if (errno)
         {
@@ -1502,11 +1605,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
@@ -1795,7 +1968,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
 )
@@ -1809,7 +1982,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;    
@@ -1826,8 +1999,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))
     {
@@ -1853,8 +2026,19 @@ PAF_ASIT_autoProcessing(
     nbytes = SIO_reclaim(pAstCfg->xInp[zMI].hRxSio, (Ptr)&pAstCfg->xInp[zMI].pInpBuf, NULL);
     if (nbytes == -DIBERR_SYNC)
     {
+#if 0 // (***) FL: shows timing of autosync restart
+        // (***) debug // B5
+        {
+            static Uint8 toggleState = 0;
+            if (toggleState == 0)
+                GPIOSetOutput(GPIO_PORT_0, GPIO_PIN_99);
+            else
+                GPIOClearOutput(GPIO_PORT_0, GPIO_PIN_99);
+            toggleState = ~(toggleState);
+        }
+#endif                
         TRACE_TERSE2("PAF_ASIT_autoProcessing: AS%d: SIO_reclaim returned 0x%x, ignoring", as+zMS, nbytes);
-        return 0;
+        return nbytes;
     }
     if (nbytes != sizeof(PAF_InpBufConfig))
     {
@@ -1869,6 +2053,10 @@ PAF_ASIT_autoProcessing(
     return errno;
 } //PAF_ASIT_autoProcessing
 
+UInt32 gProbe1Err=0;
+UInt32 gProbe2Err=0;
+UInt32 gMajorAuMissed=0;
+
 // -----------------------------------------------------------------------------
 // ASIT Processing Function - Decode Processing
 //
@@ -1942,30 +2130,26 @@ 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;
     enum { INIT, INFO1, INFO2, DECODE, FINAL, QUIT } state;
     ALG_Handle alg[DECODEN_MAX];
     Int zMD;
-    Int zMS;
-    Int size;
-    //PAF_InpBufConfig *pIpBufConfig;
+    //Int zMS;
     Int frame; // decoder input frame count
     Int block; // (***) FL: formerly  -- decoder output block count / input frame
-#ifdef CACHE_COHERENCE
-    Int8 tempVar8;
-#endif
+    Int8 tempVar8, temp2Var8;
     
-    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;
+    //zMS = pAstCfg->masterStr;
         
     for (z=DECODE1; z < DECODEN; z++)
     {
@@ -1980,30 +2164,23 @@ PAF_ASIT_decodeProcessing(
     state = INIT;
     errno = 0; /* error number */
 
-#ifdef CACHE_COHERENCE
-    statusOp_read(&tempVar8,
-                  &(pAstCfg->xDec[zMD].decodeStatus.sourceSelect),
-                  sizeof(tempVar8));
+    tempVar8 = sharedMemReadInt8(&(pAstCfg->xDec[zMD].decodeStatus.sourceSelect), 
+                                 GATEMP_INDEX_DEC);
     TRACE_TERSE1("PAF_ASIT_decodeProcessing: sourceSelect is %d", tempVar8);
 
     for (;;) 
     {
+        tempVar8 = sharedMemReadInt8(&(pAstCfg->xDec[zMD].decodeStatus.sourceSelect), 
+                                     GATEMP_INDEX_DEC);
         if (tempVar8 == PAF_SOURCE_NONE)
         {
-#else
-    TRACE_TERSE1("PAF_ASIT_decodeProcessing: sourceSelect is %d", pAstCfg->xDec[zMD].decodeStatus.sourceSelect);
-
-    for (;;)
-    {
-        if (pAstCfg->xDec[zMD].decodeStatus.sourceSelect == PAF_SOURCE_NONE)
-        {
-#endif
             TRACE_VERBOSE0("PAF_ASIT_decodeProcessing: sourceSelect == PAF_SOURCE_NONE");
             state = QUIT;
         }
 
         // 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
             {
@@ -2015,6 +2192,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
@@ -2033,47 +2215,15 @@ PAF_ASIT_decodeProcessing(
         {
             case INIT: // initial state
                 gAsipInitCnt++;
-                Log_info0("TaskAsip: state=INIT");
-
-                // (***) FL: revisit
-#if 1 // 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);
-                Cache_wait();*/
-#endif
-#if 0
-                ////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))
+                Log_info0("TaskAsip: state=INIT");               
+
+                errno = pP->fxns->decodeInit(pP, pQ, pAsitCfg, sourceSelect);
+                if (errno)
                 {
                     TRACE_VERBOSE1("PAF_ASIT_decodeProcessing: INIT, errno 0x%x.  break after decodeInit", errno);
                     break;
                 }
-                
-#if 1
-                // (***) FL: revisit
-                // 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);
-                Cache_wait();*/
-#endif
-                
+                               
                 frame = 0;
                 block = 0;
 
@@ -2085,75 +2235,50 @@ 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)
                 {
+                    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 CACHE_COHERENCE
-                statusOp_read(&tempVar8,
-                              &(pAstCfg->xDec[zMD].decodeStatus.sourceDecode),
-                              sizeof(tempVar8));
+                tempVar8  = sharedMemReadInt8(&(pAstCfg->xDec[zMD].decodeStatus.sourceDecode),
+                                              GATEMP_INDEX_DEC);
+                temp2Var8 = sharedMemReadInt8(&(pAstCfg->xDec[zMD].decodeStatus.sampleRate), 
+                                              GATEMP_INDEX_DEC);
                 // Don't start decode until major access unit is found.
                 if (((tempVar8 == PAF_SOURCE_THD)    ||
                      (tempVar8 == PAF_SOURCE_DXP)    ||
                      (tempVar8 == PAF_SOURCE_DTSHD)) &&
-                     (pAstCfg->xStr[zMS].pAudioFrame->sampleRate == PAF_SAMPLERATE_UNKNOWN)) 
-#else
-                // Don't start decode until major access unit is found.
-                if (((pAstCfg->xDec[zMD].decodeStatus.sourceDecode == PAF_SOURCE_THD)    ||
-                     (pAstCfg->xDec[zMD].decodeStatus.sourceDecode == PAF_SOURCE_DXP)    ||
-                     (pAstCfg->xDec[zMD].decodeStatus.sourceDecode == PAF_SOURCE_DTSHD)) &&
-                     (pAstCfg->xStr[zMS].pAudioFrame->sampleRate == PAF_SAMPLERATE_UNKNOWN))
-#endif
+                     (temp2Var8 == PAF_SAMPLERATE_UNKNOWN)) 
                 {
                     Int z;
                     for (z=DECODE1; z < DECODEN; z++) 
                     {
                         Int zI = pP->inputsFromDecodes[z];
-#ifdef CACHE_COHERENCE
-                        statusOp_read(&tempVar8,
-                                      &(pAstCfg->xDec[z].decodeStatus.mode),
-                                      sizeof(tempVar8));
+                        tempVar8 = sharedMemReadInt8(&(pAstCfg->xDec[z].decodeStatus.mode), 
+                                                     GATEMP_INDEX_DEC);
                         if (pAstCfg->xInp[zI].hRxSio && tempVar8)
                         {
-#else
-                        if (pAstCfg->xInp[zI].hRxSio && pAstCfg->xDec[z].decodeStatus.mode)
-                        {
-#endif
                             TRACE_VERBOSE0("TaskAsip: PAF_ASIT_decodeProcessing: INFO1, SIO_issue");
                             if (SIO_issue(pAstCfg->xInp[zI].hRxSio, &pAstCfg->xInp[zI].inpBufConfig,
                                 sizeof(pAstCfg->xInp[zI].inpBufConfig), PAF_SIO_REQUEST_NEWFRAME))
                             {
+                                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);
                             }
                         }
                     }
                     TRACE_VERBOSE1("PAF_ASIT_decodeProcessing: INFO1: frame %d, not major access unit", frame);
+                    gMajorAuMissed++; // debug
                     frame++;
                     state = INFO1;
                     continue;
@@ -2161,9 +2286,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;
                 }
 
@@ -2175,39 +2302,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;
@@ -2216,25 +2334,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);
                     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;
@@ -2246,7 +2352,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;
                 }
@@ -2280,15 +2386,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
 
 // -----------------------------------------------------------------------------
@@ -2308,76 +2425,52 @@ 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;
     Int as;                 /* Audio Stream Number (1, 2, etc.) */
     Int z;                  /* decode counter */
     Int zS;
-#ifdef CACHE_COHERENCE
     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++) 
     {
         zS = pP->streamsFromDecodes[z];
-#ifdef CACHE_COHERENCE
-        statusOp_read(&tempVar8,
-                      &(pAstCfg->xDec[z].decodeStatus.command2),
-                      sizeof(tempVar8));
+        tempVar8 = sharedMemReadInt8(&(pAstCfg->xDec[z].decodeStatus.command2), 
+                                     GATEMP_INDEX_DEC);
         if (!(tempVar8 & 0x80))
         {
             switch (tempVar8)
             {
                 case 0: // command none - process
                     tempVar8 |= 0x80;
-                    statusOp_write(&(pAstCfg->xDec[z].decodeStatus.command2),
-                                   &tempVar8,
-                                   sizeof(tempVar8));
+                    sharedMemWriteInt8(&(pAstCfg->xDec[z].decodeStatus.command2),
+                                       tempVar8, GATEMP_INDEX_DEC);
                     break;
                 case 1: // command abort - leave now
                     TRACE_TERSE2("AS%d: PAF_ASIT_decodeCommand: decode command abort (0x%02x)", as+zS, 1);
                     tempVar8 |= 0x80;
-                    statusOp_write(&(pAstCfg->xDec[z].decodeStatus.command2),
-                                   &tempVar8,
-                                   sizeof(tempVar8));
+                    sharedMemWriteInt8(&(pAstCfg->xDec[z].decodeStatus.command2),
+                                       tempVar8, GATEMP_INDEX_DEC);
                     return (ASPERR_ABORT);
                 case 2: // command restart - leave later
                     TRACE_TERSE2("AS%d: PAF_ASIT_decodeCommand: decode command quit (0x%02x)", as+zS, 2);
                     tempVar8 |= 0x80;
-                    statusOp_write(&(pAstCfg->xDec[z].decodeStatus.command2),
-                                   &tempVar8,
-                                   sizeof(tempVar8));
-                    return (ASPERR_QUIT);
-                default: // command unknown - ignore
-                    break;
-            }
-        }
-#else
-        if (!(pAstCfg->xDec[z].decodeStatus.command2 & 0x80))
-        {
-            switch (pAstCfg->xDec[z].decodeStatus.command2)
-            {
-                case 0: // command none - process
-                    pAstCfg->xDec[z].decodeStatus.command2 |= 0x80;
-                    break;
-                case 1: // command abort - leave now
-                    TRACE_TERSE2("AS%d: PAF_ASIT_decodeCommand: decode command abort (0x%02x)", as+zS, 1);
-                    pAstCfg->xDec[z].decodeStatus.command2 |= 0x80;
-                    return (ASPERR_ABORT);
-                case 2: // command restart - leave later
-                    TRACE_TERSE2("AS%d: PAF_ASIT_decodeCommand: decode command quit (0x%02x)", as+zS, 2);
-                    pAstCfg->xDec[z].decodeStatus.command2 |= 0x80;
+                    sharedMemWriteInt8(&(pAstCfg->xDec[z].decodeStatus.command2),
+                                       tempVar8, GATEMP_INDEX_DEC);
+                                       
+                    // Invoke command to output task to break the loop
+                    gCommandOutputTask_SYNC = 1;
+                    
                     return (ASPERR_QUIT);
                 default: // command unknown - ignore
                     break;
             }
         }
-#endif
     }
 
     return 0;
@@ -2399,47 +2492,39 @@ 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 */
     Int zI, zS;
     Int zMD;
     Int zMI;
-    ASP_Msg* pAspMsg;                   /* Messaging */
     Int argIdx;
-    Int decErrno;
-    Int status;
-#ifdef CACHE_COHERENCE
     Int8 tempVar8;
-#endif
+    char decMsgBuf[ASP_MSG_BUF_LEN];
     
-    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 CACHE_COHERENCE
     // reset frameCount
     for (z=DECODE1; z < DECODEN; z++)
     {
-        statusOp_read(&tempVar8,
-                      &(pAstCfg->xDec[z].decodeStatus.mode),
-                      sizeof(tempVar8));
+        tempVar8 = sharedMemReadInt8(&(pAstCfg->xDec[z].decodeStatus.mode),
+                                     GATEMP_INDEX_DEC);
         if (tempVar8)
         {
-            tempVar8 = 0;
-            statusOp_write(&(pAstCfg->xDec[z].decodeStatus.frameCount),
-                          &tempVar8,
-                          sizeof(tempVar8));
+            sharedMemWriteInt(&(pAstCfg->xDec[z].decodeStatus.frameCount),
+                              (Int)0, GATEMP_INDEX_DEC);
         }
     }
 
@@ -2448,29 +2533,11 @@ PAF_ASIT_decodeInit(
         zI = pP->inputsFromDecodes[z];
         zS = pP->streamsFromDecodes[z];
         (void)zS; // clear compiler warning in case not used with tracing disabled
-        statusOp_read(&tempVar8,
-                      &(pAstCfg->xDec[z].decodeStatus.mode),
-                      sizeof(tempVar8));
+        tempVar8 = sharedMemReadInt8(&(pAstCfg->xDec[z].decodeStatus.mode), 
+                                     GATEMP_INDEX_DEC);
         if (pAstCfg->xInp[zI].hRxSio && tempVar8)
         {
-#else
-    // reset frameCount
-    for (z=DECODE1; z < DECODEN; z++)
-    {
-        if (pAstCfg->xDec[z].decodeStatus.mode)
-        {
-            pAstCfg->xDec[z].decodeStatus.frameCount = 0;
-        }
-    }
 
-    for (z=DECODE1; z < DECODEN; z++)
-    {
-        zI = pP->inputsFromDecodes[z];
-        zS = pP->streamsFromDecodes[z];
-        (void)zS; // clear compiler warning in case not used with tracing disabled
-        if (pAstCfg->xInp[zI].hRxSio && pAstCfg->xDec[z].decodeStatus.mode)
-        {
-#endif
             Uns gear;
             Int frameLength;
             TRACE_VERBOSE1("AS%d: PAF_ASIT_decodeInit: initializing decode", as+zS);
@@ -2478,121 +2545,42 @@ PAF_ASIT_decodeInit(
             // write back Dec configuration
             Cache_wb(&pAstCfg->xDec[z], sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
             Cache_wait();
-            
+
             // FL: send dec activate message to slave
-            pAspMsg = (ASP_Msg *)MessageQ_alloc(hAspMsgMaster->heapId, hAspMsgMaster->msgSize);  /* allocate message */
-            if (pAspMsg == NULL)
-            {
-                TRACE_TERSE0("MessageQ_alloc() failure.");
-                SW_BREAKPOINT; // temporary
-                return -1; // temporary
-            }
-            MessageQ_setReplyQueue(hAspMsgMaster->masterQue, (MessageQ_Msg)pAspMsg);            /* set the return address in the message header */
-            pAspMsg->cmd = ASP_SLAVE_DEC_ACTIVATE;                                              /* fill in message payload */
-            pAspMsg->procId = hAspMsgMaster->masterProcId;
-            pAspMsg->expectResp = TRUE;
-            pAspMsg->messageId = hAspMsgMaster->messageId & ~(1<<31);
             argIdx = 0; // set decIdx (zone index)
-            *(Int32 *)&pAspMsg->buf[argIdx] = z;
-            TRACE_MSG3("Tx ASP message: procId=%d, cmd=%d, messageId=0x%04x", pAspMsg->procId, pAspMsg->cmd, pAspMsg->messageId);
-            TRACE_MSG1("decIdx=%d", pAspMsg->buf[0]);
-            status = MessageQ_put(hAspMsgMaster->slaveQue, (MessageQ_Msg)pAspMsg);                       /* send message */
-            if (status != MessageQ_S_SUCCESS)
-            {
-                SW_BREAKPOINT;
-            }
-            // wait for dec activate complete message from slave
-            status = MessageQ_get(hAspMsgMaster->masterQue, (MessageQ_Msg *)&pAspMsg, MessageQ_FOREVER);
-            if (status != MessageQ_S_SUCCESS)
-            {
-                TRACE_TERSE0("MessageQ_get() failure.");
-                SW_BREAKPOINT; // temporary
-                return -1; // temporary
-            }
-            if ((pAspMsg->procId != hAspMsgMaster->slaveProcId) || 
-                (pAspMsg->cmd != ASP_MASTER_DEC_ACTIVATE_DONE) ||
-                (pAspMsg->messageId != (hAspMsgMaster->messageId | ((UInt32)1<<31))))
+            *(Int32 *)&decMsgBuf[argIdx] = z;
+            if(AspMsgSend(ASP_SLAVE_DEC_ACTIVATE, ASP_MASTER_DEC_ACTIVATE_DONE, 
+                          decMsgBuf, NULL) != ASP_MSG_NO_ERR)
             {
-                TRACE_TERSE3("ERROR: Rx ASP message: procId=%d, cmd=%d, messageId=0x%04x", pAspMsg->procId, pAspMsg->cmd, pAspMsg->messageId);
+                TRACE_TERSE0("decodeInit: error in sending DEC_ACTIVATE message ");
                 SW_BREAKPOINT; // temporary
                 return -1; // 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);
-            // free the message
-            status = MessageQ_free((MessageQ_Msg)pAspMsg); /* free the message */
-            if (status != MessageQ_S_SUCCESS)
-            {
-                SW_BREAKPOINT;
-            }
-            
+            }           
+
 #if 0 // FL: decoder activate call, slave
             if (decAlg[z]->fxns->algActivate)
                 decAlg[z]->fxns->algActivate (decAlg[z]);
 #endif
-
             // FL: send dec reset message to slave
-            pAspMsg = (ASP_Msg *)MessageQ_alloc(hAspMsgMaster->heapId, hAspMsgMaster->msgSize);  /* allocate message */
-            if (pAspMsg == NULL)
-            {
-                TRACE_TERSE0("MessageQ_alloc() failure.");
-                SW_BREAKPOINT; // temporary
-                return -1; // temporary
-            }
-            MessageQ_setReplyQueue(hAspMsgMaster->masterQue, (MessageQ_Msg)pAspMsg);            /* set the return address in the message header */
-            pAspMsg->cmd = ASP_SLAVE_DEC_RESET;                                                 /* fill in message payload */
-            pAspMsg->procId = hAspMsgMaster->masterProcId;
-            pAspMsg->expectResp = TRUE;
-            pAspMsg->messageId = hAspMsgMaster->messageId & ~(1<<31);
             argIdx = 0; // set decIdx
-            *(Int32 *)&pAspMsg->buf[argIdx] = z;
-            TRACE_MSG3("Tx ASP message: procId=%d, cmd=%d, messageId=0x%04x", pAspMsg->procId, pAspMsg->cmd, pAspMsg->messageId);
-            TRACE_MSG1("decIdx=%d", pAspMsg->buf[0]);
-            // wait for dec reset complete message from slave
-            status = MessageQ_put(hAspMsgMaster->slaveQue, (MessageQ_Msg)pAspMsg);              /* send message */
-            if (status != MessageQ_S_SUCCESS)
-            {
-                SW_BREAKPOINT;
-            }
-            status = MessageQ_get(hAspMsgMaster->masterQue, (MessageQ_Msg *)&pAspMsg, MessageQ_FOREVER);
-            if (status != MessageQ_S_SUCCESS)
+            *(Int32 *)&decMsgBuf[argIdx] = z;
+            if(AspMsgSend(ASP_SLAVE_DEC_RESET, ASP_MASTER_DEC_RESET_DONE, 
+                          decMsgBuf, decMsgBuf) != ASP_MSG_NO_ERR)
             {
-                TRACE_TERSE0("MessageQ_get() failure.");
+                TRACE_TERSE0("decodeInit: error in sending DEC_RESET message ");
                 SW_BREAKPOINT; // temporary
                 return -1; // temporary
             }
-            if ((pAspMsg->procId == hAspMsgMaster->slaveProcId) &&
-                (pAspMsg->cmd == ASP_MASTER_DEC_RESET_DONE) && 
-                (pAspMsg->messageId == (hAspMsgMaster->messageId | ((UInt32)1<<31))))
-            {
-                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);
-                TRACE_MSG1("decErrno=%d", pAspMsg->buf[0]);
-
-                argIdx = 0; // get decErrno
-                decErrno = *(Int32 *)&pAspMsg->buf[argIdx];
-                if (decErrno != 0)
-                {
-                    return decErrno;
-                }
-            }
             else
             {
-                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
-            }
-            // free the message
-            status = MessageQ_free((MessageQ_Msg)pAspMsg); /* free the message */
-            if (status != MessageQ_S_SUCCESS)
-            {
-                SW_BREAKPOINT;
-            }
+                argIdx = 0; // get decErrno
+                errno = *(Int32 *)&decMsgBuf[argIdx];                
+            }   
 
             // (***) FL: revisit
             // invalidate Dec configuration
             Cache_inv(&pAstCfg->xDec[z], sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
-            Cache_wait();                            
+            Cache_wait();
             
 #if 0 // FL: decoder reset call, slave
             if (dec->fxns->reset
@@ -2600,63 +2588,46 @@ PAF_ASIT_decodeInit(
                                               &pC->xDec[z].decodeControl, &pC->xDec[z].decodeStatus)))
                 return errno;
 #endif
+            if (errno != 0)
+            {
+                return errno;
+            }
             
-#ifdef CACHE_COHERENCE
-            gear = 0;  // due to size difference
-            statusOp_read(&gear,
-                          &(pAstCfg->xDec[z].decodeStatus.aspGearControl),
-                          sizeof(Int8));
+            gear = (Uns)sharedMemReadInt8(&(pAstCfg->xDec[z].decodeStatus.aspGearControl),
+                                             GATEMP_INDEX_DEC);
             tempVar8 = gear < GEARS ? gear : 0;
-            statusOp_write(&(pAstCfg->xDec[z].decodeStatus.aspGearStatus),
-                           &tempVar8,
-                           sizeof(tempVar8));
-#else
-            gear = pAstCfg->xDec[z].decodeStatus.aspGearControl;
-            pAstCfg->xDec[z].decodeStatus.aspGearStatus = gear < GEARS ? gear : 0;
-#endif
+            sharedMemWriteInt8(&(pAstCfg->xDec[z].decodeStatus.aspGearStatus),
+                                  tempVar8, GATEMP_INDEX_DEC);
             
 #if 0 // FL: change handle to decIdx (zone index)
             frameLength = pP->fxns->computeFrameLength(decAlg[z], 
                 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
-            {
-                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) 
             {
@@ -2666,22 +2637,14 @@ PAF_ASIT_decodeInit(
                 }
             }
 
-#ifdef CACHE_COHERENCE
-            statusOp_read(&tempVar8,
-                          &(pAstCfg->xDec[z].decodeStatus.sourceSelect),
-                          sizeof(Int8));
+            tempVar8 = sharedMemReadInt8(&(pAstCfg->xDec[z].decodeStatus.sourceSelect),
+                                            GATEMP_INDEX_DEC);
             if (errno = SIO_ctrl(pAstCfg->xInp[zI].hRxSio, PAF_SIO_CONTROL_SET_SOURCESELECT,
                 DECSIOMAP(tempVar8)))
             {
                 return errno;
             }
-#else
-            if (errno = SIO_ctrl(pAstCfg->xInp[zI].hRxSio, PAF_SIO_CONTROL_SET_SOURCESELECT,
-                DECSIOMAP(pAstCfg->xDec[z].decodeStatus.sourceSelect)))
-            {
-                return errno;
-            }
-#endif
+
             if (errno = SIO_ctrl(pAstCfg->xInp[zI].hRxSio, PAF_SIO_CONTROL_SET_PCMFRAMELENGTH, 
                 frameLength))
             {
@@ -2725,7 +2688,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
 )
@@ -2739,19 +2702,17 @@ PAF_ASIT_decodeInfo(
     Int zMD;
     Int zMI;
     Int zMS;
-    UInt32 curTime;
-    ASP_Msg *pAspMsg;          /* Messaging */
     Int argIdx;
-    Int status;
-#ifdef CACHE_COHERENCE
     Int8 tempVar8;
     Int tempVar;
-#endif
+    char decMsgBuf[ASP_MSG_BUF_LEN];
     // FL: revisit
     //Int size;
     //PAF_InpBufConfig *pIpBufConfig;
+    // debug
+    //UInt32 curTime;
 
-    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;
@@ -2770,7 +2731,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
@@ -2791,20 +2762,13 @@ PAF_ASIT_decodeInfo(
                     // return (ASPERR_INFO_RATECHANGE);
                 }
             }
-#ifdef CACHE_COHERENCE
-            statusOp_read(&tempVar8,
-                          &(pAstCfg->xDec[zD].decodeStatus.sourceDecode),
-                          sizeof(Int8));
+
+            tempVar8 = sharedMemReadInt8(&(pAstCfg->xDec[zD].decodeStatus.sourceDecode),
+                                            GATEMP_INDEX_DEC);
             pAstCfg->xDec[zD].decodeControl.emphasis = 
                 tempVar8 != PAF_SOURCE_PCM
                 ? PAF_IEC_PREEMPHASIS_NO // fix for Mantis ID #119
                 : pAstCfg->xInp[z].inpBufStatus.emphasisStatus;
-#else
-            pAstCfg->xDec[zD].decodeControl.emphasis =
-                pAstCfg->xDec[zD].decodeStatus.sourceDecode != PAF_SOURCE_PCM
-                ? PAF_IEC_PREEMPHASIS_NO // fix for Mantis ID #119
-                : pAstCfg->xInp[z].inpBufStatus.emphasisStatus;
-#endif
         }
         else 
         {
@@ -2825,19 +2789,34 @@ PAF_ASIT_decodeInfo(
             return ASPERR_RECLAIM;
         }
         
-        // FL: debug, capture input buffer
-        //capIb(pAstCfg->xInp[zMI].pInpBuf);
+#if 0 // debug, capture input buffer
+        capIb(pAstCfg->xInp[zMI].pInpBuf);
+        gCapIb_cnt++;
+#endif
         
+#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)
+                GPIOSetOutput(GPIO_PORT_0, GPIO_PIN_99);
+            else
+                GPIOClearOutput(GPIO_PORT_0, GPIO_PIN_99);
+            toggleState = ~(toggleState);
+        }
+#endif
+
         //
         // Simulate Rx SIO_reclaim() pend
         //
         //Semaphore_pend(semaphoreRxAudio, BIOS_WAIT_FOREVER); 
-        gTaskAsipCnt++;
-        curTime = Clock_getTicks();
+        //curTime = Clock_getTicks();
         //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
+        
+        gAsipRxSioReclaimCnt++;
+    } //pAstCfg->xInp[zMI].hRxSio
 
     // Decode info
     for (z=DECODE1; z < DECODEN; z++) 
@@ -2845,16 +2824,11 @@ PAF_ASIT_decodeInfo(
         zI = pP->inputsFromDecodes[z];
         zS = pP->streamsFromDecodes[z];
         (void)zS; // clear compiler warning in case not used with tracing disabled
-#ifdef CACHE_COHERENCE
-        statusOp_read(&tempVar8,
-                      &(pAstCfg->xDec[z].decodeStatus.mode),
-                      sizeof(Int8));
+
+        tempVar8 = sharedMemReadInt8(&(pAstCfg->xDec[z].decodeStatus.mode),
+                                     GATEMP_INDEX_DEC);
         if (pAstCfg->xInp[zI].hRxSio && tempVar8)
         {
-#else
-        if (pAstCfg->xInp[zI].hRxSio && pAstCfg->xDec[z].decodeStatus.mode) 
-        {
-#endif
             TRACE_GEN2("PAF_ASIT_decodeInfo: AS%d: processing frame %d -- info", as+zS, frame);
 
             if (errno = pP->fxns->updateInputStatus(pAstCfg->xInp[zI].hRxSio,
@@ -2868,60 +2842,26 @@ 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();
 #endif
             
             // FL: send info message to slave
-            pAspMsg = (ASP_Msg *)MessageQ_alloc(hAspMsgMaster->heapId, hAspMsgMaster->msgSize); /* allocate message */
-            if (pAspMsg == NULL)
-            {
-                TRACE_TERSE0("MessageQ_alloc() failure.");
-                SW_BREAKPOINT; // temporary
-                return -1;  // temporary
-            }
-            MessageQ_setReplyQueue(hAspMsgMaster->masterQue, (MessageQ_Msg)pAspMsg);            /* set the return address in the message header */
-            pAspMsg->cmd = ASP_SLAVE_DEC_INFO;                                                  /* fill in message payload */
-            pAspMsg->procId = hAspMsgMaster->masterProcId;
-            pAspMsg->expectResp = TRUE;
-            pAspMsg->messageId = hAspMsgMaster->messageId & ~(1<<31);
             argIdx = 0; // set decIdx
-            *(Int32 *)&pAspMsg->buf[argIdx] = z;
-            TRACE_MSG3("Tx ASP message: procId=%d, cmd=%d, messageId=0x%04x", pAspMsg->procId, pAspMsg->cmd, pAspMsg->messageId);
-            TRACE_MSG1("decIdx=%d", pAspMsg->buf[0]);
-            status = MessageQ_put(hAspMsgMaster->slaveQue, (MessageQ_Msg)pAspMsg);              /* send message to slave */
-            if (status != MessageQ_S_SUCCESS)
+            *(Int32 *)&decMsgBuf[argIdx] = z;
+            if(AspMsgSend(ASP_SLAVE_DEC_INFO, ASP_MASTER_DEC_INFO_DONE, 
+                          decMsgBuf, decMsgBuf) != ASP_MSG_NO_ERR)
             {
-                SW_BREAKPOINT;
-            }
-            // wait for dec info complete message from slave -- temporary
-            status = MessageQ_get(hAspMsgMaster->masterQue, (MessageQ_Msg *)&pAspMsg, MessageQ_FOREVER);
-            if (status != MessageQ_S_SUCCESS)
-            {
-                TRACE_TERSE0("MessageQ_get() failure.");
-                SW_BREAKPOINT;
-                return -1; // temporary
-            }
-            if ((pAspMsg->procId != hAspMsgMaster->slaveProcId) || 
-                (pAspMsg->cmd != ASP_MASTER_DEC_INFO_DONE) || 
-                (pAspMsg->messageId != (hAspMsgMaster->messageId | ((UInt32)1<<31))))
-            {
-                TRACE_TERSE3("ERROR: Rx ASP message: procId=%d, cmd=%d, messageId=0x%04x", pAspMsg->procId, pAspMsg->cmd, pAspMsg->messageId);
+                TRACE_TERSE0("decodeInfo: error in sending DEC_INFO message ");
                 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);
-            // free the message
-            status = MessageQ_free((MessageQ_Msg)pAspMsg); /* free the message */
-            if (status != MessageQ_S_SUCCESS)
-            {
-                SW_BREAKPOINT;
+                return -1;     // temporary
             }
+            else
+            {
+                argIdx = 0; // get decErrno
+                errno = *(Int32 *)&decMsgBuf[argIdx];                
+            }             
 
 #if 1
             // (***) FL: revisit
@@ -2940,27 +2880,19 @@ PAF_ASIT_decodeInfo(
                 TRACE_TERSE1("return error errno 0x%x.", errno);
                 return errno;
             }
-#ifdef CACHE_COHERENCE
-            statusOp_read(&tempVar,
-                          &(pAstCfg->xDec[z].decodeStatus.frameCount),
-                          sizeof(Int));
+
             // increment decoded frame count
+            tempVar = sharedMemReadInt(&(pAstCfg->xDec[z].decodeStatus.frameCount),
+                                       GATEMP_INDEX_DEC);
             tempVar += 1;
-            statusOp_write(&(pAstCfg->xDec[z].decodeStatus.frameCount),
-                           &tempVar,
-                           sizeof(Int));
-#else
-            // increment decoded frame count
-            pAstCfg->xDec[z].decodeStatus.frameCount += 1;
-#endif
+            sharedMemWriteInt(&(pAstCfg->xDec[z].decodeStatus.frameCount),
+                              tempVar, GATEMP_INDEX_DEC);
         }
     } // z=DECODE1 to DECODEN
 
-#ifdef CACHE_COHERENCE
-    statusOp_read(&tempVar8,
-                  &(pAstCfg->xDec[zMD].decodeStatus.mode),
-                  sizeof(Int8));
     // query IB for latest sourceProgram (needed if we started decoding due to a force mode)
+    tempVar8 = sharedMemReadInt8(&(pAstCfg->xDec[zMD].decodeStatus.mode),
+                                 GATEMP_INDEX_DEC);
     if (tempVar8)
     {
         XDAS_Int8 sourceProgram;
@@ -2970,64 +2902,33 @@ PAF_ASIT_decodeInfo(
             TRACE_TERSE1("return error ASPERR_AUTO_PROGRAM. errno 0x%x.", errno);
             return ASPERR_AUTO_PROGRAM;
         }
-        statusOp_write(&(pAstCfg->xDec[zMD].decodeStatus.sourceProgram),
-                       &(sourceProgram),
-                       sizeof(Int8));
+
+        sharedMemWriteInt8(&(pAstCfg->xDec[zMD].decodeStatus.sourceProgram),
+                           sourceProgram, GATEMP_INDEX_DEC);
     }
 
     // since now decoding update decode status for all enabled decoders
     for (z=DECODE1; z < DECODEN; z++)
     {
-        statusOp_read(&tempVar8,
-                      &(pAstCfg->xDec[z].decodeStatus.mode),
-                      sizeof(Int8));
+        tempVar8 = sharedMemReadInt8(&(pAstCfg->xDec[z].decodeStatus.mode),
+                                     GATEMP_INDEX_DEC);
         if (tempVar8)
         {
-            statusOp_read(&tempVar8,
-                          &(pAstCfg->xDec[z].decodeStatus.sourceProgram),
-                          sizeof(Int8));
-            statusOp_write(&(pAstCfg->xDec[z].decodeStatus.sourceDecode),
-                           &tempVar8,
-                           sizeof(Int8));
-            statusOp_read(&tempVar8,
-                          &(pAstCfg->xDec[z].decodeStatus.sourceSelect),
-                          sizeof(Int8));
+            tempVar8 = sharedMemReadInt8(&(pAstCfg->xDec[z].decodeStatus.sourceProgram),
+                                         GATEMP_INDEX_DEC);
+            sharedMemWriteInt8(&(pAstCfg->xDec[z].decodeStatus.sourceDecode),
+                               tempVar8, GATEMP_INDEX_DEC);
+
+            tempVar8 = sharedMemReadInt8(&(pAstCfg->xDec[z].decodeStatus.sourceSelect),
+                                         GATEMP_INDEX_DEC);
             if (tempVar8 == PAF_SOURCE_SNG)
             {
                 tempVar8 = PAF_SOURCE_SNG;
-                statusOp_write(&(pAstCfg->xDec[z].decodeStatus.sourceDecode),
-                               &tempVar8,
-                               sizeof(Int8));
-            }
-        }
-    }
-#else
-    // query IB for latest sourceProgram (needed if we started decoding due to a force mode)
-    if (pAstCfg->xDec[zMD].decodeStatus.mode) 
-    {
-        XDAS_Int8 sourceProgram;
-        if (errno = SIO_ctrl(pAstCfg->xInp[zMI].hRxSio, PAF_SIO_CONTROL_GET_SOURCEPROGRAM,
-            (Arg)&sourceProgram))
-        {
-            TRACE_TERSE1("return error ASPERR_AUTO_PROGRAM. errno 0x%x.", errno);
-            return ASPERR_AUTO_PROGRAM;
-        }
-        pAstCfg->xDec[zMD].decodeStatus.sourceProgram = sourceProgram;
-    }
-
-    // since now decoding update decode status for all enabled decoders
-    for (z=DECODE1; z < DECODEN; z++) 
-    {
-        if (pAstCfg->xDec[z].decodeStatus.mode) 
-        {
-            pAstCfg->xDec[z].decodeStatus.sourceDecode = pAstCfg->xDec[z].decodeStatus.sourceProgram;
-            if (pAstCfg->xDec[z].decodeStatus.sourceSelect == PAF_SOURCE_SNG)
-            {
-                pAstCfg->xDec[z].decodeStatus.sourceDecode = PAF_SOURCE_SNG;
+                sharedMemWriteInt8(&(pAstCfg->xDec[z].decodeStatus.sourceDecode),
+                                   tempVar8, GATEMP_INDEX_DEC);
             }
         }
     }
-#endif
 
 #if 0 // FL: ASDT (slave)
     // TODO: move this to start of this function so that it doesn't affect IO timing
@@ -3080,7 +2981,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
 )
@@ -3104,7 +3005,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
 )
@@ -3112,6 +3013,7 @@ PAF_ASIT_decodeInfo2(
     return 0;
 } //PAF_ASIT_decodeInfo2
 
+#if 0
 // -----------------------------------------------------------------------------
 // AST Decoding Function - Continuation Processing
 //
@@ -3131,7 +3033,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
@@ -3142,12 +3044,10 @@ PAF_AST_decodeCont(
     Int z;                      /* decode counter */
     Int zI, zS;
     Int zMD;
-#ifdef CACHE_COHERENCE
     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;
     zMD = pAstCfg->masterDec;
     (void)as;  // clear compiler warning in case not used with tracing disabled
@@ -3158,20 +3058,12 @@ PAF_AST_decodeCont(
         zI = pP->inputsFromDecodes[z];
         zS = pP->streamsFromDecodes[z];
         (void)zS;
-#ifdef CACHE_COHERENCE
-        statusOp_read(&tempVar8,
-                      &(pAstCfg->xDec[z].decodeStatus.mode),
-                      sizeof(Int8));
+        tempVar8 = sharedMemReadInt8(&(pAstCfg->xDec[z].decodeStatus.mode),
+                                     GATEMP_INDEX_DEC);
         if (z == zMD
             || ! pAstCfg->xInp[zI].hRxSio
             || ! tempVar8)
             continue;
-#else
-        if (z == zMD
-            || ! pAstCfg->xInp[zI].hRxSio
-            || ! pAstCfg->xDec[z].decodeStatus.mode)
-            continue;
-#endif
         TRACE_VERBOSE2("PAF_AST_decodeCont: AS%d: awaiting frame %d -- data", as+zS, frame);
         if (SIO_reclaim(pAstCfg->xInp[zI].hRxSio, (Ptr)&pAstCfg->xInp[zI].pInpBuf, NULL)
             != sizeof (pAstCfg->xInp[zI].inpBufConfig))
@@ -3180,6 +3072,7 @@ PAF_AST_decodeCont(
 
     return 0;
 } //PAF_AST_decodeCont
+#endif
 
 // -----------------------------------------------------------------------------
 // ASIT Decoding Function - Decode Processing
@@ -3198,7 +3091,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
@@ -3209,13 +3102,12 @@ PAF_ASIT_decodeDecode(
     Int z;                      /* decode/stream counter */
     Int errno;                  /* error number */
     //Int ch;
-    ASP_Msg *pAspMsg;           /* Messaging */
     Int argIdx;
-    Int status;
     Int cbErrno;
     Int frameLength;    
+    char decMsgBuf[ASP_MSG_BUF_LEN];
 
-    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
 
@@ -3245,8 +3137,9 @@ PAF_ASIT_decodeDecode(
                     (IArg)pAstCfg->xInp[z].pInpBuf->base.pVoid,
                     (IArg)pAstCfg->xInp[z].pInpBuf->head.pVoid);
 
-            // FL: debug, capture input buffer
-            //capIbPcm(pAstCfg->xInp[z].pInpBuf);
+#if 0 // debug, capture input buffer
+            capIbPcm(pAstCfg->xInp[z].pInpBuf);
+#endif
             
             // (***) FL: revisit
             // write back Dec configuration
@@ -3254,63 +3147,28 @@ PAF_ASIT_decodeDecode(
             Cache_wait();                        
 
             // FL: send decode message to slave
-            pAspMsg = (ASP_Msg *)MessageQ_alloc(hAspMsgMaster->heapId, hAspMsgMaster->msgSize);  /* allocate message */
-            if (pAspMsg == NULL)
-            {
-                TRACE_TERSE0("MessageQ_alloc() failure.");
-                SW_BREAKPOINT; // temporary
-                return -1; // temporary
-            }
-            MessageQ_setReplyQueue(hAspMsgMaster->masterQue, (MessageQ_Msg)pAspMsg);            /* set the return address in the message header */
-            pAspMsg->cmd = ASP_SLAVE_DEC_DECODE;                                                /* fill in message payload */
-            pAspMsg->procId = hAspMsgMaster->masterProcId;
-            pAspMsg->expectResp = TRUE;
-            pAspMsg->messageId = hAspMsgMaster->messageId & ~(1<<31);
             argIdx = 0; // set decIdx
-            *(Int32 *)&pAspMsg->buf[argIdx] = z;
-            TRACE_MSG3("Tx ASP message: procId=%d, cmd=%d, messageId=0x%04x", pAspMsg->procId, pAspMsg->cmd, pAspMsg->messageId);
-            TRACE_MSG1("decIdx=%d", pAspMsg->buf[argIdx]);
-            status = MessageQ_put(hAspMsgMaster->slaveQue, (MessageQ_Msg)pAspMsg);              /* send message */
-            if (status != MessageQ_S_SUCCESS)
-            {
-                SW_BREAKPOINT;
-            }
-            // wait for decode complete message from slave -- temporary
-            status = MessageQ_get(hAspMsgMaster->masterQue, (MessageQ_Msg *)&pAspMsg, MessageQ_FOREVER);
-            if (status != MessageQ_S_SUCCESS)
+            *(Int32 *)&decMsgBuf[argIdx] = z;
+            if(AspMsgSend(ASP_SLAVE_DEC_DECODE, ASP_MASTER_DEC_DECODE_DONE, 
+                          decMsgBuf, decMsgBuf) != ASP_MSG_NO_ERR)
             {
-                TRACE_TERSE0("MessageQ_get() failure.");
+                TRACE_TERSE0("decodeDecode: error in sending DEC_DECODE message ");
                 SW_BREAKPOINT; // temporary
-                return -1; // temporary
+                return -1;     // temporary
             }
-            if ((pAspMsg->procId == hAspMsgMaster->slaveProcId) && 
-                (pAspMsg->cmd == ASP_MASTER_DEC_DECODE_DONE) &&
-                (pAspMsg->messageId == (hAspMsgMaster->messageId | ((UInt32)1<<31))))
+            else 
             {
-                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;
-                errno = *(Int32 *)&pAspMsg->buf[argIdx];
-                argIdx += sizeof(Int32);
-                cbErrno = *(Int32 *)&pAspMsg->buf[argIdx];
+                argIdx = 0; // get decErrno
+                errno = *(Int32 *)&decMsgBuf[argIdx];
+                argIdx += sizeof(Int32); // get cbErrno
+                cbErrno = *(Int32 *)&decMsgBuf[argIdx];
                 if (cbErrno != 0)
                 {
+                    gCbWrtAfErrCnt++;
                     TRACE_TERSE1("CB write error=%d", cbErrno);
-                    SW_BREAKPOINT; // temporary
+                    //SW_BREAKPOINT; // temporary
                 }
-            }
-            else
-            {
-                TRACE_TERSE3("ERROR: Rx ASP message: procId=%d, cmd=%d, messageId=0x%04x", pAspMsg->procId, pAspMsg->cmd, pAspMsg->messageId);
-                SW_BREAKPOINT; // temporary
-            }
-            // free the message
-            status = MessageQ_free((MessageQ_Msg)pAspMsg); /* free the message */
-            if (status != MessageQ_S_SUCCESS)
-            {
-                SW_BREAKPOINT;
-            }
+            }           
 
             // (***) FL: revisit
             // invalidate Dec configuration
@@ -3337,24 +3195,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
-            {
-                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
+
 
 // ............................................................................
 
@@ -3429,7 +3291,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
 )
@@ -3438,26 +3300,15 @@ PAF_ASIT_decodeFinalTest(
     Int zMD;
     Int sourceSelect;
     Int sourceProgram;
-#ifdef CACHE_COHERENCE
     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 CACHE_COHERENCE
-    statusOp_read(&tempVar8,
-                  &(pAstCfg->xDec[zMD].decodeStatus.sourceSelect),
-                  sizeof(Int8));
-    sourceSelect = tempVar8;
-    statusOp_read(&tempVar8,
-                  &(pAstCfg->xDec[zMD].decodeStatus.sourceProgram),
-                  sizeof(Int8));
-    sourceProgram = tempVar8;
-#else
-    sourceSelect  = pAstCfg->xDec[zMD].decodeStatus.sourceSelect;
-    sourceProgram = pAstCfg->xDec[zMD].decodeStatus.sourceProgram;
-#endif
+    sourceSelect  = (Int)sharedMemReadInt8(&(pAstCfg->xDec[zMD].decodeStatus.sourceSelect),
+                                           GATEMP_INDEX_DEC);
+    sourceProgram = (Int)sharedMemReadInt8(&(pAstCfg->xDec[zMD].decodeStatus.sourceProgram),
+                                           GATEMP_INDEX_DEC);
 
     if ((sourceSelect == PAF_SOURCE_NONE) || (sourceSelect == PAF_SOURCE_PASS))
     {
@@ -3489,23 +3340,14 @@ PAF_ASIT_decodeFinalTest(
         }
         else 
         {
-#ifdef CACHE_COHERENCE
-            statusOp_read(&tempVar8,
-                          &(pAstCfg->xDec[zMD].decodeStatus.sourceDecode),
-                          sizeof(Int8));
-            statusOp_read(&temp2Var8,
-                          &(pAstCfg->xDec[zMD].decodeStatus.sourceSelect),
-                          sizeof(Int8));
+            tempVar8  = sharedMemReadInt8(&(pAstCfg->xDec[zMD].decodeStatus.sourceDecode),
+                                          GATEMP_INDEX_DEC);
+            temp2Var8 = sharedMemReadInt8(&(pAstCfg->xDec[zMD].decodeStatus.sourceSelect),
+                                          GATEMP_INDEX_DEC);
             if (temp2Var8 != tempVar8)
             {
                 return 1;
             }
-#else
-            if (pAstCfg->xDec[zMD].decodeStatus.sourceSelect != pAstCfg->xDec[zMD].decodeStatus.sourceDecode)
-            {
-                return 1;
-            }
-#endif
         }
     }
 
@@ -3528,7 +3370,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
@@ -3537,16 +3379,11 @@ PAF_ASIT_decodeComplete(
     PAF_AST_Config *pAstCfg;
     Int as;                     /* Audio Stream Number (1, 2, etc.) */
     Int z;                      /* decode/encode counter */
-    ASP_Msg* pAspMsg;
     Int argIdx;
-    Int errno;                  /* error number */
-    Int status;
-#ifdef CACHE_COHERENCE
     Int8 tempVar8;
-#endif
-
+    char decMsgBuf[ASP_MSG_BUF_LEN];
     
-    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
 
@@ -3559,65 +3396,26 @@ PAF_ASIT_decodeComplete(
         DEC_Handle dec = (DEC_Handle )decAlg[z];
 #endif /* PAF_ASP_FINAL */
         Int zI = pP->inputsFromDecodes[z];
-#ifdef CACHE_COHERENCE
-        statusOp_read(&tempVar8,
-                      &(pAstCfg->xDec[z].decodeStatus.mode),
-                      sizeof(Int8));
+        tempVar8 = sharedMemReadInt8(&(pAstCfg->xDec[z].decodeStatus.mode),
+                                     GATEMP_INDEX_DEC);
         if (pAstCfg->xInp[zI].hRxSio && tempVar8)
         {
-#else
-        if (pAstCfg->xInp[zI].hRxSio && pAstCfg->xDec[z].decodeStatus.mode) 
-        {
-#endif
             TRACE_VERBOSE1("PAF_ASIT_decodeComplete: AS%d: finalizing decode", as+z);
 #ifdef PAF_ASP_FINAL
             if (dec->fxns->final)
                 dec->fxns->final(dec, NULL, &pAstCfg->xDec[z].decodeControl,
                                  &pAstCfg->xDec[z].decodeStatus);
 #endif /* PAF_ASP_FINAL */
+
             // FL: send dec deactivate message to slave
-            pAspMsg = (ASP_Msg *)MessageQ_alloc(hAspMsgMaster->heapId, hAspMsgMaster->msgSize);  /* allocate message */
-            if (pAspMsg == NULL)
-            {
-                TRACE_TERSE0("MessageQ_alloc() failure.");
-                errno = -1; // temporary
-                return errno;
-            }
-            MessageQ_setReplyQueue(hAspMsgMaster->masterQue, (MessageQ_Msg)pAspMsg);              /* set the return address in the message header */
-            pAspMsg->cmd = ASP_SLAVE_DEC_DEACTIVATE;                                              /* fill in message payload */
-            pAspMsg->procId = hAspMsgMaster->masterProcId;
-            pAspMsg->expectResp = TRUE;
-            pAspMsg->messageId = hAspMsgMaster->messageId & ~(1<<31);
             argIdx = 0; // set decIdx
-            *(Int32 *)&pAspMsg->buf[argIdx] = z;
-            TRACE_MSG3("Tx ASP message: procId=%d, cmd=%d, messageId=0x%04x", pAspMsg->procId, pAspMsg->cmd, pAspMsg->messageId);
-            TRACE_MSG1("decIdx=%d", pAspMsg->buf[0]);
-            status = MessageQ_put(hAspMsgMaster->slaveQue, (MessageQ_Msg)pAspMsg);                /* send message */
-            if (status != MessageQ_S_SUCCESS)
-            {
-                SW_BREAKPOINT;
-            }
-            // wait for dec deactivate complete message from slave
-            status = MessageQ_get(hAspMsgMaster->masterQue, (MessageQ_Msg *)&pAspMsg, MessageQ_FOREVER);
-            if (status != MessageQ_S_SUCCESS)
-            {
-                TRACE_TERSE0("MessageQ_get() failure.");
-                return errno;
-            }
-            if ((pAspMsg->procId != hAspMsgMaster->slaveProcId) ||
-                (pAspMsg->cmd != ASP_MASTER_DEC_DEACTIVATE_DONE) ||
-                (pAspMsg->messageId != (hAspMsgMaster->messageId | ((UInt32)1<<31))))
-            {
-                TRACE_MSG3("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_TERSE3("Rx ASP message: procId=%d, cmd=%d, messageId=0x%04x", pAspMsg->procId, pAspMsg->cmd, pAspMsg->messageId);
-            // free the message
-            status = MessageQ_free((MessageQ_Msg)pAspMsg); /* free the message */
-            if (status != MessageQ_S_SUCCESS)
+            *(Int32 *)&decMsgBuf[argIdx] = z;
+            if(AspMsgSend(ASP_SLAVE_DEC_DEACTIVATE, ASP_MASTER_DEC_DEACTIVATE_DONE,
+                          decMsgBuf, NULL) != ASP_MSG_NO_ERR)
             {
+                TRACE_TERSE0("decodeComplete: error in sending DEC_DEACTIVATE message.");
                 SW_BREAKPOINT;
+                return -1;
             }
 
 #if 0 // FL: decoder deactivate call, slave
@@ -3650,7 +3448,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;
@@ -3661,7 +3459,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
@@ -3728,37 +3526,26 @@ Int
 PAF_ASIT_sourceDecode(
     const PAF_ASIT_Params *pP, 
     const PAF_ASIT_Patchs *pQ, 
-    PAF_ASIT_Config *pC
+    PAF_ASIT_Config *pAsitCfg
     Int x
 )
 {
     PAF_AST_Config *pAstCfg;
     Int z;                              /* decode counter */
-#ifdef CACHE_COHERENCE
     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++)
     {
-#ifdef CACHE_COHERENCE
-        statusOp_read(&tempVar8,
-                      &(pAstCfg->xDec[z].decodeStatus.mode),
-                      sizeof(Int8));
+        tempVar8 = sharedMemReadInt8(&(pAstCfg->xDec[z].decodeStatus.mode),
+                                     GATEMP_INDEX_DEC);
         if (tempVar8)
         {
             tempVar8 = x;
-            statusOp_write(&(pAstCfg->xDec[z].decodeStatus.sourceDecode),
-                           &tempVar8,
-                           sizeof(Int8));
-        }
-#else
-        if (pAstCfg->xDec[z].decodeStatus.mode) 
-        {
-            pAstCfg->xDec[z].decodeStatus.sourceDecode = x;
+            sharedMemWriteInt8(&(pAstCfg->xDec[z].decodeStatus.sourceDecode),
+                               tempVar8, GATEMP_INDEX_DEC);
         }
-#endif
     }
     
     return 0;
@@ -3853,3 +3640,43 @@ 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_AAC:
+            frameLength = 1024;
+            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;
+        case PAF_SOURCE_DTS:
+        case PAF_SOURCE_DTSHD:
+        case PAF_SOURCE_DTS12:
+        case PAF_SOURCE_DTS13:
+        case PAF_SOURCE_DTS14:
+        case PAF_SOURCE_DTS16:
+        case PAF_SOURCE_DTSALL:
+            frameLength = ASIP_FRAMELEN_SS_DTS;
+            break;
+        default:
+            frameLength = ASIP_FRAMELEN_SS_DEFAULT;
+            break;
+    }
+    
+    return frameLength;
+}