diff --git a/pasdk/test_dsp/framework/audioStreamOutProc.c b/pasdk/test_dsp/framework/audioStreamOutProc.c
index 4f42f8c0c638f5dd529459543f9dee53a510cc6d..dd2101706aa12f737ce1a21630fe410f2469a862 100644 (file)
#include "evmc66x_gpio_dbg.h"
#include "dbgCapAf.h"
+#include "ioConfig.h"
// -----------------------------------------------------------------------------
// Debugging Trace Control, local to this file.
#define ASOP_DP_DECFINALTEST_ERR ( -6 ) // decode final error
-
/* Check if at least one output selected */
static Int checkOutSel(
const PAF_ASOT_Params *pP,
);
// Initialize Output Processing state function
-static Int PAF_ASOT_initOutProc(
+//static Int PAF_ASOT_initOutProc(
+// used by new OutProc.c, will be changed back to static once refactoring is done
+Int PAF_ASOT_initOutProc(
const PAF_ASOT_Params *pP,
PAF_AST_Stream *xStr
);
// Initialize Output Processing state function
-static Int PAF_ASOT_initSyncDecReset(
+// used by new OutProc.c, will be changed back to static once refactoring is done
+Int PAF_ASOT_initSyncDecReset(
const PAF_ASOT_Params *pP,
const PAF_ASOT_Patchs *pQ,
PAF_ASOT_Config *pAsotCfg,
);
// Purpose: Init-Sync Dec Info1 state function.
-// Performes Dec Info1 Init-Sync.
-static Int PAF_ASOT_initSyncDecInfo1(
+// Performs Dec Info1 Init-Sync.
+Int PAF_ASOT_initSyncDecInfo1(
const PAF_ASOT_Params *pP,
const PAF_ASOT_Patchs *pQ,
PAF_ASOT_Config *pAsotCfg,
);
// Purpose: Init-Sync Dec Decode1 state function.
-// Performes Dec Decode1 Init-Sync.
-static Int PAF_ASOT_initSyncDecDecode1(
+// Performs Dec Decode1 Init-Sync.
+Int PAF_ASOT_initSyncDecDecode1(
const PAF_ASOT_Params *pP,
const PAF_ASOT_Patchs *pQ,
PAF_ASOT_Config *pAsotCfg
);
// Purpose: Init-Sync Re-Sync state function.
-// Peformed Init-Sync using stored Dec Reset/Info1 AFs.
-static Int PAF_ASOT_initSyncResync(
+// Performs Init-Sync using stored Dec Reset/Info1 AFs.
+Int PAF_ASOT_initSyncResync(
const PAF_ASOT_Params *pP,
const PAF_ASOT_Patchs *pQ,
PAF_ASOT_Config *pAsotCfg,
PAF_AudioFrame *pDecInfo1Af
);
-#if 0
-// Init-Sync update audio frame
-static Int initSyncUpdateAf(
- PAF_AudioFrame *dstAf,
- PAF_AudioFrame *srcAf
-);
-#endif
-
// Reset audio frames
static Void resetAfs(
const PAF_ASOT_Params *pP,
PAF_AST_Stream *xStr
);
+// Create ASOT event
+static Int asotCreateEvent(void);
+
LINNO_DEFN(TaskAsop); /* Line number macros */
ERRNO_DEFN(TaskAsop); /* Error number macros */
#pragma DATA_SECTION(gPAF_ASOT_config, ".globalSectionPafAsotConfig")
PAF_ASOT_Config gPAF_ASOT_config = {
NULL, // taskHandle
+ 0, // asotState
NULL, // acp
- 0,0,0, // CB drained flags (size DECODE_MAXN)
+ 0,0,0, // cbDrainedFlag (size DECODE_MAXN)
&gPAF_ASPM_config, // pAspmCfg
&gPAF_AST_config // pAstCfg
};
+/* ASOT event handle - to put in structure */
+Event_Handle asotEvt;
+
// Underflow threshold before circular buffer reset and return error to Top-Level FSM
#define DEC_OP_CB_RDAF_UND_THR ( 80 ) // FL: arbitrary setting
UInt32 gCbReadAfErr =0; // read circular buffer error count, not including underflows
UInt32 gAsopQuitCnt =0;
/*
- * ======== taskAsopFxn ========
- * Audio Stream Output Processing task function
+ * ======== taskAsopFxnInit ========
+ * Audio Stream Output Processing initialization function
*/
-Void taskAsopFxn(
-// Int betaPrimeValue, // FL: revisit
+Void taskAsopFxnInit(
const PAF_ASOT_Params *pP,
const PAF_ASOT_Patchs *pQ
)
Int z; /* input/encode/stream/decode/output counter */
Int i; /* phase */
Int zMS;
- Int errno; // error number
- Int8 procSleep; // whether to sleep: 0: No, 1: Yes
- Int8 procOutDevSel; // whether to perform output device selection: 0: No, 1:Yes
- Int outSel; // whether output device selected
- enum { INIT_OUT_PROC_STATE,
- INITSYNC_DEC_RESET_STATE, INITSYNC_DEC_INFO1_STATE, INITSYNC_DEC_DECODE1_STATE,
- INITSYNC_RESYNC_STATE,
- OUT_PROC_STATE } state;
- PAF_AudioFrame decResetAf;
- PAF_AudioFrame decInfo1Af;
- Int loopCount = 0; // used to stop trace to see startup behavior.
-
+ Int status;
- Log_info0("Enter taskAsopFxn()");
+ Log_info0("Enter taskAsopFxnInit()");
//
// Audio Stream Output Task Parameters & Patch (*pP, *pQ)
//
- if (!pP)
+ if (!pP)
{
TRACE_TERSE0("TaskAsop: No Parameters defined. Exiting.");
LINNO_RPRT(TaskAsop, -1);
TRACE_TERSE0("TaskAsop: No Patchs defined. Exiting.");
LINNO_RPRT(TaskAsop, -1);
return;
- }
+ }
//
// Audio Stream Output Task Configuration (*pAsotCfg):
pAsotCfg->taskHandle = Task_self(); // set task handle
pAstCfg = pAsotCfg->pAstCfg; // get pointer to AST common (shared) configuration
- /* Obtain Audio Stream Number (1, 2, etc.) */
+ // Create ASIT event
+ status = asotCreateEvent();
+ if (status < 0)
+ {
+ TRACE_TERSE0("TaskAsop: unable to initialize event. Exiting.");
+ return;
+ }
+
+ /* Obtain Audio Stream Number (1, 2, etc.) */
as = pAstCfg->as;
TRACE_TERSE1("TaskAsop: Started with AS%d.", as);
TRACE_TERSE1("TaskAsop: AS%d: initiated", as+z);
}
LINNO_RPRT(TaskAsop, -1);
-
+
//
// Determine stream index
//
if (pP->fxns->initPhase[i])
{
linno = pP->fxns->initPhase[i](pP, pQ, pAsotCfg);
- if (linno)
+ if (linno)
{
LINNO_RPRT(TaskAsop, linno);
return;
}
}
- else
+ else
{
TRACE_TERSE1("TaskAsop: AS%d: initialization phase - null", as+zMS);
}
TRACE_TERSE2("TaskAsop: AS%d: initialization phase - %d completed", as+zMS, i);
LINNO_RPRT(TaskAsop, -i-3);
}
-
+
//
// End of Initialization -- display memory usage report.
//
if (pP->fxns->memStatusPrint)
{
pP->fxns->memStatusPrint("ASOT MEMSTAT REPORT",
- HEAP_INTERNAL, HEAP_INTERNAL1, HEAP_EXTERNAL,
+ HEAP_INTERNAL, HEAP_INTERNAL1, HEAP_EXTERNAL,
HEAP_INTERNAL1_SHM, HEAP_EXTERNAL_SHM, HEAP_EXTERNAL_NONCACHED_SHM);
}
+} /* taskAsopFxnInit */
+
+/*
+ * ========asotCreateEvent ========
+ * Create ASOT event
+ */
+static Int asotCreateEvent(void)
+{
+ Error_Block eb;
+
+ Error_init(&eb);
+
+ // Default instance configuration params
+ asotEvt = Event_create(NULL, &eb);
+ if (asotEvt == NULL)
+ {
+ return -1; // error code
+ }
+
+ return 0;
+} /* asotCreateEvent */
+
+/*
+ * ======== taskAsopFxn ========
+ * Audio Stream Output Processing task function
+ */
+#ifdef PASDK_SIO_DEV
+Void taskAsopFxn(
+#else
+#ifndef IO_LOOPBACK_TEST
+Void taskAsopFxn_NOt_Used(
+#else
+Void taskAsopFxn_Not_Used(
+#endif
+#endif
+ const PAF_ASOT_Params *pP,
+ const PAF_ASOT_Patchs *pQ
+)
+{
+ PAF_ASOT_Config *pAsotCfg; /* ASOT configuration pointer */
+ PAF_AST_Config *pAstCfg; /* Common (shared) configuration pointer */
+ Int as; /* Audio Stream Number (1, 2, etc.) */
+ Int z; /* input/encode/stream/decode/output counter */
+ Int zMS;
+ Int errno; // error number
+ Int8 procSleep; // whether to sleep: 0: No, 1: Yes
+ Int8 procOutDevSel; // whether to perform output device selection: 0: No, 1:Yes
+ Int outSel; // whether output device selected
+ enum { INIT_OUT_PROC_STATE,
+ INITSYNC_DEC_RESET_STATE, INITSYNC_DEC_INFO1_STATE, INITSYNC_DEC_DECODE1_STATE,
+ INITSYNC_RESYNC_STATE,
+ OUT_PROC_STATE } state;
+ PAF_AudioFrame decResetAf;
+ PAF_AudioFrame decInfo1Af;
+ Int loopCount = 0; // used to stop trace to see startup behavior.
+
+ Log_info0("Enter taskAsopFxn()");
+
+ taskAsopFxnInit(pP, pQ); // initialization of output task
+
+ //
+ // Audio Stream Output Task Configuration (*pAsotCfg):
+ //
+ pAsotCfg = &gPAF_ASOT_config; // initialize pointer to task configuration
+ pAstCfg = pAsotCfg->pAstCfg; // get pointer to AST common (shared) configuration
+
+ /* Obtain Audio Stream Number (1, 2, etc.) */
+ as = pAstCfg->as;
+
+ zMS = pAstCfg->masterStr;
//
// Main processing loop
//Log_info0("Exit taskAsopFxn()");
}
+Int PAF_ASOT_ioCompCreate(PAF_AST_IoOut *pIoOut, int numOut, IHeap_Handle iHeapHandle)
+{
+ int i, j, num_alloc;
+ lib_mem_rec_t *mem_rec;
+ ioBuffHandle_t ioBufHandle;
+ ioPhyHandle_t ioPhyHandle;
+ Error_Block eb;
+
+ for(i=0; i<numOut; i++)
+ {
+ // Create an I/O BUFF instance
+ // Obtain number of memory blocks required by I/O BUFF
+ num_alloc = ioBuffNumAlloc();
+
+ // Obtain requirements of each memory block
+ mem_rec = (lib_mem_rec_t *)malloc(sizeof(lib_mem_rec_t)*num_alloc);
+ if(ioBuffAlloc(mem_rec) != IOBUFF_NOERR) {
+ return __LINE__;
+ }
+
+ /* Allocate memory and create I/O BUFF instance */
+ for(j=0; j<num_alloc; j++) {
+ mem_rec[j].base = Memory_calloc(iHeapHandle, mem_rec[j].size,
+ (1<<mem_rec[j].alignment), &eb);
+ }
+
+ if(ioBuffCreate(&ioBufHandle, mem_rec) != IOBUFF_NOERR) {
+ return __LINE__;
+ }
+
+ pIoOut[i].hIoBuff = ioBufHandle;
+
+ free(mem_rec);
+
+ // Create an I/O PHY instance
+ // Obtain number of memory blocks required by I/O PHY
+ num_alloc = ioPhyNumAlloc();
+
+ // Obtain requirements of each memory block
+ mem_rec = (lib_mem_rec_t *)malloc(sizeof(lib_mem_rec_t)*num_alloc);
+ if(ioPhyAlloc(mem_rec) != IOBUFF_NOERR) {
+ return __LINE__;
+ }
+
+ /* Allocate memory and create I/O PHY instance */
+ for(j=0; j<num_alloc; j++) {
+ mem_rec[j].base = Memory_calloc(iHeapHandle, mem_rec[j].size,
+ (1<<mem_rec[j].alignment), &eb);
+ }
+
+ if(ioPhyCreate(&ioPhyHandle, mem_rec) != IOBUFF_NOERR) {
+ return __LINE__;
+ }
+
+ pIoOut[i].hIoPhy = ioPhyHandle;
+
+ free(mem_rec);
+
+ } // end of for loop
+
+ return 0;
+} // PAF_ASOT_ioCompCreate
+
// -----------------------------------------------------------------------------
// AST Initialization Function - Memory Allocation
//
{
PAF_AST_Config *pAstCfg;
Int as; /* Audio Stream Number (1, 2, etc.) */
- Int zMS;
+ Int zMS, errLineNum;
Error_Block eb;
//Int i;
OUTPUTN * sizeof (*pAstCfg->xOut),
HEAP_ID_INTERNAL, (IArg)pAstCfg->xOut);
+ /* Output I/O data structure memory */
+ if (!(pAsotCfg->pIoOut = Memory_calloc((IHeap_Handle)HEAP_INTERNAL, OUTPUTN * sizeof (*pAsotCfg->pIoOut), 4, &eb)))
+ {
+ TRACE_TERSE1("PAF_ASOT_initPhaseMalloc: AS%d: Memory_calloc failed", as+zMS);
+ SW_BREAKPOINT;
+ return __LINE__;
+ }
+ TRACE_TERSE3("PAF_ASOT_initPhaseMalloc. (pAsotCfg->pIoOut) %d bytes from space %d at 0x%x.",
+ OUTPUTN * sizeof (*pAsotCfg->pIoOut),
+ HEAP_ID_INTERNAL, (IArg)pAsotCfg->pIoOut);
+
+ /* I/O components memory for output */
+ errLineNum = PAF_ASOT_ioCompCreate(pAsotCfg->pIoOut, OUTPUTN, (IHeap_Handle)HEAP_INTERNAL);
+ if(errLineNum)
+ {
+ SW_BREAKPOINT;
+ return errLineNum;
+ }
TRACE_TERSE1("PAF_ASOT_initPhaseMalloc: AS%d: initialization phase - memory allocation complete.", as+zMS);
return 0;
} //PAF_ASOT_initPhaseMalloc
}
// TODO: use pC->xOut[z].pOutBuf in following ->encode call
-#if 1 // (***) FL: shows timing of Output Rx SIO reclaim
+#if 0 // (***) FL: shows timing of Output Tx SIO reclaim
// (***) debug // B8
{
static Uint8 toggleState = 0;
}
// Initialize Output Processing state function
-static Int PAF_ASOT_initOutProc(
+//static Int PAF_ASOT_initOutProc(
+Int PAF_ASOT_initOutProc(
const PAF_ASOT_Params *pP,
PAF_AST_Stream *xStr
)
return ASOP_SOK;
}
-#if 0
-// Init-Sync update audio frame
-static Int initSyncUpdateAf(
- PAF_AudioFrame *dstAf,
- PAF_AudioFrame *srcAf
-)
-{
- memcpy(dstAf, srcAf, sizeof(PAF_AudioFrame));
-
- return ASOP_SOK;
-}
-#endif
-
// Purpose: Init-Sync Dec Reset state function.
// Performes Dec Reset Init-Sync.
-static Int PAF_ASOT_initSyncDecReset(
+//static Int PAF_ASOT_initSyncDecReset(
+// used by new OutProc.c, will be changed back to static once refactoring is done
+Int PAF_ASOT_initSyncDecReset(
const PAF_ASOT_Params *pP,
const PAF_ASOT_Patchs *pQ,
PAF_ASOT_Config *pAsotCfg,
// Update Stream Audio Frame.
// Copy Dec Reset AF to Stream AF.
- //errno = initSyncUpdateAf(pStrAf, pDecResetAf);
- //if (errno < 0)
- //{
- // return errno;
- //}
outIsCpyAf(pDecResetAf, pStrAf);
// Enc activate
Int16 gOutFrameLen=PAF_ASOT_FRAMELENGTH; // output frame length (PCM samples)
// Purpose: Init-Sync Dec Info1 state function.
-// Performes Dec Info1 Init-Sync.
-static Int PAF_ASOT_initSyncDecInfo1(
+// Performs Dec Info1 Init-Sync.
+Int PAF_ASOT_initSyncDecInfo1(
const PAF_ASOT_Params *pP,
const PAF_ASOT_Patchs *pQ,
PAF_ASOT_Config *pAsotCfg,
zMS = pAstCfg->masterStr;
pStrAf = pAstCfg->xStr[zMS].pAudioFrame;
- // Update Stream Audio Frame.
- // Copy Dec Reset AF to Stream AF.
- //errno = initSyncUpdateAf(pStrAf, pDecInfo1Af);
- //if (errno < 0)
- //{
- // return errno;
- //}
-
- // Hack to set ASOT output frame length.
+ // Set ASOT output frame length.
// THD sets this to 256 (hard-coded in Dec Info)
- // DDP sets this to 0 (audio frame passthrough, 0 from ASDT AF frame length)
+ // DDP sets this to 0 (audio frame pass through, 0 from ASDT AF frame length)
// PCM sets this to 256 (decodeControl.frameLength)
- //pDecInfo1Af->sampleCount = 256; // !!!! GJ: Revisit !!!!
- pDecInfo1Af->sampleCount = gOutFrameLen;
+ pDecInfo1Af->sampleCount = gOutFrameLen; // !!!! GJ: Revisit !!!!
+ // Update Stream Audio Frame.
+ // Copy Dec Reset AF to Stream AF.
outIsCpyAf(pDecInfo1Af, pStrAf);
- // Hack to set ASOT output frame length
- // THD sets this to 256 (hard-coded in Dec Info)
- // DDP sets this to 0 (audio frame passthrough, 0 from ASDT AF frame length)
- // PCM sets this to 256 (decodeControl.frameLength)
- //pStrAf->sampleCount = 256; // !!!! GJ: Revisit !!!!
-
// outputInfo1():
// - ASP chain reset,
// - Enc Info
}
// Purpose: Init-Sync Dec Decode1 state function.
-// Performes Dec Decode1 Init-Sync.
-static Int PAF_ASOT_initSyncDecDecode1(
+// Performs Dec Decode1 Init-Sync.
+//static Int PAF_ASOT_initSyncDecDecode1(
+Int PAF_ASOT_initSyncDecDecode1(
const PAF_ASOT_Params *pP,
const PAF_ASOT_Patchs *pQ,
PAF_ASOT_Config *pAsotCfg
}
// Purpose: Init-Sync Re-Sync state function.
-// Peformed Init-Sync using stored Dec Reset/Info1 AFs.
-static Int PAF_ASOT_initSyncResync(
+// Peforms Init-Sync using stored Dec Reset/Info1 AFs.
+Int PAF_ASOT_initSyncResync(
const PAF_ASOT_Params *pP,
const PAF_ASOT_Patchs *pQ,
PAF_ASOT_Config *pAsotCfg,
// Update Stream Audio Frame.
// Copy Dec Reset AF to Stream AF.
- //errno = initSyncUpdateAf(pStrAf, pDecResetAf);
- //if (errno < 0)
- //{
- // return errno;
- //}
outIsCpyAf(pDecResetAf, pStrAf);
// Enc activate,
// Update Stream Audio Frame.
// Copy Dec Info1 AF to Stream AF.
- //errno = initSyncUpdateAf(pStrAf, pDecInfo1Af);
- //if (errno < 0)
- //{
- // return errno;
- //}
outIsCpyAf(pDecInfo1Af, pStrAf);
// decodeInfo1():