Several updates
authorFrank Livingston <frank-livingston@ti.com>
Sun, 4 Sep 2016 14:51:18 +0000 (09:51 -0500)
committerFrank Livingston <frank-livingston@ti.com>
Sun, 4 Sep 2016 14:51:18 +0000 (09:51 -0500)
- Change pC (AST configuration pointer) to local pointer for each AS task
- Change location of Decoder Output Circular Buffer in AST configuration
- Add separate initPhase in ASIT for Decoder Output Circular Buffer

processor_audio_sdk_1_00_00_00/pasdk/common/audioStreamProc_common.c
processor_audio_sdk_1_00_00_00/pasdk/common/audioStreamProc_config.h
processor_audio_sdk_1_00_00_00/pasdk/common/paf_decOpCircBuf.c
processor_audio_sdk_1_00_00_00/pasdk/common/paf_decOpCircBuf.h
processor_audio_sdk_1_00_00_00/pasdk/test_arm/framework/audioStreamDecodeProc.c
processor_audio_sdk_1_00_00_00/pasdk/test_arm/framework/itopo/params.c
processor_audio_sdk_1_00_00_00/pasdk/test_dsp/framework/audioStreamInpProc.c
processor_audio_sdk_1_00_00_00/pasdk/test_dsp/framework/audioStreamInpProc.h
processor_audio_sdk_1_00_00_00/pasdk/test_dsp/framework/audioStreamInpProc_paramsFxns.c
processor_audio_sdk_1_00_00_00/pasdk/test_dsp/framework/audioStreamOutProc.c

index 85ac046cf7a404ba6304b4bb899ffe8bdb7a148a..738c5e36c9edf541d79c2bb2697c02c125fb87fa 100644 (file)
@@ -44,13 +44,13 @@ All rights reserved.
 // Task data
 #ifndef _TMS320C6X
 PAF_AST_Config gPAF_AST_config      __attribute__ ((section(".globalSectionPafAstConfig"))); /* Global configuration */
-PAF_AST_Config *pC                  __attribute__ ((section(".globalSectionPafAstConfig"))); /* Global configuration pointer */
+//PAF_AST_Config *pC                  __attribute__ ((section(".globalSectionPafAstConfig"))); /* Global configuration pointer */
 
 #else
 
 #pragma DATA_SECTION(gPAF_AST_config, ".globalSectionPafAstConfig")
 #pragma DATA_SECTION(pC, ".globalSectionPafAstConfig")
 PAF_AST_Config gPAF_AST_config; /* Global configuration */
-far PAF_AST_Config *pC;         /* Global configuration pointer */
+//far PAF_AST_Config *pC;         /* Global configuration pointer */
 
 #endif
index 53ed9b04e2b3d5fe42477f6a34f3728910fd0c38..0011b8134446d7b354fc11d5efee47879a51b325 100644 (file)
@@ -87,7 +87,6 @@ typedef struct PAF_AST_Decode {
     PAF_ASP_Chain       decChainData;
     ALG_Handle          decAlg[PAF_SOURCE_N];
     PAF_AudioFrame     *pAudioFrame;
-    PAF_DecodeOpCircBuf decOpCb;
 } PAF_AST_Decode;
 
 typedef struct PAF_AST_Stream {
@@ -125,18 +124,19 @@ typedef struct PAF_AST_MQ {
 #endif
 
 typedef struct PAF_AST_Config {
-    Int                 as;
-    ACP_Handle          acp;
-    ACP_Handle          acpSlave;
-    PAF_AST_InpBuf      *xInp; /* INPUT1 -INPUTN  */
-    PAF_AST_Decode      *xDec; /* DECODE1-DECODEN  */
-    PAF_AST_Stream      *xStr; /* STREAM1-STREAMN */
-    PAF_AST_Encode      *xEnc; /* ENCODE1-ENCODEN */
-    PAF_AST_OutBuf      *xOut; /* OUTPUT1-OUTPUTN */
-    SmInt               masterDec; // these two are computer based on MASTER input
-    SmInt               masterStr;
+    Int                  as;
+    ACP_Handle           acp;
+    ACP_Handle           acpSlave;
+    PAF_AST_InpBuf       *xInp;     /* INPUT1 -INPUTN  */
+    PAF_AST_Decode       *xDec;     /* DECODE1-DECODEN */
+    PAF_AST_Stream       *xStr;     /* STREAM1-STREAMN */
+    PAF_AST_Encode       *xEnc;     /* ENCODE1-ENCODEN */
+    PAF_AST_OutBuf       *xOut;     /* OUTPUT1-OUTPUTN */
+    PAF_AST_DecOpCircBuf *xDecOpCb; /* DECODE1-DECODEN */
+    SmInt                masterDec; // these two are computer based on MASTER input
+    SmInt                masterStr;
 #ifdef HSE_MSGQ
-    PAF_AST_MQ          mq;
+    PAF_AST_MQ           mq;
 #endif
 } PAF_AST_Config;
 
index 565bea45b973000df3fbc878dc2fe5e30b38ee35..edd1d35479a7d83988601dd29e0b786cd32754bc 100644 (file)
@@ -60,7 +60,7 @@ 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
+    PAF_AST_DecOpCircBuf *pCb,  // decoder output circular buffer
     Int8 resetRwFlags           // whether to reset reader, writer, and empty flags
 )
 {
@@ -171,7 +171,7 @@ Int cbInit(
     
     // (***) FL: revisit
     // Write back circular buffer configuration
-    Cache_wb(pCb, sizeof(PAF_DecodeOpCircBuf), Cache_Type_ALLD, 0);
+    Cache_wb(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0);
     // Write back AF circular buffer
     Cache_wb(pCb->afCb, pCb->maxNumAfCb*sizeof(PAF_AudioFrame), Cache_Type_ALLD, 0);
     // Write back PCM data
@@ -197,7 +197,7 @@ Int cbInit(
 
 // Start writes to circular buffer
 Int cbWriteStart(
-    PAF_DecodeOpCircBuf *pCb    // decoder output circular buffer
+    PAF_AST_DecOpCircBuf *pCb   // decoder output circular buffer
 )
 {
     PAF_AudioFrame *pAfCb;
@@ -207,7 +207,7 @@ Int cbWriteStart(
     // (***) FL: revisit
     // Invalidate circular buffer configuration.
     // NOTE: Probably only a subset of this information needs to be updated.
-    Cache_inv(pCb, sizeof(PAF_DecodeOpCircBuf), Cache_Type_ALLD, 0);
+    Cache_inv(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0);
     Cache_wait();
     
     // Invalidate AF circular buffer
@@ -230,7 +230,7 @@ Int cbWriteStart(
     
     // (***) FL: revisit
     // Write back circular buffer configuration
-    Cache_wb(pCb, sizeof(PAF_DecodeOpCircBuf), Cache_Type_ALLD, 0);
+    Cache_wb(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0);
     Cache_wait();
 
     return PAF_DECOP_CB_SOK;
@@ -238,11 +238,11 @@ Int cbWriteStart(
 
 // Stop writes to circular buffer
 Int cbWriteStop(
-    PAF_DecodeOpCircBuf *pCb    // decoder output circular buffer
+    PAF_AST_DecOpCircBuf *pCb   // decoder output circular buffer
 )
 {
     // Invalidate circular buffer configuration
-    Cache_inv(pCb, sizeof(PAF_DecodeOpCircBuf), Cache_Type_ALLD, 0);
+    Cache_inv(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0);
     Cache_wait();
     
     // update flags
@@ -251,7 +251,7 @@ Int cbWriteStop(
 
     // (***) FL: revisit
     // Write back circular buffer configuration
-    Cache_wb(pCb, sizeof(PAF_DecodeOpCircBuf), Cache_Type_ALLD, 0);
+    Cache_wb(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0);
     Cache_wait();
     
     return PAF_DECOP_CB_SOK;
@@ -259,11 +259,11 @@ Int cbWriteStop(
 
 // Start reads from circular buffer
 Int cbReadStart(
-    PAF_DecodeOpCircBuf *pCb    // decoder output circular buffer
+    PAF_AST_DecOpCircBuf *pCb   // decoder output circular buffer
 )
 {
     // Invalidate circular buffer configuration
-    Cache_inv(pCb, sizeof(PAF_DecodeOpCircBuf), Cache_Type_ALLD, 0);
+    Cache_inv(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0);
     Cache_wait();
     
     // update flags
@@ -271,7 +271,7 @@ Int cbReadStart(
     
     // (***) FL: revisit
     // Write back circular buffer configuration
-    Cache_wb(pCb, sizeof(PAF_DecodeOpCircBuf), Cache_Type_ALLD, 0);
+    Cache_wb(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0);
     Cache_wait();
 
     return PAF_DECOP_CB_SOK;
@@ -279,11 +279,11 @@ Int cbReadStart(
 
 // Stop reads from circular buffer
 Int cbReadStop(
-    PAF_DecodeOpCircBuf *pCb    // decoder output circular buffer
+    PAF_AST_DecOpCircBuf *pCb   // decoder output circular buffer
 )
 {
     // Invalidate circular buffer configuration
-    Cache_inv(pCb, sizeof(PAF_DecodeOpCircBuf), Cache_Type_ALLD, 0);
+    Cache_inv(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0);
     Cache_wait();
     
     // update flags
@@ -291,7 +291,7 @@ Int cbReadStop(
     
     // (***) FL: revisit
     // Write back circular buffer configuration
-    Cache_wb(pCb, sizeof(PAF_DecodeOpCircBuf), Cache_Type_ALLD, 0);
+    Cache_wb(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0);
     Cache_wait();
 
     return PAF_DECOP_CB_SOK;
@@ -299,7 +299,7 @@ Int cbReadStop(
 
 // Read audio frame from circular buffer
 Int cbReadAf(
-    PAF_DecodeOpCircBuf *pCb,   // decoder output circular buffer
+    PAF_AST_DecOpCircBuf *pCb,  // decoder output circular buffer
     PAF_AudioFrame *pAfRd       // audio frame into which to read
 )
 {
@@ -310,7 +310,7 @@ Int cbReadAf(
 
     // (***) FL: revisit
     // Invalidate circular buffer configuration.
-    Cache_inv(pCb, sizeof(PAF_DecodeOpCircBuf), Cache_Type_ALLD, 0);
+    Cache_inv(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0);
     Cache_wait();
 
     if ((pCb->writerActiveFlag == 1) && (pCb->emptyFlag == 1))
@@ -347,7 +347,7 @@ Int cbReadAf(
             //SW_BREAKPOINT; // FL: debug
             
             // Write back circular buffer configuration.
-            Cache_wb(pCb, sizeof(PAF_DecodeOpCircBuf), Cache_Type_ALLD, 0);
+            Cache_wb(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0);
             Cache_wait();    
             
             return PAF_DECOP_CB_READ_UNDERFLOW;
@@ -477,7 +477,7 @@ Int cbReadAf(
     // (***) FL: revisit
     // Write back circular buffer configuration.
     // NOTE: Probably only a subset of this information needs to be updated.
-    Cache_wb(pCb, sizeof(PAF_DecodeOpCircBuf), Cache_Type_ALLD, 0);
+    Cache_wb(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0);
     Cache_wait();    
         
     return PAF_DECOP_CB_SOK;
@@ -485,7 +485,7 @@ Int cbReadAf(
 
 // Write audio frame to circular buffer
 Int cbWriteAf(
-    PAF_DecodeOpCircBuf *pCb,   // decoder output circular buffer
+    PAF_AST_DecOpCircBuf *pCb,  // decoder output circular buffer
     PAF_AudioFrame *pAfWrt      // audio frame from which to write
 )
 {
@@ -497,7 +497,7 @@ Int cbWriteAf(
     // (***) FL: revisit
     // Invalidate circular buffer configuration.
     // NOTE: Probably only a subset of this information nexeds to be updated.
-    Cache_inv(pCb, sizeof(PAF_DecodeOpCircBuf), Cache_Type_ALLD, 0);
+    Cache_inv(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0);
     Cache_wait();
     
     if (pCb->readerActiveFlag == 1)
@@ -581,7 +581,7 @@ Int cbWriteAf(
 
         // (***) FL: revisit
         // Write back circular buffer configuration
-        Cache_wb(pCb, sizeof(PAF_DecodeOpCircBuf), Cache_Type_ALLD, 0);
+        Cache_wb(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0);
         // write back audio frame
         Cache_wb(pAfCb, sizeof(PAF_AudioFrame), Cache_Type_ALLD, 0);
         Cache_wb(pAfCb->data.samsiz, PAF_DECOP_CB_MAX_NUM_PCM_CH*sizeof(PAF_AudioSize), Cache_Type_ALLD, 0);
@@ -608,8 +608,8 @@ Int cbWriteAf(
 
 // Get next audio frame to write in circular buffer
 Int cbGetNextWriteAf(
-    PAF_DecodeOpCircBuf *pCb, // decoder output circular buffer
-    PAF_AudioFrame **ppAfWrt  // audio frame next to be written
+    PAF_AST_DecOpCircBuf *pCb, // decoder output circular buffer
+    PAF_AudioFrame **ppAfWrt   // audio frame next to be written
 )
 {
     // get pointer to current audio frame in circular buffer
@@ -627,7 +627,7 @@ Int cbGetNextWriteAf(
 
 // Output log of circular buffer control variables (debug)
 Int cbLog(
-    PAF_DecodeOpCircBuf *pCb,
+    PAF_AST_DecOpCircBuf *pCb,
     Int8 fullLog, 
     char *locInfo
 )
@@ -678,4 +678,4 @@ static Void cbReadAfMute(
         }
         pAfRd->data.samsiz[i] = 0;
     }
-}
\ No newline at end of file
+}
index b7bcf6c3e1cec9e80b83776fade6975337d804c5..d721228f8d31d979b1a248e1bc8363b147ea9e79 100644 (file)
@@ -52,74 +52,75 @@ All rights reserved.
 #define PAF_DECOP_CB_PCM_BUF_SZ             ( PAF_DECOP_CB_MAX_NUM_PCM_CH * PAF_DECOP_CB_MAX_NUM_PCM_FRAMES * PAF_DECOP_CB_MAX_PCM_FRAME_LEN )
 
 // Decoder output circular buffer
-typedef struct PAF_DecodeOpCircBuf {
-        PAF_AudioFrame *afCb;   // audio frame CB
-        PAF_AudioData *pcmBuf;  // PCM buffer, contains PCM data associated with audio frames
-        Int8          *metaBuf; // metafdata buffer, contains metadata associated with audio frames //QIN
-        Int8 afRdIdx;           // audio frame CB read index
-        Int8 afWrtIdx;          // audio frame CB write index
-        Int16 pcmRdIdx;         // pcm buffer read index
-        Int8 numAfCb;           // current number frames in CB
-        Int8 maxNumAfCb;        // maximum number of audio frames in CB
-        Int16 decOpFrameLen;    // selected decoder output frame length (input transaction size)
-        Int16 strFrameLen;      // stream frame length (output transaction size)
-        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
-        Int8 errUndCnt;         // underflow count
-        Int8 errOvrCnt;         // overflow count
-} PAF_DecodeOpCircBuf;
+typedef struct PAF_AST_DecOpCircBuf 
+{
+    PAF_AudioFrame *afCb;   // audio frame CB
+    PAF_AudioData *pcmBuf;  // PCM buffer, contains PCM data associated with audio frames
+    Int8          *metaBuf; // metafdata buffer, contains metadata associated with audio frames //QIN
+    Int8 afRdIdx;           // audio frame CB read index
+    Int8 afWrtIdx;          // audio frame CB write index
+    Int16 pcmRdIdx;         // pcm buffer read index
+    Int8 numAfCb;           // current number frames in CB
+    Int8 maxNumAfCb;        // maximum number of audio frames in CB
+    Int16 decOpFrameLen;    // selected decoder output frame length (input transaction size)
+    Int16 strFrameLen;      // stream frame length (output transaction size)
+    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
+    Int8 errUndCnt;         // underflow count
+    Int8 errOvrCnt;         // overflow count
+} PAF_AST_DecOpCircBuf;
 
 // 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
+    PAF_AST_DecOpCircBuf *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
+    PAF_AST_DecOpCircBuf *pCb   // decoder output circular buffer
 );
 
 // Stop writes to circular buffer
 Int cbWriteStop(
-    PAF_DecodeOpCircBuf *pCb    // decoder output circular buffer
+    PAF_AST_DecOpCircBuf *pCb   // decoder output circular buffer
 );
 
 // Start reads from circular buffer
 Int cbReadStart(
-    PAF_DecodeOpCircBuf *pCb    // decoder output circular buffer
+    PAF_AST_DecOpCircBuf *pCb   // decoder output circular buffer
 );
 
 // Stop reads from circular buffer
 Int cbReadStop(
-    PAF_DecodeOpCircBuf *pCb    // decoder output circular buffer
+    PAF_AST_DecOpCircBuf *pCb   // decoder output circular buffer
 );
 
 // Read audio frame from circular buffer
 Int cbReadAf(
-    PAF_DecodeOpCircBuf *pCb,   // decoder output circular buffer
+    PAF_AST_DecOpCircBuf *pCb,  // decoder output circular buffer
     PAF_AudioFrame *pAfRd       // audio frame into which to read
 );
 
 // Write audio frame to circular buffer
 Int cbWriteAf(
-    PAF_DecodeOpCircBuf *pCb,   // decoder output circular buffer
+    PAF_AST_DecOpCircBuf *pCb,  // decoder output circular buffer
     PAF_AudioFrame *pAfWrt      // audio frame from which to write
 );
 
 // Get next audio frame to write in circular buffer
 Int cbGetNextWriteAf(
-    PAF_DecodeOpCircBuf *pCb,   // decoder output circular buffer
+    PAF_AST_DecOpCircBuf *pCb,  // decoder output circular buffer
     PAF_AudioFrame **ppAfWrt    // audio frame next to be written
 );
 
 // Output log of circular buffer control variables (debug)
 Int cbLog(
-    PAF_DecodeOpCircBuf *pCb,
+    PAF_AST_DecOpCircBuf *pCb,
     Int8 fullLog, 
     char *locInfo
 );
index 63ba333f68859ac9df2fd2349bfb37cc5d838c55..993a2a82157b2b1957236a7923443a78ec8ebc0b 100644 (file)
@@ -117,6 +117,7 @@ Void taskAsdpFxn(
     const PAF_AST_Patchs *pQ
 )
 {
+    PAF_AST_Config *pC;             /* Local configuration pointer */
     Int as;                         /* Audio Stream Number (1, 2, etc.) */
     Int z;                          /* input/encode/stream/decode/output counter */
     Int i;                          /* phase */
@@ -133,7 +134,7 @@ Void taskAsdpFxn(
     Int size;
     Int argIdx;
     // Decoder output circular buffer
-    PAF_DecodeOpCircBuf *pCb;
+    PAF_AST_DecOpCircBuf *pCb;
     PAF_AudioFrame *pAfWrt;
     Int cbErrno;    
     // Messaging
@@ -180,14 +181,9 @@ Void taskAsdpFxn(
     TRACE_MSG3("Rx ASP message, procId=%d, cmd=%d, messageId=0x%04x", pAspMsg->procId, pAspMsg->cmd, pAspMsg->messageId);
 
     Cache_inv(&gPAF_AST_config, sizeof(PAF_AST_Config), Cache_Type_ALLD, 0);
-    Cache_inv(&pC, sizeof(PAF_AST_Config *), Cache_Type_ALLD, 0);
+    // FL: no need to share this pointer, can be local
+    //Cache_inv(&pC, sizeof(PAF_AST_Config *), Cache_Type_ALLD, 0);
     Cache_wait();
-    if (!pC)
-    {
-        TRACE_TERSE0("TaskAsdp: No Configuration defined. Exiting.");
-        LINNO_RPRT(TaskAsdp, -1);
-        return;
-    }
     
     // (***) FL: revisit
     // invalidate Dec configuration
@@ -197,9 +193,13 @@ Void taskAsdpFxn(
     // (***) FL: revisit
     Cache_inv((Ptr)(&IACP_STD_BETA_TABLE.pStatus[0]), 512*sizeof(IALG_Status *), Cache_Type_ALLD, 0); // invalidate entire beta table
     Cache_wait();
-
+    
+    //
     // Audio Framework Configuration (*pC):
+    //
+    pC = &gPAF_AST_config;
     as = pC->as; // obtain audio stream number
+    TRACE_TERSE1("TaskAsdp: Started with AS%d.", as);
     
     //
     // Initialize message log trace and line number reporting
@@ -437,7 +437,7 @@ Void taskAsdpFxn(
                     }
 
                     // Start writes to circular buffer
-                    pCb = &pC->xDec[z].decOpCb;
+                    pCb = &pC->xDecOpCb[z];
                     cbErrno = cbWriteStart(pCb);
                     if (cbErrno < 0)
                     {
@@ -606,7 +606,7 @@ Void taskAsdpFxn(
                         //TRACE_TERSE0("Dec:decode done");
                         
                         // copy decoder output to decoder output circular buffers
-                        pCb = &pC->xDec[z].decOpCb;
+                        pCb = &pC->xDecOpCb[z];
                         //TRACE_TERSE1("Dec:pCb=0x%04x", (IArg)pCb);
                         
                         pAfWrt = pC->xDec[z].decodeOutStruct.pAudioFrame;
@@ -674,7 +674,7 @@ Void taskAsdpFxn(
                     }
                     
                     // Stop writes to circular buffer
-                    pCb = &pC->xDec[z].decOpCb;
+                    pCb = &pC->xDecOpCb[z];
                     cbErrno = cbWriteStop(pCb);
                     if (cbErrno < 0)
                     {
index ceb8118fbf7e8c03ff403da52c3d593bb576eeb3..2bbf88696f0a171a6ba0be54f470bc3677de5288 100644 (file)
@@ -78,7 +78,7 @@ extern const SmInt PAF_AST_params_numchan[];
 // Audio Stream Processing Function Table Definition
 //
 
-const PAF_AudioFunctions PAF_AST_params_audioFrameFunctions_Slave =
+const PAF_AudioFunctions PAF_ASDT_params_audioFrameFunctions =
 {
     &PAF_ASP_dB2ToLinear,
     &PAF_ASP_channelMask,
@@ -312,11 +312,11 @@ const PAF_DecodeStatus PAF_AST_params_decodeStatus_primary =
     4,                                                      // sourceKaraoke: both
     0,                                                      // aspGearControl: unused
     0,                                                      // aspGearStatus: unused
-    0, 0, 0, 0,                                                                                                // Unused
-    0, 0, 0, 0,                                                                                                // Unused
-    0, 0, 0, 0,                                                                                                // Unused
-    0, 0, 0, 0,                                                                                                // Unused
-    0, 0, 0, 0,                                                                                                // Unused
+    0, 0, 0, 0,                                                // Unused
+    0, 0, 0, 0,                                                // Unused
+    0, 0, 0, 0,                                                // Unused
+    0, 0, 0, 0,                                                // Unused
+    0, 0, 0, 0,                                                // Unused
     0,                                                      // frameCount
     0x40,                                                   // karaoka: Vocal 1 Level
     0x40,                                                   // karaoka: Vocal 1 Pan
@@ -326,20 +326,20 @@ const PAF_DecodeStatus PAF_AST_params_decodeStatus_primary =
     0x00,                                                   // karaoka: Melody Pan
     0,                                                      // decBypass
     0,                                                      // unused
-       0,                                                                              // frameLength: reset later
-    1,                                                                         // bufferRatio: unity
-    PAF_IEC_PREEMPHASIS_UNKNOWN,                                               // emphasis
-       0,                                                                                                      // bufferDrift
-       0, 0,
-       PAF_CC_SAT_SURROUND4, PAF_CC_SUB_ONE, PAF_CC_AUX_SURROUND4_UNKNOWN, 0, 0, 0, 0, 0,      
+    0,                                                         // frameLength: reset later
+    1,                                                      // bufferRatio: unity
+    PAF_IEC_PREEMPHASIS_UNKNOWN,                            // emphasis
+    0,                                                        // bufferDrift
+    0, 0,
+    PAF_CC_SAT_SURROUND4, PAF_CC_SUB_ONE, PAF_CC_AUX_SURROUND4_UNKNOWN, 0, 0, 0, 0, 0,    
     // channelConfigurationRequest.full
-    PAF_CC_SAT_UNKNOWN, PAF_CC_SUB_ZERO, 0, 0, 0, 0, 0, 0,     
+    PAF_CC_SAT_UNKNOWN, PAF_CC_SUB_ZERO, 0, 0, 0, 0, 0, 0,    
     // channelConfigurationProgram.full
-    PAF_CC_SAT_UNKNOWN, PAF_CC_SUB_ZERO, 0, 0, 0, 0, 0, 0,     
+    PAF_CC_SAT_UNKNOWN, PAF_CC_SUB_ZERO, 0, 0, 0, 0, 0, 0,    
     // channelConfigurationDecode.full
-    PAF_CC_SAT_UNKNOWN, PAF_CC_SUB_ZERO, 0, 0, 0, 0, 0, 0,     
+    PAF_CC_SAT_UNKNOWN, PAF_CC_SUB_ZERO, 0, 0, 0, 0, 0, 0,    
     // channelConfigurationDownmix.full
-    PAF_CC_SAT_UNKNOWN, PAF_CC_SUB_ZERO, 0, 0, 0, 0, 0, 0,     
+    PAF_CC_SAT_UNKNOWN, PAF_CC_SUB_ZERO, 0, 0, 0, 0, 0, 0,    
     // channelConfigurationOverride.full 
     -3,                                                     // channelMap.from[0]
     -3,                                                     // channelMap.from[1]
@@ -417,7 +417,7 @@ const PAF_DecodeStatus PAF_AST_params_decodeStatus_primary =
 // FL: extern this, making it look like shared information between ARM/DSP.
 // FL: Note could just define the same thing in separate file for ARM application (i.e. add "Slave" at end of identifier).
 /* audio frame "width" in channels */
-const PAF_DecodeStatus *const PAF_AST_params_decodeStatus[] =
+const PAF_DecodeStatus *const PAF_ASDT_params_decodeStatus[] =
 {
     &PAF_AST_params_decodeStatus_primary,
 };
@@ -450,21 +450,21 @@ const PAF_EncodeStatus PAF_AST_params_encodeStatus_primary =
     0,                                                      // unused1
     PAF_SAMPLERATE_UNKNOWN,                                 // sampleRate
     0,                                                      // channelCount
-    0, 0, 0, 0,                                                                                                //Unused                                        
-    0, 0, 0, 0,                                                                                                //Unused
-    0, 0, 0, 0,                                                                                        //Unused
-    0, 0, 0, 0,                                                                                                //Unused
-    0, 0, 0, 0,                                                                                        //Unused
+    0, 0, 0, 0,                                                //Unused                                        
+    0, 0, 0, 0,                                                //Unused
+    0, 0, 0, 0,                                             //Unused
+    0, 0, 0, 0,                                                //Unused
+    0, 0, 0, 0,                                             //Unused
     0,                                                      // frameLength
     0,                                                      // encBypass
     PAF_SOURCE_PCM,                                         // select
-       PAF_CC_SAT_SURROUND4, PAF_CC_SUB_ONE, PAF_CC_AUX_SURROUND4_UNKNOWN, 0,0,0,0,0,
+    PAF_CC_SAT_SURROUND4, PAF_CC_SUB_ONE, PAF_CC_AUX_SURROUND4_UNKNOWN, 0,0,0,0,0,
     // channelConfigurationRequest.full
     PAF_CC_SAT_UNKNOWN, PAF_CC_SUB_ZERO, 0, 0,0,0,0,0,
     // channelConfigurationStream.full
     PAF_CC_SAT_UNKNOWN, PAF_CC_SUB_ZERO, 0, 0,0,0,0,0,
     // channelConfigurationEncode.full
-    0, 0, 0, 0,        0, 0, 0, 0,                                                             //Unused
+    0, 0, 0, 0,    0, 0, 0, 0,                                 //Unused
     -3,                                                     // channelMap.from[0]
     -3,                                                     // channelMap.from[1]
     -3,                                                     // channelMap.from[2]
@@ -529,8 +529,8 @@ const PAF_EncodeStatus PAF_AST_params_encodeStatus_primary =
     -3,                                                     // channelMap.to[13]
     -3,                                                     // channelMap.to[14]
     -3,                                                     // channelMap.to[15]
-    0,                                                                         // programFormat.mask
-    0,                                                                         // programFormat.form
+    0,                                                      // programFormat.mask
+    0,                                                      // programFormat.form
     0,                                                      // sampleProcess[0]
 };
 #endif // FL: #if 0
@@ -688,15 +688,15 @@ const IALG_MemRec outMemTabPrimary[] =
 {
     // SDRAM buffer
     // 4 buffers * 256 samples * 32 ch * 4 bytes
-               {
-                       4 * 256 * 32 * 4,                                      // size: note:
-                       //6 * 256 * 32 * 4,                                      // size: note:
-                       //16 * 256 * 32 * 4,                                      // size: note:
-                       128,                                                   // alignment
-                       IALG_EXTERNAL,                                         // space
-                       IALG_PERSIST,                                          // attrs
-                       NULL,                                                  // base
-               }
+        {
+            4 * 256 * 32 * 4,                                      // size: note:
+            //6 * 256 * 32 * 4,                                      // size: note:
+            //16 * 256 * 32 * 4,                                      // size: note:
+            128,                                                   // alignment
+            IALG_EXTERNAL,                                         // space
+            IALG_PERSIST,                                          // attrs
+            NULL,                                                  // base
+        }
 };
 
 
@@ -760,12 +760,12 @@ const PAF_ASP_outNumBufMap outPrimaryNumBufMap =
 
 const PAF_ASP_outNumBufMap *const outNumBufMap[] =
 {
-       &outPrimaryNumBufMap,
+    &outPrimaryNumBufMap,
 };
 #endif // FL: #if 0
 
 // .............................................................................
-const PAF_MetadataBufStatus PAF_AST_params_MetadataBufStatus_Slave[] =
+const PAF_MetadataBufStatus PAF_ASDT_params_MetadataBufStatus[] =
 {
     4 * 1024,               // bufSize
     PAF_MAX_NUM_PRIVATE_MD, // NumBuf
@@ -784,56 +784,56 @@ const PAF_MetadataBufStatus PAF_AST_params_MetadataBufStatus_Slave[] =
 // number of channels only.
 //
 
-const PAF_AudioFrameBufStatus  PAF_AST_params_AudioFrameBufStatus[PAF_MAXNUMCHAN] =
+const PAF_AudioFrameBufStatus    PAF_AST_params_AudioFrameBufStatus[PAF_MAXNUMCHAN] =
 {
-       IALG_SARAM, // 0
-       IALG_SARAM,
-       IALG_SARAM,
-       IALG_SARAM,
-       IALG_SARAM,
-       IALG_SARAM,
-       IALG_SARAM,
-       IALG_SARAM,
-       IALG_SARAM,
-       IALG_SARAM,
-       IALG_SARAM,
-       IALG_SARAM,
-       IALG_SARAM,
-       IALG_SARAM,
-       IALG_SARAM,
-       IALG_SARAM,
-       IALG_SARAM, // 16
-       IALG_SARAM,
-       IALG_SARAM,
-       IALG_SARAM,
-       IALG_SARAM,
-       IALG_SARAM,
-       IALG_SARAM,
-       IALG_SARAM,
-       IALG_SARAM,
-       IALG_SARAM,
-       IALG_SARAM,
-       IALG_SARAM,
-       IALG_SARAM,
-       IALG_SARAM,
-       IALG_SARAM,
-       IALG_SARAM, // 31
-       //IALG_EXTERNAL, // 16
-       //IALG_EXTERNAL,
-       //IALG_EXTERNAL,
-       //IALG_EXTERNAL,
-       //IALG_EXTERNAL,
-       //IALG_EXTERNAL,
-       //IALG_EXTERNAL,
-       //IALG_EXTERNAL,
-       //IALG_EXTERNAL,
-       //IALG_EXTERNAL,
-       //IALG_EXTERNAL,
-       //IALG_EXTERNAL,
-       //IALG_EXTERNAL,
-       //IALG_EXTERNAL,
-       //IALG_EXTERNAL,
-       //IALG_EXTERNAL // 31
+    IALG_SARAM, // 0
+    IALG_SARAM,
+    IALG_SARAM,
+    IALG_SARAM,
+    IALG_SARAM,
+    IALG_SARAM,
+    IALG_SARAM,
+    IALG_SARAM,
+    IALG_SARAM,
+    IALG_SARAM,
+    IALG_SARAM,
+    IALG_SARAM,
+    IALG_SARAM,
+    IALG_SARAM,
+    IALG_SARAM,
+    IALG_SARAM,
+    IALG_SARAM, // 16
+    IALG_SARAM,
+    IALG_SARAM,
+    IALG_SARAM,
+    IALG_SARAM,
+    IALG_SARAM,
+    IALG_SARAM,
+    IALG_SARAM,
+    IALG_SARAM,
+    IALG_SARAM,
+    IALG_SARAM,
+    IALG_SARAM,
+    IALG_SARAM,
+    IALG_SARAM,
+    IALG_SARAM,
+    IALG_SARAM, // 31
+    //IALG_EXTERNAL, // 16
+    //IALG_EXTERNAL,
+    //IALG_EXTERNAL,
+    //IALG_EXTERNAL,
+    //IALG_EXTERNAL,
+    //IALG_EXTERNAL,
+    //IALG_EXTERNAL,
+    //IALG_EXTERNAL,
+    //IALG_EXTERNAL,
+    //IALG_EXTERNAL,
+    //IALG_EXTERNAL,
+    //IALG_EXTERNAL,
+    //IALG_EXTERNAL,
+    //IALG_EXTERNAL,
+    //IALG_EXTERNAL,
+    //IALG_EXTERNAL // 31
 };
 #endif // FL: #if 0
 
@@ -883,10 +883,10 @@ const PAF_AST_Params asdp_params_PAi =
     NULL,                                                   // z_tx_bufsiz
     PAF_AST_params_numchan,                                 // z_numchan
     256,                                                    // framelength
-    &PAF_AST_params_audioFrameFunctions_Slave,              // pAudioFrameFunctions
+    &PAF_ASDT_params_audioFrameFunctions,                   // pAudioFrameFunctions
     &PAF_ASP_chainFxns,                                     // pChainFxns
     NULL, //&PAF_AST_params_inpBufStatus,                           // pInpBufStatus
-    PAF_AST_params_decodeStatus,                            // z_pDecodeStatus
+    PAF_ASDT_params_decodeStatus,                           // z_pDecodeStatus
     NULL, //&PAF_AST_params_outBufStatus,                           // pOutBufStatus
     NULL, //PAF_AST_params_encodeStatus,                            // z_pEncodeStatus
     NULL, //&PAF_AST_params_volumeStatus,                           // pVolumeStatus
@@ -900,7 +900,7 @@ const PAF_AST_Params asdp_params_PAi =
     NULL, //inpLinkInit,                                            // i_inpLinkInit
     NULL, //outLinkInit,                                            // i_outLinkInit
     NULL, //outNumBufMap,                                           // outNumBufMap // FL: poutNumBufMap
-    PAF_AST_params_MetadataBufStatus_Slave,                 //metadata buffer status
+    PAF_ASDT_params_MetadataBufStatus,                      //metadata buffer status
     NULL, //PAF_AST_params_AudioFrameBufStatus                      //Audio frame buffer status
 };
 
index e59942cf1909949c8943a324613b562b32040228..8bcf66445d86affa2397391df661422cfd8a5fc1 100644 (file)
@@ -317,7 +317,7 @@ Void taskAsipFxn(
 {
     // Task data
     //PAF_AST_Config PAF_AST_config;  /* Local configuration */
-    //PAF_AST_Config *pC;             /* Local configuration pointer */
+    PAF_AST_Config *pC;             /* Local configuration pointer */
     // Local data
     Int as;                         /* Audio Stream Number (1, 2, etc.) */
     Int z;                          /* input/encode/stream/decode/output counter */
@@ -338,32 +338,31 @@ Void taskAsipFxn(
     simStart();
 #endif // SIMULATE_SIO
 
-    //
-    // Audio Framework Configuration (*pC):
-    //
-    pC = &gPAF_AST_config;
-
-    TRACE_TERSE1("TaskAsip: Started with betaPrimeValue=%d.", gBetaPrimeValue);
-    as = gBetaPrimeValue + 1;        /* Audio Stream Number (1, 2, etc.) */    
-    pC->as = as;    
-
     //
     // Audio Framework Parameters & Patch (*pP, *pQ)
     //
     if (!pP) 
     {
-        TRACE_TERSE1("TaskAsip: AS%d: No Parameters defined. Exiting.", as);
+        TRACE_TERSE0("TaskAsip: No Parameters defined. Exiting.");
         LINNO_RPRT(TaskAsip, -1);
         return;
     }
 
     if (!pQ)
     {
-        TRACE_TERSE1("TaskAsip: AS%d: No Patchs defined. Exiting.", as);
+        TRACE_TERSE0("TaskAsip: No Patchs defined. Exiting.");
         LINNO_RPRT(TaskAsip, -1);
         return;
     }    
     
+    //
+    // Audio Framework Configuration (*pC):
+    //
+    pC = &gPAF_AST_config;
+    as = gBetaPrimeValue + 1;        /* Audio Stream Number (1, 2, etc.) */    
+    pC->as = as;    
+    TRACE_TERSE1("TaskAsip: Started with AS%d.", as);
+
     //
     // Initialize message log trace and line number reporting
     //
@@ -434,7 +433,8 @@ Void taskAsipFxn(
     // (***) FL: revisit
     // write back configuration
     Cache_wb(&gPAF_AST_config, sizeof(PAF_AST_Config), Cache_Type_ALLD, 0);
-    Cache_wb(&pC, sizeof(PAF_AST_Config *), Cache_Type_ALLD, 0);
+    // FL: no need to share this pointer, can be local
+    //Cache_wb(&pC, sizeof(PAF_AST_Config *), Cache_Type_ALLD, 0);
     Cache_wait();
 
     // (***) FL: revisit
@@ -871,69 +871,29 @@ PAF_ASIT_initPhaseMalloc(
     Error_init(&eb); 
 
     /* Input memory */
-    if (!(pC->xInp = Memory_calloc((IHeap_Handle)HEAP_INTERNAL1_SHM, INPUTN * sizeof (*pC->xInp), 4, &eb)))
+    if (!(pC->xInp = Memory_calloc((IHeap_Handle)HEAP_INTERNAL1_SHM, 
+        INPUTN * sizeof (*pC->xInp), 4, &eb)))
     {
         TRACE_TERSE1("PAF_ASIT_initPhaseMalloc: AS%d: Memory_calloc failed", as+zMS);
         SW_BREAKPOINT;
         return __LINE__;
     }
     TRACE_TERSE3("PAF_ASIT_initPhaseMalloc. (pC->xInp) %d bytes from space %d at 0x%x.",
-            INPUTN * sizeof (*pC->xInp),
-            HEAP_ID_INTERNAL1_SHM, (IArg)pC->xInp);
+        INPUTN * sizeof (*pC->xInp),
+        HEAP_ID_INTERNAL1_SHM, (IArg)pC->xInp);
 
     /* Decode memory */
-    if (!(pC->xDec = Memory_calloc((IHeap_Handle)HEAP_INTERNAL1_SHM, DECODEN * sizeof (*pC->xDec), 4, &eb)))
+    if (!(pC->xDec = Memory_calloc((IHeap_Handle)HEAP_INTERNAL1_SHM, 
+        DECODEN * sizeof (*pC->xDec), 4, &eb)))
     {
         TRACE_TERSE1("PAF_ASIT_initPhaseMalloc: AS%d: Memory_calloc failed", as+zMS);
         SW_BREAKPOINT;
         return __LINE__;
     }
     TRACE_TERSE3("PAF_ASIT_initPhaseMalloc. (pC->xDec) %d bytes from space %d at 0x%x.",
-            DECODEN * sizeof (*pC->xDec),
-            HEAP_ID_INTERNAL1_SHM, (IArg)pC->xDec);
-            
-    {   
-        // FL: added for decode output circular buffer
-        // FL: (***)revisit
-        Int z; /* decode counter */
-        
-        for (z=DECODE1; z < DECODEN; z++)
-        {
-            // allocate audio frame circular buffer
-            if (!(pC->xDec[z].decOpCb.afCb = Memory_calloc((IHeap_Handle)HEAP_INTERNAL1_SHM, PAF_DECOP_CB_MAX_NUM_AF * sizeof(PAF_AudioFrame), 4, &eb)))
-            {
-                TRACE_TERSE1("PAF_ASIT_initPhaseMalloc: AS%d: Memory_calloc failed", as+zMS);
-                SW_BREAKPOINT;
-            }
-            // allocate audio frame PCM sample pointer array
-            for (i = 0; i<PAF_DECOP_CB_MAX_NUM_AF; i++)
-            {
-                if (!(pC->xDec[z].decOpCb.afCb[i].data.sample = Memory_calloc((IHeap_Handle)HEAP_INTERNAL1_SHM, PAF_DECOP_CB_MAX_NUM_PCM_CH * sizeof(PAF_AudioData *), 4, &eb)))
-                {
-                    TRACE_TERSE1("PAF_ASIT_initPhaseMalloc: AS%d: Memory_calloc failed", as+zMS);
-                    SW_BREAKPOINT;
-                }
-                if (!(pC->xDec[z].decOpCb.afCb[i].data.samsiz = Memory_calloc((IHeap_Handle)HEAP_INTERNAL1_SHM, PAF_DECOP_CB_MAX_NUM_PCM_CH * sizeof(PAF_AudioSize), 4, &eb)))
-                {
-                    TRACE_TERSE1("PAF_ASIT_initPhaseMalloc: AS%d: Memory_calloc failed", as+zMS);
-                    SW_BREAKPOINT;
-                }                
-            }
-            // allocate PCM sample buffer
-            if (!(pC->xDec[z].decOpCb.pcmBuf = Memory_calloc((IHeap_Handle)HEAP_INTERNAL1_SHM, PAF_DECOP_CB_PCM_BUF_SZ * sizeof(PAF_AudioData), 4, &eb)))
-            {
-                TRACE_TERSE1("PAF_ASIT_initPhaseMalloc: AS%d: Memory_calloc failed", as+zMS);
-                SW_BREAKPOINT;
-            }
-            // allocate Metadata buffers //QIN
-            if (!(pC->xDec[z].decOpCb.metaBuf = Memory_calloc((IHeap_Handle)HEAP_INTERNAL1_SHM, PAF_DECOP_CB_MAX_NUM_AF * PAF_MAX_PRIVATE_MD_SZ * PAF_MAX_NUM_PRIVATE_MD * sizeof(Int8), 4, &eb)))
-            {
-                TRACE_TERSE1("PAF_ASIT_initPhaseMalloc: AS%d: Memory_calloc failed", as+zMS);
-                SW_BREAKPOINT;
-            }
-        }
-    }
-    
+        DECODEN * sizeof (*pC->xDec),
+        HEAP_ID_INTERNAL1_SHM, (IArg)pC->xDec);
+                
     TRACE_TERSE1("PAF_ASIT_initPhaseMalloc: AS%d: initialization phase - memory allocation complete.", as+zMS);
     return 0;
 } //PAF_ASIT_initPhaseMalloc
@@ -963,7 +923,6 @@ PAF_ASIT_initPhaseConfig(
     Int z;                              /* input/encode/stream/decode/output counter */
     Int zMS = pC->masterStr;
     Int errno;                          /* error number */
-    PAF_DecodeOpCircBuf *pCb;           /* Decoder output circular buffer */
 
     TRACE_TERSE1("PAF_ASIT_initPhaseConfig: AS%d: initialization phase - configuration", as+zMS);
 
@@ -983,18 +942,6 @@ PAF_ASIT_initPhaseConfig(
         pC->xDec[z].decodeControl.size = sizeof(pC->xDec[z].decodeControl);
         pC->xDec[z].decodeControl.pInpBufConfig = (const PAF_InpBufConfig *)&pC->xInp[zI].inpBufConfig;
         //pC->xDec[z].decodeStatus = *pP->z_pDecodeStatus[z]; // FL: slave
-
-        // Initialize decoder output circular buffer for PCM
-        // (***) FL: revisit, here PCM is hard-coded for 256 sample dec op frame length        
-        pCb = &pC->xDec[z].decOpCb;
-        errno = cbInit(PAF_SOURCE_PCM, 256, FRAMELENGTH, pCb, 1);
-        if (errno)
-        {
-            SW_BREAKPOINT; // FL: debug
-            return errno;
-        }
-        // FL: debug
-        cbLog(pCb, 1, "PAF_ASIT_initPhaseConfig:cbInit");
     }
 
     TRACE_TERSE1("PAF_ASIT_initPhaseConfig: AS%d: initialization phase - configuration complete.", as+zMS);
@@ -1413,6 +1360,102 @@ PAF_ASIT_initPhaseDevice(
     return 0;
 } //PAF_ASIT_initPhaseDevice
 
+// -----------------------------------------------------------------------------
+// ASIT Initialization Function - Decoder Output Circular Buffer
+//
+//   Name:      PAF_ASIT_initPhaseDecOpCircBuf
+//   Purpose:   Audio Stream Input Task Function for initialization of Decoder Output Circular Buffer.
+//   From:      audioStream1Task or equivalent
+//   Uses:      See code.
+//   States:    x
+//   Return:    0 on success.
+//              Source code line number on device allocation failure.
+//   Trace:     Message Log "trace" in Debug Project Configuration reports:
+//              * State information as per parent.
+//              * Memory allocation errors.
+//
+Int
+PAF_ASIT_initPhaseDecOpCircBuf(
+    const PAF_AST_Params *pP, 
+    const PAF_AST_Patchs *pQ, 
+    PAF_AST_Config *pC
+)
+{
+    Int as = pC->as;                    /* Audio Stream Number (1, 2, etc.) */
+    Int zMS = pC->masterStr;
+    Int z; /* decode counter */
+    PAF_AST_DecOpCircBuf *pCb;          /* Decoder output circular buffer */
+    Int errno;                          /* error number */
+    Error_Block    eb;
+    Int i;
+
+    // FL: (***)revisit
+    
+    /* Decode output circular buffer memory */
+    if (!(pC->xDecOpCb = Memory_calloc((IHeap_Handle)HEAP_INTERNAL1_SHM, 
+        DECODEN * sizeof (*pC->xDecOpCb), 4, &eb)))
+    {
+        TRACE_TERSE1("PAF_ASIT_initPhaseDecOpCircBuf: AS%d: Memory_calloc failed", as+zMS);
+        SW_BREAKPOINT;
+        return __LINE__;
+    }
+    TRACE_TERSE3("PAF_ASIT_initPhaseDecOpCircBuf. (pC->xDecOpCb) %d bytes from space %d at 0x%x.",
+        DECODEN * sizeof (*pC->xDecOpCb),
+        HEAP_ID_INTERNAL1_SHM, (IArg)pC->xDecOpCb);
+        
+    for (z=DECODE1; z < DECODEN; z++)
+    {
+        pCb = &pC->xDecOpCb[z];
+        
+        // allocate audio frame circular buffer
+        if (!(pCb->afCb = Memory_calloc((IHeap_Handle)HEAP_INTERNAL1_SHM, PAF_DECOP_CB_MAX_NUM_AF * sizeof(PAF_AudioFrame), 4, &eb)))
+        {
+            TRACE_TERSE1("PAF_ASIT_initPhaseDecOpCircBuf: AS%d: Memory_calloc failed", as+zMS);
+            SW_BREAKPOINT;
+        }
+        // allocate audio frame PCM sample pointer array
+        for (i = 0; i<PAF_DECOP_CB_MAX_NUM_AF; i++)
+        {
+            if (!(pCb->afCb[i].data.sample = Memory_calloc((IHeap_Handle)HEAP_INTERNAL1_SHM, PAF_DECOP_CB_MAX_NUM_PCM_CH * sizeof(PAF_AudioData *), 4, &eb)))
+            {
+                TRACE_TERSE1("PAF_ASIT_initPhaseDecOpCircBuf: AS%d: Memory_calloc failed", as+zMS);
+                SW_BREAKPOINT;
+            }
+            if (!(pCb->afCb[i].data.samsiz = Memory_calloc((IHeap_Handle)HEAP_INTERNAL1_SHM, PAF_DECOP_CB_MAX_NUM_PCM_CH * sizeof(PAF_AudioSize), 4, &eb)))
+            {
+                TRACE_TERSE1("PAF_ASIT_initPhaseDecOpCircBuf: AS%d: Memory_calloc failed", as+zMS);
+                SW_BREAKPOINT;
+            }                
+        }
+        // allocate PCM sample buffer
+        if (!(pCb->pcmBuf = Memory_calloc((IHeap_Handle)HEAP_INTERNAL1_SHM, PAF_DECOP_CB_PCM_BUF_SZ * sizeof(PAF_AudioData), 4, &eb)))
+        {
+            TRACE_TERSE1("PAF_ASIT_initPhaseDecOpCircBuf: AS%d: Memory_calloc failed", as+zMS);
+            SW_BREAKPOINT;
+        }
+        // allocate Metadata buffers //QIN
+        if (!(pCb->metaBuf = Memory_calloc((IHeap_Handle)HEAP_INTERNAL1_SHM, PAF_DECOP_CB_MAX_NUM_AF * PAF_MAX_PRIVATE_MD_SZ * PAF_MAX_NUM_PRIVATE_MD * sizeof(Int8), 4, &eb)))
+        {
+            TRACE_TERSE1("PAF_ASIT_initPhaseDecOpCircBuf: AS%d: Memory_calloc failed", as+zMS);
+            SW_BREAKPOINT;
+        }
+        
+        // (***) 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);
+        if (errno)
+        {
+            SW_BREAKPOINT; // FL: debug
+            return errno;
+        }
+        // FL: debug
+        cbLog(pCb, 1, "PAF_ASIT_initPhaseDecOpCircBuf:cbInit");        
+    }
+
+    return 0;
+} //PAF_ASIT_initPhaseDecOpCircBuf
+
+
 #if 0
 // -----------------------------------------------------------------------------
 // AST Processing Function - Pass-Through Processing
@@ -2233,7 +2276,7 @@ PAF_ASIT_decodeInit(
     Int argIdx;
     Int decErrno;
     Int status;
-    PAF_DecodeOpCircBuf *pCb;           /* Decoder output circular buffer */
+    PAF_AST_DecOpCircBuf *pCb;         /* Decoder output circular buffer */
     
     (void)as;  // clear compiler warning in case not used with tracing disabled
 
@@ -2420,7 +2463,7 @@ PAF_ASIT_decodeInit(
             //pC->xDec[z].decodeControl.rdSampleCount = 0;
 
             // Initialize decoder output circular buffer for selected source
-            pCb = &pC->xDec[z].decOpCb;
+            pCb = &pC->xDecOpCb[z];
             errno = cbInit(sourceSelect, frameLength, FRAMELENGTH, pCb, 0);
             if (errno)
             {
@@ -3164,7 +3207,7 @@ PAF_ASIT_decodeComplete(
     Int argIdx;
     Int errno;                           /* error number */
     Int status;
-    PAF_DecodeOpCircBuf *pCb; // FL: decoder output circular buffer
+    PAF_AST_DecOpCircBuf *pCb;           /* decoder output circular buffer */
 
     (void)as;  // clear compiler warning in case not used with tracing disabled
 
@@ -3233,17 +3276,7 @@ PAF_ASIT_decodeComplete(
 #if 0 // FL: decoder deactivate call, slave
             if (decAlg[z]->fxns->algDeactivate)
                 decAlg[z]->fxns->algDeactivate (decAlg[z]);
-#endif
-
-#if 0
-            // Stop decoder output circular buffer writes
-            pCb = &pC->xDec[z].decOpCb;
-            errno = cbWriteStop(pCb);
-            if (errno)
-            {
-                return errno;
-            }
-#endif            
+#endif    
         }
         else 
         {
index 3f50e57a4da70cb1e9ddbab8a27516a2d5399e28..cf9bfa36ac363f92874d0d36e26c2e7709c0b5d4 100644 (file)
@@ -104,6 +104,14 @@ PAF_ASIT_initPhaseAlgKey(
     PAF_AST_Config *pC
 );
 
+//   Purpose:   Audio Stream Input Task Function for initialization of Decoder Output Circular Buffer.
+Int
+PAF_ASIT_initPhaseDecOpCircBuf(
+    const PAF_AST_Params *pP, 
+    const PAF_AST_Patchs *pQ, 
+    PAF_AST_Config *pC
+);
+
 //   Purpose:   Audio Stream Input Task Function for initialization of Input Devices.
 Int
 PAF_ASIT_initPhaseDevice(
index 48035642b105644086372923d5e8b22a49e7bbf8..8e64b48e5ba4fbb83934dadfd058b136ab1b5e3f 100644 (file)
@@ -62,7 +62,7 @@ const PAF_AST_Fxns PAF_ASIT_params_fxns =
         PAF_ASIT_initPhaseCommon,
         PAF_ASIT_initPhaseAlgKey,
         PAF_ASIT_initPhaseDevice,
-        NULL,
+        PAF_ASIT_initPhaseDecOpCircBuf,
         NULL
     },
     NULL, //PAF_AST_initFrame0,             // initFrame0
index 30228251423eb2865377898a9e3c25ec6c1c7322..c883b1caf663398d5bf6ab2d105919e68c2cd6d2 100644 (file)
@@ -130,6 +130,7 @@ Void taskAsopFxn(
     const PAF_AST_Patchs *pQ
 )
 {
+    PAF_AST_Config *pC;             /* Local configuration pointer */
     Int as;                         /* Audio Stream Number (1, 2, etc.) */
     Int z;                          /* input/encode/stream/decode/output counter */
     Int i;                          /* phase */
@@ -139,31 +140,30 @@ Void taskAsopFxn(
 
     Log_info0("Enter taskAsopFxn()");    
 
-    //
-    // Audio Framework Configuration (*pC):
-    //
-    pC = &gPAF_AST_config;
-
-    TRACE_TERSE1("TaskAsop: Started with betaPrimeValue=%d.", gBetaPrimeValue);
-    as = pC->as;        /* Audio Stream Number (1, 2, etc.) */    
-
     //
     // Audio Framework Parameters & Patch (*pP, *pQ)
     //
     if (!pP) 
     {
-        TRACE_TERSE1("TaskAsop: AS%d: No Parameters defined. Exiting.", as);
+        TRACE_TERSE0("TaskAsop: No Parameters defined. Exiting.");
         LINNO_RPRT(TaskAsop, -1);
         return;
     }
 
     if (!pQ)
     {
-        TRACE_TERSE1("TaskAsip: AS%d: No Patchs defined. Exiting.", as);
+        TRACE_TERSE0("TaskAsip: No Patchs defined. Exiting.");
         LINNO_RPRT(TaskAsop, -1);
         return;
     }    
 
+    //
+    // Audio Framework Configuration (*pC):
+    //
+    pC = &gPAF_AST_config;
+    as = pC->as;        /* Audio Stream Number (1, 2, etc.) */    
+    TRACE_TERSE1("TaskAsop: Started with AS%d.", as);
+
     //
     // Initialize message log trace and line number reporting
     //
@@ -1576,12 +1576,12 @@ PAF_ASOT_decodeInit(
     Int z;                              /* decode/encode counter */
     Int errno;                          /* error number */
     Int zO, zS;
-    PAF_DecodeOpCircBuf *pCb;           /* decoder output circular buffer */
+    PAF_AST_DecOpCircBuf *pCb;          /* decoder output circular buffer */
 
     for (z=DECODE1; z < DECODEN; z++)
     {
         // Start decoder output circular buffer reads
-        pCb = &pC->xDec[z].decOpCb;
+        pCb = &pC->xDecOpCb[z];
         errno = cbReadStart(pCb);
         if (errno)
         {
@@ -1757,7 +1757,7 @@ PAF_ASOT_decodeStream(
 )
 {
     Int z;                              /* decode/stream counter */
-    PAF_DecodeOpCircBuf *pCb;
+    PAF_AST_DecOpCircBuf *pCb;          /* decoder output circular buffer */
     PAF_AudioFrame *pAfRd;
     Int cbErrno;
     Int errno;
@@ -1769,7 +1769,7 @@ PAF_ASOT_decodeStream(
         //
         // (***) FL: read circular buffer
         //
-        pCb = &pC->xDec[z].decOpCb;
+        pCb = &pC->xDecOpCb[z];
         pAfRd = pC->xStr[zS].pAudioFrame;
         cbErrno = cbReadAf(pCb, pAfRd);
         if (cbErrno != 0)
@@ -2028,14 +2028,14 @@ PAF_ASOT_decodeComplete(
     Int as  = pC->as;                   /* Audio Stream Number (1, 2, etc.) */
     Int z;                              /* decode/encode counter */
     Int errno;                          /* error number */
-    PAF_DecodeOpCircBuf *pCb;           /* decoder output circular buffer */
+    PAF_AST_DecOpCircBuf *pCb;          /* decoder output circular buffer */
 
     (void)as;  // clear compiler warning in case not used with tracing disabled
 
     for (z=DECODE1; z < DECODEN; z++)
     {
         // Stop decoder output circular buffer reads
-        pCb = &pC->xDec[z].decOpCb;
+        pCb = &pC->xDecOpCb[z];
         errno = cbReadStop(pCb);
         if (errno)
         {