From baabb165232fa2f83d42c3ec75ef9bf41ec96d51 Mon Sep 17 00:00:00 2001 From: Frank Livingston Date: Tue, 6 Sep 2016 18:27:11 -0500 Subject: [PATCH] Add GateMP for Decoder Output Circular Buffer --- .../pasdk/common/aspDecOpCircBuf_common.c | 23 +++- .../pasdk/common/aspDecOpCircBuf_common.h | 22 ++- .../framework/aspDecOpCircBuf_slave.c | 100 +++++++++++++- .../framework/aspDecOpCircBuf_slave.h | 18 ++- .../framework/audioStreamDecodeProc.c | 25 ++-- .../framework/audioStreamDecodeProc.h | 3 + .../pasdk/test_arm/framework/systemInit.c | 11 ++ .../framework/aspDecOpCircBuf_master.c | 126 ++++++++++++++++-- .../framework/aspDecOpCircBuf_master.h | 33 +++-- .../test_dsp/framework/audioStreamInpProc.c | 33 ++--- .../test_dsp/framework/audioStreamOutProc.c | 39 +++--- .../framework/audioStreamProc_master.h | 2 +- .../pasdk/test_dsp/framework/systemInit.c | 11 ++ 13 files changed, 357 insertions(+), 89 deletions(-) diff --git a/processor_audio_sdk_1_00_00_00/pasdk/common/aspDecOpCircBuf_common.c b/processor_audio_sdk_1_00_00_00/pasdk/common/aspDecOpCircBuf_common.c index 41669a98..edf3b7c1 100644 --- a/processor_audio_sdk_1_00_00_00/pasdk/common/aspDecOpCircBuf_common.c +++ b/processor_audio_sdk_1_00_00_00/pasdk/common/aspDecOpCircBuf_common.c @@ -34,18 +34,32 @@ All rights reserved. */ #include -#include #include +#include +#include #include "aspDecOpCircBuf_common.h" // Output log of circular buffer control variables (debug) Int cbLog( - PAF_AST_DecOpCircBuf *pCb, + PAF_AST_DecOpCircBufCtl *pCbCtl, + Int8 cbIdx, Int8 fullLog, char *locInfo ) { + IArg key; + GateMP_Handle gateHandle; + PAF_AST_DecOpCircBuf *pCb; + + // Get gate handle + gateHandle = pCbCtl->gateHandle; + // Enter gate + key = GateMP_enter(gateHandle); + + // Get circular buffer base pointer + pCb = &pCbCtl->xDecOpCb[cbIdx]; + // Invalidate circular buffer configuration. Cache_inv(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0); Cache_wait(); @@ -61,6 +75,9 @@ Int cbLog( Log_info2("CB: decOpFrameLen=%d, strFrameLen=%d", pCb->decOpFrameLen, pCb->strFrameLen); //Log_info1("cbWriteInit=%d", pCb->cbWriteAfInit); } + + // Leave the gate + GateMP_leave(gateHandle, key); - return 0; + return ASP_DECOP_CB_SOK; } diff --git a/processor_audio_sdk_1_00_00_00/pasdk/common/aspDecOpCircBuf_common.h b/processor_audio_sdk_1_00_00_00/pasdk/common/aspDecOpCircBuf_common.h index 7b74a725..46d91f17 100644 --- a/processor_audio_sdk_1_00_00_00/pasdk/common/aspDecOpCircBuf_common.h +++ b/processor_audio_sdk_1_00_00_00/pasdk/common/aspDecOpCircBuf_common.h @@ -40,7 +40,9 @@ All rights reserved. #include #include "paftyp.h" -#define ASP_DECOP_CB_SOK ( 0 ) // ok +#define ASP_DECOP_CB_SOK ( 0 ) // ok +#define ASP_DECOP_CB_CTL_INIT_INV_GATE ( ASP_DECOP_CB_SOK-1 ) // error: invalid gate handle +#define ASP_DECOP_CB_ERR_START ( ASP_DECOP_CB_CTL_INIT_INV_GATE ) #define ASP_DECOP_CB_MAX_NUM_AF ( 4 ) // decoder output circular buffer maximum number audio frames #define ASP_DECOP_CB_MAX_NUM_PCM_CH ( 16 ) // decoder output circular buffer maximum number audio PCM channels @@ -48,6 +50,9 @@ All rights reserved. #define ASP_DECOP_CB_MAX_PCM_FRAME_LEN ( 6*256 ) // decoder output circular buffer maximum PCM frame length #define ASP_DECOP_CB_PCM_BUF_SZ ( ASP_DECOP_CB_MAX_NUM_PCM_CH * ASP_DECOP_CB_MAX_NUM_PCM_FRAMES * ASP_DECOP_CB_MAX_PCM_FRAME_LEN ) +#define ASP_DECODE_CB_GATE_NAME ( "AspDecOpCbGate" ) +#define ASP_DECODE_CB_GATE_REGION_ID ( 0 ) + // Decoder output circular buffer typedef struct PAF_AST_DecOpCircBuf @@ -70,15 +75,22 @@ typedef struct PAF_AST_DecOpCircBuf } PAF_AST_DecOpCircBuf; // Decoder output circular buffer control -typedef struct PAF_AST_DecOpCircBufCtrl +typedef struct PAF_AST_DecOpCircBufCtl { - GateMP_Handle *gateHandle; // circular buffer gate handle + GateMP_Handle gateHandle; // circular buffer gate handle PAF_AST_DecOpCircBuf *xDecOpCb; // circular buffer base pointer -} PAF_AST_DecOpCircBufCtrl; +} PAF_AST_DecOpCircBufCtl; + +// Initialize circular buffer control +Int cbCtlInit( + PAF_AST_DecOpCircBufCtl *pCbCtl, // decoder output circular buffer control + PAF_AST_DecOpCircBuf *xDecOpCb // decoder output circular buffer base pointer +); // Output log of circular buffer control variables (debug) Int cbLog( - PAF_AST_DecOpCircBuf *pCb, + PAF_AST_DecOpCircBufCtl *pCbCtl, + Int8 cbIdx, Int8 fullLog, char *locInfo ); diff --git a/processor_audio_sdk_1_00_00_00/pasdk/test_arm/framework/aspDecOpCircBuf_slave.c b/processor_audio_sdk_1_00_00_00/pasdk/test_arm/framework/aspDecOpCircBuf_slave.c index 6fb390de..16010b8e 100644 --- a/processor_audio_sdk_1_00_00_00/pasdk/test_arm/framework/aspDecOpCircBuf_slave.c +++ b/processor_audio_sdk_1_00_00_00/pasdk/test_arm/framework/aspDecOpCircBuf_slave.c @@ -44,15 +44,48 @@ All rights reserved. //#include "pafsp.h" #include "aspDecOpCircBuf_slave.h" +// Initialize circular buffer control +Int cbCtlInit( + PAF_AST_DecOpCircBufCtl *pCbCtl, // decoder output circular buffer control + PAF_AST_DecOpCircBuf *xDecOpCb // decoder output circular buffer base pointer +) +{ + GateMP_Handle gateHandle; + Int status; + + status = GateMP_open(ASP_DECODE_CB_GATE_NAME, &gateHandle); + if (status < 0) + { + return ASP_DECOP_CB_CTL_INIT_INV_GATE; + } + + pCbCtl->xDecOpCb = xDecOpCb; + + return ASP_DECOP_CB_SOK; + +} + // Start writes to circular buffer Int cbWriteStart( - PAF_AST_DecOpCircBuf *pCb // decoder output circular buffer + PAF_AST_DecOpCircBufCtl *pCbCtl, // decoder output circular buffer control + Int8 cbIdx // decoder output circular buffer index ) { + IArg key; + GateMP_Handle gateHandle; + PAF_AST_DecOpCircBuf *pCb; PAF_AudioFrame *pAfCb; Int8 n; //Int8 i; + // Get gate handle + gateHandle = pCbCtl->gateHandle; + // Enter gate + key = GateMP_enter(gateHandle); + + // Get circular buffer base pointer + pCb = &pCbCtl->xDecOpCb[cbIdx]; + // (***) FL: revisit // Invalidate circular buffer configuration. // NOTE: Probably only a subset of this information needs to be updated. @@ -82,14 +115,30 @@ Int cbWriteStart( Cache_wb(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0); Cache_wait(); + // Leave the gate + GateMP_leave(gateHandle, key); + return ASP_DECOP_CB_SOK; }; // Stop writes to circular buffer Int cbWriteStop( - PAF_AST_DecOpCircBuf *pCb // decoder output circular buffer + PAF_AST_DecOpCircBufCtl *pCbCtl, // decoder output circular buffer control + Int8 cbIdx // decoder output circular buffer index ) { + IArg key; + GateMP_Handle gateHandle; + PAF_AST_DecOpCircBuf *pCb; + + // Get gate handle + gateHandle = pCbCtl->gateHandle; + // Enter gate + key = GateMP_enter(gateHandle); + + // Get circular buffer base pointer + pCb = &pCbCtl->xDecOpCb[cbIdx]; + // Invalidate circular buffer configuration Cache_inv(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0); Cache_wait(); @@ -103,20 +152,35 @@ Int cbWriteStop( Cache_wb(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0); Cache_wait(); + // Leave the gate + GateMP_leave(gateHandle, key); + return ASP_DECOP_CB_SOK; } // Write audio frame to circular buffer Int cbWriteAf( - PAF_AST_DecOpCircBuf *pCb, // decoder output circular buffer - PAF_AudioFrame *pAfWrt // audio frame from which to write + PAF_AST_DecOpCircBufCtl *pCbCtl, // decoder output circular buffer control + Int8 cbIdx, // decoder output circular buffer index + PAF_AudioFrame *pAfWrt // audio frame from which to write ) { + IArg key; + GateMP_Handle gateHandle; + PAF_AST_DecOpCircBuf *pCb; PAF_AudioFrame *pAfCb; PAF_ChannelMask_HD streamMask; Int8 i; Int16 j; + // Get gate handle + gateHandle = pCbCtl->gateHandle; + // Enter gate + key = GateMP_enter(gateHandle); + + // Get circular buffer base pointer + pCb = &pCbCtl->xDecOpCb[cbIdx]; + // (***) FL: revisit // Invalidate circular buffer configuration. // NOTE: Probably only a subset of this information nexeds to be updated. @@ -149,8 +213,13 @@ Int cbWriteAf( if (pCb->numAfCb >= pCb->maxNumAfCb) { pCb->errOvrCnt++; + //SW_BREAKPOINT; Log_info1("cbWriteAf: ERROR: overflow, numAfCb=%d", pCb->numAfCb); + + // Leave the gate + GateMP_leave(gateHandle, key); + return ASP_DECOP_CB_WRITE_OVERFLOW; } @@ -226,15 +295,31 @@ Int cbWriteAf( Cache_wait(); } + // Leave the gate + GateMP_leave(gateHandle, key); + return ASP_DECOP_CB_SOK; } // Get next audio frame to write in circular buffer Int cbGetNextWriteAf( - PAF_AST_DecOpCircBuf *pCb, // decoder output circular buffer - PAF_AudioFrame **ppAfWrt // audio frame next to be written + PAF_AST_DecOpCircBufCtl *pCbCtl, // decoder output circular buffer control + Int8 cbIdx, // decoder output circular buffer index + PAF_AudioFrame **ppAfWrt // audio frame next to be written ) { + IArg key; + GateMP_Handle gateHandle; + PAF_AST_DecOpCircBuf *pCb; + + // Get gate handle + gateHandle = pCbCtl->gateHandle; + // Enter gate + key = GateMP_enter(gateHandle); + + // Get circular buffer base pointer + pCb = &pCbCtl->xDecOpCb[cbIdx]; + // get pointer to current audio frame in circular buffer *ppAfWrt = &pCb->afCb[pCb->afWrtIdx]; @@ -245,5 +330,8 @@ Int cbGetNextWriteAf( pCb->afWrtIdx = 0; } + // Leave the gate + GateMP_leave(gateHandle, key); + return ASP_DECOP_CB_SOK; } diff --git a/processor_audio_sdk_1_00_00_00/pasdk/test_arm/framework/aspDecOpCircBuf_slave.h b/processor_audio_sdk_1_00_00_00/pasdk/test_arm/framework/aspDecOpCircBuf_slave.h index 2759e378..4e4dbf14 100644 --- a/processor_audio_sdk_1_00_00_00/pasdk/test_arm/framework/aspDecOpCircBuf_slave.h +++ b/processor_audio_sdk_1_00_00_00/pasdk/test_arm/framework/aspDecOpCircBuf_slave.h @@ -40,28 +40,32 @@ All rights reserved. #include "paftyp.h" #include "aspDecOpCircBuf_common.h" -#define ASP_DECOP_CB_WRITE_OVERFLOW ( ASP_DECOP_CB_SOK-1 ) // error: write overflow +#define ASP_DECOP_CB_WRITE_OVERFLOW ( ASP_DECOP_CB_ERR_START-1 ) // error: write overflow // Start writes to circular buffer Int cbWriteStart( - PAF_AST_DecOpCircBuf *pCb // decoder output circular buffer + PAF_AST_DecOpCircBufCtl *pCbCtl, // decoder output circular buffer control + Int8 cbIdx // decoder output circular buffer index ); // Stop writes to circular buffer Int cbWriteStop( - PAF_AST_DecOpCircBuf *pCb // decoder output circular buffer + PAF_AST_DecOpCircBufCtl *pCbCtl, // decoder output circular buffer control + Int8 cbIdx // decoder output circular buffer index ); // Write audio frame to circular buffer Int cbWriteAf( - PAF_AST_DecOpCircBuf *pCb, // decoder output circular buffer - PAF_AudioFrame *pAfWrt // audio frame from which to write + PAF_AST_DecOpCircBufCtl *pCbCtl, // decoder output circular buffer control + Int8 cbIdx, // decoder output circular buffer index + PAF_AudioFrame *pAfWrt // audio frame from which to write ); // Get next audio frame to write in circular buffer Int cbGetNextWriteAf( - PAF_AST_DecOpCircBuf *pCb, // decoder output circular buffer - PAF_AudioFrame **ppAfWrt // audio frame next to be written + PAF_AST_DecOpCircBufCtl *pCbCtl, // decoder output circular buffer control + Int8 cbIdx, // decoder output circular buffer index + PAF_AudioFrame **ppAfWrt // audio frame next to be written ); #endif /* _ASP_DECOP_CB_SLAVE_H_ */ diff --git a/processor_audio_sdk_1_00_00_00/pasdk/test_arm/framework/audioStreamDecodeProc.c b/processor_audio_sdk_1_00_00_00/pasdk/test_arm/framework/audioStreamDecodeProc.c index 6d0fec4b..e7ab2ca2 100644 --- a/processor_audio_sdk_1_00_00_00/pasdk/test_arm/framework/audioStreamDecodeProc.c +++ b/processor_audio_sdk_1_00_00_00/pasdk/test_arm/framework/audioStreamDecodeProc.c @@ -89,6 +89,7 @@ ERRNO_DEFN(TaskAsdp); /* Error number macros */ PAF_ASDT_Config gPAF_ASDT_config __attribute__ ((section(".globalSectionPafAsdtConfig"))) = { NULL, // acp + {NULL, NULL}, // decOpCircBufCtl &gPAF_AST_config // ASIT/ASOT/ASDT shared configuration }; @@ -139,7 +140,8 @@ Void taskAsdpFxn( Int size; Int argIdx; // Decoder output circular buffer - PAF_AST_DecOpCircBuf *pCb; + PAF_AST_DecOpCircBufCtl *pCbCtl; /* Decoder output circular buffer control */ + //PAF_AST_DecOpCircBuf *pCb; PAF_AudioFrame *pAfWrt; Int cbErrno; // Messaging @@ -173,7 +175,8 @@ Void taskAsdpFxn( // Audio Framework Configuration (*pC): // pC = &gPAF_ASDT_config; - pAstCfg = pC->pAstCfg; + pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration + pCbCtl = &pC->decOpCircBufCtl; // get pointer to circular buffer control // wait for initialization message from master do { @@ -449,14 +452,14 @@ Void taskAsdpFxn( } // Start writes to circular buffer - pCb = &pAstCfg->xDecOpCb[z]; - cbErrno = cbWriteStart(pCb); + //pCb = &pAstCfg->xDecOpCb[z]; + cbErrno = cbWriteStart(pCbCtl, z); if (cbErrno < 0) { SW_BREAKPOINT; } // FL: debug, log circular buffer control variables - cbLog(pCb, 1, "cbWriteStart"); + cbLog(pCbCtl, z, 1, "cbWriteStart"); // Reset audio frame resetAf(pP, z, sourceSelect); @@ -618,7 +621,7 @@ Void taskAsdpFxn( //TRACE_TERSE0("Dec:decode done"); // copy decoder output to decoder output circular buffers - pCb = &pAstCfg->xDecOpCb[z]; + //pCb = &pAstCfg->xDecOpCb[z]; //TRACE_TERSE1("Dec:pCb=0x%04x", (IArg)pCb); pAfWrt = pAstCfg->xDec[z].decodeOutStruct.pAudioFrame; @@ -631,7 +634,7 @@ Void taskAsdpFxn( // Log_info0("capAfWrite() error"); //} - cbErrno = cbWriteAf(pCb, pAfWrt); + cbErrno = cbWriteAf(pCbCtl, z, pAfWrt); if (cbErrno < 0) { SW_BREAKPOINT; @@ -639,7 +642,7 @@ Void taskAsdpFxn( //TRACE_TERSE0("Dec:cbWriteAf() complete"); // FL: debug, log circular buffer control variables - cbLog(pCb, 1, "cbWriteAf"); + cbLog(pCbCtl, z, 1, "cbWriteAf"); } // write back Dec configuration @@ -686,14 +689,14 @@ Void taskAsdpFxn( } // Stop writes to circular buffer - pCb = &pAstCfg->xDecOpCb[z]; - cbErrno = cbWriteStop(pCb); + //pCb = &pAstCfg->xDecOpCb[z]; + cbErrno = cbWriteStop(pCbCtl, z); if (cbErrno < 0) { SW_BREAKPOINT; } // FL: debug, log circular buffer control variables - cbLog(pCb, 1, "cbWriteStop"); + cbLog(pCbCtl, z, 1, "cbWriteStop"); // send dec deactivate complete message to master queId = MessageQ_getReplyQueue(pAspMsg); diff --git a/processor_audio_sdk_1_00_00_00/pasdk/test_arm/framework/audioStreamDecodeProc.h b/processor_audio_sdk_1_00_00_00/pasdk/test_arm/framework/audioStreamDecodeProc.h index da0aacef..3fa0fca5 100644 --- a/processor_audio_sdk_1_00_00_00/pasdk/test_arm/framework/audioStreamDecodeProc.h +++ b/processor_audio_sdk_1_00_00_00/pasdk/test_arm/framework/audioStreamDecodeProc.h @@ -45,6 +45,7 @@ All rights reserved. #include "audioStreamProc_params.h" #include "audioStreamProc_patchs.h" #include "audioStreamProc_config.h" +#include "aspDecOpCircBuf_common.h" struct PAF_ASDT_Params; struct PAF_ASDT_Patchs; @@ -107,6 +108,7 @@ typedef struct PAF_ASDT_Patchs { typedef struct PAF_ASDT_Config { ACP_Handle acp; + PAF_AST_DecOpCircBufCtl decOpCircBufCtl; // decoder output circular buffer control PAF_AST_Config *pAstCfg; // ASIT/ASOT/ASDT shared configuration } PAF_ASDT_Config; @@ -192,5 +194,6 @@ Int resetAfSamsiz( Int z ); +extern PAF_ASDT_Config gPAF_ASDT_config; #endif /* _ASDP_H_ */ diff --git a/processor_audio_sdk_1_00_00_00/pasdk/test_arm/framework/systemInit.c b/processor_audio_sdk_1_00_00_00/pasdk/test_arm/framework/systemInit.c index ad983176..dd6b2a10 100644 --- a/processor_audio_sdk_1_00_00_00/pasdk/test_arm/framework/systemInit.c +++ b/processor_audio_sdk_1_00_00_00/pasdk/test_arm/framework/systemInit.c @@ -46,6 +46,9 @@ All rights reserved. #include "pafhjt.h" #include "paf_heapMgr.h" +#include "aspDecOpCircBuf_slave.h" +#include "audioStreamProc_common.h" +#include "audioStreamDecodeProc.h" const PAFHJT_t *pafhjt; @@ -97,6 +100,14 @@ Void taskSysInitFxn(Void) return; } + /* Initialize decoder output circular buffer control */ + status = cbCtlInit(&gPAF_ASDT_config.decOpCircBufCtl, gPAF_AST_config.xDecOpCb); + if (status < 0) + { + Log_info1("%s: unable to initialize Decoder Output Circular Buffer Control. Exiting.", (IArg)__TASK_NAME__); + return; + } + /* Initialize PAF heap manager */ Log_info0("taskSysInitFxn:pafHeapMgr_init()"); pafHeapMgr_init((IHeap_Handle)heapMemL2Sram, diff --git a/processor_audio_sdk_1_00_00_00/pasdk/test_dsp/framework/aspDecOpCircBuf_master.c b/processor_audio_sdk_1_00_00_00/pasdk/test_dsp/framework/aspDecOpCircBuf_master.c index 948c1fb9..e8c86a38 100644 --- a/processor_audio_sdk_1_00_00_00/pasdk/test_dsp/framework/aspDecOpCircBuf_master.c +++ b/processor_audio_sdk_1_00_00_00/pasdk/test_dsp/framework/aspDecOpCircBuf_master.c @@ -37,6 +37,7 @@ All rights reserved. #include #include #include +#include #include "common.h" #include "paftyp.h" @@ -55,21 +56,65 @@ static Void cbReadAfMute( Int16 strFrameLen // stream frame length (output transaction size) ); + +// Initialize circular buffer control +Int cbCtlInit( + PAF_AST_DecOpCircBufCtl *pCbCtl, // decoder output circular buffer control + PAF_AST_DecOpCircBuf *xDecOpCb // decoder output circular buffer base pointer +) +{ + GateMP_Params gateParams; + GateMP_Handle gateHandle; + + GateMP_Params_init(&gateParams); + gateParams.localProtect = GateMP_LocalProtect_THREAD; + gateParams.remoteProtect = GateMP_RemoteProtect_SYSTEM; + gateParams.name = ASP_DECODE_CB_GATE_NAME; + gateParams.regionId = ASP_DECODE_CB_GATE_REGION_ID; + gateHandle = GateMP_create(&gateParams); + if (gateHandle != NULL) + { + pCbCtl->gateHandle = gateHandle; + } + else + { + pCbCtl->gateHandle = NULL; + return ASP_DECOP_CB_CTL_INIT_INV_GATE; + } + + pCbCtl->xDecOpCb = xDecOpCb; + + return ASP_DECOP_CB_SOK; + +} + // 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_AST_DecOpCircBuf *pCb, // decoder output circular buffer - Int8 resetRwFlags // whether to reset reader, writer, and empty flags + PAF_AST_DecOpCircBufCtl *pCbCtl, // decoder output circular buffer control + Int8 cbIdx, // decoder output circular buffer index + Int8 sourceSelect, // source select (PCM, DDP, etc.) + Int16 decOpFrameLen, // decoder output frame length (PCM samples) + Int16 strFrameLen, // stream frame length (PCM samples) + Int8 resetRwFlags // whether to reset reader, writer, and empty flags ) { + IArg key; + GateMP_Handle gateHandle; + PAF_AST_DecOpCircBuf *pCb; PAF_AudioFrame *pAfCb; PAF_AudioData *pPcmBuf; UInt8 *pMetaBuf; //QIN Int8 n; Int8 i; + // Get gate handle + gateHandle = pCbCtl->gateHandle; + // Enter gate + key = GateMP_enter(gateHandle); + + // Get circular buffer base pointer + pCb = &pCbCtl->xDecOpCb[cbIdx]; + // set input frame length pCb->decOpFrameLen = decOpFrameLen; @@ -125,6 +170,9 @@ Int cbInit( } else { + // Leave the gate + GateMP_leave(gateHandle, key); + return ASP_DECOP_CB_INIT_INV_SOURCE_SEL; } @@ -192,14 +240,30 @@ Int cbInit( } Cache_wait(); + // Leave the gate + GateMP_leave(gateHandle, key); + return ASP_DECOP_CB_SOK; } // Start reads from circular buffer Int cbReadStart( - PAF_AST_DecOpCircBuf *pCb // decoder output circular buffer + PAF_AST_DecOpCircBufCtl *pCbCtl, // decoder output circular buffer control + Int8 cbIdx // decoder output circular buffer index ) { + IArg key; + GateMP_Handle gateHandle; + PAF_AST_DecOpCircBuf *pCb; + + // Get gate handle + gateHandle = pCbCtl->gateHandle; + // Enter gate + key = GateMP_enter(gateHandle); + + // Get circular buffer base pointer + pCb = &pCbCtl->xDecOpCb[cbIdx]; + // Invalidate circular buffer configuration Cache_inv(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0); Cache_wait(); @@ -212,14 +276,30 @@ Int cbReadStart( Cache_wb(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0); Cache_wait(); + // Leave the gate + GateMP_leave(gateHandle, key); + return ASP_DECOP_CB_SOK; } // Stop reads from circular buffer Int cbReadStop( - PAF_AST_DecOpCircBuf *pCb // decoder output circular buffer + PAF_AST_DecOpCircBufCtl *pCbCtl, // decoder output circular buffer control + Int8 cbIdx // decoder output circular buffer index ) { + IArg key; + GateMP_Handle gateHandle; + PAF_AST_DecOpCircBuf *pCb; + + // Get gate handle + gateHandle = pCbCtl->gateHandle; + // Enter gate + key = GateMP_enter(gateHandle); + + // Get circular buffer base pointer + pCb = &pCbCtl->xDecOpCb[cbIdx]; + // Invalidate circular buffer configuration Cache_inv(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0); Cache_wait(); @@ -232,20 +312,35 @@ Int cbReadStop( Cache_wb(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0); Cache_wait(); + // Leave the gate + GateMP_leave(gateHandle, key); + return ASP_DECOP_CB_SOK; } // Read audio frame from circular buffer Int cbReadAf( - PAF_AST_DecOpCircBuf *pCb, // decoder output circular buffer - PAF_AudioFrame *pAfRd // audio frame into which to read + PAF_AST_DecOpCircBufCtl *pCbCtl, // decoder output circular buffer control + Int8 cbIdx, // decoder output circular buffer index + PAF_AudioFrame *pAfRd // audio frame into which to read ) { + IArg key; + GateMP_Handle gateHandle; + PAF_AST_DecOpCircBuf *pCb; PAF_AudioFrame *pAfCb; PAF_ChannelMask_HD streamMask; Int8 i; Int16 j; + // Get gate handle + gateHandle = pCbCtl->gateHandle; + // Enter gate + key = GateMP_enter(gateHandle); + + // Get circular buffer base pointer + pCb = &pCbCtl->xDecOpCb[cbIdx]; + // (***) FL: revisit // Invalidate circular buffer configuration. Cache_inv(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0); @@ -257,6 +352,10 @@ Int cbReadAf( // writer is active AND draining circular buffer Log_info2("cbReadAf: ERROR: writerActiveFlag=%d, emptyFlag=%d", pCb->writerActiveFlag, pCb->emptyFlag); SW_BREAKPOINT; // FL: debug + + // Leave the gate + GateMP_leave(gateHandle, key); + return ASP_DECOP_CB_READ_INVSTATE; } @@ -268,6 +367,9 @@ Int cbReadAf( // cbReadAfMute(pAfRd, pCb->strFrameLen); + // Leave the gate + GateMP_leave(gateHandle, key); + return ASP_DECOP_CB_SOK; } @@ -288,6 +390,9 @@ Int cbReadAf( Cache_wb(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0); Cache_wait(); + // Leave the gate + GateMP_leave(gateHandle, key); + return ASP_DECOP_CB_READ_UNDERFLOW; } } @@ -418,6 +523,9 @@ Int cbReadAf( Cache_wb(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0); Cache_wait(); + // Leave the gate + GateMP_leave(gateHandle, key); + return ASP_DECOP_CB_SOK; } diff --git a/processor_audio_sdk_1_00_00_00/pasdk/test_dsp/framework/aspDecOpCircBuf_master.h b/processor_audio_sdk_1_00_00_00/pasdk/test_dsp/framework/aspDecOpCircBuf_master.h index fd297784..eb4e89b8 100644 --- a/processor_audio_sdk_1_00_00_00/pasdk/test_dsp/framework/aspDecOpCircBuf_master.h +++ b/processor_audio_sdk_1_00_00_00/pasdk/test_dsp/framework/aspDecOpCircBuf_master.h @@ -40,40 +40,45 @@ All rights reserved. #include "paftyp.h" #include "aspDecOpCircBuf_common.h" -#define ASP_DECOP_CB_INIT_INV_SOURCE_SEL ( ASP_DECOP_CB_SOK-1 ) // error: invalid source selection on init -#define ASP_DECOP_CB_READ_UNDERFLOW ( ASP_DECOP_CB_SOK-2 ) // error: read underflow -#define ASP_DECOP_CB_READ_INVSTATE ( ASP_DECOP_CB_SOK-3 ) // error: circular buffer invalid state on read +#define ASP_DECOP_CB_INIT_INV_SOURCE_SEL ( ASP_DECOP_CB_ERR_START-1 ) // error: invalid source selection on init +#define ASP_DECOP_CB_READ_UNDERFLOW ( ASP_DECOP_CB_ERR_START-2 ) // error: read underflow +#define ASP_DECOP_CB_READ_INVSTATE ( ASP_DECOP_CB_ERR_START-3 ) // error: circular buffer invalid state on read // 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_AST_DecOpCircBuf *pCb, // decoder output circular buffer - Int8 resetRwFlags // whether to reset reader, writer, and empty flags + PAF_AST_DecOpCircBufCtl *pCbCtl, // decoder output circular buffer control + Int8 cbIdx, // decoder output circular buffer index + Int8 sourceSelect, // source select (PCM, DDP, etc.) + Int16 decOpFrameLen, // decoder output frame length (PCM samples) + Int16 strFrameLen, // stream frame length (PCM samples) + Int8 resetRwFlags // whether to reset reader, writer, and empty flags ); // Start reads from circular buffer Int cbReadStart( - PAF_AST_DecOpCircBuf *pCb // decoder output circular buffer + PAF_AST_DecOpCircBufCtl *pCbCtl, // decoder output circular buffer control + Int8 cbIdx // decoder output circular buffer index ); // Stop reads from circular buffer Int cbReadStop( - PAF_AST_DecOpCircBuf *pCb // decoder output circular buffer + PAF_AST_DecOpCircBufCtl *pCbCtl, // decoder output circular buffer control + Int8 cbIdx // decoder output circular buffer index ); // Read audio frame from circular buffer Int cbReadAf( - PAF_AST_DecOpCircBuf *pCb, // decoder output circular buffer - PAF_AudioFrame *pAfRd // audio frame into which to read + PAF_AST_DecOpCircBufCtl *pCbCtl, // decoder output circular buffer control + Int8 cbIdx, // decoder output circular buffer index + PAF_AudioFrame *pAfRd // audio frame into which to read ); // Write audio frame to circular buffer Int cbWriteAf( - PAF_AST_DecOpCircBuf *pCb, // decoder output circular buffer - PAF_AudioFrame *pAfWrt // audio frame from which to write + PAF_AST_DecOpCircBufCtl *pCbCtl, // decoder output circular buffer control + Int8 cbIdx, // decoder output circular buffer index + PAF_AudioFrame *pAfWrt // audio frame from which to write ); #endif /* _ASP_DECOP_CB_MASTER_H_ */ diff --git a/processor_audio_sdk_1_00_00_00/pasdk/test_dsp/framework/audioStreamInpProc.c b/processor_audio_sdk_1_00_00_00/pasdk/test_dsp/framework/audioStreamInpProc.c index 6fe77021..5209f704 100644 --- a/processor_audio_sdk_1_00_00_00/pasdk/test_dsp/framework/audioStreamInpProc.c +++ b/processor_audio_sdk_1_00_00_00/pasdk/test_dsp/framework/audioStreamInpProc.c @@ -1333,19 +1333,21 @@ PAF_ASIT_initPhaseDecOpCircBuf( ) { PAF_AST_Config *pAstCfg; - Int as; /* Audio Stream Number (1, 2, etc.) */ + PAF_AST_DecOpCircBufCtl *pCbCtl; /* Decoder output circular buffer control */ + PAF_AST_DecOpCircBuf *pCb; /* Decoder output circular buffer */ + Int as; /* Audio Stream Number (1, 2, etc.) */ Int zMS; - Int z; /* decode counter */ - PAF_AST_DecOpCircBuf *pCb; /* Decoder output circular buffer */ - Int errno; /* error number */ + Int z; /* decode counter */ + Int errno; /* error number */ Error_Block eb; Int i; // FL: (***)revisit - pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration as = pAstCfg->as; zMS = pAstCfg->masterStr; + + pCbCtl = &pC->pAspmCfg->decOpCircBufCtl; // get pointer to circular buffer control /* Decode output circular buffer memory */ if (!(pAstCfg->xDecOpCb = Memory_calloc((IHeap_Handle)HEAP_INTERNAL1_SHM, @@ -1398,14 +1400,14 @@ PAF_ASIT_initPhaseDecOpCircBuf( // (***) FL: revisit, here PCM is hard-coded for 256 sample dec op frame length // Initialize decoder output circular buffer for PCM - errno = cbInit(PAF_SOURCE_PCM, 256, FRAMELENGTH, pCb, 1); + errno = cbInit(pCbCtl, z, PAF_SOURCE_PCM, 256, FRAMELENGTH, 1); if (errno) { SW_BREAKPOINT; // FL: debug return errno; } // FL: debug - cbLog(pCb, 1, "PAF_ASIT_initPhaseDecOpCircBuf:cbInit"); + cbLog(pCbCtl, z, 1, "PAF_ASIT_initPhaseDecOpCircBuf:cbInit"); } return 0; @@ -2238,17 +2240,17 @@ PAF_ASIT_decodeInit( ) { 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 zI, zS; Int zMD; Int zMI; - ASP_Msg* pAspMsg; /* Messaging */ + ASP_Msg* pAspMsg; /* Messaging */ Int argIdx; Int decErrno; Int status; - PAF_AST_DecOpCircBuf *pCb; /* Decoder output circular buffer */ pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration as = pAstCfg->as; @@ -2256,6 +2258,8 @@ PAF_ASIT_decodeInit( zMI = pP->zone.master; (void)as; // clear compiler warning in case not used with tracing disabled + pCbCtl = &pC->pAspmCfg->decOpCircBufCtl; // get pointer to circular buffer control + // reset frameCount for (z=DECODE1; z < DECODEN; z++) { @@ -2439,15 +2443,14 @@ PAF_ASIT_decodeInit( //pC->xDec[z].decodeControl.rdSampleCount = 0; // Initialize decoder output circular buffer for selected source - pCb = &pAstCfg->xDecOpCb[z]; - errno = cbInit(sourceSelect, frameLength, FRAMELENGTH, pCb, 0); + errno = cbInit(pCbCtl, z, sourceSelect, frameLength, FRAMELENGTH, 0); if (errno) { SW_BREAKPOINT; // FL: debug return errno; } // FL: debug - cbLog(pCb, 1, "PAF_ASIT_decodeInit:cbInit"); + cbLog(pCbCtl, z, 1, "PAF_ASIT_decodeInit:cbInit"); if (z != zMD) { 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 9ff831a0..7d0b6127 100644 --- 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 @@ -1629,21 +1629,22 @@ PAF_ASOT_decodeInit( ) { 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); @@ -1651,7 +1652,7 @@ PAF_ASOT_decodeInit( 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 @@ -1825,14 +1826,16 @@ PAF_ASOT_decodeStream( ) { 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++) { @@ -1841,9 +1844,8 @@ PAF_ASOT_decodeStream( // // (***) FL: read 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); @@ -1853,7 +1855,7 @@ PAF_ASOT_decodeStream( //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"); @@ -2101,21 +2103,22 @@ PAF_ASOT_decodeComplete( ) { 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); @@ -2123,7 +2126,7 @@ PAF_ASOT_decodeComplete( 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); diff --git a/processor_audio_sdk_1_00_00_00/pasdk/test_dsp/framework/audioStreamProc_master.h b/processor_audio_sdk_1_00_00_00/pasdk/test_dsp/framework/audioStreamProc_master.h index 3d1526db..3a458a56 100644 --- a/processor_audio_sdk_1_00_00_00/pasdk/test_dsp/framework/audioStreamProc_master.h +++ b/processor_audio_sdk_1_00_00_00/pasdk/test_dsp/framework/audioStreamProc_master.h @@ -47,7 +47,7 @@ All rights reserved. // Audio Stream Input/Output Task shared typedef struct PAF_ASPM_Config { - PAF_AST_DecOpCircBufCtrl decOpCircBufCtrl; + PAF_AST_DecOpCircBufCtl decOpCircBufCtl; // decoder output circular buffer control } PAF_ASPM_Config; extern PAF_ASPM_Config gPAF_ASPM_config; diff --git a/processor_audio_sdk_1_00_00_00/pasdk/test_dsp/framework/systemInit.c b/processor_audio_sdk_1_00_00_00/pasdk/test_dsp/framework/systemInit.c index d85d0a28..f5e1a744 100644 --- a/processor_audio_sdk_1_00_00_00/pasdk/test_dsp/framework/systemInit.c +++ b/processor_audio_sdk_1_00_00_00/pasdk/test_dsp/framework/systemInit.c @@ -49,6 +49,9 @@ All rights reserved. #include "paf_heapMgr.h" #include "aspMsg_common.h" #include "aspMsg_master.h" +#include "aspDecOpCircBuf_master.h" +#include "audioStreamProc_master.h" // ASIT/ASOT config +#include "audioStreamProc_common.h" // ASIT/ASOT/ASDT config #include "fwkSim.h" extern Void ACP_main_cus(Void); // (*** ?) FL: revisit -- check method of patching alpha codes @@ -116,6 +119,14 @@ Void taskSysInitFxn(Void) return; } + /* Initialize decoder output circular buffer control */ + status = cbCtlInit(&gPAF_ASPM_config.decOpCircBufCtl, gPAF_AST_config.xDecOpCb); + if (status < 0) + { + Log_info0("TaskSysInit: unable to initialize Decoder Output Circular Buffer Control. Exiting."); + return; + } + /* Initialize PAF heap manager */ Log_info0("taskSysInitFxn:pafHeapMgr_init()"); regionId = SharedRegion_getIdByName("SR_MSMC"); -- 2.26.2