3 * Copyright (C) Texas Instruments - http://www.ti.com/
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.
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.
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
21 /* ==============================================================================
22 * Texas Instruments OMAP (TM) Platform Software
23 * (c) Copyright Texas Instruments, Incorporated. All Rights Reserved.
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 * ============================================================================ */
29 * @file OMX_WbAmrDecoder.c
31 * This file implements OMX Component for WbAMR decoder that
32 * is fully compliant with the OMX Audio specification 1.5.
38 /* ----------------------------------------------------------------------------
41 *! ===================================
42 *! 12-Sept-2005 mf: Initial Version. Change required per OMAPSWxxxxxxxxx
43 *! to provide _________________.
45 * ============================================================================= */
48 /* ------compilation control switches -------------------------*/
49 /****************************************************************
51 ****************************************************************/
52 /* ----- system and platform files ----------------------------*/
61 #include <sys/types.h>
62 #include <sys/ioctl.h>
63 #include <sys/select.h>
74 #ifdef DSP_RENDERING_ON
75 #include <AudioManagerAPI.h>
78 #ifdef RESOURCE_MANAGER_ENABLED
79 #include <ResourceManagerProxyAPI.h>
82 /*-------program files ----------------------------------------*/
83 #include <OMX_Component.h>
86 #include "OMX_WbAmrDecoder.h"
87 #include "OMX_WbAmrDec_Utils.h"
89 #define AMRWB_DEC_ROLE "audio_decoder.amrwb"
92 /****************************************************************
93 * EXTERNAL REFERENCES NOTE : only use if not found in header file
94 ****************************************************************/
95 /*--------data declarations -----------------------------------*/
97 /*--------function prototypes ---------------------------------*/
99 /****************************************************************
100 * PUBLIC DECLARATIONS Defined here, used elsewhere
101 ****************************************************************/
102 /*--------data declarations -----------------------------------*/
104 /*--------function prototypes ---------------------------------*/
106 /****************************************************************
107 * PRIVATE DECLARATIONS Defined here, used only here
108 ****************************************************************/
109 /*--------data declarations -----------------------------------*/
111 /*--------function prototypes ---------------------------------*/
113 static OMX_ERRORTYPE SetCallbacks (OMX_HANDLETYPE hComp,
114 OMX_CALLBACKTYPE* pCallBacks, OMX_PTR pAppData);
115 static OMX_ERRORTYPE GetComponentVersion (OMX_HANDLETYPE hComp,
116 OMX_STRING pComponentName,
117 OMX_VERSIONTYPE* pComponentVersion,
118 OMX_VERSIONTYPE* pSpecVersion,
119 OMX_UUIDTYPE* pComponentUUID);
121 static OMX_ERRORTYPE SendCommand (OMX_HANDLETYPE hComp, OMX_COMMANDTYPE nCommand,
122 OMX_U32 nParam, OMX_PTR pCmdData);
124 static OMX_ERRORTYPE GetParameter(OMX_HANDLETYPE hComp, OMX_INDEXTYPE nParamIndex,
125 OMX_PTR ComponentParamStruct);
126 static OMX_ERRORTYPE SetParameter (OMX_HANDLETYPE hComp,
127 OMX_INDEXTYPE nParamIndex,
128 OMX_PTR ComponentParamStruct);
129 static OMX_ERRORTYPE GetConfig (OMX_HANDLETYPE hComp,
130 OMX_INDEXTYPE nConfigIndex,
131 OMX_PTR pComponentConfigStructure);
132 static OMX_ERRORTYPE SetConfig (OMX_HANDLETYPE hComp,
133 OMX_INDEXTYPE nConfigIndex,
134 OMX_PTR pComponentConfigStructure);
136 static OMX_ERRORTYPE EmptyThisBuffer (OMX_HANDLETYPE hComp, OMX_BUFFERHEADERTYPE* pBuffer);
138 static OMX_ERRORTYPE FillThisBuffer (OMX_HANDLETYPE hComp, OMX_BUFFERHEADERTYPE* pBuffer);
139 static OMX_ERRORTYPE GetState (OMX_HANDLETYPE hComp, OMX_STATETYPE* pState);
140 static OMX_ERRORTYPE ComponentTunnelRequest (OMX_HANDLETYPE hComp,
141 OMX_U32 nPort, OMX_HANDLETYPE hTunneledComp,
142 OMX_U32 nTunneledPort,
143 OMX_TUNNELSETUPTYPE* pTunnelSetup);
145 static OMX_ERRORTYPE ComponentDeInit(OMX_HANDLETYPE pHandle);
146 static OMX_ERRORTYPE AllocateBuffer (OMX_IN OMX_HANDLETYPE hComponent,
147 OMX_INOUT OMX_BUFFERHEADERTYPE** pBuffer,
148 OMX_IN OMX_U32 nPortIndex,
149 OMX_IN OMX_PTR pAppPrivate,
150 OMX_IN OMX_U32 nSizeBytes);
152 static OMX_ERRORTYPE FreeBuffer(
153 OMX_IN OMX_HANDLETYPE hComponent,
154 OMX_IN OMX_U32 nPortIndex,
155 OMX_IN OMX_BUFFERHEADERTYPE* pBuffer);
157 static OMX_ERRORTYPE UseBuffer (
158 OMX_IN OMX_HANDLETYPE hComponent,
159 OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr,
160 OMX_IN OMX_U32 nPortIndex,
161 OMX_IN OMX_PTR pAppPrivate,
162 OMX_IN OMX_U32 nSizeBytes,
163 OMX_IN OMX_U8* pBuffer);
165 static OMX_ERRORTYPE GetExtensionIndex(
166 OMX_IN OMX_HANDLETYPE hComponent,
167 OMX_IN OMX_STRING cParameterName,
168 OMX_OUT OMX_INDEXTYPE* pIndexType);
170 static OMX_ERRORTYPE ComponentRoleEnum(
171 OMX_IN OMX_HANDLETYPE hComponent,
172 OMX_OUT OMX_U8 *cRole,
173 OMX_IN OMX_U32 nIndex);
174 #ifdef DSP_RENDERING_ON
175 #define FIFO1 "/dev/fifo.1"
176 #define FIFO2 "/dev/fifo.2"
180 AM_COMMANDDATATYPE cmd_data;
182 /*-------------------------------------------------------------------*/
184 * OMX_ComponentInit() Set the all the function pointers of component
186 * This method will update the component function pointer to the handle
188 * @param hComp handle for this instance of the component
190 * @retval OMX_NoError Success, ready to roll
191 * OMX_ErrorInsufficientResources If the newmalloc fails
193 /*-------------------------------------------------------------------*/
194 OMX_ERRORTYPE OMX_ComponentInit (OMX_HANDLETYPE hComp)
196 OMX_PARAM_PORTDEFINITIONTYPE *pPortDef_ip, *pPortDef_op;
197 WBAMR_DEC_COMPONENT_PRIVATE *pComponentPrivate = NULL;
198 OMX_AUDIO_PARAM_AMRTYPE *amr_ip;
199 OMX_AUDIO_PARAM_PCMMODETYPE *amr_op;
200 OMX_ERRORTYPE error = OMX_ErrorNone;
201 OMX_ERRORTYPE eError = OMX_ErrorNone;
202 OMX_COMPONENTTYPE *pHandle = (OMX_COMPONENTTYPE*) hComp;
205 OMXDBG_PRINT(stderr, PRINT, 1, 0, "Entering\n");
207 /*Set the all component function pointer to the handle */
208 pHandle->SetCallbacks = SetCallbacks;
209 pHandle->GetComponentVersion = GetComponentVersion;
210 pHandle->SendCommand = SendCommand;
211 pHandle->GetParameter = GetParameter;
212 pHandle->SetParameter = SetParameter;
213 pHandle->GetConfig = GetConfig;
214 pHandle->SetConfig = SetConfig;
215 pHandle->GetState = GetState;
216 pHandle->EmptyThisBuffer = EmptyThisBuffer;
217 pHandle->FillThisBuffer = FillThisBuffer;
218 pHandle->ComponentTunnelRequest = ComponentTunnelRequest;
219 pHandle->ComponentDeInit = ComponentDeInit;
220 pHandle->AllocateBuffer = AllocateBuffer;
221 pHandle->FreeBuffer = FreeBuffer;
222 pHandle->UseBuffer = UseBuffer;
223 pHandle->GetExtensionIndex= GetExtensionIndex;
224 pHandle->ComponentRoleEnum = ComponentRoleEnum;
226 /*Allocate the memory for Component private data area */
227 OMX_MALLOC_GENERIC(pHandle->pComponentPrivate, WBAMR_DEC_COMPONENT_PRIVATE);
230 ((WBAMR_DEC_COMPONENT_PRIVATE *)
231 pHandle->pComponentPrivate)->pHandle = pHandle;
233 /* Initialize component data structures to default values */
234 ((WBAMR_DEC_COMPONENT_PRIVATE *)
235 pHandle->pComponentPrivate)->sPortParam.nPorts = 0x2;
236 ((WBAMR_DEC_COMPONENT_PRIVATE *)
237 pHandle->pComponentPrivate)->sPortParam.nStartPortNumber = 0x0;
239 OMX_MALLOC_GENERIC(amr_ip , OMX_AUDIO_PARAM_AMRTYPE);
240 OMX_MALLOC_GENERIC(amr_op , OMX_AUDIO_PARAM_PCMMODETYPE);
242 ((WBAMR_DEC_COMPONENT_PRIVATE *)
243 pHandle->pComponentPrivate)->wbamrParams[WBAMR_DEC_INPUT_PORT] = amr_ip;
244 ((WBAMR_DEC_COMPONENT_PRIVATE *)
245 pHandle->pComponentPrivate)->wbamrParams[WBAMR_DEC_OUTPUT_PORT] = (OMX_AUDIO_PARAM_AMRTYPE*)amr_op;
249 pComponentPrivate = pHandle->pComponentPrivate;
250 OMX_DBG_INIT(pComponentPrivate->dbg, "OMX_DBG_WBAMRDEC");
252 #ifdef __PERF_INSTRUMENTATION__
253 pComponentPrivate->pPERF = PERF_Create(PERF_FOURCC('W','B','D','_'),
255 PERF_ModuleAudioDecode);
258 #ifdef ANDROID /* currently using default values until more is understood */
259 pComponentPrivate->iPVCapabilityFlags.iIsOMXComponentMultiThreaded = OMX_TRUE; /* this should be true always for TI components */
260 pComponentPrivate->iPVCapabilityFlags.iOMXComponentSupportsExternalOutputBufferAlloc = OMX_FALSE;
261 pComponentPrivate->iPVCapabilityFlags.iOMXComponentSupportsExternalInputBufferAlloc = OMX_FALSE;
262 pComponentPrivate->iPVCapabilityFlags.iOMXComponentSupportsMovableInputBuffers = OMX_FALSE; /* experiment with this */
263 pComponentPrivate->iPVCapabilityFlags.iOMXComponentSupportsPartialFrames = OMX_FALSE; /* experiment with this */
264 pComponentPrivate->iPVCapabilityFlags.iOMXComponentNeedsNALStartCode = OMX_FALSE; /* used only for H.264, leave this as false */
265 pComponentPrivate->iPVCapabilityFlags.iOMXComponentCanHandleIncompleteFrames = OMX_FALSE; /* experiment with this */
268 OMX_MALLOC_GENERIC(pComponentPrivate->pInputBufferList, WBAMR_DEC_BUFFERLIST);
269 pComponentPrivate->pInputBufferList->numBuffers = 0; /* initialize number of buffers */
270 OMX_MALLOC_GENERIC(pComponentPrivate->pOutputBufferList, WBAMR_DEC_BUFFERLIST);
271 OMX_MALLOC_GENERIC(pComponentPrivate->pPriorityMgmt, OMX_PRIORITYMGMTTYPE);
272 pComponentPrivate->pOutputBufferList->numBuffers = 0; /* initialize number of buffers */
273 for (i=0; i < WBAMR_DEC_MAX_NUM_OF_BUFS; i++) {
274 pComponentPrivate->pOutputBufferList->pBufHdr[i] = NULL;
275 pComponentPrivate->pInputBufferList->pBufHdr[i] = NULL;
276 pComponentPrivate->arrTickCount[i] = 0;
277 pComponentPrivate->arrBufIndex[i] = 0;
280 pComponentPrivate->IpBufindex = 0;
281 pComponentPrivate->OpBufindex = 0;
283 OMX_PRINT1(pComponentPrivate->dbg, "Setting dasfmode and mimemode to 0\n");
284 pComponentPrivate->dasfmode = 0;
285 pComponentPrivate->mimemode = 0;
286 pComponentPrivate->bPortDefsAllocated = 0;
287 pComponentPrivate->bCompThreadStarted = 0;
288 pComponentPrivate->nHoldLength = 0;
289 pComponentPrivate->pHoldBuffer = NULL;
290 pComponentPrivate->bInitParamsInitialized = 0;
291 pComponentPrivate->wbamrMimeBytes[0] = WBAMR_DEC_FRAME_SIZE_18;
292 pComponentPrivate->wbamrMimeBytes[1] = WBAMR_DEC_FRAME_SIZE_24;
293 pComponentPrivate->wbamrMimeBytes[2] = WBAMR_DEC_FRAME_SIZE_33;
294 pComponentPrivate->wbamrMimeBytes[3] = WBAMR_DEC_FRAME_SIZE_37;
295 pComponentPrivate->wbamrMimeBytes[4] = WBAMR_DEC_FRAME_SIZE_41;
296 pComponentPrivate->wbamrMimeBytes[5] = WBAMR_DEC_FRAME_SIZE_47;
297 pComponentPrivate->wbamrMimeBytes[6] = WBAMR_DEC_FRAME_SIZE_51;
298 pComponentPrivate->wbamrMimeBytes[7] = WBAMR_DEC_FRAME_SIZE_59;
299 pComponentPrivate->wbamrMimeBytes[8] = WBAMR_DEC_FRAME_SIZE_61;
300 pComponentPrivate->wbamrMimeBytes[9] = WBAMR_DEC_FRAME_SIZE_6;
301 pComponentPrivate->wbamrMimeBytes[10] = WBAMR_DEC_FRAME_SIZE_0;
302 pComponentPrivate->wbamrMimeBytes[11] = WBAMR_DEC_FRAME_SIZE_0;
303 pComponentPrivate->wbamrMimeBytes[12] = WBAMR_DEC_FRAME_SIZE_0;
304 pComponentPrivate->wbamrMimeBytes[13] = WBAMR_DEC_FRAME_SIZE_0;
305 pComponentPrivate->wbamrMimeBytes[14] = WBAMR_DEC_FRAME_SIZE_1;
306 pComponentPrivate->wbamrMimeBytes[15] = WBAMR_DEC_FRAME_SIZE_1;
308 pComponentPrivate->wbamrIf2Bytes[0] = WBAMR_DEC_FRAME_SIZE_18;
309 pComponentPrivate->wbamrIf2Bytes[1] = WBAMR_DEC_FRAME_SIZE_23;
310 pComponentPrivate->wbamrIf2Bytes[2] = WBAMR_DEC_FRAME_SIZE_33;
311 pComponentPrivate->wbamrIf2Bytes[3] = WBAMR_DEC_FRAME_SIZE_37;
312 pComponentPrivate->wbamrIf2Bytes[4] = WBAMR_DEC_FRAME_SIZE_41;
313 pComponentPrivate->wbamrIf2Bytes[5] = WBAMR_DEC_FRAME_SIZE_47;
314 pComponentPrivate->wbamrIf2Bytes[6] = WBAMR_DEC_FRAME_SIZE_51;
315 pComponentPrivate->wbamrIf2Bytes[7] = WBAMR_DEC_FRAME_SIZE_59;
316 pComponentPrivate->wbamrIf2Bytes[8] = WBAMR_DEC_FRAME_SIZE_61;
317 pComponentPrivate->wbamrIf2Bytes[9] = WBAMR_DEC_FRAME_SIZE_6;
318 pComponentPrivate->wbamrIf2Bytes[10] = WBAMR_DEC_FRAME_SIZE_0;
319 pComponentPrivate->wbamrIf2Bytes[11] = WBAMR_DEC_FRAME_SIZE_0;
320 pComponentPrivate->wbamrIf2Bytes[12] = WBAMR_DEC_FRAME_SIZE_0;
321 pComponentPrivate->wbamrIf2Bytes[13] = WBAMR_DEC_FRAME_SIZE_0;
322 pComponentPrivate->wbamrIf2Bytes[14] = WBAMR_DEC_FRAME_SIZE_1;
323 pComponentPrivate->wbamrIf2Bytes[15] = WBAMR_DEC_FRAME_SIZE_1;
325 pComponentPrivate->pMarkBuf = NULL;
326 pComponentPrivate->pMarkData = NULL;
327 pComponentPrivate->nEmptyBufferDoneCount = 0;
328 pComponentPrivate->nEmptyThisBufferCount = 0;
329 pComponentPrivate->nFillBufferDoneCount = 0;
330 pComponentPrivate->nFillThisBufferCount = 0;
331 pComponentPrivate->strmAttr = NULL;
332 /* pComponentPrivate->bIdleCommandPending = 0; */
333 pComponentPrivate->bDisableCommandParam = 0;
334 pComponentPrivate->SendAfterEOS = 0;
335 pComponentPrivate->PendingPausedBufs = 0;
336 for (i=0; i < WBAMR_DEC_MAX_NUM_OF_BUFS; i++) {
337 pComponentPrivate->pInputBufHdrPending[i] = NULL;
338 pComponentPrivate->pOutputBufHdrPending[i] = NULL;
340 pComponentPrivate->nNumInputBufPending = 0;
341 pComponentPrivate->nNumOutputBufPending = 0;
342 pComponentPrivate->bDisableCommandPending = 0;
343 pComponentPrivate->nOutStandingFillDones = 0;
344 pComponentPrivate->bStopSent=0;
345 pComponentPrivate->bNoIdleOnStop = OMX_FALSE;
346 pComponentPrivate->pParams = NULL; /* Without this initialization repetition cases failed. */
347 pComponentPrivate->LastOutbuf=NULL;
348 pComponentPrivate->using_rtsp = 0;
349 strcpy((char*)pComponentPrivate->componentRole.cRole, AMRWB_DEC_ROLE);
353 /* Set input port format defaults */
354 pComponentPrivate->sInPortFormat.nPortIndex = WBAMR_DEC_INPUT_PORT;
355 pComponentPrivate->sInPortFormat.nIndex = OMX_IndexParamAudioAmr;
356 pComponentPrivate->sInPortFormat.eEncoding = OMX_AUDIO_CodingAMR;
359 /* Set output port format defaults */
360 pComponentPrivate->sOutPortFormat.nPortIndex = WBAMR_DEC_OUTPUT_PORT;
361 pComponentPrivate->sOutPortFormat.nIndex = OMX_IndexParamAudioPcm;
362 pComponentPrivate->sOutPortFormat.eEncoding = OMX_AUDIO_CodingPCM;
364 pComponentPrivate->bPreempted = OMX_FALSE;
366 amr_ip->nPortIndex = OMX_DirInput;
367 amr_ip->nChannels = 1;
368 amr_ip->nBitRate = 8000;
369 amr_ip->eAMRBandMode = OMX_AUDIO_AMRBandModeWB0;
370 amr_ip->eAMRDTXMode = OMX_AUDIO_AMRDTXModeOff;
371 amr_ip->eAMRFrameFormat = OMX_AUDIO_AMRFrameFormatConformance;
372 amr_ip->nSize = sizeof (OMX_AUDIO_PARAM_AMRTYPE);
374 /* PCM format defaults - These values are required to pass StdAudioDecoderTest*/
375 amr_op->nPortIndex = OMX_DirOutput;
376 amr_op->nChannels = 1;
377 amr_op->eNumData= OMX_NumericalDataSigned;
378 amr_op->nSamplingRate = 16000;
379 amr_op->nBitPerSample = 16;
380 amr_op->ePCMMode = OMX_AUDIO_PCMModeLinear;
382 OMX_MALLOC_SIZE(pComponentPrivate->sDeviceString, (100*sizeof(char)),OMX_STRING);
383 pComponentPrivate->IpBufindex = 0;
384 pComponentPrivate->OpBufindex = 0;
385 pComponentPrivate->ptrLibLCML = NULL;
387 strcpy((char*)pComponentPrivate->sDeviceString,"/eteedn:i0:o0/codec\0");
389 pthread_mutex_init(&pComponentPrivate->AlloBuf_mutex, NULL);
390 pthread_cond_init (&pComponentPrivate->AlloBuf_threshold, NULL);
391 pComponentPrivate->AlloBuf_waitingsignal = 0;
393 pthread_mutex_init(&pComponentPrivate->codecStop_mutex, NULL);
394 pthread_cond_init (&pComponentPrivate->codecStop_threshold, NULL);
395 pComponentPrivate->codecStop_waitingsignal = 0;
397 pthread_mutex_init(&pComponentPrivate->InLoaded_mutex, NULL);
398 pthread_cond_init (&pComponentPrivate->InLoaded_threshold, NULL);
399 pComponentPrivate->InLoaded_readytoidle = 0;
401 pthread_mutex_init(&pComponentPrivate->InIdle_mutex, NULL);
402 pthread_cond_init (&pComponentPrivate->InIdle_threshold, NULL);
403 pComponentPrivate->InIdle_goingtoloaded = 0;
405 OMX_CreateEvent(&(pComponentPrivate->AlloBuf_event));
406 pComponentPrivate->AlloBuf_waitingsignal = 0;
408 OMX_CreateEvent(&(pComponentPrivate->InLoaded_event));
409 pComponentPrivate->InLoaded_readytoidle = 0;
411 OMX_CreateEvent(&(pComponentPrivate->InIdle_event));
412 pComponentPrivate->InIdle_goingtoloaded = 0;
414 OMX_MALLOC_GENERIC(pPortDef_ip, OMX_PARAM_PORTDEFINITIONTYPE);
416 OMX_MALLOC_GENERIC(pPortDef_op, OMX_PARAM_PORTDEFINITIONTYPE);
418 OMX_PRBUFFER2(pComponentPrivate->dbg, "[ALLOC] %p\n",pPortDef_op);
419 OMX_PRINT1(pComponentPrivate->dbg, "pPortDef_ip = %p\n",pPortDef_ip);
420 OMX_PRINT1(pComponentPrivate->dbg, "pPortDef_op = %p\n",pPortDef_op);
422 ((WBAMR_DEC_COMPONENT_PRIVATE*) pHandle->pComponentPrivate)->pPortDef[WBAMR_DEC_INPUT_PORT]
425 ((WBAMR_DEC_COMPONENT_PRIVATE*) pHandle->pComponentPrivate)->pPortDef[WBAMR_DEC_OUTPUT_PORT]
427 pPortDef_ip->nSize = sizeof (OMX_PARAM_PORTDEFINITIONTYPE);
428 pPortDef_ip->nPortIndex = 0x0;
429 pPortDef_ip->nBufferCountActual = NUM_WBAMRDEC_INPUT_BUFFERS;
430 pPortDef_ip->nBufferCountMin = NUM_WBAMRDEC_INPUT_BUFFERS;
431 pPortDef_ip->nBufferAlignment = DSP_CACHE_ALIGNMENT;
432 pPortDef_ip->eDir = OMX_DirInput;
433 pPortDef_ip->bEnabled = OMX_TRUE;
434 /* Use bigger IN buffer size for PV-Android */
435 pPortDef_ip->nBufferSize = IP_WBAMRDEC_BUFFERSIZE;
436 pPortDef_ip->bPopulated = 0;
437 pPortDef_ip->format.audio.eEncoding = OMX_AUDIO_CodingAMR;
439 pPortDef_op->nSize = sizeof (OMX_PARAM_PORTDEFINITIONTYPE);
440 pPortDef_op->nPortIndex = 0x1;
441 pPortDef_op->nBufferCountActual = NUM_WBAMRDEC_OUTPUT_BUFFERS;
442 pPortDef_op->nBufferCountMin = NUM_WBAMRDEC_OUTPUT_BUFFERS;
443 pPortDef_op->nBufferAlignment = DSP_CACHE_ALIGNMENT;
444 pPortDef_op->eDir = OMX_DirOutput;
445 pPortDef_op->bEnabled = OMX_TRUE;
446 pPortDef_op->nBufferSize = OUTPUT_WBAMRDEC_BUFFER_SIZE;
447 pPortDef_op->bPopulated = 0;
448 pPortDef_op->format.audio.eEncoding = OMX_AUDIO_CodingPCM;
449 pComponentPrivate->bIsInvalidState = OMX_FALSE;
451 #ifdef RESOURCE_MANAGER_ENABLED
452 error = RMProxy_NewInitalize();
453 if (error != OMX_ErrorNone) {
454 OMX_ERROR4(pComponentPrivate->dbg, "Error returned from loading ResourceManagerProxy thread\n");
459 error = WBAMR_DEC_StartComponentThread(pHandle);
460 if (error != OMX_ErrorNone) {
461 OMX_ERROR4(pComponentPrivate->dbg, "Error returned from the Component\n");
464 OMX_PRINT1(pComponentPrivate->dbg, "OMX_ComponentInit\n");
467 #ifdef DSP_RENDERING_ON
468 OMX_PRINT1(pComponentPrivate->dbg, "OMX_ComponentInit\n");
469 if((pComponentPrivate->fdwrite=open(FIFO1,O_WRONLY))<0) {
470 OMX_ERROR4(pComponentPrivate->dbg, "[WBAMR Dec Component] - failure to open WRITE pipe\n");
473 OMX_PRINT1(pComponentPrivate->dbg, "OMX_ComponentInit\n");
474 if((pComponentPrivate->fdread=open(FIFO2,O_RDONLY))<0) {
475 OMX_ERROR4(pComponentPrivate->dbg, "[WBAMR Dec Component] - failure to open READ pipe\n");
480 #ifdef __PERF_INSTRUMENTATION__
481 PERF_ThreadCreated(pComponentPrivate->pPERF, pComponentPrivate->WBAMR_DEC_ComponentThread,
482 PERF_FOURCC('W','B','D','T'));
485 if (pComponentPrivate != NULL) {
486 OMX_PRINT1(pComponentPrivate->dbg, "Exiting - returning %d\n", error);
491 /*-------------------------------------------------------------------*/
493 * SetCallbacks() Sets application callbacks to the component
495 * This method will update application callbacks
496 * to the component. So that component can make use of those call back
497 * while sending buffers to the application. And also it will copy the
498 * application private data to component memory
500 * @param pComponent handle for this instance of the component
501 * @param pCallBacks application callbacks
502 * @param pAppData Application private data
504 * @retval OMX_NoError Success, ready to roll
505 * OMX_Error_BadParameter The input parameter pointer is null
507 /*-------------------------------------------------------------------*/
509 static OMX_ERRORTYPE SetCallbacks (OMX_HANDLETYPE pComponent,
510 OMX_CALLBACKTYPE* pCallBacks,
513 OMX_ERRORTYPE eError = OMX_ErrorNone;
515 OMX_COMPONENTTYPE *pHandle = (OMX_COMPONENTTYPE*)pComponent;
517 WBAMR_DEC_COMPONENT_PRIVATE *pComponentPrivate =
518 (WBAMR_DEC_COMPONENT_PRIVATE *)pHandle->pComponentPrivate;
520 if (pCallBacks == NULL) {
521 OMX_ERROR4(pComponentPrivate->dbg, "About to return OMX_ErrorBadParameter on line\n");
522 eError = OMX_ErrorBadParameter;
523 OMX_PRDSP1(pComponentPrivate->dbg, "Received the empty callbacks from the \
528 /*Copy the callbacks of the application to the component private */
529 memcpy (&(pComponentPrivate->cbInfo), pCallBacks, sizeof(OMX_CALLBACKTYPE));
531 /*copy the application private data to component memory */
532 pHandle->pApplicationPrivate = pAppData;
534 pComponentPrivate->curState = OMX_StateLoaded;
535 #ifdef __PERF_INSTRUMENTATION__
536 PERF_Boundary(pComponentPrivate->pPERFcomp,PERF_BoundaryComplete | PERF_BoundaryCleanup);
543 /*-------------------------------------------------------------------*/
545 * GetComponentVersion() This will return the component version
547 * This method will retrun the component version
549 * @param hComp handle for this instance of the component
550 * @param pCompnentName Name of the component
551 * @param pCompnentVersion handle for this instance of the component
552 * @param pSpecVersion application callbacks
553 * @param pCompnentUUID
555 * @retval OMX_NoError Success, ready to roll
556 * OMX_Error_BadParameter The input parameter pointer is null
558 /*-------------------------------------------------------------------*/
560 static OMX_ERRORTYPE GetComponentVersion (OMX_HANDLETYPE hComp,
561 OMX_STRING pComponentName,
562 OMX_VERSIONTYPE* pComponentVersion,
563 OMX_VERSIONTYPE* pSpecVersion,
564 OMX_UUIDTYPE* pComponentUUID)
566 OMX_ERRORTYPE eError = OMX_ErrorNone;
568 eError = OMX_ErrorNotImplemented;
569 OMXDBG_PRINT(stderr, PRINT, 1, 0, "Inside the GetComponentVersion\n");
575 /*-------------------------------------------------------------------*/
577 * SendCommand() used to send the commands to the component
579 * This method will be used by the application.
581 * @param phandle handle for this instance of the component
582 * @param Cmd Command to be sent to the component
583 * @param nParam indicates commmad is sent using this method
585 * @retval OMX_NoError Success, ready to roll
586 * OMX_Error_BadParameter The input parameter pointer is null
588 /*-------------------------------------------------------------------*/
590 static OMX_ERRORTYPE SendCommand (OMX_HANDLETYPE phandle,
592 OMX_U32 nParam,OMX_PTR pCmdData)
594 OMX_ERRORTYPE eError = OMX_ErrorNone;
596 OMX_COMPONENTTYPE *pHandle = (OMX_COMPONENTTYPE *)phandle;
597 WBAMR_DEC_COMPONENT_PRIVATE *pCompPrivate =
598 (WBAMR_DEC_COMPONENT_PRIVATE *)pHandle->pComponentPrivate;
600 OMX_PRINT1(pCompPrivate->dbg, "Inside SendCommand\n");
602 OMX_PRDSP2(pCompPrivate->dbg, "phandle = %p\n",phandle);
603 OMX_PRDSP1(pCompPrivate->dbg, "pCompPrivate = %p\n",pCompPrivate);
605 pCompPrivate->pHandle = phandle;
607 #ifdef _ERROR_PROPAGATION__
608 if (pCompPrivate->curState == OMX_StateInvalid){
609 eError = OMX_ErrorInvalidState;
613 if(pCompPrivate->curState == OMX_StateInvalid){
614 OMX_PRINT1(pCompPrivate->dbg, "Inside SendCommand\n");
615 eError = OMX_ErrorInvalidState;
616 OMX_ERROR4(pCompPrivate->dbg, "Error NotIfication \
618 pCompPrivate->cbInfo.EventHandler (pHandle,
619 pHandle->pApplicationPrivate,
621 OMX_ErrorInvalidState,
627 #ifdef __PERF_INSTRUMENTATION__
628 PERF_SendingCommand(pCompPrivate->pPERF, Cmd,
629 (Cmd == OMX_CommandMarkBuffer) ? ((OMX_U32) pCmdData) : nParam,
630 PERF_ModuleComponent);
634 case OMX_CommandStateSet:
635 OMX_PRINT1(pCompPrivate->dbg, "Inside SendCommand\n");
636 OMX_PRSTATE1(pCompPrivate->dbg, "pCompPrivate->curState = %d\n",pCompPrivate->curState);
637 if (nParam == OMX_StateLoaded) {
638 pCompPrivate->bLoadedCommandPending = OMX_TRUE;
640 if(pCompPrivate->curState == OMX_StateLoaded) {
641 if((nParam == OMX_StateExecuting) || (nParam == OMX_StatePause)) {
642 pCompPrivate->cbInfo.EventHandler (
644 pHandle->pApplicationPrivate,
646 OMX_ErrorIncorrectStateTransition,
652 if(nParam == OMX_StateInvalid) {
653 OMX_PRINT1(pCompPrivate->dbg, "Inside SendCommand\n");
654 pCompPrivate->curState = OMX_StateInvalid;
655 pCompPrivate->cbInfo.EventHandler (
657 pHandle->pApplicationPrivate,
659 OMX_ErrorInvalidState,
666 case OMX_CommandFlush:
667 OMX_PRINT1(pCompPrivate->dbg, "Inside SendCommand\n");
668 if(nParam > 1 && nParam != -1) {
669 eError = OMX_ErrorBadPortIndex;
674 case OMX_CommandPortDisable:
675 OMX_PRINT1(pCompPrivate->dbg, "Inside SendCommand\n");
677 case OMX_CommandPortEnable:
678 OMX_PRINT1(pCompPrivate->dbg, "Inside SendCommand\n");
680 case OMX_CommandMarkBuffer:
681 OMX_PRINT1(pCompPrivate->dbg, "Inside SendCommand\n");
683 eError = OMX_ErrorBadPortIndex;
688 OMX_ERROR2(pCompPrivate->dbg, "Command Received Default \
690 pCompPrivate->cbInfo.EventHandler (pHandle,
691 pHandle->pApplicationPrivate,
700 OMX_PRINT1(pCompPrivate->dbg, "Inside SendCommand\n");
701 nRet = write (pCompPrivate->cmdPipe[1], &Cmd, sizeof(Cmd));
703 OMX_PRINT1(pCompPrivate->dbg, "Inside SendCommand\n");
704 eError = OMX_ErrorInsufficientResources;
708 if (Cmd == OMX_CommandMarkBuffer) {
709 nRet = write(pCompPrivate->cmdDataPipe[1], &pCmdData,
713 nRet = write(pCompPrivate->cmdDataPipe[1], &nParam,
717 OMX_PRINT1(pCompPrivate->dbg, "Inside SendCommand\n");
718 OMX_PRINT2(pCompPrivate->dbg, "nRet = %d\n",nRet);
720 OMX_PRINT1(pCompPrivate->dbg, "Inside SendCommand\n");
721 eError = OMX_ErrorInsufficientResources;
725 #ifdef DSP_RENDERING_ON
726 if(Cmd == OMX_CommandStateSet && nParam == OMX_StateExecuting) {
727 /* enable Tee device command*/
728 cmd_data.hComponent = pHandle;
729 cmd_data.AM_Cmd = AM_CommandTDNDownlinkMode;
732 cmd_data.streamID = 0;
733 if((write(pCompPrivate->fdwrite, &cmd_data, sizeof(cmd_data)))<0) {
734 eError = OMX_ErrorHardware;
744 /*-------------------------------------------------------------------*/
746 * GetParameter() Gets the current configurations of the component
748 * @param hComp handle for this instance of the component
750 * @param ComponentParameterStructure
752 * @retval OMX_NoError Success, ready to roll
753 * OMX_Error_BadParameter The input parameter pointer is null
755 /*-------------------------------------------------------------------*/
757 static OMX_ERRORTYPE GetParameter (OMX_HANDLETYPE hComp,
758 OMX_INDEXTYPE nParamIndex,
759 OMX_PTR ComponentParameterStructure)
762 OMX_ERRORTYPE eError = OMX_ErrorNone;
763 WBAMR_DEC_COMPONENT_PRIVATE *pComponentPrivate;
764 OMX_PARAM_PORTDEFINITIONTYPE *pParameterStructure;
767 pComponentPrivate = (WBAMR_DEC_COMPONENT_PRIVATE *)(((OMX_COMPONENTTYPE*)hComp)->pComponentPrivate);
768 OMX_PRINT1 (pComponentPrivate->dbg, "Entering with index:: %x\n",nParamIndex);
769 pParameterStructure = (OMX_PARAM_PORTDEFINITIONTYPE*)ComponentParameterStructure;
771 if (pParameterStructure == NULL) {
772 eError = OMX_ErrorBadParameter;
776 OMX_PRINT2(pComponentPrivate->dbg, "pParameterStructure = %p\n",pParameterStructure);
779 #ifdef _ERROR_PROPAGATION__
780 if (pComponentPrivate->curState == OMX_StateInvalid){
781 eError = OMX_ErrorInvalidState;
785 if(pComponentPrivate->curState == OMX_StateInvalid) {
786 pComponentPrivate->cbInfo.EventHandler(
788 ((OMX_COMPONENTTYPE *)hComp)->pApplicationPrivate,
790 OMX_ErrorIncorrectStateOperation,
797 case OMX_IndexParamAudioInit:
798 OMX_PRDSP2(pComponentPrivate->dbg, "OMX_IndexParamAudioInit\n");
799 memcpy(ComponentParameterStructure, &pComponentPrivate->sPortParam, sizeof(OMX_PORT_PARAM_TYPE));
802 case OMX_IndexParamPortDefinition:
803 OMX_PRDSP2(pComponentPrivate->dbg, "pParameterStructure->nPortIndex = %ld\n",pParameterStructure->nPortIndex);
804 OMX_PRCOMM2(pComponentPrivate->dbg, "pComponentPrivate->pPortDef[WBAMR_DEC_INPUT_PORT]->nPortIndex = %ld\n",pComponentPrivate->pPortDef[WBAMR_DEC_INPUT_PORT]->nPortIndex);
805 if(((OMX_PARAM_PORTDEFINITIONTYPE *)(ComponentParameterStructure))->nPortIndex ==
806 pComponentPrivate->pPortDef[WBAMR_DEC_INPUT_PORT]->nPortIndex) {
808 memcpy(ComponentParameterStructure,
809 pComponentPrivate->pPortDef[WBAMR_DEC_INPUT_PORT],
810 sizeof(OMX_PARAM_PORTDEFINITIONTYPE)
813 } else if(((OMX_PARAM_PORTDEFINITIONTYPE *)(ComponentParameterStructure))->nPortIndex ==
814 pComponentPrivate->pPortDef[WBAMR_DEC_OUTPUT_PORT]->nPortIndex) {
816 memcpy(ComponentParameterStructure,
817 pComponentPrivate->pPortDef[WBAMR_DEC_OUTPUT_PORT],
818 sizeof(OMX_PARAM_PORTDEFINITIONTYPE)
823 eError = OMX_ErrorBadPortIndex;
827 case OMX_IndexParamAudioPortFormat:
828 OMX_PRCOMM2(pComponentPrivate->dbg, "nPortIndex = %ld\n",((OMX_AUDIO_PARAM_PORTFORMATTYPE *)(ComponentParameterStructure))->nPortIndex);
829 OMX_PRCOMM2(pComponentPrivate->dbg, "pComponentPrivate->sInPortFormat.nPortIndex= %ld\n",pComponentPrivate->sInPortFormat.nPortIndex);
830 OMX_PRCOMM2(pComponentPrivate->dbg, "pComponentPrivate->sOutPortFormat.nPortIndex= %ld\n",pComponentPrivate->sOutPortFormat.nPortIndex);
831 if(((OMX_AUDIO_PARAM_PORTFORMATTYPE *)(ComponentParameterStructure))->nPortIndex == pComponentPrivate->pPortDef[WBAMR_DEC_INPUT_PORT]->nPortIndex) {
833 if(((OMX_AUDIO_PARAM_PORTFORMATTYPE *)(ComponentParameterStructure))->nIndex >
834 pComponentPrivate->sInPortFormat.nPortIndex) {
836 eError = OMX_ErrorNoMore;
839 memcpy(ComponentParameterStructure, &pComponentPrivate->sInPortFormat,
840 sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE));
843 else if(((OMX_AUDIO_PARAM_PORTFORMATTYPE *)(ComponentParameterStructure))->nPortIndex ==
844 pComponentPrivate->pPortDef[WBAMR_DEC_OUTPUT_PORT]->nPortIndex){
846 if(((OMX_AUDIO_PARAM_PORTFORMATTYPE *)(ComponentParameterStructure))->nIndex > pComponentPrivate->sOutPortFormat.nPortIndex) {
847 eError = OMX_ErrorNoMore;
850 memcpy(ComponentParameterStructure, &pComponentPrivate->sOutPortFormat,
851 sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE));
855 eError = OMX_ErrorBadPortIndex;
859 case OMX_IndexParamAudioAmr:
860 if(((OMX_PARAM_PORTDEFINITIONTYPE *)(ComponentParameterStructure))->nPortIndex ==
861 pComponentPrivate->pPortDef[WBAMR_DEC_INPUT_PORT]->nPortIndex) {
862 OMX_PRINT1(pComponentPrivate->dbg, "Inside the GetParameter\n");
863 memcpy(ComponentParameterStructure,pComponentPrivate->wbamrParams[WBAMR_DEC_INPUT_PORT],
864 sizeof(OMX_AUDIO_PARAM_AMRTYPE));
866 else if(((OMX_PARAM_PORTDEFINITIONTYPE *)(ComponentParameterStructure))->nPortIndex ==
867 pComponentPrivate->pPortDef[WBAMR_DEC_OUTPUT_PORT]->nPortIndex) {
868 OMX_PRINT1(pComponentPrivate->dbg, "Inside the GetParameter\n");
869 memcpy(ComponentParameterStructure, pComponentPrivate->wbamrParams[WBAMR_DEC_OUTPUT_PORT],
870 sizeof(OMX_AUDIO_PARAM_AMRTYPE));
873 eError = OMX_ErrorBadPortIndex;
878 case OMX_IndexParamAudioPcm:
879 if(((OMX_AUDIO_PARAM_AMRTYPE *)(ComponentParameterStructure))->nPortIndex == WBAMR_DEC_OUTPUT_PORT){
880 memcpy(ComponentParameterStructure, pComponentPrivate->wbamrParams[WBAMR_DEC_OUTPUT_PORT], sizeof(OMX_AUDIO_PARAM_PCMMODETYPE));
883 eError = OMX_ErrorBadPortIndex;
886 case OMX_IndexParamPriorityMgmt:
887 if (pComponentPrivate->pPriorityMgmt == NULL) {
888 eError = OMX_ErrorBadPortIndex;
891 memcpy(ComponentParameterStructure, pComponentPrivate->pPriorityMgmt, sizeof(OMX_PRIORITYMGMTTYPE));
894 case OMX_IndexParamCompBufferSupplier:
895 if(((OMX_PARAM_BUFFERSUPPLIERTYPE *)(ComponentParameterStructure))->nPortIndex == OMX_DirInput) {
896 OMX_PRDSP2(pComponentPrivate->dbg, "OMX_IndexParamCompBufferSupplier \n");
897 /* memcpy(ComponentParameterStructure, pBufferSupplier, sizeof(OMX_PARAM_BUFFERSUPPLIERTYPE)); */
899 else if(((OMX_PARAM_BUFFERSUPPLIERTYPE *)(ComponentParameterStructure))->nPortIndex == OMX_DirOutput) {
900 OMX_PRINT1(pComponentPrivate->dbg, "OMX_IndexParamCompBufferSupplier \n");
901 /*memcpy(ComponentParameterStructure, pBufferSupplier, sizeof(OMX_PARAM_BUFFERSUPPLIERTYPE)); */
904 OMX_ERROR2(pComponentPrivate->dbg, "OMX_ErrorBadPortIndex from GetParameter");
905 eError = OMX_ErrorBadPortIndex;
909 case OMX_IndexParamVideoInit:
912 case OMX_IndexParamImageInit:
915 case OMX_IndexParamOtherInit:
917 case (OMX_INDEXTYPE) PV_OMX_COMPONENT_CAPABILITY_TYPE_INDEX:
919 OMX_PRINT2(pComponentPrivate->dbg, "Entering PV_OMX_COMPONENT_CAPABILITY_TYPE_INDEX\n");
920 PV_OMXComponentCapabilityFlagsType* pCap_flags = (PV_OMXComponentCapabilityFlagsType *) ComponentParameterStructure;
921 if (NULL == pCap_flags)
923 OMX_ERROR4(pComponentPrivate->dbg, "ERROR PV_OMX_COMPONENT_CAPABILITY_TYPE_INDEX\n");
924 eError = OMX_ErrorBadParameter;
927 OMX_PRINT2(pComponentPrivate->dbg, "Copying PV_OMX_COMPONENT_CAPABILITY_TYPE_INDEX\n");
928 memcpy(pCap_flags, &(pComponentPrivate->iPVCapabilityFlags), sizeof(PV_OMXComponentCapabilityFlagsType));
929 eError = OMX_ErrorNone;
934 eError = OMX_ErrorUnsupportedIndex;
938 OMX_PRINT1(pComponentPrivate->dbg, "Exiting - %x\n",nParamIndex);
942 /*-------------------------------------------------------------------*/
944 * SetParameter() Sets configuration paramets to the component
946 * @param hComp handle for this instance of the component
950 * @retval OMX_NoError Success, ready to roll
951 * OMX_Error_BadParameter The input parameter pointer is null
953 /*-------------------------------------------------------------------*/
955 static OMX_ERRORTYPE SetParameter (OMX_HANDLETYPE hComp,
956 OMX_INDEXTYPE nParamIndex,
959 OMX_ERRORTYPE eError = OMX_ErrorNone;
960 OMX_BOOL temp_bEnabled,temp_bPopulated;
961 OMX_PARAM_COMPONENTROLETYPE *pRole;
962 OMX_AUDIO_PARAM_PCMMODETYPE *amr_op;
963 OMX_PARAM_BUFFERSUPPLIERTYPE sBufferSupplier;
965 OMX_COMPONENTTYPE* pHandle= (OMX_COMPONENTTYPE*)hComp;
967 WBAMR_DEC_COMPONENT_PRIVATE *pComponentPrivate;
968 pComponentPrivate = (WBAMR_DEC_COMPONENT_PRIVATE *)(((OMX_COMPONENTTYPE*)hComp)->pComponentPrivate);
970 if (pCompParam == NULL) {
971 eError = OMX_ErrorBadParameter;
975 #ifdef _ERROR_PROPAGATION__
976 if (pComponentPrivate->curState == OMX_StateInvalid){
977 eError = OMX_ErrorInvalidState;
981 switch(nParamIndex) {
982 case OMX_IndexParamAudioPortFormat:
984 OMX_PARAM_PORTDEFINITIONTYPE *pComponentParam =
985 (OMX_PARAM_PORTDEFINITIONTYPE *)pCompParam;
987 OMX_PRCOMM2(pComponentPrivate->dbg, "pComponentParam->nPortIndex = %ld\n",pComponentParam->nPortIndex);
988 OMX_PRBUFFER2(pComponentPrivate->dbg, "pComponentParam->nBufferCountActual= %ld\n",pComponentParam->nBufferCountActual);
989 OMX_PRBUFFER2(pComponentPrivate->dbg, "pComponentParam->nBufferSize= %ld\n",pComponentParam->nBufferSize);
991 /* 0 means Input port */
992 if (pComponentParam->nPortIndex == 0) {
994 memcpy(&pComponentPrivate->sInPortFormat, pComponentParam, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE));
996 } else if (pComponentParam->nPortIndex == 1) {
997 /* 1 means Output port */
998 memcpy(&pComponentPrivate->sOutPortFormat, pComponentParam, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE));
1001 OMX_ERROR4(pComponentPrivate->dbg, "Wrong Port Index Parameter\n");
1002 OMX_ERROR4(pComponentPrivate->dbg, "About to return OMX_ErrorBadParameter on line\n");
1003 eError = OMX_ErrorBadParameter;
1008 case OMX_IndexParamAudioAmr:
1010 OMX_AUDIO_PARAM_AMRTYPE *pCompAmrParam =
1011 (OMX_AUDIO_PARAM_AMRTYPE *)pCompParam;
1013 if (OMX_AUDIO_AMRFrameFormatConformance == pCompAmrParam->eAMRFrameFormat)
1014 pComponentPrivate->mimemode = 0;
1015 else if (OMX_AUDIO_AMRFrameFormatIF2 == pCompAmrParam->eAMRFrameFormat)
1016 pComponentPrivate->mimemode = 2;
1017 else if (OMX_AUDIO_AMRFrameFormatRTPPayload == pCompAmrParam->eAMRFrameFormat){
1018 pComponentPrivate->mimemode = 1;
1019 pComponentPrivate->using_rtsp = 1;
1022 pComponentPrivate->mimemode = 1; /*MIME Format*/
1024 /* 0 means Input port */
1025 if(pCompAmrParam->nPortIndex == 0) {
1026 memcpy(((WBAMR_DEC_COMPONENT_PRIVATE*)
1027 pHandle->pComponentPrivate)->wbamrParams[WBAMR_DEC_INPUT_PORT],
1028 pCompAmrParam, sizeof(OMX_AUDIO_PARAM_AMRTYPE));
1030 } else if (pCompAmrParam->nPortIndex == 1) {
1031 /* 1 means Output port */
1032 memcpy(((WBAMR_DEC_COMPONENT_PRIVATE *)
1033 pHandle->pComponentPrivate)->wbamrParams[WBAMR_DEC_OUTPUT_PORT],
1034 pCompAmrParam, sizeof(OMX_AUDIO_PARAM_AMRTYPE));
1037 eError = OMX_ErrorBadPortIndex;
1042 case OMX_IndexParamPortDefinition:
1043 if(((OMX_PARAM_PORTDEFINITIONTYPE *)(pCompParam))->nPortIndex ==
1044 pComponentPrivate->pPortDef[WBAMR_DEC_INPUT_PORT]->nPortIndex) {
1045 temp_bEnabled = pComponentPrivate->pPortDef[WBAMR_DEC_INPUT_PORT]->bEnabled;
1046 temp_bPopulated = pComponentPrivate->pPortDef[WBAMR_DEC_INPUT_PORT]->bPopulated;
1047 memcpy(pComponentPrivate->pPortDef[WBAMR_DEC_INPUT_PORT],
1049 sizeof(OMX_PARAM_PORTDEFINITIONTYPE)
1051 pComponentPrivate->pPortDef[WBAMR_DEC_INPUT_PORT]->bEnabled = temp_bEnabled;
1052 pComponentPrivate->pPortDef[WBAMR_DEC_INPUT_PORT]->bPopulated = temp_bPopulated;
1054 else if(((OMX_PARAM_PORTDEFINITIONTYPE *)(pCompParam))->nPortIndex ==
1055 pComponentPrivate->pPortDef[WBAMR_DEC_OUTPUT_PORT]->nPortIndex) {
1056 temp_bEnabled = pComponentPrivate->pPortDef[WBAMR_DEC_OUTPUT_PORT]->bEnabled;
1057 temp_bPopulated = pComponentPrivate->pPortDef[WBAMR_DEC_OUTPUT_PORT]->bPopulated;
1058 memcpy(pComponentPrivate->pPortDef[WBAMR_DEC_OUTPUT_PORT],
1060 sizeof(OMX_PARAM_PORTDEFINITIONTYPE)
1062 pComponentPrivate->pPortDef[WBAMR_DEC_OUTPUT_PORT]->bEnabled = temp_bEnabled;
1063 pComponentPrivate->pPortDef[WBAMR_DEC_OUTPUT_PORT]->bPopulated = temp_bPopulated;
1067 eError = OMX_ErrorBadPortIndex;
1070 case OMX_IndexParamPriorityMgmt:
1071 if (pComponentPrivate->curState != OMX_StateLoaded) {
1072 eError = OMX_ErrorIncorrectStateOperation;
1074 if (pComponentPrivate->pPriorityMgmt == NULL) {
1075 eError = OMX_ErrorBadParameter;
1078 memcpy(pComponentPrivate->pPriorityMgmt, (OMX_PRIORITYMGMTTYPE*)pCompParam, sizeof(OMX_PRIORITYMGMTTYPE));
1081 case OMX_IndexParamStandardComponentRole:
1083 pRole = (OMX_PARAM_COMPONENTROLETYPE *)pCompParam;
1084 memcpy(&(pComponentPrivate->componentRole), (void *)pRole, sizeof(OMX_PARAM_COMPONENTROLETYPE));
1086 eError = OMX_ErrorBadParameter;
1090 case OMX_IndexParamAudioPcm:
1092 amr_op = (OMX_AUDIO_PARAM_PCMMODETYPE *)pCompParam;
1093 memcpy(pComponentPrivate->wbamrParams[WBAMR_DEC_OUTPUT_PORT], amr_op, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE));
1096 eError = OMX_ErrorBadParameter;
1100 case OMX_IndexParamCompBufferSupplier:
1101 if(((OMX_PARAM_PORTDEFINITIONTYPE *)(pCompParam))->nPortIndex ==
1102 pComponentPrivate->pPortDef[WBAMR_DEC_INPUT_PORT]->nPortIndex) {
1103 OMX_PRINT2(pComponentPrivate->dbg, ":: SetParameter OMX_IndexParamCompBufferSupplier \n");
1104 sBufferSupplier.eBufferSupplier = OMX_BufferSupplyInput;
1105 memcpy(&sBufferSupplier, pCompParam, sizeof(OMX_PARAM_BUFFERSUPPLIERTYPE));
1108 else if(((OMX_PARAM_PORTDEFINITIONTYPE *)(pCompParam))->nPortIndex ==
1109 pComponentPrivate->pPortDef[WBAMR_DEC_OUTPUT_PORT]->nPortIndex) {
1110 OMX_PRINT2(pComponentPrivate->dbg, ":: SetParameter OMX_IndexParamCompBufferSupplier \n");
1111 sBufferSupplier.eBufferSupplier = OMX_BufferSupplyOutput;
1112 memcpy(&sBufferSupplier, pCompParam, sizeof(OMX_PARAM_BUFFERSUPPLIERTYPE));
1115 OMX_ERROR2(pComponentPrivate->dbg, ":: OMX_ErrorBadPortIndex from SetParameter");
1116 eError = OMX_ErrorBadPortIndex;
1127 /*-------------------------------------------------------------------*/
1129 * GetConfig() Gets the current configuration of to the component
1131 * @param hComp handle for this instance of the component
1132 * @param nConfigIndex
1133 * @param ComponentConfigStructure
1135 * @retval OMX_NoError Success, ready to roll
1136 * OMX_Error_BadParameter The input parameter pointer is null
1138 /*-------------------------------------------------------------------*/
1140 static OMX_ERRORTYPE GetConfig (OMX_HANDLETYPE hComp,
1141 OMX_INDEXTYPE nConfigIndex,
1142 OMX_PTR ComponentConfigStructure)
1144 OMX_ERRORTYPE eError = OMX_ErrorNone;
1145 OMX_COMPONENTTYPE* pHandle = (OMX_COMPONENTTYPE*)hComp;
1146 WBAMR_DEC_COMPONENT_PRIVATE *pComponentPrivate =
1147 (WBAMR_DEC_COMPONENT_PRIVATE *) pHandle->pComponentPrivate;
1148 TI_OMX_STREAM_INFO *streamInfo;
1150 OMX_MALLOC_GENERIC(streamInfo, TI_OMX_STREAM_INFO);
1151 #ifdef _ERROR_PROPAGATION__
1152 if (pComponentPrivate->curState == OMX_StateInvalid){
1153 eError = OMX_ErrorInvalidState;
1157 if(nConfigIndex == OMX_IndexCustomWbAmrDecStreamIDConfig){
1158 streamInfo->streamId = pComponentPrivate->streamID;
1159 memcpy(ComponentConfigStructure,streamInfo,sizeof(TI_OMX_STREAM_INFO));
1161 else if(nConfigIndex == OMX_IndexCustomDebug){
1162 OMX_DBG_GETCONFIG(pComponentPrivate->dbg, ComponentConfigStructure);
1166 OMX_MEMFREE_STRUCT(streamInfo);
1167 OMX_PRINT1(pComponentPrivate->dbg, "Exiting GetConfig. Returning = 0x%x\n",eError);
1170 /*-------------------------------------------------------------------*/
1172 * SetConfig() Sets the configraiton to the component
1174 * @param hComp handle for this instance of the component
1175 * @param nConfigIndex
1176 * @param ComponentConfigStructure
1178 * @retval OMX_NoError Success, ready to roll
1179 * OMX_Error_BadParameter The input parameter pointer is null
1181 /*-------------------------------------------------------------------*/
1183 static OMX_ERRORTYPE SetConfig (OMX_HANDLETYPE hComp,
1184 OMX_INDEXTYPE nConfigIndex,
1185 OMX_PTR ComponentConfigStructure)
1187 OMX_ERRORTYPE eError = OMX_ErrorNone;
1188 OMX_COMPONENTTYPE* pHandle = (OMX_COMPONENTTYPE*)hComp;
1189 WBAMR_DEC_COMPONENT_PRIVATE *pComponentPrivate = NULL;
1190 OMX_S16 *customFlag = NULL;
1191 TI_OMX_DSP_DEFINITION *configData;
1192 TI_OMX_DATAPATH dataPath;
1193 #ifdef DSP_RENDERING_ON
1194 OMX_AUDIO_CONFIG_MUTETYPE *pMuteStructure = NULL;
1195 OMX_AUDIO_CONFIG_VOLUMETYPE *pVolumeStructure = NULL;
1197 OMX_PRINT1(pComponentPrivate->dbg, "Entering SetConfig\n");
1198 if (pHandle == NULL) {
1199 OMX_ERROR4(pComponentPrivate->dbg, "Invalid HANDLE OMX_ErrorBadParameter \n");
1200 eError = OMX_ErrorBadParameter;
1204 pComponentPrivate = (WBAMR_DEC_COMPONENT_PRIVATE *)pHandle->pComponentPrivate;
1205 #ifdef _ERROR_PROPAGATION__
1206 if (pComponentPrivate->curState == OMX_StateInvalid){
1207 eError = OMX_ErrorInvalidState;
1211 switch (nConfigIndex) {
1212 case OMX_IndexCustomWbAmrDecHeaderInfoConfig:
1214 OMX_PRDSP2(pComponentPrivate->dbg, "SetConfig OMX_IndexCustomWbAmrDecHeaderInfoConfig \n");
1215 configData = (TI_OMX_DSP_DEFINITION*)ComponentConfigStructure;
1216 if (configData == NULL) {
1217 eError = OMX_ErrorBadParameter;
1218 OMX_ERROR4(pComponentPrivate->dbg, "OMX_ErrorBadParameter from SetConfig\n");
1221 pComponentPrivate->acdnmode = configData->acousticMode;
1222 pComponentPrivate->dasfmode = configData->dasfMode;
1223 if( 2 == pComponentPrivate->dasfmode ){
1224 pComponentPrivate->dasfmode--;
1227 if (pComponentPrivate->dasfmode ){
1228 pComponentPrivate->pPortDef[WBAMR_DEC_OUTPUT_PORT]->bEnabled = 0;
1231 pComponentPrivate->streamID = configData->streamId;
1235 case OMX_IndexCustomWbAmrDecDataPath:
1236 customFlag = (OMX_S16*)ComponentConfigStructure;
1237 if (customFlag == NULL) {
1238 eError = OMX_ErrorBadParameter;
1243 case DATAPATH_APPLICATION:
1244 OMX_MMMIXER_DATAPATH(pComponentPrivate->sDeviceString, RENDERTYPE_DECODER, pComponentPrivate->streamID);
1247 case DATAPATH_APPLICATION_RTMIXER:
1248 strcpy((char*)pComponentPrivate->sDeviceString,(char*)RTM_STRING);
1252 strcpy((char*)pComponentPrivate->sDeviceString,(char*)ACDN_STRING);
1261 case OMX_IndexCustomModeDasfConfig_WBAMRDEC:
1263 OMX_PRDSP2(pComponentPrivate->dbg, "SetConfig OMX_IndexCustomModeDasfConfig \n");
1264 customFlag = (OMX_S16*)ComponentConfigStructure;
1265 if (customFlag == NULL) {
1266 eError = OMX_ErrorBadParameter;
1267 OMX_ERROR4(pComponentPrivate->dbg, "OMX_ErrorBadParameter from SetConfig\n");
1270 pComponentPrivate->dasfmode = *customFlag;
1271 if( 2 == pComponentPrivate->dasfmode ){
1272 pComponentPrivate->dasfmode--;
1274 if (pComponentPrivate->dasfmode){
1275 pComponentPrivate->pPortDef[WBAMR_DEC_OUTPUT_PORT]->bEnabled = 0;
1279 case OMX_IndexCustomModeMimeConfig_WBAMRDEC:
1281 OMX_PRDSP2(pComponentPrivate->dbg, "SetConfig OMX_IndexCustomModeMimeConfig \n");
1282 customFlag = (OMX_S16*)ComponentConfigStructure;
1283 if (customFlag == NULL)
1285 eError = OMX_ErrorBadParameter;
1286 OMX_ERROR4(pComponentPrivate->dbg, "OMX_ErrorBadParameter from SetConfig\n");
1289 pComponentPrivate->mimemode = *customFlag;
1292 case OMX_IndexCustomWbAmrDecNextFrameLost:
1294 pComponentPrivate->bFrameLost=OMX_TRUE;
1297 case OMX_IndexConfigAudioMute:
1299 #ifdef DSP_RENDERING_ON
1300 pMuteStructure = (OMX_AUDIO_CONFIG_MUTETYPE *)ComponentConfigStructure;
1301 OMX_PRDSP2(pComponentPrivate->dbg, "Set Mute/Unmute for playback stream\n");
1302 cmd_data.hComponent = hComp;
1303 if(pMuteStructure->bMute == OMX_TRUE)
1305 OMX_PRSTATE2(pComponentPrivate->dbg, "Mute the playback stream\n");
1306 cmd_data.AM_Cmd = AM_CommandStreamMute;
1310 OMX_PRSTATE2(pComponentPrivate->dbg, "unMute the playback stream\n");
1311 cmd_data.AM_Cmd = AM_CommandStreamUnMute;
1313 cmd_data.param1 = 0;
1314 cmd_data.param2 = 0;
1315 cmd_data.streamID = pComponentPrivate->streamID;
1316 if((write(pComponentPrivate->fdwrite, &cmd_data, sizeof(cmd_data)))<0)
1318 OMX_ERROR4(pComponentPrivate->dbg, "[WBAMR decoder] - fail to send Mute command to audio manager\n");
1323 case OMX_IndexConfigAudioVolume:
1325 #ifdef DSP_RENDERING_ON
1326 pVolumeStructure = (OMX_AUDIO_CONFIG_VOLUMETYPE *)ComponentConfigStructure;
1327 OMX_PRDSP2(pComponentPrivate->dbg, "Set volume for playback stream\n");
1328 cmd_data.hComponent = hComp;
1329 cmd_data.AM_Cmd = AM_CommandSWGain;
1330 cmd_data.param1 = pVolumeStructure->sVolume.nValue;
1331 cmd_data.param2 = 0;
1332 cmd_data.streamID = pComponentPrivate->streamID;
1334 if((write(pComponentPrivate->fdwrite, &cmd_data, sizeof(cmd_data)))<0)
1336 OMX_ERROR4(pComponentPrivate->dbg, "[WBAMR decoder] - fail to send Volume command to audio manager\n");
1342 case OMX_IndexCustomDebug:
1344 OMX_DBG_SETCONFIG(pComponentPrivate->dbg, ComponentConfigStructure);
1348 eError = OMX_ErrorUnsupportedIndex;
1352 OMX_PRINT1(pComponentPrivate->dbg, "Exiting SetConfig\n");
1353 OMX_PRINT1(pComponentPrivate->dbg, "Returning = 0x%x\n",eError);
1357 /*-------------------------------------------------------------------*/
1359 * GetState() Gets the current state of the component
1361 * @param pCompomponent handle for this instance of the component
1364 * @retval OMX_NoError Success, ready to roll
1365 * OMX_Error_BadParameter The input parameter pointer is null
1367 /*-------------------------------------------------------------------*/
1369 static OMX_ERRORTYPE GetState (OMX_HANDLETYPE pComponent, OMX_STATETYPE* pState)
1371 OMX_ERRORTYPE error = OMX_ErrorUndefined;
1372 OMX_COMPONENTTYPE *pHandle = (OMX_COMPONENTTYPE *)pComponent;
1375 error = OMX_ErrorBadParameter;
1376 OMXDBG_PRINT(stderr, ERROR, 4, 0, "About to return OMX_ErrorBadParameter on line\n");
1380 if (pHandle && pHandle->pComponentPrivate) {
1381 *pState = ((WBAMR_DEC_COMPONENT_PRIVATE*)
1382 pHandle->pComponentPrivate)->curState;
1384 *pState = OMX_StateLoaded;
1387 error = OMX_ErrorNone;
1393 /*-------------------------------------------------------------------*/
1395 * EmptyThisBuffer() This callback is used to send the input buffer to
1398 * @param pComponent handle for this instance of the component
1399 * @param nPortIndex input port index
1400 * @param pBuffer buffer to be sent to codec
1402 * @retval OMX_NoError Success, ready to roll
1403 * OMX_Error_BadParameter The input parameter pointer is null
1405 /*-------------------------------------------------------------------*/
1407 static OMX_ERRORTYPE EmptyThisBuffer (OMX_HANDLETYPE pComponent,
1408 OMX_BUFFERHEADERTYPE* pBuffer)
1410 OMX_ERRORTYPE eError = OMX_ErrorNone;
1411 OMX_COMPONENTTYPE *pHandle = (OMX_COMPONENTTYPE *)pComponent;
1412 WBAMR_DEC_COMPONENT_PRIVATE *pComponentPrivate =
1413 (WBAMR_DEC_COMPONENT_PRIVATE *)pHandle->pComponentPrivate;
1414 OMX_PARAM_PORTDEFINITIONTYPE *pPortDef;
1417 pPortDef = ((WBAMR_DEC_COMPONENT_PRIVATE*)
1418 pComponentPrivate)->pPortDef[WBAMR_DEC_INPUT_PORT];
1419 #ifdef _ERROR_PROPAGATION__
1420 if (pComponentPrivate->curState == OMX_StateInvalid){
1421 eError = OMX_ErrorInvalidState;
1426 #ifdef __PERF_INSTRUMENTATION__
1427 PERF_ReceivedFrame(pComponentPrivate->pPERF,
1429 pBuffer->nFilledLen,
1433 if(!pPortDef->bEnabled) {
1434 eError = OMX_ErrorIncorrectStateOperation;
1438 if (pBuffer == NULL) {
1439 eError = OMX_ErrorBadParameter;
1440 OMX_ERROR4(pComponentPrivate->dbg, "About to return OMX_ErrorBadParameter on line\n");
1444 if (pBuffer->nSize != sizeof(OMX_BUFFERHEADERTYPE)) {
1445 eError = OMX_ErrorBadParameter;
1449 if (pBuffer->nVersion.nVersion != pComponentPrivate->nVersion) {
1450 eError = OMX_ErrorVersionMismatch;
1454 if (pBuffer->nInputPortIndex != WBAMR_DEC_INPUT_PORT) {
1455 eError = OMX_ErrorBadPortIndex;
1459 if(pComponentPrivate->curState != OMX_StateExecuting && pComponentPrivate->curState != OMX_StatePause) {
1460 eError = OMX_ErrorIncorrectStateOperation;
1466 OMX_PRBUFFER2(pComponentPrivate->dbg, "\n------------------------------------------\n\n");
1467 OMX_PRBUFFER2(pComponentPrivate->dbg, "Component Sending Filled ip buff %p \
1468 to Component Thread\n",pBuffer);
1469 OMX_PRBUFFER2(pComponentPrivate->dbg, "\n------------------------------------------\n\n");
1472 pComponentPrivate->app_nBuf--;
1474 pComponentPrivate->pMarkData = pBuffer->pMarkData;
1475 pComponentPrivate->hMarkTargetComponent = pBuffer->hMarkTargetComponent;
1477 pComponentPrivate->nUnhandledEmptyThisBuffers++;
1479 ret = write (pComponentPrivate->dataPipe[1], &pBuffer,
1480 sizeof(OMX_BUFFERHEADERTYPE*));
1482 OMX_ERROR4(pComponentPrivate->dbg, "Error in Writing to the Data pipe\n");
1483 eError = OMX_ErrorHardware;
1486 pComponentPrivate->nEmptyThisBufferCount++;
1491 /*-------------------------------------------------------------------*/
1493 * FillThisBuffer() This callback is used to send the output buffer to
1496 * @param pComponent handle for this instance of the component
1497 * @param nPortIndex output port number
1498 * @param pBuffer buffer to be sent to codec
1500 * @retval OMX_NoError Success, ready to roll
1501 * OMX_Error_BadParameter The input parameter pointer is null
1503 /*-------------------------------------------------------------------*/
1505 static OMX_ERRORTYPE FillThisBuffer (OMX_HANDLETYPE pComponent,
1506 OMX_BUFFERHEADERTYPE* pBuffer)
1508 OMX_ERRORTYPE eError = OMX_ErrorNone;
1509 OMX_COMPONENTTYPE *pHandle = (OMX_COMPONENTTYPE *)pComponent;
1510 WBAMR_DEC_COMPONENT_PRIVATE *pComponentPrivate =
1511 (WBAMR_DEC_COMPONENT_PRIVATE *)pHandle->pComponentPrivate;
1512 OMX_PARAM_PORTDEFINITIONTYPE *pPortDef;
1514 pPortDef = ((WBAMR_DEC_COMPONENT_PRIVATE*)
1515 pComponentPrivate)->pPortDef[WBAMR_DEC_OUTPUT_PORT];
1516 #ifdef _ERROR_PROPAGATION__
1517 if (pComponentPrivate->curState == OMX_StateInvalid){
1518 eError = OMX_ErrorInvalidState;
1522 #ifdef __PERF_INSTRUMENTATION__
1523 PERF_ReceivedFrame(pComponentPrivate->pPERF,
1529 if(!pPortDef->bEnabled) {
1530 eError = OMX_ErrorIncorrectStateOperation;
1534 if (pBuffer == NULL) {
1535 eError = OMX_ErrorBadParameter;
1536 OMX_ERROR4(pComponentPrivate->dbg, "About to return OMX_ErrorBadParameter on line\n");
1540 if (pBuffer->nSize != sizeof(OMX_BUFFERHEADERTYPE)) {
1541 eError = OMX_ErrorBadParameter;
1546 if (pBuffer->nVersion.nVersion != pComponentPrivate->nVersion) {
1547 eError = OMX_ErrorVersionMismatch;
1551 if (pBuffer->nOutputPortIndex != WBAMR_DEC_OUTPUT_PORT) {
1552 eError = OMX_ErrorBadPortIndex;
1556 if(pComponentPrivate->curState != OMX_StateExecuting && pComponentPrivate->curState != OMX_StatePause) {
1557 eError = OMX_ErrorIncorrectStateOperation;
1562 pComponentPrivate->app_nBuf--;
1563 OMX_PRBUFFER2(pComponentPrivate->dbg, "Decrementing app_nBuf = %ld\n",pComponentPrivate->app_nBuf);
1565 OMX_PRBUFFER1(pComponentPrivate->dbg, "pComponentPrivate->pMarkBuf = %p\n",pComponentPrivate->pMarkBuf);
1566 OMX_PRBUFFER1(pComponentPrivate->dbg, "pComponentPrivate->pMarkData = %p\n",pComponentPrivate->pMarkData);
1567 if(pComponentPrivate->pMarkBuf){
1568 pBuffer->hMarkTargetComponent = pComponentPrivate->pMarkBuf->hMarkTargetComponent;
1569 pBuffer->pMarkData = pComponentPrivate->pMarkBuf->pMarkData;
1570 pComponentPrivate->pMarkBuf = NULL;
1573 if (pComponentPrivate->pMarkData) {
1574 pBuffer->hMarkTargetComponent = pComponentPrivate->hMarkTargetComponent;
1575 pBuffer->pMarkData = pComponentPrivate->pMarkData;
1576 pComponentPrivate->pMarkData = NULL;
1579 OMX_PRBUFFER1(pComponentPrivate->dbg, "\n------------------------------------------\n\n");
1580 OMX_PRBUFFER1(pComponentPrivate->dbg, "Component Sending Emptied op buff %p \
1581 to Component Thread\n",pBuffer);
1582 OMX_PRBUFFER1(pComponentPrivate->dbg, "\n------------------------------------------\n\n");
1584 pComponentPrivate->nUnhandledFillThisBuffers++;
1586 write (pComponentPrivate->dataPipe[1], &pBuffer,
1587 sizeof (OMX_BUFFERHEADERTYPE*));
1588 pComponentPrivate->nFillThisBufferCount++;
1593 /*-------------------------------------------------------------------*/
1595 * OMX_ComponentDeinit() this methold will de init the component
1597 * @param pComp handle for this instance of the component
1599 * @retval OMX_NoError Success, ready to roll
1600 * OMX_Error_BadParameter The input parameter pointer is null
1602 /*-------------------------------------------------------------------*/
1604 static OMX_ERRORTYPE ComponentDeInit(OMX_HANDLETYPE pHandle)
1606 OMX_ERRORTYPE eError = OMX_ErrorNone;
1608 /* inform audio manager to remove the streamID*/
1609 /* compose the data */
1610 OMX_COMPONENTTYPE *pComponent = (OMX_COMPONENTTYPE *)pHandle;
1611 WBAMR_DEC_COMPONENT_PRIVATE *pComponentPrivate =
1612 (WBAMR_DEC_COMPONENT_PRIVATE *)pComponent->pComponentPrivate;
1613 struct OMX_TI_Debug dbg;
1614 dbg = pComponentPrivate->dbg;
1616 OMX_PRINT1(dbg, "ComponentDeInit\n");
1618 #ifdef __PERF_INSTRUMENTATION__
1619 PERF_Boundary(pComponentPrivate->pPERF,
1620 PERF_BoundaryStart | PERF_BoundaryCleanup);
1622 #ifdef DSP_RENDERING_ON
1623 close(pComponentPrivate->fdwrite);
1624 close(pComponentPrivate->fdread);
1627 #ifdef RESOURCE_MANAGER_ENABLED
1629 eError = RMProxy_NewSendCommand(pHandle, RMProxy_FreeResource, OMX_WBAMR_Decoder_COMPONENT, 0, 3456, NULL);
1631 if (eError != OMX_ErrorNone) {
1632 OMX_ERROR4(dbg, "Error returned from destroy ResourceManagerProxy thread\n");
1634 eError = RMProxy_Deinitalize();
1635 if (eError != OMX_ErrorNone) {
1636 OMX_ERROR4(dbg, "Error from RMProxy_Deinitalize\n");
1641 OMX_PRINT1(dbg, "ComponentDeInit\n");
1642 pComponentPrivate->bIsStopping = 1;
1643 eError = WBAMR_DEC_StopComponentThread(pHandle);
1644 /* Wait for thread to exit so we can get the status into "error" */
1646 OMX_MEMFREE_STRUCT(pComponentPrivate->pInputBufferList);
1648 OMX_MEMFREE_STRUCT(pComponentPrivate->pOutputBufferList);
1650 /* close the pipe handles */
1651 WBAMR_DEC_FreeCompResources(pHandle);
1653 #ifdef __PERF_INSTRUMENTATION__
1654 PERF_Boundary(pComponentPrivate->pPERF,
1655 PERF_BoundaryComplete | PERF_BoundaryCleanup);
1656 PERF_Done(pComponentPrivate->pPERF);
1658 OMX_MEMFREE_STRUCT(pComponentPrivate->sDeviceString);
1659 OMX_PRINT2(dbg, "After WBAMR_DEC_FreeCompResources\n");
1661 OMX_MEMFREE_STRUCT(pComponentPrivate);
1666 /*-------------------------------------------------------------------*/
1668 * ComponentTunnelRequest() this method is not implemented in 1.5
1670 * This method will update application callbacks
1673 * @param pComp handle for this instance of the component
1674 * @param pCallBacks application callbacks
1677 * @retval OMX_NoError Success, ready to roll
1678 * OMX_Error_BadParameter The input parameter pointer is null
1680 /*-------------------------------------------------------------------*/
1682 static OMX_ERRORTYPE ComponentTunnelRequest (OMX_HANDLETYPE hComp,
1683 OMX_U32 nPort, OMX_HANDLETYPE hTunneledComp,
1684 OMX_U32 nTunneledPort,
1685 OMX_TUNNELSETUPTYPE* pTunnelSetup)
1687 OMX_ERRORTYPE eError = OMX_ErrorNone;
1688 OMXDBG_PRINT(stderr, PRINT, 1, 0, "Inside the ComponentTunnelRequest\n");
1689 eError = OMX_ErrorNotImplemented;
1693 /*-------------------------------------------------------------------*/
1697 * @param pComp handle for this instance of the component
1698 * @param pCallBacks application callbacks
1701 * @retval OMX_NoError Success, ready to roll
1702 * OMX_Error_BadParameter The input parameter pointer is null
1704 /*-------------------------------------------------------------------*/
1706 static OMX_ERRORTYPE AllocateBuffer (OMX_IN OMX_HANDLETYPE hComponent,
1707 OMX_INOUT OMX_BUFFERHEADERTYPE** pBuffer,
1708 OMX_IN OMX_U32 nPortIndex,
1709 OMX_IN OMX_PTR pAppPrivate,
1710 OMX_IN OMX_U32 nSizeBytes)
1713 OMX_PARAM_PORTDEFINITIONTYPE *pPortDef;
1714 WBAMR_DEC_COMPONENT_PRIVATE *pComponentPrivate;
1715 OMX_ERRORTYPE eError = OMX_ErrorNone;
1716 OMX_BUFFERHEADERTYPE *pBufferHeader;
1718 pComponentPrivate = (WBAMR_DEC_COMPONENT_PRIVATE *)
1719 (((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate);
1721 pPortDef = ((WBAMR_DEC_COMPONENT_PRIVATE*)
1722 pComponentPrivate)->pPortDef[nPortIndex];
1723 #ifdef _ERROR_PROPAGATION__
1724 if (pComponentPrivate->curState == OMX_StateInvalid){
1725 eError = OMX_ErrorInvalidState;
1729 OMX_PRCOMM1(pComponentPrivate->dbg, "pPortDef = %p\n",pPortDef);
1730 OMX_PRCOMM1(pComponentPrivate->dbg, "pPortDef->bEnabled = %d\n",pPortDef->bEnabled);
1732 OMX_PRCOMM2(pComponentPrivate->dbg, "pPortDef->bEnabled = %d\n", pPortDef->bEnabled);
1733 while (!pPortDef->bEnabled) {
1734 pComponentPrivate->AlloBuf_waitingsignal = 1;
1736 pthread_mutex_lock(&pComponentPrivate->AlloBuf_mutex);
1737 pthread_cond_wait(&pComponentPrivate->AlloBuf_threshold, &pComponentPrivate->AlloBuf_mutex);
1738 pthread_mutex_unlock(&pComponentPrivate->AlloBuf_mutex);
1740 OMX_WaitForEvent(&(pComponentPrivate->AlloBuf_event));
1744 OMX_MALLOC_GENERIC(pBufferHeader, OMX_BUFFERHEADERTYPE);
1745 OMX_MALLOC_SIZE_DSPALIGN(pBufferHeader->pBuffer, nSizeBytes,OMX_U8);
1747 if (nPortIndex == WBAMR_DEC_INPUT_PORT) {
1748 pBufferHeader->nInputPortIndex = nPortIndex;
1749 pBufferHeader->nOutputPortIndex = -1;
1750 pComponentPrivate->pInputBufferList->pBufHdr[pComponentPrivate->pInputBufferList->numBuffers] = pBufferHeader;
1751 pComponentPrivate->pInputBufferList->bBufferPending[pComponentPrivate->pInputBufferList->numBuffers] = 0;
1752 OMX_PRBUFFER2(pComponentPrivate->dbg, "pComponentPrivate->pInputBufferList->pBufHdr[%d] = %p\n",pComponentPrivate->pInputBufferList->numBuffers,pComponentPrivate->pInputBufferList->pBufHdr[pComponentPrivate->pInputBufferList->numBuffers]);
1753 pComponentPrivate->pInputBufferList->bufferOwner[pComponentPrivate->pInputBufferList->numBuffers++] = 1;
1754 OMX_PRBUFFER2(pComponentPrivate->dbg, "Allocate WBAMR_DEC_Buffer Line\n");
1755 OMX_PRBUFFER2(pComponentPrivate->dbg, "pComponentPrivate->pInputBufferList->numBuffers = %d\n",pComponentPrivate->pInputBufferList->numBuffers);
1756 OMX_PRBUFFER2(pComponentPrivate->dbg, "pPortDef->nBufferCountMin = %ld\n",pPortDef->nBufferCountMin);
1757 if (pComponentPrivate->pInputBufferList->numBuffers == pPortDef->nBufferCountActual) {
1758 OMX_PRCOMM2(pComponentPrivate->dbg, "Setting pPortDef->bPopulated = OMX_TRUE for input port\n");
1759 pPortDef->bPopulated = OMX_TRUE;
1762 else if (nPortIndex == WBAMR_DEC_OUTPUT_PORT) {
1763 pBufferHeader->nInputPortIndex = -1;
1764 pBufferHeader->nOutputPortIndex = nPortIndex;
1765 OMX_MALLOC_GENERIC(pBufferHeader->pOutputPortPrivate, WBAMRDEC_BUFDATA);
1766 pComponentPrivate->pOutputBufferList->pBufHdr[pComponentPrivate->pOutputBufferList->numBuffers] = pBufferHeader;
1767 pComponentPrivate->pOutputBufferList->bBufferPending[pComponentPrivate->pOutputBufferList->numBuffers] = 0;
1768 OMX_PRBUFFER2(pComponentPrivate->dbg, "pComponentPrivate->pOutputBufferList->pBufHdr[%d] = %p\n",pComponentPrivate->pOutputBufferList->numBuffers,pComponentPrivate->pOutputBufferList->pBufHdr[pComponentPrivate->pOutputBufferList->numBuffers]);
1769 pComponentPrivate->pOutputBufferList->bufferOwner[pComponentPrivate->pOutputBufferList->numBuffers++] = 1;
1770 if (pComponentPrivate->pOutputBufferList->numBuffers == pPortDef->nBufferCountActual) {
1771 OMX_PRCOMM2(pComponentPrivate->dbg, "Setting pPortDef->bPopulated = OMX_TRUE for input port\n");
1772 pPortDef->bPopulated = OMX_TRUE;
1776 eError = OMX_ErrorBadPortIndex;
1779 if((pComponentPrivate->pPortDef[WBAMR_DEC_OUTPUT_PORT]->bPopulated == pComponentPrivate->pPortDef[WBAMR_DEC_OUTPUT_PORT]->bEnabled)&&
1780 (pComponentPrivate->pPortDef[WBAMR_DEC_INPUT_PORT]->bPopulated == pComponentPrivate->pPortDef[WBAMR_DEC_INPUT_PORT]->bEnabled) &&
1781 (pComponentPrivate->InLoaded_readytoidle))
1783 pComponentPrivate->InLoaded_readytoidle = 0;
1785 pthread_mutex_lock(&pComponentPrivate->InLoaded_mutex);
1786 pthread_cond_signal(&pComponentPrivate->InLoaded_threshold);
1787 pthread_mutex_unlock(&pComponentPrivate->InLoaded_mutex);
1789 OMX_SignalEvent(&(pComponentPrivate->InLoaded_event));
1792 pBufferHeader->pAppPrivate = pAppPrivate;
1793 pBufferHeader->pPlatformPrivate = pComponentPrivate;
1794 pBufferHeader->nAllocLen = nSizeBytes;
1795 pBufferHeader->nVersion.s.nVersionMajor = WBAMR_DEC_MAJOR_VER;
1796 pBufferHeader->nVersion.s.nVersionMinor = WBAMR_DEC_MINOR_VER;
1797 pComponentPrivate->nVersion = pBufferHeader->nVersion.nVersion;
1800 pBufferHeader->nSize = sizeof(OMX_BUFFERHEADERTYPE);
1801 *pBuffer = pBufferHeader;
1803 if (pComponentPrivate->bEnableCommandPending && pPortDef->bPopulated) {
1804 SendCommand (pComponentPrivate->pHandle,
1805 OMX_CommandPortEnable,
1806 pComponentPrivate->bEnableCommandParam,NULL);
1809 #ifdef __PERF_INSTRUMENTATION__
1810 PERF_ReceivedBuffer(pComponentPrivate->pPERF,
1811 (*pBuffer)->pBuffer, nSizeBytes,
1814 OMX_PRINT1(pComponentPrivate->dbg, "AllocateBuffer returning %d\n",eError);
1818 /* ================================================================================= */
1820 * @fn FreeBuffer() description for FreeBuffer
1822 Called by the OMX IL client to newfree a buffer.
1826 /* ================================================================================ */
1828 static OMX_ERRORTYPE FreeBuffer(OMX_IN OMX_HANDLETYPE hComponent,
1829 OMX_IN OMX_U32 nPortIndex,
1830 OMX_IN OMX_BUFFERHEADERTYPE* pBuffer)
1832 OMX_ERRORTYPE eError = OMX_ErrorNone;
1833 WBAMR_DEC_COMPONENT_PRIVATE * pComponentPrivate = NULL;
1834 OMX_BUFFERHEADERTYPE* buff;
1836 int inputIndex = -1;
1837 int outputIndex = -1;
1838 OMX_COMPONENTTYPE *pHandle;
1840 pComponentPrivate = (WBAMR_DEC_COMPONENT_PRIVATE *)
1841 (((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate);
1843 pHandle = (OMX_COMPONENTTYPE *) pComponentPrivate->pHandle;
1844 for (i=0; i < WBAMR_DEC_MAX_NUM_OF_BUFS; i++) {
1845 buff = pComponentPrivate->pInputBufferList->pBufHdr[i];
1846 if (buff == pBuffer) {
1847 OMX_PRBUFFER2(pComponentPrivate->dbg, "Found matching input buffer\n");
1848 OMX_PRBUFFER2(pComponentPrivate->dbg, "buff = %p\n",buff);
1849 OMX_PRBUFFER2(pComponentPrivate->dbg, "pBuffer = %p\n",pBuffer);
1854 OMX_PRBUFFER2(pComponentPrivate->dbg, "This is not a match\n");
1855 OMX_PRBUFFER2(pComponentPrivate->dbg, "buff = %p\n",buff);
1856 OMX_PRBUFFER2(pComponentPrivate->dbg, "pBuffer = %p\n",pBuffer);
1860 for (i=0; i < WBAMR_DEC_MAX_NUM_OF_BUFS; i++) {
1861 buff = pComponentPrivate->pOutputBufferList->pBufHdr[i];
1862 if (buff == pBuffer) {
1863 OMX_PRBUFFER2(pComponentPrivate->dbg, "Found matching output buffer\n");
1864 OMX_PRBUFFER2(pComponentPrivate->dbg, "buff = %p\n",buff);
1865 OMX_PRBUFFER2(pComponentPrivate->dbg, "pBuffer = %p\n",pBuffer);
1870 OMX_PRBUFFER2(pComponentPrivate->dbg, "This is not a match\n");
1871 OMX_PRBUFFER2(pComponentPrivate->dbg, "buff = %p\n",buff);
1872 OMX_PRBUFFER2(pComponentPrivate->dbg, "pBuffer = %p\n",pBuffer);
1877 if (inputIndex != -1) {
1878 #ifdef __PERF_INSTRUMENTATION__
1879 PERF_SendingBuffer(pComponentPrivate->pPERF,
1880 pComponentPrivate->pInputBufferList->pBufHdr[inputIndex]->pBuffer,
1881 pComponentPrivate->pInputBufferList->pBufHdr[inputIndex]->nAllocLen,
1884 if (pComponentPrivate->pInputBufferList->bufferOwner[inputIndex] == 1) {
1885 OMX_MEMFREE_STRUCT_DSPALIGN(pComponentPrivate->pInputBufferList->pBufHdr[inputIndex]->pBuffer, OMX_U8);
1887 OMX_MEMFREE_STRUCT(pComponentPrivate->pInputBufferList->pBufHdr[inputIndex]);
1888 pComponentPrivate->pInputBufferList->numBuffers--;
1889 if (pComponentPrivate->pInputBufferList->numBuffers <
1890 pComponentPrivate->pPortDef[WBAMR_DEC_INPUT_PORT]->nBufferCountMin) {
1892 pComponentPrivate->pPortDef[WBAMR_DEC_INPUT_PORT]->bPopulated = OMX_FALSE;
1894 if(pComponentPrivate->pPortDef[WBAMR_DEC_INPUT_PORT]->bEnabled &&
1895 pComponentPrivate->bLoadedCommandPending == OMX_FALSE &&
1896 (pComponentPrivate->curState == OMX_StateIdle ||
1897 pComponentPrivate->curState == OMX_StateExecuting ||
1898 pComponentPrivate->curState == OMX_StatePause)) {
1899 pComponentPrivate->cbInfo.EventHandler(
1900 pHandle, pHandle->pApplicationPrivate,
1901 OMX_EventError, OMX_ErrorPortUnpopulated,OMX_TI_ErrorMinor, "Input Port Unpopulated");
1904 else if (outputIndex != -1) {
1905 #ifdef __PERF_INSTRUMENTATION__
1906 PERF_SendingBuffer(pComponentPrivate->pPERF,
1907 pComponentPrivate->pOutputBufferList->pBufHdr[outputIndex]->pBuffer,
1908 pComponentPrivate->pOutputBufferList->pBufHdr[outputIndex]->nAllocLen,
1911 if (pComponentPrivate->pOutputBufferList->bufferOwner[outputIndex] == 1) {
1912 OMX_MEMFREE_STRUCT_DSPALIGN(pComponentPrivate->pOutputBufferList->pBufHdr[outputIndex]->pBuffer, OMX_U8);
1914 OMX_MEMFREE_STRUCT(pComponentPrivate->pOutputBufferList->pBufHdr[outputIndex]->pOutputPortPrivate);
1915 OMX_MEMFREE_STRUCT(pComponentPrivate->pOutputBufferList->pBufHdr[outputIndex]);
1916 pComponentPrivate->pOutputBufferList->numBuffers--;
1918 if (pComponentPrivate->pOutputBufferList->numBuffers <
1919 pComponentPrivate->pPortDef[WBAMR_DEC_OUTPUT_PORT]->nBufferCountMin) {
1920 pComponentPrivate->pPortDef[WBAMR_DEC_OUTPUT_PORT]->bPopulated = OMX_FALSE;
1922 if(pComponentPrivate->pPortDef[WBAMR_DEC_OUTPUT_PORT]->bEnabled &&
1923 pComponentPrivate->bLoadedCommandPending == OMX_FALSE &&
1924 (pComponentPrivate->curState == OMX_StateIdle ||
1925 pComponentPrivate->curState == OMX_StateExecuting ||
1926 pComponentPrivate->curState == OMX_StatePause)) {
1927 pComponentPrivate->cbInfo.EventHandler(
1928 pHandle, pHandle->pApplicationPrivate,
1929 OMX_EventError, OMX_ErrorPortUnpopulated,OMX_TI_ErrorMinor, "Output Port Unpopulated");
1933 OMX_ERROR4(pComponentPrivate->dbg, "Returning OMX_ErrorBadParameter\n");
1934 eError = OMX_ErrorBadParameter;
1936 if ((!pComponentPrivate->pInputBufferList->numBuffers &&
1937 !pComponentPrivate->pOutputBufferList->numBuffers) &&
1938 pComponentPrivate->InIdle_goingtoloaded)
1940 pComponentPrivate->InIdle_goingtoloaded = 0;
1942 pthread_mutex_lock(&pComponentPrivate->InIdle_mutex);
1943 pthread_cond_signal(&pComponentPrivate->InIdle_threshold);
1944 pthread_mutex_unlock(&pComponentPrivate->InIdle_mutex);
1946 OMX_SignalEvent(&(pComponentPrivate->InIdle_event));
1949 if (pComponentPrivate->bDisableCommandPending && (pComponentPrivate->pInputBufferList->numBuffers + pComponentPrivate->pOutputBufferList->numBuffers == 0)) {
1950 SendCommand (pComponentPrivate->pHandle,OMX_CommandPortDisable,pComponentPrivate->bDisableCommandParam,NULL);
1953 OMX_PRINT1(pComponentPrivate->dbg, "Exiting FreeBuffer\n");
1957 /* ================================================================================= */
1959 * @fn UseBuffer() description for UseBuffer
1961 Called by the OMX IL client to pass a buffer to be used.
1965 /* ================================================================================ */
1967 static OMX_ERRORTYPE UseBuffer (OMX_IN OMX_HANDLETYPE hComponent,
1968 OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr,
1969 OMX_IN OMX_U32 nPortIndex,
1970 OMX_IN OMX_PTR pAppPrivate,
1971 OMX_IN OMX_U32 nSizeBytes,
1972 OMX_IN OMX_U8* pBuffer)
1974 OMX_PARAM_PORTDEFINITIONTYPE *pPortDef;
1975 WBAMR_DEC_COMPONENT_PRIVATE *pComponentPrivate;
1976 OMX_ERRORTYPE eError = OMX_ErrorNone;
1977 OMX_BUFFERHEADERTYPE *pBufferHeader;
1979 pComponentPrivate = (WBAMR_DEC_COMPONENT_PRIVATE *)
1980 (((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate);
1982 #ifdef _ERROR_PROPAGATION__
1983 if (pComponentPrivate->curState == OMX_StateInvalid){
1984 eError = OMX_ErrorInvalidState;
1988 pPortDef = ((WBAMR_DEC_COMPONENT_PRIVATE*)
1989 pComponentPrivate)->pPortDef[nPortIndex];
1990 OMX_PRCOMM1(pComponentPrivate->dbg, "pPortDef->bPopulated = %d\n",pPortDef->bPopulated);
1992 if(!pPortDef->bEnabled) {
1993 OMX_ERROR4(pComponentPrivate->dbg, "In UseBuffer\n");
1994 eError = OMX_ErrorIncorrectStateOperation;
1998 /*if(nSizeBytes != pPortDef->nBufferSize || pPortDef->bPopulated) {
1999 OMX_PRINT1(pComponentPrivate->dbg, "In UseBuffer\n");
2000 eError = OMX_ErrorBadParameter;
2004 OMX_MALLOC_GENERIC(pBufferHeader, OMX_BUFFERHEADERTYPE);
2005 if (nPortIndex == WBAMR_DEC_OUTPUT_PORT) {
2006 pBufferHeader->nInputPortIndex = -1;
2007 pBufferHeader->nOutputPortIndex = nPortIndex;
2008 OMX_MALLOC_GENERIC(pBufferHeader->pOutputPortPrivate, WBAMRDEC_BUFDATA);
2009 pComponentPrivate->pOutputBufferList->pBufHdr[pComponentPrivate->pOutputBufferList->numBuffers] = pBufferHeader;
2010 pComponentPrivate->pOutputBufferList->bBufferPending[pComponentPrivate->pOutputBufferList->numBuffers] = 0;
2011 pComponentPrivate->pOutputBufferList->bufferOwner[pComponentPrivate->pOutputBufferList->numBuffers++] = 0;
2012 if (pComponentPrivate->pOutputBufferList->numBuffers == pPortDef->nBufferCountActual) {
2013 pPortDef->bPopulated = OMX_TRUE;
2017 pBufferHeader->nInputPortIndex = nPortIndex;
2018 pBufferHeader->nOutputPortIndex = -1;
2019 pComponentPrivate->pInputBufferList->pBufHdr[pComponentPrivate->pInputBufferList->numBuffers] = pBufferHeader;
2020 pComponentPrivate->pInputBufferList->bBufferPending[pComponentPrivate->pInputBufferList->numBuffers] = 0;
2021 pComponentPrivate->pInputBufferList->bufferOwner[pComponentPrivate->pInputBufferList->numBuffers++] = 0;
2022 if (pComponentPrivate->pInputBufferList->numBuffers == pPortDef->nBufferCountActual) {
2023 pPortDef->bPopulated = OMX_TRUE;
2027 if((pComponentPrivate->pPortDef[WBAMR_DEC_OUTPUT_PORT]->bPopulated == pComponentPrivate->pPortDef[WBAMR_DEC_OUTPUT_PORT]->bEnabled)&&
2028 (pComponentPrivate->pPortDef[WBAMR_DEC_INPUT_PORT]->bPopulated == pComponentPrivate->pPortDef[WBAMR_DEC_INPUT_PORT]->bEnabled) &&
2029 (pComponentPrivate->InLoaded_readytoidle))
2031 pComponentPrivate->InLoaded_readytoidle = 0;
2033 pthread_mutex_lock(&pComponentPrivate->InLoaded_mutex);
2034 pthread_cond_signal(&pComponentPrivate->InLoaded_threshold);
2035 pthread_mutex_unlock(&pComponentPrivate->InLoaded_mutex);
2037 OMX_SignalEvent(&(pComponentPrivate->InLoaded_event));
2040 pBufferHeader->pAppPrivate = pAppPrivate;
2041 pBufferHeader->pPlatformPrivate = pComponentPrivate;
2042 pBufferHeader->nAllocLen = nSizeBytes;
2043 pBufferHeader->nVersion.s.nVersionMajor = WBAMR_DEC_MAJOR_VER;
2044 pBufferHeader->nVersion.s.nVersionMinor = WBAMR_DEC_MINOR_VER;
2045 pComponentPrivate->nVersion = pBufferHeader->nVersion.nVersion;
2046 pBufferHeader->pBuffer = pBuffer;
2047 pBufferHeader->nSize = sizeof(OMX_BUFFERHEADERTYPE);
2048 *ppBufferHdr = pBufferHeader;
2049 OMX_PRBUFFER2(pComponentPrivate->dbg, "pBufferHeader = %p\n",pBufferHeader);
2051 #ifdef __PERF_INSTRUMENTATION__
2052 PERF_ReceivedBuffer(pComponentPrivate->pPERF,
2053 pBuffer, nSizeBytes,
2059 /* ================================================================================= */
2061 * @fn GetExtensionIndex() description for GetExtensionIndex
2062 GetExtensionIndex().
2063 Returns index for vendor specific settings.
2067 /* ================================================================================ */
2068 static OMX_ERRORTYPE GetExtensionIndex(OMX_IN OMX_HANDLETYPE hComponent,
2069 OMX_IN OMX_STRING cParameterName,
2070 OMX_OUT OMX_INDEXTYPE* pIndexType)
2072 OMX_ERRORTYPE eError = OMX_ErrorNone;
2074 if(!(strcmp(cParameterName,"OMX.TI.index.config.wbamrheaderinfo"))) {
2075 *pIndexType = OMX_IndexCustomWbAmrDecHeaderInfoConfig;
2077 else if(!(strcmp(cParameterName,"OMX.TI.index.config.wbamrstreamIDinfo"))) {
2078 *pIndexType = OMX_IndexCustomWbAmrDecStreamIDConfig;
2080 else if(!(strcmp(cParameterName,"OMX.TI.index.config.wbamr.datapath")))
2082 *pIndexType = OMX_IndexCustomWbAmrDecDataPath;
2084 else if(!(strcmp(cParameterName,"OMX.TI.index.config.wbamr.framelost")))
2086 *pIndexType = OMX_IndexCustomWbAmrDecNextFrameLost;
2088 else if(!(strcmp(cParameterName,"OMX.TI.WBAMR.Decode.Debug")))
2090 *pIndexType = OMX_IndexCustomDebug;
2093 eError = OMX_ErrorBadParameter;
2099 /* ================================================================================= */
2101 * @fn ComponentRoleEnum() description for ComponentRoleEnum()
2103 Returns the role at the given index
2107 /* ================================================================================ */
2108 static OMX_ERRORTYPE ComponentRoleEnum(OMX_IN OMX_HANDLETYPE hComponent,
2109 OMX_OUT OMX_U8 *cRole,
2110 OMX_IN OMX_U32 nIndex)
2112 WBAMR_DEC_COMPONENT_PRIVATE *pComponentPrivate;
2114 OMX_ERRORTYPE eError = OMX_ErrorNone;
2115 pComponentPrivate = (WBAMR_DEC_COMPONENT_PRIVATE *)(((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate);
2117 if (cRole == NULL) {
2118 eError = OMX_ErrorBadParameter;
2121 memcpy(cRole, &pComponentPrivate->componentRole.cRole, sizeof(OMX_U8) * OMX_MAX_STRINGNAME_SIZE);
2122 OMX_PRINT1(pComponentPrivate->dbg, "In ComponenetRoleEnum: cRole is set to %s\n",cRole);
2126 eError = OMX_ErrorNoMore;
2131 #ifdef WBAMRDEC_DEBUGMEM
2132 void * mymalloc(int line, char *s, int size)
2138 OMXDBG_PRINT(stderr, ERROR, 4, 0, "Memory not available\n");
2142 while((lines[e]!=0)&& (e<500) ){
2149 OMXDBG_PRINT(stderr, PRINT, 1, 0, "Allocating %d bytes on address %p, line %d file %s\n", size, p, line, s);
2154 int myfree(void *dp, int line, char *s){
2157 OMXDBG_PRINT(stderr, ERROR, 4, 0, "Null Memory can not be deleted line: %d file: %s\n", line, s);
2163 OMXDBG_PRINT(stderr, PRINT, 1, 0, "Deleting %d bytes on address %p, line %d file %s\n", bytes[q],dp, line, s);
2172 OMXDBG_PRINT(stderr, ERROR, 4, 0, "\n\nPointer not found. Line:%d File%s!!\n\n",line, s);