]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/performance-audio-sr.git/blob - pasdk/test_dsp/framework/audioStreamOutProc.h
PASDK-71:Add PFP for (1) ASIT decode processing and (2) ASOT output processing
[processor-sdk/performance-audio-sr.git] / 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_
42  
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)(HeapMem_Handle hInternalHeap, HeapMem_Handle hInternal1Heap, HeapMem_Handle hExternalHeap, HeapMem_Handle hInternal1HeapShm);
97 } PAF_ASOT_Fxns;
99 // Audio Stream Output Task (ASOT) parameters
100 typedef struct PAF_ASOT_Params {
101     const PAF_ASOT_Fxns *fxns;
102     struct {
103         SmInt master;
104         SmInt inputs;
105         SmInt input1;
106         SmInt inputN;
107         SmInt decodes;
108         SmInt decode1;
109         SmInt decodeN;
110         SmInt streams;
111         SmInt stream1; /* unused */
112         SmInt streamN; /* unused */
113         SmInt encodes;
114         SmInt encode1;
115         SmInt encodeN;
116         SmInt outputs;
117         SmInt output1;
118         SmInt outputN;
119     } zone;
120     const SmInt *inputsFromDecodes;
121     const SmInt *outputsFromEncodes;
122     struct {
123         int *pHeapIdIntern;   //int *pIntern;
124         int *pHeapIdExtern;   //int *pExtern;
125         int *pHeapIdInpbuf;   //int *pInpbuf;
126         int *pHeapIdOutbuf;   //int *pOutbuf;
127         int *pHeapIdFrmbuf;   //int *pFrmbuf;
128         int *pHeapIdIntern1;  //int *pIntern1;
129         int clear; 
130     } heap;
131     struct {
132         const IALG_MemSpace *space;
133     } common;
134     const LgInt *z_rx_bufsiz;
135     const LgInt *z_tx_bufsiz;
136     const SmInt *z_numchan;
137     MdInt framelength;
138     const PAF_AudioFunctions *pAudioFrameFunctions;
139     const struct PAF_ASP_ChainFxns *pChainFxns;
140     const PAF_InpBufStatus *pInpBufStatus;
141     const PAF_DecodeStatus * const *z_pDecodeStatus;
142     const PAF_OutBufStatus *pOutBufStatus;
143     const PAF_EncodeStatus * const *z_pEncodeStatus;
144     const PAF_VolumeStatus *pVolumeStatus;
145     const PAF_ASP_AlgKey *pDecAlgKey;
146     const PAF_ASP_AlgKey *pEncAlgKey;
147     const PAF_ASP_SioMap *pDecSioMap;
148     const SmInt *streamsFromDecodes;
149     const SmInt *streamsFromEncodes;
150     const MdInt maxFramelength;
151     const SmInt *streamOrder;
152     const PAF_ASP_LinkInit * const (*i_inpLinkInit);
153     const PAF_ASP_LinkInit * const (*i_outLinkInit);
154     const PAF_ASP_outNumBufMap *  const (*poutNumBufMap);
155     const PAF_MetadataBufStatus *pMetadataBufStatus;
156     const PAF_AudioFrameBufStatus *pAudioFrameBufStatus;
157 } PAF_ASOT_Params;
159 // Audio Stream Output Task (ASOT) patchs
160 typedef struct PAF_ASOT_Patchs {
161     //const PAF_SIO_ParamsN * devinp;
162     const PAF_SIO_ParamsN * devout;
163     //const PAF_ASP_LinkInit * const (*i_decLinkInit);
164     const PAF_ASP_LinkInit * const (*i_aspLinkInit)[GEARS];
165     const PAF_ASP_LinkInit * const (*i_encLinkInit);
166 } PAF_ASOT_Patchs;
168 // Audio Stream Input Task (ASOT) configuration
169 typedef struct PAF_ASOT_Config {
170     Task_Handle taskHandle;     // ASOT handle
171     ACP_Handle acp;             // ASOT local ACP handle
172     PAF_ASPM_Config *pAspmCfg;  // ASIT/ASOT shared configuration
173     PAF_AST_Config *pAstCfg;    // ASIT/ASOT/ASDT shared configuration
174 } PAF_ASOT_Config;
177 //   Purpose:   Audio Stream Outpu Task Function for initialization of data pointers
178 //              by allocation of memory.
179 Int 
180 PAF_ASOT_initPhaseMalloc(
181     const PAF_ASOT_Params *pP, 
182     const PAF_ASOT_Patchs *pQ, 
183     PAF_ASOT_Config *pC
184 );
185     
186 //   Purpose:   Audio Stream Output Task Function for initialization of data values
187 //              from parameters.
188 Int
189 PAF_ASOT_initPhaseConfig(
190     const PAF_ASOT_Params *pP, 
191     const PAF_ASOT_Patchs *pQ, 
192     PAF_ASOT_Config *pC
193 );
195 //   Purpose:   Audio Stream Output Task Function for initialization of ACP by
196 //              instantiation of the algorithm.
197 Int
198 PAF_ASOT_initPhaseAcpAlg(
199     const PAF_ASOT_Params *pP, 
200     const PAF_ASOT_Patchs *pQ, 
201     PAF_ASOT_Config *pC
202 );
204 //   (***) FL: ASIT/ASOT currently consider common memory independently.
205 //             Should simultaneously consider all algs in ASIT/ASOT.
206 //   Purpose:   Audio Stream Output Task Function for allocation of common memory.
207 Int
208 PAF_ASOT_initPhaseCommon(
209     const PAF_ASOT_Params *pP, 
210     const PAF_ASOT_Patchs *pQ, 
211     PAF_ASOT_Config *pC
212 );
214 //   Purpose:   Audio Stream Output Task Function for initialization of ASP algorithms.
215 Int
216 PAF_ASOT_initPhaseAspAlg(
217     const PAF_ASOT_Params *pP, 
218     const PAF_ASOT_Patchs *pQ, 
219     PAF_ASOT_Config *pC
220 );
222 //   Purpose:   Audio Stream Output Task Function for initialization of data values
223 //              from parameters for Algorithm Keys.
224 Int
225 PAF_ASOT_initPhaseAlgKey(
226     const PAF_ASOT_Params *pP, 
227     const PAF_ASOT_Patchs *pQ, 
228     PAF_ASOT_Config *pC
229 );
231 //   Purpose:   Audio Stream Output Task Function for initialization of Input Devices.
232 Int
233 PAF_ASOT_initPhaseDevice(
234     const PAF_ASOT_Params *pP, 
235     const PAF_ASOT_Patchs *pQ, 
236     PAF_ASOT_Config *pC
237 );
239 //   Purpose:   Audio Stream Output Task Function for initialization of the Audio
240 //              Frame(s) by memory allocation and loading of data pointers
241 //              and values.
242 Int
243 PAF_ASOT_initFrame0(
244     const PAF_ASOT_Params *pP, 
245     const PAF_ASOT_Patchs *pQ, 
246     PAF_ASOT_Config *pC, 
247     Int z
248 );
250 //   Purpose:   Audio Stream Task Function for initialization or reinitiali-
251 //              zation of the Audio Frame(s) by loading of data values of a
252 //              time-varying nature.
253 Int
254 PAF_ASOT_initFrame1(
255     const PAF_ASOT_Params *pP, 
256     const PAF_ASOT_Patchs *pQ, 
257     PAF_ASOT_Config *pC, 
258     Int z, 
259     Int apply
260 );
262 //   Purpose:   Audio Stream Output Task Function for selecting the devices used
263 //              for output.
264 Int
265 PAF_ASOT_selectDevices(
266     const PAF_ASOT_Params *pP, 
267     const PAF_ASOT_Patchs *pQ, 
268     PAF_ASOT_Config *pC
269 );
271 //   Purpose:   Audio Stream Output Task Function for processing audio data.
272 //
273 Int
274 PAF_ASOT_decodeProcessing(
275     const PAF_ASOT_Params *pP, 
276     const PAF_ASOT_Patchs *pQ, 
277     PAF_ASOT_Config *pC, 
278     Int sourceSelect
279 );
281 //   Purpose:   Decoding Function for processing Encode Commands.
282 Int
283 PAF_ASOT_encodeCommand(
284     const PAF_ASOT_Params *pP, 
285     const PAF_ASOT_Patchs *pQ, 
286     PAF_ASOT_Config *pC
287 );
289 //   Purpose:   Decoding Function for reinitializing the decoding process.
290 Int
291 PAF_ASOT_decodeInit(
292     const PAF_ASOT_Params *pP, 
293     const PAF_ASOT_Patchs *pQ, 
294     PAF_ASOT_Config *pC, 
295     Int sourceSelect
296 );
298 //   Purpose:   Decoding Function for processing information in a manner that
299 //              is unique to initial frames of input data.
300 Int
301 PAF_ASOT_decodeInfo(
302     const PAF_ASOT_Params *pP, 
303     const PAF_ASOT_Patchs *pQ, 
304     PAF_ASOT_Config *pC, 
305     Int frame, 
306     Int block
307 );
309 //   Purpose:   Decoding Function for processing information in a manner that
310 //              is unique to initial frames of input data.
311 Int
312 PAF_ASOT_decodeInfo1(
313     const PAF_ASOT_Params *pP, 
314     const PAF_ASOT_Patchs *pQ, 
315     PAF_ASOT_Config *pC, 
316     Int frame, 
317     Int block
318 );
320 //   Purpose:   Decoding Function for processing information in a manner that
321 //              is unique to frames of input data other than the initial one.
322 Int
323 PAF_ASOT_decodeInfo2(
324     const PAF_ASOT_Params *pP, 
325     const PAF_ASOT_Patchs *pQ, 
326     PAF_ASOT_Config *pC, 
327     Int frame, 
328     Int block
329 );
331 //   Purpose:   Decoding Function for processing of audio frame data by the
332 //              ASP Algorithms.
333 Int
334 PAF_ASOT_decodeStream(
335     const PAF_ASOT_Params *pP, 
336     const PAF_ASOT_Patchs *pQ, 
337     PAF_ASOT_Config *pC, 
338     Int frame, 
339     Int block
340 );
342 //   Purpose:   Decoding Function for processing of audio frame data by the
343 //              Encode Algorithm.
344 Int
345 PAF_ASOT_decodeEncode(
346     const PAF_ASOT_Params *pP, 
347     const PAF_ASOT_Patchs *pQ, 
348     PAF_ASOT_Config *pC, 
349     Int frame, 
350     Int block
351 );
353 //   Purpose:   Decoding Function for terminating the decoding process.
354 Int
355 PAF_ASOT_decodeComplete(
356     const PAF_ASOT_Params *pP, 
357     const PAF_ASOT_Patchs *pQ, 
358     PAF_ASOT_Config *pC, 
359     ALG_Handle decAlg[], 
360     Int frame, 
361     Int block
362 );
364 //   Purpose:   Decoding Function for initiating output.
365 Int
366 PAF_ASOT_startOutput(
367     const PAF_ASOT_Params *pP, 
368     const PAF_ASOT_Patchs *pQ, 
369     PAF_ASOT_Config *pC
370 );
372 //   Purpose:   Decoding Function for terminating output.
373 Int
374 PAF_ASOT_stopOutput(
375     const PAF_ASOT_Params *pP, 
376     const PAF_ASOT_Patchs *pQ, 
377     PAF_ASOT_Config *pC
378 );
380 //   Purpose:   Decoding Function for re-initiating output.
381 Int
382 PAF_ASOT_setCheckRateX(
383     const PAF_ASOT_Params *pP, 
384     const PAF_ASOT_Patchs *pQ, 
385     PAF_ASOT_Config *pC, 
386     Int check
387 );
389 //   Purpose:   Common Function for processing algorithm chains.
390 Int
391 PAF_ASOT_streamChainFunction(
392     const PAF_ASOT_Params *pP, 
393     const PAF_ASOT_Patchs *pQ, 
394     PAF_ASOT_Config *pC, 
395     Int iChainFrameFxns, 
396     Int abortOnError, 
397     Int logArg
398 );
400 #endif /* _ASOP_H_ */