From aa43fe6ba41c3c0bd1cacde47f44e6271b6bf3c1 Mon Sep 17 00:00:00 2001 From: Jianzhong Xu Date: Thu, 14 Dec 2017 08:57:04 -0500 Subject: [PATCH 1/1] Split ASIP and ASOP initialization into separate routines. --- pasdk/test_dsp/framework/audioStreamInpProc.c | 87 +++++++++++++------ pasdk/test_dsp/framework/audioStreamOutProc.c | 81 +++++++++++------ 2 files changed, 118 insertions(+), 50 deletions(-) diff --git a/pasdk/test_dsp/framework/audioStreamInpProc.c b/pasdk/test_dsp/framework/audioStreamInpProc.c index e39d3b90..fb7b6ec4 100644 --- a/pasdk/test_dsp/framework/audioStreamInpProc.c +++ b/pasdk/test_dsp/framework/audioStreamInpProc.c @@ -372,11 +372,10 @@ extern struct { #include "evmc66x_gpio_dbg.h" /* - * ======== taskAsipFxn ======== - * Audio Stream Input Processing task function + * ======== taskAsipFxnInit ======== + * Audio Stream Input Processing initialization function */ -Void taskAsipFxn( -// Int betaPrimeValue, // FL: revisit +Void taskAsipFxnInit( const PAF_ASIT_Params *pP, const PAF_ASIT_Patchs *pQ ) @@ -386,22 +385,18 @@ Void taskAsipFxn( Int as; /* Audio Stream Number (1, 2, etc.) */ Int z; /* input/encode/stream/decode/output counter */ Int i; /* phase */ - Int errno; /* error number */ - Int zMD, zMI, zMS, zX; - Int loopCount = 0; // used to stop trace to see startup behavior. + Int zMI, zMS, zX; Int size; // Messaging - ASP_Msg *pAspMsg; + ASP_Msg *pAspMsg; Int status; - Int8 tempVar8; - char asipMsgBuf[ASP_MSG_BUF_LEN]; - Log_info0("Enter taskAsipFxn()"); + Log_info0("Enter taskAsipFxnInit()"); // // Audio Stream Input Task Parameters & Patch (*pP, *pQ) // - if (!pP) + if (!pP) { TRACE_TERSE0("TaskAsip: No Parameters defined. Exiting."); LINNO_RPRT(TaskAsip, -1); @@ -413,8 +408,8 @@ Void taskAsipFxn( TRACE_TERSE0("TaskAsip: No Patchs defined. Exiting."); LINNO_RPRT(TaskAsip, -1); return; - } - + } + // // Audio Stream Input Task Configuration (*pAsitCfg): // @@ -424,7 +419,7 @@ Void taskAsipFxn( /* Set Audio Stream Number (1, 2, etc.) */ as = gBetaPrimeValue + 1; - pAstCfg->as = as; + pAstCfg->as = as; TRACE_TERSE1("TaskAsip: Started with AS%d.", as); // @@ -435,7 +430,7 @@ Void taskAsipFxn( TRACE_TERSE1("TaskAsip: AS%d: initiated", as+z); } LINNO_RPRT(TaskAsip, -1); - + // // Determine decoder and stream indices associated with the master input // @@ -451,7 +446,6 @@ Void taskAsipFxn( break; } } - zMD = pAstCfg->masterDec; zMS = pAstCfg->masterStr; // Initialize as per parametrized phases: @@ -473,13 +467,13 @@ Void taskAsipFxn( if (pP->fxns->initPhase[i]) { linno = pP->fxns->initPhase[i](pP, pQ, pAsitCfg); - if (linno) + if (linno) { LINNO_RPRT(TaskAsip, linno); return; } } - else + else { TRACE_TERSE1("TaskAsip: AS%d: initialization phase - null", as+zMS); } @@ -493,10 +487,10 @@ Void taskAsipFxn( if (pP->fxns->memStatusPrint) { pP->fxns->memStatusPrint("ASIT MEMSTAT REPORT", - HEAP_INTERNAL, HEAP_INTERNAL1, HEAP_EXTERNAL, + HEAP_INTERNAL, HEAP_INTERNAL1, HEAP_EXTERNAL, HEAP_INTERNAL1_SHM, HEAP_EXTERNAL_SHM, HEAP_EXTERNAL_NONCACHED_SHM); } - + // (***) FL: revisit // write back AST shared configuration Cache_wb(pAstCfg, sizeof(PAF_AST_Config), Cache_Type_ALLD, 0); @@ -511,7 +505,7 @@ Void taskAsipFxn( // write back entire beta table Cache_wb((Ptr)(&IACP_STD_BETA_TABLE.pStatus[0]), 512*sizeof(IALG_Status *), Cache_Type_ALLD, 0); Cache_wait(); - + // FL: send start initialization message to slave pAspMsg = (ASP_Msg *)MessageQ_alloc(hAspMsgMaster->heapId, hAspMsgMaster->msgSize); /* allocate message */ MessageQ_setReplyQueue(hAspMsgMaster->masterQue, (MessageQ_Msg)pAspMsg); /* set the return address in the message header */ @@ -531,7 +525,7 @@ Void taskAsipFxn( status = MessageQ_get(hAspMsgMaster->masterQue, (MessageQ_Msg *)&pAspMsg, 0); // FL: no other thread is allowed to run until Slave finished startup } while ((status != MessageQ_S_SUCCESS) || (pAspMsg->cmd != ASP_MASTER_START_DONE)); if ((pAspMsg->procId != hAspMsgMaster->slaveProcId) || - (pAspMsg->cmd != ASP_MASTER_START_DONE) || + (pAspMsg->cmd != ASP_MASTER_START_DONE) || (pAspMsg->messageId != (hAspMsgMaster->messageId | ((UInt32)1<<31)))) { TRACE_TERSE3("ERROR: Rx ASP message: procId=%d, cmd=%d, messageId=0x%04x", pAspMsg->procId, pAspMsg->cmd, pAspMsg->messageId); @@ -568,7 +562,7 @@ Void taskAsipFxn( if (!IACP_STD_BETA_TABLE.pStatus[STD_BETA_DTSUHDA]) Log_info0("WARNING: beta unit for Dec==NULL"); if (!IACP_STD_BETA_TABLE.pStatus[STD_BETA_AAC]) Log_info0("WARNING: beta unit for Dec==NULL"); if (!IACP_STD_BETA_TABLE.pStatus[STD_BETA_AAC2]) Log_info0("WARNING: beta unit for Dec==NULL"); - + // (***) FL: revisit // invalidate Status structures for Beta Units initialized on Slave // @@ -642,7 +636,7 @@ Void taskAsipFxn( Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_AAC2]), size, Cache_Type_ALLD, 0); Cache_wait(); } - + #ifdef NON_CACHE_STATUS // Get the shared status structure GateMP handles. Initialized at slave. if (statusOp_Init(GATEMP_INDEX_DEC) == STATUSOP_INIT_FAIL) @@ -670,6 +664,49 @@ Void taskAsipFxn( // invalidate Dec configuration Cache_inv(&gPAF_AST_config.xDec[0], DECODEN*sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0); Cache_wait(); + +} /* taskAsipFxnInit */ + +/* + * ======== taskAsipFxn ======== + * Audio Stream Input Processing task function + */ +Void taskAsipFxn( +// Int betaPrimeValue, // FL: revisit + const PAF_ASIT_Params *pP, + const PAF_ASIT_Patchs *pQ +) +{ + PAF_ASIT_Config *pAsitCfg; /* ASIT configuration pointer */ + PAF_AST_Config *pAstCfg; /* AST Common (shared) configuration pointer */ + Int as; /* Audio Stream Number (1, 2, etc.) */ + Int z; /* input/encode/stream/decode/output counter */ + Int errno; /* error number */ + Int zMD, zMI, zMS; + Int loopCount = 0; // used to stop trace to see startup behavior. + // Messaging + Int8 tempVar8; + char asipMsgBuf[ASP_MSG_BUF_LEN]; + + Log_info0("Enter taskAsipFxn()"); + + taskAsipFxnInit(pP, pQ); // initialization of input task + + // + // Audio Stream Input Task Configuration (*pAsitCfg): + // + pAsitCfg = &gPAF_ASIT_config; // initialize pointer to task configuration + pAstCfg = pAsitCfg->pAstCfg; // get pointer to AST common (shared) configuration + + /* Set Audio Stream Number (1, 2, etc.) */ + as = pAstCfg->as; + + // + // Determine decoder and stream indices associated with the master input + // + zMI = pP->zone.master; + zMD = pAstCfg->masterDec; + zMS = pAstCfg->masterStr; // // Main processing loop diff --git a/pasdk/test_dsp/framework/audioStreamOutProc.c b/pasdk/test_dsp/framework/audioStreamOutProc.c index daafbc01..e744cd2a 100644 --- a/pasdk/test_dsp/framework/audioStreamOutProc.c +++ b/pasdk/test_dsp/framework/audioStreamOutProc.c @@ -317,11 +317,10 @@ UInt32 gAsopOutSioUpdateCnt =0; 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 ) @@ -332,25 +331,13 @@ Void taskAsopFxn( 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. - - 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); @@ -362,7 +349,7 @@ Void taskAsopFxn( TRACE_TERSE0("TaskAsop: No Patchs defined. Exiting."); LINNO_RPRT(TaskAsop, -1); return; - } + } // // Audio Stream Output Task Configuration (*pAsotCfg): @@ -371,7 +358,7 @@ Void taskAsopFxn( pAsotCfg->taskHandle = Task_self(); // set task handle pAstCfg = pAsotCfg->pAstCfg; // get pointer to AST common (shared) configuration - /* Obtain Audio Stream Number (1, 2, etc.) */ + /* Obtain Audio Stream Number (1, 2, etc.) */ as = pAstCfg->as; TRACE_TERSE1("TaskAsop: Started with AS%d.", as); @@ -383,7 +370,7 @@ Void taskAsopFxn( TRACE_TERSE1("TaskAsop: AS%d: initiated", as+z); } LINNO_RPRT(TaskAsop, -1); - + // // Determine stream index // @@ -408,29 +395,73 @@ Void taskAsopFxn( 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 */ + + +/* + * ======== taskAsopFxn ======== + * Audio Stream Output Processing task function + */ +Void taskAsopFxn( +// Int betaPrimeValue, // FL: revisit + 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 -- 2.39.2