Fixed problem of input task being stuck when input stream stops:
[processor-sdk/performance-audio-sr.git] / pasdk / test_dsp / framework / audioStreamInpProcNewIO.c
index 1ce5608d32efdafd040b152b3849b7e90198dad9..4d95b8b4bd579144d7b9c4d114d1a59a57157707 100644 (file)
@@ -190,6 +190,8 @@ Int asipErrno;
 Int inputReadyForProcessing;
 #endif
 
+    Int firstTimeInit = TRUE;
+
     Log_info0("Enter taskAsipFxn()");
 
     taskAsipFxnInit(pP, pQ);  // initialization of input task
@@ -240,15 +242,22 @@ Int inputReadyForProcessing;
 
             inputReadyForProcessing = asipPrepareProcessing(pP, pQ, pAsitCfg, &asipErrno);
             if (inputReadyForProcessing) {
-                // Input is ready for processing, so we initialize the I/O components
-                asipIoCompsInit(&pAstCfg->xInp[zMI], pInp);
+                // Input is ready for processing, so we initialize the I/O components.
+                // Note that the I/O components init. and I/O PHY prime are performed only at the
+                // first time. This should be changed later - init. and prime should be done whenever
+                // input interface has changed.
+                if(firstTimeInit) {
+                    asipIoCompsInit(&pAstCfg->xInp[zMI], pInp);
+
+                    // Start I/O physical layer by priming McASP LLD for input
+                    asipIoPhyPrime(pInp);
+
+                    firstTimeInit = FALSE;
+                }
 
                 // Initialize ASIP processing
                 asipProcInit(pInp, &pAsitCfg->inpDec);
 
-                // Start I/O physical layer by priming McASP LLD for input
-                asipIoPhyPrime(pInp);
-
                 pInp->asipState = ASIP_INPUT_PROCESSING;
             }
             break;
@@ -1072,7 +1081,7 @@ Int asipProcessing(const PAF_ASIT_Params *pP,
             }
 
             // Inform decoder to complete decoding previous frame
-            pInp->sourceSelect = PAF_SOURCE_UNKNOWN;
+            pInp->sourceSelect = PAF_SOURCE_NONE;
 
             pInp->numFrameReceived = 0;
             pInp->asipProcState  = ASIP_SOURCE_DETECTION;
@@ -1087,6 +1096,15 @@ Int asipProcessing(const PAF_ASIT_Params *pP,
 #ifndef PCM_LOOPBACK_TEST
         asipStatus = asipDecodeProcessing(pP, pQ, pAsitCfg, pInp->sourceSelect);
         if(asipStatus != ASIP_NO_ERR) {
+
+            // FL: send dec exit message to slave
+            if( AspMsgSend(ASP_SLAVE_DEC_EXIT, ASP_MASTER_DEC_EXIT_DONE, NULL, NULL)
+                != ASP_MSG_NO_ERR)
+            {
+                TRACE_VERBOSE0("TaskAsip: error in sending DEC_EXIT message");
+                SW_BREAKPOINT;
+            }
+
             return asipStatus;
         }
 #else