]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/performance-audio-sr.git/blobdiff - pasdk/test_dsp/framework/audioStreamOutProc.c
PASDK-218:Relocate first setCheckRateX and startOutput to ASOT:decodeProcessing:INIT
[processor-sdk/performance-audio-sr.git] / pasdk / test_dsp / framework / audioStreamOutProc.c
index 416b56e1edf982dcfbef6ad5b3b6e360305949c0..21cc1172655204b3d7993027b4a3e28ba5b28234 100644 (file)
@@ -57,11 +57,13 @@ All rights reserved.
 #include "aspMsg_common.h"
 #include "aspMsg_master.h"
 #include "aspDecOpCircBuf_master.h"
+#include "aspOutInitSync_master.h"
 #include "audioStreamProc_common.h"
 #include "audioStreamOutProc.h"
 
 #include "pfp/pfp.h"
 #include "pfp_app.h"        /* contains all PFP ID's */
+Int32 gNumPfpAsot1=0; // debug
 
 // FL: debug
 #include "evmc66x_gpio_dbg.h"
@@ -101,20 +103,126 @@ All rights reserved.
 #define __TASK_NAME__  "TaskAsop"
 
 
-/* FL: Check if at least one output selected */
+//
+// Audio Stream Output Task definitions
+//
+
+// status codes
+// Output FSM
+#define ASOP_INITSYNC_NOTREADY      (  1 )  // ok, init-sync not ready
+#define ASOP_SOK                    (  0 )  // ok
+#define ASOP_FORWARD_ERR            ( -1 )  // forward (ASIT) error
+#define ASOP_ENCRESET_ERR           ( -2 )  // enc reset error
+#define ASOP_DECINFO1_ERR           ( -3 )  // dec info1 error
+// Decode Processing
+#define ASOP_DP_OUT_SIO_UPDATE      (  3 )  // new output selected
+#define ASOP_DP_CB_DRAINED          (  2 )  // circular buffer drained
+#define ASOP_DP_SOK                 (  0 )  // ok
+#define ASOP_DP_FORWARD_ERR         ( -1 )  // forward (ASIT) error
+#define ASOP_DP_DECINIT_ERR         ( -2 )  // decode init error
+#define ASOP_DP_DECSTREAM_ERR       ( -3 )  // decode stream error
+#define ASOP_DP_DECENC_ERR          ( -4 )  // decode encode error
+#define ASOP_DP_DECINFO2_ERR        ( -5 )  // decode encode error
+#define ASOP_DP_DECFINALTEST_ERR    ( -6 )  // decode final error
+
+
+
+/* Check if at least one output selected */
 static Int checkOutSel(
     const PAF_ASOT_Params *pP, 
-    PAF_ASOT_Config *pC,
+    PAF_ASOT_Config *pAsotCfg,
     Int *pOutSel
 );
 
-/* FL: Check if at least one output sio changed */
+/* Check if at least one output sio changed */
 static Int checkOutSio(
     const PAF_ASOT_Params *pP, 
-    PAF_ASOT_Config *pC,
+    PAF_ASOT_Config *pAsotCfg,
     Int *pOutSioUpdate
 );
 
+// Initialize Output Processing state function
+static Int PAF_ASOT_initOutProc(
+    const PAF_ASOT_Params *pP, 
+    PAF_AST_Stream *xStr
+);
+
+// Initialize Output Processing state function
+static Int PAF_ASOT_initSyncDecReset(
+    const PAF_ASOT_Params *pP, 
+    const PAF_ASOT_Patchs *pQ, 
+    PAF_ASOT_Config *pAsotCfg,
+    PAF_AudioFrame *pDecResetAf
+);
+
+//   Purpose:   ASOT Function for Output reset
+static Int PAF_ASOT_outputReset(
+    const PAF_ASOT_Params *pP, 
+    const PAF_ASOT_Patchs *pQ, 
+    PAF_ASOT_Config *pAsotCfg
+);
+
+//   Purpose:   Init-Sync Dec Info1 state function.
+//              Performes Dec Info1 Init-Sync.
+static Int PAF_ASOT_initSyncDecInfo1(
+    const PAF_ASOT_Params *pP, 
+    const PAF_ASOT_Patchs *pQ, 
+    PAF_ASOT_Config *pAsotCfg,
+    PAF_AudioFrame *pDecInfo1Af
+);
+
+//   Purpose:   ASOT function for ASP chain reset and ENC info
+static Int PAF_ASOT_outputInfo1(
+    const PAF_ASOT_Params *pP, 
+    const PAF_ASOT_Patchs *pQ, 
+    PAF_ASOT_Config *pAsotCfg
+);
+
+//   Purpose:   Init-Sync Dec Decode1 state function.
+//              Performes Dec Decode1 Init-Sync.
+static Int PAF_ASOT_initSyncDecDecode1(
+    const PAF_ASOT_Params *pP, 
+    const PAF_ASOT_Patchs *pQ, 
+    PAF_ASOT_Config *pAsotCfg
+);
+
+//   Purpose:   Init-Sync Re-Sync state function.
+//              Peformed Init-Sync using stored Dec Reset/Info1 AFs.
+static Int PAF_ASOT_initSyncResync(
+    const PAF_ASOT_Params *pP, 
+    const PAF_ASOT_Patchs *pQ, 
+    PAF_ASOT_Config *pAsotCfg,
+    PAF_AudioFrame *pDecResetAf,
+    PAF_AudioFrame *pDecInfo1Af  
+);
+
+#if 0
+// Init-Sync update audio frame
+static Int initSyncUpdateAf(
+    PAF_AudioFrame *dstAf, 
+    PAF_AudioFrame *srcAf
+);
+#endif
+
+// Reset audio frames
+static Void resetAfs(
+    const PAF_ASOT_Params *pP, 
+    PAF_AST_Stream *xStr
+);
+
+// Reset audio frame pointers to original values
+static Void resetAfPointers(
+    const PAF_ASOT_Params *pP, 
+    PAF_AST_Stream *xStr
+);
+
+// Reset audio frame meta data elements
+static Void resetAfMetadata(
+    const PAF_ASOT_Params *pP, 
+    PAF_AST_Stream *xStr
+);
+
+
 LINNO_DEFN(TaskAsop); /* Line number macros */
 ERRNO_DEFN(TaskAsop); /* Error number macros */
 
@@ -123,6 +231,7 @@ ERRNO_DEFN(TaskAsop); /* Error number macros */
 PAF_ASOT_Config gPAF_ASOT_config = {
     NULL,               // taskHandle
     NULL,               // acp
+    0,0,0,              // CB drained flags (size DECODE_MAXN)
     &gPAF_ASPM_config,  // pAspmCfg
     &gPAF_AST_config    // pAstCfg
 };
@@ -132,14 +241,22 @@ PAF_ASOT_Config gPAF_ASOT_config = {
 UInt32 gCbReadAfErr         =0; // read circular buffer error count, not including underflows
 UInt32 gDecOpCbRdAfUnd      =0; // decoder output circular buffer underflow count
 UInt32 gMaxDecOpCbRdAfUnd   =0; // max (consecutive) decoder output circular buffer underflow count
+UInt32 gMasterCbResetCnt    =0; // master circular buffer reset count
 
 // Global debug counters */
-UInt32 gTaskAsopCnt=0; // debug
-UInt32 gAsopInitCnt         =0;
-UInt32 gAsopStreamCnt       =0;
-UInt32 gAsopEncodeCnt       =0;
-UInt32 gAsopFinalCnt        =0;
-UInt32 gAsopQuitCnt         =0;
+UInt32 gAsopInitOutProcCnt          =0;
+UInt32 gAsopInitSyncDecResetCnt     =0;
+UInt32 gAsopInitSyncDecInfo1Cnt     =0;
+UInt32 gAsopInitSyncDecDecode1Cnt   =0;
+UInt32 gAsopInitSyncResyncCnt       =0;
+UInt32 gAsopOutProcCnt              =0;
+UInt32 gAsopInitCnt                 =0;
+UInt32 gAsopStreamCnt               =0;
+UInt32 gAsopEncodeCnt               =0;
+UInt32 gAsopFinalCnt                =0;
+UInt32 gAsopOutSioUpdateCnt         =0;
+UInt32 gAsopQuitCnt                 =0;
+UInt32 gAsopTxSioReclaimCnt         =0;
 
 
 /*
@@ -152,7 +269,7 @@ Void taskAsopFxn(
     const PAF_ASOT_Patchs *pQ
 )
 {
-    PAF_ASOT_Config *pC;            /* Local configuration pointer */
+    PAF_ASOT_Config *pAsotCfg;      /* ASOT configuration pointer */
     PAF_AST_Config *pAstCfg;        /* Common (shared) configuration pointer */
     Int as;                         /* Audio Stream Number (1, 2, etc.) */
     Int z;                          /* input/encode/stream/decode/output counter */
@@ -160,11 +277,19 @@ Void taskAsopFxn(
     Int errno;                      /* error number */
     Int zMS;
     Int loopCount = 0;  // used to stop trace to see startup behavior.        
+    Int outSel;
+    enum { INIT_OUT_PROC_STATE, 
+           INITSYNC_DEC_RESET_STATE, INITSYNC_DEC_INFO1_STATE, INITSYNC_DEC_DECODE1_STATE, 
+           INITSYNC_RESYNC_STATE, 
+           OUT_PROC_STATE } state;
+    PAF_AudioFrame decResetAf;
+    PAF_AudioFrame decInfo1Af;
+    
 
     Log_info0("Enter taskAsopFxn()");    
 
     //
-    // Audio Framework Parameters & Patch (*pP, *pQ)
+    // Audio Stream Output Task Parameters & Patch (*pP, *pQ)
     //
     if (!pP) 
     {
@@ -181,11 +306,11 @@ Void taskAsopFxn(
     }    
 
     //
-    // Audio Framework Configuration (*pC):
+    // Audio Stream Output Task Configuration (*pAsotCfg):
     //
-    pC = &gPAF_ASOT_config;         // initialize pointer to task configuration
-    pC->taskHandle = Task_self();   // set task handle
-    pAstCfg = pC->pAstCfg;          // get pointer to common (shared) configuration
+    pAsotCfg = &gPAF_ASOT_config;       // initialize pointer to task configuration
+    pAsotCfg->taskHandle = Task_self(); // set task handle
+    pAstCfg = pAsotCfg->pAstCfg;        // get pointer to AST common (shared) configuration
 
     /* Obtain Audio Stream Number (1, 2, etc.) */    
     as = pAstCfg->as;
@@ -223,7 +348,8 @@ Void taskAsopFxn(
         Int linno;
         if (pP->fxns->initPhase[i])
         {
-            if (linno = pP->fxns->initPhase[i](pP, pQ, pC)) 
+            linno = pP->fxns->initPhase[i](pP, pQ, pAsotCfg);
+            if (linno) 
             {
                 LINNO_RPRT(TaskAsop, linno);
                 return;
@@ -242,7 +368,9 @@ Void taskAsopFxn(
     //
     if (pP->fxns->memStatusPrint)
     {
-        pP->fxns->memStatusPrint(HEAP_INTERNAL, HEAP_INTERNAL1, HEAP_EXTERNAL, HEAP_INTERNAL1_SHM);
+        pP->fxns->memStatusPrint("ASOT MEMSTAT REPORT",
+            HEAP_INTERNAL, HEAP_INTERNAL1, HEAP_EXTERNAL, 
+            HEAP_INTERNAL1_SHM, HEAP_EXTERNAL_SHM, HEAP_EXTERNAL_NONCACHED_SHM);
     }
 
     //
@@ -253,14 +381,17 @@ Void taskAsopFxn(
         TRACE_VERBOSE1("TaskAsip: AS%d: running", as+z);
     }
     
-    errno = 0;
+    state = INIT_OUT_PROC_STATE;    // initialize state
+    errno = 0;                      // reset error indicator
     for (;;)
     {
-        Int outSel;
-
         loopCount++;
         TRACE_GEN2("TaskAsop (begin Main loop %d) (errno 0x%x)", loopCount, errno);
 
+        //
+        // Check forward (ASIT) error here, TBD
+        //
+        
         // any error forces idling of output
         if (errno) 
         {
@@ -279,15 +410,18 @@ Void taskAsopFxn(
         TRACE_VERBOSE1("TaskAsop: AS%d: ... sleeping ...", as+zMS);
         Task_sleep(1);
 
+        // select output devices
         TRACE_GEN1("TaskAsop: AS%d: Output device selection ...", as+zMS);
-        if (errno = pP->fxns->selectDevices(pP, pQ, pC))
+        errno = pP->fxns->selectDevices(pP, pQ, pAsotCfg);
+        if (errno)
         {
             TRACE_TERSE2("TaskAsop: AS%d: selectDevices returned errno = 0x%04x", as+zMS, errno);
             continue;
         }
 
-        // if no output selected skip any remaining processing
-        if (errno = checkOutSel(pP, pC, &outSel))
+        // if no output selected skip remaining processing
+        errno = checkOutSel(pP, pAsotCfg, &outSel);
+        if (errno < 0)
         {
             TRACE_TERSE2("TaskAsop: AS%d: checkOutSel returned errno = 0x%04x", as+zMS, errno);
             continue;
@@ -298,19 +432,224 @@ Void taskAsopFxn(
             continue;
         }
         
-        TRACE_VERBOSE0("TaskAsop: calling outputProcessing.");
-        errno = pP->fxns->decodeProcessing(pP, pQ, pC, -1);
-        if (errno) 
+        switch (state)
         {
-            TRACE_TERSE1("TaskAsop: outputProcessing returns 0x%x, continue", errno);
+            case INIT_OUT_PROC_STATE:
+                gAsopInitOutProcCnt++;
+                Log_info0("TaskAsop: state=INIT_OUT_PROC_STATE");
+                
+                //
+                // Output Processing initialization.
+                //
+                errno = PAF_ASOT_initOutProc(pP, pAstCfg->xStr);
+                if (errno < 0)
+                {
+                    state = INIT_OUT_PROC_STATE;
+                }
+                else
+                {
+                    state = INITSYNC_DEC_RESET_STATE;
+                }
+            
+                break;
+                
+            case INITSYNC_DEC_RESET_STATE:
+                gAsopInitSyncDecResetCnt++;
+                Log_info0("TaskAsop: state=INITSYNC_DEC_RESET_STATE");
+
+                //
+                // Dec Reset Init-Sync.
+                //  
+                
+                // Perform Dec Reset init-sync.
+                // Latch Dec Reset AF.
+                errno = PAF_ASOT_initSyncDecReset(pP, pQ, pAsotCfg, &decResetAf);
+                if (errno < 0)
+                {
+                    Log_info1("TaskAsop: state=INITSYNC_DEC_RESET_STATE errno=%d", errno);
+                    // sync error -- start over
+                    state = INIT_OUT_PROC_STATE;
+                }
+                else if (errno == ASOP_INITSYNC_NOTREADY)
+                {
+                    Log_info1("TaskAsop: state=INITSYNC_DEC_RESET_STATE not sync'd errno=%d", errno);
+                    // sync not ready -- try again
+                    state = INITSYNC_DEC_RESET_STATE;
+                    errno=0; // FL: temp hack
+                }
+                else // errno==0
+                {
+                    Log_info1("TaskAsop: state=INITSYNC_DEC_RESET_STATE sync'd, errno=%d", errno);
+                    // sync'd -- move on
+                    state = INITSYNC_DEC_INFO1_STATE;
+                }
+                
+                break;
+            
+            case INITSYNC_DEC_INFO1_STATE:
+                gAsopInitSyncDecInfo1Cnt++;
+                Log_info0("TaskAsop: state=INITSYNC_DEC_INFO1_STATE");
+                
+                //
+                // Dec Info1 Init-Sync.
+                //
+
+                // Perform Dec Info1 init-sync.
+                // Latch Dec Info1 AF.
+                errno = PAF_ASOT_initSyncDecInfo1(pP, pQ, pAsotCfg, &decInfo1Af);
+                if (errno < 0)
+                {
+                    Log_info1("TaskAsop: state=INITSYNC_DEC_INFO1_STATE errno=%d", errno);
+                    // sync error -- start over
+                    state = INIT_OUT_PROC_STATE;
+                }
+                else if (errno == ASOP_INITSYNC_NOTREADY)
+                {
+                    Log_info1("TaskAsop: state=INITSYNC_DEC_INFO1_STATE not sync'd errno=%d", errno);
+                    // sync not ready -- try again
+                    state = INITSYNC_DEC_INFO1_STATE;
+                    errno=0; // FL: temp hack
+                }
+                else // errno = 0
+                {
+                    Log_info1("TaskAsop: state=INITSYNC_DEC_INFO1_STATE sync'd errno=%d", errno);
+                    // sync'd -- move on
+                    state = INITSYNC_DEC_DECODE1_STATE;
+                }
+                
+                break;
+            
+            case INITSYNC_DEC_DECODE1_STATE:
+                gAsopInitSyncDecDecode1Cnt++;
+                Log_info0("TaskAsop: state=INITSYNC_DEC_DECODE1_STATE");
+                
+                //
+                // Dec Info1 Init-Sync.
+                //
+
+                // Perform Dec Info1 init-sync.
+                // Latch Dec Info1 AF.
+                errno = PAF_ASOT_initSyncDecDecode1(pP, pQ, pAsotCfg);
+                if (errno < 0)
+                {
+                    Log_info1("TaskAsop: state=INITSYNC_DEC_DECODE1_STATE errno=%d", errno);
+                    // sync error -- start over
+                    state = INIT_OUT_PROC_STATE;
+                }
+                else if (errno == ASOP_INITSYNC_NOTREADY)
+                {
+                    Log_info1("TaskAsop: state=INITSYNC_DEC_DECODE1_STATE not sync'd errno=%d", errno);
+                    // sync not ready -- try again
+                    state = INITSYNC_DEC_DECODE1_STATE;
+                    errno=0; // FL: temp hack
+                }
+                else // errno = 0
+                {
+                    Log_info1("TaskAsop: state=INITSYNC_DEC_DECODE1_STATE sync'd errno=%d", errno);
+                    // sync'd -- move on
+                    state = OUT_PROC_STATE;
+                }
+                
+                break;
+            
+            case INITSYNC_RESYNC_STATE:
+                gAsopInitSyncResyncCnt++;
+                Log_info0("TaskAsop: state=INITSYNC_RESYNC_STATE");
+
+                //
+                // Re-Sync.
+                // Use stored AF info from init-sync.
+                // This is done in case of local error.
+                //
+                
+                // Perform Dec Info1 init-sync.
+                errno = PAF_ASOT_initSyncResync(pP, pQ, pAsotCfg, &decResetAf, 
+                    &decInfo1Af);
+                if (errno < 0)
+                {
+                    Log_info1("TaskAsop: state=INITSYNC_RESYNC_STATE errno=%d", errno);
+                    // sync error -- start over
+                    state = INIT_OUT_PROC_STATE;
+                }
+                else
+                {
+                    Log_info1("TaskAsop: state=INITSYNC_RESYNC_STATE sync'd errno=%d", errno);
+                    // re-sync'd -- move on
+                    state = OUT_PROC_STATE;
+                }
+                    
+                break;
+            
+            case OUT_PROC_STATE:        
+                gAsopOutProcCnt++;
+                Log_info0("TaskAsop: state=OUT_PROC_STATE");
+                
+                //
+                // Output Processing.
+                //
+
+                TRACE_VERBOSE0("TaskAsop: calling decodeProcessing.");
+                errno = pP->fxns->decodeProcessing(pP, pQ, pAsotCfg);
+                if (errno < 0)
+                {
+                    Log_info1("TaskAsop: state=OUT_PROC_STATE errno=%d", errno);
+                    
+                    //
+                    // Output Processing exit, due to error
+                    //
+                    
+                    TRACE_TERSE1("TaskAsop: decodeProcessing returns 0x%x, continue", errno);
+                    if (errno == ASOP_DP_FORWARD_ERR)
+                    {
+                        // forward (ASIT) error -- start over
+                        state = INIT_OUT_PROC_STATE;
+                    }
+                    else
+                    {
+                        // local (ASOT) error
+                        state = INITSYNC_RESYNC_STATE;    
+                    }        
+                }
+                else if (errno > 0)
+                {
+                    Log_info1("TaskAsop: state=OUT_PROC_STATE errno=%d", errno);
+
+                    //
+                    // Output Processing exit, not due to error
+                    //
+
+                    TRACE_TERSE1("TaskAsop: decodeProcessing returns 0x%x, continue", errno);                    
+                    if (errno == ASOP_DP_OUT_SIO_UPDATE)
+                    {
+                        // skip re-sync
+                        // resume output processing after new output selected
+                        state = OUT_PROC_STATE;
+                    }
+                }
+                else
+                {
+                    Log_info1("TaskAsop: state=OUT_PROC_STATE errno=%d", errno);
+
+                    //
+                    // Output Processing exit, normal
+                    //
+                    
+                    TRACE_VERBOSE0("TaskAsop: outputProcessing complete with no error.");
+                    
+                    // no error returned if CB drained 
+                    // (i.e. CB drained is normal behavior)
+                    state = INIT_OUT_PROC_STATE;
+                }
+                
+                break;
+            
+            default: // unknown state
+                TRACE_TERSE2("TaskAsop: AS%d: state: unknown, 0x%x", as+zMS, state);
+                break;
         }
-        else
-        {
-            TRACE_VERBOSE0("TaskAsop: outputProcessing complete with no error.");
-        }        
     } // End of main processing loop for (;;)
     
-    Log_info0("Exit taskAsopFxn()");
+    //Log_info0("Exit taskAsopFxn()");
 }
 
 // -----------------------------------------------------------------------------
@@ -333,7 +672,7 @@ Int
 PAF_ASOT_initPhaseMalloc (
     const PAF_ASOT_Params *pP, 
     const PAF_ASOT_Patchs *pQ, 
-    PAF_ASOT_Config *pC
+    PAF_ASOT_Config *pAsotCfg
 )
 {
     PAF_AST_Config *pAstCfg;
@@ -342,7 +681,7 @@ PAF_ASOT_initPhaseMalloc (
     Error_Block    eb;
     //Int i;
 
-    pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
+    pAstCfg = pAsotCfg->pAstCfg; // get pointer to AST common (shared) configuration
     as = pAstCfg->as;
     zMS = pAstCfg->masterStr;
 
@@ -428,7 +767,7 @@ Int
 PAF_ASOT_initPhaseConfig(
     const PAF_ASOT_Params *pP, 
     const PAF_ASOT_Patchs *pQ, 
-    PAF_ASOT_Config *pC
+    PAF_ASOT_Config *pAsotCfg
 )
 {
     PAF_AST_Config *pAstCfg;
@@ -436,7 +775,7 @@ PAF_ASOT_initPhaseConfig(
     Int z;                      /* input/encode/stream/decode/output counter */
     Int zMS;
 
-    pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
+    pAstCfg = pAsotCfg->pAstCfg; // get pointer to AST common (shared) configuration
     as = pAstCfg->as;
     zMS = pAstCfg->masterStr;
 
@@ -449,11 +788,11 @@ PAF_ASOT_initPhaseConfig(
     for (z=STREAM1; z < STREAMN; z++) 
     {
         Int linno;
-        if (linno = pP->fxns->initFrame0(pP, pQ, pC, z))
+        if (linno = pP->fxns->initFrame0(pP, pQ, pAsotCfg, z))
         {
             return linno;           
         }
-        if (linno = pP->fxns->initFrame1(pP, pQ, pC, z, -1))
+        if (linno = pP->fxns->initFrame1(pP, pQ, pAsotCfg, z, -1))
         {
             return linno;
         }
@@ -501,7 +840,7 @@ Int
 PAF_ASOT_initPhaseAcpAlg(
     const PAF_ASOT_Params *pP, 
     const PAF_ASOT_Patchs *pQ, 
-    PAF_ASOT_Config *pC
+    PAF_ASOT_Config *pAsotCfg
 )
 {
     PAF_AST_Config *pAstCfg;
@@ -512,7 +851,7 @@ PAF_ASOT_initPhaseAcpAlg(
     Int zMS;
     Int zS, zX;
 
-    pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
+    pAstCfg = pAsotCfg->pAstCfg; // get pointer to AST common (shared) configuration
     as = pAstCfg->as;
     zMS = pAstCfg->masterStr;
 
@@ -525,7 +864,7 @@ PAF_ASOT_initPhaseAcpAlg(
         TRACE_TERSE1("PAF_ASOT_initPhaseAcpAlg: AS%d: ACP algorithm instance creation  failed", as+zMS);
         return __LINE__;
     }
-    pC->acp = acp;
+    pAsotCfg->acp = acp;
 
     ((ALG_Handle)acp)->fxns->algControl((ALG_Handle) acp,
         ACP_GETBETAPRIMEOFFSET, (IALG_Status *)&betaPrimeOffset);
@@ -586,7 +925,7 @@ Int
 PAF_ASOT_initPhaseCommon(
     const PAF_ASOT_Params *pP, 
     const PAF_ASOT_Patchs *pQ, 
-    PAF_ASOT_Config *pC
+    PAF_ASOT_Config *pAsotCfg
 )
 {
     PAF_AST_Config *pAstCfg;
@@ -597,8 +936,8 @@ PAF_ASOT_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 = pAsotCfg->acp;
+    pAstCfg = pAsotCfg->pAstCfg; // get pointer to AST common (shared) configuration
     as = pAstCfg->as;
 
     TRACE_TERSE0("PAF_ASOT_initPhaseCommon: initialization phase - Common Memory");
@@ -826,7 +1165,7 @@ Int
 PAF_ASOT_initPhaseAlgKey(
     const PAF_ASOT_Params *pP, 
     const PAF_ASOT_Patchs *pQ, 
-    PAF_ASOT_Config *pC
+    PAF_ASOT_Config *pAsotCfg
 )
 {
     PAF_AST_Config *pAstCfg;
@@ -835,7 +1174,7 @@ PAF_ASOT_initPhaseAlgKey(
     Int s;                      /* key number */
     PAF_ASP_Link *that;
 
-    pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
+    pAstCfg = pAsotCfg->pAstCfg; // get pointer to AST common (shared) configuration
     as = pAstCfg->as;
     (void)as; // clear compiler warning in case not used with tracing disabled
 
@@ -879,7 +1218,7 @@ Int
 PAF_ASOT_initPhaseDevice(
     const PAF_ASOT_Params *pP, 
     const PAF_ASOT_Patchs *pQ, 
-    PAF_ASOT_Config *pC
+    PAF_ASOT_Config *pAsotCfg
 )
 {
     PAF_AST_Config *pAstCfg;
@@ -889,7 +1228,7 @@ PAF_ASOT_initPhaseDevice(
     PAF_SIO_IALG_Config *pAlgConfig;
     PAF_IALG_Config pafAlgConfig;
 
-    pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
+    pAstCfg = pAsotCfg->pAstCfg; // get pointer to AST common (shared) configuration
     as = pAstCfg->as;
     (void)as; // clear compiler warning in case not used with tracing disabled
 
@@ -958,7 +1297,7 @@ Int
 PAF_ASOT_initFrame0(
     const PAF_ASOT_Params *pP, 
     const PAF_ASOT_Patchs *pQ, 
-    PAF_ASOT_Config *pC
+    PAF_ASOT_Config *pAsotCfg
     Int z
 )
 {
@@ -977,7 +1316,7 @@ PAF_ASOT_initFrame0(
     char i;
     Error_Block    eb;
 
-    pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
+    pAstCfg = pAsotCfg->pAstCfg; // get pointer to AST common (shared) configuration
     as = pAstCfg->as;
 
     // Initialize error block
@@ -1165,14 +1504,14 @@ Int
 PAF_ASOT_initFrame1(
     const PAF_ASOT_Params *pP, 
     const PAF_ASOT_Patchs *pQ, 
-    PAF_ASOT_Config *pC
+    PAF_ASOT_Config *pAsotCfg
     Int z, 
     Int apply
 )
 {
     PAF_AST_Config *pAstCfg;
 
-    pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
+    pAstCfg = pAsotCfg->pAstCfg; // get pointer to AST common (shared) configuration
 
     //
     // Reinitialize audio frame elements:
@@ -1220,7 +1559,7 @@ Int
 PAF_ASOT_selectDevices(
     const PAF_ASOT_Params *pP, 
     const PAF_ASOT_Patchs *pQ, 
-    PAF_ASOT_Config *pC
+    PAF_ASOT_Config *pAsotCfg
 )
 {
     PAF_AST_Config *pAstCfg;
@@ -1230,7 +1569,7 @@ PAF_ASOT_selectDevices(
     Int errme;                  /* error number, local */
     Int device;
 
-    pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
+    pAstCfg = pAsotCfg->pAstCfg; // get pointer to AST common (shared) configuration
     as = pAstCfg->as;
     (void)as;  // clear compiler warning in case not used with tracing disabled
 
@@ -1330,28 +1669,32 @@ Int
 PAF_ASOT_decodeProcessing(
     const PAF_ASOT_Params *pP, 
     const PAF_ASOT_Patchs *pQ, 
-    PAF_ASOT_Config *pC, 
-    Int sourceSelect
+    PAF_ASOT_Config *pAsotCfg 
 )
 {
     PAF_AST_Config *pAstCfg;
-    Int z;                              /* decode counter */
     Int errno;                          /* error number */
     Int getVal;
-    enum { INIT, STREAM, ENCODE, FINAL, QUIT } state;
+    enum { INIT, STREAM, ENCODE, FINAL, QUIT, OUT_SIO_UPDATE } state;
     state = INIT;
     errno = 0; /* error number */
     Int frame; // (***) FL: formerly -- decoder input frame count
     Int block; // decoder output block count / input frame
     Int outSioUpdate;
     
-    pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
+    pAstCfg = pAsotCfg->pAstCfg; // get pointer to AST common (shared) configuration
 
     for (;;) 
     {
-        // FL: Check if any change in output SIO, e.g. from Output shortcut.
+        //
+        // Check forward (ASIT) error here, TBD
+        //
+        
+        
+        // Check if any change in output SIO, e.g. from Output shortcut.
         // Changes will break FSM and allow Output reconfiguration.
-        if (errno = checkOutSio(pP, pC, &outSioUpdate))
+        errno = checkOutSio(pP, pAsotCfg, &outSioUpdate);
+        if (errno < 0)
         {
             TRACE_TERSE1("PAF_ASOT_decodeProcessing: checkOutSio returned errno = 0x%04x", errno);
             break;
@@ -1359,11 +1702,12 @@ PAF_ASOT_decodeProcessing(
         else if (outSioUpdate)
         {
             TRACE_VERBOSE0("PAF_ASOT_decodeProcessing: Change in Output SIO selection");
-            state = QUIT;
+            state = OUT_SIO_UPDATE;
         }
         
         // Process commands (encode)
-        if (getVal = pP->fxns->encodeCommand(pP, pQ, pC)) 
+        getVal = pP->fxns->encodeCommand(pP, pQ, pAsotCfg);
+        if (getVal) 
         {
             /* ignore */;
         }
@@ -1375,58 +1719,36 @@ PAF_ASOT_decodeProcessing(
                 gAsopInitCnt++;
                 Log_info0("TaskAsop: state=INIT");
             
+                frame = 0;
+                block = 0;
+
+#if 0 // FL: moved to PAF_ASOT_initOutProc()
                 // Reset audio frame pointers to original values
                 // (may be needed if error occurred).
-                for (z=STREAM1; z < STREAMN; z++) 
-                {
-                    Int ch;
-                    for (ch=PAF_LEFT; ch < PAF_MAXNUMCHAN_AF; ch++) 
-                    {
-                        if (pAstCfg->xStr[z].audioFrameChannelPointers[ch])
-                        {
-                            pAstCfg->xStr[z].audioFrameChannelPointers[ch] = 
-                                pAstCfg->xStr[z].origAudioFrameChannelPointers[ch];
-                        }
-                    }
-                }
-                
+                resetAfPointers(pP, pAstCfg->xStr);
                 // Reset audio frame meta data elements
-                {
-                    Int i;
-                    
-                    for (z=STREAM1; z < STREAMN; z++) 
-                    {
-                        pAstCfg->xStr[z].pAudioFrame->pafBsMetadataUpdate = XDAS_FALSE;
-                        pAstCfg->xStr[z].pAudioFrame->numPrivateMetadata = 0;
-                        pAstCfg->xStr[z].pAudioFrame->bsMetadata_offset = 0;
-                        pAstCfg->xStr[z].pAudioFrame->bsMetadata_type = PAF_bsMetadata_channelData;
+                resetAfMetadata(pP, pAstCfg->xStr);
+#endif
 
-                        for (i=0; i<pP->pMetadataBufStatus->NumBuf; i++)
-                        {
-                            pAstCfg->xStr[z].pAudioFrame->pafPrivateMetadata[i].offset = 0;
-                            pAstCfg->xStr[z].pAudioFrame->pafPrivateMetadata[i].size = 0;
-                        }
-                    }
-                }
-                
-                if (errno = pP->fxns->decodeInit(pP, pQ, pC, sourceSelect))
+                errno = pP->fxns->decodeInit(pP, pQ, pAsotCfg);
+                if (errno)
                 {
                     TRACE_VERBOSE1("PAF_ASOT_decodeProcessing: INIT, errno 0x%x.  break after decodeInit", errno);
+                    errno = ASOP_DP_DECINIT_ERR;
                     break;
                 }
                 
-                // (***) FL: setup output (ASP chain reset, ENC reset, setCheckRateX, start output)
-                //           Contained in INFO1 in combined FSM.
+                //
+                // Setup output: setCheckRateX, start output
+                //
                 // Establish secondary timing
-                if (errno = pP->fxns->decodeInfo1(pP, pQ, pC, frame, block))
+                errno = pP->fxns->decodeInfo1(pP, pQ, pAsotCfg, frame, block);
+                if (errno)
                 {
                     TRACE_VERBOSE1("PAF_ASOT_decodeProcessing: INIT, errno 0x%x.  break after decodeInfo1", errno);
                     break;
                 }
-
-                frame = 0;
-                block = 0;
-
+                
                 TRACE_VERBOSE0("PAF_ASOT_decodeProcessing: state: INIT->STREAM");                
                 state = STREAM;
                 continue;
@@ -1435,9 +1757,11 @@ PAF_ASOT_decodeProcessing(
                 gAsopStreamCnt++;
                 Log_info0("TaskAsop: state=STREAM");
 
-                if (errno = pP->fxns->decodeStream(pP, pQ, pC, frame, block))
+                errno = pP->fxns->decodeStream(pP, pQ, pAsotCfg, frame, block);
+                if (errno)
                 {
                     TRACE_TERSE1("PAF_ASOT_decodeProcessing: state: STREAM.  decodeStream err 0x%x", errno);
+                    errno = ASOP_DP_DECSTREAM_ERR;
                     break;
                 }
 
@@ -1449,40 +1773,35 @@ PAF_ASOT_decodeProcessing(
                 gAsopEncodeCnt++;
                 Log_info0("TaskAsop: state=ENCODE");
 
-                if (errno = pP->fxns->decodeEncode(pP, pQ, pC, frame, block))
+                errno = pP->fxns->decodeEncode(pP, pQ, pAsotCfg, frame, block);
+                if (errno)
                 {
                     TRACE_TERSE1("PAF_ASOT_decodeProcessing: state: ENCODE.  decodeEncode err 0x%x", errno);
+                    errno = ASOP_DP_DECENC_ERR;
                     break;
                 }
                 
                 // Measure cycles in output processing loop.
                 // Only measures cycles spent in loop.
-                pfpEnd(PFP_ID_TASK1_1, PFP_FINISH_MEAS);
-                pfpBegin(PFP_ID_TASK1_1, pC->taskHandle);
-
+                pfpEnd(PFP_ID_ASOT_1, PFP_FINISH_MEAS);
+                gNumPfpAsot1--;
+                pfpBegin(PFP_ID_ASOT_1, pAsotCfg->taskHandle);
+                gNumPfpAsot1++;
+                
                 // (***) FL: do we need this? 
                 //       AF pointers come from CB read, any resets occur in Decoder AF.
+                //
                 // Reset audio frame pointers to original values
                 // (may have been adjusted by ARC or the like).
-                for (z=STREAM1; z < STREAMN; z++) 
-                {
-                    Int ch;
-                    for (ch=PAF_LEFT; ch < PAF_MAXNUMCHAN_AF; ch++) 
-                    {
-                        if (pAstCfg->xStr[z].audioFrameChannelPointers[ch])
-                        {
-                            pAstCfg->xStr[z].audioFrameChannelPointers[ch] = 
-                                pAstCfg->xStr[z].origAudioFrameChannelPointers[ch];
-                        }
-                    }
-                }
+                resetAfPointers(pP, pAstCfg->xStr);
 
-                //
                 // (***) FL: update output (setCheckRateX)
                 //           Contained in INFO2 in combined FSM.
-                if (errno = pP->fxns->decodeInfo2(pP, pQ, pC, frame, block))
+                errno = pP->fxns->decodeInfo2(pP, pQ, pAsotCfg, frame, block);
+                if (errno)
                 {
                     TRACE_TERSE1("PAF_ASOT_decodeProcessing: ENCODE break on decodeInfo2. errno 0x%x", errno);
+                    errno = ASOP_DP_DECINFO2_ERR;
                     break;
                 }
 
@@ -1502,12 +1821,12 @@ PAF_ASOT_decodeProcessing(
                 //              will probably always exit FSM if only Output running
                 //       (2) Checking Dec Status info asych to input events (maybe ok)
                 //
-#if 0
                 // Check for final frame, and if indicated:
                 // - Update audio flag to cause output buffer flush rather than
                 //   the default truncate in "complete" processing.
                 // - Exit state machine to "complete" processing.
-                if (pP->fxns->decodeFinalTest(pP, pQ, pC, frame, block)) 
+#if 0
+                if (pP->fxns->decodeFinalTest(pP, pQ, pAsotCfg, frame, block)) 
                 {
                     for (z=OUTPUT1; z < OUTPUTN; z++)
                     {
@@ -1519,12 +1838,34 @@ PAF_ASOT_decodeProcessing(
                     }
                     break;
                 }
-#endif                
+#endif
+                errno = pP->fxns->decodeFinalTest(pP, pQ, pAsotCfg, frame, block);
+                if (errno < 0)
+                {
+                    TRACE_TERSE1("PAF_ASOT_decodeProcessing: DECODE FINAL break. errno 0x%x", errno);
+                    errno = ASOP_DP_DECFINALTEST_ERR;
+                    break;
+                }
+                else if (errno == ASOP_DP_CB_DRAINED)
+                {
+                    // EOS, exit normally
+                    TRACE_TERSE1("PAF_ASOT_decodeProcessing: DECODE FINAL normal exit. errno 0x%x", errno);
+                    errno = ASOP_DP_SOK;
+                    break;
+                }
 
                 TRACE_VERBOSE0("PAF_ASOT_decodeProcessing: state: FINAL->STREAM");
                 state = STREAM;
                 continue;
                 
+            case OUT_SIO_UPDATE:
+                gAsopOutSioUpdateCnt++;
+                Log_info0("TaskAsop: state=OUT_SIO_UPDATE");
+
+                TRACE_VERBOSE0("PAF_ASOT_decodeProcessing: state: OUT_SIO_UPDATE");
+                errno = ASOP_DP_OUT_SIO_UPDATE;
+                break;
+                
             case QUIT:
                 gAsopQuitCnt++;
                 Log_info0("TaskAsop: state=QUIT");
@@ -1545,14 +1886,21 @@ PAF_ASOT_decodeProcessing(
         }  // End of switch (state).
         
         TRACE_VERBOSE0("PAF_ASOT_decodeProcessing: Calling decode complete");
-        if (pP->fxns->decodeComplete(pP, pQ, pC, NULL, frame, block))
+        if (pP->fxns->decodeComplete(pP, pQ, pAsotCfg, NULL, frame, block))
         {
             /* ignored? */;
         }
         
-        return errno;
+        //pfpEnd(PFP_ID_ASOT_1, PFP_FINISH_MEAS); // PFP end -- outside of PFP for errors, EOS, or Output SIO change
+        //gNumPfpAsot1--;
+        
+        //return errno;
+        break;        
     } // End of for (;;)
         
+    pfpEnd(PFP_ID_ASOT_1, PFP_FINISH_MEAS); // PFP end -- outside of PFP for errors, EOS, or Output SIO change
+    gNumPfpAsot1--;
+        
     return errno;
 }
 
@@ -1574,7 +1922,7 @@ Int
 PAF_ASOT_encodeCommand(
     const PAF_ASOT_Params *pP, 
     const PAF_ASOT_Patchs *pQ, 
-    PAF_ASOT_Config *pC
+    PAF_ASOT_Config *pAsotCfg
 )
 {
     PAF_AST_Config *pAstCfg;
@@ -1584,7 +1932,7 @@ PAF_ASOT_encodeCommand(
     Int zO, zS;
 
 
-    pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
+    pAstCfg = pAsotCfg->pAstCfg; // get pointer to AST common (shared) configuration
     as = pAstCfg->as;
 
     for (z=ENCODE1; z < ENCODEN; z++) 
@@ -1648,22 +1996,20 @@ Int
 PAF_ASOT_decodeInit(
     const PAF_ASOT_Params *pP, 
     const PAF_ASOT_Patchs *pQ, 
-    PAF_ASOT_Config *pC, 
-    Int sourceSelect
+    PAF_ASOT_Config *pAsotCfg
 )
 {
-    PAF_AST_Config *pAstCfg;
+    //PAF_AST_Config *pAstCfg;
     PAF_AST_DecOpCircBufCtl *pCbCtl;    /* Decoder output circular buffer control */
-    Int as;                             /* Audio Stream Number (1, 2, etc.) */
+    //Int as;                             /* Audio Stream Number (1, 2, etc.) */
     Int z;                              /* decode/encode counter */
     Int errno;                          /* error number */
-    Int zO, zS;
+    //Int zO, zS;
 
+    //pAstCfg = pAsotCfg->pAstCfg; // get pointer to AST common (shared) configuration
+    //as = pAstCfg->as;
 
-    pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
-    as = pAstCfg->as;
-
-    pCbCtl = &pC->pAspmCfg->decOpCircBufCtl; // get pointer to circular buffer control
+    pCbCtl = &pAsotCfg->pAspmCfg->decOpCircBufCtl; // get pointer to circular buffer control
 
     for (z=DECODE1; z < DECODEN; z++)
     {
@@ -1672,17 +2018,19 @@ PAF_ASOT_decodeInit(
         if (errno)
         {
             TRACE_TERSE1("PAF_ASOT_decodeInit:cbReadStart() error=%d", errno);
-            SW_BREAKPOINT; // FL: debug
+            SW_BREAKPOINT; // debug
             return errno;
         }
         gCbReadAfErr=0;         // reset read circular buffer error count
         gDecOpCbRdAfUnd=0;      // reset decoder output circular buffer underflow count
         gMaxDecOpCbRdAfUnd=0;   // reset max decoder output circular buffer underflow count
+        gMasterCbResetCnt=0;    // reset master circular buffer reset count
 
-        // FL: debug
+        // FL: debug, log circular buffer control variables
         cbLog(pCbCtl, z, 1, "PAF_ASOT_decodeInit:cbReadStart");
     }
     
+#if 0 // moved to PAF_ASOT_outputReset()
     // TODO: move this to start of this function so that it doesn't affect IO timing
     for (z=ENCODE1; z < ENCODEN; z++) 
     {
@@ -1698,15 +2046,18 @@ PAF_ASOT_decodeInit(
             {
                 encAlg->fxns->algActivate (encAlg);
             }
-            if (enc->fxns->reset
-                && (errno = enc->fxns->reset(enc, NULL,
-                    &pAstCfg->xEnc[z].encodeControl, &pAstCfg->xEnc[z].encodeStatus)))
+            if (enc->fxns->reset)
             {
-                return errno;
+                errno = enc->fxns->reset(enc, NULL, 
+                    &pAstCfg->xEnc[z].encodeControl, &pAstCfg->xEnc[z].encodeStatus);
+                if (errno)
+                {
+                    return errno;
+                }
             }
         }
     }
-    
+#endif
     
     return 0;
 }
@@ -1728,21 +2079,23 @@ Int
 PAF_ASOT_decodeInfo1(
     const PAF_ASOT_Params *pP, 
     const PAF_ASOT_Patchs *pQ, 
-    PAF_ASOT_Config *pC
+    PAF_ASOT_Config *pAsotCfg
     Int frame, 
     Int block
 )
 {
-    PAF_AST_Config *pAstCfg;
-    Int z;                              /* decode/encode counter */
+    //PAF_AST_Config *pAstCfg;
+    //Int z;                              /* decode/encode counter */
     Int errno;                          /* error number */
 
-    pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
+#if 0 // moved to PAF_ASOT_outputInfo1()
+    pAstCfg = pAsotCfg->pAstCfg; // get pointer to AST common (shared) configuration
 
     // run the chain of ASP's on the stream.
     TRACE_VERBOSE0("PAF_ASOT_decodeInfo1: calling streamChainFunction.");
-    if (errno = pP->fxns->streamChainFunction(pP, pQ, pC, 
-        PAF_ASP_CHAINFRAMEFXNS_RESET, 1, frame))
+    errno = pP->fxns->streamChainFunction(pP, pQ, pAsotCfg, 
+        PAF_ASP_CHAINFRAMEFXNS_RESET, 1, frame);
+    if (errno)
     {
         TRACE_TERSE1("PAF_ASOT_decodeInfo1: streamChainFunction returns errno 0x%x ", errno);
         return errno;
@@ -1757,17 +2110,24 @@ PAF_ASOT_decodeInfo1(
             Int select = pAstCfg->xEnc[z].encodeStatus.select;
             ALG_Handle encAlg = pAstCfg->xEnc[z].encAlg[select];
             ENC_Handle enc = (ENC_Handle )encAlg;
-            if (enc->fxns->info
-                && (errno = enc->fxns->info(enc, NULL,
-                    &pAstCfg->xEnc[z].encodeControl, &pAstCfg->xEnc[z].encodeStatus)))
+            
+            if (enc->fxns->info)
             {
-                TRACE_TERSE1("PAF_ASOT_decodeInfo1: info returns errno 0x%x ", errno);
-                return errno;
+                errno = enc->fxns->info(enc, NULL,
+                    &pAstCfg->xEnc[z].encodeControl, 
+                    &pAstCfg->xEnc[z].encodeStatus);
+                if (errno)
+                {
+                    TRACE_TERSE1("PAF_ASOT_decodeInfo1: info returns errno 0x%x ", errno);
+                    return errno;
+                }
             }
         }
     }
+#endif    
 
-    if (errno = pP->fxns->setCheckRateX(pP, pQ, pC, 0))
+    errno = pP->fxns->setCheckRateX(pP, pQ, pAsotCfg, 0);
+    if (errno)
     {
         // ignore if rateX has changed since we haven't, but are about to,
         // start the output. If we didn't ignore this case then the state machine
@@ -1784,7 +2144,8 @@ PAF_ASOT_decodeInfo1(
         }
     }
 
-    if (errno = pP->fxns->startOutput(pP, pQ, pC)) 
+    errno = pP->fxns->startOutput(pP, pQ, pAsotCfg);
+    if (errno) 
     {
         if (errno == 0x105) 
         {
@@ -1795,7 +2156,7 @@ PAF_ASOT_decodeInfo1(
             TRACE_TERSE1("PAF_ASOT_decodeInfo1: startOutput returns errno 0x%x", errno);
         }
         return errno;
-    }    
+    }
     
     return 0;
 }
@@ -1816,7 +2177,7 @@ Int
 PAF_ASOT_decodeInfo2(
     const PAF_ASOT_Params *pP, 
     const PAF_ASOT_Patchs *pQ, 
-    PAF_ASOT_Config *pC
+    PAF_ASOT_Config *pAsotCfg
     Int frame, 
     Int block
 )
@@ -1825,13 +2186,15 @@ PAF_ASOT_decodeInfo2(
     Int errno;
 
     
-    //pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
+    //pAstCfg = pAsotCfg->pAstCfg; // get pointer to AST common (shared) configuration
 
-    errno = pP->fxns->setCheckRateX (pP, pQ, pC, 1);
+    errno = pP->fxns->setCheckRateX (pP, pQ, pAsotCfg, 1);
     TRACE_VERBOSE1("PAF_ASOT_decodeInfo2: return 0x%x", errno);
     return errno;
 } //PAF_ASOT_decodeInfo2
 
+
+PAF_AST_DecOpCircBufStats gCbStats; // FL: debug
 // -----------------------------------------------------------------------------
 // ASOT Decoding Function - Stream Processing
 //
@@ -1849,7 +2212,7 @@ Int
 PAF_ASOT_decodeStream(
     const PAF_ASOT_Params *pP, 
     const PAF_ASOT_Patchs *pQ, 
-    PAF_ASOT_Config *pC
+    PAF_ASOT_Config *pAsotCfg
     Int frame, 
     Int block
 )
@@ -1859,13 +2222,14 @@ PAF_ASOT_decodeStream(
     Int z;                              /* decode/stream counter */
     PAF_AudioFrame *pAfRd;
     Int cbErrno;
+    PAF_AST_DecOpCircBufStats cbStats;  /* circular buffer statistics */
     Int errno;
 
 
-    pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
+    pAstCfg = pAsotCfg->pAstCfg; // get pointer to AST common (shared) configuration
+    
+    pCbCtl = &pAsotCfg->pAspmCfg->decOpCircBufCtl; // get pointer to circular buffer control
     
-    pCbCtl = &pC->pAspmCfg->decOpCircBufCtl; // get pointer to circular buffer control
-
     for (z=DECODE1; z < DECODEN; z++) 
     {
         Int zS = pP->streamsFromDecodes[z];
@@ -1874,7 +2238,7 @@ PAF_ASOT_decodeStream(
         // Read decoder output circular buffer
         //
         pAfRd = pAstCfg->xStr[zS].pAudioFrame;
-        GPIOSetOutput(GPIO_PORT_0, GPIO_PIN_106);
+        //GPIOSetOutput(GPIO_PORT_0, GPIO_PIN_106);
         cbErrno = cbReadAf(pCbCtl, z, pAfRd);
         if ((cbErrno < 0) && (cbErrno != ASP_DECOP_CB_READ_UNDERFLOW))
         {
@@ -1906,7 +2270,8 @@ PAF_ASOT_decodeStream(
 
                 // Reset circular buffer
                 cbReset(pCbCtl, z);
-                Log_info0("PAF_ASOT_decodeStream:cbReset");
+                gMasterCbResetCnt++; // increment master circular buffer reset count
+                Log_info0("ASOT:cbReset");
             
                 return cbErrno;
             }
@@ -1925,7 +2290,7 @@ PAF_ASOT_decodeStream(
             gDecOpCbRdAfUnd = 0; // reset circular buffer underflow count
         }
         //Log_info0("PAF_ASOT_decodeStream:cbReadAf() complete.");
-        GPIOClearOutput(GPIO_PORT_0, GPIO_PIN_106);
+        //GPIOClearOutput(GPIO_PORT_0, GPIO_PIN_106);
         Log_info0("PAF_ASOT_decodeStream:cbReadAf() complete.");
         
 #if 0 // (***) FL: shows timing of CB read
@@ -1940,6 +2305,11 @@ PAF_ASOT_decodeStream(
             }
 #endif
 
+        // FL: debug
+        // Get circular buffer statistics (debug)
+        //cbGetStats(pCbCtl, z, &cbStats);
+        cbGetStats(pCbCtl, z, &gCbStats);
+
         // FL: debug
         cbLog(pCbCtl, z, 1, "PAF_ASOT_decodeStream:cbReadAf");
         //if (capAfWrite(pAfRd, 0) != CAP_AF_SOK)
@@ -1949,7 +2319,7 @@ PAF_ASOT_decodeStream(
     }
             
     TRACE_VERBOSE0("PAF_ASOT_outputStream: calling streamChainFunction.");
-    errno = pP->fxns->streamChainFunction(pP, pQ, pC
+    errno = pP->fxns->streamChainFunction(pP, pQ, pAsotCfg
         PAF_ASP_CHAINFRAMEFXNS_APPLY, 1, block);
     if (errno)
     {
@@ -1978,7 +2348,7 @@ Int
 PAF_ASOT_decodeEncode(
     const PAF_ASOT_Params *pP, 
     const PAF_ASOT_Patchs *pQ, 
-    PAF_ASOT_Config *pC
+    PAF_ASOT_Config *pAsotCfg
     Int frame, 
     Int block
 )
@@ -1990,7 +2360,7 @@ PAF_ASOT_decodeEncode(
     Int zX, zE, zS;
     UInt32 curTime;
 
-    pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
+    pAstCfg = pAsotCfg->pAstCfg; // get pointer to AST common (shared) configuration
     as = pAstCfg->as;
 
     // Await output buffers (but not first time)
@@ -2023,7 +2393,7 @@ PAF_ASOT_decodeEncode(
             }
             // TODO: use pC->xOut[z].pOutBuf in following ->encode call
 
-#if 0 // (***) FL: shows timing of Input Rx SIO reclaim after decoding has started (autodet complete)
+#if 0 // (***) FL: shows timing of Output Rx SIO reclaim
             // (***) debug // B8
             {
                 static Uint8 toggleState = 0;
@@ -2035,11 +2405,12 @@ PAF_ASOT_decodeEncode(
             }
 #endif            
 
+            gAsopTxSioReclaimCnt++;
+
             //
             // Simulate Tx SIO_reclaim() pend
             //
-            //Semaphore_pend(semaphoreTxAudio, BIOS_WAIT_FOREVER); 
-            gTaskAsopCnt++;
+            //Semaphore_pend(semaphoreTxAudio, BIOS_WAIT_FOREVER);
             curTime = Clock_getTicks();
             //System_printf("System time in TaskAsipFxn Tx audio = %lu\n", (ULong)curTime);
             //Log_info1("outputEncode():Tx SIO reclaim(), system time = %u", curTime);
@@ -2094,8 +2465,10 @@ PAF_ASOT_decodeEncode(
             {
                 pAstCfg->xEnc[z].encodeOutStruct.bypassFlag =
                         pP->z_pEncodeStatus[z]->encBypass;
-                if (errno = enc->fxns->encode(enc, NULL, 
-                    &pAstCfg->xEnc[z].encodeInStruct, &pAstCfg->xEnc[z].encodeOutStruct))
+                errno = enc->fxns->encode(enc, NULL, 
+                    &pAstCfg->xEnc[z].encodeInStruct, 
+                    &pAstCfg->xEnc[z].encodeOutStruct);
+                if (errno)
                 {
                     if (errno != PCEERR_OUTPUT_POINTERNULL)
                     {
@@ -2194,7 +2567,7 @@ Int
 PAF_ASOT_decodeComplete(
     const PAF_ASOT_Params *pP, 
     const PAF_ASOT_Patchs *pQ, 
-    PAF_ASOT_Config *pC
+    PAF_ASOT_Config *pAsotCfg
     ALG_Handle decAlg[], 
     Int frame, 
     Int block
@@ -2207,11 +2580,11 @@ PAF_ASOT_decodeComplete(
     Int errno;                          /* error number */
 
     
-    pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
+    pAstCfg = pAsotCfg->pAstCfg; // get pointer to AST common (shared) configuration
     as = pAstCfg->as;
     (void)as;  // clear compiler warning in case not used with tracing disabled
 
-    pCbCtl = &pC->pAspmCfg->decOpCircBufCtl; // get pointer to circular buffer control
+    pCbCtl = &pAsotCfg->pAspmCfg->decOpCircBufCtl; // get pointer to circular buffer control
     
     for (z=DECODE1; z < DECODEN; z++)
     {
@@ -2227,7 +2600,7 @@ PAF_ASOT_decodeComplete(
         cbLog(pCbCtl, z, 1, "PAF_ASOT_decodeComplete:cbReadStop");
     }
     
-    pP->fxns->streamChainFunction(pP, pQ, pC, PAF_ASP_CHAINFRAMEFXNS_FINAL, 0, frame);
+    pP->fxns->streamChainFunction(pP, pQ, pAsotCfg, PAF_ASP_CHAINFRAMEFXNS_FINAL, 0, frame);
 
     for (z=ENCODE1; z < ENCODEN; z++) 
     {
@@ -2257,7 +2630,7 @@ PAF_ASOT_decodeComplete(
     }
 
     // wait for remaining data to be output
-    pP->fxns->stopOutput(pP, pQ, pC);
+    pP->fxns->stopOutput(pP, pQ, pAsotCfg);
 
     return 0;
 } //PAF_ASOT_decodeComplete
@@ -2282,7 +2655,7 @@ Int
 PAF_ASOT_startOutput(
     const PAF_ASOT_Params *pP, 
     const PAF_ASOT_Patchs *pQ, 
-    PAF_ASOT_Config *pC
+    PAF_ASOT_Config *pAsotCfg
 ) 
 {
     PAF_AST_Config *pAstCfg;
@@ -2295,7 +2668,7 @@ PAF_ASOT_startOutput(
     PAF_SIO_IALG_Config *pAlgConfig;
 
     
-    pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
+    pAstCfg = pAsotCfg->pAstCfg; // get pointer to AST common (shared) configuration
     as = pAstCfg->as;
     zMD = pAstCfg->masterDec;
 
@@ -2384,7 +2757,7 @@ Int
 PAF_ASOT_stopOutput(
     const PAF_ASOT_Params *pP, 
     const PAF_ASOT_Patchs *pQ, 
-    PAF_ASOT_Config *pC
+    PAF_ASOT_Config *pAsotCfg
 )
 {
     PAF_AST_Config *pAstCfg;
@@ -2395,7 +2768,7 @@ PAF_ASOT_stopOutput(
     PAF_SIO_IALG_Obj    *pObj;
     PAF_SIO_IALG_Config *pAlgConfig;
 
-    pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
+    pAstCfg = pAsotCfg->pAstCfg; // get pointer to AST common (shared) configuration
     as = pAstCfg->as;
     (void)as;  // clear compiler warning in case not used with tracing disabled
 
@@ -2509,7 +2882,7 @@ Int
 PAF_ASOT_setCheckRateX(
     const PAF_ASOT_Params *pP, 
     const PAF_ASOT_Patchs *pQ, 
-    PAF_ASOT_Config *pC
+    PAF_ASOT_Config *pAsotCfg
     Int check
 )
 {
@@ -2525,7 +2898,7 @@ PAF_ASOT_setCheckRateX(
     Int zMS;
     Int zE, zX;
 
-    pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
+    pAstCfg = pAsotCfg->pAstCfg; // get pointer to AST common (shared) configuration
     zMD = pAstCfg->masterDec;
     zMS = pAstCfg->masterStr;
     zMI = pP->zone.master;
@@ -2535,13 +2908,17 @@ PAF_ASOT_setCheckRateX(
     rateI = pAstCfg->xStr[zMS].pAudioFrame->fxns->sampleRateHz
         (pAstCfg->xStr[zMS].pAudioFrame, inputRate, PAF_SAMPLERATEHZ_INV);
 
-    for (z=OUTPUT1; z < OUTPUTN; z++) {
-        if (pAstCfg->xOut[z].hTxSio && (pAstCfg->xOut[z].outBufStatus.clock & 0x01)) {
+    for (z=OUTPUT1; z < OUTPUTN; z++) 
+    {
+        if (pAstCfg->xOut[z].hTxSio && (pAstCfg->xOut[z].outBufStatus.clock & 0x01)) 
+        {
 
             // determine associated encoder
             zE = z;
-            for (zX = ENCODE1; zX < ENCODEN; zX++) {
-                if (pP->outputsFromEncodes[zX] == z) {
+            for (zX = ENCODE1; zX < ENCODEN; zX++) 
+            {
+                if (pP->outputsFromEncodes[zX] == z) 
+                {
                     zE = zX;
                     break;
                 }
@@ -2551,18 +2928,29 @@ PAF_ASOT_setCheckRateX(
             outputCount = pAstCfg->xEnc[zE].encodeStatus.frameLength;
             rateO = pAstCfg->xStr[zMS].pAudioFrame->fxns->sampleRateHz
                 (pAstCfg->xStr[zMS].pAudioFrame, outputRate, PAF_SAMPLERATEHZ_STD);
-            if (rateI > 0 && rateO > 0)
+            if ((rateI > 0) && (rateO > 0))
+            {
                 rateX = rateO /* std */ * rateI /* inv */;
+            }
             else if (inputCount != 0)
+            {
                 rateX = (float )outputCount / inputCount;
+            }
             else
+            {
                 return ( ASPERR_INFO_RATERATIO );
+            }
 
             getVal = SIO_ctrl (pAstCfg->xOut[z].hTxSio, PAF_SIO_CONTROL_SET_RATEX, (Arg) &rateX);
-            if (getVal == DOBERR_RATECHANGE) {
+            if (getVal == DOBERR_RATECHANGE) 
+            {
                 for (zx=OUTPUT1; zx < OUTPUTN; zx++)
+                {
                     if (pAstCfg->xOut[zx].hTxSio)
+                    {
                         SIO_idle (pAstCfg->xOut[zx].hTxSio);
+                    }
+                }
 
                 // this forces an exit from the calling state machine which will
                 // eventually call startOutput which calls setCheckRateX for all outputs
@@ -2571,7 +2959,9 @@ PAF_ASOT_setCheckRateX(
                 return ASPERR_INFO_RATECHANGE;
             }
             else if( getVal != SYS_OK )
+            {
                 return ((getVal & 0xff) | ASPERR_RATE_CHECK);
+            }
         }
     }
 
@@ -2596,7 +2986,7 @@ Int
 PAF_ASOT_streamChainFunction(
     const PAF_ASOT_Params *pP, 
     const PAF_ASOT_Patchs *pQ, 
-    PAF_ASOT_Config *pC
+    PAF_ASOT_Config *pAsotCfg
     Int iChainFrameFxns, 
     Int abortOnError, 
     Int logArg
@@ -2610,7 +3000,7 @@ PAF_ASOT_streamChainFunction(
     Int zX;
     Int zS;
 
-    pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
+    pAstCfg = pAsotCfg->pAstCfg; // get pointer to AST common (shared) configuration
     as = pAstCfg->as;
     (void)as; // clear compiler warning in case not used with tracing disabled
 
@@ -2691,10 +3081,10 @@ PAF_ASOT_streamChainFunction(
     return 0;
 } //PAF_ASOT_streamChainFunction
 
-/* FL: Check if at least one output selected */
+/* Check if at least one output selected */
 static Int checkOutSel(
     const PAF_ASOT_Params *pP, 
-    PAF_ASOT_Config *pC,
+    PAF_ASOT_Config *pAsotCfg,
     Int *pOutSel
 )
 {
@@ -2702,7 +3092,7 @@ static Int checkOutSel(
     Int outSel;
     Int z;
     
-    pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
+    pAstCfg = pAsotCfg->pAstCfg; // get pointer to AST common (shared) configuration
 
     outSel = 0;
     for (z=OUTPUT1; z < OUTPUTN; z++) 
@@ -2716,13 +3106,13 @@ static Int checkOutSel(
     
     *pOutSel = outSel;
 
-    return 0;
+    return ASOP_SOK;
 }
 
-/* FL: Check if at least one output sio changed */
+/* Check if at least one output sio changed */
 static Int checkOutSio(
     const PAF_ASOT_Params *pP, 
-    PAF_ASOT_Config *pC,
+    PAF_ASOT_Config *pAsotCfg,
     Int *pOutSioUpdate
 )
 {
@@ -2730,7 +3120,7 @@ static Int checkOutSio(
     Int outSioUpdate;
     Int z;
     
-    pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
+    pAstCfg = pAsotCfg->pAstCfg; // get pointer to AST common (shared) configuration
 
     outSioUpdate = 0;
     for (z=OUTPUT1; z < OUTPUTN; z++) 
@@ -2744,5 +3134,455 @@ static Int checkOutSio(
     
     *pOutSioUpdate = outSioUpdate;
 
-    return 0;    
+    return ASOP_SOK;
+}
+
+// Reset audio frames
+static Void resetAfs(
+    const PAF_ASOT_Params *pP, 
+    PAF_AST_Stream *xStr
+)
+{
+    // Reset audio frame pointers to original values
+    // (may be needed if error occurred).
+    resetAfPointers(pP, xStr);
+    // Reset audio frame meta data elements
+    resetAfMetadata(pP, xStr);
+}
+
+// Reset audio frame pointers to original values
+static Void resetAfPointers(
+    const PAF_ASOT_Params *pP, 
+    PAF_AST_Stream *xStr
+)
+{
+    Int z;
+    Int ch;
+
+    // Reset audio frame pointers to original values
+    for (z = STREAM1; z < STREAMN; z++) 
+    {
+        for (ch = PAF_LEFT; ch < PAF_MAXNUMCHAN_AF; ch++) 
+        {
+            if (xStr[z].audioFrameChannelPointers[ch])
+            {
+                xStr[z].audioFrameChannelPointers[ch] = 
+                    xStr[z].origAudioFrameChannelPointers[ch];
+            }
+        }
+    }
+}
+
+// Reset audio frame meta data elements
+static Void resetAfMetadata(
+    const PAF_ASOT_Params *pP, 
+    PAF_AST_Stream *xStr
+)
+{
+    Int z;
+    Int i;
+
+    for (z = STREAM1; z < STREAMN; z++) 
+    {
+        xStr[z].pAudioFrame->pafBsMetadataUpdate = XDAS_FALSE;
+        xStr[z].pAudioFrame->numPrivateMetadata = 0;
+        xStr[z].pAudioFrame->bsMetadata_offset = 0;
+        xStr[z].pAudioFrame->bsMetadata_type = PAF_bsMetadata_channelData;
+
+        for (i = 0; i < pP->pMetadataBufStatus->NumBuf; i++)
+        {
+            xStr[z].pAudioFrame->pafPrivateMetadata[i].offset = 0;
+            xStr[z].pAudioFrame->pafPrivateMetadata[i].size = 0;
+        }
+    }
+}
+
+// Initialize Output Processing state function
+static Int PAF_ASOT_initOutProc(
+    const PAF_ASOT_Params *pP, 
+    PAF_AST_Stream *xStr
+)
+{
+    // Reset audio frames
+    resetAfs(pP, xStr);
+    
+    return ASOP_SOK;
+}
+
+#if 0
+// Init-Sync update audio frame
+static Int initSyncUpdateAf(
+    PAF_AudioFrame *dstAf, 
+    PAF_AudioFrame *srcAf
+)
+{
+    memcpy(dstAf, srcAf, sizeof(PAF_AudioFrame));
+    
+    return ASOP_SOK;
+}
+#endif
+
+//   Purpose:   Init-Sync Dec Reset state function.
+//              Performes Dec Reset Init-Sync.
+static Int PAF_ASOT_initSyncDecReset(
+    const PAF_ASOT_Params *pP, 
+    const PAF_ASOT_Patchs *pQ, 
+    PAF_ASOT_Config *pAsotCfg,
+    PAF_AudioFrame *pDecResetAf
+)
+{
+    PAF_AST_Config *pAstCfg;            // ASIT/ASOT/ASDT shared configuration
+    Int zMD, zMS;                       // Dec and Stream Master indices
+    PAF_AudioFrame *pStrAf;             // stream audio frame
+    PAF_AST_OutInitSyncCtl *pOutIsCtl;  // Output Init-Sync control
+    Int8 decFlag;                       // dec stage flag
+    Int errno;                          // error number
+
+    
+    pAstCfg = pAsotCfg->pAstCfg;
+    zMD = pAstCfg->masterDec;
+    pOutIsCtl = &pAsotCfg->pAspmCfg->outIsCtl;
+    
+    // check for Dec Reset
+    // store dec reset AF
+    errno = outIsReadDecStageFlagAndAf(pOutIsCtl, zMD,
+        ASP_OUTIS_DEC_STAGE_RESET_IDX, &decFlag, pDecResetAf);
+    if (errno < 0)
+    {
+        return errno;
+    }
+    
+    if (decFlag == 0)
+    {
+        return ASOP_INITSYNC_NOTREADY;
+    }
+    else
+    {
+        zMS = pAstCfg->masterStr;
+        pStrAf = pAstCfg->xStr[zMS].pAudioFrame;
+        
+        // Update Stream Audio Frame.
+        // Copy Dec Reset AF to Stream AF.
+        //errno = initSyncUpdateAf(pStrAf, pDecResetAf);
+        //if (errno < 0)
+        //{
+        //    return errno;
+        //}
+        outIsCpyAf(pDecResetAf, pStrAf);
+        
+        // Enc activate
+        // Enc reset
+        errno = PAF_ASOT_outputReset(pP, pQ, pAsotCfg);
+        if (errno < 0)
+        {
+            return errno;
+        }
+        
+        return ASOP_SOK;
+    }
+}
+
+//   Purpose:   ASOT Function for Output reset
+static Int PAF_ASOT_outputReset(
+    const PAF_ASOT_Params *pP, 
+    const PAF_ASOT_Patchs *pQ, 
+    PAF_ASOT_Config *pAsotCfg
+)
+{
+    PAF_AST_Config *pAstCfg;    // ASIT/ASOT/ASDT shared configuration
+    Int as;                     // Audio Stream Number (1, 2, etc.) */
+    Int z;                      // encode counter
+    Int errno;                  // error number
+    Int zO, zS;
+
+
+    pAstCfg = pAsotCfg->pAstCfg; // get pointer to AST common (shared) configuration
+    as = pAstCfg->as;
+
+    for (z=ENCODE1; z < ENCODEN; z++) 
+    {
+        zO = pP->outputsFromEncodes[z];
+        zS = pP->streamsFromEncodes[z];
+        if (pAstCfg->xOut[zO].hTxSio && pAstCfg->xEnc[z].encodeStatus.mode) 
+        {
+            Int select = pAstCfg->xEnc[z].encodeStatus.select;
+            ALG_Handle encAlg = pAstCfg->xEnc[z].encAlg[select];
+            ENC_Handle enc = (ENC_Handle )encAlg;
+
+            TRACE_VERBOSE1("AS%d: PAF_ASOT_outputReset: initializing encode", as+zS);
+
+            if (encAlg->fxns->algActivate)
+            {
+                encAlg->fxns->algActivate(encAlg);
+            }
+            
+            if (enc->fxns->reset)
+            {
+                errno = enc->fxns->reset(enc, NULL, 
+                    &pAstCfg->xEnc[z].encodeControl, 
+                    &pAstCfg->xEnc[z].encodeStatus);
+                if (errno)
+                {
+                    return ASOP_ENCRESET_ERR;
+                }
+            }
+        }
+    }    
+    
+    return ASOP_SOK;
+}
+
+//   Purpose:   Init-Sync Dec Info1 state function.
+//              Performes Dec Info1 Init-Sync.
+static Int PAF_ASOT_initSyncDecInfo1(
+    const PAF_ASOT_Params *pP, 
+    const PAF_ASOT_Patchs *pQ, 
+    PAF_ASOT_Config *pAsotCfg,
+    PAF_AudioFrame *pDecInfo1Af
+)
+{
+    PAF_AST_Config *pAstCfg;            // ASIT/ASOT/ASDT shared configuration
+    Int zMD, zMS;                       // Dec and Stream Master indices
+    PAF_AudioFrame *pStrAf;             // stream audio frame
+    PAF_AST_OutInitSyncCtl *pOutIsCtl;  // Output Init-Sync control
+    Int8 decFlag;                       // dec stage flag
+    Int errno;                          // error number
+
+    
+    pAstCfg = pAsotCfg->pAstCfg;
+    zMD = pAstCfg->masterDec;
+    pOutIsCtl = &pAsotCfg->pAspmCfg->outIsCtl;
+    
+    // Check for Dec Reset, 
+    // Store dec reset AF
+    errno = outIsReadDecStageFlagAndAf(pOutIsCtl, zMD,
+        ASP_OUTIS_DEC_STAGE_INFO1_IDX, &decFlag, pDecInfo1Af);
+    if (errno < 0)
+    {
+        return errno;
+    }
+    
+    if (decFlag == 0)
+    {
+        return ASOP_INITSYNC_NOTREADY;
+    }
+    else
+    {
+        zMS = pAstCfg->masterStr;
+        pStrAf = pAstCfg->xStr[zMS].pAudioFrame;
+        
+        // Update Stream Audio Frame.
+        // Copy Dec Reset AF to Stream AF.
+        //errno = initSyncUpdateAf(pStrAf, pDecInfo1Af);
+        //if (errno < 0)
+        //{
+        //    return errno;
+        //}
+        outIsCpyAf(pDecInfo1Af, pStrAf);
+        
+        // outputInfo1():
+        //      - ASP chain reset,
+        //      - Enc Info
+        PAF_ASOT_outputInfo1(pP, pQ, pAsotCfg);
+        if (errno)
+        {
+            return ASOP_DECINFO1_ERR;
+        }
+        
+        return ASOP_SOK;
+    }
+}
+
+//   Purpose:   ASOT function for ASP chain reset and ENC info
+static Int PAF_ASOT_outputInfo1(
+    const PAF_ASOT_Params *pP, 
+    const PAF_ASOT_Patchs *pQ, 
+    PAF_ASOT_Config *pAsotCfg
+)
+{
+    PAF_AST_Config *pAstCfg;
+    Int z;                              /* decode/encode counter */
+    Int errno;                          /* error number */
+
+    
+    pAstCfg = pAsotCfg->pAstCfg; // get pointer to AST common (shared) configuration
+
+    // FL: frame parameter hard-coded to 0
+    // run the chain of ASP's on the stream.
+    TRACE_VERBOSE0("PAF_ASOT_decodeInfo1: calling streamChainFunction.");
+    errno = pP->fxns->streamChainFunction(pP, pQ, pAsotCfg, 
+        PAF_ASP_CHAINFRAMEFXNS_RESET, 1, 0);
+    if (errno)
+    {
+        TRACE_TERSE1("PAF_ASOT_outputInfo1: streamChainFunction returns errno 0x%x ", errno);
+        return errno;
+    }
+
+    TRACE_VERBOSE0("PAF_ASOT_outputInfo1: calling enc->info.");
+    for (z=ENCODE1; z < ENCODEN; z++) 
+    {
+        Int zO = pP->outputsFromEncodes[z];
+        if (pAstCfg->xOut[zO].hTxSio && pAstCfg->xEnc[z].encodeStatus.mode) 
+        {
+            Int select = pAstCfg->xEnc[z].encodeStatus.select;
+            ALG_Handle encAlg = pAstCfg->xEnc[z].encAlg[select];
+            ENC_Handle enc = (ENC_Handle )encAlg;
+            
+            if (enc->fxns->info)
+            {
+                errno = enc->fxns->info(enc, NULL,
+                    &pAstCfg->xEnc[z].encodeControl, 
+                    &pAstCfg->xEnc[z].encodeStatus);
+                if (errno)
+                {
+                    TRACE_TERSE1("PAF_ASOT_outputInfo1: info returns errno 0x%x ", errno);
+                    return errno;
+                }
+            }
+        }
+    }
+    
+    return 0;
+}
+
+//   Purpose:   Init-Sync Dec Decode1 state function.
+//              Performes Dec Decode1 Init-Sync.
+static Int PAF_ASOT_initSyncDecDecode1(
+    const PAF_ASOT_Params *pP, 
+    const PAF_ASOT_Patchs *pQ, 
+    PAF_ASOT_Config *pAsotCfg
+)
+{
+    PAF_AST_Config *pAstCfg;            // ASIT/ASOT/ASDT shared configuration
+    Int zMD;                            // Dec Master index
+    PAF_AST_OutInitSyncCtl *pOutIsCtl;  // Output Init-Sync control
+    Int8 decFlag;                       // dec stage flag
+    Int errno;                          // error number
+
+    
+    pAstCfg = pAsotCfg->pAstCfg;
+    zMD = pAstCfg->masterDec;
+    pOutIsCtl = &pAsotCfg->pAspmCfg->outIsCtl;
+    
+    // Check for Dec Reset, 
+    // Store dec reset AF
+    errno = outIsReadDecStageFlag(pOutIsCtl, zMD,
+        ASP_OUTIS_DEC_STAGE_DECODE1_IDX, &decFlag);
+    if (errno < 0)
+    {
+        return errno;
+    }
+    
+    if (decFlag == 0)
+    {
+        return ASOP_INITSYNC_NOTREADY;
+    }
+    else
+    {
+        return ASOP_SOK;
+    }
+}
+
+//   Purpose:   Init-Sync Re-Sync state function.
+//              Peformed Init-Sync using stored Dec Reset/Info1 AFs.
+static Int PAF_ASOT_initSyncResync(
+    const PAF_ASOT_Params *pP, 
+    const PAF_ASOT_Patchs *pQ, 
+    PAF_ASOT_Config *pAsotCfg,
+    PAF_AudioFrame *pDecResetAf,
+    PAF_AudioFrame *pDecInfo1Af    
+)
+{
+    PAF_AST_Config *pAstCfg;    // ASIT/ASOT/ASDT shared configuration
+    Int zMS;                    // Stream Master index
+    PAF_AudioFrame *pStrAf;     // stream audio frame
+    Int errno;                  // error number
+
+    
+    pAstCfg = pAsotCfg->pAstCfg;
+    zMS = pAstCfg->masterStr;
+    pStrAf = pAstCfg->xStr[zMS].pAudioFrame;
+        
+    // Reset audio frames
+    resetAfs(pP, pAstCfg->xStr);
+    
+    //
+    // Dec Reset re-sync using stored Dec Reset AF
+    //
+    
+    // Update Stream Audio Frame.
+    // Copy Dec Reset AF to Stream AF.
+    //errno = initSyncUpdateAf(pStrAf, pDecResetAf);
+    //if (errno < 0)
+    //{
+    //    return errno;
+    //}
+    outIsCpyAf(pDecResetAf, pStrAf);
+    
+    // Enc activate,
+    // Enc reset
+    errno = PAF_ASOT_outputReset(pP, pQ, pAsotCfg);
+    if (errno)
+    {
+        return errno;
+    }
+    
+    //
+    // Dec Info1 re-sync using stored Dec Info1 AF
+    //
+    
+    // Update Stream Audio Frame.
+    // Copy Dec Info1 AF to Stream AF.
+    //errno = initSyncUpdateAf(pStrAf, pDecInfo1Af);
+    //if (errno < 0)
+    //{
+    //    return errno;
+    //}
+    outIsCpyAf(pDecInfo1Af, pStrAf);
+    
+    // decodeInfo1():
+    //      - ASP chain reset,
+    //      - Enc Info
+    errno = PAF_ASOT_outputInfo1(pP, pQ, pAsotCfg);
+    if (errno)
+    {
+        return errno;
+    }
+    
+    return ASOP_SOK;    
 }
+
+//   Purpose:   Decoding Function for determining whether processing of the
+//              current stream is complete.
+Int
+PAF_ASOT_decodeFinalTest(
+    const struct PAF_ASOT_Params *pP, 
+    const struct PAF_ASOT_Patchs *pQ, 
+    struct PAF_ASOT_Config *pAsotCfg, 
+    Int frame, 
+    Int block
+)
+{
+    PAF_AST_DecOpCircBufCtl *pCbCtl;    // decoder output circular buffer control
+    Int8 drainedFlag;                   // CB drained indicator flag
+    Int zMD;                            // master Dec index
+    Int errno;                          // error number
+
+    
+    pCbCtl = &pAsotCfg->pAspmCfg->decOpCircBufCtl; // get pointer to circular buffer control
+    zMD = pAsotCfg->pAstCfg->masterDec; // get master Dec index
+
+    // Check circular buffer drain state
+    errno = cbCheckDrainState(pCbCtl, zMD, &drainedFlag);
+    if (errno < 0)
+    {
+        return errno;
+    }
+    
+    if (drainedFlag == 1)
+    {
+        return ASOP_DP_CB_DRAINED;
+    }
+    
+    return ASOP_DP_SOK;
+}