]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/performance-audio-sr.git/blobdiff - pasdk/test_dsp/framework/audioStreamOutProc.c
PASDK-443:Fix comment
[processor-sdk/performance-audio-sr.git] / pasdk / test_dsp / framework / audioStreamOutProc.c
index 9fbe6638fa433d1932af4275a1a2cf1430a0c02d..be08b59c5ee0844c717bb5a9b4eb0a3a1ee214dd 100644 (file)
@@ -297,7 +297,12 @@ UInt32 gDecOpCbRdAfUnd      =0; // decoder output circular buffer underflow coun
 UInt32 gMaxDecOpCbRdAfUnd   =0; // max (consecutive) decoder output circular buffer underflow count
 UInt32 gMasterCbResetCnt    =0; // master circular buffer reset count
 
+// For writeDECCommandRestart
+extern volatile UInt32 gCommandOutputTask_SYNC;
+extern volatile UInt32 gCommandOutputTask_ACK;
+
 // Global debug counters */
+UInt32 gAsopTxSioReclaimCnt         =0;
 UInt32 gAsopInitOutProcCnt          =0;
 UInt32 gAsopInitSyncDecResetCnt     =0;
 UInt32 gAsopInitSyncDecInfo1Cnt     =0;
@@ -310,7 +315,6 @@ UInt32 gAsopEncodeCnt               =0;
 UInt32 gAsopFinalCnt                =0;
 UInt32 gAsopOutSioUpdateCnt         =0;
 UInt32 gAsopQuitCnt                 =0;
-UInt32 gAsopTxSioReclaimCnt         =0;
 
 /*
  *  ======== taskAsopFxn ========
@@ -449,6 +453,20 @@ Void taskAsopFxn(
         // Check forward (ASIT) error here, TBD
         //
         
+        // Even if we are not in error state, we check if writeDECCommandRestar issued or not
+        if (gCommandOutputTask_SYNC) {
+            TRACE_TERSE0("TaskAsop: ack for writeDECCommandRestart ... Wait for the command deasserted");
+            gCommandOutputTask_ACK = 1;
+            while (gCommandOutputTask_SYNC) {
+                Task_sleep(1);
+            }
+            TRACE_TERSE0("TaskAsop: ack for writeDECCommandRestart ... Sync-ed! Startover the process");
+            procSleep = 1;                  // init sleep flag -- sleep
+            procOutDevSel = 1;              // init device output selection flag -- perform output device selection
+            state = INIT_OUT_PROC_STATE;    // init state -- starover
+            errno = ASOP_DP_FORWARD_ERR;    // Override the error -- for flushing SIO output device
+        }
+        
         // any error forces idling of output
         if (errno) 
         {
@@ -462,8 +480,8 @@ Void taskAsopFxn(
         
             TRACE_TERSE1("TaskAsop: Trace stopped at loop %d.", loopCount);
             ERRNO_RPRT(TaskAsop, errno);
-        }        
-    
+        }
+        
         if (procSleep == 1)
         {
             TRACE_VERBOSE1("TaskAsop: AS%d: ... sleeping ...", as+zMS);
@@ -1813,7 +1831,13 @@ PAF_ASOT_decodeProcessing(
         // Check forward (ASIT) error here, TBD
         //
         
-        
+        // If writeDECCommandRestart issued, force exit the statemachine
+        if (gCommandOutputTask_SYNC) {
+            TRACE_VERBOSE1("PAF_ASOT_decodeProcessing: writeDECCommandRestart issued in state=0x%x ... exiting core loop", state);
+            errno = ASOP_DP_FORWARD_ERR;
+            break;
+        }
+
         // Check if any change in output SIO, e.g. from Output shortcut.
         // Changes will break FSM and allow Output reconfiguration.
         errno = checkOutSio(pP, pAsotCfg, &outSioUpdate);
@@ -2359,7 +2383,7 @@ PAF_ASOT_decodeStream(
     Int z;                              /* decode/stream counter */
     PAF_AudioFrame *pAfRd;
     Int cbErrno;
-    PAF_AST_DecOpCircBufStats cbStats;  /* circular buffer statistics */
+    //PAF_AST_DecOpCircBufStats cbStats;  /* circular buffer statistics */
     Int errno;
 
 
@@ -2375,9 +2399,9 @@ PAF_ASOT_decodeStream(
         // Read decoder output circular buffer
         //
         pAfRd = pAstCfg->xStr[zS].pAudioFrame;
-        GPIOSetOutput(GPIO_PORT_0, GPIO_PIN_106);   // debug
+        //GPIOSetOutput(GPIO_PORT_0, GPIO_PIN_106);       // debug
         cbErrno = cbReadAf(pCbCtl, z, pAfRd);
-        GPIOClearOutput(GPIO_PORT_0, GPIO_PIN_106);
+        //GPIOClearOutput(GPIO_PORT_0, GPIO_PIN_106);     // debug
         if ((cbErrno < 0) && 
             (cbErrno != ASP_DECOP_CB_AF_READ_UNDERFLOW) && 
             (cbErrno != ASP_DECOP_CB_PCM_READ_UNDERFLOW))
@@ -2427,7 +2451,7 @@ PAF_ASOT_decodeStream(
             gDecOpCbRdAfUnd = 0; // reset circular buffer underflow count
         }
         //Log_info0("PAF_ASOT_decodeStream:cbReadAf() complete.");
-        //GPIOClearOutput(GPIO_PORT_0, GPIO_PIN_106);
+        //GPIOClearOutput(GPIO_PORT_0, GPIO_PIN_106);   // debug
         Log_info0("PAF_ASOT_decodeStream:cbReadAf() complete.");
         
 #if 0 // (***) FL: shows timing of CB read
@@ -2442,17 +2466,19 @@ PAF_ASOT_decodeStream(
             }
 #endif
 
-        // FL: debug
-        // Get circular buffer statistics (debug)
+        // debug, get circular buffer statistics
         //cbGetStats(pCbCtl, z, &cbStats);
         cbGetStats(pCbCtl, z, &gCbStats);
 
         // debug
         cbLog(pCbCtl, z, 1, "PAF_ASOT_decodeStream:cbReadAf");
-        //if (capAfWrite(pAfRd, PAF_LEFT) != CAP_AF_SOK)
-        //{
-        //    Log_info0("capAfWrite() error");
-        //}
+        
+#if 0 // debug, capture audio frame
+        if (capAfWrite(pAfRd, PAF_LEFT) != CAP_AF_SOK)
+        {
+            Log_info0("capAfWrite() error");
+        }
+#endif
     }
             
     TRACE_VERBOSE0("PAF_ASOT_outputStream: calling streamChainFunction.");
@@ -2495,7 +2521,8 @@ PAF_ASOT_decodeEncode(
     Int z;                      /* encode/output counter */
     Int errno;                  /* error number */
     Int zX, zE, zS;
-    UInt32 curTime;
+    // debug
+    //UInt32 curTime;
 
     pAstCfg = pAsotCfg->pAstCfg; // get pointer to AST common (shared) configuration
     as = pAstCfg->as;
@@ -2521,9 +2548,9 @@ PAF_ASOT_decodeEncode(
             pAstCfg->xOut[z].outBufConfig.lengthofFrame = 
                 pAstCfg->xEnc[zE].encodeInStruct.pAudioFrame->sampleCount;
             TRACE_GEN2("PAF_ASOT_decodeEncode: AS%d: processing block %d -- idle", as+zS, block);
-            //GPIOClearOutput(GPIO_PORT_0, GPIO_PIN_106);
+            //GPIOClearOutput(GPIO_PORT_0, GPIO_PIN_106);   // debug
             errno = SIO_reclaim(pAstCfg->xOut[z].hTxSio,(Ptr *) &pAstCfg->xOut[z].pOutBuf, NULL);
-            //GPIOSetOutput(GPIO_PORT_0, GPIO_PIN_106); // debug
+            //GPIOSetOutput(GPIO_PORT_0, GPIO_PIN_106);     // debug
             if (errno < 0)
             {
                 SIO_idle(pAstCfg->xOut[z].hTxSio);
@@ -2532,7 +2559,7 @@ PAF_ASOT_decodeEncode(
             }
             // TODO: use pC->xOut[z].pOutBuf in following ->encode call
 
-#if 0 // (***) FL: shows timing of Output Rx SIO reclaim
+#if 1 // (***) FL: shows timing of Output Tx SIO reclaim
             // (***) debug // B8
             {
                 static Uint8 toggleState = 0;
@@ -2544,15 +2571,15 @@ PAF_ASOT_decodeEncode(
             }
 #endif            
 
-            gAsopTxSioReclaimCnt++;
-
             //
             // Simulate Tx SIO_reclaim() pend
             //
             //Semaphore_pend(semaphoreTxAudio, BIOS_WAIT_FOREVER);
-            curTime = Clock_getTicks();
+            //curTime = Clock_getTicks();
             //System_printf("System time in TaskAsopFxn Tx audio = %lu\n", (ULong)curTime);
             //Log_info1("outputEncode():Tx SIO reclaim(), system time = %u", curTime);
+            
+            gAsopTxSioReclaimCnt++;
         }
         else 
         {
@@ -2651,10 +2678,10 @@ PAF_ASOT_decodeEncode(
         if (pAstCfg->xOut[z].hTxSio) 
         {
             TRACE_GEN2("PAF_ASOT_decodeEncode: AS%d: processing block %d -- output", as+zS, block);
-            //GPIOSetOutput(GPIO_PORT_0, GPIO_PIN_106); // debug
+            //GPIOSetOutput(GPIO_PORT_0, GPIO_PIN_106);       // debug
             errno = SIO_issue(pAstCfg->xOut[z].hTxSio, 
                 &pAstCfg->xOut[z].outBufConfig, sizeof (pAstCfg->xOut[z].outBufConfig), 0);
-            //GPIOClearOutput(GPIO_PORT_0, GPIO_PIN_106);
+            //GPIOClearOutput(GPIO_PORT_0, GPIO_PIN_106);     // debug
             if (errno)
             {
                 SIO_idle(pAstCfg->xOut[z].hTxSio);
@@ -3751,9 +3778,9 @@ PAF_ASOT_decodeFinalTest(
     zMD = pAsotCfg->pAstCfg->masterDec; // get master Dec index
 
     // Check circular buffer drain state
-    //GPIOSetOutput(GPIO_PORT_0, GPIO_PIN_107);
+    //GPIOSetOutput(GPIO_PORT_0, GPIO_PIN_107);     // debug
     errno = cbCheckDrainState(pCbCtl, zMD, &drainedFlag);
-    //GPIOClearOutput(GPIO_PORT_0, GPIO_PIN_107);
+    //GPIOClearOutput(GPIO_PORT_0, GPIO_PIN_107);   // debug
     if (errno < 0)
     {
         return errno;