PASDK-633:Add code to process pending ack messages on decode complete
authorFrank Livingston <frank-livingston@ti.com>
Fri, 27 Apr 2018 21:30:47 +0000 (16:30 -0500)
committerFrank Livingston <frank-livingston@ti.com>
Fri, 27 Apr 2018 21:30:47 +0000 (16:30 -0500)
ASIT was losing messaging sync in decode compelte (decDecodeComplete()
because of pending IPC MessageQ ACK messages (e.g. stream terminated
before EOS). Added code to process any such pending ACK messages.

pasdk/shared/config.bld
pasdk/test_dsp/.cproject
pasdk/test_dsp/framework/aspMsg_master.c
pasdk/test_dsp/framework/aspMsg_master.h
pasdk/test_dsp/framework/audioStreamInpDec.c
pasdk/test_dsp/framework/audioStreamInpProc.h

index db86d62c46eed44dbeee399a67d153d25f6d1540..c206cadaf8224f4d59bc90c7924d42c1efebb6a9 100644 (file)
@@ -128,10 +128,10 @@ Build.platformTable["ti.platforms.evmTCI66AK2G02:host"] = {
 Build.platformTable["ti.platforms.evmTCI66AK2G02:core0"] = {
     customMemoryMap: [
         ["L2SRAM", {
-            comment:    "1MB L2 SRAM/CACHE",
+            comment:    "768 MB L2 SRAM/CACHE",
             name:       "L2SRAM",
             base:       0x00800000,
-            len:        0x00100000,
+            len:        0x000C0000,
             space:      "code/data",
             access:     "RWX"
         }],
index eb061dcd845d705bc9c7fdf82379b2a0e7d1ebbb..4c0e34540bfe308e6e43a4655446e00e2010f22b 100644 (file)
                                                                <option id="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.STACK_SIZE.1423564318" name="Set C system stack size (--stack_size, -stack)" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.STACK_SIZE" value="0x800" valueType="string"/>
                                                                <option id="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.HEAP_SIZE.1585410811" name="Heap size for C/C++ dynamic memory allocation (--heap_size, -heap)" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.HEAP_SIZE" value="0x800" valueType="string"/>
                                                                <option id="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.MAP_FILE.1259978399" name="Link information (map) listed into &lt;file&gt; (--map_file, -m)" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.MAP_FILE" value="&quot;${ProjName}.map&quot;" valueType="string"/>
-                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.OUTPUT_FILE.1931504909" name="Specify output file name (--output_file, -o)" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.OUTPUT_FILE" value="&quot;${ProjName}.out&quot;" valueType="string"/>
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.OUTPUT_FILE.1931504909" name="Specify output file name (--output_file, -o)" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.OUTPUT_FILE" useByScannerDiscovery="false" value="${ProjName}.out" valueType="string"/>
                                                                <option id="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.LIBRARY.1441647372" name="Include library file or command file as input (--library, -l)" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.LIBRARY" valueType="libs">
                                                                        <listOptionValue builtIn="false" value="${COM_TI_UIA_LIBRARIES}"/>
                                                                        <listOptionValue builtIn="false" value="${BIOS_LIBRARIES}"/>
                                                                <option id="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.STACK_SIZE.611971956" name="Set C system stack size (--stack_size, -stack)" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.STACK_SIZE" value="0x800" valueType="string"/>
                                                                <option id="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.HEAP_SIZE.2131291138" name="Heap size for C/C++ dynamic memory allocation (--heap_size, -heap)" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.HEAP_SIZE" value="0x800" valueType="string"/>
                                                                <option id="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.MAP_FILE.407812709" name="Link information (map) listed into &lt;file&gt; (--map_file, -m)" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.MAP_FILE" value="&quot;${ProjName}.map&quot;" valueType="string"/>
-                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.OUTPUT_FILE.970931644" name="Specify output file name (--output_file, -o)" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.OUTPUT_FILE" value="&quot;${ProjName}.out&quot;" valueType="string"/>
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.OUTPUT_FILE.970931644" name="Specify output file name (--output_file, -o)" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.OUTPUT_FILE" useByScannerDiscovery="false" value="${ProjName}.out" valueType="string"/>
                                                                <option id="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.LIBRARY.1387803818" name="Include library file or command file as input (--library, -l)" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.LIBRARY" valueType="libs">
                                                                        <listOptionValue builtIn="false" value="${TI_PDK_LIBRARIES}"/>
                                                                        <listOptionValue builtIn="false" value="${COM_TI_UIA_LIBRARIES}"/>
                                                                <option id="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.STACK_SIZE.844480008" name="Set C system stack size (--stack_size, -stack)" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.STACK_SIZE" value="0x800" valueType="string"/>
                                                                <option id="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.HEAP_SIZE.17237602" name="Heap size for C/C++ dynamic memory allocation (--heap_size, -heap)" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.HEAP_SIZE" value="0x800" valueType="string"/>
                                                                <option id="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.MAP_FILE.1971283486" name="Link information (map) listed into &lt;file&gt; (--map_file, -m)" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.MAP_FILE" value="&quot;${ProjName}.map&quot;" valueType="string"/>
-                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.OUTPUT_FILE.1233003978" name="Specify output file name (--output_file, -o)" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.OUTPUT_FILE" value="&quot;${ProjName}.out&quot;" valueType="string"/>
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.OUTPUT_FILE.1233003978" name="Specify output file name (--output_file, -o)" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.OUTPUT_FILE" useByScannerDiscovery="false" value="${ProjName}.out" valueType="string"/>
                                                                <option id="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.LIBRARY.665379411" name="Include library file or command file as input (--library, -l)" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.LIBRARY" valueType="libs">
                                                                        <listOptionValue builtIn="false" value="${TI_PDK_LIBRARIES}"/>
                                                                        <listOptionValue builtIn="false" value="${COM_TI_UIA_LIBRARIES}"/>
                                                                <option id="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.STACK_SIZE.134367375" name="Set C system stack size (--stack_size, -stack)" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.STACK_SIZE" value="0x800" valueType="string"/>
                                                                <option id="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.HEAP_SIZE.342276831" name="Heap size for C/C++ dynamic memory allocation (--heap_size, -heap)" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.HEAP_SIZE" value="0x800" valueType="string"/>
                                                                <option id="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.MAP_FILE.903050085" name="Link information (map) listed into &lt;file&gt; (--map_file, -m)" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.MAP_FILE" value="&quot;${ProjName}.map&quot;" valueType="string"/>
-                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.OUTPUT_FILE.896884643" name="Specify output file name (--output_file, -o)" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.OUTPUT_FILE" value="&quot;${ProjName}.out&quot;" valueType="string"/>
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.OUTPUT_FILE.896884643" name="Specify output file name (--output_file, -o)" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.OUTPUT_FILE" useByScannerDiscovery="false" value="${ProjName}.out" valueType="string"/>
                                                                <option id="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.LIBRARY.1863202587" name="Include library file or command file as input (--library, -l)" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.LIBRARY" valueType="libs">
                                                                        <listOptionValue builtIn="false" value="${COM_TI_UIA_LIBRARIES}"/>
                                                                        <listOptionValue builtIn="false" value="${BIOS_LIBRARIES}"/>
                                                                <option id="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.STACK_SIZE.1691501922" name="Set C system stack size (--stack_size, -stack)" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.STACK_SIZE" value="0x800" valueType="string"/>
                                                                <option id="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.HEAP_SIZE.1660816124" name="Heap size for C/C++ dynamic memory allocation (--heap_size, -heap)" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.HEAP_SIZE" value="0x800" valueType="string"/>
                                                                <option id="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.MAP_FILE.1796595326" name="Link information (map) listed into &lt;file&gt; (--map_file, -m)" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.MAP_FILE" value="&quot;${ProjName}.map&quot;" valueType="string"/>
-                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.OUTPUT_FILE.877443255" name="Specify output file name (--output_file, -o)" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.OUTPUT_FILE" value="&quot;${ProjName}.out&quot;" valueType="string"/>
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.OUTPUT_FILE.877443255" name="Specify output file name (--output_file, -o)" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.OUTPUT_FILE" useByScannerDiscovery="false" value="${ProjName}.out" valueType="string"/>
                                                                <option id="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.LIBRARY.1194060942" name="Include library file or command file as input (--library, -l)" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.LIBRARY" valueType="libs">
                                                                        <listOptionValue builtIn="false" value="${TI_PDK_LIBRARIES}"/>
                                                                        <listOptionValue builtIn="false" value="${COM_TI_UIA_LIBRARIES}"/>
                                                                <option id="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.STACK_SIZE.825686519" name="Set C system stack size (--stack_size, -stack)" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.STACK_SIZE" value="0x800" valueType="string"/>
                                                                <option id="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.HEAP_SIZE.1367598920" name="Heap size for C/C++ dynamic memory allocation (--heap_size, -heap)" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.HEAP_SIZE" value="0x800" valueType="string"/>
                                                                <option id="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.MAP_FILE.373784443" name="Link information (map) listed into &lt;file&gt; (--map_file, -m)" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.MAP_FILE" value="&quot;${ProjName}.map&quot;" valueType="string"/>
-                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.OUTPUT_FILE.970982752" name="Specify output file name (--output_file, -o)" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.OUTPUT_FILE" value="&quot;${ProjName}.out&quot;" valueType="string"/>
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.OUTPUT_FILE.970982752" name="Specify output file name (--output_file, -o)" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.OUTPUT_FILE" useByScannerDiscovery="false" value="${ProjName}.out" valueType="string"/>
                                                                <option id="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.LIBRARY.1369280818" name="Include library file or command file as input (--library, -l)" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.LIBRARY" valueType="libs">
                                                                        <listOptionValue builtIn="false" value="${TI_PDK_LIBRARIES}"/>
                                                                        <listOptionValue builtIn="false" value="${COM_TI_UIA_LIBRARIES}"/>
                                                                </option>
                                                                <option id="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.STACK_SIZE.1257774453" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.STACK_SIZE" value="0x800" valueType="string"/>
                                                                <option id="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.HEAP_SIZE.2087952217" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.HEAP_SIZE" value="0x800" valueType="string"/>
-                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.OUTPUT_FILE.718963225" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.OUTPUT_FILE" value="&quot;${ProjName}.out&quot;" valueType="string"/>
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.OUTPUT_FILE.718963225" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.OUTPUT_FILE" useByScannerDiscovery="false" value="${ProjName}.out" valueType="string"/>
                                                                <option id="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.MAP_FILE.841763545" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.MAP_FILE" value="&quot;${ProjName}.map&quot;" valueType="string"/>
                                                                <option id="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.LIBRARY.862860158" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.2.linkerID.LIBRARY" valueType="libs">
                                                                        <listOptionValue builtIn="false" value="${EDMA3_LLD_LIBRARIES}"/>
                                                <toolChain id="com.ti.ccstudio.buildDefinitions.C6000_8.2.exe.DebugToolchain.1501133916" name="TI Build Tools" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.2.exe.DebugToolchain" unusedChildren="">
                                                        <option id="com.ti.ccstudio.buildDefinitions.core.OPT_TAGS.1113289019.878655841" superClass="com.ti.ccstudio.buildDefinitions.core.OPT_TAGS.1113289019"/>
                                                        <option id="com.ti.ccstudio.buildDefinitions.core.OPT_CODEGEN_VERSION.1607095822.1828814052" name="Compiler version" superClass="com.ti.ccstudio.buildDefinitions.core.OPT_CODEGEN_VERSION.1607095822"/>
-                                                       <tool id="com.ti.ccstudio.buildDefinitions.C6000_8.2.exe.compilerDebug.141455865" name="C6000 Compiler" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.2.exe.compilerDebug.440121953"/>
+                                                       <tool id="com.ti.ccstudio.buildDefinitions.C6000_8.2.exe.compilerDebug.141455865" name="C6000 Compiler" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.2.exe.compilerDebug.440121953">
+                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_8.2.compiler.inputType__C_SRCS.66765679" name="C Sources" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.2.compiler.inputType__C_SRCS"/>
+                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_8.2.compiler.inputType__CPP_SRCS.1393340611" name="C++ Sources" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.2.compiler.inputType__CPP_SRCS"/>
+                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_8.2.compiler.inputType__ASM_SRCS.2136267732" name="Assembly Sources" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.2.compiler.inputType__ASM_SRCS"/>
+                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_8.2.compiler.inputType__ASM2_SRCS.1333704729" name="Assembly Sources" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.2.compiler.inputType__ASM2_SRCS"/>
+                                                       </tool>
                                                        <tool id="com.ti.ccstudio.buildDefinitions.C6000_8.2.exe.linkerDebug.512388035" name="C6000 Linker" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.2.exe.linkerDebug.1923676976"/>
                                                        <tool id="com.ti.ccstudio.buildDefinitions.C6000_8.2.hex.1554065099" name="C6000 Hex Utility" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.2.hex.2016532430"/>
                                                        <tool id="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.2083164526" name="XDCtools" superClass="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.210654452"/>
index 26bb029987ff24ec58469cc043273ba340e491c9..6362d9d8d731591f87297b6a03839411ca0ec127 100644 (file)
@@ -52,6 +52,12 @@ All rights reserved.
 #include "audioStreamProc_common.h"
 #include "common.h"
 
+// Gets ack command corresponding to send command
+static UInt32 
+getAckCmd(
+    UInt32 sndCmd
+);
+
 /* Initialize ASP master messaging */
 Int AspMsgMaster_init(
     AspMsgMaster_Handle hAspMsgMaster,  // message master handle
@@ -88,10 +94,10 @@ Int AspMsgMaster_init(
     hAspMsgMaster->poolSize = 0;
     hAspMsgMaster->store = NULL;            // placed in Shared Region 0
     hAspMsgMaster->messageId = 0;
-    hAspMsgMaster->saveMsgId = NULL;        // placed in Shared Region 0
+    hAspMsgMaster->saveMsgInfo = NULL;      // placed in Shared Region 0
     hAspMsgMaster->saveMsgWrtIdx = 0;
     hAspMsgMaster->saveMsgRdIdx = 0;
-    hAspMsgMaster->numSaveMsgId = 0;
+    hAspMsgMaster->numSaveMsgInfo = 0;
     hAspMsgMaster->syncEventHandle = NULL;
     hAspMsgMaster->eventHandle =  NULL;
     hAspMsgMaster->eventId = Event_Id_NONE;
@@ -189,12 +195,14 @@ Int AspMsgMaster_init(
     Log_info0("AspMsgMaster_init(): MessageQ_open() finish");
 
     // allocate and initialize send message Id array
-    hAspMsgMaster->saveMsgId = Memory_alloc(srHeap, numMsgs * sizeof(UInt32), align, NULL); // send message Id array hard-coded in Shared Region 0
-    if (hAspMsgMaster->saveMsgId != NULL)
+    hAspMsgMaster->saveMsgInfo = Memory_alloc(srHeap, numMsgs * sizeof(AspMsgMaster_SaveMsgInfo), align, NULL); // send message Id array hard-coded in Shared Region 0
+    if (hAspMsgMaster->saveMsgInfo != NULL)
     {
         for (i = 0; i < hAspMsgMaster->numMsgs; i++)
         {
-            hAspMsgMaster->saveMsgId[i] = (UInt32)(1<<31); // mark as unused
+            // mark as unused
+            hAspMsgMaster->saveMsgInfo[i].sndCmd = ASP_SLAVE_NULL;
+            hAspMsgMaster->saveMsgInfo[i].msgId = (UInt32)(1<<31);
         }
     }
     else
@@ -217,8 +225,8 @@ Int AspMsgMaster_init(
 // ASP message send function
 Int AspMsgSnd(
     AspMsgMaster_Handle hAspMsgMaster,  // message master handle
-       UInt32 sndCmd,                      // command sent from master to slave
-       char *sndMsgBuf                     // message buffer for message sent from master to slave
+    UInt32 sndCmd,                      // command sent from master to slave
+    char *sndMsgBuf                     // message buffer for message sent from master to slave
 )
 {
     AspMsg *pAspMsg;
@@ -254,17 +262,18 @@ Int AspMsgSnd(
         return ASP_MSG_ERR_QUEUE_PUT;
     }
 
-    // Save message Id for ack message validation.
+    // Save message info for ack message validation.
     //  Expect ack messages in same order as sent messages.
     //  Multiple messages can be sent between response messages.
-    hAspMsgMaster->saveMsgId[hAspMsgMaster->saveMsgWrtIdx] = hAspMsgMaster->messageId;
+    hAspMsgMaster->saveMsgInfo[hAspMsgMaster->saveMsgWrtIdx].sndCmd = sndCmd;
+    hAspMsgMaster->saveMsgInfo[hAspMsgMaster->saveMsgWrtIdx].msgId = hAspMsgMaster->messageId;
     hAspMsgMaster->saveMsgWrtIdx++;
     if (hAspMsgMaster->saveMsgWrtIdx >= hAspMsgMaster->numMsgs)
     {
         hAspMsgMaster->saveMsgWrtIdx = 0;
     }
-    hAspMsgMaster->numSaveMsgId++;
-    if (hAspMsgMaster->numSaveMsgId > hAspMsgMaster->numMsgs)
+    hAspMsgMaster->numSaveMsgInfo++;
+    if (hAspMsgMaster->numSaveMsgInfo > hAspMsgMaster->numMsgs)
     {
         Log_info0("AspMsgSnd(): Tx message overflow.");
         MessageQ_free((MessageQ_Msg)pAspMsg);
@@ -278,17 +287,20 @@ Int AspMsgSnd(
 } /* AspMsgSnd */
 
 // Message receive acknowledge function
+//  Expected acknowledge is an input parameter.
+//  Expected acknowledge is compared against acknowledge for least recently sent command.
 Int                                     // returned status
 AspMsgRcvAck(
     AspMsgMaster_Handle hAspMsgMaster,  // message master handle
-       UInt32 ackCmd,                      // acknowledgment sent from slave to master
-       char *ackMsgBuf,                    // message buffer for acknowledgment message sent from slave to master
+    UInt32 ackCmd,                      // expected acknowledgment sent from slave to master
+    char *ackMsgBuf,                    // message buffer for acknowledgment message sent from slave to master
     Bool pendOnEvent                    // whether to pend on Event synchronizer
 )
 {
     AspMsg *pAspMsg;
     Bool validMsg;
     Int status;
+    UInt32 saveAckCmd;
 
     if (hAspMsgMaster->syncEventHandle == NULL)
     {
@@ -343,8 +355,7 @@ AspMsgRcvAck(
     
     // check if returned message is valid
     validMsg = ((pAspMsg->procId == hAspMsgMaster->slaveProcId) &&  // check ack message from slave
-                (pAspMsg->messageId & (UInt32)(1<<31)) &&           // check message ack bit set by slave
-                (pAspMsg->cmd == ackCmd));                          // check command ack from slave
+                (pAspMsg->messageId & (UInt32)(1<<31)));            // check message ack bit set by slave
     if (validMsg == FALSE)
     {
         Log_info3("AspMsgRcvAck(): Rx Message ACK ERROR: procId=%d, messageId=0x%04x, cmd=%d", pAspMsg->procId, pAspMsg->messageId, pAspMsg->cmd);
@@ -352,18 +363,34 @@ AspMsgRcvAck(
         return ASP_MSG_ERR_ACKNOWLEDGE;
     }
 
-    // Compare response message Id against message Id of least recently sent message
-    validMsg = ((pAspMsg->messageId & (UInt32)~(1<<31)) == hAspMsgMaster->saveMsgId[hAspMsgMaster->saveMsgRdIdx]);
+    // Determine ack command for least recently sent message
+    saveAckCmd = getAckCmd(hAspMsgMaster->saveMsgInfo[hAspMsgMaster->saveMsgRdIdx].sndCmd);
+    
+    // Compare expected ack command against ack command of least recently sent message
+    validMsg = (ackCmd == saveAckCmd);
+    if (validMsg == FALSE)
+    {
+        TRACE_TERSE2("AspMsgRcvAck(): Rx Message ACK ERROR: expect ackCmd=%d, ack for oldest message=%d", ackCmd, saveAckCmd);
+        MessageQ_free((MessageQ_Msg)pAspMsg);
+        return ASP_MSG_ERR_ACKNOWLEDGE;
+    }
+    
+    // Compare returned message ack command & Id against ack command & Id of least recently sent message
+    validMsg = ((pAspMsg->cmd == saveAckCmd) && 
+                ((pAspMsg->messageId & (UInt32)~(1<<31)) == hAspMsgMaster->saveMsgInfo[hAspMsgMaster->saveMsgRdIdx].msgId));
     if (validMsg == TRUE)
     {
-        hAspMsgMaster->saveMsgId[hAspMsgMaster->saveMsgRdIdx] = (UInt32)(1<<31); // mark location unused
+        // mark location unused
+        hAspMsgMaster->saveMsgInfo[hAspMsgMaster->saveMsgRdIdx].sndCmd = ASP_SLAVE_NULL;
+        hAspMsgMaster->saveMsgInfo[hAspMsgMaster->saveMsgRdIdx].msgId = (UInt32)(1<<31);
+        
         hAspMsgMaster->saveMsgRdIdx++;
         if (hAspMsgMaster->saveMsgRdIdx >= hAspMsgMaster->numMsgs)
         {
             hAspMsgMaster->saveMsgRdIdx = 0;
         }
-        hAspMsgMaster->numSaveMsgId--;
-        if (hAspMsgMaster->numSaveMsgId < 0)
+        hAspMsgMaster->numSaveMsgInfo--;
+        if (hAspMsgMaster->numSaveMsgInfo < 0)
         {
             Log_info0("AspMsgRcvAck(): Rx message underflow.");
             MessageQ_free((MessageQ_Msg)pAspMsg);
@@ -395,3 +422,167 @@ AspMsgRcvAck(
     // may be error in returned (acknowledgment) message.
     return ASP_MSG_NO_ERR;
 } /* AspMsgRcvAck */
+
+// Get number of outstanding messages function
+Int                                     // returned status
+AspMsgGetNumSndMsgUnack(
+    AspMsgMaster_Handle hAspMsgMaster,  // message master handle
+    UInt16 *pNumSndMsgUnack             // number of unacknowledged messages sent to the slave
+)
+{
+    *pNumSndMsgUnack = hAspMsgMaster->numSaveMsgInfo;
+    
+    return ASP_MSG_NO_ERR;
+}
+
+// Message receive acknowledge function
+//  Received acknowledge is an output parameter.
+Int                                     // returned status
+AspMsgRcvAckUnk(
+    AspMsgMaster_Handle hAspMsgMaster,  // message master handle
+    UInt32 *pAckCmd,                    // acknowledgment sent from slave to master
+    char *ackMsgBuf,                    // message buffer for acknowledgment message sent from slave to master
+    Bool pendOnEvent                    // whether to pend on Event synchronizer
+)
+{
+    AspMsg *pAspMsg;
+    Bool validMsg;
+    Int status;
+    UInt32 saveAckCmd;
+
+    if (hAspMsgMaster->syncEventHandle == NULL)
+    {
+        // wait for complete message from slave
+        // pend on default Semaphore synchronizer
+        // read message upon sync
+        status = MessageQ_get(hAspMsgMaster->masterQue, (MessageQ_Msg *)&pAspMsg, MessageQ_FOREVER);    
+        if (status != MessageQ_S_SUCCESS)
+        {
+            Log_info0("AspMsgRcvAck(): MessageQ_get() failure.");
+            if (pAspMsg != NULL)
+            {
+                MessageQ_free((MessageQ_Msg)pAspMsg);
+            }
+            return ASP_MSG_ERR_QUEUE_GET;
+        }
+    }
+    else
+    {
+        if (pendOnEvent == TRUE)
+        {
+            // wait for complete message from slave
+            // pend on non-default SyncEvent synchronizer
+            Event_pend(hAspMsgMaster->eventHandle, Event_Id_NONE, hAspMsgMaster->eventId, BIOS_WAIT_FOREVER);
+        }
+        else
+        {
+            // Sync already performed outside this function or polling
+            ;
+        }
+        
+        // Read message from MessageQ
+        status = MessageQ_get(hAspMsgMaster->masterQue, (MessageQ_Msg *)&pAspMsg, 0);
+        if (status != MessageQ_S_SUCCESS)
+        {
+            if (status == MessageQ_E_TIMEOUT)
+            {
+                Log_info0("AspMsgRcvAck(): MessageQ_get() timeout.");
+                return ASP_MSG_ERR_QUEUE_TIMEOUT;
+            }
+            else
+            {
+                Log_info0("AspMsgRcvAck(): MessageQ_get() failure.");
+                if (pAspMsg != NULL)
+                {
+                    MessageQ_free((MessageQ_Msg)pAspMsg);
+                }
+                return ASP_MSG_ERR_QUEUE_GET;
+            }
+        }
+    }
+    
+    // check if returned message is valid
+    validMsg = ((pAspMsg->procId == hAspMsgMaster->slaveProcId) &&  // check ack message from slave
+                (pAspMsg->messageId & (UInt32)(1<<31)));            // check message ack bit set by slave
+    if (validMsg == FALSE)
+    {
+        Log_info3("AspMsgRcvAck(): Rx Message ACK ERROR: procId=%d, messageId=0x%04x, cmd=%d", pAspMsg->procId, pAspMsg->messageId, pAspMsg->cmd);
+        MessageQ_free((MessageQ_Msg)pAspMsg);
+        return ASP_MSG_ERR_ACKNOWLEDGE;
+    }
+
+    // Determine ack command for least recently sent message
+    saveAckCmd = getAckCmd(hAspMsgMaster->saveMsgInfo[hAspMsgMaster->saveMsgRdIdx].sndCmd);
+    
+#if 0
+    // Compare expected ack command against ack command of least recently sent message
+    validMsg = (ackCmd == saveAckCmd);
+    if (validMsg == FALSE)
+    {
+        TRACE_TERSE2("AspMsgRcvAck(): Rx Message ACK ERROR: expect ackCmd=%d, ack for oldest message=%d", ackCmd, saveAckCmd);
+        MessageQ_free((MessageQ_Msg)pAspMsg);
+        return ASP_MSG_ERR_ACKNOWLEDGE;
+    }
+#endif
+    
+    // Compare returned message ack command & Id against ack command & Id of least recently sent message
+    validMsg = ((pAspMsg->cmd == saveAckCmd) && 
+                ((pAspMsg->messageId & (UInt32)~(1<<31)) == hAspMsgMaster->saveMsgInfo[hAspMsgMaster->saveMsgRdIdx].msgId));
+    if (validMsg == TRUE)
+    {
+        // mark location unused
+        hAspMsgMaster->saveMsgInfo[hAspMsgMaster->saveMsgRdIdx].sndCmd = ASP_SLAVE_NULL;
+        hAspMsgMaster->saveMsgInfo[hAspMsgMaster->saveMsgRdIdx].msgId = (UInt32)(1<<31);
+        
+        hAspMsgMaster->saveMsgRdIdx++;
+        if (hAspMsgMaster->saveMsgRdIdx >= hAspMsgMaster->numMsgs)
+        {
+            hAspMsgMaster->saveMsgRdIdx = 0;
+        }
+        hAspMsgMaster->numSaveMsgInfo--;
+        if (hAspMsgMaster->numSaveMsgInfo < 0)
+        {
+            Log_info0("AspMsgRcvAck(): Rx message underflow.");
+            MessageQ_free((MessageQ_Msg)pAspMsg);
+            return ASP_MSG_ERR_RECEIVE_UND;
+        }
+    }
+    else
+    {
+        TRACE_TERSE3("AspMsgRcvAck(): Rx Message ACK ERROR: procId=%d, messageId=0x%04x, cmd=%d", pAspMsg->procId, pAspMsg->messageId, pAspMsg->cmd);
+        MessageQ_free((MessageQ_Msg)pAspMsg);
+        return ASP_MSG_ERR_ACKNOWLEDGE;
+    }
+
+    // get the returned message
+    if (pAckCmd != NULL)
+    {
+        *pAckCmd = pAspMsg->cmd;
+    }
+    
+    if (ackMsgBuf != NULL) 
+    {
+        memcpy(ackMsgBuf, pAspMsg->buf, ASP_MSG_BUF_LEN*sizeof(char));
+    }
+
+    // free the message 
+    status = MessageQ_free((MessageQ_Msg)pAspMsg);
+    if (status != MessageQ_S_SUCCESS) 
+    {
+        Log_info0("AspMsgRcvAck(): MessageQ_free() failure.");
+        return ASP_MSG_ERR_QUEUE_FREE;
+    }
+
+    // No error in messaging operation, even though there
+    // may be error in returned (acknowledgment) message.
+    return ASP_MSG_NO_ERR;
+} /* AspMsgRcvAckUnk */
+
+// Gets ack command corresponding to send command
+static UInt32 
+getAckCmd(
+    UInt32 sndCmd
+)
+{
+    return sndCmd+ASP_SLAVE_NCOMMANDS;
+}
index 7fb507337104c65335db8b930d885a41f8d9370d..e8553d2c4a319c9d8ce3192e7900088137c94d37 100644 (file)
@@ -64,27 +64,34 @@ All rights reserved.
 
 #define ASP_MSG_MASTER_DEF_NUMMSGS                  (  4 )
 
+// save message info
+typedef struct AspMsgMaster_SaveMsgInfo
+{
+    UInt32 sndCmd;  // command sent from master to slave
+    UInt32 msgId;   // Id contained in LS 31 bits, MS bit is 0
+} AspMsgMaster_SaveMsgInfo;
+
 // module structure
 typedef struct AspMsgMaster_Module
 {
-    UInt16              masterProcId;       // master processor id
-    UInt16              slaveProcId;        // slave processor id
-    MessageQ_Handle     masterQue;          // created locally
-    MessageQ_QueueId    slaveQueId;         // created remotely, opened locally
-    UInt16              heapId;             // MessageQ heapId
-    UInt16              numMsgs;            // number of messages
-    HeapBuf_Handle      heap;               // message heap
-    Int                 msgSize;            // aligned size of message
-    Int                 poolSize;           // size of message pool
-    Ptr                 store;              // memory store for message pool
-    UInt32              messageId;          // Next send message Id. Format: Id contained in LS 31 bits, MS bit is 0.
-    UInt32              *saveMsgId;         // Send message Id array. Array member format: Id contained in LS 31 bits, MS bit is 0.
-    UInt8               saveMsgWrtIdx;      // index of next location in saveMessageId[] for write (message send)
-    UInt8               saveMsgRdIdx;       // index of next location in saveMessageId[] for read (message receive)
-    Int8                numSaveMsgId;       // number of saved message Ids
-    SyncEvent_Handle    syncEventHandle;    // sync event handle
-    Event_Handle        eventHandle;        // event handle
-    UInt                eventId;            // event Id
+    UInt16                      masterProcId;       // master processor id
+    UInt16                      slaveProcId;        // slave processor id
+    MessageQ_Handle             masterQue;          // created locally
+    MessageQ_QueueId            slaveQueId;         // created remotely, opened locally
+    UInt16                      heapId;             // MessageQ heapId
+    UInt16                      numMsgs;            // maximum number of messages
+    HeapBuf_Handle              heap;               // message heap
+    Int                         msgSize;            // aligned size of message
+    Int                         poolSize;           // size of message pool
+    Ptr                         store;              // memory store for message pool
+    UInt32                      messageId;          // Next send message Id. Format: Id contained in LS 31 bits, MS bit is 0.
+    AspMsgMaster_SaveMsgInfo    *saveMsgInfo;       // Send message info array
+    UInt8                       saveMsgWrtIdx;      // index of next location in saveMsgInfo[] for write (message send)
+    UInt8                       saveMsgRdIdx;       // index of next location in saveMsgInfo[] for read (message receive)
+    Int8                        numSaveMsgInfo;     // number of saved message info
+    SyncEvent_Handle            syncEventHandle;    // sync event handle
+    Event_Handle                eventHandle;        // event handle
+    UInt                        eventId;            // event Id
 } AspMsgMaster_Module;
 
 // module handle
@@ -111,8 +118,8 @@ AspMsgMaster_init(
 Int                                     // returned status
 AspMsgSnd(
     AspMsgMaster_Handle hAspMsgMaster,  // message master handle
-       UInt32 sndCmd,                      // command sent from master to slave
-       char *sndMsgBuf                     // message buffer for message sent from master to slave
+    UInt32 sndCmd,                      // command sent from master to slave
+    char *sndMsgBuf                     // message buffer for message sent from master to slave
 );
 
 /* 
@@ -120,12 +127,40 @@ AspMsgSnd(
  *
  * Description: 
  *      This function receives an acknowledgment message from the slave to the master processor.
+ *      The expected acknowledgement is an input to the function.
  */
 Int                                     // returned status
 AspMsgRcvAck(
     AspMsgMaster_Handle hAspMsgMaster,  // message master handle
-       UInt32 ackCmd,                      // acknowledgment sent from slave to master
-       char *ackMsgBuf,                    // message buffer for acknowledgment message sent from slave to master
+    UInt32 ackCmd,                      // expected acknowledgment sent from slave to master
+    char *ackMsgBuf,                    // message buffer for acknowledgment message sent from slave to master
+    Bool pendOnEvent                    // whether to pend on Event synchronizer
+);
+
+/* 
+ * ASP message get number of outstanding messages function
+ *
+ * Description: 
+ *      This function returns the number of messages sent to the slave which haven't yet been acknowledged.
+ */
+Int                                     // returned status
+AspMsgGetNumSndMsgUnack(
+    AspMsgMaster_Handle hAspMsgMaster,  // message master handle
+    UInt16 *pNumSndMsgUnack             // number of unacknowledged messages sent to the slave
+);
+
+/* 
+ * ASP message receive acknowledge function
+ *
+ * Description: 
+ *      This function receives an acknowledgment message from the slave to the master processor.
+ *      The receive acknowledgement is output by the function.
+ */
+Int                                     // returned status
+AspMsgRcvAckUnk(
+    AspMsgMaster_Handle hAspMsgMaster,  // message master handle
+    UInt32 *pAckCmd,                    // acknowledgment sent from slave to master
+    char *ackMsgBuf,                    // message buffer for acknowledgment message sent from slave to master
     Bool pendOnEvent                    // whether to pend on Event synchronizer
 );
 
index d62af3bda84d845fd722790d9ac77cd6fb12a2c0..43dd8e725f68ce0730b129e455786de0e34ea49f 100644 (file)
@@ -94,6 +94,31 @@ static Int decIbConfigQueNotEmpty(asipDecProc_t *pDec);
 
 Int decCheckMajorAu(PAF_AST_Config *pAstCfg);
 
+// Processes unacknowledged Ack messages in decDecodeComplete()
+static Int decDecodeCompleteProcAck(
+    const PAF_ASIT_Params *pP, 
+    PAF_ASIT_Config *pAsitCfg,
+    Int z,
+    UInt32 ackCmd, 
+    char *decMsgBuf
+);
+
+// Processes unacknowledged Info Ack messages in decDecodeComplete()
+static Int decDecodeCompleteProcDecInfoAck(
+    const PAF_ASIT_Params *pP, 
+    PAF_ASIT_Config *pAsitCfg,
+    Int z,
+    char *decMsgBuf
+);
+
+// Processes unacknowledged Decode Ack messages in decDecodeComplete()
+static Int decDecodeCompleteProcDecDecodeAck(
+    const PAF_ASIT_Params *pP, 
+    PAF_ASIT_Config *pAsitCfg,
+    Int z,
+    char *decMsgBuf
+);
+
 extern UInt32 gCbWrtAfErrCnt;
 
 
@@ -117,7 +142,6 @@ Int decDecodeInit(
     return ASIP_NO_ERR;
 }
 
-
 // -----------------------------------------------------------------------------
 // -----------------------------------------------------------------------------
 Int decDecodeFsm(
@@ -581,48 +605,83 @@ static Int decodeInit(
     return ASIP_NO_ERR;
 }  /* decDecodeInit */
 
-
-
 Int decDecodeComplete( const PAF_ASIT_Params *pP,
                        PAF_ASIT_Config *pAsitCfg)
 {
     PAF_AST_Config *pAstCfg;
+    PAF_AST_IoInp  *pInp;
     AspMsgMaster_Handle hAspMsgMaster;  // ASIT message master handle
-    Int as;                     /* Audio Stream Number (1, 2, etc.) */
-    Int z;                      /* decode/encode counter */
+    Int as;                             /* Audio Stream Number (1, 2, etc.) */
+    Int z;                              /* decode/encode counter */
+    Int zI;
     Int argIdx;
     Int8 tempVar8;
+    UInt32 ackCmd;
     char decMsgBuf[ASP_MSG_BUF_LEN];
     Int status;
+    UInt16 numSndMsgUnack;      // number of unknowledged send messages
 
     pAstCfg = pAsitCfg->pAstCfg;                // get pointer to AST common (shared) configuration
+    pInp    = pAsitCfg->pIoInp;                 // get pointer to IO configuration
     hAspMsgMaster = pAsitCfg->hAspMsgMaster;    // get message master handle
     as = pAstCfg->as;
     (void)as;  // clear compiler warning in case not used with tracing disabled
 
     for (z=DECODE1; z < DECODEN; z++)
     {
+        zI = pP->inputsFromDecodes[z];
+
         tempVar8 = sharedMemReadInt8(&(pAstCfg->xDec[z].decodeStatus.mode),
                                      GATEMP_INDEX_DEC);
-        if (pAsitCfg->pIoInp[z].hIoPhy && tempVar8)
+        if (pInp[zI].hIoPhy && tempVar8)
         {
             TRACE_VERBOSE1("decDecodeComplete: AS%d: finalizing decode", as+z);
 
+            // Get number of pending ack messages
+            AspMsgGetNumSndMsgUnack(hAspMsgMaster, &numSndMsgUnack);
+            TRACE_TERSE1("decDecodeComplete: number of pending ACK messages=%d.", numSndMsgUnack);
+            
+            // Process any pending ack messages as they arrive
+            while (numSndMsgUnack > 0)
+            {
+                // Receive pending acknowledge message
+                status = AspMsgRcvAckUnk(hAspMsgMaster, &ackCmd, decMsgBuf, TRUE);
+                if (status != ASP_MSG_NO_ERR)
+                {
+                    TRACE_TERSE0("decDecodeComplete: error in receiving ACK message.");
+                    SW_BREAKPOINT; // debug
+                    return DEC_ERR_COMPLETE_MSG;
+                }
+                TRACE_TERSE1("decDecodeComplete: Rx pending ACK message=%d.", ackCmd);
+                
+                //
+                // Process acknowledge message
+                //
+                status = decDecodeCompleteProcAck(pP, pAsitCfg, z, ackCmd, decMsgBuf);
+                if (status != DEC_NO_ERR)
+                {
+                    TRACE_TERSE1("decDecodeComplete: error processing ACK message=%d.", ackCmd);
+                    return status;
+                }
+
+                AspMsgGetNumSndMsgUnack(hAspMsgMaster, &numSndMsgUnack);
+            }
+            
             // send dec deactivate message to slave
             argIdx = 0; // set decIdx
             *(Int32 *)&decMsgBuf[argIdx] = z;
             status = AspMsgSnd(hAspMsgMaster, ASP_SLAVE_DEC_DEACTIVATE, decMsgBuf);
             if (status != ASP_MSG_NO_ERR)
             {
-                TRACE_TERSE0("decodeComplete: error in sending DEC_DEACTIVATE message.");
-                SW_BREAKPOINT;
+                TRACE_TERSE0("decDecodeComplete: error in sending DEC_DEACTIVATE message.");
+                SW_BREAKPOINT; // debug
                 return DEC_ERR_COMPLETE_MSG;
             }
             status = AspMsgRcvAck(hAspMsgMaster, ASP_MASTER_DEC_DEACTIVATE_DONE, NULL, TRUE);
             if (status != ASP_MSG_NO_ERR)
             {
-                TRACE_TERSE0("decodeComplete: error in sending DEC_DEACTIVATE message.");
-                SW_BREAKPOINT;
+                TRACE_TERSE0("decDecodeComplete: error in receiving DEC_DEACTIVATE_DONE message.");
+                SW_BREAKPOINT; // debug
                 return DEC_ERR_COMPLETE_MSG;
             }
         }
@@ -852,12 +911,12 @@ Int decInfoAck(
     PAF_AST_Config *pAstCfg;
     PAF_AST_IoInp  *pInp;
     AspMsgMaster_Handle hAspMsgMaster;
-    Int as;                    /* Audio Stream Number (1, 2, etc.) */
+    //Int as;                    /* Audio Stream Number (1, 2, etc.) */
     Int z;                     /* input/decode/stream counter */
     Int errno;                 /* error number */
-    Int zI, zS;
+    Int zI;
     Int zMD;
-    Int zMS;
+    Int zMI;
     Int argIdx;
     Int8 tempVar8;
     Int tempVar;
@@ -867,18 +926,15 @@ Int decInfoAck(
     pAstCfg = pAsitCfg->pAstCfg;                // get pointer to common (shared) configuration
     pInp    = pAsitCfg->pIoInp;                 // get pointer to IO configuration
     hAspMsgMaster = pAsitCfg->hAspMsgMaster;    // get message master handle
-    as = pAstCfg->as;
+    //as = pAstCfg->as;
     zMD = pAstCfg->masterDec;
-    zMS = pAstCfg->masterStr;
-    (void)zMS;  (void)as;  // clear compiler warning in case not used with tracing disabled
+    zMI = pP->zone.master;
 
     // Decode info
     for (z=DECODE1; z < DECODEN; z++)
     {
         zI = pP->inputsFromDecodes[z];
-        zS = pP->streamsFromDecodes[z];
-        (void)zS; // clear compiler warning in case not used with tracing disabled
-
+        
         tempVar8 = sharedMemReadInt8(&(pAstCfg->xDec[z].decodeStatus.mode),
                                      GATEMP_INDEX_DEC);
         if (pInp[zI].hIoPhy  && tempVar8)
@@ -925,7 +981,7 @@ Int decInfoAck(
     if (tempVar8)
     {
         sharedMemWriteInt8(&(pAstCfg->xDec[zMD].decodeStatus.sourceProgram),
-                           pInp[zMD].sourceProgram, GATEMP_INDEX_DEC);
+                           pInp[zMI].sourceProgram, GATEMP_INDEX_DEC);
     }
 
     // since now decoding update decode status for all enabled decoders
@@ -964,7 +1020,8 @@ static Int decDecodeSnd(const PAF_ASIT_Params *pP, const PAF_ASIT_Patchs *pQ,
     Int as;                     /* Audio Stream Number (1, 2, etc.) */
     Int z;                      /* decode/stream counter */
     Int argIdx;
-    Int cbErrno, errno;
+    //Int cbErrno;
+    Int errno;
     char decMsgBuf[ASP_MSG_BUF_LEN];
     Int status;
 
@@ -1117,6 +1174,151 @@ static Int decDecodeAck(const PAF_ASIT_Params *pP, const PAF_ASIT_Patchs *pQ,
     return ASIP_NO_ERR;
 } /* decDecodeAck */
 
+// Processes unacknowledged Ack messages in decDecodeComplete()
+static Int decDecodeCompleteProcAck(
+    const PAF_ASIT_Params *pP, 
+    PAF_ASIT_Config *pAsitCfg,
+    Int z,
+    UInt32 ackCmd, 
+    char *decMsgBuf
+)
+{
+    Int status;
+    
+    switch(ackCmd)
+    {
+        case ASP_MASTER_DEC_INFO_DONE:
+            status = decDecodeCompleteProcDecInfoAck(pP, pAsitCfg, z, decMsgBuf);
+            break;
+        
+        case ASP_MASTER_DEC_DECODE_DONE: 
+            status = decDecodeCompleteProcDecDecodeAck(pP, pAsitCfg, z, decMsgBuf);
+            break;
+            
+        default:
+            status = DEC_ERR_COMPLETE_ACKMSG;
+            break;
+    }
+    
+    return status;
+} /* decDecodeCompleteProcAck */
+
+// Processes unacknowledged Decode Ack messages in decDecodeComplete()
+static Int decDecodeCompleteProcDecInfoAck(
+    const PAF_ASIT_Params *pP, 
+    PAF_ASIT_Config *pAsitCfg,
+    Int z,
+    char *decMsgBuf
+)
+{
+    PAF_AST_Config *pAstCfg;    // pointer to common (shared) ASIT/ASDT/ASOT configuration
+    PAF_AST_IoInp  *pInp;       // pointer to Input IO configuration
+    Int zMD;
+    Int zMI;
+    Int argIdx;                 // message payload argument index
+    Int tempVar;
+    Int8 tempVar8;
+    Int errno;
+
+    pAstCfg = pAsitCfg->pAstCfg;                // get pointer to common (shared) configuration
+    pInp = pAsitCfg->pIoInp;                    // get pointer to Input IO configuration
+    zMD = pAstCfg->masterDec;
+    zMI = pP->zone.master;
+
+
+    // invalidate Dec configuration
+    Cache_inv(&pAstCfg->xDec[z], sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
+    Cache_wait();
+
+    // extract message payload
+    argIdx = 0; // get decErrno
+    errno = *(Int32 *)&decMsgBuf[argIdx];
+    
+    if (errno) 
+    {
+        TRACE_TERSE1("decDecodeCompleteProcDecInfoAck() return error errno 0x%x.", errno);
+        return DEC_ERR_COMPLETE_INFO_ACKMSG;
+    }
+    
+    // increment decoded frame count
+    tempVar = sharedMemReadInt(&(pAstCfg->xDec[z].decodeStatus.frameCount), 
+        GATEMP_INDEX_DEC);
+    tempVar += 1;
+    sharedMemWriteInt(&(pAstCfg->xDec[z].decodeStatus.frameCount), 
+        tempVar, GATEMP_INDEX_DEC);
+    
+    // query IB for latest sourceProgram (needed if we started decoding due to a force mode)
+    tempVar8 = sharedMemReadInt8(&(pAstCfg->xDec[zMD].decodeStatus.mode), 
+        GATEMP_INDEX_DEC);
+    if (tempVar8)
+    {
+        sharedMemWriteInt8(&(pAstCfg->xDec[zMD].decodeStatus.sourceProgram),
+            pInp[zMI].sourceProgram, GATEMP_INDEX_DEC);
+    }
+
+    // update decode status for all enabled decoders
+    tempVar8 = sharedMemReadInt8(&(pAstCfg->xDec[z].decodeStatus.mode), 
+        GATEMP_INDEX_DEC);
+    if (tempVar8)
+    {
+        tempVar8 = sharedMemReadInt8(&(pAstCfg->xDec[z].decodeStatus.sourceProgram), 
+            GATEMP_INDEX_DEC);
+        sharedMemWriteInt8(&(pAstCfg->xDec[z].decodeStatus.sourceDecode), 
+            tempVar8, GATEMP_INDEX_DEC);
+
+        tempVar8 = sharedMemReadInt8(&(pAstCfg->xDec[z].decodeStatus.sourceSelect),
+            GATEMP_INDEX_DEC);
+        if (tempVar8 == PAF_SOURCE_SNG)
+        {
+            sharedMemWriteInt8(&(pAstCfg->xDec[z].decodeStatus.sourceDecode),
+                tempVar8, GATEMP_INDEX_DEC);
+        }
+    }
+
+    return DEC_NO_ERR;
+}
+
+// Processes unacknowledged Decode Ack messages in decDecodeComplete()
+static Int decDecodeCompleteProcDecDecodeAck(
+    const PAF_ASIT_Params *pP, 
+    PAF_ASIT_Config *pAsitCfg,
+    Int z,
+    char *decMsgBuf
+)
+{
+    PAF_AST_Config *pAstCfg;    // pointer to common (shared) ASIT/ASDT/ASOT configuration
+    Int argIdx;                 // message payload argument index
+    Int errno;
+    Int cbErrno;
+    
+    pAstCfg = pAsitCfg->pAstCfg;                // get pointer to common (shared) configuration
+    
+    // invalidate Dec configuration
+    Cache_inv(&pAstCfg->xDec[z], sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
+    Cache_wait();
+    
+    // extract message payload
+    argIdx = 0; // get decErrno
+    errno = *(Int32 *)&decMsgBuf[argIdx];
+    argIdx += sizeof(Int32); // get cbErrno
+    cbErrno = *(Int32 *)&decMsgBuf[argIdx];
+    
+    if (cbErrno != 0)
+    {
+        gCbWrtAfErrCnt++;
+        TRACE_TERSE1("CB write error=%d", cbErrno);
+        //SW_BREAKPOINT; // temporary
+    }
+    
+    if (errno) 
+    {
+        TRACE_TERSE1("decDecodeCompleteProcDecInfoAck() return error errno 0x%x.", errno);
+        return DEC_ERR_COMPLETE_DECODE_ACKMSG;
+    }
+    
+    return DEC_NO_ERR;
+}
+
 
 #if 0
 Int asipDecodeProcessing(
index 85aec193c491aa739aac81b06eeebf41c81b9771..4f9ca0dea5830bb29ab43714b6a3b4b682ced21d 100644 (file)
@@ -239,7 +239,10 @@ enum {
     DEC_ERR_DECODE_SNDMSG,
     DEC_ERR_DECODE_ACKMSG,
     DEC_ERR_DECODE_FINAL,
-    DEC_ERR_COMPLETE_MSG
+    DEC_ERR_COMPLETE_MSG,
+    DEC_ERR_COMPLETE_ACKMSG, 
+    DEC_ERR_COMPLETE_INFO_ACKMSG,
+    DEC_ERR_COMPLETE_DECODE_ACKMSG
 };