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_AmrDecoder.h
     30 *
     31 * This is an header file for an audio PCM decoder that is fully
     32 * compliant with the OMX Audio specification.
     33 * This the file that the application that uses OMX would include
     34 * in its code.
     35 *
     36 * @path $(CSLPATH)\
     37 *
     38 * @rev 0.1
     39 */
     40 /* --------------------------------------------------------------------------- */
     41 
     42 #ifndef OMX_AMRDECODER_H
     43 #define OMX_AMRDECODER_H
     44 
     45 #include "LCML_DspCodec.h"
     46 #include <OMX_Component.h>
     47 #include <pthread.h>
     48 #include <OMX_TI_Debug.h>
     49 
     50 #ifdef RESOURCE_MANAGER_ENABLED
     51 #include <ResourceManagerProxyAPI.h>
     52 #endif
     53 
     54 #ifdef __PERF_INSTRUMENTATION__
     55     #include "perf.h"
     56 #endif
     57 
     58 #ifdef DSP_RENDERING_ON
     59 #include <AudioManagerAPI.h>
     60 #endif
     61 
     62 
     63 #ifndef ANDROID
     64     #define ANDROID
     65 #endif
     66 
     67 #ifdef ANDROID
     68     #undef LOG_TAG
     69     #define LOG_TAG "OMX_NBAMRDEC"
     70 
     71     /* PV opencore capability custom parameter index */
     72     #define PV_OMX_COMPONENT_CAPABILITY_TYPE_INDEX 0xFF7A347
     73 #endif
     74 
     75 
     76 /* ======================================================================= */
     77 /**
     78  * @def    EXTRA_BUFFBYTES                Num of Extra Bytes to be allocated
     79  */
     80 /* ======================================================================= */
     81 #define EXTRA_BUFFBYTES (256)
     82 
     83 /* ======================================================================= */
     84 /**
     85  * @def    NBAMRD_TIMEOUT   Default timeout used to come out of blocking calls
     86  */
     87 /* ======================================================================= */
     88 #define NBAMRD_TIMEOUT (1000) /* millisecs */
     89 
     90 /* ======================================================================= */
     91 /**
     92  * @def    NUM_NBAMRDEC_INPUT_BUFFERS              Number of Input Buffers
     93  */
     94 /* ======================================================================= */
     95 #define NUM_NBAMRDEC_INPUT_BUFFERS 1
     96 
     97 /* ======================================================================= */
     98 /**
     99  * @def    NUM_NBAMRDEC_OUTPUT_BUFFERS              Number of Output Buffers
    100  */
    101 /* ======================================================================= */
    102 #define NUM_NBAMRDEC_OUTPUT_BUFFERS 2
    103 
    104 /* ======================================================================= */
    105 /**
    106  * @def    NUM_NBAMRDEC_OUTPUT_BUFFERS_DASF         Number of Output Buffers
    107  *                                                  on DASF mode
    108  */
    109 /* ======================================================================= */
    110 #define NUM_NBAMRDEC_OUTPUT_BUFFERS_DASF 2
    111 
    112 /* ======================================================================= */
    113 /**
    114  * @def    OUTPUT_NBAMRDEC_BUFFER_SIZE           Standart Output Buffer Size
    115  */
    116 /* ======================================================================= */
    117 #define OUTPUT_NBAMRDEC_BUFFER_SIZE 320
    118 /* ======================================================================= */
    119 /**
    120  * @def    INPUT_NBAMRDEC_BUFFER_SIZE_MIME       Mime Input Buffer Size
    121  */
    122 /* ======================================================================= */
    123 #define INPUT_NBAMRDEC_BUFFER_SIZE_MIME 34
    124 
    125 /* ======================================================================= */
    126 /**
    127  * @def    INPUT_BUFF_SIZE_EFR                  Input Buffer Size EFR
    128  */
    129 /* ======================================================================= */
    130 #define INPUT_BUFF_SIZE_EFR 120
    131 
    132 /* @def    INPUT_NBAMRDEC_BUFFER_SIZE_MIME       IF2 Input Buffer Size*/
    133 /* ======================================================================= */
    134 #define INPUT_NBAMRDEC_BUFFER_SIZE_IF2 32
    135 
    136 
    137 /* ======================================================================= */
    138 /**
    139  * @def    STD_NBAMRDEC_BUF_SIZE                  Standart Input Buffer Size
    140  */
    141 /* ======================================================================= */
    142 #define STD_NBAMRDEC_BUF_SIZE 118
    143 
    144 /* ======================================================================= */
    145 /**
    146  * @def    FRAME_SIZE_x                          Size in Bytes of determined
    147  *                                               frame.
    148  */
    149 /* ======================================================================= */
    150 #define  FRAME_SIZE_13  13
    151 #define  FRAME_SIZE_19  19
    152 #define  FRAME_SIZE_26  26
    153 #define  FRAME_SIZE_31  31
    154 #define  FRAME_SIZE_14  14
    155 #define  FRAME_SIZE_16  16
    156 #define  FRAME_SIZE_18  18
    157 #define  FRAME_SIZE_20  20
    158 #define  FRAME_SIZE_21  21
    159 #define  FRAME_SIZE_27  27
    160 #define  FRAME_SIZE_32  32
    161 #define  FRAME_SIZE_6   6
    162 #define  FRAME_SIZE_1   1
    163 #define  FRAME_SIZE_0   0
    164 
    165 /* ======================================================================= */
    166 /**
    167  * @def    STREAM_COUNT                         Stream Count value for
    168  *                                              LCML init.
    169  */
    170 /* ======================================================================= */
    171 #define STREAM_COUNT 2
    172 
    173 /* ======================================================================= */
    174 /**
    175  * @def    INPUT_STREAM_ID                      Input Stream ID
    176  */
    177 /* ======================================================================= */
    178 #define INPUT_STREAM_ID 0
    179 
    180 
    181 
    182 /* ======================================================================= */
    183 /**
    184  * @def    NBAMRDEC_SAMPLING_FREQUENCY          Sampling Frequency
    185  */
    186 /* ======================================================================= */
    187 #define NBAMRDEC_SAMPLING_FREQUENCY 8000
    188 
    189 /* ======================================================================= */
    190 /**
    191  * @def    NBAMRDEC_CPU_LOAD                    CPU Load in MHz
    192  */
    193 /* ======================================================================= */
    194 #define NBAMRDEC_CPU_LOAD 10
    195 
    196 /* ======================================================================= */
    197 /**
    198  * @def    MAX_NUM_OF_BUFS                      Max Num of Bufs Allowed
    199  */
    200 /* ======================================================================= */
    201 #define MAX_NUM_OF_BUFS 12
    202 /* ======================================================================= */
    203 /**
    204  * @def    IP_BUFFERSIZE                      Input Port Buffer Size
    205  */
    206 /* ======================================================================= */
    207 #define IP_BUFFERSIZE 4096
    208 /* ======================================================================= */
    209 /**
    210  * @def    NUM_MIME_BYTES_ARRAY               amrMimeBytes array size
    211  */
    212 /* ======================================================================= */
    213 #define NUM_MIME_BYTES_ARRAY 16
    214 /* ======================================================================= */
    215 /**
    216  * @def    NUM_IF2_BYTES_ARRAY                amrIF2Bytes array size
    217  */
    218 /* ======================================================================= */
    219 #define NUM_IF2_BYTES_ARRAY 16
    220 
    221 /* ======================================================================= */
    222 /**
    223  * @def    NBAMRDEC_DEBUGMEM   Turns memory leaks messaging on and off.
    224  *         APP_DEBUGMEM must be defined in Test App in order to get
    225  *         this functionality On.
    226  */
    227 /* ======================================================================= */
    228 #undef NBAMRDEC_DEBUGMEM
    229 /*#define NBAMRDEC_DEBUGMEM*/
    230 
    231 
    232 /*#define AMRDEC_DEBUG*/
    233 #undef AMRDEC_DEBUG
    234 #undef AMRDEC_MEMCHECK
    235 
    236 
    237 #ifndef UNDER_CE
    238 
    239 #define AMRDEC_EPRINT(...)  __android_log_print(ANDROID_LOG_VERBOSE, __FILE__,"%s %d:: ERROR    ",__FUNCTION__, __LINE__);\
    240                                     __android_log_print(ANDROID_LOG_VERBOSE, __FILE__, __VA_ARGS__);\
    241                                     __android_log_print(ANDROID_LOG_VERBOSE, __FILE__, "\n");
    242 
    243 #ifdef  AMRDEC_DEBUG
    244         #define AMRDEC_DPRINT(...)    __android_log_print(ANDROID_LOG_VERBOSE, __FILE__,"%s %d::    ",__FUNCTION__, __LINE__);\
    245                                     __android_log_print(ANDROID_LOG_VERBOSE, __FILE__, __VA_ARGS__);\
    246                                     __android_log_print(ANDROID_LOG_VERBOSE, __FILE__, "\n");
    247 #else
    248         #define AMRDEC_DPRINT(...)
    249 #endif
    250 
    251 #ifdef  AMRDEC_MEMCHECK
    252         #define AMRDEC_MEMPRINT(...)    fprintf(stderr,__VA_ARGS__)
    253 #else
    254         #define AMRDEC_MEMPRINT(...)
    255 #endif
    256 
    257 
    258 #ifdef  AMRDEC_DEBUG_MCP
    259         #define AMRDEC_MCP_DPRINT(...)    __android_log_print(ANDROID_LOG_VERBOSE, __FILE__,"%s %d:: MCP    ",__FUNCTION__, __LINE__);\
    260                                     __android_log_print(ANDROID_LOG_VERBOSE, __FILE__, __VA_ARGS__);\
    261                                     __android_log_print(ANDROID_LOG_VERBOSE, __FILE__, "\n");
    262 #else
    263         #define AMRDEC_MCP_DPRINT(...)
    264 #endif
    265 #else /*UNDER_CE*/
    266 #define AMRDEC_EPRINT   printf
    267 #ifdef  AMRDEC_DEBUG
    268  #define AMRDEC_DPRINT(STR, ARG...) printf()
    269 #else
    270 #endif
    271 
    272 #ifdef AMRDEC_MEMCHECK
    273     #define AMRDEC_MEMPRINT(STR, ARG...) printf()
    274 #else
    275 #endif
    276 #ifdef UNDER_CE
    277 
    278 #ifdef DEBUG
    279     #define AMRDEC_DPRINT   printf
    280     #define AMRDEC_MEMPRINT   printf
    281 
    282 #else
    283     #define AMRDEC_DPRINT
    284     #define AMRDEC_MEMPRINT
    285 #endif
    286 
    287 #endif  //UNDER_CE
    288 
    289 #endif
    290 
    291 
    292 /* ======================================================================= */
    293 /**
    294   * @def  CACHE_ALIGNMENT                           Buffer Cache Alignment
    295  */
    296 /* ======================================================================= */
    297 #define CACHE_ALIGNMENT 128
    298 
    299 /* ======================================================================= */
    300 /**
    301  * @def    NUM_OF_PORTS                       Number of Comunication Port
    302  */
    303 /* ======================================================================= */
    304 #define NUM_OF_PORTS 2
    305 
    306 /* ======================================================================= */
    307 /**
    308  * @def    _ERROR_PROPAGATION__              Allow Logic to Detec Arm Errors
    309  */
    310 /* ======================================================================= */
    311 #define _ERROR_PROPAGATION__
    312 
    313 /* ======================================================================= */
    314 /**
    315 * pthread variable to indicate OMX returned all buffers to app
    316 */
    317 /* ======================================================================= */
    318 pthread_mutex_t bufferReturned_mutex;
    319 pthread_cond_t bufferReturned_condition;
    320 
    321 /* ======================================================================= */
    322 /** NBAMRDEC_COMP_PORT_TYPE  Port Type
    323 *
    324 *  @param  NBAMRDEC_INPUT_PORT                  Port Type Input
    325 *
    326 *  @param  NBAMRDEC_OUTPUT_PORT                 Port Type Output
    327 *
    328 */
    329 /*  ==================================================================== */
    330 typedef enum NBAMRDEC_COMP_PORT_TYPE {
    331     NBAMRDEC_INPUT_PORT = 0,
    332     NBAMRDEC_OUTPUT_PORT
    333 }NBAMRDEC_COMP_PORT_TYPE;
    334 
    335 /* ======================================================================= */
    336 /** NBAMRDEC_StreamType  StreamType
    337 *
    338 *  @param  NBAMRDEC_DMM                 Stream Type DMM
    339 *
    340 *  @param  NBAMRDEC_INSTRM              Stream Type Input
    341 *
    342 *  @param  NBAMRDEC_OUTSTRM             Stream Type Output
    343 */
    344 /*  ==================================================================== */
    345 enum NBAMRDEC_StreamType
    346 {
    347     NBAMRDEC_DMM,
    348     NBAMRDEC_INSTRM,
    349     NBAMRDEC_OUTSTRM
    350 };
    351 
    352 /* ======================================================================= */
    353 /** NBAMRDEC_DecodeType  Decode Type Mode
    354 *
    355 *  @param  NBAMR                    OMX_AUDIO_AMRDTX
    356 *
    357 *  @param  NBAMRDEC_EFR             OMX_AUDIO_AMRDTX as EFR
    358 */
    359 /*  ==================================================================== */
    360 enum NBAMRDEC_DecodeType
    361 {
    362     NBAMR,
    363     NBAMRDEC_EFR
    364 };
    365 
    366 /* ======================================================================= */
    367 /** NBAMRDEC_MimeMode  Mime Mode
    368 *
    369 *  @param  NBAMRDEC_FORMATCONFORMANCE       Mime Mode and IF2 Off
    370 *
    371 *  @param  NBAMRDEC_MIMEMODE                Mime Mode On
    372 */
    373 /*  ==================================================================== */
    374 enum NBAMRDEC_MimeMode {
    375     NBAMRDEC_FORMATCONFORMANCE,
    376     NBAMRDEC_MIMEMODE,
    377         NBAMRDEC_IF2,
    378         NBAMRDEC_PADMIMEMODE
    379 };
    380 
    381 /* ======================================================================= */
    382 /** NBAMRDEC_BUFFER_Dir  Direction of the Buffer
    383 *
    384 *  @param  NBAMRDEC_DIRECTION_INPUT             Direction Input
    385 *
    386 *  @param  NBAMRDEC_DIRECTION_INPUT             Direction Output
    387 */
    388 /*  ==================================================================== */
    389 typedef enum {
    390     NBAMRDEC_DIRECTION_INPUT,
    391     NBAMRDEC_DIRECTION_OUTPUT
    392 }NBAMRDEC_BUFFER_Dir;
    393 
    394 /* =================================================================================== */
    395 /**
    396 *  Buffer Information.
    397 */
    398 /* ================================================================================== */
    399 typedef struct BUFFS
    400 {
    401     OMX_S8 BufHeader;
    402     OMX_S8 Buffer;
    403 }BUFFS;
    404 
    405 /* =================================================================================== */
    406 /**
    407 * NBAMR Buffer Header Type Info.
    408 */
    409 /* ================================================================================== */
    410 typedef struct BUFFERHEADERTYPE_INFO
    411 {
    412     OMX_BUFFERHEADERTYPE* pBufHeader[MAX_NUM_OF_BUFS];
    413     BUFFS bBufOwner[MAX_NUM_OF_BUFS];
    414 }BUFFERHEADERTYPE_INFO;
    415 
    416 /* ======================================================================= */
    417 /** LCML_MimeMode  modes
    418 *
    419 *  @param  MODE_MIME                    Mode MIME
    420 *
    421 *  @param  MODE_NONMIME                 Mode NONMIME
    422 */
    423 /*  ==================================================================== */
    424 typedef enum {
    425     MODE_MIME,
    426     MODE_NONMIME
    427 }LCML_MimeMode;
    428 
    429 /* =================================================================================== */
    430 /**
    431 * Socket node input parameters.
    432 */
    433 /* ================================================================================== */
    434 typedef struct AMRDEC_AudioCodecParams
    435 {
    436     unsigned long iSamplingRate;
    437     unsigned long iStrmId;
    438     unsigned short iAudioFormat;
    439 }AMRDEC_AudioCodecParams;
    440 
    441 /* =================================================================================== */
    442 /**
    443 * Socket node alg parameters..
    444 */
    445 /* ================================================================================== */
    446 /*typedef struct {
    447 
    448         unsigned long usEndOfFile;
    449         unsigned long usFrameLost;
    450 }AMRDEC_UAlgInBufParamStruct;*/
    451 
    452 typedef struct {
    453         unsigned long int usLastFrame;
    454         unsigned long int usFrameLost;
    455 }NBAMRDEC_FrameStruct;
    456 
    457 typedef struct{
    458          unsigned long int usNbFrames;
    459          NBAMRDEC_FrameStruct *pParamElem;
    460 }NBAMRDEC_ParamStruct;
    461 
    462 /* =================================================================================== */
    463 /**
    464 * LCML_NBAMRDEC_BUFHEADERTYPE
    465 */
    466 /* ================================================================================== */
    467 typedef struct LCML_NBAMRDEC_BUFHEADERTYPE {
    468       NBAMRDEC_BUFFER_Dir  eDir;
    469       OMX_BUFFERHEADERTYPE* buffer;
    470       NBAMRDEC_FrameStruct *pFrameParam;
    471       NBAMRDEC_ParamStruct *pBufferParam;
    472       DMM_BUFFER_OBJ* pDmmBuf;
    473 }LCML_NBAMRDEC_BUFHEADERTYPE;
    474 
    475 #ifndef UNDER_CE
    476 
    477 OMX_ERRORTYPE OMX_ComponentInit (OMX_HANDLETYPE hComp);
    478 
    479 #else
    480 /* =================================================================================== */
    481 /**
    482 *   OMX_EXPORT                                           WinCE Implicit Export Syntax
    483 */
    484 /* ================================================================================== */
    485 #define OMX_EXPORT __declspec(dllexport)
    486 
    487 OMX_EXPORT OMX_ERRORTYPE OMX_ComponentInit (OMX_HANDLETYPE hComp);
    488 
    489 #endif
    490 
    491 OMX_ERRORTYPE NBAMRDEC_StartComponentThread(OMX_HANDLETYPE pHandle);
    492 OMX_ERRORTYPE NBAMRDEC_StopComponentThread(OMX_HANDLETYPE pHandle);
    493 OMX_ERRORTYPE NBAMRDEC_FreeCompResources(OMX_HANDLETYPE pComponent);
    494 
    495 /* =================================================================================== */
    496 /**
    497 * Instrumentation info
    498 */
    499 /* ================================================================================== */
    500 
    501 typedef struct _NBAMRDEC_BUFFERLIST NBAMRDEC_BUFFERLIST;
    502 
    503 /* =================================================================================== */
    504 /**
    505 * Structure for buffer list
    506 */
    507 /* ================================================================================== */
    508 struct _NBAMRDEC_BUFFERLIST{
    509     OMX_BUFFERHEADERTYPE *pBufHdr[MAX_NUM_OF_BUFS]; /* records buffer header send by client */
    510     OMX_U32 bufferOwner[MAX_NUM_OF_BUFS];
    511     OMX_U32 bBufferPending[MAX_NUM_OF_BUFS];
    512     OMX_U16 numBuffers;
    513 };
    514 
    515 #ifdef UNDER_CE
    516     #ifndef _OMX_EVENT_
    517         #define _OMX_EVENT_
    518         typedef struct OMX_Event {
    519             HANDLE event;
    520         } OMX_Event;
    521     #endif
    522 #endif
    523 
    524 typedef struct PV_OMXComponentCapabilityFlagsType
    525 {
    526         ////////////////// OMX COMPONENT CAPABILITY RELATED MEMBERS (for opencore compatability)
    527         OMX_BOOL iIsOMXComponentMultiThreaded;
    528         OMX_BOOL iOMXComponentSupportsExternalOutputBufferAlloc;
    529         OMX_BOOL iOMXComponentSupportsExternalInputBufferAlloc;
    530         OMX_BOOL iOMXComponentSupportsMovableInputBuffers;
    531         OMX_BOOL iOMXComponentSupportsPartialFrames;
    532         OMX_BOOL iOMXComponentNeedsNALStartCode;
    533         OMX_BOOL iOMXComponentCanHandleIncompleteFrames;
    534 } PV_OMXComponentCapabilityFlagsType;
    535 
    536 /* =================================================================================== */
    537 /*
    538  * NBAMRDEC_BUFDATA
    539  */
    540 /* =================================================================================== */
    541 typedef struct NBAMRDEC_BUFDATA {
    542    OMX_U8 nFrames;
    543 }NBAMRDEC_BUFDATA;
    544 
    545 /* =================================================================================== */
    546 /**
    547 * Component private data
    548 */
    549 /* ================================================================================== */
    550 typedef struct AMRDEC_COMPONENT_PRIVATE
    551 {
    552     /** Array of pointers to BUFFERHEADERTYPE structues
    553        This pBufHeader[NBAMRDEC_INPUT_PORT] will point to all the
    554        BUFFERHEADERTYPE structures related to input port,
    555        not just one structure. Same is for output port
    556        also. */
    557 
    558 #ifdef __PERF_INSTRUMENTATION__
    559     PERF_OBJHANDLE pPERF, pPERFcomp;
    560     OMX_U32 nLcml_nCntIp;
    561     OMX_U32 nLcml_nCntOpReceived;
    562 #endif
    563 
    564     OMX_BUFFERHEADERTYPE* pBufHeader[NUM_OF_PORTS];
    565 
    566     BUFFERHEADERTYPE_INFO BufInfo[NUM_OF_PORTS];
    567 
    568     /** Structure of callback pointers */
    569     OMX_CALLBACKTYPE cbInfo;
    570 
    571     /** Handle for use with async callbacks */
    572     OMX_PORT_PARAM_TYPE sPortParam;
    573 
    574     /** Input port parameters */
    575     OMX_AUDIO_PARAM_PORTFORMATTYPE sInPortFormat;
    576 
    577     /** Output port parameters */
    578     OMX_AUDIO_PARAM_PORTFORMATTYPE sOutPortFormat;
    579 
    580     /** This will contain info like how many buffers
    581         are there for input/output ports, their size etc, but not
    582         BUFFERHEADERTYPE POINTERS. */
    583     OMX_PARAM_PORTDEFINITIONTYPE* pPortDef[NUM_OF_PORTS];
    584 
    585     /** NBAMR Component Parameters */
    586     OMX_AUDIO_PARAM_AMRTYPE* amrParams[NUM_OF_PORTS]; /*amrParams[Output] = OMX_AUDIO_PARAM_PCMMODETYPE*/
    587 
    588     /** This is component handle */
    589     OMX_COMPONENTTYPE* pHandle;
    590 
    591     /** Current state of this component */
    592     OMX_STATETYPE curState;
    593 
    594     /** The component thread handle */
    595     pthread_t ComponentThread;
    596 
    597     /** The pipes for sending buffers to the thread */
    598     int dataPipe[2];
    599 
    600     /** The pipes for sending buffers to the thread */
    601     int cmdPipe[2];
    602 
    603     /** The pipes for sending buffers to the thread */
    604     int cmdDataPipe[2];
    605 
    606     /** Set to indicate component is stopping */
    607     OMX_U32 bIsStopping;
    608 
    609     /** Count of number of buffers outstanding with bridge */
    610     OMX_U32 lcml_nIpBuf;
    611 
    612     /** Count of number of buffers outstanding with bridge */
    613     OMX_U32 lcml_nOpBuf;
    614 
    615     /** Number of Buffers In the Application*/
    616     OMX_U32 app_nBuf;
    617 
    618     /** LCML Number Input Buffer Received*/
    619     OMX_U32 lcml_nCntIp;
    620 
    621     /** LCML Number Output Buffer Received*/
    622     OMX_U32 lcml_nCntOpReceived;
    623 
    624     /** Num Reclaimed OutPut Buff    */
    625     OMX_U32 num_Reclaimed_Op_Buff;
    626 
    627     /** LCML Handle */
    628     OMX_HANDLETYPE pLcmlHandle;
    629 
    630     /** LCML Buffer Header */
    631     LCML_NBAMRDEC_BUFHEADERTYPE *pLcmlBufHeader[2];
    632 
    633     /** Flag for mime mode */
    634     OMX_S16 iAmrMimeFlag;
    635 
    636     /** Sampling Frequeny */
    637     OMX_S16 iAmrSamplingFrequeny;
    638 
    639     /** Number of channels */
    640     OMX_U32 iAmrChannels;
    641 
    642     /** Flag for Amr mode */
    643     OMX_S16 iAmrMode;
    644 
    645     /** Flag for DASF mode */
    646     OMX_S16 dasfmode;
    647 
    648     /** Flag for mime mode */
    649     OMX_S16 mimemode;
    650 
    651     /** Flag for ACDN mode */
    652     OMX_S16 acdnmode;
    653 
    654     /** Writing pipe Used for DSP_RENDERING_ON */
    655     int fdwrite;
    656 
    657     /** Reading pipe Used for DSP_RENDERING_ON */
    658     int fdread;
    659 
    660     /* ID stream ID*/
    661     OMX_U32 streamID;
    662 
    663     /* Flag for Port Defs Allocated*/
    664     OMX_U32 bPortDefsAllocated;
    665 
    666     /* Flag for Component Thread Started*/
    667     OMX_U32 bCompThreadStarted;
    668 
    669     /** Mark data */
    670     OMX_PTR pMarkData;
    671 
    672     /** Mark buffer */
    673     OMX_MARKTYPE *pMarkBuf;
    674 
    675     /** Mark target component */
    676    OMX_HANDLETYPE hMarkTargetComponent;
    677 
    678    /** Flag set when buffer should not be queued to the DSP */
    679    OMX_U32 bBypassDSP;
    680 
    681    /** Input buffer list */
    682    NBAMRDEC_BUFFERLIST *pInputBufferList;
    683 
    684    /** Output buffer list */
    685    NBAMRDEC_BUFFERLIST *pOutputBufferList;
    686 
    687    /** LCML stream attributes */
    688    LCML_STRMATTR *strmAttr;
    689 
    690    /** Component version */
    691    OMX_U32 nVersion;
    692 
    693    /** Play Complete Flag */
    694    OMX_U32 bPlayCompleteFlag;
    695 
    696    /** NBAMR Mime Bytes */
    697    OMX_U32 amrMimeBytes[NUM_MIME_BYTES_ARRAY];
    698 
    699    /**NBAMR IF2 Bytes**/
    700    OMX_U32 amrIF2Bytes[NUM_IF2_BYTES_ARRAY];
    701 
    702    /** Number of Bytes holding to be sent*/
    703    OMX_U32 nHoldLength;
    704 
    705    /** Pointer to the data holding to be sent*/
    706    OMX_U8* pHoldBuffer;
    707 
    708    /** Flag set when LCML handle is opened */
    709    OMX_S16 bLcmlHandleOpened;
    710 
    711    /** Keeps track of the number of nFillThisBufferCount() calls */
    712    OMX_U32 nFillThisBufferCount;
    713 
    714    /** Keeps track of the number of nFillBufferDoneCount() calls */
    715     OMX_U32 nFillBufferDoneCount;
    716 
    717    /** Keeps track of the number of nEmptyThisBufferCount() calls */
    718     OMX_U32 nEmptyThisBufferCount;
    719 
    720    /** Keeps track of the number of nEmptyBufferDoneCount() calls */
    721     OMX_U32 nEmptyBufferDoneCount;
    722 
    723    /** Parameters for the Audio Codec */
    724    AMRDEC_AudioCodecParams *pParams;
    725 
    726    /** Flag for Init Params Initialized */
    727    OMX_U32 bInitParamsInitialized;
    728 
    729    /** Flag for bIdleCommandPending */
    730  /*  OMX_U32 bIdleCommandPending;  */
    731 
    732    /** Array of Input Buffers that are pending to sent due State = Idle */
    733    OMX_BUFFERHEADERTYPE *pInputBufHdrPending[MAX_NUM_OF_BUFS];
    734 
    735    /** Number of Input Buffers that are pending to sent due State = Idle */
    736    OMX_U32 nNumInputBufPending;
    737 
    738    /** Array of Output Buffers that are pending to sent due State = Idle */
    739    OMX_BUFFERHEADERTYPE *pOutputBufHdrPending[MAX_NUM_OF_BUFS];
    740 
    741    /** Number of Output Buffers that are pending to sent due State = Idle */
    742    OMX_U32 nNumOutputBufPending;
    743 
    744    /** Flag for bDisableCommandPending*/
    745    OMX_U32 bDisableCommandPending;
    746 
    747    OMX_U32 bEnableCommandPending;
    748 
    749    /** Flag for bDisableCommandParam*/
    750    OMX_U32 bDisableCommandParam;
    751 
    752    OMX_U32 bEnableCommandParam;
    753 
    754     /** Flag to set when socket node stop callback should not transition
    755         component to OMX_StateIdle */
    756     OMX_U32 bNoIdleOnStop;
    757 
    758     /** Number of outstanding FillBufferDone() calls */
    759     OMX_U32 nOutStandingFillDones;
    760 
    761     /** Stop Codec Command Sent Flag*/
    762     OMX_U8 bStopSent;
    763 
    764     OMX_U32 nRuntimeInputBuffers;
    765 
    766     OMX_U32 nRuntimeOutputBuffers;
    767 
    768     /* Removing sleep() calls. Definition. */
    769 #ifndef UNDER_CE
    770     pthread_mutex_t AlloBuf_mutex;
    771     pthread_cond_t AlloBuf_threshold;
    772     OMX_U8 AlloBuf_waitingsignal;
    773 
    774     pthread_mutex_t codecStop_mutex;
    775     pthread_cond_t codecStop_threshold;
    776     OMX_U8 codecStop_waitingsignal;
    777 
    778     pthread_mutex_t InLoaded_mutex;
    779     pthread_cond_t InLoaded_threshold;
    780     OMX_U8 InLoaded_readytoidle;
    781 
    782     pthread_mutex_t InIdle_mutex;
    783     pthread_cond_t InIdle_threshold;
    784     OMX_U8 InIdle_goingtoloaded;
    785 
    786     OMX_S8 nUnhandledFillThisBuffers;
    787     OMX_S8 nUnhandledEmptyThisBuffers;
    788     OMX_BOOL bFlushOutputPortCommandPending;
    789     OMX_BOOL bFlushInputPortCommandPending;
    790 #else
    791     OMX_Event AlloBuf_event;
    792     OMX_U8 AlloBuf_waitingsignal;
    793 
    794     OMX_Event InLoaded_event;
    795     OMX_U8 InLoaded_readytoidle;
    796 
    797     OMX_Event InIdle_event;
    798     OMX_U8 InIdle_goingtoloaded;
    799 #endif
    800     /* Removing sleep() calls. Definition. */
    801 
    802     OMX_U8 PendingPausedBufs;
    803     OMX_BUFFERHEADERTYPE *pOutputBufHdrPausedPending[MAX_NUM_OF_BUFS];
    804 
    805     OMX_BUFFERHEADERTYPE *LastOutbuf;
    806 
    807     OMX_BOOL bIsInvalidState;
    808     OMX_STRING* sDeviceString;
    809 
    810     void* ptrLibLCML;
    811 
    812     /** Circular array to keep buffer timestamps */
    813     OMX_S64 arrBufIndex[MAX_NUM_OF_BUFS];
    814     /** Circular array to keep buffer nTickCounts */
    815     OMX_S64 arrTickCount[MAX_NUM_OF_BUFS];
    816     /** Index to arrBufIndex[], used for input buffer timestamps */
    817     OMX_U8 IpBufindex;
    818     /** Index to arrBufIndex[], used for output buffer timestamps */
    819     OMX_U8 OpBufindex;
    820 
    821     /** Flag to flush SN after EOS in order to process more buffers after EOS**/
    822     OMX_U8 SendAfterEOS;
    823 
    824     /** Flag to mark the first sent buffer**/
    825     OMX_U8 first_buff;
    826     /** First Time Stamp sent **/
    827     OMX_TICKS first_TS;
    828 
    829     /** Temporal time stamp **/
    830     OMX_TICKS temp_TS;
    831 
    832     OMX_BOOL bLoadedCommandPending;
    833 
    834     OMX_PARAM_COMPONENTROLETYPE componentRole;
    835 
    836     /** Pointer to port priority management structure */
    837     OMX_PRIORITYMGMTTYPE* pPriorityMgmt;
    838 
    839 #ifdef RESOURCE_MANAGER_ENABLED
    840     RMPROXY_CALLBACKTYPE rmproxyCallback;
    841 #endif
    842 
    843     OMX_BOOL bPreempted;
    844     OMX_BOOL bFrameLost;
    845 
    846     /** Flag to mark RTSP**/
    847     OMX_U8 using_rtsp;
    848 
    849     PV_OMXComponentCapabilityFlagsType iPVCapabilityFlags;
    850 
    851     struct OMX_TI_Debug dbg;
    852 
    853     /** Indicate when first output buffer received from DSP **/
    854     OMX_U32 first_output_buf_rcv;
    855 
    856 } AMRDEC_COMPONENT_PRIVATE;
    857 
    858 typedef enum OMX_NBAMRDEC_INDEXAUDIOTYPE {
    859         OMX_IndexCustomNbAmrDecModeEfrConfig = 0xFF000001,
    860         OMX_IndexCustomNbAmrDecModeAmrConfig,
    861         OMX_IndexCustomNbAmrDecModeAcdnConfig,
    862         OMX_IndexCustomNbAmrDecModeDasfConfig,
    863         OMX_IndexCustomNbAmrDecModeMimeConfig,
    864         OMX_IndexCustomNbAmrDecHeaderInfoConfig,
    865         OMX_IndexCustomNbAmrDecStreamIDConfig,
    866         OMX_IndexCustomNbAmrDecDataPath,
    867         OMX_IndexCustomNbAmrDecNextFrameLost,
    868         OMX_IndexCustomDebug
    869 }OMX_NBAMRDEC_INDEXAUDIOTYPE;
    870 
    871 /*=======================================================================*/
    872 /*! @fn SignalIfAllBuffersAreReturned
    873 
    874  * @brief Sends pthread signal to indicate OMX has returned all buffers to app
    875 
    876  * @param  none
    877 
    878  * @Return void
    879 
    880  */
    881 /*=======================================================================*/
    882 void SignalIfAllBuffersAreReturned(AMRDEC_COMPONENT_PRIVATE *pComponentPrivate);
    883 
    884 #endif /* OMX_AMRDECODER_H */
    885