Merge remote-tracking branch 'origin/PASDK-563-DDP-Verification' into dev_pasdk_frank...
authorFrank Livingston <frank-livingston@ti.com>
Fri, 20 Apr 2018 14:49:52 +0000 (09:49 -0500)
committerFrank Livingston <frank-livingston@ti.com>
Fri, 20 Apr 2018 14:49:52 +0000 (09:49 -0500)
1  2 
pasdk/test_dsp/framework/audioStreamOutIo.c
pasdk/test_dsp/framework/audioStreamOutProc.c

index 49d25883369e5bd466e8219c802c0db74e3b8fee,f8ea42b7d0750b89a87acbb82910b0a76101ead8..2764cfa66a380d82006d09a55aa25d8173690ca1
@@@ -652,9 -689,9 +689,9 @@@ Int asopUpdateOutBufConfig
          
          // already underflows and remain in underflow
      }
+ #if 0
      // Update Output buffer pointer for Encoder
 -      pOutBufCfg->pntr.pLgInt = buff1;
 +    pOutBufCfg->pntr.pLgInt = buff1;
      if ((buff2 != NULL) || (size2 != 0))
      {
          // buff2 should always be NULL for Output & size2 should always be 0 for Output.
index 2302281b4fcdda81b2b75aca92fedb28477ea900,a800d2d7cc7e155337b4d5c957de1382d34fea56..a8dee14d824f457d2df008de7204b15675d0311a
@@@ -245,9 -243,17 +246,17 @@@ static Int PAF_ASOT_initSyncResync
      Int frame
  );
  
+ static Int asopDecOutProcEncodeWrap(
+     const PAF_ASOT_Params *pP,
+     const PAF_ASOT_Patchs *pQ,
+     PAF_ASOT_Config *pAsotCfg,
+     Int frame,
+     Int zO
+ );
  // ASOT SM function
  //   Purpose:   Re-select devices used for Output.
 -//              Performs Init-Sync using stored Dec Reset/Info1 AFs.
 +//              Performs Init-Sync using stored Init-Sync AFs.
  static Int PAF_ASOT_reselectDevices(
      const PAF_ASOT_Params *pP, 
      const PAF_ASOT_Patchs *pQ, 
@@@ -1281,7 -1234,8 +1291,8 @@@ static Int PAF_ASOT_initSyncDecDecode1
          // FL, New IO: API for single Output
  
          // I/O physical layer prime operation required by McASP LLD
 -        asopIoPhyPrime(&pAsotCfg->pIoOut[zO]);        
 +        asopIoPhyPrime(&pAsotCfg->pIoOut[zO]);
+         TRACE_VERBOSE0("PAF_ASOT_initSyncDecDecode1: ASOP McASP LLD primed.");
          
          return ASOP_SOK;
      }
@@@ -1426,9 -1387,98 +1444,98 @@@ static Int PAF_ASOT_procDecOut
      return status;
  }
  
+ static Int asopDecOutProcEncodeWrap(
+     const PAF_ASOT_Params *pP,
+     const PAF_ASOT_Patchs *pQ,
+     PAF_ASOT_Config *pAsotCfg,
+     Int frame,
+     Int zO
+ )
+ {
+     PAF_AST_Config *pAstCfg;    // ASIT/ASOT/ASDT shared configuration
+     Int errno;                  // error number
+     Int status;                 // status code
+     PAF_OutBufConfig *pOutBufCfg;
+     PAF_AudioFrame * pAf;
+     status = ASOP_SOK;
+     pAstCfg = pAsotCfg->pAstCfg;
+     pOutBufCfg = &(pAstCfg->xOut[zO].outBufConfig);
+     pAf = pAstCfg->xEnc[zO].encodeInStruct.pAudioFrame;
+     if(pAsotCfg->pIoOut[zO].buff2 == NULL)
+     {
+         // Output buffer won't wrap around - to invoke the encoder once
+         pOutBufCfg->lengthofFrame = pAf->sampleCount;
+         pOutBufCfg->pntr.pLgInt   = pAsotCfg->pIoOut[zO].buff1;
+         // Execute encode
+         errno = asopDecOutProcEncode(pP, pQ, pAsotCfg, frame);
+         if (errno < 0)
+         {
+             status = errno;
+         }
+     }
+     else
+     {
+         // Output buffer will wrap around - to invoke the encoder twice
+         XDAS_Int16 sampleCountSave;
+         PAF_AudioData *afDataAddrSave[16];
+         PAF_AudioData **afDataAddr;
+         int i, ch;
+         sampleCountSave = pAf->sampleCount;  // save sample count for restoring later
+         // Invoke the encoder to write data to the end of output buffer
+         pOutBufCfg->lengthofFrame = pAsotCfg->pIoOut[zO].size1 / (pOutBufCfg->stride * pOutBufCfg->sizeofElement);
+         pAf->sampleCount = pOutBufCfg->lengthofFrame;
+         pOutBufCfg->pntr.pLgInt   = pAsotCfg->pIoOut[zO].buff1;
+         // Execute encode
+         errno = asopDecOutProcEncode(pP, pQ, pAsotCfg, frame);
+         if (errno < 0)
+         {
+             status = errno;
+         }
+         // Adjust audio frame buffer addresses for second invoking of the encoder
+         afDataAddr = pAf->data.sample;
+         for(i=0; i<pOutBufCfg->stride; i++)
+         {
+             ch = pAstCfg->xEnc[zO].encodeStatus.channelMap.from[i];
+             afDataAddrSave[i] = afDataAddr[ch];   // save audio frame buffer addresses
+             afDataAddr[ch] = &afDataAddr[ch][pOutBufCfg->lengthofFrame];
+         }
+         // Invoke the encoder to write data to the beginning of output buffer (wrapping around)
+         pOutBufCfg->lengthofFrame = pAsotCfg->pIoOut[zO].size2 / (pOutBufCfg->stride * pOutBufCfg->sizeofElement);
+         pAf->sampleCount = pOutBufCfg->lengthofFrame;
+         pOutBufCfg->pntr.pLgInt   = pAsotCfg->pIoOut[zO].buff2;
+         // Execute encode
+         errno = asopDecOutProcEncode(pP, pQ, pAsotCfg, frame);
+         if (errno < 0)
+         {
+             status = errno;
+         }
+         // Restore sample count and audio frame buffer addresses
+         pAf->sampleCount = sampleCountSave;
+         for(i=0; i<pOutBufCfg->stride; i++)
+         {
+             ch = pAstCfg->xEnc[zO].encodeStatus.channelMap.from[i];
+             afDataAddr[ch] = afDataAddrSave[i];
+         }
+         pAsotCfg->pIoOut[zO].ioBuffBuf2AllocCnt++; // debug
+     }
+     return status;
+ }
  // ASOT SM function
  //   Purpose:   Init-Sync Re-Sync state function.
 -//              Performs Init-Sync using stored Dec Reset/Info1 AFs.
 +//              Performs Init-Sync using stored Init-Sync AFs.
  static Int PAF_ASOT_initSyncResync(
      const PAF_ASOT_Params *pP, 
      const PAF_ASOT_Patchs *pQ,