PASDK-218:Add check for Dec sync before sending INFO1 sync message
authorFrank Livingston <frank-livingston@ti.com>
Tue, 4 Jul 2017 17:41:11 +0000 (12:41 -0500)
committerFrank Livingston <frank-livingston@ti.com>
Tue, 4 Jul 2017 17:41:11 +0000 (12:41 -0500)
Add check for Dec sync before sending Dec Info1 sync message. This is
similar to logic in DSP:ASIT:decodeProcessing():INFO1 which checks for
THD/DTSHD/DXP majorAu.

Inspecting Dec Info function for various decoders:
- it appears this should work for MAT-THD/PCM, DDP & PCM.
- this may not work for DTSHD and DXP.
Whether it work correctly depends on Dec Info audio frame sampleDecode and
sampleRate output parameters.

Limited testing demonstrates this works for MAT-THD & DDP.

pasdk/test_arm/framework/audioStreamDecodeProc.c

index 636dacfaf4bd049efcfe39c259dece0300e6b0b1..d64d53f8e2fb257fd213c311fe180b5c4f5b94a6 100644 (file)
@@ -78,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];
@@ -133,6 +138,10 @@ Uint32 tempCap_frameCnt = 0;
 int tempCap_decSampleOut[CAP_FRAME_MAX] = {0};
 #endif
 
+// debug
+//PAF_AudioFrame gAfCap[20];
+//gAfCapIdx=0;
+
 /*
  *  ======== taskAsdpFxn ========
  *  Audio Stream Decode Processing task function
@@ -654,42 +663,56 @@ Void taskAsdpFxn(
                             &pAstCfg->xDec[z].decodeStatus);
                         pfpEnd(PFP_ID_ASDT_1, PFP_FINISH_MEAS);
 
+                        // debug
+                        //if (gAfCapIdx < 20)
+                        //{
+                        //    gAfCap[gAfCapIdx] = *pAstCfg->xDec[z].decodeControl.pAudioFrame;
+                        //    gAfCapIdx++;
+                        //}
+                        
+                        // debug
+                        //if (outIsDecInfo1Flag < 10) 
+                        //    outIsDecInfo1Flag++;
+                        //if (outIsDecInfo1Flag == 10)
+                        
                         if (outIsDecInfo1Flag == 0)
                         {
                             // get pointer to Dec Info1 output audio frame
                             pDecCtrlAf = pAstCfg->xDec[z].decodeControl.pAudioFrame;
 
-                            // Perform Dec Info 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)
+                            if (checkDecSync(pDecCtrlAf) == 1)
                             {
-                                SW_BREAKPOINT; // debug
-                            }
-
-                            //
-                            // FL: cbInitSourceSel() moved from DSP:ASIT:INIT:decodeInit()
-                            //  frameLength: changed to decodeControl.frameLength.
-                            //    Written by ASIT:decodeInit:getFrameLengthSourceSel().
-                            //  FRAMELENGTH: pP->frameLength.
-                            //    Formerly ASIT, now ASDT but same value (PAF_SYS_FRAMELENGTH).
-                            //
-                            // FL: hard-coded CB init, not using DEC Info1 output AF
-                            
-                            // Initialize decoder output circular buffer for selected source
-                            errno = cbInitSourceSel(pCbCtl, z, sourceSelect, 
-                                pAstCfg->xDec[z].decodeControl.frameLength, 
-                                FRAMELENGTH, 0, pDecCtrlAf);
-                            if (errno)
-                            {
-                                SW_BREAKPOINT; // debug
+                                // Perform Dec Info 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
+                                }
+
+                                //
+                                // FL: cbInitSourceSel() moved from DSP:ASIT:INIT:decodeInit()
+                                //  frameLength: changed to decodeControl.frameLength.
+                                //    Written by ASIT:decodeInit:getFrameLengthSourceSel().
+                                //  FRAMELENGTH: pP->frameLength.
+                                //    Formerly ASIT, now ASDT but same value (PAF_SYS_FRAMELENGTH).
+                                //
+                                
+                                // Initialize decoder output circular buffer for selected source
+                                errno = cbInitSourceSel(pCbCtl, z, sourceSelect, 
+                                    pAstCfg->xDec[z].decodeControl.frameLength, 
+                                    FRAMELENGTH, 0, pDecCtrlAf);
+                                if (errno)
+                                {
+                                    SW_BREAKPOINT; // debug
+                                }
+                                // debug
+                                cbLog(pCbCtl, z, 1, "cbInitSourceSel");
+
+                                outIsDecInfo1Flag = 1; // set flag to indicate OutIS Dec Info has executed                             
                             }
-                            // debug
-                            cbLog(pCbCtl, z, 1, "cbInitSourceSel");
-
-                            outIsDecInfo1Flag = 1; // set flag to indicate OutIS Dec Info has executed
                         }
                     }
                     
@@ -1647,3 +1670,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;
+    }
+}