Home | History | Annotate | Download | only in inc
      1 
      2 /*
      3  * Copyright (C) Texas Instruments - http://www.ti.com/
      4  *
      5  * This library is free software; you can redistribute it and/or
      6  * modify it under the terms of the GNU Lesser General Public
      7  * License as published by the Free Software Foundation; either
      8  * version 2.1 of the License, or (at your option) any later version.
      9  *
     10  *
     11  * This library is distributed in the hope that it will be useful,
     12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     14  * Lesser General Public License for more details.
     15  *
     16  *
     17  * You should have received a copy of the GNU Lesser General Public
     18  * License along with this library; if not, write to the Free Software
     19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
     20  */
     21 /* =============================================================================
     22  *             Texas Instruments OMAP(TM) Platform Software
     23  *  (c) Copyright Texas Instruments, Incorporated.  All Rights Reserved.
     24  *
     25  *  Use of this software is controlled by the terms and conditions found
     26  *  in the license agreement under which this software has been supplied.
     27  * ============================================================================ */
     28 /**
     29  * @file OMX_G726Decoder.h
     30  *
     31  * This is an header file for an audio G726 decoder that is fully
     32  * compliant with the OMX Audio specification.
     33  * This the file is used internally by the component
     34  * in its code.
     35  *
     36  * @path  $(CSLPATH)\OMAPSW_MPU\linux\audio\src\openmax_il\g726_dec\inc\
     37  *
     38  * @rev 1.0
     39  */
     40 /* --------------------------------------------------------------------------- */
     41 
     42 
     43 #ifndef OMX_G726DEC_UTILS__H
     44 #define OMX_G726DEC_UTILS__H
     45 
     46 #include <OMX_Component.h>
     47 #include "LCML_DspCodec.h"
     48 
     49 #ifdef UNDER_CE
     50 #include <windows.h>
     51 #include <oaf_osal.h>
     52 #include <omx_core.h>
     53 #include <stdlib.h>
     54 #else
     55 #include <pthread.h>
     56 #ifdef RESOURCE_MANAGER_ENABLED
     57 #include <ResourceManagerProxyAPI.h>
     58 #endif
     59 #endif
     60 
     61 
     62 #undef G726DEC_DEBUG           /* See all debug statement of the component */
     63 #undef G726DEC_MEMDETAILS      /* See memory details of the component */
     64 #undef G726DEC_BUFDETAILS      /* See buffers details of the component */
     65 #undef G726DEC_STATEDETAILS    /* See all state transitions of the component */
     66 
     67 #define MAX_NUM_OF_BUFS 4 /* Max number of buffers used */
     68 #define G726D_NUM_INPUT_BUFFERS 1  /* Default number of input buffers */
     69 #define G726D_NUM_OUTPUT_BUFFERS 1 /* Default number of output buffers */
     70 #define G726D_INPUT_BUFFER_SIZE  20 /* Default size of input buffer */
     71 #define G726D_OUTPUT_BUFFER_SIZE 320 /* Default size of output buffer */
     72 #define NUM_OF_PORTS 2 /* Number of ports of component */
     73 #define INVALID_SAMPLING_FREQ  51
     74 #define EXIT_COMPONENT_THRD  10
     75 #define G726DEC_MAJOR_VER 1 /* Majer version of the component */
     76 #define G726DEC_MINOR_VER 1 /* Minor version of the component */
     77 #define G726DEC_BUFHEADER_VERSION 0x0 /* Version of the buffer header struct */
     78 #define NOT_USED 10 /* To specify that a particulat field is not used */
     79 #define NORMAL_BUFFER 0 /* Marks a buffer as normal buffer i.e. not last buffer */
     80 #define OMX_G726DEC_DEFAULT_SEGMENT (0) /* Default segment ID */
     81 #define OMX_G726DEC_SN_TIMEOUT (-1) /* timeout, wait until ack is received */
     82 #define OMX_G726DEC_SN_PRIORITY (10) /* Priority used by DSP */
     83 #define G726DEC_CPU 50 /* TBD, 50MHz for the moment */
     84 
     85 
     86 /* G726 frame size IN BYTES */
     87 #define SPEECH16_FRAME_SIZE 20
     88 #define  SPEECH24_FRAME_SIZE 30
     89 #define  SPEECH32_FRAME_SIZE 40
     90 #define  SPEECH40_FRAME_SIZE 50
     91 
     92 /* G726 frame type */
     93 #define SPEECH63_FRAME_TYPE 0    /* No tx frame */
     94 #define SPEECH53_FRAME_TYPE 1    /* Speech Frame flag */
     95 #define SID_FRAME_TYPE 2    /* SID frame flag */
     96 #define NODATA_FRAME 3    /* Erasure frame flag */
     97 
     98 #ifdef UNDER_CE
     99 #define USN_DLL_NAME "\\windows\\usn.dll64P" /* Path of USN DLL */
    100 #define G726DEC_DLL_NAME "\\windows\\g726dec_sn.dll64P" /* Path of G726 SN DLL */
    101 #else
    102 #define USN_DLL_NAME "usn.dll64P" /* Path of USN DLL */
    103 #define G726DEC_DLL_NAME "g726dec_sn.dll64P" /* Path of G726 SN DLL */
    104 #endif
    105 
    106 #define DONT_CARE 0 /* Value unused or ignored */
    107 #define G726DEC_BUFDETAILS
    108 /** Default timeout used to come out of blocking calls*/
    109 #define G726D_TIMEOUT 1 /* seconds */
    110 
    111 #ifdef UNDER_CE
    112 
    113 #ifdef DEBUG
    114 #define G726DEC_DPRINT   printf
    115 #define G726DEC_EPRINT   printf
    116 #define G726DEC_MEMPRINT   printf
    117 #define G726DEC_STATEPRINT   printf
    118 #define G726DEC_BUFPRINT   printf
    119 #else
    120 #define G726DEC_DPRINT
    121 #define G726DEC_EPRINT
    122 #define G726DEC_MEMPRINT
    123 #define G726DEC_STATEPRINT
    124 #define G726DEC_BUFPRINT
    125 #endif
    126 
    127 #else /* for Linux */
    128 
    129 #ifdef  G726DEC_DEBUG
    130 
    131 #define G726DEC_DPRINT(...)  fprintf(stdout, "%s %d::  ",__FUNCTION__, __LINE__); \
    132     fprintf(stdout, __VA_ARGS__);                                       \
    133     fprintf(stdout, "\n");
    134 
    135 #define G726DEC_BUFPRINT printf
    136 #define G726DEC_MEMPRINT printf
    137 #define G726DEC_STATEPRINT printf
    138 
    139 #else
    140 #define G726DEC_DPRINT(...)
    141 
    142 #ifdef G726DEC_STATEDETAILS
    143 #define G726DEC_STATEPRINT printf
    144 #else
    145 #define G726DEC_STATEPRINT(...)
    146 #endif
    147 
    148 #ifdef G726DEC_BUFDETAILS
    149 #define G726DEC_BUFPRINT printf
    150 #else
    151 #define G726DEC_BUFPRINT(...)
    152 #endif
    153 
    154 #ifdef G726DEC_MEMDETAILS
    155 #define G726DEC_MEMPRINT(...)  fprintf(stdout, "%s %d::  ",__FUNCTION__, __LINE__); \
    156     fprintf(stdout, __VA_ARGS__);                                       \
    157     fprintf(stdout, "\n");
    158 #else
    159 #define G726DEC_MEMPRINT(...)
    160 #endif
    161 
    162 #endif
    163 
    164 #define G726DEC_EPRINT(...)  fprintf(stdout, "%s %s %d::  ", __FILE__,__FUNCTION__, __LINE__); \
    165     fprintf(stdout, __VA_ARGS__);                                       \
    166     fprintf(stdout, "\n");
    167 
    168 #endif /*for UNDER_CE*/
    169 
    170 #define G726D_OMX_MALLOC(_pStruct_, _sName_)                        \
    171     _pStruct_ = (_sName_*)malloc(sizeof(_sName_));                  \
    172     if(_pStruct_ == NULL){                                          \
    173         printf("***********************************\n");            \
    174         printf("%d :: Malloc Failed\n",__LINE__);                   \
    175         printf("***********************************\n");            \
    176         eError = OMX_ErrorInsufficientResources;                    \
    177         goto EXIT;                                                  \
    178     }                                                               \
    179     memset(_pStruct_,0,sizeof(_sName_));                            \
    180     G726DEC_MEMPRINT("%d :: Malloced = %p\n",__LINE__,_pStruct_);
    181 
    182 
    183 
    184 #define G726D_OMX_MALLOC_SIZE(_ptr_, _size_,_name_)             \
    185     _ptr_ = (_name_ *)malloc(_size_);                           \
    186     if(_ptr_ == NULL){                                          \
    187         printf("***********************************\n");        \
    188         printf("%d :: Malloc Failed\n",__LINE__);               \
    189         printf("***********************************\n");        \
    190         eError = OMX_ErrorInsufficientResources;                \
    191         goto EXIT;                                              \
    192     }                                                           \
    193     memset(_ptr_,0,_size_);                                     \
    194     G726DEC_MEMPRINT("%d :: Malloced = %p\n",__LINE__,_ptr_);
    195 
    196 #define G726D_OMX_ERROR_EXIT(_e_, _c_, _s_)                             \
    197     _e_ = _c_;                                                          \
    198     printf("\n**************** OMX ERROR ************************\n");  \
    199     printf("%d : Error Name: %s : Error Num = %x",__LINE__, _s_, _e_);  \
    200     printf("\n**************** OMX ERROR ************************\n");  \
    201     goto EXIT;
    202 
    203 
    204 #define G726D_OMX_CONF_CHECK_CMD(_ptr1, _ptr2, _ptr3)   \
    205     {                                                   \
    206         if(!_ptr1 || !_ptr2 || !_ptr3){                 \
    207             eError = OMX_ErrorBadParameter;             \
    208             goto EXIT;                                  \
    209         }                                               \
    210     }
    211 
    212 #define G726D_OMX_FREE(ptr)                                             \
    213     if(NULL != ptr) {                                                   \
    214         G726DEC_MEMPRINT("%d :: Freeing Address = %p\n",__LINE__,ptr);  \
    215         free(ptr);                                                      \
    216         ptr = NULL;                                                     \
    217     }
    218 
    219 #define OMX_CONF_INIT_STRUCT(_s_, _name_)       \
    220     memset((_s_), 0x0, sizeof(_name_));         \
    221     (_s_)->nSize = sizeof(_name_);              \
    222     (_s_)->nVersion.s.nVersionMajor = 0x1;      \
    223     (_s_)->nVersion.s.nVersionMinor = 0x1;      \
    224     (_s_)->nVersion.s.nRevision = 0x0;          \
    225     (_s_)->nVersion.s.nStep = 0x0
    226 
    227 
    228 /* ======================================================================= */
    229 /** OMX_G726DEC_INDEXAUDIOTYPE  Defines the custom configuration settings
    230  *                              for the component
    231  *
    232  *  @param  OMX_IndexCustomG726DecModeDasfConfig      Sets the DASF mode
    233  *
    234  */
    235 /*  ==================================================================== */
    236 typedef enum OMX_G726DEC_INDEXAUDIOTYPE {
    237     /*OMX_IndexCustomG726DecModeDasfConfig = OMX_IndexIndexVendorStartUnused + 1,*/
    238     OMX_IndexCustomG726DecModeDasfConfig = 0xFF000001,
    239     OMX_IndexCustomG726DecHeaderInfoConfig,
    240     OMX_IndexCustomG726DecStreamIDConfig,
    241     OMX_IndexCustomG726DecDataPath
    242 }OMX_G726DEC_INDEXAUDIOTYPE;
    243 
    244 
    245 /* ============================================================================== * */
    246 /** G726D_COMP_PORT_TYPE  describes the input and output port of indices of the
    247  * component.
    248  *
    249  * @param  G726D_INPUT_PORT  Input port index
    250  *
    251  * @param  G726D_OUTPUT_PORT Output port index
    252  */
    253 /* ============================================================================ * */
    254 typedef enum G726D_COMP_PORT_TYPE {
    255     G726D_INPUT_PORT = 0,
    256     G726D_OUTPUT_PORT
    257 }G726D_COMP_PORT_TYPE;
    258 
    259 /* ======================================================================= */
    260 /** G726DEC_ParamStruct: This struct is passed with input buffers that
    261  * are sent to DSP.
    262  */
    263 /* ==================================================================== */
    264 typedef struct {
    265     /* Set to 1 if buffer is last buffer */
    266     unsigned long usLastFrame;
    267 }G726DEC_FrameStruct;
    268 
    269 
    270 /* ======================================================================= */
    271 /** G726DEC_UAlgInBufParamStruct: This struct is passed with input buffers that
    272  * are sent to DSP.
    273  */
    274 /* ==================================================================== */
    275 typedef struct {
    276     /* Set to 1 if buffer is last buffer */
    277     unsigned short bLastBuffer;
    278 }G726DEC_UAlgInBufParamStruct;
    279 
    280 
    281 /* ======================================================================= */
    282 /** G726D_USN_AudioCodecParams: This contains the information which does to Codec
    283  * on DSP
    284  * are sent to DSP.
    285  */
    286 /* ==================================================================== */
    287 typedef struct USN_AudioCodecParams{
    288     /* Specifies the sample frequency */
    289     unsigned long ulSamplingFreq;
    290     /* Specifies the UUID */
    291     unsigned long unUUID;
    292     /* Specifies the audio format */
    293     unsigned short unAudioFormat;
    294 }G726D_USN_AudioCodecParams;
    295 
    296 /* ======================================================================= */
    297 /** G726DEC_UAlgOutBufParamStruct: This is passed with output buffer to DSP.
    298  */
    299 /* ==================================================================== */
    300 typedef struct {
    301     /* Number of frames in a buffer */
    302     unsigned long ulFrameCount;
    303 }G726DEC_UAlgOutBufParamStruct;
    304 
    305 /* ======================================================================= */
    306 /** G726D_LCML_BUFHEADERTYPE: This is LCML buffer header which is sent to LCML
    307  * for both input and output buffers.
    308  */
    309 /* ==================================================================== */
    310 typedef struct G726D_LCML_BUFHEADERTYPE {
    311     /* Direction whether input or output buffer */
    312     OMX_DIRTYPE eDir;
    313     /* Pointer to OMX Buffer Header */
    314     OMX_BUFFERHEADERTYPE *pBufHdr;
    315     /* Other parameters, may be useful for enhancements */
    316     void *pOtherParams[10];
    317     /* Input Parameter Information structure */
    318     G726DEC_UAlgInBufParamStruct *pFrameParam;
    319 }G726D_LCML_BUFHEADERTYPE;
    320 
    321 /* ======================================================================= */
    322 /** G726D_AUDIODEC_PORT_TYPE: This contains component port information.
    323  *
    324  * @see OMX_AUDIO_PARAM_PORTFORMATTYPE
    325  */
    326 /* ==================================================================== */
    327 typedef struct AUDIODEC_PORT_TYPE {
    328     /* Used in tunneling, this is handle of tunneled component */
    329     OMX_HANDLETYPE hTunnelComponent;
    330     /* Port which has to be tunneled */
    331     OMX_U32 nTunnelPort;
    332     /* Buffer Supplier Information */
    333     OMX_BUFFERSUPPLIERTYPE eSupplierSetting;
    334     /* Number of buffers */
    335     OMX_U8 nBufferCnt;
    336     /* Port format information */
    337     OMX_AUDIO_PARAM_PORTFORMATTYPE* pPortFormat;
    338 } G726D_AUDIODEC_PORT_TYPE;
    339 
    340 
    341 /* ======================================================================= */
    342 /** _G726D_BUFFERLIST: This contains information about a buffer's owner whether
    343  * it is application or component, number of buffers owned etc.
    344  *
    345  * @see OMX_BUFFERHEADERTYPE
    346  */
    347 /* ==================================================================== */
    348 struct _G726D_BUFFERLIST{
    349     /* Array of pointer to OMX buffer headers */
    350     OMX_BUFFERHEADERTYPE *pBufHdr[MAX_NUM_OF_BUFS];
    351     /* Array that tells about owner of each buffer */
    352     OMX_U32 bufferOwner[MAX_NUM_OF_BUFS];
    353     OMX_U32 bBufferPending[MAX_NUM_OF_BUFS];
    354     /* Number of buffers  */
    355     OMX_U32 numBuffers;
    356 };
    357 
    358 typedef struct _G726D_BUFFERLIST G726D_BUFFERLIST;
    359 
    360 #ifdef UNDER_CE
    361 #ifndef _OMX_EVENT_
    362 #define _OMX_EVENT_
    363 typedef struct OMX_Event {
    364     HANDLE event;
    365 } OMX_Event;
    366 #endif
    367 int OMX_CreateEvent(OMX_Event *event);
    368 int OMX_SignalEvent(OMX_Event *event);
    369 int OMX_WaitForEvent(OMX_Event *event);
    370 int OMX_DestroyEvent(OMX_Event *event);
    371 #endif
    372 
    373 /* ======================================================================= */
    374 /** G726DEC_COMPONENT_PRIVATE: This is the major and main structure of the
    375  * component which contains all type of information of buffers, ports etc
    376  * contained in the component.
    377  *
    378  * @see OMX_BUFFERHEADERTYPE
    379  * @see OMX_AUDIO_PARAM_PORTFORMATTYPE
    380  * @see OMX_PARAM_PORTDEFINITIONTYPE
    381  * @see G726D_LCML_BUFHEADERTYPE
    382  * @see OMX_PORT_PARAM_TYPE
    383  * @see OMX_PRIORITYMGMTTYPE
    384  * @see G726D_AUDIODEC_PORT_TYPE
    385  * @see G726D_BUFFERLIST
    386  * @see G726D_AUDIODEC_PORT_TYPE
    387  * @see LCML_STRMATTR
    388  * @see
    389  */
    390 /* ==================================================================== */
    391 typedef struct G726DEC_COMPONENT_PRIVATE
    392 {
    393     /** Handle for use with async callbacks */
    394     OMX_CALLBACKTYPE cbInfo;
    395 
    396     /* Component port information */
    397     OMX_PORT_PARAM_TYPE *sPortParam;
    398 
    399     /* Input port information */
    400     OMX_AUDIO_PARAM_PORTFORMATTYPE sInPortFormat;
    401 
    402     /* Output port information */
    403     OMX_AUDIO_PARAM_PORTFORMATTYPE sOutPortFormat;
    404 
    405     /* Buffer owner information */
    406     OMX_U32 bIsBufferOwned[NUM_OF_PORTS];
    407 
    408     /** Number of input buffers at runtime */
    409     OMX_U32 nRuntimeInputBuffers;
    410 
    411     /** Number of output buffers at runtime */
    412     OMX_U32 nRuntimeOutputBuffers;
    413 
    414     /* Audio codec parameters structure */
    415     G726D_USN_AudioCodecParams *pParams;
    416 
    417     /** This will contain info like how many buffers
    418         are there for input/output ports, their size etc, but not
    419         BUFFERHEADERTYPE POINTERS. */
    420     OMX_PARAM_PORTDEFINITIONTYPE* pPortDef[NUM_OF_PORTS];
    421 
    422     /* Contains information that come from application */
    423     OMX_AUDIO_PARAM_G726TYPE* G726Params;
    424 
    425     /* Contains information that come from application */
    426     OMX_AUDIO_PARAM_PCMMODETYPE* PcmParams;
    427 
    428     /** This is component handle */
    429     OMX_COMPONENTTYPE* pHandle;
    430 
    431     /** Current state of this component */
    432     OMX_STATETYPE curState;
    433 
    434     /** The component thread handle */
    435     pthread_t ComponentThread;
    436 
    437     /** The pipes for sending buffers to the thread */
    438     int dataPipe[2];
    439 
    440     /** The pipes for sending buffers to the thread */
    441     int cmdPipe[2];
    442 
    443     /** The pipes for sending command data to the thread */
    444     int cmdDataPipe[2];
    445 
    446     /** The pipes for sending buffers to the thread */
    447     int lcml_Pipe[2];
    448 
    449     /** Set to indicate component is stopping */
    450     OMX_U32 bIsEOFSent;
    451 
    452     /** Count of number of buffers outstanding with bridge */
    453     OMX_U32 lcml_nIpBuf;
    454 
    455     /** Count of number of buffers outstanding with bridge */
    456     OMX_U32 lcml_nOpBuf;
    457 
    458     /** Counts of number of input buffers sent to LCML */
    459     OMX_U32 lcml_nCntIp;
    460 
    461     /** Counts of number of input buffers received from LCML */
    462     OMX_U32 lcml_nCntIpRes;
    463 
    464     /** Counts of number of output buffers sent to LCML */
    465     OMX_U32 lcml_nCntOp;
    466 
    467     /** Counts of number of output buffers received from LCML */
    468     OMX_U32 lcml_nCntOpReceived;
    469 
    470     /** Counts of number of buffers sent to App  */
    471     OMX_U32 lcml_nCntApp;
    472 
    473     /** Counts of number of buffers received from App  */
    474     OMX_U32 app_nBuf;
    475 
    476     /** Counts of number of output buffers reclaimed from lcml  */
    477     OMX_U32 num_Reclaimed_Op_Buff;
    478 
    479     /** Counts of number of input buffers sent to lcml  */
    480     OMX_U32 num_Sent_Ip_Buff;
    481 
    482     /** Counts of number of output buffers sent to lcml  */
    483     OMX_U32 num_Op_Issued;
    484 
    485     /** Holds the value of dasf mode, 1: DASF mode or 0: File Mode  */
    486     OMX_U32 dasfmode;
    487 
    488     /* contains the value indicating if linear or rtp is used */
    489     OMX_U32 packingType;
    490 
    491     /* contains the string for the hardware device */
    492     OMX_STRING* sDeviceString;
    493 
    494     /** This is LCML handle  */
    495     OMX_HANDLETYPE pLcmlHandle;
    496 
    497     /** Contains pointers to LCML Buffer Headers */
    498     G726D_LCML_BUFHEADERTYPE *pLcmlBufHeader[2];
    499 
    500     /*contains a flag for if the buffers are allocated */
    501     OMX_U32 bBufferIsAllocated;
    502 
    503     /** Tells whether buffers on ports have been allocated */
    504     OMX_U32 bPortDefsAllocated;
    505 
    506     /** Tells whether component thread has started */
    507     OMX_U32 bCompThreadStarted;
    508 
    509     /** Marks the buffer data  */
    510     OMX_PTR pMarkData;
    511 
    512     /** Marks the buffer */
    513     OMX_MARKTYPE *pMarkBuf;
    514 
    515     /** Marks the target component */
    516     OMX_HANDLETYPE hMarkTargetComponent;
    517 
    518     /** Flag to track when input buffer's filled length is 0 */
    519     OMX_U32 bBypassDSP;
    520 
    521     /** Input port enable flag */
    522     int ipPortEnableFlag;
    523 
    524     /** Input port disble flag */
    525     int ipPortDisableFlag;
    526 
    527     /** Pointer to port parameter structure */
    528     OMX_PORT_PARAM_TYPE* pPortParamType;
    529 
    530     /** Pointer to port priority management structure */
    531     OMX_PRIORITYMGMTTYPE* pPriorityMgmt;
    532 
    533     /** Contains the port related info of both the ports */
    534     G726D_AUDIODEC_PORT_TYPE *pCompPort[NUM_OF_PORTS];
    535 
    536     /* Checks whether or not buffer were allocated by appliction */
    537     int bufAlloced;
    538 
    539     /** Flag to check about execution of component thread */
    540     OMX_U16 bExitCompThrd;
    541 
    542     /** Pointer to list of input buffers */
    543     G726D_BUFFERLIST *pInputBufferList;
    544 
    545     /** Pointer to list of output buffers */
    546     G726D_BUFFERLIST *pOutputBufferList;
    547 
    548     /** it is used for component's create phase arguments */
    549     LCML_STRMATTR  *strmAttr;
    550 
    551     /** Contains the version information */
    552     OMX_U32 nVersion;
    553 
    554     /** ACDN mode flag */
    555     OMX_U32 acdnmode;
    556 
    557     /** Audio Stream ID */
    558     OMX_U32 streamID;
    559 
    560     /* flag if the lcml handle is opened */
    561     int bLcmlHandleOpened;
    562 
    563     /* counts the calls to FillThisBuffer() */
    564     OMX_U32 nFillThisBufferCount;
    565 
    566     /** Counts number of FillBufferDone calls*/
    567     OMX_U32 nFillBufferDoneCount;
    568 
    569     /** Counts number of EmptyThisBuffer calls*/
    570     OMX_U32 nEmptyThisBufferCount;
    571 
    572     /** Counts number of EmptyBufferDone calls*/
    573     OMX_U32 nEmptyBufferDoneCount;
    574 
    575     /** Checks if component Init Params have been initialized */
    576     OMX_U32 bInitParamsInitialized;
    577 
    578     /* list of input buffers */
    579     G726D_BUFFERLIST *pInputBufferListQueue;
    580 
    581     /* list of output buffers */
    582     G726D_BUFFERLIST *pOutputBufferListQueue;
    583 
    584     /* array of pending input buffers headers */
    585     OMX_BUFFERHEADERTYPE *pInputBufHdrPending[MAX_NUM_OF_BUFS];
    586 
    587     /* number of pending input buffers */
    588     OMX_U32 nNumInputBufPending;
    589 
    590     /* array of pending output buffers */
    591     OMX_BUFFERHEADERTYPE *pOutputBufHdrPending[MAX_NUM_OF_BUFS];
    592 
    593     /* number of pending output buffers */
    594     OMX_U32 nNumOutputBufPending;
    595 
    596     /* array of buffers received while paused */
    597     OMX_BUFFERHEADERTYPE *pOutBufHdrWhilePaused[MAX_NUM_OF_BUFS];
    598 
    599     /* number of buffers received while paused */
    600     OMX_U32 nPendingOutPausedBufs;
    601 
    602     /* flag if disable port command is pending */
    603     OMX_U32 bDisableCommandPending;
    604 
    605     /* params for disable port command */
    606     OMX_U32 bDisableCommandParam;
    607 
    608     /* number of invalid frames received */
    609     OMX_U32 nInvalidFrameCount;
    610 
    611     /* number of pending buffers */
    612     OMX_U32 numPendingBuffers;
    613 
    614     /* flag for if component should go to idle state when stopped */
    615     OMX_U32 bNoIdleOnStop;
    616 
    617     /* flag for if dsp is stopped while component is in executing state */
    618     OMX_U32 bDspStoppedWhileExecuting;
    619 
    620     /* flag for if transition to idle state is pending */
    621     OMX_U32 bIdleCommandPending;
    622 
    623     /* number of FillThisBuffer calls pending */
    624     OMX_U32 nOutStandingFillDones;
    625 
    626     /* coutns the number of unhandled FillThisBuffer() calls */
    627     OMX_U8 nUnhandledFillThisBuffers;
    628 
    629     /* coutns the number of unhandled EmptyThisBuffer() calls */
    630     OMX_U8 nUnhandledEmptyThisBuffers;
    631 
    632     /* flag if the flush command is pending in Output Port */
    633     OMX_BOOL bFlushOutputPortCommandPending;
    634 
    635     /* flag if the flush command is pending in Output Port */
    636     OMX_BOOL bFlushInputPortCommandPending;
    637 
    638 #ifndef UNDER_CE
    639     /* mutex for allocating buffers */
    640     pthread_mutex_t AlloBuf_mutex;
    641     pthread_cond_t AlloBuf_threshold;
    642     OMX_U8 AlloBuf_waitingsignal;
    643 
    644     /*mutex for transition from loaded state to idle state */
    645     pthread_mutex_t InLoaded_mutex;
    646     pthread_cond_t InLoaded_threshold;
    647     OMX_U8 InLoaded_readytoidle;
    648 
    649     /* mutex for transition from idle state to loaded state */
    650     pthread_mutex_t InIdle_mutex;
    651     pthread_cond_t InIdle_threshold;
    652     OMX_U8 InIdle_goingtoloaded;
    653 #else
    654     OMX_Event AlloBuf_event;
    655     OMX_U8 AlloBuf_waitingsignal;
    656 
    657     OMX_Event InLoaded_event;
    658     OMX_U8 InLoaded_readytoidle;
    659 
    660     OMX_Event InIdle_event;
    661     OMX_U8 InIdle_goingtoloaded;
    662 #endif
    663 
    664     /* flag if transition to loaded is pending */
    665     OMX_BOOL bLoadedCommandPending;
    666 
    667     /* contains the OMX defined role of the component */
    668     /* not used in non-standard components */
    669     OMX_PARAM_COMPONENTROLETYPE *componentRole;
    670 
    671     /* describes the OMX_IL version inluding major, minor */
    672     OMX_VERSIONTYPE ComponentVersion;
    673 
    674     /* holds the name of the component */
    675     OMX_STRING cComponentName;
    676 
    677     /** Keep buffer timestamps **/
    678     OMX_S64 arrTimestamp[MAX_NUM_OF_BUFS];
    679 
    680     /** Keep buffer tick count **/
    681     OMX_S64 arrTickCount[MAX_NUM_OF_BUFS];
    682 
    683     /** Index to arrBufIndex[], used for input buffer timestamps */
    684     OMX_U8 IpBufindex;
    685 
    686     /** Index to arrBufIndex[], used for output buffer timestamps */
    687     OMX_U8 OpBufindex;
    688 
    689     /* flag if the component is preempted for resource or policy reasons */
    690     OMX_BOOL bPreempted;
    691 
    692     /** Pointer to RM callback **/
    693 #ifdef RESOURCE_MANAGER_ENABLED
    694     RMPROXY_CALLBACKTYPE rmproxyCallback;
    695 #endif
    696 
    697 
    698 } G726DEC_COMPONENT_PRIVATE;
    699 
    700 
    701 
    702 /* ================================================================================= * */
    703 /**
    704  * OMX_ComponentInit() function is called by OMX Core to initialize the component
    705  * with default values of the component. Before calling this function OMX_Init
    706  * must have been called.
    707  *
    708  * @param *hComp This is component handle allocated by the OMX core.
    709  *
    710  * @pre          OMX_Init should be called by application.
    711  *
    712  * @post         Component has initialzed with default values.
    713  *
    714  *  @return      OMX_ErrorNone = Successful Inirialization of the component\n
    715  *               OMX_ErrorInsufficientResources = Not enough memory
    716  *
    717  *  @see          G726Dec_StartCompThread()
    718  */
    719 /* ================================================================================ * */
    720 #ifndef UNDER_CE
    721 OMX_ERRORTYPE OMX_ComponentInit (OMX_HANDLETYPE hComp);
    722 #else
    723 /*  WinCE Implicit Export Syntax */
    724 #define OMX_EXPORT __declspec(dllexport)
    725 OMX_EXPORT OMX_ERRORTYPE OMX_ComponentInit (OMX_HANDLETYPE hComp);
    726 #endif
    727 
    728 /* ================================================================================= * */
    729 /**
    730  * G726Dec_StartCompThread() starts the component thread. This is internal
    731  * function of the component.
    732  *
    733  * @param pHandle This is component handle allocated by the OMX core.
    734  *
    735  * @pre          None
    736  *
    737  * @post         None
    738  *
    739  *  @return      OMX_ErrorNone = Successful Inirialization of the component\n
    740  *               OMX_ErrorInsufficientResources = Not enough memory
    741  *
    742  *  @see         None
    743  */
    744 /* ================================================================================ * */
    745 OMX_ERRORTYPE G726Dec_StartCompThread(OMX_HANDLETYPE pHandle);
    746 
    747 /* ================================================================================= * */
    748 /**
    749  * G726DEC_Fill_LCMLInitParams() fills the LCML initialization structure.
    750  *
    751  * @param pHandle This is component handle allocated by the OMX core.
    752  *
    753  * @param plcml_Init This structure is filled and sent to LCML.
    754  *
    755  * @pre          None
    756  *
    757  * @post         None
    758  *
    759  *  @return      OMX_ErrorNone = Successful Inirialization of the LCML struct.
    760  *               OMX_ErrorInsufficientResources = Not enough memory
    761  *
    762  *  @see         None
    763  */
    764 /* ================================================================================ * */
    765 OMX_ERRORTYPE G726DEC_Fill_LCMLInitParams(OMX_HANDLETYPE pHandle,
    766                                           LCML_DSP *plcml_Init, OMX_U16 arr[]);
    767 
    768 /* ================================================================================= * */
    769 /**
    770  * G726DEC_GetBufferDirection() function determines whether it is input buffer or
    771  * output buffer.
    772  *
    773  * @param *pBufHeader This is pointer to buffer header whose direction needs to
    774  *                    be determined.
    775  *
    776  * @param *eDir  This is output argument which stores the direction of buffer.
    777  *
    778  * @pre          None
    779  *
    780  * @post         None
    781  *
    782  *  @return      OMX_ErrorNone = Successful processing.
    783  *               OMX_ErrorBadParameter = In case of invalid buffer
    784  *
    785  *  @see         None
    786  */
    787 /* ================================================================================ * */
    788 OMX_ERRORTYPE G726DEC_GetBufferDirection(OMX_BUFFERHEADERTYPE *pBufHeader,
    789                                          OMX_DIRTYPE *eDir);
    790 
    791 /* ================================================================================= * */
    792 /**
    793  * G726DEC_LCML_Callback() function is callback which is called by LCML whenever
    794  * there is an even generated for the component.
    795  *
    796  * @param event  This is event that was generated.
    797  *
    798  * @param arg    This has other needed arguments supplied by LCML like handles
    799  *               etc.
    800  *
    801  * @pre          None
    802  *
    803  * @post         None
    804  *
    805  *  @return      OMX_ErrorNone = Successful processing.
    806  *               OMX_ErrorInsufficientResources = Not enough memory
    807  *
    808  *  @see         None
    809  */
    810 /* ================================================================================ * */
    811 OMX_ERRORTYPE G726DEC_LCML_Callback (TUsnCodecEvent event,void * args [10]);
    812 
    813 /* ================================================================================= * */
    814 /**
    815  * G726DEC_HandleCommand() function handles the command sent by the application.
    816  * All the state transitions, except from nothing to loaded state, of the
    817  * component are done by this function.
    818  *
    819  * @param pComponentPrivate  This is component's private date structure.
    820  *
    821  * @pre          None
    822  *
    823  * @post         None
    824  *
    825  *  @return      OMX_ErrorNone = Successful processing.
    826  *               OMX_ErrorInsufficientResources = Not enough memory
    827  *               OMX_ErrorHardware = Hardware error has occured lile LCML failed
    828  *               to do any said operartion.
    829  *
    830  *  @see         None
    831  */
    832 /* ================================================================================ * */
    833 OMX_U32 G726DEC_HandleCommand (G726DEC_COMPONENT_PRIVATE *pComponentPrivate);
    834 
    835 /* ================================================================================= * */
    836 /**
    837  * G726DEC_HandleDataBuf_FromApp() function handles the input and output buffers
    838  * that come from the application. It is not direct function wich gets called by
    839  * the application rather, it gets called eventually.
    840  *
    841  * @param *pBufHeader This is the buffer header that needs to be processed.
    842  *
    843  * @param *pComponentPrivate  This is component's private date structure.
    844  *
    845  * @pre          None
    846  *
    847  * @post         None
    848  *
    849  *  @return      OMX_ErrorNone = Successful processing.
    850  *               OMX_ErrorInsufficientResources = Not enough memory
    851  *               OMX_ErrorHardware = Hardware error has occured lile LCML failed
    852  *               to do any said operartion.
    853  *
    854  *  @see         None
    855  */
    856 /* ================================================================================ * */
    857 OMX_ERRORTYPE G726DEC_HandleDataBuf_FromApp(OMX_BUFFERHEADERTYPE *pBufHeader,
    858                                             G726DEC_COMPONENT_PRIVATE *pComponentPrivate);
    859 
    860 /* ================================================================================= * */
    861 
    862 /* ================================================================================= * */
    863 /**
    864  * G726DEC_GetLCMLHandle() function gets the LCML handle and interacts with LCML
    865  * by using this LCML Handle.
    866  *
    867  * @param *pBufHeader This is the buffer header that needs to be processed.
    868  *
    869  * @param *pComponentPrivate  This is component's private date structure.
    870  *
    871  * @pre          None
    872  *
    873  * @post         None
    874  *
    875  *  @return      OMX_HANDLETYPE = Successful loading of LCML library.
    876  *               OMX_ErrorHardware = Hardware error has occured.
    877  *
    878  *  @see         None
    879  */
    880 /* ================================================================================ * */
    881 OMX_HANDLETYPE G726DEC_GetLCMLHandle(G726DEC_COMPONENT_PRIVATE *pComponentPrivate);
    882 
    883 /* ================================================================================= * */
    884 /**
    885  * G726DEC_GetCorresponding_LCMLHeader() function gets the corresponding LCML
    886  * header from the actual data buffer for required processing.
    887  *
    888  * @param *pBuffer This is the data buffer pointer.
    889  *
    890  * @param eDir   This is direction of buffer. Input/Output.
    891  *
    892  * @param *G726D_LCML_BUFHEADERTYPE  This is pointer to LCML Buffer Header.
    893  *
    894  * @pre          None
    895  *
    896  * @post         None
    897  *
    898  *  @return      OMX_ErrorNone = Successful Inirialization of the component\n
    899  *               OMX_ErrorHardware = Hardware error has occured.
    900  *
    901  *  @see         None
    902  */
    903 /* ================================================================================ * */
    904 OMX_ERRORTYPE G726DEC_GetCorresponding_LCMLHeader(G726DEC_COMPONENT_PRIVATE *pComponentPrivate,
    905                                                   OMX_U8 *pBuffer,
    906                                                   OMX_DIRTYPE eDir,
    907                                                   G726D_LCML_BUFHEADERTYPE **ppLcmlHdr);
    908 
    909 /* ================================================================================= * */
    910 /**
    911  * G726DEC_FreeCompResources() function frees the component resources.
    912  *
    913  * @param pComponent This is the component handle.
    914  *
    915  * @pre          None
    916  *
    917  * @post         None
    918  *
    919  *  @return      OMX_ErrorNone = Successful Inirialization of the component\n
    920  *               OMX_ErrorHardware = Hardware error has occured.
    921  *
    922  *  @see         None
    923  */
    924 /* ================================================================================ * */
    925 OMX_ERRORTYPE G726DEC_FreeCompResources(OMX_HANDLETYPE pComponent);
    926 
    927 /* ================================================================================= * */
    928 /**
    929  * G726DEC_CleanupInitParams() function frees only the initialization time
    930  * memories allocated. For example, it will not close pipes, it will not free the
    931  * memory allocated to the buffers etc. But it does free the memory of buffers
    932  * utilized by the LCML etc. It is basically subset of G726DEC_FreeResources()
    933  * function.
    934  *
    935  * @param pComponent This is the component handle.
    936  *
    937  * @pre          None
    938  *
    939  * @post         None
    940  *
    941  *  @return      OMX_ErrorNone = Successful Inirialization of the component\n
    942  *
    943  *  @see         None
    944  */
    945 /* ================================================================================ * */
    946 void G726DEC_CleanupInitParams(OMX_HANDLETYPE pComponent);
    947 
    948 /* ================================================================================= * */
    949 /**
    950  * G726DEC_ComponentThread() This is component thread of the component which keeps
    951  * running or lsitening from the application unless component is deinitialized
    952  * from by the application i.e. component is transitioned from Idle to Loaded
    953  * state.
    954  *
    955  * @param pHandle This is component handle allocated by the OMX core.
    956  *
    957  * @pre          None
    958  *
    959  * @post         None
    960  *
    961  *  @return      OMX_ErrorNone = Successful Inirialization of the component\n
    962  *               OMX_ErrorInsufficientResources = Not enough memory
    963  *
    964  *  @see         None
    965  */
    966 /* ================================================================================ * */
    967 void* G726DEC_ComponentThread (void* pThreadData);
    968 
    969 OMX_ERRORTYPE G726DECFill_LCMLInitParamsEx(OMX_HANDLETYPE pComponent);
    970 void G726DEC_SetPending(G726DEC_COMPONENT_PRIVATE *pComponentPrivate,
    971                         OMX_BUFFERHEADERTYPE *pBufHdr, OMX_DIRTYPE eDir, OMX_U32 lineNumber);
    972 void G726DEC_ClearPending(G726DEC_COMPONENT_PRIVATE *pComponentPrivate,
    973                           OMX_BUFFERHEADERTYPE *pBufHdr, OMX_DIRTYPE eDir, OMX_U32 lineNumber) ;
    974 OMX_U32 G726DEC_IsPending(G726DEC_COMPONENT_PRIVATE *pComponentPrivate,
    975                           OMX_BUFFERHEADERTYPE *pBufHdr, OMX_DIRTYPE eDir);
    976 OMX_U32 G726DEC_IsValid(G726DEC_COMPONENT_PRIVATE *pComponentPrivate,
    977                         OMX_U8 *pBuffer, OMX_DIRTYPE eDir) ;
    978 
    979 OMX_ERRORTYPE OMX_DmmMap(DSP_HPROCESSOR ProcHandle, int size, void* pArmPtr, DMM_BUFFER_OBJ* pDmmBuf);
    980 OMX_ERRORTYPE OMX_DmmUnMap(DSP_HPROCESSOR ProcHandle, void* pMapPtr, void* pResPtr);
    981 
    982 #ifdef RESOURCE_MANAGER_ENABLED
    983 /***********************************
    984  *  Callback to the RM                                       *
    985  ***********************************/
    986 void G726DEC_ResourceManagerCallback(RMPROXY_COMMANDDATATYPE cbData);
    987 #endif
    988 
    989 #endif
    990