2 /*
3 Copyright (c) 2017, Texas Instruments Incorporated - http://www.ti.com/
4 All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 *
13 * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the
16 * distribution.
17 *
18 * Neither the name of Texas Instruments Incorporated nor the names of
19 * its contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 */
36 /*
37 * ======== aspOutInitSync_slave.c ========
38 */
41 #include <xdc/std.h>
43 #include "aspOutInitSync_common.h"
44 #include "aspOutInitSync_slave.h"
46 // Reset dec stage flags
47 Int outIsResetDecStageFlags(
48 PAF_AST_OutInitSyncCtl *pOutIsCtl, // Output Init-Sync Control
49 Int8 outIsiIdx // Output Init-Sync Info index
50 )
51 {
52 IArg key;
53 GateMP_Handle gateHandle;
54 PAF_AST_OutInitSyncInfo *pOutIsi;
55 Int8 i;
57 // Get gate handle
58 gateHandle = pOutIsCtl->gateHandle;
59 // Enter gate
60 key = GateMP_enter(gateHandle);
62 //
63 // Reset decoder stage flags
64 //
66 // Get address of Output Init-Sync Info
67 pOutIsi = &((*pOutIsCtl->pXOutIsInfo)[outIsiIdx]);
69 // Reset flags
70 for (i = 0; i < ASP_OUTIS_NUM_DEC_STAGES; i++)
71 {
72 pOutIsi->decStageOutInitSyncInfo[i].decFlag = 0;
73 }
75 // Leave the gate
76 GateMP_leave(gateHandle, key);
78 return ASP_OUTIS_SOK;
79 }
81 // Write dec stage flag
82 Int outIsWriteDecStageFlag(
83 PAF_AST_OutInitSyncCtl *pOutIsCtl, // Output Init-Sync Control
84 Int8 outIsiIdx, // Output Init-Sync Info index
85 Int8 decStageIdx, // dec stage index
86 Int8 decFlag // flag value to write (0/1)
87 )
88 {
89 IArg key;
90 GateMP_Handle gateHandle;
91 PAF_AST_OutInitSyncInfo *pOutIsi;
92 PAF_AST_DecStageOutInitSyncInfo *pDecStageOutIsi;
94 // Get gate handle
95 gateHandle = pOutIsCtl->gateHandle;
96 // Enter gate
97 key = GateMP_enter(gateHandle);
99 //
100 // Write decoder stage flag
101 //
103 // Get address of Output Init-Sync Info
104 pOutIsi = &((*pOutIsCtl->pXOutIsInfo)[outIsiIdx]);
105 // Get address of Decoder Output Init-Sync Info
106 pDecStageOutIsi = &pOutIsi->decStageOutInitSyncInfo[decStageIdx];
108 // Write flag value
109 pDecStageOutIsi->decFlag = decFlag;
111 // Leave the gate
112 GateMP_leave(gateHandle, key);
114 return ASP_OUTIS_SOK;
115 }
117 // Write dec stage flag and AF.
118 // Flag must be non-zero for write of AF.
119 Int outIsWriteDecStageFlagAndAf(
120 PAF_AST_OutInitSyncCtl *pOutIsCtl, // Output Init-Sync Control
121 Int8 outIsiIdx, // Output Init-Sync Info index
122 Int8 decStageIdx, // dec stage index
123 Int8 decFlag, // flag value to write (0/1)
124 PAF_AudioFrame *pDecAfWrt // audio frame to write
125 )
126 {
127 IArg key;
128 GateMP_Handle gateHandle;
129 PAF_AST_OutInitSyncInfo *pOutIsi;
130 PAF_AST_DecStageOutInitSyncInfo *pDecStageOutIsi;
132 // Get gate handle
133 gateHandle = pOutIsCtl->gateHandle;
134 // Enter gate
135 key = GateMP_enter(gateHandle);
137 //
138 // Write decoder stage audio frame
139 // Write decoder stage flag
140 //
142 // Get address of Output Init-Sync Info
143 pOutIsi = &((*pOutIsCtl->pXOutIsInfo)[outIsiIdx]);
144 // Get address of Decoder Output Init-Sync Info
145 pDecStageOutIsi = &pOutIsi->decStageOutInitSyncInfo[decStageIdx];
147 if (decFlag != 0)
148 {
149 // Write audio frame to Out IS
150 outIsCpyAf(pDecAfWrt, &pDecStageOutIsi->decAf);
151 }
153 // Write flag value
154 pDecStageOutIsi->decFlag = decFlag;
156 // Leave the gate
157 GateMP_leave(gateHandle, key);
159 return ASP_OUTIS_SOK;
160 }