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