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