2 /*
3 Copyright (c) 2016, 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 * ======== audioStreamOutProc.h ========
38 */
40 #ifndef _ASOP_H_
41 #define _ASOP_H_
43 #include <xdc/std.h>
44 #include <ti/sysbios/knl/Task.h>
46 #include "audioStreamProc_params.h"
47 #include "audioStreamProc_patchs.h"
48 #include "audioStreamProc_config.h"
49 #include "audioStreamProc_master.h"
51 // Global debug counter */
52 extern Uint32 gTaskAsopCnt; // debug counter for ASOP task
54 struct PAF_ASOT_Params;
55 struct PAF_ASOT_Patchs;
56 struct PAF_ASOT_Config;
58 // Audio Stream Output Task (ASOT) parameters, functions
59 typedef struct PAF_ASOT_Fxns {
60 Int (*initPhase[8]) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *);
61 Int (*initFrame0) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, Int);
62 Int (*initFrame1) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, Int, Int);
63 //Int (*passProcessing) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *, Int);
64 //Int (*passProcessingCopy) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *);
65 //Int (*autoProcessing) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *, Int, ALG_Handle);
66 Int (*decodeProcessing) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, Int);
67 //Int (*decodeCommand) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *);
68 Int (*encodeCommand) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *);
69 Int (*decodeInit) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, Int);
70 //Int (*decodeInfo) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *, Int, Int);
71 Int (*decodeInfo1) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, Int, Int);
72 Int (*decodeInfo2) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, Int, Int);
73 //Int (*decodeCont) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *, ALG_Handle *, Int, Int);
74 //Int (*decodeDecode) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *, Int, Int, Int);
75 Int (*decodeStream) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, Int, Int);
76 Int (*decodeEncode) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, Int, Int);
77 //Int (*decodeFinalTest) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *, Int, Int);
78 Int (*decodeComplete) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, ALG_Handle *, Int, Int);
79 Int (*selectDevices) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *);
80 //Int (*sourceDecode) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *, Int);
81 Int (*startOutput) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *);
82 Int (*stopOutput) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *);
83 Int (*setCheckRateX) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, Int);
84 Int (*streamChainFunction) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, Int, Int, Int);
85 Int (*deviceAllocate) (SIO_Handle *, int, int, int, Ptr);
86 Int (*deviceSelect) (SIO_Handle *, int, int, Ptr);
87 //Int (*computeFrameLength) (Int, Int, Int);
88 //Int (*updateInputStatus) (SIO_Handle, PAF_InpBufStatus *, PAF_InpBufConfig *);
89 //Int (*copy) (Uns, PAF_InpBufConfig *, Uns, PAF_OutBufConfig *);
91 // For RAM_report
92 Void (*headerPrint)();
93 Int (*allocPrint)(const PAF_ALG_AllocInit *pInit, Int sizeofInit, PAF_IALG_Config *p);
94 Void (*commonPrint)(IALG_MemRec common[], PAF_IALG_Config *p);
95 Void (*bufMemPrint)(Int z, Int size, Int heapId, Int bufType);
96 Void (*memStatusPrint)(
97 CString header,
98 HeapMem_Handle hInternalHeap,
99 HeapMem_Handle hInternal1Heap,
100 HeapMem_Handle hExternalHeap,
101 HeapMem_Handle hInternal1HeapShm,
102 HeapMem_Handle hExternalHeapShm,
103 HeapMem_Handle hExternalNoncachedHeapShm);
104 } PAF_ASOT_Fxns;
106 // Audio Stream Output Task (ASOT) parameters
107 typedef struct PAF_ASOT_Params {
108 const PAF_ASOT_Fxns *fxns;
109 struct {
110 SmInt master;
111 SmInt inputs;
112 SmInt input1;
113 SmInt inputN;
114 SmInt decodes;
115 SmInt decode1;
116 SmInt decodeN;
117 SmInt streams;
118 SmInt stream1; /* unused */
119 SmInt streamN; /* unused */
120 SmInt encodes;
121 SmInt encode1;
122 SmInt encodeN;
123 SmInt outputs;
124 SmInt output1;
125 SmInt outputN;
126 } zone;
127 const SmInt *inputsFromDecodes;
128 const SmInt *outputsFromEncodes;
129 struct {
130 int *pHeapIdIntern; // INT memory heap ID
131 int *pHeapIdExtern; // EXT memory heap ID
132 int *pHeapIdInpbuf; // IB buffer heap ID
133 int *pHeapIdOutbuf; // OB buffer heap ID
134 int *pHeapIdFrmbuf; // Frame buffer heap ID
135 int *pHeapIdIntern1; // INT1 memory heap ID
136 int *pHeapIdInt1Shm; // INT1 SHared Memory heap ID
137 int *pHeapIdExtShm; // EXT SHared Memory heap ID
138 int *pHeapIdExtNonCachedShm; // EXT Non-Cached SHared Memory heap ID
139 int clear;
140 } heap;
141 struct {
142 const IALG_MemSpace *space;
143 } common;
144 const LgInt *z_rx_bufsiz;
145 const LgInt *z_tx_bufsiz;
146 const SmInt *z_numchan;
147 MdInt framelength;
148 const PAF_AudioFunctions *pAudioFrameFunctions;
149 const struct PAF_ASP_ChainFxns *pChainFxns;
150 const PAF_InpBufStatus *pInpBufStatus;
151 const PAF_DecodeStatus * const *z_pDecodeStatus;
152 const PAF_OutBufStatus *pOutBufStatus;
153 const PAF_EncodeStatus * const *z_pEncodeStatus;
154 const PAF_VolumeStatus *pVolumeStatus;
155 const PAF_ASP_AlgKey *pDecAlgKey;
156 const PAF_ASP_AlgKey *pEncAlgKey;
157 const PAF_ASP_SioMap *pDecSioMap;
158 const SmInt *streamsFromDecodes;
159 const SmInt *streamsFromEncodes;
160 const MdInt maxFramelength;
161 const SmInt *streamOrder;
162 const PAF_ASP_LinkInit * const (*i_inpLinkInit);
163 const PAF_ASP_LinkInit * const (*i_outLinkInit);
164 const PAF_ASP_outNumBufMap * const (*poutNumBufMap);
165 const PAF_MetadataBufStatus *pMetadataBufStatus;
166 const PAF_AudioFrameBufStatus *pAudioFrameBufStatus;
167 } PAF_ASOT_Params;
169 // Audio Stream Output Task (ASOT) patchs
170 typedef struct PAF_ASOT_Patchs {
171 //const PAF_SIO_ParamsN * devinp;
172 const PAF_SIO_ParamsN * devout;
173 //const PAF_ASP_LinkInit * const (*i_decLinkInit);
174 const PAF_ASP_LinkInit * const (*i_aspLinkInit)[GEARS];
175 const PAF_ASP_LinkInit * const (*i_encLinkInit);
176 } PAF_ASOT_Patchs;
178 // Audio Stream Input Task (ASOT) configuration
179 typedef struct PAF_ASOT_Config {
180 Task_Handle taskHandle; // ASOT handle
181 ACP_Handle acp; // ASOT local ACP handle
182 PAF_ASPM_Config *pAspmCfg; // ASIT/ASOT shared configuration
183 PAF_AST_Config *pAstCfg; // ASIT/ASOT/ASDT shared configuration
184 } PAF_ASOT_Config;
187 // Purpose: Audio Stream Outpu Task Function for initialization of data pointers
188 // by allocation of memory.
189 Int
190 PAF_ASOT_initPhaseMalloc(
191 const PAF_ASOT_Params *pP,
192 const PAF_ASOT_Patchs *pQ,
193 PAF_ASOT_Config *pC
194 );
196 // Purpose: Audio Stream Output Task Function for initialization of data values
197 // from parameters.
198 Int
199 PAF_ASOT_initPhaseConfig(
200 const PAF_ASOT_Params *pP,
201 const PAF_ASOT_Patchs *pQ,
202 PAF_ASOT_Config *pC
203 );
205 // Purpose: Audio Stream Output Task Function for initialization of ACP by
206 // instantiation of the algorithm.
207 Int
208 PAF_ASOT_initPhaseAcpAlg(
209 const PAF_ASOT_Params *pP,
210 const PAF_ASOT_Patchs *pQ,
211 PAF_ASOT_Config *pC
212 );
214 // (***) FL: ASIT/ASOT currently consider common memory independently.
215 // Should simultaneously consider all algs in ASIT/ASOT.
216 // Purpose: Audio Stream Output Task Function for allocation of common memory.
217 Int
218 PAF_ASOT_initPhaseCommon(
219 const PAF_ASOT_Params *pP,
220 const PAF_ASOT_Patchs *pQ,
221 PAF_ASOT_Config *pC
222 );
224 // Purpose: Audio Stream Output Task Function for initialization of ASP algorithms.
225 Int
226 PAF_ASOT_initPhaseAspAlg(
227 const PAF_ASOT_Params *pP,
228 const PAF_ASOT_Patchs *pQ,
229 PAF_ASOT_Config *pC
230 );
232 // Purpose: Audio Stream Output Task Function for initialization of data values
233 // from parameters for Algorithm Keys.
234 Int
235 PAF_ASOT_initPhaseAlgKey(
236 const PAF_ASOT_Params *pP,
237 const PAF_ASOT_Patchs *pQ,
238 PAF_ASOT_Config *pC
239 );
241 // Purpose: Audio Stream Output Task Function for initialization of Input Devices.
242 Int
243 PAF_ASOT_initPhaseDevice(
244 const PAF_ASOT_Params *pP,
245 const PAF_ASOT_Patchs *pQ,
246 PAF_ASOT_Config *pC
247 );
249 // Purpose: Audio Stream Output Task Function for initialization of the Audio
250 // Frame(s) by memory allocation and loading of data pointers
251 // and values.
252 Int
253 PAF_ASOT_initFrame0(
254 const PAF_ASOT_Params *pP,
255 const PAF_ASOT_Patchs *pQ,
256 PAF_ASOT_Config *pC,
257 Int z
258 );
260 // Purpose: Audio Stream Task Function for initialization or reinitiali-
261 // zation of the Audio Frame(s) by loading of data values of a
262 // time-varying nature.
263 Int
264 PAF_ASOT_initFrame1(
265 const PAF_ASOT_Params *pP,
266 const PAF_ASOT_Patchs *pQ,
267 PAF_ASOT_Config *pC,
268 Int z,
269 Int apply
270 );
272 // Purpose: Audio Stream Output Task Function for selecting the devices used
273 // for output.
274 Int
275 PAF_ASOT_selectDevices(
276 const PAF_ASOT_Params *pP,
277 const PAF_ASOT_Patchs *pQ,
278 PAF_ASOT_Config *pC
279 );
281 // Purpose: Audio Stream Output Task Function for processing audio data.
282 //
283 Int
284 PAF_ASOT_decodeProcessing(
285 const PAF_ASOT_Params *pP,
286 const PAF_ASOT_Patchs *pQ,
287 PAF_ASOT_Config *pC,
288 Int sourceSelect
289 );
291 // Purpose: Decoding Function for processing Encode Commands.
292 Int
293 PAF_ASOT_encodeCommand(
294 const PAF_ASOT_Params *pP,
295 const PAF_ASOT_Patchs *pQ,
296 PAF_ASOT_Config *pC
297 );
299 // Purpose: Decoding Function for reinitializing the decoding process.
300 Int
301 PAF_ASOT_decodeInit(
302 const PAF_ASOT_Params *pP,
303 const PAF_ASOT_Patchs *pQ,
304 PAF_ASOT_Config *pC,
305 Int sourceSelect
306 );
308 // Purpose: Decoding Function for processing information in a manner that
309 // is unique to initial frames of input data.
310 Int
311 PAF_ASOT_decodeInfo(
312 const PAF_ASOT_Params *pP,
313 const PAF_ASOT_Patchs *pQ,
314 PAF_ASOT_Config *pC,
315 Int frame,
316 Int block
317 );
319 // Purpose: Decoding Function for processing information in a manner that
320 // is unique to initial frames of input data.
321 Int
322 PAF_ASOT_decodeInfo1(
323 const PAF_ASOT_Params *pP,
324 const PAF_ASOT_Patchs *pQ,
325 PAF_ASOT_Config *pC,
326 Int frame,
327 Int block
328 );
330 // Purpose: Decoding Function for processing information in a manner that
331 // is unique to frames of input data other than the initial one.
332 Int
333 PAF_ASOT_decodeInfo2(
334 const PAF_ASOT_Params *pP,
335 const PAF_ASOT_Patchs *pQ,
336 PAF_ASOT_Config *pC,
337 Int frame,
338 Int block
339 );
341 // Purpose: Decoding Function for processing of audio frame data by the
342 // ASP Algorithms.
343 Int
344 PAF_ASOT_decodeStream(
345 const PAF_ASOT_Params *pP,
346 const PAF_ASOT_Patchs *pQ,
347 PAF_ASOT_Config *pC,
348 Int frame,
349 Int block
350 );
352 // Purpose: Decoding Function for processing of audio frame data by the
353 // Encode Algorithm.
354 Int
355 PAF_ASOT_decodeEncode(
356 const PAF_ASOT_Params *pP,
357 const PAF_ASOT_Patchs *pQ,
358 PAF_ASOT_Config *pC,
359 Int frame,
360 Int block
361 );
363 // Purpose: Decoding Function for terminating the decoding process.
364 Int
365 PAF_ASOT_decodeComplete(
366 const PAF_ASOT_Params *pP,
367 const PAF_ASOT_Patchs *pQ,
368 PAF_ASOT_Config *pC,
369 ALG_Handle decAlg[],
370 Int frame,
371 Int block
372 );
374 // Purpose: Decoding Function for initiating output.
375 Int
376 PAF_ASOT_startOutput(
377 const PAF_ASOT_Params *pP,
378 const PAF_ASOT_Patchs *pQ,
379 PAF_ASOT_Config *pC
380 );
382 // Purpose: Decoding Function for terminating output.
383 Int
384 PAF_ASOT_stopOutput(
385 const PAF_ASOT_Params *pP,
386 const PAF_ASOT_Patchs *pQ,
387 PAF_ASOT_Config *pC
388 );
390 // Purpose: Decoding Function for re-initiating output.
391 Int
392 PAF_ASOT_setCheckRateX(
393 const PAF_ASOT_Params *pP,
394 const PAF_ASOT_Patchs *pQ,
395 PAF_ASOT_Config *pC,
396 Int check
397 );
399 // Purpose: Common Function for processing algorithm chains.
400 Int
401 PAF_ASOT_streamChainFunction(
402 const PAF_ASOT_Params *pP,
403 const PAF_ASOT_Patchs *pQ,
404 PAF_ASOT_Config *pC,
405 Int iChainFrameFxns,
406 Int abortOnError,
407 Int logArg
408 );
410 #endif /* _ASOP_H_ */