]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/performance-audio-sr.git/blobdiff - pasdk/test_arm/framework/audioStreamDecodeProc.c
PASDK-218:CB updates for THD 192 kHz
[processor-sdk/performance-audio-sr.git] / pasdk / test_arm / framework / audioStreamDecodeProc.c
index 234d351ad2951fcfea276ff9a1a18f2a729a36d1..a3b16baa15f02a209ed4c9525b26a79cebb8fee3 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
-Copyright (c) 2016, Texas Instruments Incorporated - http://www.ti.com/
+Copyright (c) 2017, Texas Instruments Incorporated - http://www.ti.com/
 All rights reserved.
 
 * Redistribution and use in source and binary forms, with or without 
@@ -58,14 +58,18 @@ All rights reserved.
 #include "aspMsg_common.h"
 #include "aspMsg_slave.h"
 #include "aspDecOpCircBuf_slave.h"
+#include "aspOutInitSync_slave.h"
 #include "audioStreamProc_common.h"
 #include "audioStreamDecodeProc.h"
+#include "statusOp_common.h"
+
+#include "pfp/pfp.h"
+#include "pfp_app.h"        /* contains all PFP ID's */
 
 // FL: debug
-//#include "fwkSim.h"
 #include "dbgCapAf.h"
 #include "dbgDib.h"
-
+#include "evmc66x_gpio_dbg.h"
 
 //
 // Decoder Definitions
@@ -74,6 +78,11 @@ All rights reserved.
 
 #define __TASK_NAME__  "TaskAsdp"
 
+// Check decoder sync using information in INFO audio frame 
+static Int8 checkDecSync(
+    PAF_AudioFrame *pAf
+);
+
 extern struct {
     Int size;
     IALG_Status *pStatus[512];
@@ -88,8 +97,10 @@ ERRNO_DEFN(TaskAsdp); /* Error number macros */
 // ASDT configuration
 PAF_ASDT_Config gPAF_ASDT_config 
 __attribute__ ((section(".globalSectionPafAsdtConfig"))) = {
+    NULL,               // taskHandle
     NULL,               // acp
-    {NULL, NULL},       // decOpCircBufCtl
+    {NULL, 0, NULL},    // decOpCircBufCtl
+    {NULL, NULL},       // outIsCtl
     &gPAF_AST_config    // ASIT/ASOT/ASDT shared configuration
 };
 
@@ -98,9 +109,12 @@ PAF_AudioData  *gDecAudioFrameChannelPointers[PAF_MAXNUMCHAN_AF];
 PAF_AudioSize  gDecAudioFrameChannelSizes[PAF_MAXNUMCHAN_AF];
 PAF_AudioData  *gDecOrigAudioFrameChannelPointers[PAF_MAXNUMCHAN_AF];
 
-// Underflow threshold before returning error to Top-Level FSM
+// Overflow threshold before circular buffer reset and return error to Top-Level FSM
 #define DEC_OP_CB_WRTAF_OVR_THR  ( 20 ) // FL: arbitrary setting
-UInt32 gDecOpCbWrtAfOvr  =0; // decoder output circular buffer overflow count
+UInt32 gCbWrtAfErrCnt           =0; // decoder output circular buffer write error count, not including overflows
+UInt32 gDecOpCbWrtAfOvr         =0; // decoder output circular buffer overflow count
+UInt32 gMaxDecOpCbWrtAfOvr      =0; // max (consecutive) decoder output circular buffer overflow count
+UInt32 gSlaveCbResetCnt         =0; // slave circular buffer reset count
 
 // Global debug counters */
 UInt32 gSlaveStartErrCnt        =0;
@@ -116,6 +130,15 @@ UInt32 gSlaveDecDecodeCnt       =0;
 UInt32 gSlaveDecDeactivateCnt   =0;
 
 
+//#define CAPTURE_DECODER_OUTSAMPLES_PP
+#ifdef CAPTURE_DECODER_OUTSAMPLES_PP
+
+#define CAP_FRAME_MAX            2000
+Uint32 tempCap_frameCnt = 0;
+int tempCap_decSampleOut[CAP_FRAME_MAX] = {0};
+#endif
+
+
 /*
  *  ======== taskAsdpFxn ========
  *  Audio Stream Decode Processing task function
@@ -126,11 +149,11 @@ Void taskAsdpFxn(
     const PAF_ASDT_Patchs *pQ
 )
 {
-    PAF_ASDT_Config *pC;            /* Local configuration pointer */
-    PAF_AST_Config *pAstCfg;        /* Common (shared) configuration pointer */
-    Int as;                         /* Audio Stream Number (1, 2, etc.) */
-    Int z;                          /* input/encode/stream/decode/output counter */
-    Int i;                          /* phase */
+    PAF_ASDT_Config *pAsdtCfg;          // ASDT configuration pointer
+    PAF_AST_Config *pAstCfg;            // Common (shared) configuration pointer
+    Int as;                             // Audio Stream Number (1, 2, etc.)
+    Int z;                              // input/encode/stream/decode/output counter
+    Int i;                              // phase
     Int zMD, zMS;
     Bool done;
     Bool decDone;
@@ -138,27 +161,33 @@ Void taskAsdpFxn(
     ASP_Slave_Cmd slaveCmd;
     Int sourceSelect;
     DEC_Handle dec;
-    IALG_Cmd decCtrlCmd;            // decoder control command
-    Int decCtrlRet;                 // decoder control return
-    Int errno;                      /* error number */
+    IALG_Cmd decCtrlCmd;                // decoder control command
+    Int decCtrlRet;                     // decoder control return
+    Int errno;                          // error number
     Int size;
     Int argIdx;
     // Decoder output circular buffer
-    PAF_AST_DecOpCircBufCtl *pCbCtl;    /* Decoder output circular buffer control */
-    //PAF_AST_DecOpCircBuf *pCb;
-    PAF_AudioFrame *pAfWrt;
-    Int cbErrno;    
+    PAF_AST_DecOpCircBufCtl *pCbCtl;    // Decoder output Circular Buffer control
+    PAF_AudioFrame *pAfWrt;             // pointer to audio frame written to CB
+    Int cbErrno;                        // CB error number
+    // Output Init-Sync
+    PAF_AudioFrame *pDecCtrlAf;         // pointer to Dec Control audio frame
+    PAF_AST_OutInitSyncCtl *pOutIsCtl;  // OutIS control
+    Int8 outIsDecInfo1Flag;             // indicates whether Dec Info Init-Sync has executed
+    Int8 outIsDecDecode1Flag;           // indicates whether Dec Decode1 Init-Sync has executed
+    Int outIsErrno;                     // OutIS error number
     // Messaging
-    PAF_InpBufConfig *pIpBufConfig;
-    ASP_Msg *pAspMsg;
-    MessageQ_QueueId queId;
+    PAF_InpBufConfig *pIpBufConfig;     // IB buffer configuration
+    ASP_Msg *pAspMsg;                   // Rx/Tx MessageQ message
+    MessageQ_QueueId queId;             // MessageQ ID
     Int status;
     Int zI;
     Int bufEnd, wrapSize, currentBufSize, chunkSize;
+    Int8 temp8;
 
-    
     Log_info0("Enter taskAsdpFxn()");
     
+    
     //
     // Audio Framework Parameters & Patch (*pP, *pQ):
     //
@@ -177,12 +206,14 @@ Void taskAsdpFxn(
     }    
 
     //
-    // Audio Framework Configuration (*pC):
+    // Audio Stream Decode Task Configuration (*pAsdtCfg):
     //
-    pC = &gPAF_ASDT_config;
-    pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration 
-    pCbCtl = &pC->decOpCircBufCtl; // get pointer to circular buffer control
-
+    pAsdtCfg = &gPAF_ASDT_config;           // initialize pointer to task configuration
+    pAsdtCfg->taskHandle = Task_self();     // set task handle
+    pAstCfg = pAsdtCfg->pAstCfg;            // get pointer to AST common (shared) configuration 
+    pCbCtl = &pAsdtCfg->decOpCircBufCtl;    // get pointer to circular buffer control
+    pOutIsCtl = &pAsdtCfg->outIsCtl;        // get pointer to output init-sync control
+    
     // wait for initialization message from master
     do {
         status = MessageQ_get(hAspMsgSlave->slaveQue, (MessageQ_Msg *)&pAspMsg, MessageQ_FOREVER);
@@ -201,8 +232,6 @@ Void taskAsdpFxn(
 
     // invalidate AST shared configuration
     Cache_inv(pAstCfg, sizeof(PAF_AST_Config), Cache_Type_ALLD, 0);
-    // FL: no need to share this pointer, can be local
-    //Cache_inv(&pC, sizeof(PAF_AST_Config *), Cache_Type_ALLD, 0);
     Cache_wait();
     
     // (***) FL: revisit
@@ -249,7 +278,7 @@ Void taskAsdpFxn(
         Int linno;
         if (pP->fxns->initPhase[i])
         {
-            if ((linno = pP->fxns->initPhase[i](pP, pQ, pC)))
+            if ((linno = pP->fxns->initPhase[i](pP, pQ, pAsdtCfg)))
             {
                 LINNO_RPRT(TaskAsdp, linno);
                 return;
@@ -262,13 +291,37 @@ Void taskAsdpFxn(
         TRACE_TERSE2("TaskAsdp: AS%d: initialization phase - %d completed", as+zMS, i);
         LINNO_RPRT(TaskAsdp, -i-3);
     }
-    
+      
+#ifdef NON_CACHE_STATUS
+    //
+    // init Status structure Gate
+    //
+    if (statusOp_Init(GATEMP_INDEX_DEC) == STATUSOP_INIT_FAIL)
+    {
+        TRACE_TERSE1("TaskAsdp: Gate Index %d:initialization status GateMP Fail.", GATEMP_INDEX_DEC);
+    }
+    if (statusOp_Init(GATEMP_INDEX_DDP) == STATUSOP_INIT_FAIL)
+    {
+        TRACE_TERSE1("TaskAsdp: Gate Index %d:initialization status GateMP Fail.", GATEMP_INDEX_DDP);
+    }
+    if (statusOp_Init(GATEMP_INDEX_PCM) == STATUSOP_INIT_FAIL)
+    {
+        TRACE_TERSE1("TaskAsdp: Gate Index %d:initialization status GateMP Fail.", GATEMP_INDEX_PCM);
+    }
+    if (statusOp_Init(GATEMP_INDEX_THD) == STATUSOP_INIT_FAIL)
+    {
+        TRACE_TERSE1("TaskAsdp: Gate Index %d:initialization status GateMP Fail.", GATEMP_INDEX_THD);
+    }
+#endif
+
     //
     // End of Initialization -- final memory usage report.
     //
     if (pP->fxns->memStatusPrint)
     {
-        pP->fxns->memStatusPrint(HEAP_INTERNAL, HEAP_INTERNAL1, HEAP_EXTERNAL, HEAP_INTERNAL1_SHM);
+        pP->fxns->memStatusPrint("ASDT MEMSTAT REPORT",
+            HEAP_INTERNAL, HEAP_INTERNAL1, HEAP_EXTERNAL, 
+            HEAP_INTERNAL1_SHM, HEAP_EXTERNAL_SHM, HEAP_EXTERNAL_NONCACHED_SHM);
     }
     
     // (***) FL: revisit
@@ -278,26 +331,28 @@ Void taskAsdpFxn(
     Cache_wb((Ptr)(&IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM2]), sizeof(IALG_Status *), Cache_Type_ALLD, 0);
     Cache_wb((Ptr)(&IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP]), sizeof(IALG_Status *), Cache_Type_ALLD, 0);
     Cache_wb((Ptr)(&IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP2]), sizeof(IALG_Status *), Cache_Type_ALLD, 0);
+    Cache_wb((Ptr)(&IACP_STD_BETA_TABLE.pStatus[STD_BETA_THD]), sizeof(IALG_Status *), Cache_Type_ALLD, 0);
+    Cache_wb((Ptr)(&IACP_STD_BETA_TABLE.pStatus[STD_BETA_THD2]), sizeof(IALG_Status *), Cache_Type_ALLD, 0);
     Cache_wait();
     
     // (***) FL: revisit
     // write back Status structures for Beta Units initialized on Slave
-    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_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_wb((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM]), size, Cache_Type_ALLD, 0);
+    Cache_wbInv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM]), size, Cache_Type_ALLD, 0);
     size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM2]->size;
-    Cache_wb((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM2]), size, Cache_Type_ALLD, 0);
+    Cache_wbInv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM2]), 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_wbInv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP]), size, Cache_Type_ALLD, 0);
     size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP2]->size;
-    Cache_wb((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP2]), size, Cache_Type_ALLD, 0);
+    Cache_wbInv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP2]), size, Cache_Type_ALLD, 0);
     Cache_wait();
 
     // (***) FL: revisit
     // write back Dec configuration
-    Cache_wb(&pAstCfg->xDec[0], DECODEN*sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
-    Cache_wait();
+    Cache_wbInv(&pAstCfg->xDec[0], DECODEN*sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
+    Cache_wait();*/
     
     // Send initialization complete message to master
     queId = MessageQ_getReplyQueue(pAspMsg);
@@ -343,10 +398,10 @@ Void taskAsdpFxn(
         }
         alg[zMD] = pAstCfg->xDec[zMD].decAlg[sourceSelect];
 
-        // FL: debug, reset IB capture buffer
+        // Reset IB capture buffer (debug)
         //capIbReset();
         //Log_info0("capIbReset()");
-        // FL: debug, reset audio frame capture buffer
+        // Reset audio frame capture buffer (debug)
         //capAfReset();
         
         decDone = FALSE;
@@ -403,8 +458,6 @@ Void taskAsdpFxn(
                     
                 case ASP_SLAVE_DEC_CONTROL:
                     gSlaveDecControlCnt++;
-                    // simulate dec control load
-                    //simLoad(DEC_CONTROL_LOAD);
                     
                     argIdx = 0; // get decIdx
                     z = *(Int32 *)&pAspMsg->buf[argIdx];
@@ -432,18 +485,16 @@ Void taskAsdpFxn(
                     
                 case ASP_SLAVE_DEC_ACTIVATE:
                     gSlaveDecActivateCnt++;
-                    // simulate dec activate load
-                    //simLoad(DEC_ACTIVATE_LOAD);
                     
                     // (***) FL: revisit
                     // invalidate Status structures for shared Beta Units
                     //size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_DECODE]->size;
                     //Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_DECODE]), size, Cache_Type_ALLD, 0);
-                    size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM]->size;
+                    /*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();
+                    Cache_wait();*/
                     
                     argIdx = 0; // get decIdx
                     z = *(Int32 *)&pAspMsg->buf[argIdx];
@@ -459,17 +510,25 @@ Void taskAsdpFxn(
                     }
 
                     // Start writes to circular buffer
-                    //pCb = &pAstCfg->xDecOpCb[z];
                     cbErrno = cbWriteStart(pCbCtl, z);
                     if (cbErrno < 0)
                     {
                         SW_BREAKPOINT;
                     }
-                    // FL: debug, log circular buffer control variables
+                    gCbWrtAfErrCnt=0;       // reset write circular buffer error count
+                    gDecOpCbWrtAfOvr=0;     // reset decoder output circular buffer overflow count
+                    gMaxDecOpCbWrtAfOvr=0;  // reset max decoder output circular buffer overflow count
+                    gSlaveCbResetCnt=0;     // reset slave circular buffer reset count
+                    // Log circular buffer control variables (debug)
                     cbLog(pCbCtl, z, 1, "cbWriteStart");
+                    
                     // Reset audio frame
                     resetAf(pP, z, sourceSelect);
                     
+                    // Initialize OutIS Dec flags
+                    outIsDecInfo1Flag = 0;      // OutIS Dec Info1 hasn't executed
+                    outIsDecDecode1Flag = 0;    // OutIS Dec Decode1 hasn't executed
+                    
                     // send dec activate complete message to master
                     queId = MessageQ_getReplyQueue(pAspMsg);
                     pAspMsg->procId = hAspMsgSlave->slaveProcId;
@@ -486,8 +545,6 @@ Void taskAsdpFxn(
                     
                 case ASP_SLAVE_DEC_RESET:
                     gSlaveDecResetCnt++;
-                    // simulate dec reset load
-                    //simLoad(DEC_RESET_LOAD);
                     
                     argIdx = 0; // get decIdx
                     z = *(Int32 *)&pAspMsg->buf[argIdx];
@@ -497,7 +554,23 @@ Void taskAsdpFxn(
                     errno = 0;
                     if (dec->fxns->reset)
                     {
+                        //
+                        // Execute decode reset
+                        //
                         errno = dec->fxns->reset(dec, NULL, &pAstCfg->xDec[z].decodeControl, &pAstCfg->xDec[z].decodeStatus);
+
+                        // Get pointer to Dec Reset output audio frame
+                        pDecCtrlAf = pAstCfg->xDec[z].decodeControl.pAudioFrame;
+
+                        // Perform Dec Reset Init-Sync
+                        //  - Write Dec Reset output audio frame
+                        //  - Set Dec Reset decoder stage flag
+                        outIsErrno = outIsWriteDecStageFlagAndAf(pOutIsCtl, z, 
+                            ASP_OUTIS_DEC_STAGE_RESET_IDX, 1, pDecCtrlAf);
+                        if (outIsErrno < 0)
+                        {
+                            SW_BREAKPOINT; // debug
+                        }
                     }
 
                     // write back Dec configuration
@@ -508,12 +581,12 @@ Void taskAsdpFxn(
                     // 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_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_wb((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP]), size, Cache_Type_ALLD, 0);
-                    Cache_wait();
-                    
+                    Cache_wbInv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP]), size, Cache_Type_ALLD, 0);
+                    Cache_wait();*/
+
                     // send dec reset complete message to master
                     queId = MessageQ_getReplyQueue(pAspMsg);
                     pAspMsg->procId = hAspMsgSlave->slaveProcId;
@@ -532,15 +605,13 @@ Void taskAsdpFxn(
                     
                 case ASP_SLAVE_DEC_INFO:
                     gSlaveDecInfoCnt++;
-                    // simulate dec info load
-                    //simLoad(DEC_INFO_LOAD);
                     
                     argIdx = 0; // get decIdx
                     z = *(Int32 *)&pAspMsg->buf[argIdx];
                     TRACE_TERSE2("slaveCmd=%d,decIdx=%d", slaveCmd, z);
                     // Get input associated w/ decoder
                     zI = pP->inputsFromDecodes[z];
-                    
+
                     // (***) FL: revisit
                     // invalidate Inp configuration
                     Cache_inv(&pAstCfg->xInp[zI], sizeof(PAF_AST_InpBuf), Cache_Type_ALLD, 0);
@@ -566,8 +637,8 @@ Void taskAsdpFxn(
                     wrapSize = size - chunkSize;
                     // invalidate input data
                     Cache_inv((Ptr)pIpBufConfig->pntr.pSmInt, chunkSize, Cache_Type_ALLD, 0);
-                    TRACE_MSG2("IBUF : pIpBufConfig->pntr.pSmInt: 0x%x and chunkSize: %d", pIpBufConfig->pntr.pSmInt, chunkSize);
                     // invalidate Dec configuration
+                    TRACE_MSG2("IBUF : pIpBufConfig->pntr.pSmInt: 0x%x and chunkSize: %d", (IArg)pIpBufConfig->pntr.pSmInt, chunkSize);
                     Cache_inv(&pAstCfg->xDec[z], sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
                     // status for selected decoder should be invalidated
                     Cache_wait();
@@ -578,7 +649,7 @@ Void taskAsdpFxn(
                     {
                         // invalidate input data
                         Cache_inv((Ptr)pIpBufConfig->base.pSmInt, wrapSize, Cache_Type_ALLD, 0);
-                        TRACE_MSG2("IBUF : pIpBufConfig->base.pSmInt: 0x%x and wrapSize: %d",pIpBufConfig->base.pSmInt, wrapSize);
+                        TRACE_MSG2("IBUF : pIpBufConfig->base.pSmInt: 0x%x and wrapSize: %d", (IArg)pIpBufConfig->base.pSmInt, wrapSize);
                         // status for selected decoder should be invalidated
                         Cache_wait();
                     }
@@ -588,19 +659,63 @@ Void taskAsdpFxn(
                     errno = 0;
                     if (dec->fxns->info)
                     {
-                        errno = dec->fxns->info(dec, NULL, &pAstCfg->xDec[z].decodeControl, &pAstCfg->xDec[z].decodeStatus);
+                        //
+                        // Execute decode info
+                        //
+                        pfpBegin(PFP_ID_ASDT_1, pAsdtCfg->taskHandle);
+                        errno = dec->fxns->info(dec, NULL, 
+                            &pAstCfg->xDec[z].decodeControl, 
+                            &pAstCfg->xDec[z].decodeStatus);
+                        pfpEnd(PFP_ID_ASDT_1, PFP_FINISH_MEAS);
+
+                        //
+                        // Execute Dec Info1 Init-Sync if required
+                        //
+                        if (outIsDecInfo1Flag == 0)
+                        {
+                            // Get pointer to Dec Info1 output audio frame
+                            pDecCtrlAf = pAstCfg->xDec[z].decodeControl.pAudioFrame;
+
+                            if (checkDecSync(pDecCtrlAf) == 1)
+                            {
+                                // Perform Dec Info1 Init-Sync
+                                //  - Write Dec Info1 output audio frame
+                                //  - Set Dec Info1 decoder stage flag
+                                outIsErrno = outIsWriteDecStageFlagAndAf(pOutIsCtl, z, 
+                                    ASP_OUTIS_DEC_STAGE_INFO1_IDX, 1, pDecCtrlAf);
+                                if (outIsErrno < 0)
+                                {
+                                    SW_BREAKPOINT; // debug
+                                }
+
+                                outIsDecInfo1Flag = 1;  // OutIS Dec Info1 has executed
+                            }
+                        }
                     }
                     
                     // write back Dec configuration
                     Cache_wb(&pAstCfg->xDec[z], sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
                     Cache_wait();            
                     
-                    // Re-initialize audio frame if decoder is disabled or 
-                    // doesn't have a valid input 
+#ifdef NON_CACHE_STATUS
+                    statusOp_read(&(temp8),
+                                  &(pAstCfg->xDec[z].decodeStatus.mode),
+                                  sizeof(Int8),
+                                  GATEMP_INDEX_DEC);
+                    // Re-initialize audio frame if decoder is disabled or
+                    // doesn't have a valid input
+                    if (!temp8 || !pAstCfg->xInp[zI].hRxSio)
+                    {
+                        pP->fxns->initFrame1(pP, pQ, pAsdtCfg, z, 0);
+                    }
+#else
+                    // Re-initialize audio frame if decoder is disabled or
+                    // doesn't have a valid input
                     if (!pAstCfg->xDec[z].decodeStatus.mode || !pAstCfg->xInp[zI].hRxSio)
                     {
-                        pP->fxns->initFrame1(pP, pQ, pC, z, 0);
+                        pP->fxns->initFrame1(pP, pQ, pAsdtCfg, z, 0);
                     }
+#endif
 
                     // send dec info complete message to master
                     queId = MessageQ_getReplyQueue(pAspMsg);
@@ -620,8 +735,6 @@ Void taskAsdpFxn(
                     
                 case ASP_SLAVE_DEC_DECODE:
                     gSlaveDecDecodeCnt++;
-                    // simulate dec info load
-                    //simLoad(DEC_DECODE_LOAD);
                     
                     argIdx = 0; // get decIdx
                     z = *(Int32 *)&pAspMsg->buf[argIdx];
@@ -632,7 +745,7 @@ Void taskAsdpFxn(
                     // Reset AF samsiz
                     resetAfSamsiz(z);
                     
-                    // invalidate Dec configuration
+                    // Invalidate Dec configuration
                     Cache_inv(&pAstCfg->xDec[z], sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
                     Cache_wait();
                     //TRACE_TERSE0("Dec:cache wb done");
@@ -644,54 +757,137 @@ Void taskAsdpFxn(
                     cbErrno = 0;
                     if (dec->fxns->decode)
                     {
-                        // FL: debug, capture input buffer
+                        // Capture input buffer (debug)
                         //capIb(pAstCfg->xInp[z].pInpBuf);
-                    
+                        
+                        //
+                        // Execute decode
+                        //
+                        pfpBegin(PFP_ID_ASDT_2, pAsdtCfg->taskHandle);
                         errno = dec->fxns->decode(dec, NULL, &pAstCfg->xDec[z].decodeInStruct, &pAstCfg->xDec[z].decodeOutStruct);
+                        pfpEnd(PFP_ID_ASDT_2, PFP_FINISH_MEAS);
                         if (errno < 0)
                         {
-                            SW_BREAKPOINT;
+                            //SW_BREAKPOINT;
                         }
                         TRACE_TERSE0("Dec:decode done");
+
+                        // Get pointer to Dec Decode output audio frame
+                        pAfWrt = pAstCfg->xDec[z].decodeOutStruct.pAudioFrame;                           
+                        TRACE_TERSE2("Dec:pAfWrt=0x%04x, nSamples=%d", (IArg)pAfWrt, pAfWrt->data.nSamples);
                         
-                        // copy decoder output to decoder output circular buffers
-                        //pCb = &pAstCfg->xDecOpCb[z];
-                        //TRACE_TERSE1("Dec:pCb=0x%04x", (IArg)pCb);
-                        
-                        pAfWrt = pAstCfg->xDec[z].decodeOutStruct.pAudioFrame;
-                        TRACE_TERSE1("Dec:pAfWrt=0x%04x", (IArg)pAfWrt);
-                        //TRACE_TERSE1("nSamples=%d",pAfWrt->data.nSamples);
-                        
-                        // FL: debug, capture audio frame
-                        //if (capAfWrite(pAfWrt, PAF_CNTR) != CAP_AF_SOK)
+                        // Capture audio frame (debug)
+                        //if (capAfWrite(pAfWrt, PAF_LEFT) != CAP_AF_SOK)
                         //{
                         //    Log_info0("capAfWrite() error");
-                        //}                        
+                        //}
 
-                        cbErrno = cbWriteAf(pCbCtl, z, pAfWrt);
-                        if (cbErrno < 0)
+                        #ifdef CAPTURE_DECODER_OUTSAMPLES_PP
+                        if (tempCap_frameCnt < CAP_FRAME_MAX)
                         {
-                            SW_BREAKPOINT; // FL: debug
+                            tempCap_decSampleOut[tempCap_frameCnt] = pAfWrt->sampleCount;
+                            tempCap_frameCnt++;
+                        }
+                        #endif
+
+                        //
+                        // Execute Dec Decode1 Init-Sync if required
+                        //
+                        if (outIsDecDecode1Flag == 0)
+                        {
+                            //
+                            // FL: cbInitSourceSel() moved from DSP:ASIT:INIT:decodeInit()
+                            //  frameLength: changed to decodeControl.frameLength.
+                            //    Written by ASIT:decodeInit:getFrameLengthSourceSel().
+                            
+                            // Initialize decoder output circular buffer
+                            errno = cbInitDecWrite(pCbCtl, z, sourceSelect,
+                                pAstCfg->xDec[z].decodeControl.frameLength, 
+                                0, pAfWrt);
+                            if (errno)
+                            {
+                                SW_BREAKPOINT; // debug
+                            }
+                            // debug
+                            cbLog(pCbCtl, z, 1, "cbInitSourceSel");
                             
-                            if (cbErrno == ASP_DECOP_CB_WRITE_OVERFLOW)
+                            // Perform Dec Decode1 Init-Sync
+                            //  - Set Dec Decode1 decoder stage flag
+                            outIsErrno = outIsWriteDecStageFlag(pOutIsCtl, z, 
+                                ASP_OUTIS_DEC_STAGE_DECODE1_IDX, 1);
+                            if (outIsErrno < 0)
+                            {
+                                SW_BREAKPOINT; // debug
+                            }
+
+                            outIsDecDecode1Flag = 1;    // OutIS Dec Decode1 has executed
+                        }
+
+                        //
+                        // Write decoder output audio frame to circular buffer
+                        //
+
+                        // debug
+                        //pCb = &pAstCfg->xDecOpCb[z];
+                        //TRACE_TERSE1("Dec:pCb=0x%04x", (IArg)pCb);                                                
+
+                        GPIOSetOutput(GPIO_PORT_0, GPIO_PIN_99); // debug
+                        cbErrno = cbWriteAf(pCbCtl, z, pAfWrt);
+                        GPIOClearOutput(GPIO_PORT_0, GPIO_PIN_99);
+                        if ((cbErrno < 0) && 
+                            (cbErrno != ASP_DECOP_CB_AF_WRITE_OVERFLOW) && 
+                            (cbErrno != ASP_DECOP_CB_PCM_WRITE_OVERFLOW))
+                        {
+                            gCbWrtAfErrCnt++;
+                            //SW_BREAKPOINT; // debug
+                        }
+                        
+                        // Handle circular buffer overflows
+                        if ((cbErrno == ASP_DECOP_CB_AF_WRITE_OVERFLOW) ||
+                            (cbErrno == ASP_DECOP_CB_PCM_WRITE_OVERFLOW))
+                        {
+                            gDecOpCbWrtAfOvr++; // increment circular buffer overflow count
+                            if (gDecOpCbWrtAfOvr >= DEC_OP_CB_WRTAF_OVR_THR)
                             {
+                                gMaxDecOpCbWrtAfOvr = DEC_OP_CB_WRTAF_OVR_THR; // update max overflow count
+                                gDecOpCbWrtAfOvr = 0; // reset overflow count
+                                
                                 // Reset circular buffer
                                 cbReset(pCbCtl, z);
-                                // Update overflow count, return if above threshold
-                                gDecOpCbWrtAfOvr++;
-                                if (gDecOpCbWrtAfOvr < DEC_OP_CB_WRTAF_OVR_THR)
-                                {
-                                    cbErrno = 0;
-                                }
-                                else 
-                                {
-                                    gDecOpCbWrtAfOvr = 0;
-                                }
+                                gSlaveCbResetCnt++; // increment slave circular buffer reset count
+                                Log_info0("ASDT:cbReset");
                             }
                         }
+                        else if ((cbErrno == ASP_DECOP_CB_SOK) && (gDecOpCbWrtAfOvr > 0))
+                        {
+                            // No overflow detected.
+                            // update max overflow count,
+                            // reset overflow count
+                            
+                            if (gDecOpCbWrtAfOvr > gMaxDecOpCbWrtAfOvr)
+                            {
+                                gMaxDecOpCbWrtAfOvr = gDecOpCbWrtAfOvr;
+                            }
+                            gDecOpCbWrtAfOvr = 0; // reset circular buffer overflow count
+                            
+                            cbErrno = 0; // don't return error condition
+                        }
+                        //GPIOClearOutput(GPIO_PORT_0, GPIO_PIN_107);
                         TRACE_TERSE0("Dec:cbWriteAf() complete");
                         
-                        // FL: debug, log circular buffer control variables
+#if 0 // (***) FL: shows timing of CB write
+                        // (***) debug // B9
+                        {
+                            static Uint8 toggleState = 0;
+                            if (toggleState == 0)
+                                GPIOSetOutput(GPIO_PORT_0, GPIO_PIN_107);
+                            else
+                                GPIOClearOutput(GPIO_PORT_0, GPIO_PIN_107);
+                            toggleState = ~(toggleState);
+                        }
+#endif        
+                        
+                        // Log circular buffer control variables (debug)
                         cbLog(pCbCtl, z, 1, "cbWriteAf");
                     }
                     
@@ -699,13 +895,25 @@ Void taskAsdpFxn(
                     Cache_wb(&pAstCfg->xDec[z], sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
                     Cache_wait();
                     
+#ifdef NON_CACHE_STATUS
+                    statusOp_read(&(temp8),
+                                  &(pAstCfg->xDec[z].decodeStatus.mode),
+                                  sizeof(Int8),
+                                  GATEMP_INDEX_DEC);
                     // Re-initialize audio frame if decoder is disabled or 
                     // doesn't have a valid input 
+                    if (!temp8 || !pAstCfg->xInp[zI].hRxSio)
+                    {
+                        pP->fxns->initFrame1(pP, pQ, pAsdtCfg, z, 0);
+                    }
+#else
+                    // Re-initialize audio frame if decoder is disabled or
+                    // doesn't have a valid input
                     if (!pAstCfg->xDec[z].decodeStatus.mode || !pAstCfg->xInp[zI].hRxSio)
                     {
-                        pP->fxns->initFrame1(pP, pQ, pC, z, 0);
+                        pP->fxns->initFrame1(pP, pQ, pAsdtCfg, z, 0);
                     }
-
+#endif
                     // send dec info complete message to master
                     queId = MessageQ_getReplyQueue(pAspMsg);
                     pAspMsg->procId = hAspMsgSlave->slaveProcId;
@@ -726,8 +934,6 @@ Void taskAsdpFxn(
                     
                 case ASP_SLAVE_DEC_DEACTIVATE:
                     gSlaveDecDeactivateCnt++;
-                    // simulate dec info load
-                    //simLoad(DEC_DEACTIVATE_LOAD);
                     
                     argIdx = 0; // get decIdx
                     z = *(Int32 *)&pAspMsg->buf[argIdx];
@@ -739,15 +945,21 @@ Void taskAsdpFxn(
                     }
                     
                     // Stop writes to circular buffer
-                    //pCb = &pAstCfg->xDecOpCb[z];
                     cbErrno = cbWriteStop(pCbCtl, z);
                     if (cbErrno < 0)
                     {
-                        SW_BREAKPOINT;
+                        SW_BREAKPOINT; // debug
                     }
-                    // FL: debug, log circular buffer control variables
+                    // Log circular buffer control variables (debug)
                     cbLog(pCbCtl, z, 1, "cbWriteStop");
                     
+                    // Reset Output Init-Sync decoder stage flags
+                    outIsErrno = outIsResetDecStageFlags(pOutIsCtl, z);
+                    if (outIsErrno < 0)
+                    {
+                        SW_BREAKPOINT; // debug
+                    }
+                    
                     // send dec deactivate complete message to master
                     queId = MessageQ_getReplyQueue(pAspMsg);
                     pAspMsg->procId = hAspMsgSlave->slaveProcId;
@@ -792,7 +1004,7 @@ Int
 PAF_ASDT_initPhaseMalloc(
     const PAF_ASDT_Params *pP, 
     const PAF_ASDT_Patchs *pQ, 
-    PAF_ASDT_Config *pC
+    PAF_ASDT_Config *pAsdtCfg
 )
 {
     PAF_AST_Config *pAstCfg;
@@ -800,7 +1012,7 @@ PAF_ASDT_initPhaseMalloc(
     Int zMS;
     Error_Block eb;
 
-    pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
+    pAstCfg = pAsdtCfg->pAstCfg; // get pointer to AST common (shared) configuration
     as = pAstCfg->as;
     zMS = pAstCfg->masterStr;
     
@@ -809,8 +1021,7 @@ PAF_ASDT_initPhaseMalloc(
     // Initialize error block
     Error_init(&eb); 
 
-//    if (!(gpDecAudioFrame = (PAF_AudioFrame *)Memory_calloc((IHeap_Handle)HEAP_INTERNAL1,
-    if (!(gpDecAudioFrame = (PAF_AudioFrame *)Memory_calloc((IHeap_Handle)HEAP_EXTERNAL, //Qin - moved to external memory
+    if (!(gpDecAudioFrame = (PAF_AudioFrame *)Memory_calloc((IHeap_Handle)HEAP_EXTERNAL,
         DECODEN * sizeof (PAF_AudioFrame), 4, &eb)))
     {
         TRACE_TERSE1("PAF_ASDT_initPhaseMalloc: AS%d: Memory_calloc failed", as+zMS);
@@ -845,7 +1056,7 @@ Int
 PAF_ASDT_initPhaseConfig(
     const PAF_ASDT_Params *pP, 
     const PAF_ASDT_Patchs *pQ, 
-    PAF_ASDT_Config *pC
+    PAF_ASDT_Config *pAsdtCfg
 )
 {
     PAF_AST_Config *pAstCfg;
@@ -853,7 +1064,7 @@ PAF_ASDT_initPhaseConfig(
     Int zMS;
     Int z;
 
-    pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
+    pAstCfg = pAsdtCfg->pAstCfg; // get pointer to AST common (shared) configuration
     as = pAstCfg->as;
     zMS = pAstCfg->masterStr;
     
@@ -868,7 +1079,7 @@ PAF_ASDT_initPhaseConfig(
         pAstCfg->xDec[z].decodeControl.pAudioFrame = &gpDecAudioFrame[z];
         pAstCfg->xDec[z].decodeInStruct.pAudioFrame = &gpDecAudioFrame[z];
         pAstCfg->xDec[z].decodeStatus = *pP->z_pDecodeStatus[z];
-        pP->fxns->initFrame0(pP, pQ, pC, z);
+        pP->fxns->initFrame0(pP, pQ, pAsdtCfg, z);
     }
 
     return 0;
@@ -893,7 +1104,7 @@ Int
 PAF_ASDT_initPhaseAcpAlg(
     const PAF_ASDT_Params *pP, 
     const PAF_ASDT_Patchs *pQ, 
-    PAF_ASDT_Config *pC
+    PAF_ASDT_Config *pAsdtCfg
 )
 {
     PAF_AST_Config *pAstCfg;
@@ -904,7 +1115,7 @@ PAF_ASDT_initPhaseAcpAlg(
     Int zMS;
     Int zS; //, zX;
 
-    pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
+    pAstCfg = pAsdtCfg->pAstCfg; // get pointer to AST common (shared) configuration
     as = pAstCfg->as;
     zMS = pAstCfg->masterStr;    
 
@@ -917,7 +1128,7 @@ PAF_ASDT_initPhaseAcpAlg(
         TRACE_TERSE1("PAF_ASDT_initPhaseAcpAlg: AS%d: ACP algorithm instance creation  failed", as+zMS);
         return __LINE__;
     }
-    pC->acp = acp;
+    pAsdtCfg->acp = acp;
 
     ((ALG_Handle)acp)->fxns->algControl((ALG_Handle)acp,
         ACP_GETBETAPRIMEOFFSET, (IALG_Status *)&betaPrimeOffset);
@@ -963,7 +1174,7 @@ Int
 PAF_ASDT_initPhaseCommon(
     const PAF_ASDT_Params *pP, 
     const PAF_ASDT_Patchs *pQ, 
-    PAF_ASDT_Config *pC
+    PAF_ASDT_Config *pAsdtCfg
 )
 {
     PAF_AST_Config *pAstCfg;
@@ -974,8 +1185,8 @@ PAF_ASDT_initPhaseCommon(
     PAF_IALG_Config pafAlgConfig;
     IALG_MemRec common[3][PAF_IALG_COMMON_MEMN+1];
    
-    acp = pC->acp; // get acp handle
-    pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
+    acp = pAsdtCfg->acp; // get acp handle
+    pAstCfg = pAsdtCfg->pAstCfg; // get pointer to AST common (shared) configuration
     as = pAstCfg->as;
     
     TRACE_TERSE0("PAF_ASDT_initPhaseCommon: initialization phase - Common Memory");
@@ -986,11 +1197,12 @@ PAF_ASDT_initPhaseCommon(
 
     TRACE_TERSE0("PAF_ASDT_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_ID_EXTERNAL_SHM,   HEAP_EXTERNAL_SHM, 
+        HEAP_ID_INTERNAL,               HEAP_INTERNAL, 
+        HEAP_ID_INTERNAL1,              HEAP_INTERNAL1, 
+        HEAP_ID_EXTERNAL,               HEAP_EXTERNAL, 
+        HEAP_ID_INTERNAL1_SHM,          HEAP_INTERNAL1_SHM, 
+        HEAP_ID_EXTERNAL_SHM,           HEAP_EXTERNAL_SHM, 
+        HEAP_ID_EXTERNAL_NONCACHED_SHM, HEAP_EXTERNAL_NONCACHED_SHM,
         HEAP_CLEAR);
 
     if (pP->fxns->headerPrint)
@@ -1158,7 +1370,7 @@ Int
 PAF_ASDT_initPhaseAlgKey(
     const PAF_ASDT_Params *pP, 
     const PAF_ASDT_Patchs *pQ, 
-    PAF_ASDT_Config *pC
+    PAF_ASDT_Config *pAsdtCfg
 )
 {
     PAF_AST_Config *pAstCfg;
@@ -1169,7 +1381,7 @@ PAF_ASDT_initPhaseAlgKey(
 
     (void)as;  // clear warning.
 
-    pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
+    pAstCfg = pAsdtCfg->pAstCfg; // get pointer to AST common (shared) configuration
     as = pAstCfg->as;
     
     TRACE_VERBOSE1("PAF_ASDT_initPhaseAlgKey: AS%d: initialization phase - Algorithm Keys", as);
@@ -1199,7 +1411,7 @@ Int
 PAF_ASDT_initFrame0(
     const PAF_ASDT_Params *pP, 
     const PAF_ASDT_Patchs *pQ, 
-    PAF_ASDT_Config *pC
+    PAF_ASDT_Config *pAsdtCfg
     Int z
 )
 {
@@ -1215,7 +1427,7 @@ PAF_ASDT_initFrame0(
     PAF_AudioFrame *pAudioFrame;
     Int i;
 
-    pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
+    pAstCfg = pAsdtCfg->pAstCfg; // get pointer to AST common (shared) configuration
     as = pAstCfg->as;
 
     pAudioFrame = &gpDecAudioFrame[z];
@@ -1228,7 +1440,9 @@ PAF_ASDT_initFrame0(
     Error_init(&eb); 
     
     //maxFrameLength += PA_MODULO - maxFrameLength % PA_MODULO; // compute maximum framelength (needed for ARC support)
-    aLen = numchan[z] * maxFrameLength;
+    //aLen = numchan[z] * maxFrameLength;
+    aLen = numchan[z] * maxFrameLength + (maxFrameLength - FRAMELENGTH); /* Qin - need additional memory for starting offset
+                                                                                  See line 1301 */
 
     //
     // Initialize audio frame elements directly
@@ -1351,7 +1565,7 @@ Int
 PAF_ASDT_initFrame1(
     const PAF_ASDT_Params *pP, 
     const PAF_ASDT_Patchs *pQ, 
-    PAF_ASDT_Config *pC
+    PAF_ASDT_Config *pAsdtCfg
     Int z, 
     Int apply
 )
@@ -1408,12 +1622,13 @@ Int resetAf(
     }
 
     // Reinitialize audio frame elements
-    pAudioFrame->channelConfigurationRequest.legacy = PAF_CC_NONE;
-    pAudioFrame->channelConfigurationStream.legacy = PAF_CC_NONE;
+    pAudioFrame->sampleDecode = PAF_SOURCE_UNKNOWN;
     pAudioFrame->sampleRate = PAF_SAMPLERATE_UNKNOWN;
     pAudioFrame->sampleCount = 0;
-    pAudioFrame->data.nChannels = PAF_MAXNUMCHAN;
+    pAudioFrame->channelConfigurationRequest.full = PAF_CC_UNKNOWN;
+    pAudioFrame->channelConfigurationStream.full = PAF_CC_UNKNOWN;
     
+    pAudioFrame->data.nChannels = PAF_MAXNUMCHAN;
     switch (sourceSelect)
     {
         case PAF_SOURCE_PCM:
@@ -1423,6 +1638,9 @@ Int resetAf(
         case PAF_SOURCE_DDP:
             pAudioFrame->data.nSamples = 1536;
             break;
+        case PAF_SOURCE_THD:
+            pAudioFrame->data.nSamples = 5120; //QIN FIX ME
+            break;
         default:  
             pAudioFrame->data.nSamples = FRAMELENGTH;
             break;
@@ -1441,7 +1659,7 @@ Int resetAf(
     pAudioFrame->pafBsMetadataUpdate = XDAS_FALSE;
     pAudioFrame->numPrivateMetadata = 0;
     pAudioFrame->bsMetadata_offset = 0;
-    pAudioFrame->bsMetadata_type = PAF_bsMetadata_channelData;
+    pAudioFrame->bsMetadata_type = PAF_bsMetadata_none;
     for (i=0; i<pP->pMetadataBufStatus->NumBuf; i++)
     {
         pAudioFrame->pafPrivateMetadata[i].offset = 0;
@@ -1474,3 +1692,20 @@ Int resetAfSamsiz(
 
     return 0;
 }
+
+// (***) FL: Check correct behavior for other decs, esp DTSHD & DXP
+// Check decoder sync using information in INFO audio frame
+static Int8 checkDecSync(
+    PAF_AudioFrame *pAf
+)
+{
+    if ((pAf->sampleDecode == PAF_SOURCE_THD) &&
+        (pAf->sampleRate == PAF_SAMPLERATE_UNKNOWN))
+    {
+        return 0;
+    }
+    else
+    {
+        return 1;
+    }
+}