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