Merge remote-tracking branch 'origin/dev_psdkaudio_qin_astsplit' into dev_psdkaudio_frank
authorFrank Livingston <frank-livingston@ti.com>
Fri, 12 Aug 2016 23:17:16 +0000 (18:17 -0500)
committerFrank Livingston <frank-livingston@ti.com>
Fri, 12 Aug 2016 23:17:16 +0000 (18:17 -0500)
Conflicts:
readme_demo.txt

1  2 
procsdk_audio_x_xx_xx_xx/test_arm/.cproject
procsdk_audio_x_xx_xx_xx/test_arm/framework/audioStreamDecodeProc.c
procsdk_audio_x_xx_xx_xx/test_dsp/application/itopo/evmk2g/io.c
procsdk_audio_x_xx_xx_xx/test_dsp/framework/audioStreamInpProc.c
readme_demo.txt

index 1dd55912be70bf1dc182dda79c846bdb7e19ac54,1dd55912be70bf1dc182dda79c846bdb7e19ac54..9ec39bafb83b50462e9f8b52f80bd3abe072baf2
@@@ -11,8 -11,8 +11,8 @@@
                                        <stringMacro name="AIF2_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="CSL_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="MMCSD_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
--                                      <stringMacro name="PDK_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti/pdk_k2g_1_0_1/packages"/>
                                        <stringMacro name="ICSS_EMAC_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
++                                      <stringMacro name="PDK_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti/pdk_k2g_1_0_1/packages"/>
                                        <stringMacro name="USB_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="I2C_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="CPPI_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="IQN_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="PKTLIB_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="SRIO_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
--                                      <stringMacro name="PRUSS_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="DFE_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
++                                      <stringMacro name="PRUSS_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="PROCSDK_AUDIO_ROOT" type="VALUE_PATH_DIR" value="C:/ti/procsdk_audio_x_xx_xx_xx"/>
--                                      <stringMacro name="UART_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
--                                      <stringMacro name="FATFS_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="SBL_BOOT_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
--                                      <stringMacro name="BOARD_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
++                                      <stringMacro name="FATFS_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
++                                      <stringMacro name="UART_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="NWAL_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
++                                      <stringMacro name="BOARD_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="SPI_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                </macros>
                                <externalSettings/>
                                        <stringMacro name="AIF2_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="CSL_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="MMCSD_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
--                                      <stringMacro name="PDK_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti/pdk_k2g_1_0_1/packages"/>
                                        <stringMacro name="ICSS_EMAC_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
++                                      <stringMacro name="PDK_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti/pdk_k2g_1_0_1/packages"/>
                                        <stringMacro name="USB_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="I2C_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="CPPI_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="IQN_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="PKTLIB_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="SRIO_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
--                                      <stringMacro name="PRUSS_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="DFE_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
++                                      <stringMacro name="PRUSS_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="PROCSDK_AUDIO_ROOT" type="VALUE_PATH_DIR" value="C:/ti/procsdk_audio_x_xx_xx_xx"/>
--                                      <stringMacro name="UART_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
--                                      <stringMacro name="FATFS_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="SBL_BOOT_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
--                                      <stringMacro name="BOARD_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
++                                      <stringMacro name="FATFS_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
++                                      <stringMacro name="UART_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="NWAL_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
++                                      <stringMacro name="BOARD_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="SPI_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                </macros>
                                <externalSettings/>
index 0000000000000000000000000000000000000000,e91275a7c4a21f4ada96ad488a3630a9aebac084..e786d622ca9eda3b89fcf07f7150312330c36a31
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,3418 +1,3418 @@@
 -              // allocate Metadata buffers //QIN
+ /*
+  *  ======== audioStreamInpProc.c ========
+  */
+ #include <xdc/std.h>
+ #include <xdc/cfg/global.h>
+ #include <xdc/runtime/Diags.h>
+ #include <xdc/runtime/Error.h>
+ #include <xdc/runtime/Log.h>
+ #include <xdc/runtime/Memory.h>
+ #include <xdc/runtime/System.h>
+ #include <ti/sysbios/BIOS.h>
+ #include <ti/sysbios/hal/Hwi.h>
+ #include <ti/sysbios/hal/Cache.h>
+ #include <ti/sysbios/knl/Clock.h>
+ #include <ti/sysbios/knl/Task.h>
+ #include <ti/ipc/Ipc.h>
+ #include <ti/ipc/MessageQ.h>
+ #include <ti/ipc/MultiProc.h>
+ #include <sio.h>
+ #include <pafsio_ialg.h>
+ #include "common.h"
+ #include "paf_heapMgr.h"
+ #include "aspMsg_common.h"
+ #include "aspMsg_master.h"
+ #include "audioStreamProc_common.h"
+ #include "audioStreamInpProc.h"
+ // FL: porting
+ #include "fwkSim.h"
+ //#include "fwkPort.h"
+ // FL: debug
+ #include "dbgCapAf.h"
+ // -----------------------------------------------------------------------------
+ // Debugging Trace Control, local to this file.
+ // 
+ #include "logp.h"
+ #define TRACE_ARC(a)
+ // allows you to set a different trace module in pa.cfg
+ #define TR_MOD  trace
+ // Allow a developer to selectively enable tracing.
+ #define CURRENT_TRACE_MASK      0x21
+ #define TRACE_MASK_TERSE        0x01   // only flag errors and show init
+ #define TRACE_MASK_GENERAL      0x02   // half dozen lines per frame
+ #define TRACE_MASK_VERBOSE      0x04   // trace full operation
+ #define TRACE_MASK_DATA         0x08   // Show data
+ #define TRACE_MASK_TIME         0x10   // Timing related traces
+ #define TRACE_MASK_MSG          0x20   // Message related traces
+ #if !(CURRENT_TRACE_MASK & TRACE_MASK_TERSE)
+     #undef  TRACE_TERSE0
+     #undef  TRACE_TERSE1
+     #undef  TRACE_TERSE2
+     #undef  TRACE_TERSE3
+     #undef  TRACE_TERSE4
+     #define TRACE_TERSE0(a)
+     #define TRACE_TERSE1(a,b)
+     #define TRACE_TERSE2(a,b,c)
+     #define TRACE_TERSE3(a,b,c,d)
+     #define TRACE_TERSE4(a,b,c,d,e)
+ #endif
+ #if !(CURRENT_TRACE_MASK & TRACE_MASK_GENERAL)
+     #undef  TRACE_GEN0
+     #undef  TRACE_GEN1
+     #undef  TRACE_GEN2
+     #undef  TRACE_GEN3
+     #undef  TRACE_GEN4
+     #define TRACE_GEN0(a)
+     #define TRACE_GEN1(a,b)
+     #define TRACE_GEN2(a,b,c)
+     #define TRACE_GEN3(a,b,c,d)
+     #define TRACE_GEN4(a,b,c,d,e)
+ #endif
+ #if (CURRENT_TRACE_MASK & TRACE_MASK_VERBOSE)
+     // consolidate list of processing strings, indexed by PAF_SOURCE
+     static char *procName[] =
+     {
+         "", //PAF_SOURCE_UNKNOWN
+         "", //PAF_SOURCE_NONE
+         "AS%d: Pass processing ...",   //PAF_SOURCE_PASS
+         "AS%d: SNG processing ...",    //PAF_SOURCE_SNG
+         "AS%d: Auto processing ...",   //PAF_SOURCE_AUTO
+         "AS%d: Auto processing ...",   //PAF_SOURCE_BITSTREAM
+         "AS%d: DTS processing ...",    //PAF_SOURCE_DTSALL
+         "AS%d: PCM processing ...",    //PAF_SOURCE_PCMAUTO
+         "AS%d: PCM processing ...",    //PAF_SOURCE_PCM
+         "AS%d: PCN processing ...",    //PAF_SOURCE_PC8
+         "AS%d: AC3 processing ...",    //PAF_SOURCE_AC3
+         "AS%d: DTS processing ...",    //PAF_SOURCE_DTS
+         "AS%d: AAC processing ...",    //PAF_SOURCE_AAC
+         "AS%d: MPG processing ...",    //PAF_SOURCE_MPEG
+         "AS%d: DTS processing ...",    //PAF_SOURCE_DTS12
+         "AS%d: DTS processing ...",    //PAF_SOURCE_DTS13
+         "AS%d: DTS processing ...",    //PAF_SOURCE_DTS14
+         "AS%d: DTS processing ...",    //PAF_SOURCE_DTS16
+         "AS%d: WMP processing ...",    //PAF_SOURCE_WMA9PRO
+         "AS%d: MP3 processing ...",    //PAF_SOURCE_MP3
+         "AS%d: DSD processing ...",    //PAF_SOURCE_DSD1
+         "AS%d: DSD processing ...",    //PAF_SOURCE_DSD2
+         "AS%d: DSD processing ...",    //PAF_SOURCE_DSD3
+         "AS%d: DDP processing ...",    //PAF_SOURCE_DDP
+         "AS%d: DTSHD processing ...",  //PAF_SOURCE_DTSHD
+         "AS%d: THD processing ...",    //PAF_SOURCE_THD
+         "AS%d: DXP processing ...",    //PAF_SOURCE_DXP
+         "AS%d: WMA processing ...",    //PAF_SOURCE_WMA
+     };
+ #else
+     #undef  TRACE_VERBOSE0
+     #undef  TRACE_VERBOSE1
+     #undef  TRACE_VERBOSE2
+     #undef  TRACE_VERBOSE3
+     #undef  TRACE_VERBOSE4
+     #define TRACE_VERBOSE0(a)
+     #define TRACE_VERBOSE1(a,b)
+     #define TRACE_VERBOSE2(a,b,c)
+     #define TRACE_VERBOSE3(a,b,c,d)
+     #define TRACE_VERBOSE4(a,b,c,d,e)
+ #endif
+ #if (CURRENT_TRACE_MASK & TRACE_MASK_DATA)
+     #define TRACE_DATA(a) LOG_printf a
+ #else
+     #define TRACE_DATA(a)
+ #endif
+ #if (CURRENT_TRACE_MASK & TRACE_MASK_TIME)
+     #define TRACE_TIME(a) LOG_printf a
+     #define TIME_MOD  trace // this could be different
+     static Int dtime()
+     {
+          static Int old_time = 0;
+          Int time = TSK_time();
+          Int delta_time = time - old_time;
+          old_time = time;
+          return( delta_time);
+     }
+     static char *stateName[11] =
+     {
+          "INIT",
+          "INFO1",
+          "AGAIN",
+          "INFO2",
+          "CONT",
+          "TIME",
+          "DECODE",
+          "STREAM",
+          "ENCODE",
+          "FINAL",
+          "QUIT"
+     };
+ #else
+     #define TRACE_TIME(a)
+ #endif
+ #if !(CURRENT_TRACE_MASK & TRACE_MASK_MSG)
+     #undef  TRACE_MSG0
+     #undef  TRACE_MSG1
+     #undef  TRACE_MSG2
+     #undef  TRACE_MSG3
+     #undef  TRACE_MSG4
+     #define TRACE_MSG0(a)
+     #define TRACE_MSG1(a,b)
+     #define TRACE_MSG2(a,b,c)
+     #define TRACE_MSG3(a,b,c,d)
+     #define TRACE_MSG4(a,b,c,d,e)
+ #endif
+     
+ // .............................................................................
+ #include <pafsio.h>
+ #include "paferr.h"
+ #include <acp_mds.h>
+ #include <pcm.h>
+ #include <pce.h>
+ #include <doberr.h>
+ #include <diberr.h>
+ #include <stdasp.h>
+ #include "as0.h"
+ #include "asperr.h"
+ #include "audioStreamProc_params.h"
+ #include "audioStreamProc_patchs.h"
+ #include "audioStreamProc_config.h"
+ //
+ // Audio Stream Definitions
+ //
+ // minimum audio frame "length" in samples (must be multiple of PA_MODULO)
+ #define MINFRAMELENGTH 24
+ #define PA_MODULO       8   // also defined independently in ARC2 code, and may be hard coded other places.
+ #if 0 // (***) FL: no longer used w/ removal of CONTINUOUS mode
+ Int PAF_AST_decodeHandleErrorInput (const PAF_AST_Params *pP, const PAF_AST_Patchs *pQ, PAF_AST_Config *pC, ALG_Handle decAlg[], Int z, Int error);
+ #endif
+ //
+ // Decoder Definitions
+ //
+ //#define decLinkInit pQ->i_decLinkInit
+ //
+ // Audio Stream Processing Definitions
+ //
+ //#define aspLinkInit pQ->i_aspLinkInit
+ //
+ // Encoder Definitions
+ //
+ #define encLinkInit pQ->i_encLinkInit
+ //
+ // Input, Output Definitions
+ //
+ #define inpLinkInit pP->i_inpLinkInit
+ //#define outLinkInit pP->i_outLinkInit
+ /* ---------------------------------------------------------------- */
+ /*              Parameter macro definitions end here.               */
+ /* ---------------------------------------------------------------- */
+ //
+ // Standardized Definitions
+ //
+ //#define DEC_Handle PCM_Handle /* works for all: SNG, PCM, AC3, DTS, AAC */
+ //#define ENC_Handle PCE_Handle /* works for all: PCE */
+ #define __TASK_NAME__  "TaskAsip"
+ LINNO_DEFN(TaskAsip); /* Line number macros */
+ ERRNO_DEFN(TaskAsip); /* Error number macros */
+ // 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"
+ extern struct {
+     Int size;
+     IALG_Status *pStatus[512];
+ } IACP_STD_BETA_TABLE;
+ /*
+  *  ======== taskAsipFxn ========
+  *  Audio Stream Input Processing task function
+  */
+ Void taskAsipFxn(
+ //    Int betaPrimeValue, // FL: comeback to this
+     const PAF_AST_Params *pP,
+     const PAF_AST_Patchs *pQ
+ )
+ {
+     // Task data
+     //PAF_AST_Config PAF_AST_config;  /* Local configuration */
+     //PAF_AST_Config *pC;             /* Local configuration pointer */
+     // Local data
+     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;
+     // FL: Messaging
+     ASP_Msg *pAspMsg;
+     Int status;
+     Log_info0("Enter taskAsipFxn()");
+     
+ #ifdef SIMULATE_SIO
+     /* Start simulation */
+     simStart();
+ #endif // SIMULATE_SIO
+     //
+     // Audio Framework Configuration (*pC):
+     //
+     pC = &gPAF_AST_config;
+     TRACE_TERSE1("TaskAsip: Started with betaPrimeValue=%d.", gBetaPrimeValue);
+     as = gBetaPrimeValue + 1;        /* Audio Stream Number (1, 2, etc.) */    
+     pC->as = as;    
+     //
+     // Audio Framework Parameters & Patch (*pP, *pQ)
+     //
+     if (!pP) 
+     {
+         TRACE_TERSE1("TaskAsip: AS%d: No Parameters defined. Exiting.", as);
+         LINNO_RPRT(TaskAsip, -1);
+         return;
+     }
+     if (!pQ)
+     {
+         TRACE_TERSE1("TaskAsip: AS%d: No Patchs defined. Exiting.", as);
+         LINNO_RPRT(TaskAsip, -1);
+         return;
+     }    
+     
+     //
+     // Initialize message log trace and line number reporting
+     //
+     for (z=STREAM1; z < STREAMN; z++)
+     {
+         TRACE_TERSE1("TaskAsip: AS%d: initiated", as+z);
+     }
+     LINNO_RPRT(TaskAsip, -1);
+     
+     //
+     // Determine decoder and stream indices associated with the master input
+     //
+     zMI = pP->zone.master;
+     pC->masterDec = zMI;
+     pC->masterStr = zMI;
+     for (zX = DECODE1; zX < DECODEN; zX++)
+     {
+         if (pP->inputsFromDecodes[zX] == zMI)
+         {
+             pC->masterDec = zX;
+             pC->masterStr = pP->streamsFromDecodes[zX];
+             break;
+         }
+     }
+     zMD = pC->masterDec;
+     zMS = pC->masterStr;
+     // Initialize as per parametrized phases:
+     //
+     //   In standard form these are:
+     //      - Malloc: Memory Allocation
+     //      - Config: Configuration Initialization
+     //      - AcpAlg: ACP Algorithm Initialization and Local Attachment
+     //      - Common: Common Memory Initialization
+     //      - AlgKey: Dec/Enc chain to Array Initialization
+     //      - Device: I/O Device Initialization
+     //      - Unused: (available)
+     //      - Unused: (available)
+     //
+     LINNO_RPRT(TaskAsip, -2);
+     for (i=0; i < lengthof(pP->fxns->initPhase); i++)
+     {
+         Int linno;
+         if (pP->fxns->initPhase[i])
+         {
+             if (linno = pP->fxns->initPhase[i](pP, pQ, pC)) 
+             {
+                 LINNO_RPRT(TaskAsip, linno);
+                 return;
+             }
+         }
+         else 
+         {
+             TRACE_TERSE1("TaskAsip: AS%d: initialization phase - null", as+zMS);
+         }
+         TRACE_TERSE2("TaskAsip: AS%d: initialization phase - %d completed", as+zMS, i);
+         LINNO_RPRT(TaskAsip, -i-3);
+     }
+     //
+     // End of Initialization -- display memory usage report.
+     //
+     if (pP->fxns->memStatusPrint)
+     {
+         pP->fxns->memStatusPrint(HEAP_INTERNAL, HEAP_INTERNAL1, HEAP_EXTERNAL, HEAP_INTERNAL1_SHM);
+     }
+     
+     // (***) FL: hackin'
+     // write back configuration
+     Cache_wb(&gPAF_AST_config, sizeof(gPAF_AST_config), Cache_Type_ALLD, 0);
+     Cache_wb(&pC, sizeof(pC), Cache_Type_ALLD, 0);
+     Cache_wait();
+     // (***) FL: hackin'
+     // write Dec configuration
+     Cache_wb(&gPAF_AST_config.xDec[0], DECODEN*sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
+     Cache_wait();
+     // (***) FL: hackin'
+     // write back entire beta table
+     Cache_wb((Ptr)(&IACP_STD_BETA_TABLE.pStatus[0]), 512*sizeof(IALG_Status *), Cache_Type_ALLD, 0);
+     Cache_wait();
+     
+     // FL: send start initialization 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_START;                                                     /* fill in message payload */
+     pAspMsg->procId = hAspMsgMaster->masterProcId;
+     pAspMsg->messageId = hAspMsgMaster->messageId & ~(1<<31);
+     pAspMsg->expectResp = TRUE;
+     TRACE_MSG3("Tx ASP message: procId=%d, cmd=%d, messageId=0x%04x", pAspMsg->procId, pAspMsg->cmd, pAspMsg->messageId);
+     status = MessageQ_put(hAspMsgMaster->slaveQue, (MessageQ_Msg)pAspMsg);              /* send message */
+     if (status != MessageQ_S_SUCCESS)
+     {
+         SW_BREAKPOINT;
+     }
+     // wait for initialization complete message from slave
+     do {
+         //status = MessageQ_get(hAspMsgMaster->masterQue, (MessageQ_Msg *)&pAspMsg, MessageQ_FOREVER);
+         status = MessageQ_get(hAspMsgMaster->masterQue, (MessageQ_Msg *)&pAspMsg, 0); // FL: no other thread is allowed to run until Slave finished startup
+     } while ((status != MessageQ_S_SUCCESS) || (pAspMsg->cmd != ASP_MASTER_START_DONE));
+     if ((pAspMsg->procId != hAspMsgMaster->slaveProcId) ||
+         (pAspMsg->cmd != ASP_MASTER_START_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)
+     {
+         SW_BREAKPOINT;
+     }
+     // (***) FL: hackin'
+     // invalidate Status structure addresses for Beta Units initialized on Slave
+     Cache_inv((Ptr)(&IACP_STD_BETA_TABLE.pStatus[STD_BETA_DECODE]), sizeof(IALG_Status *), Cache_Type_ALLD, 0);
+     Cache_inv((Ptr)(&IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM]), sizeof(IALG_Status *), Cache_Type_ALLD, 0);
+     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_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");
+     
+     // (***) FL: hackin'
+     // 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();
+     
+     // (***) FL: hackin'
+     // invalidate Dec configuration
+     Cache_inv(&gPAF_AST_config.xDec[0], DECODEN*sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
+     Cache_wait();
+     
+     //
+     // Main processing loop
+     //   
+     for (z=STREAM1; z < STREAMN; z++)
+     {
+         TRACE_VERBOSE1("TaskAsip: AS%d: running", as+z);
+     }
+     TRACE_TERSE0("TaskAsip: Entering Main Loop.");
+     
+     errno = 0;
+     for (;;)
+     {
+         Int sourceSelect;
+         XDAS_Int8 sourceProgram;
+         loopCount++;
+ #if 0   // enable and tune to see startup behavior.
+         // this is an alternative to fixed/circular setting in pa.cfg.
+         // If you are searching for a memory allocation failure, disable on first round.
+         // All allocation has already happened.
+         // This is the outer loop.  This loop count goes up when the stream resets.
+         // If the stream is running without problems, this does not increment.
+         // If the stream is repeatedly resetting, this loop count will go up rapidly.
+         if (loopCount > 10)  // see traces for a few of the passes through the main loop.
+         {
+              TRACE_TERSE1("TaskAsip: Trace stopped at loop %d.", loopCount);
+              LOG_disable(&TR_MOD);  // stop tracing
+         }
+ #endif
+         TRACE_GEN2("TaskAsip (begin Main loop %d) (errno 0x%x)", loopCount, errno);
+         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);
+         // any error forces idling of input
+         if (errno) 
+         {
+             for (z=INPUT1; z < INPUTN; z++)
+             {
+                 if (pC->xInp[z].hRxSio)
+                 {
+                     SIO_idle(pC->xInp[z].hRxSio);
+                 }
+             }
+         
+             TRACE_TERSE1("TaskAsip: Trace stopped at loop %d.", loopCount);
+             ERRNO_RPRT(TaskAsip, errno);
+         }
+         
+         // Execute a TSK_sleep to ensure that any non-blocking code paths are broken
+         // up to allow lower priority tasks to run. This may seem odd to be at the top
+         // of the state machine but provides for a cleaner flow even though the very
+         // first time we enter we do a sleep which is non-intuitive.
+         TRACE_VERBOSE1("TaskAsip: AS%d: ... sleeping ...", as+zMS);
+         TRACE_TIME((&TIME_MOD, "as1-f2... + %d = %d (begin SLEEP)", dtime(), TSK_time()));
+         Task_sleep(1);
+         TRACE_GEN1("TaskAsip: AS%d: Input device selection ...", as+zMS);
+         if (errno = pP->fxns->selectDevices(pP, pQ, pC))
+         {
+             TRACE_TERSE2("TaskAsip: selectDevices returned errno = 0x%04x at line %d. AS%d", errno, as+zMS);
+             continue;
+         }
+         // if no master input selected then we don't know what may be at the input
+         // so set to unknown and skip any remaining processing
+         if (!pC->xInp[zMI].hRxSio)
+         {
+             pC->xDec[zMD].decodeStatus.sourceProgram = PAF_SOURCE_UNKNOWN;
+             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(pC->xInp[zMI].hRxSio, &pC->xInp[zMI].inpBufStatus, &pC->xInp[zMI].inpBufConfig))
+         {
+             TRACE_VERBOSE1("TaskAsip: continue as updateInputStatus returns 0x%x", errno);
+             continue;
+         }
+         
+         // If master decoder is not enabled, or the input is unlocked, then do nothing
+         if (!pC->xDec[zMD].decodeStatus.mode || !pC->xInp[zMI].inpBufStatus.lock)
+         {
+             TRACE_VERBOSE0("TaskAsip: Not locked, continue");
+             continue;
+         }
+         
+         // If no source selected then do nothing
+         if (pC->xDec[zMD].decodeStatus.sourceSelect == PAF_SOURCE_NONE) 
+         {
+             pC->xDec[zMD].decodeStatus.sourceProgram = PAF_SOURCE_NONE;
+             TRACE_VERBOSE1("TaskAsip: AS%d: no source selected, continue", as+zMS);
+             continue;
+         }
+         // If we want pass processing then proceed directly
+         if (pC->xDec[zMD].decodeStatus.sourceSelect == PAF_SOURCE_PASS) 
+         {
+             TRACE_VERBOSE1("TaskAsip: AS%d: Pass processing ...", as+zMS);
+             pC->xDec[zMD].decodeStatus.sourceProgram = PAF_SOURCE_PASS;
+             pP->fxns->sourceDecode(pP, pQ, pC, PAF_SOURCE_PASS);
+             if (pP->fxns->passProcessing)
+             {
+                 errno = pP->fxns->passProcessing(pP, pQ, pC, NULL);                
+             }
+             else 
+             {
+                 TRACE_TERSE2("TaskAsip: AS%d: Pass Processing not supported, errno 0x%x", as+zMS, ASPERR_PASS);
+                 errno = ASPERR_PASS;
+             }
+             TRACE_VERBOSE0("TaskAsip: continue");
+             continue;
+         }
+         // .....................................................................
+         // 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, pC->xDec[zMD].decodeStatus.sourceSelect, NULL)) // (***) FL: hard-coded to use PCM framelength inside function
+         {
+             TRACE_VERBOSE1("TaskAsip: autoProcessing returns 0x%x, continue", errno);
+             continue;
+         }
+         
+         // query for input type
+         if (errno = SIO_ctrl(pC->xInp[zMI].hRxSio, PAF_SIO_CONTROL_GET_SOURCEPROGRAM, (Arg )&sourceProgram))
+         {
+             TRACE_TERSE2("TaskAsip: SIO_ctrl returns 0x%x, then 0x%x, continue", errno, ASPERR_AUTO_PROGRAM);
+             errno = ASPERR_AUTO_PROGRAM;
+             continue;
+         }
+         pC->xDec[zMD].decodeStatus.sourceProgram = sourceProgram;
+         // if input is unclassifiable then do nothing
+         if (sourceProgram == PAF_SOURCE_UNKNOWN)
+         {
+             TRACE_VERBOSE0("TaskAsip: Source program unknown. continue");
+             continue;
+         }
+         // now that we have some input classification, and possibly an outstanding
+         // input frame, we determine whether or not to call decodeProcessing and with
+         // what decAlg.
+         sourceSelect = PAF_SOURCE_NONE;
+         switch (pC->xDec[zMD].decodeStatus.sourceSelect) 
+         {
+             // If autodetecting, decoding everything, and input is something
+             // (i.e. bitstream or PCM) then decode.
+             case PAF_SOURCE_AUTO:
+                 if (sourceProgram >= PAF_SOURCE_PCM)
+                 {
+                     sourceSelect = sourceProgram;                    
+                 }
+                 break;
+             // If autodetecting, decoding only PCM, and input is PCM then decode.
+             case PAF_SOURCE_PCMAUTO:
+                 if (sourceProgram == PAF_SOURCE_PCM)
+                 {
+                     sourceSelect = sourceProgram;                    
+                 }
+                 break;
+             // If autodetecting, decoding only bitstreams, and input is a bitstream then decode.
+             case PAF_SOURCE_BITSTREAM:
+                 if (sourceProgram >= PAF_SOURCE_AC3)
+                 {
+                     sourceSelect = sourceProgram;                    
+                 }
+                 break;
+             // If autodetecting, decoding only DTS, and input is DTS then decode.
+             case PAF_SOURCE_DTSALL:
+                 switch (sourceProgram) 
+                 {
+                     case PAF_SOURCE_DTS11:
+                     case PAF_SOURCE_DTS12:
+                     case PAF_SOURCE_DTS13:
+                     case PAF_SOURCE_DTS14:
+                     case PAF_SOURCE_DTS16:
+                     case PAF_SOURCE_DTSHD:
+                         sourceSelect = sourceProgram;
+                         break;
+                 }
+                 break;
+             // All others, e.g., force modes, fall through to here.
+             // If user made specific selection then program must match select.
+             // (NB: this compare relies on ordering of PAF_SOURCE)
+             default:
+                 sourceSelect = pC->xDec[zMD].decodeStatus.sourceSelect;
+                 if ((sourceSelect >= PAF_SOURCE_PCM) && (sourceSelect <= PAF_SOURCE_N))
+                 {
+                     if (sourceProgram != sourceSelect)
+                     {
+                         sourceSelect = PAF_SOURCE_NONE;                        
+                     }
+                 }
+                 break;
+         }
+         // if we didn't find any matches then skip
+         if (sourceSelect == PAF_SOURCE_NONE)
+         {
+             TRACE_VERBOSE0("TaskAsip: no matching source type, continue");
+             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)
+         {
+             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);
+         
+         TRACE_VERBOSE1(procName[sourceProgram], as+zMS);
+         TRACE_VERBOSE0("TaskAsip: calling decodeProcessing.");
+         //errno = pP->fxns->decodeProcessing(pP, pQ, pC, pC->xDec[zMD].decAlg[sourceSelect]);
+         //errno = pP->fxns->decodeProcessing(pP, pQ, pC, NULL); // (***) FL: dec handle doesn't exist on Master (DSP)
+         //errno = pP->fxns->decodeProcessing(pP, pQ, pC, NULL, sourceSelect);
+         errno = pP->fxns->decodeProcessing(pP, pQ, pC, sourceSelect);
+         if (errno) 
+         {
+             TRACE_TERSE1("TaskAsip: decodeProcessing returns 0x%x, continue", errno);
+         }
+         else
+         {
+             TRACE_VERBOSE0("TaskAsip: decodeProcessing complete with no error.");
+         }        
+         // 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)
+         {
+             SW_BREAKPOINT;
+         }
+     } // End of main processing loop for (;;)
+     
+     Log_info0("Exit taskAsipFxn()");
+ }
+ // -----------------------------------------------------------------------------
+ // ASIT Initialization Function - Memory Allocation
+ //
+ //   Name:      PAF_ASIT_initPhaseMalloc
+ //   Purpose:   Audio Stream Input Task Function for initialization of data pointers
+ //              by allocation of memory.
+ //   From:      audioStream1Task or equivalent
+ //   Uses:      See code.
+ //   States:    x
+ //   Return:    0 on success.
+ //              Source code line number on MEM_calloc failure.
+ //   Trace:     Message Log "trace" in Debug Project Configuration reports:
+ //              * State information as per parent.
+ //              * Memory allocation errors.
+ //
+ Int
+ PAF_ASIT_initPhaseMalloc(
+     const PAF_AST_Params *pP, 
+     const PAF_AST_Patchs *pQ, 
+     PAF_AST_Config *pC
+ )
+ {
+     Int as = pC->as;                    /* Audio Stream Number (1, 2, etc.) */
+     Int zMS = pC->masterStr;
+     Error_Block    eb;
+     Int i;
+     TRACE_TERSE1("PAF_ASIT_initPhaseMalloc: AS%d: initialization phase - memory allocation", as+zMS);
+     // Initialize error block
+     Error_init(&eb); 
+     /* Input memory */
+     if (!(pC->xInp = Memory_calloc((IHeap_Handle)HEAP_INTERNAL1_SHM, INPUTN * sizeof (*pC->xInp), 4, &eb)))
+     {
+         TRACE_TERSE1("PAF_AST_initPhaseMalloc: AS%d: Memory_calloc failed", as+zMS);
+         SW_BREAKPOINT;
+         return __LINE__;
+     }
+     TRACE_TERSE3("PAF_AST_initPhaseMalloc. (pC->xInp) %d bytes from space %d at 0x%x.",
+             INPUTN * sizeof (*pC->xInp),
+             HEAP_ID_INTERNAL1_SHM, (IArg)pC->xInp);
+     /* Decode memory */
+     if (!(pC->xDec = Memory_calloc((IHeap_Handle)HEAP_INTERNAL1_SHM, DECODEN * sizeof (*pC->xDec), 4, &eb)))
+     {
+         TRACE_TERSE1("PAF_AST_initPhaseMalloc: AS%d: Memory_calloc failed", as+zMS);
+         SW_BREAKPOINT;
+         return __LINE__;
+     }
+     TRACE_TERSE3("PAF_AST_initPhaseMalloc. (pC->xDec) %d bytes from space %d at 0x%x.",
+             DECODEN * sizeof (*pC->xDec),
+             HEAP_ID_INTERNAL1_SHM, (IArg)pC->xDec);
+             
+     {   
+         // FL: added for decode output circular buffer
+         // FL: (***)hackin'
+         Int z; /* decode counter */
+         
+         for (z=DECODE1; z < DECODEN; z++)
+         {
+             // allocate audio frame circular buffer
+             if (!(pC->xDec[z].decOpCb.afCb = Memory_calloc((IHeap_Handle)HEAP_INTERNAL1_SHM, PAF_DECOP_CB_MAX_NUM_AF * sizeof(PAF_AudioFrame), 4, &eb)))
+             {
+                 TRACE_TERSE1("PAF_AST_initPhaseMalloc: AS%d: Memory_calloc failed", as+zMS);
+                 SW_BREAKPOINT;
+             }
+             // allocate audio frame PCM sample pointer array
+             for (i = 0; i<PAF_DECOP_CB_MAX_NUM_AF; i++)
+             {
+                 if (!(pC->xDec[z].decOpCb.afCb[i].data.sample = Memory_calloc((IHeap_Handle)HEAP_INTERNAL1_SHM, PAF_DECOP_CB_MAX_NUM_PCM_CH * sizeof(PAF_AudioData *), 4, &eb)))
+                 {
+                     TRACE_TERSE1("PAF_AST_initPhaseMalloc: AS%d: Memory_calloc failed", as+zMS);
+                     SW_BREAKPOINT;
+                 }
+                 if (!(pC->xDec[z].decOpCb.afCb[i].data.samsiz = Memory_calloc((IHeap_Handle)HEAP_INTERNAL1_SHM, PAF_DECOP_CB_MAX_NUM_PCM_CH * sizeof(PAF_AudioSize), 4, &eb)))
+                 {
+                     TRACE_TERSE1("PAF_AST_initPhaseMalloc: AS%d: Memory_calloc failed", as+zMS);
+                     SW_BREAKPOINT;
+                 }                
+             }
+             // allocate PCM sample buffer
+             if (!(pC->xDec[z].decOpCb.pcmBuf = Memory_calloc((IHeap_Handle)HEAP_INTERNAL1_SHM, PAF_DECOP_CB_PCM_BUF_SZ * sizeof(PAF_AudioData), 4, &eb)))
+             {
+                 TRACE_TERSE1("PAF_AST_initPhaseMalloc: AS%d: Memory_calloc failed", as+zMS);
+                 SW_BREAKPOINT;
+             }
++            // allocate Metadata buffers //QIN
+             if (!(pC->xDec[z].decOpCb.metaBuf = Memory_calloc((IHeap_Handle)HEAP_INTERNAL1_SHM, PAF_DECOP_CB_MAX_NUM_AF * PAF_MAX_PRIVATE_MD_SZ * PAF_MAX_NUM_PRIVATE_MD * sizeof(Int8), 4, &eb)))
+             {
+                 TRACE_TERSE1("PAF_AST_initPhaseMalloc: AS%d: Memory_calloc failed", as+zMS);
+                 SW_BREAKPOINT;
+             }
+         }
+     }
+     
+     TRACE_TERSE1("PAF_ASIT_initPhaseMalloc: AS%d: initialization phase - memory allocation complete.", as+zMS);
+     return 0;
+ } //PAF_ASIT_initPhaseMalloc
+ // -----------------------------------------------------------------------------
+ // ASIT Initialization Function - Memory Initialization from Configuration
+ //
+ //   Name:      PAF_ASIT_initPhaseConfig
+ //   Purpose:   Audio Stream Task Function for initialization of data values
+ //              from parameters.
+ //   From:      audioStream1Task or equivalent
+ //   Uses:      See code.
+ //   States:    x
+ //   Return:    0 on success.
+ //              Other as per initFrame0 and initFrame1.
+ //   Trace:     Message Log "trace" in Debug Project Configuration reports:
+ //              * State information as per parent.
+ //
+ Int
+ PAF_ASIT_initPhaseConfig(
+     const PAF_AST_Params *pP, 
+     const PAF_AST_Patchs *pQ, 
+     PAF_AST_Config *pC
+ )
+ {
+     Int as = pC->as;                    /* Audio Stream Number (1, 2, etc.) */
+     Int z;                              /* input/encode/stream/decode/output counter */
+     Int zMS = pC->masterStr;
+     Int errno;                      /* error number */
+     PAF_DecodeOpCircBuf *pCb; // FL: decoder output circular buffer
+     TRACE_TERSE1("PAF_ASIT_initPhaseConfig: AS%d: initialization phase - configuration", as+zMS);
+     //
+     // Unspecified elements have been initialized to zero during alloc
+     //
+     
+     for (z=INPUT1; z < INPUTN; z++) 
+     {
+         pC->xInp[z].inpBufStatus = *pP->pInpBufStatus;
+         pC->xInp[z].inpBufConfig.pBufStatus = &pC->xInp[z].inpBufStatus;
+     }
+     for (z=DECODE1; z < DECODEN; z++) 
+     {
+         Int zI = pP->inputsFromDecodes[z];
+         pC->xDec[z].decodeControl.size = sizeof(pC->xDec[z].decodeControl);
+         pC->xDec[z].decodeControl.pInpBufConfig = (const PAF_InpBufConfig *)&pC->xInp[zI].inpBufConfig;
+         pC->xDec[z].decodeStatus = *pP->z_pDecodeStatus[z];
+         // Initialize decoder output circular buffer
+         // (***) FL: Ugly, here PCM is hard-coded for 256 sample dec op frame length        
+         pCb = &pC->xDec[z].decOpCb;
+         errno = cbInit(PAF_SOURCE_PCM, 256, FRAMELENGTH, pCb);
+         if (errno)
+         {
+             return errno;
+         }
+     }
+     TRACE_TERSE1("PAF_ASIT_initPhaseConfig: AS%d: initialization phase - configuration complete.", as+zMS);
+     return 0;
+ } //PAF_ASIT_initPhaseConfig
+ // -----------------------------------------------------------------------------
+ // ASIT Initialization Function - ACP Algorithm Instantiation
+ //
+ //   Name:      PAF_ASIT_initPhaseAcpAlg
+ //   Purpose:   Audio Stream Input Task Function for initialization of ACP by
+ //              instantiation of the algorithm.
+ //   From:      audioStream1Task or equivalent
+ //   Uses:      See code.
+ //   States:    x
+ //   Return:    0 on success.
+ //              Source code line number on ACP Algorithm creation failure.
+ //   Trace:     Message Log "trace" in Debug Project Configuration reports:
+ //              * State information as per parent.
+ //              * Memory allocation errors.
+ //
+ Int
+ PAF_ASIT_initPhaseAcpAlg(
+     const PAF_AST_Params *pP, 
+     const PAF_AST_Patchs *pQ, 
+     PAF_AST_Config *pC
+ )
+ {
+     Int as = pC->as;                    /* Audio Stream Number (1, 2, etc.) */
+     Int z;                              /* input/encode/stream/decode/output counter */
+     Int betaPrimeOffset;
+     ACP_Handle acp;
+     Int zMS = pC->masterStr;
+     Int zS, zX;
+     TRACE_TERSE1("PAF_ASIT_initPhaseAcpAlg: AS%d: initialization phase - ACP Algorithm", as+zMS);
+     ACP_MDS_init();
+     if (!(acp = (ACP_Handle )ACP_MDS_create(NULL))) 
+     {
+         TRACE_TERSE1("PAF_AST_initPhaseAcpAlg: AS%d: ACP algorithm instance creation failed", as+zMS);
+         return __LINE__;
+     }
+     pC->acp = acp;
+     ((ALG_Handle)acp)->fxns->algControl((ALG_Handle) acp,
+         ACP_GETBETAPRIMEOFFSET, (IALG_Status *)&betaPrimeOffset);
+     for (z=INPUT1; z < INPUTN; z++) 
+     {
+         zS = z;
+         for (zX = DECODE1; zX < DECODEN; zX++) 
+         {
+             if (pP->inputsFromDecodes[zX] == z) 
+             {
+                 zS = pP->streamsFromDecodes[zX];
+                 break;
+             }
+         }
+         acp->fxns->attach(acp, ACP_SERIES_STD,
+             STD_BETA_IB + betaPrimeOffset * (as-1+zS),
+             (IALG_Status *)&pC->xInp[z].inpBufStatus);
+         /* Ignore errors, not reported. */
+     }
+ #if 0 // FL: slave
+     for (z=DECODE1; z < DECODEN; z++) 
+     {
+         zS = pP->streamsFromDecodes[z];
+         acp->fxns->attach(acp, ACP_SERIES_STD,
+             STD_BETA_DECODE + betaPrimeOffset * (as-1+zS),
+             (IALG_Status *)&pC->xDec[z].decodeStatus);
+         /* Ignore errors, not reported. */
+     }
+ #endif
+     TRACE_TERSE1("PAF_ASIT_initPhaseAcpAlg: AS%d: initialization phase - ACP Algorithm complete.", as+zMS);
+     return 0;
+ } //PAF_ASIT_initPhaseAcpAlg
+ // -----------------------------------------------------------------------------
+ // ASIT Initialization Function - Common Memory
+ //
+ //   Name:      PAF_ASIT_initPhaseCommon
+ //   Purpose:   Audio Stream Input Task Function for allocation of common memory.
+ //   From:      audioStream1Task or equivalent
+ //   Uses:      See code.
+ //   States:    x
+ //   Return:    0 on success.
+ //              Source code line number on PAF_ALG_alloc failure.
+ //              Source code line number on PAF_ALG_mallocMemory failure.
+ //              Source code line number on Decode Chain initialization failure.
+ //              Source code line number on ASP Chain initialization failure.
+ //              Source code line number on Encode Chain initialization failure.
+ //   Trace:     Message Log "trace" in Debug Project Configuration reports:
+ //              * State information as per parent.
+ //              * Memory allocation errors.
+ //
+ Int
+ PAF_ASIT_initPhaseCommon(
+     const PAF_AST_Params *pP, 
+     const PAF_AST_Patchs *pQ, 
+     PAF_AST_Config *pC
+ )
+ {
+     Int as = pC->as;                    /* Audio Stream Number (1, 2, etc.) */
+     Int z;                              /* stream counter */
+     //Int g;                              /* gear */
+     ACP_Handle acp = pC->acp;
+     PAF_IALG_Config pafAlgConfig;
+     IALG_MemRec common[3][PAF_IALG_COMMON_MEMN+1];
+    
+     TRACE_TERSE0("PAF_ASIT_initPhaseCommon: initialization phase - Common Memory");
+     //
+     // Determine memory needs and instantiate algorithms across audio streams
+     //
+     TRACE_TERSE0("PAF_ASIT_initPhaseCommon: calling PAF_ALG_setup.");
+     PAF_ALG_setup(&pafAlgConfig, 
+         HEAP_ID_INTERNAL,       HEAP_INTERNAL, 
+         HEAP_ID_INTERNAL1,      HEAP_INTERNAL1, 
+         HEAP_ID_EXTERNAL,       HEAP_EXTERNAL, 
+         HEAP_ID_INTERNAL1_SHM,  HEAP_INTERNAL1_SHM, 
+         HEAP_CLEAR);
+     if (pP->fxns->headerPrint)
+     {
+         pP->fxns->headerPrint();        
+     }
+     for (z = STREAM1; z < STREAMN; z++) 
+     {
+         //Int zD, zE, zX;
+         TRACE_TERSE1("PAF_ASIT_initPhaseCommon: AS%d: initialization phase - Common Memory", as+z);
+         //
+         // Determine common memory for:
+         //  (1) Logical Input drivers
+         //
+         // Decode Algorithms common memory determined in ASP Slave.
+         //
+         PAF_ALG_init(common[z], lengthof(common[z]), COMMONSPACE);
+ #if 0 // FL: slave
+         zD = -1;
+         for (zX = DECODE1; zX < DECODEN; zX++) 
+         {
+             if (pP->streamsFromDecodes[zX] == z) 
+             {
+                 zD = zX;
+                 break;
+             }
+         }
+ #endif
+ #if 0 // FL: slave
+         if (zD >= 0) 
+         {
+             TRACE_TERSE3("%s.%d: calling PAF_ALG_ALLOC for decoder common[%d].", (IArg)__FUNCTION__, __LINE__, z);
+             if (PAF_ALG_ALLOC(decLinkInit[zD-DECODE1], common[z])) 
+             {
+                 TRACE_TERSE3("AS%d: %s.%d: PAF_ALG_alloc failed", as+z, (IArg)__FUNCTION__, __LINE__);
+                 TRACE_TERSE2("Failed to alloc %d bytes from space %d", common[z]->size, common[z]->space);
+         
+                 SW_BREAKPOINT;
+                 return __LINE__;
+             }
+             TRACE_TERSE3("alloced %d bytes from space %d at 0x%x", common[z]->size, common[z]->space, (IArg)common[z]->base);
+             if (pP->fxns->allocPrint)
+             {
+                 pP->fxns->allocPrint ((const PAF_ALG_AllocInit *)(decLinkInit[z-DECODE1]),sizeof (*(decLinkInit[z-DECODE1])), &pafAlgConfig);                
+             }
+         }
+ #endif
+         //
+         // Determine common memory needs of Logical Input driver
+         //
+         // really need to loop over all inputs for this stream using the tables
+         // inputsFromDecodes and streamsFromDecodes. But these don't exist for this
+         // patch, and not needed for FS11, since there is only one input.
+         if (INPUT1 <= z && z < INPUTN) 
+         {
+             TRACE_TERSE2("AS%d: PAF_ASIT_initPhaseCommon: alloc inpLinkInit common[%d]", as+z, z);
+             if (PAF_ALG_ALLOC(inpLinkInit[z-INPUT1], common[z]))
+             {
+                 TRACE_TERSE1("PAF_AST_initPhaseMalloc: AS%d: PAF_ALG_alloc failed", as+z);
+                 TRACE_TERSE2("failed to alloc %d bytes from space %d", common[z]->size, (IArg)common[z]->space);
+                 SW_BREAKPOINT;
+                 return __LINE__;
+             }
+             TRACE_TERSE3("alloced %d bytes from space %d at 0x%x", common[z]->size, common[z]->space, (IArg)common[z]->base);
+             if (pP->fxns->allocPrint)
+             {
+                 pP->fxns->allocPrint((const PAF_ALG_AllocInit *)(inpLinkInit[z-INPUT1]), sizeof (*(inpLinkInit[z-INPUT1])), &pafAlgConfig);
+             }
+         }
+     }
+     {
+         // Changes made to share scratch between zones
+         // Assume maximum 3 zones and scratch common memory is at offset 0;
+         int max=0;
+         for (z=STREAM1; z<STREAMN; z++)
+         {
+             if (max < common[z][0].size)
+             {
+                 max = common[z][0].size;
+             }
+         }
+         common[STREAM1][0].size=max;
+         for (z=STREAM1+1; z<STREAMN; z++)
+         {
+             common[z][0].size = 0;            
+         }
+     }
+         
+     //
+     // Allocate common memory for:
+     //  (1) Logical Input drivers
+     //
+     for (z = STREAM1; z < STREAMN; z++) 
+     {
+         //Int zD, zE, zX;
+         TRACE_TERSE0("PAF_ASIT_initPhaseCommon: calling PAF_ALG_mallocMemory for common space.");
+         if (PAF_ALG_mallocMemory(common[z], &pafAlgConfig)) 
+         {
+             TRACE_TERSE1("AS%d: PAF_ALG_mallocMemory failed", as+z);
+             TRACE_TERSE3("AS%d: z: %d.  Size 0x%x", as+z, z, common[z][0].size);
+             SW_BREAKPOINT;
+             return __LINE__;
+         }
+         TRACE_TERSE3("alloced %d bytes from space %d at 0x%x", common[z]->size, common[z]->space, (IArg)common[z]->base);
+         // share zone0 scratch with all zones 
+         common[z][0].base = common[0][0].base;
+         if (pP->fxns->commonPrint)
+         {
+             pP->fxns->commonPrint(common[z], &pafAlgConfig);
+         }
+ #if 0 // FL: slave
+         zD = -1;
+         for (zX = DECODE1; zX < DECODEN; zX++) 
+         {
+             if (pP->streamsFromDecodes[zX] == z) 
+             {
+                 zD = zX;
+                 break;
+             }
+         }
+ #endif
+ #if 0 // FL: slave
+         if (zD >= 0) 
+         {
+             PAF_ASP_Chain *chain;
+             TRACE_TERSE2("PAF_ASIT_initPhaseCommon: calling PAF_ASP_chainInit for decode.");
+             chain = PAF_ASP_chainInit(&pC->xDec[zD].decChainData, pP->pChainFxns,
+                 HEAP_INTERNAL, as+z, acp, &trace,
+                 decLinkInit[zD-DECODE1], NULL, common[z], &pafAlgConfig);
+             if (!chain) 
+             {
+                 TRACE_TERSE1("AS%d: Decode chain initialization failed", as+z);
+                 return __LINE__;
+             }
+         }
+ #endif
+         //
+         // Allocate non-common memories for Logical IO drivers
+         //    Since these structures are used at run-time we allocate from external memory
+         if (INPUT1 <= z && z < INPUTN) 
+         {
+             PAF_ASP_Chain *chain;
+             TRACE_TERSE2("PAF_AST_initPhaseMalloc: AS%d: non-common input chain init for %d",
+                            as+z, z);
+             chain = PAF_ASP_chainInit(&pC->xInp[z].inpChainData, pP->pChainFxns,
+                         HEAP_EXTERNAL, as+z, acp, &trace,
+                         inpLinkInit[z-INPUT1], NULL, common[z], &pafAlgConfig);
+             if (!chain) 
+             {
+                 TRACE_TERSE1("AS%d: Input chain initialization failed", as+z);
+                 return __LINE__;
+             }
+         }
+     }
+     TRACE_TERSE1("AS%d: PAF_ASIT_initPhaseCommon: Returning complete.", as+z);
+     return 0;
+ } //PAF_ASIT_initPhaseCommon
+ // -----------------------------------------------------------------------------
+ // ASIT Initialization Function - Algorithm Keys
+ //
+ //   Name:      PAF_ASIT_initPhaseAlgKey
+ //   Purpose:   Audio Stream Input Task Function for initialization of data values
+ //              from parameters for Algorithm Keys.
+ //   From:      audioStream1Task or equivalent
+ //   Uses:      See code.
+ //   States:    x
+ //   Return:    0.
+ //   Trace:     Message Log "trace" in Debug Project Configuration reports:
+ //              * State information as per parent.
+ //
+ // .............................................................................
+ Int
+ PAF_ASIT_initPhaseAlgKey(
+     const PAF_AST_Params *pP, 
+     const PAF_AST_Patchs *pQ, 
+     PAF_AST_Config *pC
+ )
+ {
+     Int as = pC->as;                    /* Audio Stream Number (1, 2, etc.) */
+ #if 0
+     Int z;                              /* decode/encode counter */
+     Int s;                              /* key number */
+     PAF_ASP_Link *that;
+ #endif
+     (void)as;  // clear compiler warning in case not used with tracing disabled
+     TRACE_VERBOSE1("PAF_ASIT_initPhaseAlgKey: AS%d: initialization phase - Algorithm Keys", as);
+ #if 0 // FL: slave    
+     for (z=DECODE1; z < DECODEN; z++) 
+     {
+         for (s=0; s < pP->pDecAlgKey->length; s++) 
+         {
+             if ((pP->pDecAlgKey->code[s].full != 0) &&
+                 (that = PAF_ASP_chainFind (&pC->xDec[z].decChainData, pP->pDecAlgKey->code[s]))) 
+             {
+                 pC->xDec[z].decAlg[s] = (ALG_Handle )that->alg;
+                 /* Cast in interface, for now --Kurt */
+             }
+             else
+             {
+                 pC->xDec[z].decAlg[s] = NULL;
+             }
+         }
+     }
+ #endif
+     return 0;
+ } //PAF_ASIT_initPhaseAlgKey
+ // -----------------------------------------------------------------------------
+ // ASIT Initialization Function - I/O Devices
+ //
+ //   Name:      PAF_ASIT_initPhaseDevice
+ //   Purpose:   Audio Stream Input Task Function for initialization of I/O Devices.
+ //   From:      audioStream1Task or equivalent
+ //   Uses:      See code.
+ //   States:    x
+ //   Return:    0 on success.
+ //              Source code line number on device allocation failure.
+ //   Trace:     Message Log "trace" in Debug Project Configuration reports:
+ //              * State information as per parent.
+ //              * Memory allocation errors.
+ //
+ Int
+ PAF_ASIT_initPhaseDevice(
+     const PAF_AST_Params *pP, 
+     const PAF_AST_Patchs *pQ, 
+     PAF_AST_Config *pC
+ )
+ {
+     Int as = pC->as;                    /* Audio Stream Number (1, 2, etc.) */
+     Int z;                              /* input/output counter */
+     PAF_SIO_IALG_Obj    *pObj;
+     PAF_SIO_IALG_Config *pAlgConfig;
+     PAF_IALG_Config pafAlgConfig;
+     (void)as; // clear compiler warning in case not used with tracing disabled
+     TRACE_TERSE1("PAF_ASIT_initPhaseDevice: AS%d: initialization phase - I/O Devices", as);
+     if(pP->fxns->bufMemPrint)
+     {
+         PAF_ALG_setup (&pafAlgConfig, 
+             HEAP_ID_INTERNAL,       HEAP_INTERNAL, 
+             HEAP_ID_INTERNAL1,      HEAP_INTERNAL1,
+             HEAP_ID_EXTERNAL,       HEAP_EXTERNAL,
+             HEAP_ID_INTERNAL1_SHM,  HEAP_INTERNAL1_SHM,
+             HEAP_CLEAR);
+         TRACE_TERSE2("PAF_ASIT_initPhaseDevice: AS%d: calling PAF_ALG_setup with clear at %d.", as, HEAP_CLEAR);
+     }
+     for (z=INPUT1; z < INPUTN; z++) 
+     {
+         PAF_InpBufConfig *pConfig = &pC->xInp[z].inpBufConfig;
+         pObj = (PAF_SIO_IALG_Obj *)pC->xInp[z].inpChainData.head->alg;
+         pAlgConfig = &pObj->config;
+         pC->xInp[z].hRxSio = NULL;
+         pConfig->base.pVoid       = pAlgConfig->pMemRec[0].base;
+         pConfig->pntr.pVoid       = pAlgConfig->pMemRec[0].base;
+         pConfig->head.pVoid       = pAlgConfig->pMemRec[0].base;
+         pConfig->futureHead.pVoid = pAlgConfig->pMemRec[0].base;
+         pConfig->allocation       = pAlgConfig->pMemRec[0].size;
+         pConfig->sizeofElement    = 2;
+         pConfig->precision        = 16;
+         if(pP->fxns->bufMemPrint)
+         {
+             pP->fxns->bufMemPrint(z,pAlgConfig->pMemRec[0].size,PAF_ALG_memSpaceToHeapId(&pafAlgConfig,pAlgConfig->pMemRec[0].space),0);            
+         }
+     }
+     TRACE_TERSE1("PAF_ASIT_initPhaseDevice: AS%d: initialization phase - I/O Devices complete.", as);
+     return 0;
+ } //PAF_ASIT_initPhaseDevice
+ #if 0
+ // -----------------------------------------------------------------------------
+ // AST Processing Function - Pass-Through Processing
+ //
+ //   Name:      PAF_AST_passProcessing
+ //   Purpose:   Audio Stream Task Function for processing audio data as a
+ //              pass-through from the input driver to the output driver
+ //              for development and testing.
+ //   From:      audioStream1Task or equivalent
+ //   Uses:      See code.
+ //   States:    x
+ //   Return:    Error number in standard form (0 on success).
+ //   Trace:     Message Log "trace" in Debug Project Configuration reports:
+ //              * State information on initialization.
+ //              * State information on processing.
+ //
+ #pragma CODE_SECTION(PAF_AST_passProcessing,".text:_PAF_AST_passProcessing")
+ /* Pass Processing is often omitted from builds to save memory, */
+ /* and CODE_SECTION/clink constructs facilitate this omission.  */
+ Int
+ PAF_AST_passProcessing (const PAF_AST_Params *pP, const PAF_AST_Patchs *pQ, PAF_AST_Config *pC, Int hack)
+ {
+     Int z;                              /* input/output counter */
+     Int errno = 0;                      /* error number */
+     Int getVal;
+     Int rxNumChan, txNumChan;
+     Int first;
+     Int zMD = pC->masterDec;
+     Int zMI = pP->zone.master;
+ #ifndef __TI_EABI__
+     asm (" .clink"); /* See comment above regarding CODE_SECTION/clink. */
+ #endif    
+     TRACE_VERBOSE0("PAF_AST_passProcessing: initializing");
+     //
+     // Determine that receive/transmit channels are compatible
+     //
+     // Can handle handle only master input
+     for (z=INPUT1; z < INPUTN; z++) {
+         if (z != zMI && pC->xInp[z].hRxSio)
+             return (ASPERR_PASS + 0x01);
+     }
+     /* Number of receive/transmit channels */
+     if (! pC->xInp[zMI].hRxSio)
+         return (ASPERR_PASS + 0x11);
+     if (SIO_ctrl (pC->xInp[zMI].hRxSio, PAF_SIO_CONTROL_GET_NUMCHANNELS, (Arg) &rxNumChan))
+         return (ASPERR_PASS + 0x12);
+     if (rxNumChan > NUM_TX_CHAN(zMI))
+         return (ASPERR_PASS + 0x13);
+     for (z=OUTPUT1; z < OUTPUTN; z++) {
+         if (! pC->xOut[zMI].hTxSio)
+             return (ASPERR_PASS + 0x10*(z+2) + 0x01);
+         if (SIO_ctrl (pC->xOut[z].hTxSio, PAF_SIO_CONTROL_GET_NUMCHANNELS, (Arg) &txNumChan))
+             return (ASPERR_PASS + 0x10*(z+2) + 0x02);
+         if (txNumChan > NUM_TX_CHAN(zMI))
+             return (ASPERR_PASS + 0x10*(z+2) + 0x03);
+     }
+     //
+     // Set up receive/transmit
+     //
+     SIO_idle (pC->xInp[zMI].hRxSio);
+     for (z=OUTPUT1; z < OUTPUTN; z++) {
+         if(SIO_idle (pC->xOut[z].hTxSio))
+             return ASPERR_IDLE;
+     }
+     if (SIO_ctrl (pC->xInp[zMI].hRxSio, PAF_SIO_CONTROL_SET_SOURCESELECT, PAF_SOURCE_PCM))
+         return (ASPERR_PASS + 0x14);
+     if (SIO_ctrl (pC->xInp[zMI].hRxSio, PAF_SIO_CONTROL_SET_PCMFRAMELENGTH, FRAMELENGTH))
+         return (ASPERR_PASS + 0x15);
+     for (z=OUTPUT1; z < OUTPUTN; z++)
+         pC->xOut[z].outBufConfig.lengthofFrame = FRAMELENGTH;
+     if (SIO_issue (pC->xInp[zMI].hRxSio, &pC->xInp[zMI].inpBufConfig, sizeof (pC->xInp[zMI].inpBufConfig), PAF_SIO_REQUEST_SYNC))
+         return ASPERR_PASS + 0x16;
+     if (SIO_reclaim (pC->xInp[zMI].hRxSio, (Ptr)&pC->xInp[zMI].pInpBuf, NULL) != sizeof (PAF_InpBufConfig))
+         return ASPERR_PASS + 0x17;
+     //
+     // Receive and transmit the data in single-frame buffers
+     //
+     first = 1;
+     while (pC->xDec[zMD].decodeStatus.sourceSelect == PAF_SOURCE_PASS) {
+         PAF_OutBufConfig *pOutBuf;
+         PAF_InpBufConfig *pInpBuf;
+         if (first) {
+             first = 0;
+             TRACE_VERBOSE0("PAF_AST_passProcessing: starting output");
+             for (z=OUTPUT1; z < OUTPUTN; z++) {
+                 getVal = SIO_issue (pC->xOut[z].hTxSio, &pC->xOut[z].outBufConfig, sizeof(pC->xOut[z].outBufConfig), 0);
+                 if (getVal > 0) {
+                     errno = ASPERR_ISSUE;
+                     break;
+                 }
+                 else if (getVal < 0) {
+                     errno = -getVal;
+                     break;
+                 }
+                 if (getVal = SIO_ctrl (pC->xOut[z].hTxSio, PAF_SIO_CONTROL_UNMUTE, 0))
+                     return (getVal & 0xff) | ASPERR_MUTE;
+             }
+             if (errno)
+                 break;
+         }
+         getVal = SIO_issue (pC->xInp[zMI].hRxSio, &pC->xInp[zMI].inpBufConfig, sizeof (pC->xInp[zMI].inpBufConfig), PAF_SIO_REQUEST_NEWFRAME);
+         if (getVal > 0) {
+             errno = ASPERR_ISSUE;
+             break;
+         }
+         TRACE_VERBOSE1("PAF_AST_passProcessing: awaiting frame -- input size %d", rxNumChan * FRAMELENGTH);
+         getVal = SIO_reclaim (pC->xInp[zMI].hRxSio, (Ptr) &pInpBuf, NULL);
+         if (getVal < 0) {
+             errno = -getVal;
+             break;
+         }
+         for (z=OUTPUT1; z < OUTPUTN; z++) {
+             getVal = SIO_reclaim (pC->xOut[z].hTxSio, (Ptr) &pOutBuf, NULL);
+             if (getVal < 0) {
+                 errno = -getVal;
+                 break;
+             }
+         }
+         if( errno )
+             break;
+         TRACE_VERBOSE0("PAF_AST_passProcessing: copying frame");
+         if (errno = pP->fxns->passProcessingCopy (pP, pQ, pC))
+             break;
+         for (z=OUTPUT1; z < OUTPUTN; z++) {
+             getVal = SIO_issue (pC->xOut[z].hTxSio, &pC->xOut[z].outBufConfig, sizeof(pC->xOut[z].outBufConfig), 0);
+             if (getVal > 0) {
+                 errno = ASPERR_ISSUE;
+                 break;
+             }
+             else if (getVal < 0) {
+                 errno = -getVal;
+                 break;
+             }
+         }
+         if( errno )
+             break;
+     }
+     //
+     // Close down receive/transmit
+     //
+     TRACE_TERSE0("PAF_AST_passProcessing: finalizing"));
+     for (z=OUTPUT1; z < OUTPUTN; z++) {
+         if (getVal = SIO_ctrl (pC->xOut[z].hTxSio, PAF_SIO_CONTROL_MUTE, 0)) {
+             if (! errno)
+                 errno = (getVal & 0xff) | ASPERR_MUTE;
+             /* convert to sensical errno */
+         }
+     }
+     SIO_idle (pC->xInp[zMI].hRxSio);
+     for (z=OUTPUT1; z < OUTPUTN; z++)
+         SIO_idle (pC->xOut[z].hTxSio);
+     return errno;
+ } //PAF_AST_passProcessing
+ #endif
+ #if 0
+ // -----------------------------------------------------------------------------
+ // AST Processing Function Helper - Pass-Through Processing Patch Point
+ //
+ //   Name:      PAF_AST_passProcessingCopy
+ //   Purpose:   Pass-Through Processing Function for copying audio data
+ //              from the input buffer to the output buffer.
+ //   From:      AST Parameter Function -> passProcessing
+ //   Uses:      See code.
+ //   States:    x
+ //   Return:    Error number in standard form (0 on success).
+ //   Trace:     Message Log "trace" in Debug Project Configuration reports:
+ //              x
+ //
+ #pragma CODE_SECTION(PAF_AST_passProcessingCopy,".text:_PAF_AST_passProcessingCopy")
+ /* Pass Processing is often omitted from builds to save memory, */
+ /* and CODE_SECTION/clink constructs facilitate this omission.  */
+ Int
+ PAF_AST_passProcessingCopy (const PAF_AST_Params *pP, const PAF_AST_Patchs *pQ, PAF_AST_Config *pC)
+ {
+     Int z;                              /* output counter */
+     Int errno;                          /* error number */
+     Int i;
+     Int rxNumChan, txNumChan;
+     Int zMI = pP->zone.master;
+     asm (" .clink"); /* See comment above regarding CODE_SECTION/clink. */
+     // Copy data from input channels to output channels one of two ways:
+     if (SIO_ctrl (pC->xInp[zMI].hRxSio, PAF_SIO_CONTROL_GET_NUMCHANNELS, (Arg) &rxNumChan))
+         return (ASPERR_PASS + 0x12);
+     for (z=OUTPUT1; z < OUTPUTN; z++) {
+         if (SIO_ctrl (pC->xOut[z].hTxSio, PAF_SIO_CONTROL_GET_NUMCHANNELS, (Arg) &txNumChan))
+             return (ASPERR_PASS + 0x22);
+         if( txNumChan <= rxNumChan ) {
+             // Copy one to one, ignoring later rx channels as needed.
+             for( i=0; i < txNumChan; i++ ) {
+                 errno = pP->fxns->copy( i, &pC->xInp[zMI].inpBufConfig, i, &pC->xOut[z].outBufConfig );
+                 if( errno )
+                     return errno;
+             }
+         }
+         else {
+             // Copy one to many, repeating earlier rx channels as needed.
+             Int from, to;
+             from = 0;
+             to   = 0;
+             while( to < txNumChan ) {
+                 errno = pP->fxns->copy( from, &pC->xInp[zMI].inpBufConfig, to, &pC->xOut[z].outBufConfig );
+                 if( errno )
+                     return errno;
+                 from++;
+                 to++;
+                 if( from == rxNumChan )
+                     from = 0;
+             }
+         }
+     }
+     return 0;
+ } //PAF_AST_passProcessingCopy
+ #endif
+ // -----------------------------------------------------------------------------
+ // ASIT Processing Function - Auto Processing
+ //
+ //   Name:      PAF_ASIT_autoProcessing
+ //   Purpose:   Audio Stream Input Task Function for processing audio data to
+ //              determine the input type without output.
+ //   From:      audioStream1Task or equivalent
+ //   Uses:      See code.
+ //   States:    x
+ //   Return:    Error number in standard or SIO form (0 on success).
+ //   Trace:     Message Log "trace" in Debug Project Configuration reports:
+ //              * State information on initialization.
+ //
+ #define DECSIOMAP(X)                                                \
+     pP->pDecSioMap->map[(X) >= pP->pDecSioMap->length ? 0 : (X)]
+ Int
+ PAF_ASIT_autoProcessing(
+     const PAF_AST_Params *pP, 
+     const PAF_AST_Patchs *pQ, 
+     PAF_AST_Config *pC, 
+     Int inputTypeSelect, 
+     ALG_Handle pcmAlgMaster
+ )
+ {
+     Int as = pC->as;                    /* Audio Stream Number (1, 2, etc.) */
+     Int errno = 0;                      /* error number */
+     Int nbytes;
+     Int frameLength;
+     Int zMD = pC->masterDec;
+     Int zMI = pP->zone.master;
+     Int zMS = pC->masterStr;
+     TRACE_VERBOSE1("PAF_AST_autoProcessing: AS%d: PAF_AST_autoProcessing", as+zMS);
+     if (errno = SIO_ctrl (pC->xInp[zMI].hRxSio,
+                           PAF_SIO_CONTROL_SET_SOURCESELECT,
+                           DECSIOMAP (pC->xDec[zMD].decodeStatus.sourceSelect)))
+     {
+         TRACE_VERBOSE2("PAF_AST_autoProcessing: AS%d: source select returns 0x%x", as+zMS, errno);
+         return errno;
+     }
+     //frameLength = pP->fxns->computeFrameLength (pcmAlgMaster, FRAMELENGTH,
+     //                                            pC->xDec[zMD].decodeStatus.bufferRatio);
+     frameLength = FRAMELENGTH; // FL: fix PCM frameLength, hack for demo.
+     if (errno = SIO_ctrl (pC->xInp[zMI].hRxSio,
+                           PAF_SIO_CONTROL_SET_PCMFRAMELENGTH, frameLength))
+     {
+         TRACE_VERBOSE2("PAF_AST_autoProcessing: SET_PCMFRAMELENGTH returns 0x%x, returning ASPERR_AUTO_LENGTH, 0x%x",
+             errno, ASPERR_AUTO_LENGTH);
+         return ASPERR_AUTO_LENGTH;
+     }
+     if (errno = SIO_issue (pC->xInp[zMI].hRxSio,
+                            &pC->xInp[zMI].inpBufConfig, sizeof (pC->xInp[zMI].inpBufConfig),
+                            PAF_SIO_REQUEST_SYNC))
+     {
+         TRACE_VERBOSE2("PAF_AST_autoProcessing: REQUEST_SYNC returns 0x%x, returning ASPERR_ISSUE, 0x%x",
+             errno, ASPERR_ISSUE);
+         return ASPERR_ISSUE;
+     }
+     TRACE_VERBOSE1("PAF_AST_autoProcessing: AS%d: awaiting sync", as+zMS);
+     // all of the sync scan work is done in this call. If the error returned
+     // is DIBERR_SYNC then that just means we didn't find a sync, not a real I/O
+     // error so we mask it off.
+     nbytes = SIO_reclaim (pC->xInp[zMI].hRxSio, (Ptr)&pC->xInp[zMI].pInpBuf, NULL);
+     if (nbytes == -DIBERR_SYNC)
+     {
+         TRACE_TERSE2("PAF_AST_autoProcessing: AS%d: SIO_reclaim returned 0x%x, ignoring", as+zMS, nbytes);
+         return 0;
+     }
+     if (nbytes != sizeof (PAF_InpBufConfig))
+     {
+         TRACE_TERSE3("PAF_AST_autoProcessing. SIO_reclaim returned %d, not %d, returning ASPERR_RECLAIM (0x%x)",
+                      nbytes, sizeof (PAF_InpBufConfig), ASPERR_RECLAIM);
+         return ASPERR_RECLAIM;
+     }
+     if (errno)
+     {
+         TRACE_TERSE2("PAF_AST_autoProcessing: AS%d: returning errno 0x%x", as+zMS, errno);
+     }
+     return errno;
+ } //PAF_ASIT_autoProcessing
+ // -----------------------------------------------------------------------------
+ // ASIT Processing Function - Decode Processing
+ //
+ //   Name:      PAF_ASIT_decodeProcessing
+ //   Purpose:   Audio Stream Input Task Function for processing audio data.
+ //   From:      audioStream1Task or equivalent
+ //   Uses:      See code.
+ //   States:    x
+ //   Return:    Error number in standard form (0 on success).
+ //   Trace:     Message Log "trace" in Debug Project Configuration reports:
+ //              * State information on initialization (via children).
+ //              * State information on processing (via children).
+ //              * Decode warnings.
+ //
+ // When "writeDECModeContinuous" is used for zMI input/decode:
+ // PAF_AST_decodeProcessing() loop may be (is designed to be) exited:
+ // (a) if "writeDECCommandRestart" is used
+ //    (or "writeDECCommandAbort", but this performs no cleanup whatsoever, and so its use is discouraged)
+ // (b) if "writeDECSourceSelectNone" is used
+ // [ the latter events lead to QUIT state, simply for exiting (errme = errno = ASPERR_QUIT)
+ // (c) if an error occurs in
+ //     INIT
+ //     CONT ("subsequent block state", which "Establish[es] secondary timing")
+ //         -> PAF_AST_decodeCont(): "Await slave inputs"
+ //     STREAM (errno |= PAF_COMPONENT_ASP)
+ //     ENCODE (errno |= PAF_COMPONENT_ENCODE)
+ // [ the latter errors lead to "switch_break:"
+ //         -> PAF_AST_decodeComplete(), which always returns 0 (no error) ]
+ //
+ // [ Notably, in FINAL ("frame-finalization state")
+ //         -> PAF_AST_decodeFinalTest() is *not* called,
+ //   and so any other (asynchronous) changes in pC->xDec[zMD].decodeStatus.sourceSelect are ignored. ]
+ // [ For completeness, note also: "default" state, internal check (errme = errno = ASPERR_UNKNOWNSTATE) ]
+ //
+ // States in which error can't occur:
+ //     AGAIN ("subsequent initial state")
+ //
+ // States in which (some) errors must be handled:
+ //     INFO1 ("first frame state")
+ //         -> PAF_AST_decodeInfo(): pass on ASPERR_INFO_RATECHANGE, ASPERR_INFO_PROGRAM ("bad" internal error)
+ //            -> *DONE* must "catch" ASPERR_RECLAIM from SIO_reclaim (pC->xInp[zMI].hRxSio) -- note zMI only **
+ //               ?*? but what about ASPERR_RESYNC from same call ?*?
+ //            -> *for now, at least, pass on error from pP->fxns->updateInputStatus ()*
+ //            -> *DONE* must "catch" error from (zMI) dec->fxns->info() **
+ //         -> PAF_AST_decodeInfo1(): pass on any errors which occur here:
+ //            - pP->fxns->streamChainFunction (... PAF_ASP_CHAINFRAMEFXNS_RESET)
+ //            - enc->fxns->info()
+ //            - pP->fxns->setCheckRateX()
+ //            - pP->fxns->startOutput()
+ //            - "Start slave inputs if necessary"
+ //     INFO2 ("subsequent frame state")
+ //         -> PAF_AST_decodeInfo(): (see above)
+ //         -> PAF_AST_decodeInfo2(): pass on any errors which occur here:
+ //            - pP->fxns->setCheckRateX()
+ //     TIME ("timing state")
+ //         -> PAF_AST_decodeTime(): "Special timing consideations for AC-3"
+ //         -> performs SIO_issue (... PAF_SIO_REQUEST_FULLFRAME) & SIO_reclaim() *for zMI only*
+ //         -> now, DIB_issue [PAF_SIO_REQUEST_FULLFRAME] would only return SYS_EINVAL for "bad" internal error
+ //            (*OK* don't try to recover from this*)
+ //         -> much more likely would be SIO_reclaim() error (ASPERR_RECLAIM)
+ //         -> *DONE* must "catch" (just) ASPERR_RECLAIM error -- note zMI only,
+ //            possibly in PAF_AST_decodeProcessing() itself **
+ //     DECODE ("decode state")
+ //         -> PAF_AST_decodeDecode(): pass on error from
+ //            - PAF_SIO_CONTROL_GET_NUM_REMAINING ("bad" internal error)
+ //            - dec->fxns->reset()
+ //            - PAF_SIO_CONTROL_SET_PCMFRAMELENGTH
+ //         -> *DONE* must catch error from (zMI) dec->fxns->decode()
+ //         -> *?* must catch ASPERR_ISSUE from (zMI) SIO_issue()
+ Int
+ PAF_ASIT_decodeProcessing(
+     const PAF_AST_Params *pP, 
+     const PAF_AST_Patchs *pQ, 
+     PAF_AST_Config *pC, 
+     Int sourceSelect
+ )
+ {
+     //Int as = pC->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 = pC->masterDec;
+     Int zMS = pC->masterStr;
+     Int size;
+     //PAF_InpBufConfig *pIpBufConfig;
+     Int frame; // decoder input frame count
+     Int block; // (***) FL: formerly  -- decoder output block count / input frame
+     for (z=DECODE1; z < DECODEN; z++)
+         alg[z] = pC->xDec[z].decAlg[PAF_SOURCE_PCM];
+     alg[zMD] = NULL; // decAlgMaster; // FL: alg[] init is on slave
+     //
+     // Receive and process the data in single-frame buffers
+     //
+     state = INIT;
+     errno = 0; /* error number */
+     TRACE_TERSE1("PAF_AST_decodeProcessing: sourceSelect is %d", pC->xDec[zMD].decodeStatus.sourceSelect);
+     for (;;) 
+     {
+         if (pC->xDec[zMD].decodeStatus.sourceSelect == PAF_SOURCE_NONE)
+         {
+             TRACE_VERBOSE0("PAF_AST_decodeProcessing: sourceSelect == PAF_SOURCE_NONE");
+             state = QUIT;
+         }
+         // Process commands (decode)
+         if (getVal = pP->fxns->decodeCommand(pP, pQ, pC)) 
+         {
+             if (state != INIT)   // no need to restart/abort if not yet started
+             {
+                 if (getVal == ASPERR_QUIT)
+                 {
+                     state = QUIT;
+                     TRACE_VERBOSE0("PAF_AST_decodeProcessing. %d: state = QUIT");
+                 }
+                 else if (getVal == ASPERR_ABORT)
+                 {
+                     TRACE_VERBOSE0("PAF_AST_decodeProcessing. %d: return getVal");
+                     return getVal;
+                 }
+                 else
+                 {
+                     /* ignore */;
+                 }
+             }
+             TRACE_VERBOSE0("PAF_AST_decodeProcessing: state == INIT");
+         }
+         TRACE_TIME((&TIME_MOD,         "... + %d = %d ->", dtime(), TSK_time()));
+         TRACE_TIME((&TIME_MOD,         "                 state = %s", stateName[state]));
+         // Process state (decode)
+         switch (state) 
+         {
+             case INIT: // initial state
+                 gAsipInitCnt++;
+                 Log_info0("TaskAsip: state=INIT");
+                 // (***) FL: hackin'
+ #if 0 // 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                
+                 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();                
+                 
+                 //if (errno = pP->fxns->decodeInit (pP, pQ, pC, alg))
+                 //if (errno = pP->fxns->decodeInit(pP, pQ, pC, alg, sourceSelect))
+                 if (errno = pP->fxns->decodeInit(pP, pQ, pC, sourceSelect))
+                 {
+                     TRACE_VERBOSE1("AF_AST_decodeProcessing: INIT, errno 0x%x.  break after decodeInit", errno);
+                     break;
+                 }
+                 
+ #if 0
+                     // (***) FL: hackin'
+                 // 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;
+                 TRACE_VERBOSE0("AF_AST_decodeProcessing: state: INIT->INFO1");
+                 state = INFO1;
+                 continue;
+             case INFO1: // first frame state
+                 gAsipInfo1Cnt++;
+                 Log_info0("TaskAsip: state=INFO1");
+                 
+ #if 0
+                 // (***) FL: hackin'
+                 // 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))
+                 {
+                     TRACE_TERSE1("INFO1: errno 0x%x after decodeInfo, primary timing", errno);
+                     break;
+                 }
+                 
+ #if 0
+                 // (***) FL: hackin'
+                 // invalidate Dec configuration
+                 Cache_inv(&gPAF_AST_config.xDec[0], DECODEN*sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
+                 Cache_wait();                            
+ #endif                
+                 // Don't start decode until major access unit is found.
+                 if (((pC->xDec[zMD].decodeStatus.sourceDecode == PAF_SOURCE_THD)    ||
+                      (pC->xDec[zMD].decodeStatus.sourceDecode == PAF_SOURCE_DXP)    ||
+                      (pC->xDec[zMD].decodeStatus.sourceDecode == PAF_SOURCE_DTSHD)) &&
+                      (pC->xStr[zMS].pAudioFrame->sampleRate == PAF_SAMPLERATE_UNKNOWN)) 
+                 {
+                     Int z;
+                     for (z=DECODE1; z < DECODEN; z++) 
+                     {
+                         Int zI = pP->inputsFromDecodes[z];
+                         if (pC->xInp[zI].hRxSio && pC->xDec[z].decodeStatus.mode)
+                         {
+                             TRACE_VERBOSE0("TaskAsip: PAF_AST_decodeProcessing: INFO1, SIO_issue");
+                             if (SIO_issue (pC->xInp[zI].hRxSio, &pC->xInp[zI].inpBufConfig,
+                                 sizeof (pC->xInp[zI].inpBufConfig), PAF_SIO_REQUEST_NEWFRAME))
+                             {
+                                 TRACE_TERSE0("PAF_AST_decodeProcessing. %d: INFO1, return (ASPERR_ISSUE)");
+                                 return (ASPERR_ISSUE);
+                             }
+                         }
+                     }
+                     TRACE_VERBOSE1("PAF_AST_decodeProcessing: INFO1: frame %d, not major access unit", frame);
+                     frame++;
+                     state = INFO1;
+                     continue;
+                 }
+                 TRACE_VERBOSE1("PAF_AST_decodeProcessing: INFO1: frame %d, major access unit found", frame);
+                 // Establish secondary timing
+                 if (errno = pP->fxns->decodeInfo1(pP, pQ, pC, frame, block))
+                 {
+                     TRACE_VERBOSE1("PAF_AST_decodeProcessing: INFO1, errno 0x%x.  break after decodeInfo1", errno);
+                     break;
+                 }
+                 TRACE_VERBOSE0("PAF_AST_decodeProcessing: state: INFO1->DECODE");
+                 state = DECODE;
+                 continue;
+             case INFO2: // subsequent frame state
+                 gAsipInfo2Cnt++;
+                 Log_info0("TaskAsip: state=INFO2");
+ #if 0            
+                 // (***) FL: hackin'
+                 // 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))
+                 {
+                     TRACE_TERSE1("PAF_AST_decodeProcessing: INFO2 break on decodeInfo. errno 0x%x", errno);
+                     break;
+                 }
+ #if 0            
+                 // (***) FL: hackin'
+                 // 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))
+                 {
+                     TRACE_TERSE1("PAF_AST_decodeProcessing. %d: INFO2 break on decodeInfo2. errno 0x%x", errno);
+                     break;
+                 }
+                 TRACE_VERBOSE0("PAF_AST_decodeProcessing: state: INFO2->DECODE");
+                 state = DECODE;
+                 continue;
+             case DECODE: // decode state
+                 gAsipDecodeCnt++;
+                 Log_info0("TaskAsip: state=DECODE");
+ #if 0
+                 // (***) FL: hackin'
+                 // 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))
+                 {
+                     TRACE_TERSE1("PAF_AST_decodeProcessing: state: DECODE.  decodeDecode err 0x%04x", errno);
+                     break;
+                 }
+       
+ #if 0      
+                 // (***) FL: hackin'
+                 // 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_AST_decodeProcessing: state: DECODE->FINAL");
+                 state = FINAL;
+                 continue;
+             case FINAL: // frame-finalization state
+                 gAsipFinalCnt++;
+                 Log_info0("TaskAsip: state=FINAL");
+                 // Check for final frame, and if indicated:
+                 // - Exit state machine to "complete" processing.
+                 if (pP->fxns->decodeFinalTest(pP, pQ, pC, frame, block)) 
+                 {
+                     break;
+                 }
+                 frame++;
+                 TRACE_VERBOSE0("PAF_AST_decodeProcessing: state: FINAL->AGAIN");
+                 state = INFO2;
+                 continue;
+             case QUIT: // exit state
+                 gAsipQuitCnt++;
+                 Log_info0("TaskAsip: state=QUIT");
+                 // Quit:
+                 // - Set error number registers.
+                 // - Exit state machine to "decode complete" processing.
+                 TRACE_VERBOSE0("PAF_AST_decodeProcessing: state: QUIT");
+                 errno = ASPERR_QUIT;
+                 break;
+             default: // unknown state
+                 // Unknown:
+                 // - Set error number registers.
+                 // - Exit state machine to "decode complete" processing.
+                 TRACE_TERSE1("PAF_AST_decodeProcessing: state: unknown, 0x%x", state);
+                 errno = ASPERR_UNKNOWNSTATE;
+                 break;
+         }  // End of switch (state).
+         TRACE_VERBOSE0("PAF_AST_decodeProcessing: Calling decode complete");
+         if (pP->fxns->decodeComplete(pP, pQ, pC, alg, frame, block))
+         {
+             /* ignored? */;
+         }
+         TRACE_TIME((&TIME_MOD, "as1-f2: ... + %d = ?? (final? %d)", dtime(), state == FINAL));
+         return errno;
+     }  // End of for (;;) to Receive, process, and transmit the data.
+ } //PAF_ASIT_decodeProcessing
+ // -----------------------------------------------------------------------------
+ // ASIT Decoding Function - Decode Command Processing
+ //
+ //   Name:      PAF_ASIT_decodeCommand
+ //   Purpose:   Decoding Function for processing Decode Commands.
+ //   From:      AST Parameter Function -> decodeProcessing
+ //   Uses:      See code.
+ //   States:    x
+ //   Return:    Error number in standard form (0 on success).
+ //   Trace:     Message Log "trace" in Debug Project Configuration reports:
+ //              * Command execution.
+ //
+ Int
+ PAF_ASIT_decodeCommand(
+     const PAF_AST_Params *pP, 
+     const PAF_AST_Patchs *pQ, 
+     PAF_AST_Config *pC
+ )
+ {
+     Int as = pC->as;                    /* Audio Stream Number (1, 2, etc.) */
+     Int z;                              /* decode counter */
+     Int zS;
+     for (z=DECODE1; z < DECODEN; z++) 
+     {
+         zS = pP->streamsFromDecodes[z];
+         if (!(pC->xDec[z].decodeStatus.command2 & 0x80)) 
+         {
+             switch (pC->xDec[z].decodeStatus.command2) 
+             {
+                 case 0: // command none - process
+                     pC->xDec[z].decodeStatus.command2 |= 0x80;
+                     break;
+                 case 1: // command abort - leave now
+                     TRACE_TERSE2("AS%d: PAF_AST_decodeCommand: decode command abort (0x%02x)", as+zS, 1);
+                     pC->xDec[z].decodeStatus.command2 |= 0x80;
+                     return (ASPERR_ABORT);
+                 case 2: // command restart - leave later
+                     TRACE_TERSE2("AS%d: PAF_AST_decodeCommand: decode command quit (0x%02x)", as+zS, 2);
+                     pC->xDec[z].decodeStatus.command2 |= 0x80;
+                     return (ASPERR_QUIT);
+                 default: // command unknown - ignore
+                     break;
+             }
+         }
+     }
+     return 0;
+ } //PAF_ASIT_decodeCommand
+ // -----------------------------------------------------------------------------
+ // ASIT Decoding Function - Reinitialization of Decode
+ //
+ //   Name:      PAF_ASIT_decodeInit
+ //   Purpose:   Decoding Function for reinitializing the decoding process.
+ //   From:      AST Parameter Function -> decodeProcessing
+ //   Uses:      See code.
+ //   States:    x
+ //   Return:    Error number in standard or SIO form (0 on success).
+ //   Trace:     Message Log "trace" in Debug Project Configuration reports:
+ //              * State information as per parent.
+ //
+ Int
+ PAF_ASIT_decodeInit(
+     const PAF_AST_Params *pP, 
+     const PAF_AST_Patchs *pQ, 
+     PAF_AST_Config *pC, 
+     Int sourceSelect
+ )
+ {
+     Int as = pC->as;                    /* Audio Stream Number (1, 2, etc.) */
+     Int z;                              /* decode/encode counter */
+     Int errno;                          /* error number */
+     Int zI, zS;
+     Int zMD = pC->masterDec;
+     Int zMI = pP->zone.master;
+     // FL: messaging
+     ASP_Msg* pAspMsg;
+     Int argIdx;
+     Int decErrno;
+     Int status;
+     PAF_DecodeOpCircBuf *pCb; // FL: decoder output circular buffer
+     
+     (void)as;  // clear compiler warning in case not used with tracing disabled
+     // reset frameCount
+     for (z=DECODE1; z < DECODEN; z++)
+     {
+         if (pC->xDec[z].decodeStatus.mode)
+         {
+             pC->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 (pC->xInp[zI].hRxSio && pC->xDec[z].decodeStatus.mode) 
+         {
+             Uns gear;
+             Int frameLength;
+             TRACE_VERBOSE1("AS%d: PAF_AST_decodeInit: initializing decode", as+zS);
+             // 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))))
+             {
+                 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
+             }      
+             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: hackin'
+             // write back Dec configuration
+             Cache_wb(&gPAF_AST_config.xDec[z], sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
+             Cache_wait();
+             // 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)
+             {
+                 TRACE_TERSE0("MessageQ_get() failure.");
+                 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;
+             }
+             // (***) FL: hackin'
+             // invalidate Dec configuration
+             Cache_inv(&gPAF_AST_config.xDec[z], sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
+             Cache_wait();                            
+             
+ #if 0 // FL: decoder reset call, slave
+             if (dec->fxns->reset
+                 && (errno = dec->fxns->reset (dec, NULL,
+                                               &pC->xDec[z].decodeControl, &pC->xDec[z].decodeStatus)))
+                 return errno;
+ #endif
+             
+             pC->xDec[z].decodeStatus.aspGearControl = 0;//QIN,  aspGearControl seems un-initialized
+             gear = pC->xDec[z].decodeStatus.aspGearControl;
+             pC->xDec[z].decodeStatus.aspGearStatus = gear < GEARS ? gear : 0;
+             
+ #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: hackin'. Bypass computeFrameLength().
+             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)
+             {
+                 frameLength = 1536;
+             }
+             else
+             {
+                 frameLength = 256;
+             }
+ #endif    
+             
+             pC->xDec[z].decodeControl.frameLength = frameLength;
+             pC->xDec[z].decodeInStruct.sampleCount = frameLength;
+             pC->xDec[z].decodeControl.sampleRate = PAF_SAMPLERATE_UNKNOWN;
+             
+             // (***) FL: hackin'. 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;
+             // Start decoder output circular buffer writes
+             pCb = &pC->xDec[z].decOpCb;
+             errno = cbInit(sourceSelect, frameLength, FRAMELENGTH, pCb);
+             if (errno)
+             {
+                 return errno;
+             }
+                       errno = cbReadWriteRestore(pCb); //QIN
+             if (errno)
+             {
+                 return errno;
+             }
+             // FL: debug
+             cbLog(pCb, 1);
+             
+             if (z != zMD) 
+             {
+                 if (errno = SIO_idle(pC->xInp[zI].hRxSio))
+                 {
+                     return errno;
+                 }
+             }
+             if (errno = SIO_ctrl(pC->xInp[zI].hRxSio, PAF_SIO_CONTROL_SET_SOURCESELECT,
+                 DECSIOMAP(pC->xDec[z].decodeStatus.sourceSelect)))
+             {
+                 return errno;
+             }
+             if (errno = SIO_ctrl(pC->xInp[zI].hRxSio, PAF_SIO_CONTROL_SET_PCMFRAMELENGTH, 
+                 frameLength))
+             {
+                 return errno;
+             }
+             if (errno = pP->fxns->updateInputStatus(pC->xInp[zI].hRxSio, &pC->xInp[zI].inpBufStatus, 
+                 &pC->xInp[zI].inpBufConfig))
+             {
+                 return errno;
+             }
+         }
+     }
+     if (pC->xInp[zMI].hRxSio) 
+     {
+         errno = SIO_issue(pC->xInp[zMI].hRxSio, &pC->xInp[zMI].inpBufConfig,
+             sizeof(pC->xInp[zMI].inpBufConfig), PAF_SIO_REQUEST_NEWFRAME);
+         if (errno)
+         {
+             return errno;
+         }
+     }
+     return 0;
+ } //PAF_AST_decodeInit
+ // -----------------------------------------------------------------------------
+ // ASIT Decoding Function - Info Processing, Common
+ //
+ //   Name:      PAF_ASIT_decodeInfo
+ //   Purpose:   Decoding Function for processing information in a manner that
+ //              is common for both initial and subsequent frames of input data.
+ //   From:      AST Parameter Function -> decodeProcessing
+ //   Uses:      See code.
+ //   States:    x
+ //   Return:    Error number in standard form (0 on success).
+ //   Trace:     Message Log "trace" in Debug Project Configuration reports:
+ //              * State information as per parent.
+ //
+ Int
+ PAF_ASIT_decodeInfo(
+     const PAF_AST_Params *pP, 
+     const PAF_AST_Patchs *pQ, 
+     PAF_AST_Config *pC, 
+     Int frame, 
+     Int block
+ )
+ {
+     Int as = pC->as;                    /* Audio Stream Number (1, 2, etc.) */
+     Int z;                              /* input/decode/stream counter */
+     Int errno;                          /* error number */
+     Int sioErr;                         /* error number, SIO */
+     Int zD, zI, zS, zX;
+     Int zMD = pC->masterDec;
+     Int zMI = pP->zone.master;
+     Int zMS = pC->masterStr;
+     UInt32 curTime;
+     // FL: Messaging
+     ASP_Msg *pAspMsg;
+     Int argIdx;
+     Int status;
+     // FL: hackin'
+     //Int size;
+     //PAF_InpBufConfig *pIpBufConfig;
+     (void)zMS;  (void)as;  // clear compiler warning in case not used with tracing disabled
+     // Set decode control: sample rate, emphasis
+     for (z=INPUT1; z < INPUTN; z++)
+     {
+         zD = z;
+         for (zX = DECODE1; zX < DECODEN; zX++) 
+         {
+             if (pP->inputsFromDecodes[zX] == z) 
+             {
+                 zD = zX;
+                 break;
+             }
+         }
+         if (pC->xInp[z].hRxSio) 
+         {
+             //determine associated decoder
+             if (pC->xInp[z].inpBufStatus.sampleRateStatus != 
+                 pC->xDec[zD].decodeControl.sampleRate) 
+             {
+                 if (pC->xDec[zD].decodeControl.sampleRate == PAF_SAMPLERATE_UNKNOWN) 
+                 {
+                     pC->xDec[zD].decodeControl.sampleRate = 
+                         pC->xInp[z].inpBufStatus.sampleRateStatus;
+                 }
+                 else
+                 {
+                     TRACE_TERSE1("AS%d: return error ASPERR_INFO_RATECHANGE", as+pC->masterStr);
+                     TRACE_TERSE2("inpBufStatus.sampleRateStatus: 0x%x, decodeControl.sampleRate: 0x%x",
+                         pC->xInp[z].inpBufStatus.sampleRateStatus, 
+                         pC->xDec[zD].decodeControl.sampleRate);
+                     // return (ASPERR_INFO_RATECHANGE);
+                 }
+             }
+             pC->xDec[zD].decodeControl.emphasis = 
+                 pC->xDec[zD].decodeStatus.sourceDecode != PAF_SOURCE_PCM
+                 ? PAF_IEC_PREEMPHASIS_NO // fix for Mantis ID #119
+                 : pC->xInp[z].inpBufStatus.emphasisStatus;
+         }
+         else 
+         {
+             pC->xDec[zD].decodeControl.sampleRate = PAF_SAMPLERATE_UNKNOWN;
+             pC->xDec[zD].decodeControl.emphasis = PAF_IEC_PREEMPHASIS_UNKNOWN;
+         }
+     }
+     // Wait for info input
+     TRACE_VERBOSE2("PAF_ASIT_decodeInfo: AS%d: awaiting frame %d -- sync+info+data", as+zMS, frame);
+     if (pC->xInp[zMI].hRxSio) 
+     {
+         TRACE_VERBOSE0("PAF_ASIT_decodeInfo: call SIO_reclaim to get input buffer.");
+         sioErr = SIO_reclaim(pC->xInp[zMI].hRxSio, (Ptr)&pC->xInp[zMI].pInpBuf, NULL);
+         if (sioErr != sizeof(pC->xInp[zMI].inpBufConfig))
+         {
+             TRACE_TERSE1("SIO_reclaim on input returned error ASPERR_RECLAIM.  sioErr: 0x%x", sioErr);
+             return ASPERR_RECLAIM;
+         }
+         
+         // FL: debug, capture input buffer
+         capIb(pC->xInp[zMI].pInpBuf);
+         
+         //
+         // Simulate Rx SIO_reclaim() pend
+         //
+         //Semaphore_pend(semaphoreRxAudio, BIOS_WAIT_FOREVER); 
+         gTaskAsipCnt++;
+         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
+     // Decode info
+     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 (pC->xInp[zI].hRxSio && pC->xDec[z].decodeStatus.mode) 
+         {
+             TRACE_GEN2("PAF_ASIT_decodeInfo: AS%d: processing frame %d -- info", as+zS, frame);
+             if (errno = pP->fxns->updateInputStatus(pC->xInp[zI].hRxSio,
+                 &pC->xInp[zI].inpBufStatus, &pC->xInp[zI].inpBufConfig))
+             {
+                 TRACE_TERSE1("return error errno 0x%x.", errno);
+                 return errno;
+             }
+ #if 1
+             // (***) FL: hackin'
+             // write back Inp configuration
+             Cache_wb(&gPAF_AST_config.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(&gPAF_AST_config.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)
+             {
+                 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);
+                 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;
+             }
+ #if 1
+             // (***) FL: hackin'
+             // invalidate Dec configuration
+             Cache_inv(&gPAF_AST_config.xDec[z], sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
+             Cache_wait();                            
+ #endif            
+             
+ #if 0 // FL: decoder info call, slave
+             if (dec->fxns->info
+                 && (errno = dec->fxns->info (dec, NULL,
+                                              &pC->xDec[z].decodeControl, &pC->xDec[z].decodeStatus))) 
+ #endif
+             if (errno)
+             {
+                 TRACE_TERSE1("return error errno 0x%x.", errno);
+                 return errno;
+             }
+             // increment decoded frame count
+             pC->xDec[z].decodeStatus.frameCount += 1;
+         }
+     } // z=DECODE1 to DECODEN
+     // query IB for latest sourceProgram (needed if we started decoding due to a force mode)
+     if (pC->xDec[zMD].decodeStatus.mode) 
+     {
+         XDAS_Int8 sourceProgram;
+         if (errno = SIO_ctrl(pC->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;
+         }
+         pC->xDec[zMD].decodeStatus.sourceProgram = sourceProgram;
+ #if 0
+         // (***) FL: hackin'
+         Cache_wb((Ptr)&pC->xDec[zMD].decodeStatus.sourceProgram,
+             sizeof(pC->xDec[zMD].decodeStatus.sourceProgram), Cache_Type_ALLD, 0);
+         Cache_wait();
+ #endif        
+     }
+     // since now decoding update decode status for all enabled decoders
+     for (z=DECODE1; z < DECODEN; z++) 
+     {
+         if (pC->xDec[z].decodeStatus.mode) 
+         {
+             pC->xDec[z].decodeStatus.sourceDecode = pC->xDec[z].decodeStatus.sourceProgram;
+             if (pC->xDec[z].decodeStatus.sourceSelect == PAF_SOURCE_SNG)
+             {
+                 pC->xDec[z].decodeStatus.sourceDecode = PAF_SOURCE_SNG;
+             }
+             
+ #if 0
+             // (***) FL: hackin'
+             Cache_wb((Ptr)&pC->xDec[z].decodeStatus.sourceDecode,
+                 sizeof(pC->xDec[z].decodeStatus.sourceDecode), Cache_Type_ALLD, 0);
+             Cache_wait();
+ #endif            
+         }
+     }
+ #if 0 // FL: ASDT (slave)
+     // TODO: move this to start of this function so that it doesn't affect IO timing
+     // Initialize audio frame(s)
+     //    Re-initialize audio frame if there is an associated decode and
+     //    that decode doesn't have a valid input or is turned off
+     for (z=STREAM1; z < STREAMN; z++) 
+     {
+         Int reset = 0;
+         for (zX = DECODE1; zX < DECODEN; zX++) 
+         {
+             if (pP->streamsFromDecodes[zX] == z) 
+             {
+                 zI = pP->inputsFromDecodes[zX];
+                 if (!pC->xDec[zX].decodeStatus.mode || !pC->xInp[zI].hRxSio)
+                 {
+                     reset = 1;
+                 }
+             }
+         }
+         if (reset) 
+         {
+             TRACE_VERBOSE2("PAF_ASIT_decodeInfo: AS%d: initializing block %d -- info", as+z, frame);
+             pP->fxns->initFrame1 (pP, pQ, pC, z, 0);
+         }
+         else
+         {
+             TRACE_VERBOSE2("PAF_ASIT_decodeInfo: AS%d: initializing block %d -- info <ignored>", as+z, frame);
+         }
+     }
+ #endif    
+     return 0;
+ } //PAF_ASIT_decodeInfo
+ // -----------------------------------------------------------------------------
+ // ASIT Decoding Function - Info Processing, Initial
+ //
+ //   Name:      PAF_ASIT_decodeInfo1
+ //   Purpose:   Decoding Function for processing information in a manner that
+ //              is unique to initial frames of input data.
+ //   From:      AST Parameter Function -> decodeProcessing
+ //   Uses:      See code.
+ //   States:    x
+ //   Return:    Error number in standard or SIO form (0 on success).
+ //   Trace:     Message Log "trace" in Debug Project Configuration reports:
+ //              * State information as per parent.
+ //
+ Int
+ PAF_ASIT_decodeInfo1(
+     const PAF_AST_Params *pP, 
+     const PAF_AST_Patchs *pQ, 
+     PAF_AST_Config *pC, 
+     Int frame, 
+     Int block
+ )
+ {
+     return 0;
+ } //PAF_ASIT_decodeInfo1
+ // -----------------------------------------------------------------------------
+ // AST Decoding Function - Info Processing, Subsequent
+ //
+ //   Name:      PAF_AST_decodeInfo2
+ //   Purpose:   Decoding Function for processing information in a manner that
+ //              is unique to frames of input data other than the initial one.
+ //   From:      AST Parameter Function -> decodeProcessing
+ //   Uses:      See code.
+ //   States:    x
+ //   Return:    Error number in standard form (0 on success).
+ //   Trace:     None.
+ //
+ Int
+ PAF_ASIT_decodeInfo2(
+     const PAF_AST_Params *pP, 
+     const PAF_AST_Patchs *pQ, 
+     PAF_AST_Config *pC, 
+     Int frame, 
+     Int block
+ )
+ {
+     return 0;
+ } //PAF_ASIT_decodeInfo2
+ // -----------------------------------------------------------------------------
+ // AST Decoding Function - Continuation Processing
+ //
+ //   Name:      PAF_AST_decodeCont
+ //   Purpose:   Decoding Function for processing that occurs subsequent to
+ //              information processing but antecedent to timing processing
+ //              for frames of input data other than the initial one.
+ //   From:      AST Parameter Function -> decodeProcessing
+ //   Uses:      See code.
+ //   States:    x
+ //   Return:    Error number in standard form (0 on success).
+ //   Trace:     Message Log "trace" in Debug Project Configuration reports:
+ //              * State information as per parent.
+ //
+ Int
+ PAF_AST_decodeCont (const PAF_AST_Params *pP, const PAF_AST_Patchs *pQ, PAF_AST_Config *pC, ALG_Handle decAlg[], Int frame, Int block)
+ {
+     Int as = pC->as;                    /* Audio Stream Number (1, 2, etc.) */
+     Int z;                              /* decode counter */
+     Int zI, zS;
+     Int zMD = pC->masterDec;
+     (void)as;  // clear compiler warning in case not used with tracing disabled
+     // Await slave inputs
+     for (z=DECODE1; z < DECODEN; z++) {
+         zI = pP->inputsFromDecodes[z];
+         zS = pP->streamsFromDecodes[z];
+         (void)zS;
+         if (z == zMD
+             || ! pC->xInp[zI].hRxSio
+             || ! pC->xDec[z].decodeStatus.mode)
+             continue;
+         TRACE_VERBOSE2("as1-f2: PAF_AST_decodeCont: AS%d: awaiting frame %d -- data", as+zS, frame);
+         if (SIO_reclaim (pC->xInp[zI].hRxSio, (Ptr)&pC->xInp[zI].pInpBuf, NULL)
+             != sizeof (pC->xInp[zI].inpBufConfig))
+             return (ASPERR_RECLAIM);
+     }
+     return 0;
+ } //PAF_AST_decodeCont
+ // -----------------------------------------------------------------------------
+ // ASIT Decoding Function - Decode Processing
+ //
+ //   Name:      PAF_ASIT_decodeDecode
+ //   Purpose:   Decoding Function for processing of input data by the
+ //              Decode Algorithm.
+ //   From:      AST Parameter Function -> decodeProcessing
+ //   Uses:      See code.
+ //   States:    x
+ //   Return:    Error number in standard form (0 on success).
+ //   Trace:     Message Log "trace" in Debug Project Configuration reports:
+ //              * State information as per parent.
+ //
+ Int
+ PAF_ASIT_decodeDecode(
+     const PAF_AST_Params *pP, 
+     const PAF_AST_Patchs *pQ, 
+     PAF_AST_Config *pC, 
+     Int sourceSelect, 
+     Int frame, 
+     Int block
+ )
+ {
+     Int as = pC->as;                    /* Audio Stream Number (1, 2, etc.) */
+     Int z;                              /* decode/stream counter */
+     Int errno;                          /* error number */
+     //Int ch;
+     // FL: Messaging
+     ASP_Msg *pAspMsg;
+     Int argIdx;
+     Int status;
+     Int cbErrno;
+     Int frameLength;    
+     (void)as; // clear compiler warning in case not used with tracing disabled
+ #if 0 // FL: slave
+     // Clear samsiz for all channels - MID 208.
+     for (z=STREAM1; z < STREAMN; z++) 
+     {
+         for (ch=0; ch < PAF_MAXNUMCHAN_AF; ch++) 
+         {
+             pC->xStr[z].pAudioFrame->data.samsiz[ch] = 0;
+         }
+     }
+ #endif    
+     // Decode data
+     for (z=DECODE1; z < DECODEN; z++) 
+     {
+         Int zI = pP->inputsFromDecodes[z];
+         Int zS = pP->streamsFromDecodes[z];
+         (void)zS; // clear compiler warning in case not used with tracing disabled
+         if (pC->xInp[zI].hRxSio && pC->xDec[z].decodeStatus.mode)
+         {
+             TRACE_GEN2("AS%d: decodeDecode: processing block %d -- decode", as+zS, block);
+             TRACE_VERBOSE3("as1-f2: AS%d: decodeDecode: decoding from 0x%x (base) 0x%x (ptr)",
+                     as+zS,
+                     (IArg)pC->xInp[z].pInpBuf->base.pVoid,
+                     (IArg)pC->xInp[z].pInpBuf->head.pVoid);
+             // FL: debug, capture input buffer
+             //capIbPcm(pC->xInp[z].pInpBuf);
+             
+             // (***) FL: hackin'
+             // write back Dec configuration
+             Cache_wb(&gPAF_AST_config.xDec[z], sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
+             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)
+             {
+                 TRACE_TERSE0("MessageQ_get() failure.");
+                 SW_BREAKPOINT; // temporary
+                 return -1; // temporary
+             }
+             if ((pAspMsg->procId == hAspMsgMaster->slaveProcId) && 
+                 (pAspMsg->cmd == ASP_MASTER_DEC_DECODE_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);
+                 
+                 argIdx = 0;
+                 errno = *(Int32 *)&pAspMsg->buf[argIdx];
+                 argIdx += sizeof(Int32);
+                 cbErrno = *(Int32 *)&pAspMsg->buf[argIdx];
+                 if (cbErrno != 0)
+                 {
+                     TRACE_TERSE1("CB write error=%d", cbErrno);
+                     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: hackin'
+             // invalidate Dec configuration
+             Cache_inv(&gPAF_AST_config.xDec[z], sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
+             Cache_wait();
+ #if 0 // FL: decoder decode call, slave
+             if (dec->fxns->decode
+                 && (errno = dec->fxns->decode (dec, NULL,
+                                                &pC->xDec[z].decodeInStruct, &pC->xDec[z].decodeOutStruct))) 
+ #endif
+             if (errno)
+             {
+                 TRACE_VERBOSE1("PAF_ASIT_decodeDecode: fxns->decode returns 0x%x", errno);
+                 return errno;
+             }
+ #if (CURRENT_TRACE_MASK & TRACE_MASK_DATA)
+             as_traceChannels(pC, z);
+ #endif
+ #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: hackin'. Bypass computeFrameLength().
+             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)
+                 frameLength = 1536;
+             else
+                 frameLength = 256;
+ #endif                    
+ // ............................................................................
+             pC->xDec[z].decodeControl.frameLength = frameLength;
+             pC->xDec[z].decodeInStruct.sampleCount = frameLength;
+             if (errno = SIO_ctrl(pC->xInp[zI].hRxSio,
+                 PAF_SIO_CONTROL_SET_PCMFRAMELENGTH, frameLength))
+             {
+                 TRACE_VERBOSE1("PAF_ASIT_decodeDecode: SIO SET_PCMFRAMELENGTH returns 0x%x", errno);
+                 return errno;
+             }
+                 
+             TRACE_VERBOSE1("PAF_ASIT_decodeDecode: calling SIO_issue[%d]", zI);
+             if (errno = SIO_issue(pC->xInp[zI].hRxSio, &pC->xInp[zI].inpBufConfig,
+                 sizeof(pC->xInp[zI].inpBufConfig),
+                 PAF_SIO_REQUEST_NEWFRAME))
+             {
+                 TRACE_VERBOSE2("PAF_ASIT_decodeDecode: SIO_issue returns 0x%x, we return ASPERR_ISSUE (0x%x)", errno, ASPERR_ISSUE);
+                 return (ASPERR_ISSUE);
+             }
+         } // hRxSio && decodeStatus.mode
+         else
+         {
+             TRACE_VERBOSE2("AS%d: PAF_ASIT_decodeDecode: processing block %d -- decode <ignored>", as+zS, block);
+         }
+     } // z=DECODE1 to DECODEN
+ #if 0 // FL: ASDT (slave)
+     // Set up audio frames not decoded into
+     //    Re-initialize audio frame if there is an assocatiated decode and
+     //    that decode doesn't have a valid input or is turned off
+     for (z=STREAM1; z < STREAMN; z++) 
+     {
+         Int zX;
+         Int reset = 0;
+         for (zX = DECODE1; zX < DECODEN; zX++) 
+         {
+             if (pP->streamsFromDecodes[zX] == z) 
+             {
+                 Int zI = pP->inputsFromDecodes[zX];
+                 if (!pC->xDec[zX].decodeStatus.mode || !pC->xInp[zI].hRxSio)
+                     reset = 1;
+             }
+         }
+         if (reset) 
+         {
+             TRACE_VERBOSE2("PAF_ASIT_decodeDecode: AS%d: initializing block %d -- decode", as+z, frame);
+             pP->fxns->initFrame1 (pP, pQ, pC, z, 0);
+         }
+         else
+             TRACE_VERBOSE2("PAF_ASIT_decodeDecode: AS%d: initializing block %d -- decode <ignored>", as+z, frame);
+     }
+ #endif
+     
+     return 0;
+ } //PAF_ASIT_decodeDecode
+ // -----------------------------------------------------------------------------
+ // ASIT Decoding Function - Frame-Final Processing
+ //
+ //   Name:      PAF_ASIT_decodeFinalTest
+ //   Purpose:   Decoding Function for determining whether processing of the
+ //              current frame is complete.
+ //   From:      AST Parameter Function -> decodeProcessing
+ //   Uses:      See code.
+ //   States:    x
+ //   Return:    0 if incomplete, and 1 if complete.
+ //   Trace:     None.
+ //
+ Int
+ PAF_ASIT_decodeFinalTest(
+     const PAF_AST_Params *pP, 
+     const PAF_AST_Patchs *pQ, 
+     PAF_AST_Config *pC, 
+     Int frame, 
+     Int block
+ )
+ {
+     Int zMD = pC->masterDec;
+     Int sourceSelect;
+     Int sourceProgram;
+     sourceSelect  = pC->xDec[zMD].decodeStatus.sourceSelect;
+     sourceProgram = pC->xDec[zMD].decodeStatus.sourceProgram;
+     if ((sourceSelect == PAF_SOURCE_NONE) || (sourceSelect == PAF_SOURCE_PASS))
+     {
+         return 1;
+     }
+     // The following allows for Force modes to switch without command deferral. This might
+     // be better suited for inclusion in DIB_requestFrame, but for now will reside here.
+     if ((sourceSelect == PAF_SOURCE_SNG) || (sourceSelect > PAF_SOURCE_BITSTREAM)) 
+     {
+         if (sourceSelect == PAF_SOURCE_DTSALL)
+         {
+             if (sourceProgram != PAF_SOURCE_DTS11 &&
+                 sourceProgram != PAF_SOURCE_DTS12 &&
+                 sourceProgram != PAF_SOURCE_DTS13 &&
+                 sourceProgram != PAF_SOURCE_DTS14 &&
+                 sourceProgram != PAF_SOURCE_DTS16 &&
+                 sourceProgram != PAF_SOURCE_DTSHD)
+             {
+                 return 1;
+             }
+         }
+         else if (sourceSelect == PAF_SOURCE_PCMAUTO) 
+         {
+             if (sourceProgram != PAF_SOURCE_PCM)
+             {
+                 return 1;
+             }
+         }
+         else 
+         {
+             if (pC->xDec[zMD].decodeStatus.sourceSelect != pC->xDec[zMD].decodeStatus.sourceDecode)
+             {
+                 return 1;
+             }
+         }
+     }
+     return 0;
+ } //PAF_ASIT_decodeFinalTest
+ // -----------------------------------------------------------------------------
+ // ASIT Decoding Function - Stream-Final Processing
+ //
+ //   Name:      PAF_ASIT_decodeComplete
+ //   Purpose:   Decoding Function for terminating the decoding process.
+ //   From:      AST Parameter Function -> decodeProcessing
+ //   Uses:      See code.
+ //   States:    x
+ //   Return:    0.
+ //   Trace:     Message Log "trace" in Debug Project Configuration reports:
+ //              * State information as per parent.
+ //
+ Int
+ PAF_ASIT_decodeComplete(
+     const PAF_AST_Params *pP, 
+     const PAF_AST_Patchs *pQ, 
+     PAF_AST_Config *pC, 
+     ALG_Handle decAlg[], 
+     Int frame, 
+     Int block
+ )
+ {
+     Int as  = pC->as;                    /* Audio Stream Number (1, 2, etc.) */
+     Int z;                               /* decode/encode counter */
+     ASP_Msg* pAspMsg;
+     Int argIdx;
+     Int errno;                           /* error number */
+     Int status;
+     PAF_DecodeOpCircBuf *pCb; // FL: decoder output circular buffer
+     (void)as;  // clear compiler warning in case not used with tracing disabled
+ #ifdef PAF_ASP_FINAL
+     /* This material is currently not utilized */
+ #endif /* PAF_ASP_FINAL */
+     for (z=DECODE1; z < DECODEN; z++) 
+     {
+ #ifdef PAF_ASP_FINAL
+         DEC_Handle dec = (DEC_Handle )decAlg[z];
+ #endif /* PAF_ASP_FINAL */
+         Int zI = pP->inputsFromDecodes[z];
+         if (pC->xInp[zI].hRxSio && pC->xDec[z].decodeStatus.mode) 
+         {
+             TRACE_VERBOSE1("PAF_AST_decodeComplete: AS%d: finalizing decode", as+z);
+ #ifdef PAF_ASP_FINAL
+             if (dec->fxns->final)
+                 dec->fxns->final(dec, NULL, &pC->xDec[z].decodeControl,
+                                  &pC->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)
+             {
+                 SW_BREAKPOINT;
+             }
+ #if 0 // FL: decoder deactivate call, slave
+             if (decAlg[z]->fxns->algDeactivate)
+                 decAlg[z]->fxns->algDeactivate (decAlg[z]);
+ #endif
+             // Stop decoder output circular buffer writes
+             pCb = &pC->xDec[z].decOpCb;
+             errno = cbWriteStop(pCb);
+             if (errno)
+             {
+                 return errno;
+             }
+         }
+         else 
+         {
+             TRACE_VERBOSE1("PAF_AST_decodeComplete: AS%d: processing decode <ignored>", as+z);
+         }
+     }
+     return 0;
+ } //PAF_ASIT_decodeComplete
+ // -----------------------------------------------------------------------------
+ // ASIT Selection Function - Input Device Selection
+ //
+ //   Name:      PAF_ASIT_selectDevices
+ //   Purpose:   Audio Stream Input Task Function for selecting the devices used
+ //              for input.
+ //   From:      audioStream1Task or equivalent
+ //   Uses:      See code.
+ //   States:    x
+ //   Return:    Error number in standard form (0 on success).
+ //   Trace:     Message Log "trace" in Debug Project Configuration reports:
+ //              * State information as per parent.
+ //
+ Int
+ PAF_ASIT_selectDevices(
+     const PAF_AST_Params *pP, 
+     const PAF_AST_Patchs *pQ, 
+     PAF_AST_Config *pC
+ )
+ {
+     Int as = pC->as;                    /* Audio Stream Number (1, 2, etc.) */
+     Int z;                              /* input/output counter */
+     Int errno = 0;                      /* error number */
+     Int errme;                          /* error number, local */
+     Int device;
+     Int zMD = pC->masterDec;
+     (void)as;  // clear compiler warning in case not used with tracing disabled
+     // Select input devices
+     for (z=INPUT1; z < INPUTN; z++) 
+     {
+         if ((device = pC->xInp[z].inpBufStatus.sioSelect) >= 0) 
+         {
+             TRACE_VERBOSE2("PAF_ASIT_selectDevices: AS%d: input device %d selecting ...", as+z, device);
+             // check for valid index into device array
+             if (device >= pQ->devinp->n)
+             {
+                 device = 0; /* treat as device None */
+             }
+             errme = pP->fxns->deviceSelect(&pC->xInp[z].hRxSio, SIO_INPUT,
+                 HEAP_ID_INPBUF, (Ptr)pQ->devinp->x[device]);
+             if (errme)
+             {
+                 TRACE_VERBOSE2("PAF_ASIT_selectDevices: errme 0x%x, errno 0x%x", errme, errno);
+                 if (!errno)
+                 {
+                     errno = ASPERR_DEVINP + errme;
+                 }
+                 pC->xInp[z].inpBufStatus.sioSelect = 0x80;
+             }
+             else 
+             {
+                 pC->xInp[z].inpBufStatus.sioSelect = device | 0x80;
+                 // register decodeStatus pointer with input devices
+                 // This allows, e.g., autoProcessing to exit when sourceSelect = none
+                 // Use zMIs decodeStatus for all inputs
+                 if (pC->xInp[z].hRxSio) 
+                 {
+                     // register PAF_SIO_IALG object address
+                     SIO_ctrl(pC->xInp[z].hRxSio, PAF_SIO_CONTROL_SET_IALGADDR, 
+                         (Arg)pC->xInp[z].inpChainData.head->alg);
+                     SIO_ctrl(pC->xInp[z].hRxSio, PAF_SIO_CONTROL_SET_DECSTATUSADDR, 
+                         (Arg)&pC->xDec[zMD].decodeStatus);
+                 }
+             }
+         }
+     }
+     return errno;
+ } //PAF_ASIT_selectDevices
+ // -----------------------------------------------------------------------------
+ // ASIT Selection Function - Source Selection
+ //
+ //   Name:      PAF_ASIT_sourceDecode
+ //   Purpose:   Audio Input Stream Task Function for selecting the sources used
+ //              for decoding of input to output.
+ //   From:      audioStream1Task or equivalent
+ //   Uses:      See code.
+ //   States:    x
+ //   Return:    0.
+ //   Trace:     None.
+ //
+ Int
+ PAF_ASIT_sourceDecode(
+     const PAF_AST_Params *pP, 
+     const PAF_AST_Patchs *pQ, 
+     PAF_AST_Config *pC, 
+     Int x
+ )
+ {
+     Int z;                              /* decode counter */
+     for (z=DECODE1; z < DECODEN; z++)
+     {
+         if (pC->xDec[z].decodeStatus.mode) 
+         {
+             pC->xDec[z].decodeStatus.sourceDecode = x;
+         }
+     }
+     
+     return 0;
+ } //PAF_ASIT_sourceDecode
+ // -----------------------------------------------------------------------------
+ #if 0 // (***) FL: no longer used w/ removal of CONTINUOUS mode
+ Int
+ PAF_AST_decodeHandleErrorInput (const PAF_AST_Params *pP, const PAF_AST_Patchs *pQ, PAF_AST_Config *pC, ALG_Handle decAlg[], Int z, Int error)
+ {
+     Int errno = 0;
+     Int zMD = pC->masterDec;
+     Int zI = pP->inputsFromDecodes[z];
+     // only handle real errors, on primary input, for writeDECModeContinuous
+     if ( !( error &&
+             z == zMD ))
+         return error;
+     TRACE_TIME((&TIME_MOD, "AS%d: PAF_AST_decodeHandleErrorInput: (primary) input error caught = %d", pC->as+z, error));
+     TRACE_TIME((&TIME_MOD, "AS%d: PAF_AST_decodeHandleErrorInput: old sourceProgram = %d", pC->as+z, pC->xDec[z].decodeStatus.sourceProgram));
+     if (pC->xInp[zI].hRxSio) {
+         DEC_Handle dec;
+         if (errno = SIO_idle (pC->xInp[zI].hRxSio))
+             return errno;
+         // indicates (primary) input not running
+         pC->xDec[z].decodeStatus.sourceDecode = PAF_SOURCE_NONE;
+         pC->xInp[zI].inpBufConfig.deliverZeros = 1;
+         // will be changed after next reclaim, to PAF_SOURCE_UNKNOWN or other
+         pC->xDec[z].decodeStatus.sourceProgram = PAF_SOURCE_NONE;
+         if (decAlg[z]->fxns->algDeactivate)
+             decAlg[z]->fxns->algDeactivate (decAlg[z]);
+         decAlg[z] = pC->xDec[z].decAlg[PAF_SOURCE_PCM];
+         dec = (DEC_Handle )decAlg[z];
+         TRACE_TIME((&TIME_MOD, "AS%d: PAF_AST_decodeHandleErrorInput: resetting to PCM decoder",
+                     pC->as+z));
+         if (decAlg[z]->fxns->algActivate)
+             decAlg[z]->fxns->algActivate (decAlg[z]);
+         if (dec->fxns->reset
+             && (errno = dec->fxns->reset (dec, NULL,
+                                           &pC->xDec[z].decodeControl, &pC->xDec[z].decodeStatus)))
+             return errno;
+     }
+     return errno;
+ } //PAF_AST_decodeHandleErrorInput
+ #endif
+ #if (CURRENT_TRACE_MASK & TRACE_MASK_DATA)
+ //------------------------------------------------------------------------------
+ static int sSkipCount = 0;
+ int gReportBuffers = 0;
+ void as_traceChannels(PAF_AST_Config *pC, int z)
+ {
+     PAF_AudioFrame *pAudioFrame = pC->xDec[z].decodeInStruct.pAudioFrame;
+     int i;
+          
+ // #ifdef THIS_IS_DSPA
+     sSkipCount++;
+     if (sSkipCount<1)
+         return;
+     sSkipCount = 0;
+ // #endif
+ #ifdef THIS_IS_DSPB
+     if (!gReportBuffers)
+         return;
+     gReportBuffers = 0;
+ #endif
+     dp(NULL, "\n");
+     for (i=0; i<PAF_MAXNUMCHAN; i++)
+     {
+         if (pAudioFrame->data.sample[i] != 0)
+         {
+             float *wp = (float*)pAudioFrame->data.sample[i];
+                dp(NULL, "i: %d.  p: 0x%x.  %f, %f, %f, %f\n",
+                        i, pAudioFrame->data.sample[i], wp[0], wp[1], wp[2], wp[3]);
+         }
+     }
+ }
+ #endif
diff --cc readme_demo.txt
index c975fb3620716e48b0703c94b66ce149cec29d86,021a37cff5f5c3f01a9dc773949fc1f0fede4369..5179e2fab018458352a3702fdaf57eaba0613277
@@@ -4,10 -4,12 +4,12 @@@ Update log
      06-30-16: Add note concerning PAF Makefile ROOTDIR variable
      07-08-16: Add information on UART LLD build
      07-14-16: Add note concerning <root>
+     08-04-16: Add DDP(JOC), OAR and BMDA
 +    08-10-16: Update commit Ids for PAF, Dolby Intrinsics, and DDP.
+     08-11-16: Add workaround in OAR
      
  NOTE: Below mentioned <root> has only been verified for <root>=c:\ti.
 -      Using another <root> will require changes to makefiles (e.g. DDP, Intrinsics)
 -      hard-coded to use c:\ti.
 +      Using another <root> will require changes to makefiles (e.g. DDP, Intrinsics) hard-coded to use c:\ti.
      
      Code installation:
          IPC: Unzip ipc_3_43_00_00_eng.zip (contains IPC engineering release) to <root>\ipc_3_43_00_00_eng\.
          DDP:
              Rebuild DDP libraries:
                  1) Open DOS prompt
-                 2) cd <root>\procsdk_audio_x_xx_xx_xx\ddp\Dolby_Digital_Plus_Decoder_Imp\Source_Code\make\k2g\Wrapper\ddp_library
 -                2) cd <root>\ddp\Dolby_Digital_Plus_Decoder_Imp\Source_Code\make\ddp_udc_lib\a15
++                2) cd <root>\procsdk_audio_x_xx_xx_xx\ddp\Dolby_Digital_Plus_Decoder_Imp\Source_Code\make\ddp_udc_lib\a15
                  3) Execute:
                      > gmake
-                 3) cd <root>\procsdk_audio_x_xx_xx_xx\ddp\Dolby_Digital_Plus_Decoder_Imp\Source_Code\make\k2g\Wrapper\ddp_wrapper
 -                3) cd <root>\ddp\Dolby_Digital_Plus_Decoder_Imp\Source_Code\make\ddp_udc_wrapper\a15
++                3) cd <root>\procsdk_audio_x_xx_xx_xx\ddp\Dolby_Digital_Plus_Decoder_Imp\Source_Code\make\ddp_udc_wrapper\a15
                  4) From DOS prompt, execute:
                      > gmake
              
 -         OAR:
++        OAR:
+             Rebuild OAR libraries:
+                 1) Open DOS prompt
 -                2) cd <root>\oar\CCS_OAR_lib\make
++                2) cd <root>\procsdk_audio_x_xx_xx_xx\oar\CCS_OAR_lib\make
+                 3) Execute:
+                     > gmake
+   
+         BMDA:
+             Rebuild BMDA libraries:
+                 1) Open DOS prompt
 -                2) cd <root>\bmda\Source_Code\make
++                2) cd <root>\procsdk_audio_x_xx_xx_xx\bmda\Source_Code\make
+                 3) Execute:
+                     > gmake SHELL=%ComSpec%
+             Note: Set "export ARCH = c66x" in target.mk to build BMDA library.
+                 
 -
 -       UART LLD:
 +        UART LLD:
              1) Open DOS prompt
              2) cd <root>\pdk_k2g_1_0_1\packages
              3) Execute: