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_G722Decoder.h
     30  *
     31  * This is an header file for an audio G722 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\g722_dec\inc\
     37  *
     38  * @rev 1.0
     39  */
     40 /* --------------------------------------------------------------------------- */
     41 #ifndef OMX_G722DEC_UTILS__H
     42 #define OMX_G722DEC_UTILS__H
     43 
     44 #include <OMX_Component.h>
     45 
     46 #include "LCML_DspCodec.h"
     47 
     48     #ifdef UNDER_CE
     49 #include <windows.h>
     50 #include <oaf_osal.h>
     51 #include <omx_core.h>
     52 #include <stdlib.h>
     53 #else
     54 #include <pthread.h>
     55 #endif
     56 
     57 /*#define G722DEC_DEBUG  **/         /* See all debug statement of the component */
     58 /*#define G722DEC_MEMDETAILS */     /* See memory details of the component */
     59 /*#define G722DEC_BUFDETAILS */     /* See buffers details of the component */
     60 /*#define G722DEC_STATEDETAILS */   /* See all state transitions of the component */
     61 
     62 #define MAX_NUM_OF_BUFS 10 /* Max number of buffers used */
     63 #define G722D_NUM_INPUT_BUFFERS 1  /* Default number of input buffers */
     64 #define G722D_NUM_OUTPUT_BUFFERS 1 /* Default number of output buffers */
     65 #define G722D_INPUT_BUFFER_SIZE  4096 /* Default size of input buffer */
     66 #define G722D_OUTPUT_BUFFER_SIZE 320 /* Default size of output buffer */
     67 
     68 #define NUM_OF_PORTS 2 /* Number of ports of component */
     69 #define INVALID_SAMPLING_FREQ  51
     70 
     71 #define EXIT_COMPONENT_THRD  10
     72 
     73 
     74 #define G722DEC_MAJOR_VER           0xF1 /* Majer version of the component */
     75 #define G722DEC_MINOR_VER           0xF2 /* Minor version of the component */
     76 #define G722DEC_BUFHEADER_VERSION   0x0 /* Version of the buffer header struct */
     77 #define NOT_USED                    10 /* To specify that a particulat field is not used */
     78 #define NORMAL_BUFFER               0 /* Marks a buffer as normal buffer i.e. not last buffer */
     79 #define OMX_G722DEC_DEFAULT_SEGMENT (0) /* Default segment ID */
     80 #define OMX_G722DEC_SN_TIMEOUT      (-1) /* timeout, wait until ack is received */
     81 #define OMX_G722DEC_SN_PRIORITY     (10) /* Priority used by DSP */
     82 #define G722DEC_CPU                 50 /* TBD, 50MHz for the moment */
     83 
     84 #ifdef UNDER_CE
     85 #define USN_DLL_NAME "\\windows\\usn.dll64P" /* Path of USN DLL */
     86 #define G722DEC_DLL_NAME "\\windows\\g722dec_sn.dll64P" /* Path of G722 SN DLL */
     87 #else
     88 #define USN_DLL_NAME "usn.dll64P" /* Path of USN DLL */
     89 #define G722DEC_DLL_NAME "g722dec_sn.dll64P" /* Path of G722 SN DLL */
     90 #endif
     91 
     92 #define DONT_CARE 0 /* Value unused or ignored */
     93 
     94 /** Default timeout used to come out of blocking calls*/
     95 #define G722D_TIMEOUT (1000) /* millisecs */
     96 
     97 #ifdef UNDER_CE
     98 
     99 #ifdef DEBUG
    100 #define G722DEC_DPRINT       printf
    101 #define G722DEC_EPRINT       printf
    102 #define G722DEC_MEMPRINT     printf
    103 #define G722DEC_STATEPRINT   printf
    104 #define G722DEC_BUFPRINT     printf
    105 #else
    106 #define G722DEC_DPRINT
    107 #define G722DEC_EPRINT
    108 #define G722DEC_MEMPRINT
    109 #define G722DEC_STATEPRINT
    110 #define G722DEC_BUFPRINT
    111 #endif
    112 
    113 #else /* for Linux */
    114 
    115 #ifdef  G722DEC_DEBUG
    116 
    117 #define G722DEC_DPRINT(...)  fprintf(stdout, "%s %d::  ",__FUNCTION__, __LINE__); \
    118     fprintf(stdout, __VA_ARGS__);                                       \
    119     fprintf(stdout, "\n");
    120 
    121 #define G722DEC_BUFPRINT printf
    122 #define G722DEC_MEMPRINT printf
    123 #define G722DEC_STATEPRINT printf
    124 
    125 #else
    126 #define G722DEC_DPRINT(...)
    127 
    128 #ifdef G722DEC_STATEDETAILS
    129 #define G722DEC_STATEPRINT printf
    130 #else
    131 #define G722DEC_STATEPRINT(...)
    132 #endif
    133 
    134 #ifdef G722DEC_BUFDETAILS
    135 #define G722DEC_BUFPRINT printf
    136 #else
    137 #define G722DEC_BUFPRINT(...)
    138 #endif
    139 
    140 #ifdef G722DEC_MEMDETAILS
    141 #define G722DEC_MEMPRINT(...)  fprintf(stdout, "%s %d::  ",__FUNCTION__, __LINE__); \
    142     fprintf(stdout, __VA_ARGS__);                                       \
    143     fprintf(stdout, "\n");
    144 #else
    145 #define G722DEC_MEMPRINT(...)
    146 #endif
    147 
    148 #endif
    149 
    150 #endif /*for UNDER_CE*/
    151 
    152 #define G722D_OMX_MALLOC(_pStruct_, _sName_)                        \
    153     _pStruct_ = (_sName_*)malloc(sizeof(_sName_));                  \
    154     if(_pStruct_ == NULL){                                          \
    155         printf("***********************************\n");            \
    156         printf("%d :: Malloc Failed\n",__LINE__);                   \
    157         printf("***********************************\n");            \
    158         eError = OMX_ErrorInsufficientResources;                    \
    159         goto EXIT;                                                  \
    160     }                                                               \
    161     memset(_pStruct_,0,sizeof(_sName_));                            \
    162     G722DEC_MEMPRINT("%d :: Malloced = %p\n",__LINE__,_pStruct_);
    163 
    164 
    165 
    166 #define G722D_OMX_MALLOC_SIZE(_ptr_, _size_,_name_)             \
    167     _ptr_ = (_name_ *)malloc(_size_);                           \
    168     if(_ptr_ == NULL){                                          \
    169         printf("***********************************\n");        \
    170         printf("%d :: Malloc Failed\n",__LINE__);               \
    171         printf("***********************************\n");        \
    172         eError = OMX_ErrorInsufficientResources;                \
    173         goto EXIT;                                              \
    174     }                                                           \
    175     memset(_ptr_,0,_size_);                                     \
    176     G722DEC_MEMPRINT("%d :: Malloced = %p\n",__LINE__,_ptr_);
    177 
    178 #define G722D_OMX_ERROR_EXIT(_e_, _c_, _s_)                             \
    179     _e_ = _c_;                                                          \
    180     printf("\n**************** OMX ERROR ************************\n");  \
    181     printf("%d : Error Name: %s : Error Num = %x",__LINE__, _s_, _e_);  \
    182     printf("\n**************** OMX ERROR ************************\n");  \
    183     goto EXIT;
    184 
    185 
    186 #define G722D_OMX_CONF_CHECK_CMD(_ptr1, _ptr2, _ptr3)   \
    187     {                                                   \
    188         if(!_ptr1 || !_ptr2 || !_ptr3){                 \
    189             eError = OMX_ErrorBadParameter;             \
    190             goto EXIT;                                  \
    191         }                                               \
    192     }
    193 
    194 #define G722D_OMX_FREE(ptr)                                             \
    195     if(NULL != ptr) {                                                   \
    196         G722DEC_MEMPRINT("%d :: Freeing Address = %p\n",__LINE__,ptr);  \
    197         free(ptr);                                                      \
    198         ptr = NULL;                                                     \
    199     }
    200 
    201 #define OMX_CONF_INIT_STRUCT(_s_, _name_)       \
    202     memset((_s_), 0x0, sizeof(_name_));         \
    203     (_s_)->nSize = sizeof(_name_);              \
    204     (_s_)->nVersion.s.nVersionMajor = 0x1;      \
    205     (_s_)->nVersion.s.nVersionMinor = 0x0;      \
    206     (_s_)->nVersion.s.nRevision = 0x0;          \
    207     (_s_)->nVersion.s.nStep = 0x0
    208 
    209 
    210 /* ======================================================================= */
    211 /** OMX_G722DEC_INDEXAUDIOTYPE  Defines the custom configuration settings
    212  *                              for the component
    213  *
    214  *  @param  OMX_IndexCustomG722DecModeDasfConfig      Sets the DASF mode
    215  *
    216  */
    217 /*  ==================================================================== */
    218 typedef enum OMX_G722DEC_INDEXAUDIOTYPE {
    219     /*OMX_IndexCustomG722DecModeDasfConfig = OMX_IndexIndexVendorStartUnused + 1,*/
    220     OMX_IndexCustomG722DecModeDasfConfig = 0xFF000001,
    221     OMX_IndexCustomG722DecHeaderInfoConfig,
    222     OMX_IndexCustomG722DecStreamIDConfig,
    223     OMX_IndexCustomG722DecDataPath
    224 }OMX_G722DEC_INDEXAUDIOTYPE;
    225 
    226 
    227 /* ============================================================================== * */
    228 /** G722D_COMP_PORT_TYPE  describes the input and output port of indices of the
    229  * component.
    230  *
    231  * @param  G722D_INPUT_PORT  Input port index
    232  *
    233  * @param  G722D_OUTPUT_PORT Output port index
    234  */
    235 /* ============================================================================ * */
    236 typedef enum G722D_COMP_PORT_TYPE {
    237     G722D_INPUT_PORT = 0,
    238     G722D_OUTPUT_PORT
    239 }G722D_COMP_PORT_TYPE;
    240 
    241 
    242 /* ======================================================================= */
    243 /** G722DEC_ParamStruct: This struct is passed with input buffers that
    244  * are sent to DSP.
    245  */
    246 /* ==================================================================== */
    247 typedef struct {
    248     /* Set to 1 if buffer is last buffer */
    249     unsigned long usLastFrame;
    250     unsigned long usFrameLost;
    251 }G722DEC_ParamStruct;
    252 
    253 /* ======================================================================= */
    254 /** G722DEC_UAlgInBufParamStruct: This struct is passed with input buffers that
    255  * are sent to DSP.
    256  */
    257 /* ==================================================================== */
    258 typedef struct {
    259     /* Set to 1 if buffer is last buffer */
    260     unsigned long bLastBuffer;
    261 }G722DEC_UAlgInBufParamStruct;
    262 
    263 
    264 /* ======================================================================= */
    265 /** G722D_USN_AudioCodecParams: This contains the information which does to Codec
    266  * on DSP
    267  * are sent to DSP.
    268  */
    269 /* ==================================================================== */
    270 typedef struct USN_AudioCodecParams{
    271     /* Specifies the sample frequency */
    272     unsigned long ulSamplingFreq;
    273     /* Specifies the UUID */
    274     unsigned long unUUID;
    275     /* Specifies the audio format */
    276     unsigned short unAudioFormat;
    277 }G722D_USN_AudioCodecParams;
    278 
    279 /* ======================================================================= */
    280 /** G722DEC_UAlgOutBufParamStruct: This is passed with output buffer to DSP.
    281  */
    282 /* ==================================================================== */
    283 typedef struct {
    284     /* Number of frames in a buffer */
    285     unsigned long ulFrameCount;
    286 }G722DEC_UAlgOutBufParamStruct;
    287 
    288 /* ======================================================================= */
    289 /** G722D_LCML_BUFHEADERTYPE: This is LCML buffer header which is sent to LCML
    290  * for both input and output buffers.
    291  */
    292 /* ==================================================================== */
    293 typedef struct G722D_LCML_BUFHEADERTYPE {
    294     /* Direction whether input or output buffer */
    295     OMX_DIRTYPE eDir;
    296     /* Pointer to OMX Buffer Header */
    297     OMX_BUFFERHEADERTYPE *pBufHdr;
    298     /* Other parameters, may be useful for enhancements */
    299     void *pOtherParams[10];
    300     /* Input Parameter Information structure */
    301     /*G722DEC_UAlgInBufParamStruct *pIpParam;*/
    302     G722DEC_ParamStruct *pIpParam;
    303     /* Output Parameter Information structure */
    304     G722DEC_UAlgOutBufParamStruct *pOpParam;
    305 
    306     OMX_BUFFERHEADERTYPE* buffer;
    307 }G722D_LCML_BUFHEADERTYPE;
    308 
    309 /* ======================================================================= */
    310 /** G722D_AUDIODEC_PORT_TYPE: This contains component port information.
    311  *
    312  * @see OMX_AUDIO_PARAM_PORTFORMATTYPE
    313  */
    314 /* ==================================================================== */
    315 typedef struct AUDIODEC_PORT_TYPE {
    316     /* Used in tunneling, this is handle of tunneled component */
    317     OMX_HANDLETYPE hTunnelComponent;
    318     /* Port which has to be tunneled */
    319     OMX_U32 nTunnelPort;
    320     /* Buffer Supplier Information */
    321     OMX_BUFFERSUPPLIERTYPE eSupplierSetting;
    322     /* Number of buffers */
    323     OMX_U8 nBufferCnt;
    324     /* Port format information */
    325     OMX_AUDIO_PARAM_PORTFORMATTYPE* pPortFormat;
    326 } G722D_AUDIODEC_PORT_TYPE;
    327 
    328 
    329 /* ======================================================================= */
    330 /** _G722D_BUFFERLIST: This contains information about a buffer's owner whether
    331  * it is application or component, number of buffers owned etc.
    332  *
    333  * @see OMX_BUFFERHEADERTYPE
    334  */
    335 /* ==================================================================== */
    336 struct _G722D_BUFFERLIST{
    337     /* Array of pointer to OMX buffer headers */
    338     OMX_BUFFERHEADERTYPE *pBufHdr[MAX_NUM_OF_BUFS];
    339     /* Array that tells about owner of each buffer */
    340     OMX_U32 bufferOwner[MAX_NUM_OF_BUFS];
    341     OMX_U32 bBufferPending[MAX_NUM_OF_BUFS];
    342     /* Number of buffers  */
    343     OMX_U32 numBuffers;
    344 };
    345 
    346 typedef struct _G722D_BUFFERLIST G722D_BUFFERLIST;
    347 
    348 #ifdef UNDER_CE
    349 #ifndef _OMX_EVENT_
    350 #define _OMX_EVENT_
    351 typedef struct OMX_Event {
    352     HANDLE event;
    353 } OMX_Event;
    354 #endif
    355 int OMX_CreateEvent(OMX_Event *event);
    356 int OMX_SignalEvent(OMX_Event *event);
    357 int OMX_WaitForEvent(OMX_Event *event);
    358 int OMX_DestroyEvent(OMX_Event *event);
    359 #endif
    360 
    361 /* ======================================================================= */
    362 /** G722DEC_COMPONENT_PRIVATE: This is the major and main structure of the
    363  * component which contains all type of information of buffers, ports etc
    364  * contained in the component.
    365  *
    366  * @see OMX_BUFFERHEADERTYPE
    367  * @see OMX_AUDIO_PARAM_PORTFORMATTYPE
    368  * @see OMX_PARAM_PORTDEFINITIONTYPE
    369  * @see G722D_LCML_BUFHEADERTYPE
    370  * @see OMX_PORT_PARAM_TYPE
    371  * @see OMX_PRIORITYMGMTTYPE
    372  * @see G722D_AUDIODEC_PORT_TYPE
    373  * @see G722D_BUFFERLIST
    374  * @see G722D_AUDIODEC_PORT_TYPE
    375  * @see LCML_STRMATTR
    376  * @see
    377  */
    378 /* ==================================================================== */
    379 typedef struct G722DEC_COMPONENT_PRIVATE
    380 {
    381     /** Handle for use with async callbacks */
    382     OMX_CALLBACKTYPE cbInfo;
    383     /* Component port information */
    384     OMX_PORT_PARAM_TYPE *sPortParam;
    385     /* Input port information */
    386     OMX_AUDIO_PARAM_PORTFORMATTYPE sInPortFormat;
    387     /* Output port information */
    388     OMX_AUDIO_PARAM_PORTFORMATTYPE sOutPortFormat;
    389     /* Buffer owner information */
    390     OMX_U32 bIsBufferOwned[NUM_OF_PORTS];
    391 
    392     /** Number of input buffers at runtime */
    393     OMX_U32 nRuntimeInputBuffers;
    394 
    395     /** Number of output buffers at runtime */
    396     OMX_U32 nRuntimeOutputBuffers;
    397 
    398     /* Audio codec parameters structure */
    399     G722D_USN_AudioCodecParams *pParams;
    400 
    401     /** This will contain info like how many buffers
    402         are there for input/output ports, their size etc, but not
    403         BUFFERHEADERTYPE POINTERS. */
    404     OMX_PARAM_PORTDEFINITIONTYPE* pPortDef[NUM_OF_PORTS];
    405     /* Contains information that come from application */
    406     OMX_AUDIO_PARAM_PCMMODETYPE* G722Params[NUM_OF_PORTS];
    407     /** This is component handle */
    408     OMX_COMPONENTTYPE* pHandle;
    409     /** Current state of this component */
    410     OMX_STATETYPE curState;
    411     /** The component thread handle */
    412     pthread_t ComponentThread;
    413     /** The pipes for sending buffers to the thread */
    414     int dataPipe[2];
    415     /** The pipes for sending buffers to the thread */
    416     int cmdPipe[2];
    417 
    418     /** The pipes for sending command data to the thread */
    419     int cmdDataPipe[2];
    420 
    421     /*    int portcmdPipe[2]; */
    422 
    423     /** The pipes for sending buffers to the thread */
    424     int lcml_Pipe[2];
    425 
    426     /** Set to indicate component is stopping */
    427     OMX_U32 bIsEOFSent;
    428 
    429     /** Count of number of buffers outstanding with bridge */
    430     OMX_U32 lcml_nIpBuf;
    431 
    432     /** Count of number of buffers outstanding with bridge */
    433     OMX_U32 lcml_nOpBuf;
    434 
    435     /** Counts of number of input buffers sent to LCML */
    436     OMX_U32 lcml_nCntIp;
    437     /** Counts of number of input buffers received from LCML */
    438     OMX_U32 lcml_nCntIpRes;
    439     /** Counts of number of output buffers sent to LCML */
    440     OMX_U32 lcml_nCntOp;
    441     /** Counts of number of output buffers received from LCML */
    442     OMX_U32 lcml_nCntOpReceived;
    443     /** Counts of number of buffers sent to App  */
    444     OMX_U32 lcml_nCntApp;
    445     /** Counts of number of buffers received from App  */
    446     OMX_U32 app_nBuf;
    447 
    448     /** Counts of number of output buffers reclaimed from lcml  */
    449     OMX_U32 num_Reclaimed_Op_Buff;
    450     /** Counts of number of input buffers sent to lcml  */
    451     OMX_U32 num_Sent_Ip_Buff;
    452     /** Counts of number of output buffers sent to lcml  */
    453     OMX_U32 num_Op_Issued;
    454     /** Holds the value of dasf mode, 1: DASF mode or 0: File Mode  */
    455     OMX_U32 dasfmode;
    456 
    457     OMX_STRING* sDeviceString;
    458 
    459     /** This is LCML handle  */
    460     OMX_HANDLETYPE pLcmlHandle;
    461 
    462     /** Contains pointers to LCML Buffer Headers */
    463     G722D_LCML_BUFHEADERTYPE *pLcmlBufHeader[2];
    464     OMX_U32 bBufferIsAllocated;
    465 
    466     /** Tells whether buffers on ports have been allocated */
    467     OMX_U32 bPortDefsAllocated;
    468     /** Tells whether component thread has started */
    469     OMX_U32 bCompThreadStarted;
    470     /** Marks the buffer data  */
    471     OMX_PTR pMarkData;
    472     /** Marks the buffer */
    473     OMX_MARKTYPE *pMarkBuf;
    474     /** Marks the target component */
    475     OMX_HANDLETYPE hMarkTargetComponent;
    476     /** Flag to track when input buffer's filled length is 0 */
    477     OMX_U32 bBypassDSP;
    478     /** Input port enable flag */
    479     int ipPortEnableFlag;
    480     /** Input port disble flag */
    481     int ipPortDisableFlag;
    482     /** Pointer to port parameter structure */
    483     OMX_PORT_PARAM_TYPE* pPortParamType;
    484     /** Pointer to port priority management structure */
    485     OMX_PRIORITYMGMTTYPE* pPriorityMgmt;
    486     /** Contains the port related info of both the ports */
    487     G722D_AUDIODEC_PORT_TYPE *pCompPort[NUM_OF_PORTS];
    488     /* Checks whether or not buffer were allocated by appliction */
    489     int bufAlloced;
    490     /** Flag to check about execution of component thread */
    491     OMX_U16 bExitCompThrd;
    492     /** Pointer to list of input buffers */
    493     G722D_BUFFERLIST *pInputBufferList;
    494     /** Pointer to list of output buffers */
    495     G722D_BUFFERLIST *pOutputBufferList;
    496     /** it is used for component's create phase arguments */
    497     LCML_STRMATTR  *strmAttr;
    498     /** Contains the version information */
    499     OMX_U32 nVersion;
    500 
    501     /** ACDN mode flag */
    502     OMX_U32 acdnmode;
    503 
    504     /** Audio Stream ID */
    505     OMX_U32 streamID;
    506 
    507     int nOpBit;
    508     int bLcmlHandleOpened;
    509     OMX_U32 nFillThisBufferCount;
    510     /** Counts number of FillBufferDone calls*/
    511     OMX_U32 nFillBufferDoneCount;
    512     /** Counts number of EmptyThisBuffer calls*/
    513     OMX_U32 nEmptyThisBufferCount;
    514     /** Counts number of EmptyBufferDone calls*/
    515     OMX_U32 nEmptyBufferDoneCount;
    516     /** Checks if component Init Params have been initialized */
    517     OMX_U32 bInitParamsInitialized;
    518     G722D_BUFFERLIST *pInputBufferListQueue;
    519     G722D_BUFFERLIST *pOutputBufferListQueue;
    520     OMX_BUFFERHEADERTYPE *pInputBufHdrPending[MAX_NUM_OF_BUFS];
    521     OMX_U32 nNumInputBufPending;
    522     OMX_BUFFERHEADERTYPE *pOutputBufHdrPending[MAX_NUM_OF_BUFS];
    523     OMX_U32 nNumOutputBufPending;
    524     OMX_BUFFERHEADERTYPE *pOutBufHdrWhilePaused[MAX_NUM_OF_BUFS];
    525     OMX_U32 nPendingOutPausedBufs;
    526 
    527     OMX_U32 bDisableCommandPending;
    528     OMX_U32 bDisableCommandParam;
    529     OMX_U32 nInvalidFrameCount;
    530     OMX_U32 numPendingBuffers;
    531     OMX_U32 bNoIdleOnStop;
    532     OMX_U32 bDspStoppedWhileExecuting;
    533     OMX_U32 bIdleCommandPending;
    534     OMX_U32 nOutStandingFillDones;
    535 
    536 #ifndef UNDER_CE
    537     pthread_mutex_t AlloBuf_mutex;
    538     pthread_cond_t AlloBuf_threshold;
    539     OMX_U8 AlloBuf_waitingsignal;
    540 
    541     pthread_mutex_t InLoaded_mutex;
    542     pthread_cond_t InLoaded_threshold;
    543     OMX_U8 InLoaded_readytoidle;
    544 
    545     pthread_mutex_t InIdle_mutex;
    546     pthread_cond_t InIdle_threshold;
    547     OMX_U8 InIdle_goingtoloaded;
    548 #else
    549     OMX_Event AlloBuf_event;
    550     OMX_U8 AlloBuf_waitingsignal;
    551 
    552     OMX_Event InLoaded_event;
    553     OMX_U8 InLoaded_readytoidle;
    554 
    555     OMX_Event InIdle_event;
    556     OMX_U8 InIdle_goingtoloaded;
    557 #endif
    558 
    559     OMX_BOOL bLoadedCommandPending;
    560     OMX_PARAM_COMPONENTROLETYPE *componentRole;
    561     OMX_VERSIONTYPE ComponentVersion;
    562     OMX_STRING cComponentName;
    563 
    564     /** Keep buffer timestamps **/
    565     OMX_S64 arrTimestamp[MAX_NUM_OF_BUFS];
    566     /** Keep buffer nTickCounts **/
    567     OMX_S64 arrTickCount[MAX_NUM_OF_BUFS];
    568     /** Index to arrTimestamp[], used for input buffer timestamps */
    569     OMX_U8 IpBufindex;
    570     /** Index to arrTimestamp[], used for output buffer timestamps */
    571     OMX_U8 OpBufindex;
    572 } G722DEC_COMPONENT_PRIVATE;
    573 
    574 
    575 
    576 /* ================================================================================= * */
    577 /**
    578  * OMX_ComponentInit() function is called by OMX Core to initialize the component
    579  * with default values of the component. Before calling this function OMX_Init
    580  * must have been called.
    581  *
    582  * @param *hComp This is component handle allocated by the OMX core.
    583  *
    584  * @pre          OMX_Init should be called by application.
    585  *
    586  * @post         Component has initialzed with default values.
    587  *
    588  *  @return      OMX_ErrorNone = Successful Inirialization of the component\n
    589  *               OMX_ErrorInsufficientResources = Not enough memory
    590  *
    591  *  @see          G722Dec_StartCompThread()
    592  */
    593 /* ================================================================================ * */
    594 #ifndef UNDER_CE
    595 OMX_ERRORTYPE OMX_ComponentInit (OMX_HANDLETYPE hComp);
    596 #else
    597 /*  WinCE Implicit Export Syntax */
    598 #define OMX_EXPORT __declspec(dllexport)
    599 OMX_EXPORT OMX_ERRORTYPE OMX_ComponentInit (OMX_HANDLETYPE hComp);
    600 #endif
    601 
    602 /* ================================================================================= * */
    603 /**
    604  * G722Dec_StartCompThread() starts the component thread. This is internal
    605  * function of the component.
    606  *
    607  * @param pHandle This is component handle allocated by the OMX core.
    608  *
    609  * @pre          None
    610  *
    611  * @post         None
    612  *
    613  *  @return      OMX_ErrorNone = Successful Inirialization of the component\n
    614  *               OMX_ErrorInsufficientResources = Not enough memory
    615  *
    616  *  @see         None
    617  */
    618 /* ================================================================================ * */
    619 OMX_ERRORTYPE G722Dec_StartCompThread(OMX_HANDLETYPE pHandle);
    620 
    621 /* ================================================================================= * */
    622 /**
    623  * G722DEC_Fill_LCMLInitParams() fills the LCML initialization structure.
    624  *
    625  * @param pHandle This is component handle allocated by the OMX core.
    626  *
    627  * @param plcml_Init This structure is filled and sent to LCML.
    628  *
    629  * @pre          None
    630  *
    631  * @post         None
    632  *
    633  *  @return      OMX_ErrorNone = Successful Inirialization of the LCML struct.
    634  *               OMX_ErrorInsufficientResources = Not enough memory
    635  *
    636  *  @see         None
    637  */
    638 /* ================================================================================ * */
    639 OMX_ERRORTYPE G722DEC_Fill_LCMLInitParams(OMX_HANDLETYPE pHandle,
    640                                           LCML_DSP *plcml_Init, OMX_U16 arr[]);
    641 
    642 /* ================================================================================= * */
    643 /**
    644  * G722DEC_GetBufferDirection() function determines whether it is input buffer or
    645  * output buffer.
    646  *
    647  * @param *pBufHeader This is pointer to buffer header whose direction needs to
    648  *                    be determined.
    649  *
    650  * @param *eDir  This is output argument which stores the direction of buffer.
    651  *
    652  * @pre          None
    653  *
    654  * @post         None
    655  *
    656  *  @return      OMX_ErrorNone = Successful processing.
    657  *               OMX_ErrorBadParameter = In case of invalid buffer
    658  *
    659  *  @see         None
    660  */
    661 /* ================================================================================ * */
    662 OMX_ERRORTYPE G722DEC_GetBufferDirection(OMX_BUFFERHEADERTYPE *pBufHeader,
    663                                          OMX_DIRTYPE *eDir);
    664 
    665 /* ================================================================================= * */
    666 /**
    667  * G722DEC_LCML_Callback() function is callback which is called by LCML whenever
    668  * there is an even generated for the component.
    669  *
    670  * @param event  This is event that was generated.
    671  *
    672  * @param arg    This has other needed arguments supplied by LCML like handles
    673  *               etc.
    674  *
    675  * @pre          None
    676  *
    677  * @post         None
    678  *
    679  *  @return      OMX_ErrorNone = Successful processing.
    680  *               OMX_ErrorInsufficientResources = Not enough memory
    681  *
    682  *  @see         None
    683  */
    684 /* ================================================================================ * */
    685 OMX_ERRORTYPE G722DEC_LCML_Callback (TUsnCodecEvent event,void * args [10]);
    686 
    687 /* ================================================================================= * */
    688 /**
    689  * G722DEC_HandleCommand() function handles the command sent by the application.
    690  * All the state transitions, except from nothing to loaded state, of the
    691  * component are done by this function.
    692  *
    693  * @param pComponentPrivate  This is component's private date structure.
    694  *
    695  * @pre          None
    696  *
    697  * @post         None
    698  *
    699  *  @return      OMX_ErrorNone = Successful processing.
    700  *               OMX_ErrorInsufficientResources = Not enough memory
    701  *               OMX_ErrorHardware = Hardware error has occured lile LCML failed
    702  *               to do any said operartion.
    703  *
    704  *  @see         None
    705  */
    706 /* ================================================================================ * */
    707 OMX_U32 G722DEC_HandleCommand (G722DEC_COMPONENT_PRIVATE *pComponentPrivate);
    708 
    709 /* ================================================================================= * */
    710 /**
    711  * G722DEC_HandleDataBuf_FromApp() function handles the input and output buffers
    712  * that come from the application. It is not direct function wich gets called by
    713  * the application rather, it gets called eventually.
    714  *
    715  * @param *pBufHeader This is the buffer header that needs to be processed.
    716  *
    717  * @param *pComponentPrivate  This is component's private date structure.
    718  *
    719  * @pre          None
    720  *
    721  * @post         None
    722  *
    723  *  @return      OMX_ErrorNone = Successful processing.
    724  *               OMX_ErrorInsufficientResources = Not enough memory
    725  *               OMX_ErrorHardware = Hardware error has occured lile LCML failed
    726  *               to do any said operartion.
    727  *
    728  *  @see         None
    729  */
    730 /* ================================================================================ * */
    731 OMX_ERRORTYPE G722DEC_HandleDataBuf_FromApp(OMX_BUFFERHEADERTYPE *pBufHeader,
    732                                             G722DEC_COMPONENT_PRIVATE *pComponentPrivate);
    733 
    734 /* ================================================================================= * */
    735 /**
    736  * G722DEC_GetLCMLHandle() function gets the LCML handle and interacts with LCML
    737  * by using this LCML Handle.
    738  *
    739  * @param *pBufHeader This is the buffer header that needs to be processed.
    740  *
    741  * @param *pComponentPrivate  This is component's private date structure.
    742  *
    743  * @pre          None
    744  *
    745  * @post         None
    746  *
    747  *  @return      OMX_HANDLETYPE = Successful loading of LCML library.
    748  *               OMX_ErrorHardware = Hardware error has occured.
    749  *
    750  *  @see         None
    751  */
    752 /* ================================================================================ * */
    753 OMX_HANDLETYPE G722DEC_GetLCMLHandle(G722DEC_COMPONENT_PRIVATE *pComponentPrivate);
    754 
    755 /* ================================================================================= * */
    756 /**
    757  * G722DEC_GetCorresponding_LCMLHeader() function gets the corresponding LCML
    758  * header from the actual data buffer for required processing.
    759  *
    760  * @param *pBuffer This is the data buffer pointer.
    761  *
    762  * @param eDir   This is direction of buffer. Input/Output.
    763  *
    764  * @param *G722D_LCML_BUFHEADERTYPE  This is pointer to LCML Buffer Header.
    765  *
    766  * @pre          None
    767  *
    768  * @post         None
    769  *
    770  *  @return      OMX_ErrorNone = Successful Inirialization of the component\n
    771  *               OMX_ErrorHardware = Hardware error has occured.
    772  *
    773  *  @see         None
    774  */
    775 /* ================================================================================ * */
    776 OMX_ERRORTYPE G722DEC_GetCorresponding_LCMLHeader(G722DEC_COMPONENT_PRIVATE *pComponentPrivate,
    777                                                   OMX_U8 *pBuffer,
    778                                                   OMX_DIRTYPE eDir,
    779                                                   G722D_LCML_BUFHEADERTYPE **ppLcmlHdr);
    780 
    781 /* ================================================================================= * */
    782 /**
    783  * G722DEC_FreeCompResources() function frees the component resources.
    784  *
    785  * @param pComponent This is the component handle.
    786  *
    787  * @pre          None
    788  *
    789  * @post         None
    790  *
    791  *  @return      OMX_ErrorNone = Successful Inirialization of the component\n
    792  *               OMX_ErrorHardware = Hardware error has occured.
    793  *
    794  *  @see         None
    795  */
    796 /* ================================================================================ * */
    797 OMX_ERRORTYPE G722DEC_FreeCompResources(OMX_HANDLETYPE pComponent);
    798 
    799 /* ================================================================================= * */
    800 /**
    801  * G722DEC_CleanupInitParams() function frees only the initialization time
    802  * memories allocated. For example, it will not close pipes, it will not free the
    803  * memory allocated to the buffers etc. But it does free the memory of buffers
    804  * utilized by the LCML etc. It is basically subset of G722DEC_FreeResources()
    805  * function.
    806  *
    807  * @param pComponent This is the component handle.
    808  *
    809  * @pre          None
    810  *
    811  * @post         None
    812  *
    813  *  @return      OMX_ErrorNone = Successful Inirialization of the component\n
    814  *
    815  *  @see         None
    816  */
    817 /* ================================================================================ * */
    818 void G722DEC_CleanupInitParams(OMX_HANDLETYPE pComponent);
    819 
    820 /* ================================================================================= * */
    821 /**
    822  * G722DEC_ComponentThread() This is component thread of the component which keeps
    823  * running or lsitening from the application unless component is deinitialized
    824  * from by the application i.e. component is transitioned from Idle to Loaded
    825  * state.
    826  *
    827  * @param pHandle This is component handle allocated by the OMX core.
    828  *
    829  * @pre          None
    830  *
    831  * @post         None
    832  *
    833  *  @return      OMX_ErrorNone = Successful Inirialization of the component\n
    834  *               OMX_ErrorInsufficientResources = Not enough memory
    835  *
    836  *  @see         None
    837  */
    838 /* ================================================================================ * */
    839 void* G722DEC_ComponentThread (void* pThreadData);
    840 
    841 OMX_ERRORTYPE   G722DECFill_LCMLInitParamsEx    (OMX_HANDLETYPE pComponent);
    842 void            G722DEC_SetPending              (G722DEC_COMPONENT_PRIVATE *pComponentPrivate, OMX_BUFFERHEADERTYPE *pBufHdr, OMX_DIRTYPE eDir, OMX_U32 lineNumber);
    843 void            G722DEC_ClearPending            (G722DEC_COMPONENT_PRIVATE *pComponentPrivate, OMX_BUFFERHEADERTYPE *pBufHdr, OMX_DIRTYPE eDir, OMX_U32 lineNumber) ;
    844 OMX_U32         G722DEC_IsPending               (G722DEC_COMPONENT_PRIVATE *pComponentPrivate, OMX_BUFFERHEADERTYPE *pBufHdr, OMX_DIRTYPE eDir);
    845 OMX_U32         G722DEC_IsValid                 (G722DEC_COMPONENT_PRIVATE *pComponentPrivate, OMX_U8 *pBuffer, OMX_DIRTYPE eDir) ;
    846 void            printEmmEvent                   (TUsnCodecEvent);
    847 void*           G722DEC_ComponentThread         (void* pThreadData);
    848 
    849 #ifndef OMX_G722_COMPONENTTHREAD__H
    850 #define OMX_G722_COMPONENTTHREAD__H
    851 
    852 #define EXIT_COMPONENT_THRD  10
    853 #endif
    854 
    855 #endif
    856