PASDK-218:Fix logic for reporting CB drain state
authorFrank Livingston <frank-livingston@ti.com>
Fri, 7 Jul 2017 18:26:24 +0000 (13:26 -0500)
committerFrank Livingston <frank-livingston@ti.com>
Fri, 7 Jul 2017 18:26:24 +0000 (13:26 -0500)
pasdk/test_dsp/framework/audioStreamOutProc.c

index 2dced74ccbaa07c5245b8be770ff037d18c68ce5..74a4922748e0b11882b51c757e0648557ed55b8c 100644 (file)
@@ -2901,13 +2901,17 @@ PAF_ASOT_setCheckRateX(
     rateI = pAstCfg->xStr[zMS].pAudioFrame->fxns->sampleRateHz
         (pAstCfg->xStr[zMS].pAudioFrame, inputRate, PAF_SAMPLERATEHZ_INV);
 
-    for (z=OUTPUT1; z < OUTPUTN; z++) {
-        if (pAstCfg->xOut[z].hTxSio && (pAstCfg->xOut[z].outBufStatus.clock & 0x01)) {
+    for (z=OUTPUT1; z < OUTPUTN; z++) 
+    {
+        if (pAstCfg->xOut[z].hTxSio && (pAstCfg->xOut[z].outBufStatus.clock & 0x01)) 
+        {
 
             // determine associated encoder
             zE = z;
-            for (zX = ENCODE1; zX < ENCODEN; zX++) {
-                if (pP->outputsFromEncodes[zX] == z) {
+            for (zX = ENCODE1; zX < ENCODEN; zX++) 
+            {
+                if (pP->outputsFromEncodes[zX] == z) 
+                {
                     zE = zX;
                     break;
                 }
@@ -2917,18 +2921,29 @@ PAF_ASOT_setCheckRateX(
             outputCount = pAstCfg->xEnc[zE].encodeStatus.frameLength;
             rateO = pAstCfg->xStr[zMS].pAudioFrame->fxns->sampleRateHz
                 (pAstCfg->xStr[zMS].pAudioFrame, outputRate, PAF_SAMPLERATEHZ_STD);
-            if (rateI > 0 && rateO > 0)
+            if ((rateI > 0) && (rateO > 0))
+            {
                 rateX = rateO /* std */ * rateI /* inv */;
+            }
             else if (inputCount != 0)
+            {
                 rateX = (float )outputCount / inputCount;
+            }
             else
+            {
                 return ( ASPERR_INFO_RATERATIO );
+            }
 
             getVal = SIO_ctrl (pAstCfg->xOut[z].hTxSio, PAF_SIO_CONTROL_SET_RATEX, (Arg) &rateX);
-            if (getVal == DOBERR_RATECHANGE) {
+            if (getVal == DOBERR_RATECHANGE) 
+            {
                 for (zx=OUTPUT1; zx < OUTPUTN; zx++)
+                {
                     if (pAstCfg->xOut[zx].hTxSio)
+                    {
                         SIO_idle (pAstCfg->xOut[zx].hTxSio);
+                    }
+                }
 
                 // this forces an exit from the calling state machine which will
                 // eventually call startOutput which calls setCheckRateX for all outputs
@@ -2937,7 +2952,9 @@ PAF_ASOT_setCheckRateX(
                 return ASPERR_INFO_RATECHANGE;
             }
             else if( getVal != SYS_OK )
+            {
                 return ((getVal & 0xff) | ASPERR_RATE_CHECK);
+            }
         }
     }
 
@@ -3509,7 +3526,7 @@ PAF_ASOT_decodeFinalTest(
         return errno;
     }
     
-    if (drainedFlag == 0)
+    if (drainedFlag == 1)
     {
         return ASOP_DP_CB_DRAINED;
     }