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