[processor-sdk/performance-audio-sr.git] / processor_audio_sdk_1_00_00_00 / pasdk / test_dsp / framework / audioStreamOutProc.c
diff --git a/processor_audio_sdk_1_00_00_00/pasdk/test_dsp/framework/audioStreamOutProc.c b/processor_audio_sdk_1_00_00_00/pasdk/test_dsp/framework/audioStreamOutProc.c
index 84dcacfdc0e3741346ef8d9bacc5c935e16de183..c9194211868041352ead8ca1ae21aaac51f88da0 100644 (file)
#include "common.h"
#include "aspMsg_common.h"
#include "aspMsg_master.h"
-#include "paf_decOpCircBuf.h"
+#include "aspDecOpCircBuf_master.h"
#include "audioStreamProc_common.h"
#include "audioStreamOutProc.h"
// ASOT configuration
#pragma DATA_SECTION(gPAF_ASOT_config, ".globalSectionPafAsotConfig")
PAF_ASOT_Config gPAF_ASOT_config = {
- NULL,
- &gPAF_AST_config
+ NULL, // acp
+ &gPAF_ASPM_config, // pAspmCfg
+ &gPAF_AST_config // pAstCfg
};
+// Underflow threshold before returning error to Top-Level FSM
+#define DEC_OP_CB_RDAF_UND_THR ( 20 ) // FL: arbitrary setting
+UInt32 gDecOpCbRdAfUnd =0; // decoder output circular buffer underflow count
+
// Global debug counters */
UInt32 gTaskAsopCnt=0; // debug
UInt32 gAsopInitCnt =0;
HEAP_ID_INTERNAL1, HEAP_INTERNAL1,
HEAP_ID_EXTERNAL, HEAP_EXTERNAL,
HEAP_ID_INTERNAL1_SHM, HEAP_INTERNAL1_SHM,
+ HEAP_ID_EXTERNAL_SHM, HEAP_EXTERNAL_SHM,
HEAP_CLEAR);
if (pP->fxns->headerPrint)
HEAP_ID_INTERNAL1, HEAP_INTERNAL1,
HEAP_ID_EXTERNAL, HEAP_EXTERNAL,
HEAP_ID_INTERNAL1_SHM, HEAP_INTERNAL1_SHM,
+ HEAP_ID_EXTERNAL_SHM, HEAP_EXTERNAL_SHM,
HEAP_CLEAR);
TRACE_TERSE2("PAF_ASOT_initPhaseDevice: AS%d: calling PAF_ALG_setup with clear at %d.", as, HEAP_CLEAR);
}
TRACE_TERSE3(" maxFrameLength: %d. aLen_ext*aSize: %d. aBuf_ext: 0x%x", maxFrameLength, aLen_ext*aSize, (IArg)aBuf_ext);
TRACE_TERSE1("PAF_ASOT_initFrame0: AS%d: Memory_calloc for metadata buffers", as+z);
- //if (! (metadataBuf = (XDAS_UInt8 *)MEM_calloc (*(pP->pMetadataBufStatus->pSpace), pP->pMetadataBufStatus->bufSize*pP->pMetadataBufStatus->NumBuf, pP->pMetadataBufStatus->alignment))) {
if (!(metadataBuf = (XDAS_UInt8 *)Memory_calloc((IHeap_Handle)HEAP_MDBUF, pP->pMetadataBufStatus->bufSize*pP->pMetadataBufStatus->NumBuf, pP->pMetadataBufStatus->alignment, &eb)))
{
TRACE_TERSE1("PAF_ASOT_initFrame0: AS%d: Memory_calloc failed", as+z);
)
{
PAF_AST_Config *pAstCfg;
- Int as; /* Audio Stream Number (1, 2, etc.) */
- Int z; /* decode/encode counter */
- Int errno; /* error number */
+ PAF_AST_DecOpCircBufCtl *pCbCtl; /* Decoder output circular buffer control */
+ Int as; /* Audio Stream Number (1, 2, etc.) */
+ Int z; /* decode/encode counter */
+ Int errno; /* error number */
Int zO, zS;
- PAF_AST_DecOpCircBuf *pCb; /* decoder output circular buffer */
pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
as = pAstCfg->as;
+ pCbCtl = &pC->pAspmCfg->decOpCircBufCtl; // get pointer to circular buffer control
+
for (z=DECODE1; z < DECODEN; z++)
{
// Start decoder output circular buffer reads
- pCb = &pAstCfg->xDecOpCb[z];
- errno = cbReadStart(pCb);
+ errno = cbReadStart(pCbCtl, z);
if (errno)
{
TRACE_TERSE1("PAF_ASOT_decodeInit:cbReadStart() error=%d", errno);
return errno;
}
// FL: debug
- cbLog(pCb, 1, "PAF_ASOT_decodeInit:cbReadStart");
+ cbLog(pCbCtl, z, 1, "PAF_ASOT_decodeInit:cbReadStart");
}
// TODO: move this to start of this function so that it doesn't affect IO timing
Int block
)
{
- PAF_AST_Config *pAstCfg;
+ //PAF_AST_Config *pAstCfg;
Int errno;
- pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
+ //pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
errno = pP->fxns->setCheckRateX (pP, pQ, pC, 1);
TRACE_VERBOSE1("PAF_ASOT_decodeInfo2: return 0x%x", errno);
)
{
PAF_AST_Config *pAstCfg;
+ PAF_AST_DecOpCircBufCtl *pCbCtl; /* Decoder output circular buffer control */
Int z; /* decode/stream counter */
- PAF_AST_DecOpCircBuf *pCb; /* decoder output circular buffer */
PAF_AudioFrame *pAfRd;
Int cbErrno;
Int errno;
pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
+
+ pCbCtl = &pC->pAspmCfg->decOpCircBufCtl; // get pointer to circular buffer control
for (z=DECODE1; z < DECODEN; z++)
{
Int zS = pP->streamsFromDecodes[z];
//
- // (***) FL: read circular buffer
+ // Read decoder output circular buffer
//
- pCb = &pAstCfg->xDecOpCb[z];
pAfRd = pAstCfg->xStr[zS].pAudioFrame;
- cbErrno = cbReadAf(pCb, pAfRd);
+ cbErrno = cbReadAf(pCbCtl, z, pAfRd);
if (cbErrno != 0)
{
TRACE_TERSE1("PAF_ASOT_decodeStream:cbReadAf() error=%d", cbErrno);
//SW_BREAKPOINT; // FL: debug
- //return cbErrno; // (***) FL: ignoring read failures??
+
+ if (cbErrno == ASP_DECOP_CB_READ_UNDERFLOW)
+ {
+ // Reset circular buffer
+ cbReset(pCbCtl, z);
+ Log_info0("PAF_ASOT_decodeStream:cbReset");
+
+ // Update underflow count, return if above threshold
+ gDecOpCbRdAfUnd++;
+ if (gDecOpCbRdAfUnd == DEC_OP_CB_RDAF_UND_THR)
+ {
+ gDecOpCbRdAfUnd = 0;
+ return cbErrno;
+ }
+ }
}
//Log_info0("PAF_ASOT_decodeStream:cbReadAf() complete.");
// FL: debug
- cbLog(pCb, 1, "PAF_ASOT_decodeStream:cbReadAf");
+ cbLog(pCbCtl, z, 1, "PAF_ASOT_decodeStream:cbReadAf");
//if (capAfWrite(pAfRd, 0) != CAP_AF_SOK)
//{
// Log_info0("capAfWrite() error");
)
{
PAF_AST_Config *pAstCfg;
- Int as; /* Audio Stream Number (1, 2, etc.) */
- Int z; /* decode/encode counter */
- Int errno; /* error number */
- PAF_AST_DecOpCircBuf *pCb; /* decoder output circular buffer */
+ PAF_AST_DecOpCircBufCtl *pCbCtl; /* Decoder output circular buffer control */
+ Int as; /* Audio Stream Number (1, 2, etc.) */
+ Int z; /* decode/encode counter */
+ Int errno; /* error number */
pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
as = pAstCfg->as;
(void)as; // clear compiler warning in case not used with tracing disabled
+ pCbCtl = &pC->pAspmCfg->decOpCircBufCtl; // get pointer to circular buffer control
+
for (z=DECODE1; z < DECODEN; z++)
{
// Stop decoder output circular buffer reads
- pCb = &pAstCfg->xDecOpCb[z];
- errno = cbReadStop(pCb);
+ errno = cbReadStop(pCbCtl, z);
if (errno)
{
TRACE_TERSE1("PAF_ASOT_decodeComplete:cbReadStop() error=%d", errno);
return errno;
}
// FL: debug
- cbLog(pCb, 1, "PAF_ASOT_decodeComplete:cbReadStop");
+ cbLog(pCbCtl, z, 1, "PAF_ASOT_decodeComplete:cbReadStop");
}
pP->fxns->streamChainFunction(pP, pQ, pC, PAF_ASP_CHAINFRAMEFXNS_FINAL, 0, frame);