summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7e947e5)
raw | patch | inline | side by side (parent: 7e947e5)
author | Frank Livingston <frank-livingston@ti.com> | |
Thu, 1 Sep 2016 16:03:27 +0000 (11:03 -0500) | ||
committer | Frank Livingston <frank-livingston@ti.com> | |
Thu, 1 Sep 2016 16:03:27 +0000 (11:03 -0500) |
Add reset flags parameter to cbInit function
Change cb latency for DDP back to 512 samples
Add underflow/overflow error count stats
Add cache invalidate at beginning of read/write flag update functions
Add cache wait at end of read/write flag update functions
Change cb latency for DDP back to 512 samples
Add underflow/overflow error count stats
Add cache invalidate at beginning of read/write flag update functions
Add cache wait at end of read/write flag update functions
processor_audio_sdk_1_00_00_00/pasdk/common/paf_decOpCircBuf.c | patch | blob | history | |
processor_audio_sdk_1_00_00_00/pasdk/common/paf_decOpCircBuf.h | patch | blob | history |
diff --git a/processor_audio_sdk_1_00_00_00/pasdk/common/paf_decOpCircBuf.c b/processor_audio_sdk_1_00_00_00/pasdk/common/paf_decOpCircBuf.c
index 0b9dda9bcead6eaccd3233f334148f6cb8cc015a..12e80a665fb4990b78e60bd9dcde855e7c3d1197 100644 (file)
#include <ti/sysbios/hal/Cache.h>
#include <xdc/runtime/Log.h>
+#include "common.h"
#include "pafdec.h"
#include "pafsp.h"
#include "paf_decOpCircBuf.h"
Int8 sourceSelect, // source select (PCM, DDP, etc.)
Int16 decOpFrameLen, // decoder output frame length (PCM samples)
Int16 strFrameLen, // stream frame length (PCM samples)
- PAF_DecodeOpCircBuf *pCb // decoder output circular buffer
+ PAF_DecodeOpCircBuf *pCb, // decoder output circular buffer
+ Int8 resetRwFlags // whether to reset reader, writer, and empty flags
)
{
PAF_AudioFrame *pAfCb;
{
pCb->maxNumAfCb = MAX_NUM_AF_DDP;
pCb->afRdIdx = 0;
- pCb->afWrtIdx = 0;//1;//QIN - Reduce delay to prevent cb overflow. Need further investigation.
- pCb->pcmRdIdx = 0;//decOpFrameLen - CB_INIT_RD_LAG*strFrameLen; //QIN - Reduce delay to prevent cb overflow. Need further investigation.
+ pCb->pcmRdIdx = decOpFrameLen - CB_INIT_RD_LAG*strFrameLen;
+ pCb->afWrtIdx = 1;
// initialize audio frames
for (n=0; n<pCb->maxNumAfCb; n++)
pMetaBuf += PAF_MAX_PRIVATE_MD_SZ;
}
}
- // update flags
- pCb->writerActiveFlag = 0;
- pCb->readerActiveFlag = 0;
- pCb->emptyFlag = 0;
- //pCb->cbWriteAfInit = 0;
+
+ // reset read/write flags
+ if (resetRwFlags)
+ {
+ pCb->writerActiveFlag = 0;
+ pCb->readerActiveFlag = 0;
+ pCb->emptyFlag = 0;
+ }
+ // reset error counts
+ pCb->errUndCnt = 0;
+ pCb->errOvrCnt = 0;
// (***) FL: revisit
// Write back circular buffer configuration
// (***) FL: revisit
// Write back circular buffer configuration
Cache_wb(pCb, sizeof(PAF_DecodeOpCircBuf), Cache_Type_ALLD, 0);
+ Cache_wait();
return PAF_DECOP_CB_SOK;
};
PAF_DecodeOpCircBuf *pCb // decoder output circular buffer
)
{
+ // Invalidate circular buffer configuration
+ Cache_inv(pCb, sizeof(PAF_DecodeOpCircBuf), Cache_Type_ALLD, 0);
+ Cache_wait();
+
// update flags
pCb->writerActiveFlag = 0;
pCb->emptyFlag = 1;
// (***) FL: revisit
// Write back circular buffer configuration
Cache_wb(pCb, sizeof(PAF_DecodeOpCircBuf), Cache_Type_ALLD, 0);
+ Cache_wait();
return PAF_DECOP_CB_SOK;
}
PAF_DecodeOpCircBuf *pCb // decoder output circular buffer
)
{
+ // Invalidate circular buffer configuration
+ Cache_inv(pCb, sizeof(PAF_DecodeOpCircBuf), Cache_Type_ALLD, 0);
+ Cache_wait();
+
// update flags
pCb->readerActiveFlag = 1;
// (***) FL: revisit
// Write back circular buffer configuration
Cache_wb(pCb, sizeof(PAF_DecodeOpCircBuf), Cache_Type_ALLD, 0);
+ Cache_wait();
return PAF_DECOP_CB_SOK;
}
PAF_DecodeOpCircBuf *pCb // decoder output circular buffer
)
{
- // update flags
- pCb->readerActiveFlag = 0;
-
- // (***) FL: revisit
- // Write back circular buffer configuration
- Cache_wb(pCb, sizeof(PAF_DecodeOpCircBuf), Cache_Type_ALLD, 0);
-
- return PAF_DECOP_CB_SOK;
-}
-// restore read/write flags of the circular buffer. - QIN
-Int cbReadWriteRestore(
- PAF_DecodeOpCircBuf *pCb // decoder output circular buffer
-)
-{
- // Invalidate circular buffer configuration.
+ // Invalidate circular buffer configuration
Cache_inv(pCb, sizeof(PAF_DecodeOpCircBuf), Cache_Type_ALLD, 0);
Cache_wait();
-
+
// update flags
- pCb->readerActiveFlag = 1;
- pCb->writerActiveFlag = 1;
+ pCb->readerActiveFlag = 0;
// (***) FL: revisit
// Write back circular buffer configuration
Cache_wb(pCb, sizeof(PAF_DecodeOpCircBuf), Cache_Type_ALLD, 0);
+ Cache_wait();
return PAF_DECOP_CB_SOK;
}
// This shouldn't occur:
// writer is active AND draining circular buffer
Log_info2("cbReadAf: ERROR: writerActiveFlag=%d, emptyFlag=%d", pCb->writerActiveFlag, pCb->emptyFlag);
+ SW_BREAKPOINT; // FL: debug
return PAF_DECOP_CB_READ_INVSTATE;
}
// No active writer, not draining circular buffer.
// Skip UNDerflow check, mute output.
//
-
pAfRd->sampleDecode = PAF_SOURCE_PCM;
PAF_PROCESS_ZERO(pAfRd->sampleProcess);
pAfRd->sampleRate = PAF_SAMPLERATE_48000HZ;
// check underflow
if (pCb->numAfCb <= 0)
{
+ pCb->errUndCnt++;
+ //SW_BREAKPOINT; // FL: debug
+ Log_info1("cbReadAf: ERROR: underflow, numAfCb=%d", pCb->numAfCb);
return PAF_DECOP_CB_READ_UNDERFLOW;
}
}
for (i = 0; i < PAF_MAX_NUM_PRIVATE_MD; i++)
{
//Invalidate metadata data
- Cache_inv(&pAfCb->pafPrivateMetadata[i], sizeof(PAF_PrivateMetadata), Cache_Type_ALLD, 0);
+ Cache_inv(&pAfCb->pafPrivateMetadata[i], sizeof(PAF_PrivateMetadata), Cache_Type_ALLD, 0);
Cache_wait();
if ((pAfCb->pafPrivateMetadata[i].offset >= pCb->pcmRdIdx)
&&(pAfCb->pafPrivateMetadata[i].offset < (pCb->pcmRdIdx + pCb->strFrameLen))
}
#endif
-
// check overflow
- //if (pCb->numAfCb >= pCb->maxNumAfCb)
- //{
- // return PAF_DECOP_CB_WRITE_OVERFLOW;
- //}
- while (pCb->numAfCb >= pCb->maxNumAfCb); //Qin replace with while loop for debugging
+ if (pCb->numAfCb >= pCb->maxNumAfCb)
+ {
+ pCb->errOvrCnt++;
+ //SW_BREAKPOINT;
+ Log_info1("cbWriteAf: ERROR: overflow, numAfCb=%d", pCb->numAfCb);
+ return PAF_DECOP_CB_WRITE_OVERFLOW;
+ }
+ //while (pCb->numAfCb >= pCb->maxNumAfCb); //Qin replace with while loop for debugging
// get pointer to current audio frame in circular buffer
pAfCb = &pCb->afCb[pCb->afWrtIdx];
//Write metadata to circular buffer //QIN
for (i = 0; i < PAF_MAX_NUM_PRIVATE_MD; i++)
{
- if (pAfWrt->pafPrivateMetadata[i].size )
+ if (pAfWrt->pafPrivateMetadata[i].size)
{
pAfCb->pafPrivateMetadata[i].offset = pAfWrt->pafPrivateMetadata[i].offset;
pAfCb->pafPrivateMetadata[i].size = pAfWrt->pafPrivateMetadata[i].size;
Cache_wb(pAfCb->data.sample[i], pCb->decOpFrameLen*sizeof(PAF_AudioData), Cache_Type_ALLD, 0);
}
}
-
+ // write back private metadata
for (i=0; i<PAF_MAX_NUM_PRIVATE_MD; i++) //QIN
{
Cache_wb(&pAfCb->pafPrivateMetadata[i], sizeof(PAF_PrivateMetadata), Cache_Type_ALLD, 0);
// Output log of circular buffer control variables (debug)
Int cbLog(
PAF_DecodeOpCircBuf *pCb,
- Int8 fullLog
+ Int8 fullLog,
+ char *locInfo
)
{
- Log_info4("afRdIdx=%d, pcmRdIdx=%d, afWrtIdx=%d, numAfCb=%d", pCb->afRdIdx, pCb->pcmRdIdx,
+ Log_info1("CB: %s", (IArg)locInfo);
+ Log_info3("CB: readerActiveFlag=%d, writerActiveFlag=%d, emptyFlag=%d", pCb->readerActiveFlag, pCb->writerActiveFlag, pCb->emptyFlag);
+ Log_info4("CB: afRdIdx=%d, pcmRdIdx=%d, afWrtIdx=%d, numAfCb=%d", pCb->afRdIdx, pCb->pcmRdIdx,
pCb->afWrtIdx,
pCb->numAfCb);
if (fullLog)
{
- Log_info1("maxNumAfCb=%d", pCb->maxNumAfCb);
- Log_info2("decOpFrameLen=%d, strFrameLen=%d", pCb->decOpFrameLen, pCb->strFrameLen);
+ Log_info1("CB: maxNumAfCb=%d", pCb->maxNumAfCb);
+ Log_info2("CB: decOpFrameLen=%d, strFrameLen=%d", pCb->decOpFrameLen, pCb->strFrameLen);
//Log_info1("cbWriteInit=%d", pCb->cbWriteAfInit);
}
diff --git a/processor_audio_sdk_1_00_00_00/pasdk/common/paf_decOpCircBuf.h b/processor_audio_sdk_1_00_00_00/pasdk/common/paf_decOpCircBuf.h
index 2e6808d9eb014f5e4351e001a6b0027f215373da..b7bcf6c3e1cec9e80b83776fade6975337d804c5 100644 (file)
Int8 writerActiveFlag; // flag indicates whether CB writer is active
Int8 readerActiveFlag; // flag indicates whether CB reader is active
Int8 emptyFlag; // flag indicates whether reader should empty (drain) remaining frames in CB
- //Int cbWriteAfInit; // indicates whether CB has been initialized for AF writes
+ Int8 errUndCnt; // underflow count
+ Int8 errOvrCnt; // overflow count
} PAF_DecodeOpCircBuf;
+// Initialize circular buffer
+Int cbInit(
+ Int8 sourceSelect, // source select (PCM, DDP, etc.)
+ Int16 decOpFrameLen, // decoder output frame length (PCM samples)
+ Int16 strFrameLen, // stream frame length (PCM samples)
+ PAF_DecodeOpCircBuf *pCb, // decoder output circular buffer
+ Int8 resetRwFlags // whether to reset reader, writer, and empty flags
+);
+
// Start writes to circular buffer
Int cbWriteStart(
PAF_DecodeOpCircBuf *pCb // decoder output circular buffer
// Output log of circular buffer control variables (debug)
Int cbLog(
PAF_DecodeOpCircBuf *pCb,
- Int8 fullLog
-);
-// restore read/write flags of the circular buffer. - QIN
-Int cbReadWriteRestore(
- PAF_DecodeOpCircBuf *pCb // decoder output circular buffer
+ Int8 fullLog,
+ char *locInfo
);
#endif /* _DEC_OP_CIRC_BUF_H_ */