diff --git a/pasdk/test_arm/framework/audioStreamDecodeProc.c b/pasdk/test_arm/framework/audioStreamDecodeProc.c
index 54ef3c31e390896c51a4ea26ad8c897aa5b62199..a3b16baa15f02a209ed4c9525b26a79cebb8fee3 100644 (file)
#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];
int tempCap_decSampleOut[CAP_FRAME_MAX] = {0};
#endif
+
/*
* ======== taskAsdpFxn ========
* Audio Stream Decode Processing task function
PAF_AudioFrame *pAfWrt; // pointer to audio frame written to CB
Int cbErrno; // CB error number
// Output Init-Sync
+ PAF_AudioFrame *pDecCtrlAf; // pointer to Dec Control audio frame
PAF_AST_OutInitSyncCtl *pOutIsCtl; // OutIS control
Int8 outIsDecInfo1Flag; // indicates whether Dec Info Init-Sync has executed
- PAF_AudioFrame *pOutIsAfWrt; // pointer to audio frame written to OutIS Info
+ Int8 outIsDecDecode1Flag; // indicates whether Dec Decode1 Init-Sync has executed
Int outIsErrno; // OutIS error number
// Messaging
PAF_InpBufConfig *pIpBufConfig; // IB buffer configuration
// Reset audio frame
resetAf(pP, z, sourceSelect);
- // Initialize OutIS Dec Info1 flag -- OutIS Dec Info hasn't executed
- outIsDecInfo1Flag = 0;
+ // Initialize OutIS Dec flags
+ outIsDecInfo1Flag = 0; // OutIS Dec Info1 hasn't executed
+ outIsDecDecode1Flag = 0; // OutIS Dec Decode1 hasn't executed
// send dec activate complete message to master
queId = MessageQ_getReplyQueue(pAspMsg);
errno = 0;
if (dec->fxns->reset)
{
+ //
+ // Execute decode reset
+ //
errno = dec->fxns->reset(dec, NULL, &pAstCfg->xDec[z].decodeControl, &pAstCfg->xDec[z].decodeStatus);
+ // Get pointer to Dec Reset output audio frame
+ pDecCtrlAf = pAstCfg->xDec[z].decodeControl.pAudioFrame;
+
// Perform Dec Reset Init-Sync
// - Write Dec Reset output audio frame
// - Set Dec Reset decoder stage flag
- pOutIsAfWrt = pAstCfg->xDec[z].decodeControl.pAudioFrame; // get pointer to audio frame to write
outIsErrno = outIsWriteDecStageFlagAndAf(pOutIsCtl, z,
- ASP_OUTIS_DEC_STAGE_RESET_IDX, 1, pOutIsAfWrt);
+ ASP_OUTIS_DEC_STAGE_RESET_IDX, 1, pDecCtrlAf);
if (outIsErrno < 0)
{
SW_BREAKPOINT; // debug
errno = 0;
if (dec->fxns->info)
{
+ //
+ // Execute decode info
+ //
pfpBegin(PFP_ID_ASDT_1, pAsdtCfg->taskHandle);
- errno = dec->fxns->info(dec, NULL, &pAstCfg->xDec[z].decodeControl, &pAstCfg->xDec[z].decodeStatus);
+ errno = dec->fxns->info(dec, NULL,
+ &pAstCfg->xDec[z].decodeControl,
+ &pAstCfg->xDec[z].decodeStatus);
pfpEnd(PFP_ID_ASDT_1, PFP_FINISH_MEAS);
+ //
+ // Execute Dec Info1 Init-Sync if required
+ //
if (outIsDecInfo1Flag == 0)
{
- // Perform Dec Info Init-Sync
- // - Write Dec Info1 output audio frame
- // - Set Dec Info1 decoder stage flag
- pOutIsAfWrt = pAstCfg->xDec[z].decodeControl.pAudioFrame; // get pointer to audio frame to write
- outIsErrno = outIsWriteDecStageFlagAndAf(pOutIsCtl, z,
- ASP_OUTIS_DEC_STAGE_INFO1_IDX, 1, pOutIsAfWrt);
- if (outIsErrno < 0)
+ // Get pointer to Dec Info1 output audio frame
+ pDecCtrlAf = pAstCfg->xDec[z].decodeControl.pAudioFrame;
+
+ if (checkDecSync(pDecCtrlAf) == 1)
{
- SW_BREAKPOINT; // debug
+ // Perform Dec Info1 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
+ }
+
+ outIsDecInfo1Flag = 1; // OutIS Dec Info1 has executed
}
- outIsDecInfo1Flag = 1; // set flag to indicate OutIS Dec Info has executed
}
}
// Reset AF samsiz
resetAfSamsiz(z);
- // invalidate Dec configuration
+ // Invalidate Dec configuration
Cache_inv(&pAstCfg->xDec[z], sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
Cache_wait();
//TRACE_TERSE0("Dec:cache wb done");
{
// Capture input buffer (debug)
//capIb(pAstCfg->xInp[z].pInpBuf);
-
+
+ //
+ // Execute decode
+ //
pfpBegin(PFP_ID_ASDT_2, pAsdtCfg->taskHandle);
errno = dec->fxns->decode(dec, NULL, &pAstCfg->xDec[z].decodeInStruct, &pAstCfg->xDec[z].decodeOutStruct);
pfpEnd(PFP_ID_ASDT_2, PFP_FINISH_MEAS);
//SW_BREAKPOINT;
}
TRACE_TERSE0("Dec:decode done");
-
- // copy decoder output to decoder output circular buffers
- //pCb = &pAstCfg->xDecOpCb[z];
- //TRACE_TERSE1("Dec:pCb=0x%04x", (IArg)pCb);
-
- pAfWrt = pAstCfg->xDec[z].decodeOutStruct.pAudioFrame;
- TRACE_TERSE1("Dec:pAfWrt=0x%04x", (IArg)pAfWrt);
- //TRACE_TERSE1("nSamples=%d",pAfWrt->data.nSamples);
+
+ // Get pointer to Dec Decode output audio frame
+ pAfWrt = pAstCfg->xDec[z].decodeOutStruct.pAudioFrame;
+ TRACE_TERSE2("Dec:pAfWrt=0x%04x, nSamples=%d", (IArg)pAfWrt, pAfWrt->data.nSamples);
// Capture audio frame (debug)
- //if (capAfWrite(pAfWrt, PAF_CNTR) != CAP_AF_SOK)
+ //if (capAfWrite(pAfWrt, PAF_LEFT) != CAP_AF_SOK)
//{
// Log_info0("capAfWrite() error");
- //}
+ //}
#ifdef CAPTURE_DECODER_OUTSAMPLES_PP
if (tempCap_frameCnt < CAP_FRAME_MAX)
}
#endif
- //GPIOSetOutput(GPIO_PORT_0, GPIO_PIN_107);
+ //
+ // Execute Dec Decode1 Init-Sync if required
+ //
+ if (outIsDecDecode1Flag == 0)
+ {
+ //
+ // FL: cbInitSourceSel() moved from DSP:ASIT:INIT:decodeInit()
+ // frameLength: changed to decodeControl.frameLength.
+ // Written by ASIT:decodeInit:getFrameLengthSourceSel().
+
+ // Initialize decoder output circular buffer
+ errno = cbInitDecWrite(pCbCtl, z, sourceSelect,
+ pAstCfg->xDec[z].decodeControl.frameLength,
+ 0, pAfWrt);
+ if (errno)
+ {
+ SW_BREAKPOINT; // debug
+ }
+ // debug
+ cbLog(pCbCtl, z, 1, "cbInitSourceSel");
+
+ // Perform Dec Decode1 Init-Sync
+ // - Set Dec Decode1 decoder stage flag
+ outIsErrno = outIsWriteDecStageFlag(pOutIsCtl, z,
+ ASP_OUTIS_DEC_STAGE_DECODE1_IDX, 1);
+ if (outIsErrno < 0)
+ {
+ SW_BREAKPOINT; // debug
+ }
+
+ outIsDecDecode1Flag = 1; // OutIS Dec Decode1 has executed
+ }
+
+ //
+ // Write decoder output audio frame to circular buffer
+ //
+
+ // debug
+ //pCb = &pAstCfg->xDecOpCb[z];
+ //TRACE_TERSE1("Dec:pCb=0x%04x", (IArg)pCb);
+
+ GPIOSetOutput(GPIO_PORT_0, GPIO_PIN_99); // debug
cbErrno = cbWriteAf(pCbCtl, z, pAfWrt);
- if ((cbErrno < 0) && (cbErrno != ASP_DECOP_CB_WRITE_OVERFLOW))
+ GPIOClearOutput(GPIO_PORT_0, GPIO_PIN_99);
+ if ((cbErrno < 0) &&
+ (cbErrno != ASP_DECOP_CB_AF_WRITE_OVERFLOW) &&
+ (cbErrno != ASP_DECOP_CB_PCM_WRITE_OVERFLOW))
{
gCbWrtAfErrCnt++;
//SW_BREAKPOINT; // debug
}
- // Handle overflows
- if (cbErrno == ASP_DECOP_CB_WRITE_OVERFLOW)
+ // Handle circular buffer overflows
+ if ((cbErrno == ASP_DECOP_CB_AF_WRITE_OVERFLOW) ||
+ (cbErrno == ASP_DECOP_CB_PCM_WRITE_OVERFLOW))
{
gDecOpCbWrtAfOvr++; // increment circular buffer overflow count
if (gDecOpCbWrtAfOvr >= DEC_OP_CB_WRTAF_OVR_THR)
}
// Reinitialize audio frame elements
- pAudioFrame->channelConfigurationRequest.legacy = PAF_CC_NONE;
- pAudioFrame->channelConfigurationStream.legacy = PAF_CC_NONE;
+ pAudioFrame->sampleDecode = PAF_SOURCE_UNKNOWN;
pAudioFrame->sampleRate = PAF_SAMPLERATE_UNKNOWN;
pAudioFrame->sampleCount = 0;
- pAudioFrame->data.nChannels = PAF_MAXNUMCHAN;
+ pAudioFrame->channelConfigurationRequest.full = PAF_CC_UNKNOWN;
+ pAudioFrame->channelConfigurationStream.full = PAF_CC_UNKNOWN;
+ pAudioFrame->data.nChannels = PAF_MAXNUMCHAN;
switch (sourceSelect)
{
case PAF_SOURCE_PCM:
pAudioFrame->pafBsMetadataUpdate = XDAS_FALSE;
pAudioFrame->numPrivateMetadata = 0;
pAudioFrame->bsMetadata_offset = 0;
- pAudioFrame->bsMetadata_type = PAF_bsMetadata_channelData;
+ pAudioFrame->bsMetadata_type = PAF_bsMetadata_none;
for (i=0; i<pP->pMetadataBufStatus->NumBuf; i++)
{
pAudioFrame->pafPrivateMetadata[i].offset = 0;
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;
+ }
+}