OMX_Mp3Dec_Utils.c revision b65f253fdc60f6208a54911bee793d225f23cdf8
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_Mp3Dec_Utils.c 30 * 31 * This file implements various utilitiy functions for various activities 32 * like handling command from application, callback from LCML etc. 33 * 34 * @path $(CSLPATH)\OMAPSW_MPU\linux\audio\src\openmax_il\mp3_dec\src 35 * 36 * @rev 1.0 37 */ 38/* ---------------------------------------------------------------------------- 39 *! 40 *! Revision History 41 *! =================================== 42 *! 21-sept-2006 bk: updated some review findings for alpha release 43 *! 24-Aug-2006 bk: Khronos OpenMAX (TM) 1.0 Conformance tests some more 44 *! 18-July-2006 bk: Khronos OpenMAX (TM) 1.0 Conformance tests validated for few cases 45 *! This is newest file 46 * =========================================================================== */ 47/* ------compilation control switches -------------------------*/ 48/**************************************************************** 49 * INCLUDE FILES 50 ****************************************************************/ 51/* ----- system and platform files ----------------------------*/ 52 53 54 55#ifdef UNDER_CE 56#include <windows.h> 57#include <oaf_osal.h> 58#include <omx_core.h> 59#include <stdlib.h> 60#else 61#include <wchar.h> 62#include <unistd.h> 63#include <sys/types.h> 64#include <sys/wait.h> 65#include <sys/types.h> 66#include <sys/stat.h> 67#include <dlfcn.h> 68#include <malloc.h> 69#include <memory.h> 70#include <fcntl.h> 71#endif 72 73#include <dbapi.h> 74#include <string.h> 75#include <stdio.h> 76#include <pthread.h> 77 78/*------- Program Header Files -----------------------------------------------*/ 79#include "LCML_DspCodec.h" 80#include "OMX_Mp3Dec_Utils.h" 81#include "mp3decsocket_ti.h" 82#include <decode_common_ti.h> 83#include "usn.h" 84 85#ifdef RESOURCE_MANAGER_ENABLED 86#include <ResourceManagerProxyAPI.h> 87#endif 88 89#ifdef UNDER_CE 90#define HASHINGENABLE 1 91HINSTANCE g_hLcmlDllHandle = NULL; 92void sleep(DWORD Duration) 93{ 94 Sleep(Duration); 95 96} 97#endif 98 99/* ================================================================================= * */ 100/** 101 * @fn MP3DEC_Fill_LCMLInitParams() fills the LCML initialization structure. 102 * 103 * @param pHandle This is component handle allocated by the OMX core. 104 * 105 * @param plcml_Init This structure is filled and sent to LCML. 106 * 107 * @pre None 108 * 109 * @post None 110 * 111 * @return OMX_ErrorNone = Successful Inirialization of the LCML struct. 112 * OMX_ErrorInsufficientResources = Not enough memory 113 * 114 * @see None 115 */ 116/* ================================================================================ * */ 117OMX_ERRORTYPE MP3DEC_Fill_LCMLInitParams(OMX_HANDLETYPE pComponent,LCML_DSP *plcml_Init,OMX_U16 arr[]) 118{ 119 OMX_ERRORTYPE eError = OMX_ErrorNone; 120 OMX_U32 nIpBuf,nIpBufSize,nOpBuf,nOpBufSize; 121 OMX_U32 i; 122 OMX_BUFFERHEADERTYPE *pTemp = NULL; 123 OMX_COMPONENTTYPE *pHandle = (OMX_COMPONENTTYPE *)pComponent; 124 MP3DEC_COMPONENT_PRIVATE *pComponentPrivate =(MP3DEC_COMPONENT_PRIVATE *)pHandle->pComponentPrivate; 125 MP3D_LCML_BUFHEADERTYPE *pTemp_lcml; 126 OMX_U32 size_lcml; 127 OMX_U8 *ptr; 128 129 pComponentPrivate->nRuntimeInputBuffers = 0; 130 pComponentPrivate->nRuntimeOutputBuffers = 0; 131 132 OMX_PRINT1(pComponentPrivate->dbg, "Entered MP3DEC_Fill_LCMLInitParams\n"); 133 OMX_PRCOMM2(pComponentPrivate->dbg, ":::pComponentPrivate->pPortDef[MP3D_INPUT_PORT]->bPopulated = %d\n", 134 pComponentPrivate->pPortDef[MP3D_INPUT_PORT]->bPopulated); 135 OMX_PRCOMM2(pComponentPrivate->dbg, ":::pComponentPrivate->pPortDef[MP3D_INPUT_PORT]->bEnabled = %d\n", 136 pComponentPrivate->pPortDef[MP3D_INPUT_PORT]->bEnabled); 137 OMX_PRCOMM2(pComponentPrivate->dbg, ":::pComponentPrivate->pPortDef[MP3D_OUTPUT_PORT]->bPopulated = %d\n", 138 pComponentPrivate->pPortDef[MP3D_OUTPUT_PORT]->bPopulated); 139 OMX_PRCOMM2(pComponentPrivate->dbg, ":::pComponentPrivate->pPortDef[MP3D_OUTPUT_PORT]->bEnabled = %d\n", 140 pComponentPrivate->pPortDef[MP3D_OUTPUT_PORT]->bEnabled); 141 142 pComponentPrivate->strmAttr = NULL; 143 144 nIpBuf = pComponentPrivate->pInputBufferList->numBuffers; 145 pComponentPrivate->nRuntimeInputBuffers = nIpBuf; 146 nOpBuf = pComponentPrivate->pOutputBufferList->numBuffers; 147 pComponentPrivate->nRuntimeOutputBuffers = nOpBuf; 148 nIpBufSize = pComponentPrivate->pPortDef[MP3D_INPUT_PORT]->nBufferSize; 149 nOpBufSize = pComponentPrivate->pPortDef[MP3D_OUTPUT_PORT]->nBufferSize; 150 151 152 OMX_PRBUFFER2(pComponentPrivate->dbg, "Input Buffer Count = %ld\n",nIpBuf); 153 OMX_PRBUFFER2(pComponentPrivate->dbg, "Input Buffer Size = %ld\n",nIpBufSize); 154 OMX_PRBUFFER2(pComponentPrivate->dbg, "Output Buffer Count = %ld\n",nOpBuf); 155 OMX_PRBUFFER2(pComponentPrivate->dbg, "Output Buffer Size = %ld\n",nOpBufSize); 156 157 plcml_Init->In_BufInfo.nBuffers = nIpBuf; 158 plcml_Init->In_BufInfo.nSize = nIpBufSize; 159 plcml_Init->In_BufInfo.DataTrMethod = DMM_METHOD; 160 plcml_Init->Out_BufInfo.nBuffers = nOpBuf; 161 plcml_Init->Out_BufInfo.nSize = nOpBufSize; 162 plcml_Init->Out_BufInfo.DataTrMethod = DMM_METHOD; 163 164 165 plcml_Init->NodeInfo.nNumOfDLLs = 3; 166 167 memset(plcml_Init->NodeInfo.AllUUIDs[0].DllName,0, sizeof(plcml_Init->NodeInfo.AllUUIDs[0].DllName)); 168 memset(plcml_Init->NodeInfo.AllUUIDs[1].DllName,0, sizeof(plcml_Init->NodeInfo.AllUUIDs[1].DllName)); 169 memset(plcml_Init->NodeInfo.AllUUIDs[2].DllName,0, sizeof(plcml_Init->NodeInfo.AllUUIDs[1].DllName)); 170 memset(plcml_Init->NodeInfo.AllUUIDs[0].DllName,0, sizeof(plcml_Init->DeviceInfo.AllUUIDs[1].DllName)); 171 172 plcml_Init->NodeInfo.AllUUIDs[0].uuid = &MP3DECSOCKET_TI_UUID; 173 strcpy ((char*)plcml_Init->NodeInfo.AllUUIDs[0].DllName, MP3DEC_DLL_NAME); 174 plcml_Init->NodeInfo.AllUUIDs[0].eDllType = DLL_NODEOBJECT; 175 176 plcml_Init->NodeInfo.AllUUIDs[1].uuid = &MP3DECSOCKET_TI_UUID; 177 strcpy ((char*)plcml_Init->NodeInfo.AllUUIDs[1].DllName, MP3DEC_DLL_NAME); 178 plcml_Init->NodeInfo.AllUUIDs[1].eDllType = DLL_DEPENDENT; 179 180 plcml_Init->NodeInfo.AllUUIDs[2].uuid = &USN_TI_UUID; 181 strcpy ((char*)plcml_Init->NodeInfo.AllUUIDs[2].DllName, MP3DEC_USN_DLL_NAME); 182 plcml_Init->NodeInfo.AllUUIDs[2].eDllType = DLL_DEPENDENT; 183 184 plcml_Init->SegID = OMX_MP3DEC_DEFAULT_SEGMENT; 185 plcml_Init->Timeout = OMX_MP3DEC_SN_TIMEOUT; 186 plcml_Init->Alignment = 0; 187 plcml_Init->Priority = OMX_MP3DEC_SN_PRIORITY; 188 plcml_Init->ProfileID = -1; 189 190 if(pComponentPrivate->dasfmode == 1) { 191#ifndef DSP_RENDERING_ON 192 MP3D_OMX_ERROR_EXIT(eError, OMX_ErrorInsufficientResources, 193 "Flag DSP_RENDERING_ON Must Be Defined To Use Rendering"); 194#else 195 LCML_STRMATTR *strmAttr; 196 OMX_MALLOC_GENERIC(strmAttr, LCML_STRMATTR); 197 OMX_PRBUFFER2(pComponentPrivate->dbg, ": Malloc strmAttr = %p\n",strmAttr); 198 pComponentPrivate->strmAttr = strmAttr; 199 OMX_PRDSP2(pComponentPrivate->dbg, ":: MP3 DECODER IS RUNNING UNDER DASF MODE \n"); 200 201 strmAttr->uSegid = 0; 202 strmAttr->uAlignment = 0; 203 strmAttr->uTimeout = -1; 204 205 strmAttr->uBufsize = MP3D_OUTPUT_BUFFER_SIZE; 206 207 OMX_PRBUFFER2(pComponentPrivate->dbg, "::strmAttr->uBufsize:%d\n",strmAttr->uBufsize); 208 209 strmAttr->uNumBufs = 2; 210 strmAttr->lMode = STRMMODE_PROCCOPY; 211 plcml_Init->DeviceInfo.TypeofDevice = 1; 212 plcml_Init->DeviceInfo.TypeofRender = 0; 213 214 plcml_Init->DeviceInfo.AllUUIDs[0].uuid = &DCTN_TI_UUID; 215 plcml_Init->DeviceInfo.DspStream = strmAttr; 216#endif 217 } else { 218 plcml_Init->DeviceInfo.TypeofDevice = 0; 219 } 220 221 if (pComponentPrivate->dasfmode == 0){ 222 OMX_PRDSP2(pComponentPrivate->dbg, ":: FILE MODE CREATE PHASE PARAMETERS\n"); 223 arr[0] = 2; /* Number of Streams */ 224 arr[1] = 0; /* ID of the Input Stream */ 225 arr[2] = 0; /* Type of Input Stream DMM (0) / STRM (1) */ 226#ifndef UNDER_CE 227 arr[3] = 4; /* Number of buffers for Input Stream */ 228#else 229 arr[3] = 1; /* WinCE Number of buffers for Input Stream */ 230#endif 231 arr[4] = 1; /* ID of the Output Stream */ 232 arr[5] = 0; /* Type of Output Stream */ 233#ifndef UNDER_CE 234 arr[6] = 4; /* Number of buffers for Output Stream */ 235#else 236 arr[6] = 1; /* WinCE Number of buffers for Output Stream */ 237#endif 238 239 if(pComponentPrivate->pcmParams->nBitPerSample == 24){ 240 OMX_PRCOMM2(pComponentPrivate->dbg, " PCM 24 bit output\n"); 241 arr[7] = 24; 242 } else { 243 OMX_PRCOMM2(pComponentPrivate->dbg, " PCM 16 bit output\n"); 244 arr[7] = 16; 245 } 246 247 if(pComponentPrivate->frameMode) { 248 OMX_PRMGR2(pComponentPrivate->dbg, " frame mode is on\n"); 249 arr[8] = 1; /* frame mode is on */ 250 } else { 251 arr[8] = 0; 252 OMX_PRMGR2(pComponentPrivate->dbg, " frame mode is off\n"); 253 } 254 arr[9] = END_OF_CR_PHASE_ARGS; 255 } else { 256 OMX_PRDSP2(pComponentPrivate->dbg, ":: DASF MODE CREATE PHASE PARAMETERS\n"); 257 arr[0] = 2; /* Number of Streams */ 258 arr[1] = 0; /* ID of the Input Stream */ 259 arr[2] = 0; /* Type of Input Stream DMM (0) / STRM (1) */ 260 arr[3] = 4; /* Number of buffers for Input Stream */ 261 arr[4] = 1; /* ID of the Output Stream */ 262 arr[5] = 2; /* Type of Output Stream */ 263 arr[6] = 2; /* Number of buffers for Output Stream */ 264 arr[7] = 16; /*Decoder Output PCM width is 24-bit or 16-bit */ 265 arr[8] = 0; /* frame mode off */ 266 267 arr[9] = END_OF_CR_PHASE_ARGS; 268 } 269 270 plcml_Init->pCrPhArgs = arr; 271 272 OMX_PRBUFFER2(pComponentPrivate->dbg, ":: bufAlloced = %d\n",pComponentPrivate->bufAlloced); 273 size_lcml = nIpBuf * sizeof(MP3D_LCML_BUFHEADERTYPE); 274 OMX_MALLOC_SIZE(ptr,size_lcml,OMX_U8); 275 pTemp_lcml = (MP3D_LCML_BUFHEADERTYPE *)ptr; 276 277 pComponentPrivate->pLcmlBufHeader[MP3D_INPUT_PORT] = pTemp_lcml; 278 279 for (i=0; i<nIpBuf; i++) { 280 pTemp = pComponentPrivate->pInputBufferList->pBufHdr[i]; 281 pTemp->nSize = sizeof(OMX_BUFFERHEADERTYPE); 282 283 pTemp->nAllocLen = nIpBufSize; 284 pTemp->nFilledLen = nIpBufSize; 285 pTemp->nVersion.s.nVersionMajor = MP3DEC_MAJOR_VER; 286 pTemp->nVersion.s.nVersionMinor = MP3DEC_MINOR_VER; 287 288 pTemp->pPlatformPrivate = pHandle->pComponentPrivate; 289 pTemp->nTickCount = 0; 290 291 pTemp_lcml->pBufHdr = pTemp; 292 pTemp_lcml->eDir = OMX_DirInput; 293 pTemp_lcml->pOtherParams[i] = NULL; 294 OMX_MALLOC_SIZE_DSPALIGN(pTemp_lcml->pIpParam, 295 sizeof(MP3DEC_UAlgInBufParamStruct), 296 MP3DEC_UAlgInBufParamStruct); 297 pTemp_lcml->pIpParam->bLastBuffer = 0; 298 299 pTemp->nFlags = NORMAL_BUFFER; 300 ((MP3DEC_COMPONENT_PRIVATE *) pTemp->pPlatformPrivate)->pHandle = pHandle; 301 302 OMX_PRBUFFER2(pComponentPrivate->dbg, "::Comp: InBuffHeader[%ld] = %p\n", i, pTemp); 303 OMX_PRBUFFER2(pComponentPrivate->dbg, "::Comp: >>>> InputBuffHeader[%ld]->pBuffer = %p\n", i, pTemp->pBuffer); 304 OMX_PRDSP2(pComponentPrivate->dbg, "::Comp: Ip : pTemp_lcml[%ld] = %p\n", i, pTemp_lcml); 305 306 pTemp_lcml++; 307 } 308 309 size_lcml = nOpBuf * sizeof(MP3D_LCML_BUFHEADERTYPE); 310 OMX_MALLOC_SIZE(pTemp_lcml,size_lcml,MP3D_LCML_BUFHEADERTYPE); 311 pComponentPrivate->pLcmlBufHeader[MP3D_OUTPUT_PORT] = pTemp_lcml; 312 313 for (i=0; i<nOpBuf; i++) { 314 pTemp = pComponentPrivate->pOutputBufferList->pBufHdr[i]; 315 pTemp->nSize = sizeof(OMX_BUFFERHEADERTYPE); 316 317 pTemp->nAllocLen = nOpBufSize; 318 319 OMX_PRBUFFER2(pComponentPrivate->dbg, ":: nOpBufSize = %ld\n", nOpBufSize); 320 321 pTemp->nVersion.s.nVersionMajor = MP3DEC_MAJOR_VER; 322 pTemp->nVersion.s.nVersionMinor = MP3DEC_MINOR_VER; 323 pTemp->pPlatformPrivate = pHandle->pComponentPrivate; 324 pTemp->nTickCount = 0; 325 326 pTemp_lcml->pBufHdr = pTemp; 327 pTemp_lcml->eDir = OMX_DirOutput; 328 pTemp_lcml->pOtherParams[i] = NULL; 329 OMX_MALLOC_SIZE_DSPALIGN(pTemp_lcml->pOpParam, 330 sizeof(MP3DEC_UAlgOutBufParamStruct), 331 MP3DEC_UAlgOutBufParamStruct); 332 pTemp_lcml->pOpParam->ulFrameCount = DONT_CARE; 333 pTemp_lcml->pOpParam->ulIsLastBuffer = 0; 334 335 pTemp->nFlags = NORMAL_BUFFER; 336 ((MP3DEC_COMPONENT_PRIVATE *)pTemp->pPlatformPrivate)->pHandle = pHandle; 337 OMX_PRBUFFER2(pComponentPrivate->dbg, "::Comp: >>>>>>>>>>>>> OutBuffHeader[%ld] = %p\n", i, pTemp); 338 OMX_PRBUFFER2(pComponentPrivate->dbg, "::Comp: >>>> OutBuffHeader[%ld]->pBuffer = %p\n", i, pTemp->pBuffer); 339 OMX_PRBUFFER2(pComponentPrivate->dbg, "::Comp: Op : pTemp_lcml[%ld] = %p\n", i, pTemp_lcml); 340 pTemp_lcml++; 341 } 342 pComponentPrivate->bPortDefsAllocated = 1; 343 OMX_MALLOC_SIZE_DSPALIGN(pComponentPrivate->pParams,sizeof(USN_AudioCodecParams), 344 USN_AudioCodecParams); 345 OMX_MALLOC_SIZE_DSPALIGN(pComponentPrivate->ptAlgDynParams,sizeof(MP3DEC_UALGParams), 346 MP3DEC_UALGParams); 347 348#ifdef __PERF_INSTRUMENTATION__ 349 pComponentPrivate->nLcml_nCntIp = 0; 350 pComponentPrivate->nLcml_nCntOpReceived = 0; 351#endif 352 353 pComponentPrivate->bInitParamsInitialized = 1; 354 355 EXIT: 356 OMX_PRINT1(pComponentPrivate->dbg, "Exiting MP3DEC_Fill_LCMLInitParams. error=%d\n", eError); 357 358 return eError; 359} 360 361 362/* ================================================================================= * */ 363/** 364 * @fn Mp3Dec_StartCompThread() starts the component thread. This is internal 365 * function of the component. 366 * 367 * @param pHandle This is component handle allocated by the OMX core. 368 * 369 * @pre None 370 * 371 * @post None 372 * 373 * @return OMX_ErrorNone = Successful Inirialization of the component\n 374 * OMX_ErrorInsufficientResources = Not enough memory 375 * 376 * @see None 377 */ 378/* ================================================================================ * */ 379OMX_ERRORTYPE Mp3Dec_StartCompThread(OMX_HANDLETYPE pComponent) 380{ 381 OMX_ERRORTYPE eError = OMX_ErrorNone; 382 OMX_COMPONENTTYPE *pHandle = (OMX_COMPONENTTYPE *)pComponent; 383 MP3DEC_COMPONENT_PRIVATE *pComponentPrivate = 384 (MP3DEC_COMPONENT_PRIVATE *)pHandle->pComponentPrivate; 385 int nRet = 0; 386 387#ifdef UNDER_CE 388 pthread_attr_t attr; 389 memset(&attr, 0, sizeof(attr)); 390 attr.__inheritsched = PTHREAD_EXPLICIT_SCHED; 391 attr.__schedparam.__sched_priority = OMX_AUDIO_DECODER_THREAD_PRIORITY; 392#endif 393 394 OMX_PRINT1(pComponentPrivate->dbg, ":: Enetering Mp3Dec_StartCompThread()\n"); 395 396 pComponentPrivate->lcml_nOpBuf = 0; 397 pComponentPrivate->lcml_nIpBuf = 0; 398 pComponentPrivate->app_nBuf = 0; 399 pComponentPrivate->num_Op_Issued = 0; 400 pComponentPrivate->num_Sent_Ip_Buff = 0; 401 pComponentPrivate->num_Reclaimed_Op_Buff = 0; 402 pComponentPrivate->bIsEOFSent = 0; 403 404 nRet = pipe (pComponentPrivate->dataPipe); 405 if (0 != nRet) { 406 MP3D_OMX_ERROR_EXIT(eError, OMX_ErrorInsufficientResources, 407 "Pipe Creation Failed"); 408 } 409 410 nRet = pipe (pComponentPrivate->cmdPipe); 411 if (0 != nRet) { 412 MP3D_OMX_ERROR_EXIT(eError, OMX_ErrorInsufficientResources, 413 "Pipe Creation Failed"); 414 } 415 416 nRet = pipe (pComponentPrivate->cmdDataPipe); 417 if (0 != nRet) { 418 MP3D_OMX_ERROR_EXIT(eError, OMX_ErrorInsufficientResources, 419 "Pipe Creation Failed"); 420 } 421 422 423#ifdef UNDER_CE 424 nRet = pthread_create (&(pComponentPrivate->ComponentThread), &attr, 425 MP3DEC_ComponentThread, pComponentPrivate); 426#else 427 nRet = pthread_create (&(pComponentPrivate->ComponentThread), NULL, 428 MP3DEC_ComponentThread, pComponentPrivate); 429#endif 430 if ((0 != nRet) || (!pComponentPrivate->ComponentThread)) { 431 MP3D_OMX_ERROR_EXIT(eError, OMX_ErrorInsufficientResources, 432 "Thread Creation Failed"); 433 } 434 435 pComponentPrivate->bCompThreadStarted = 1; 436 437 OMX_PRINT1(pComponentPrivate->dbg, ":: Exiting from Mp3Dec_StartCompThread()\n"); 438 439 EXIT: 440 return eError; 441} 442 443 444/* ================================================================================= * */ 445/** 446 * @fn MP3DEC_FreeCompResources() function newfrees the component resources. 447 * 448 * @param pComponent This is the component handle. 449 * 450 * @pre None 451 * 452 * @post None 453 * 454 * @return OMX_ErrorNone = Successful Inirialization of the component\n 455 * OMX_ErrorHardware = Hardware error has occured. 456 * 457 * @see None 458 */ 459/* ================================================================================ * */ 460 461OMX_ERRORTYPE MP3DEC_FreeCompResources(OMX_HANDLETYPE pComponent) 462{ 463 OMX_COMPONENTTYPE *pHandle = (OMX_COMPONENTTYPE *)pComponent; 464 MP3DEC_COMPONENT_PRIVATE *pComponentPrivate = (MP3DEC_COMPONENT_PRIVATE *) 465 pHandle->pComponentPrivate; 466 OMX_ERRORTYPE eError = OMX_ErrorNone; 467 OMX_U32 nIpBuf=0, nOpBuf=0; 468 int nRet=0; 469 470 OMX_PRINT1(pComponentPrivate->dbg, ":: Mp3Dec_FreeCompResources\n"); 471 472 OMX_PRBUFFER2(pComponentPrivate->dbg, ":::pComponentPrivate->bPortDefsAllocated = %ld\n",pComponentPrivate->bPortDefsAllocated); 473 if (pComponentPrivate->bPortDefsAllocated) { 474 nIpBuf = pComponentPrivate->pInputBufferList->numBuffers; 475 nOpBuf = pComponentPrivate->pOutputBufferList->numBuffers; 476 } 477 OMX_PRCOMM2(pComponentPrivate->dbg, ":: Closing pipess.....\n"); 478 479 nRet = close (pComponentPrivate->dataPipe[0]); 480 if (0 != nRet && OMX_ErrorNone == eError) { 481 eError = OMX_ErrorHardware; 482 } 483 484 nRet = close (pComponentPrivate->dataPipe[1]); 485 if (0 != nRet && OMX_ErrorNone == eError) { 486 eError = OMX_ErrorHardware; 487 } 488 489 nRet = close (pComponentPrivate->cmdPipe[0]); 490 if (0 != nRet && OMX_ErrorNone == eError) { 491 eError = OMX_ErrorHardware; 492 } 493 494 nRet = close (pComponentPrivate->cmdPipe[1]); 495 if (0 != nRet && OMX_ErrorNone == eError) { 496 eError = OMX_ErrorHardware; 497 } 498 499 nRet = close (pComponentPrivate->cmdDataPipe[0]); 500 if (0 != nRet && OMX_ErrorNone == eError) { 501 eError = OMX_ErrorHardware; 502 } 503 504 nRet = close (pComponentPrivate->cmdDataPipe[1]); 505 506 507 if (0 != nRet && OMX_ErrorNone == eError) { 508 eError = OMX_ErrorHardware; 509 } 510 511 if (pComponentPrivate->bPortDefsAllocated) { 512 513 OMX_MEMFREE_STRUCT(pComponentPrivate->pPortDef[MP3D_INPUT_PORT]); 514 OMX_MEMFREE_STRUCT(pComponentPrivate->pPortDef[MP3D_OUTPUT_PORT]); 515 OMX_MEMFREE_STRUCT(pComponentPrivate->mp3Params); 516 OMX_MEMFREE_STRUCT (pComponentPrivate->pcmParams); 517 OMX_MEMFREE_STRUCT(pComponentPrivate->pCompPort[MP3D_INPUT_PORT]->pPortFormat); 518 OMX_MEMFREE_STRUCT (pComponentPrivate->pCompPort[MP3D_OUTPUT_PORT]->pPortFormat); 519 OMX_MEMFREE_STRUCT (pComponentPrivate->pCompPort[MP3D_INPUT_PORT]); 520 OMX_MEMFREE_STRUCT (pComponentPrivate->pCompPort[MP3D_OUTPUT_PORT]); 521 OMX_MEMFREE_STRUCT (pComponentPrivate->sPortParam); 522 OMX_MEMFREE_STRUCT (pComponentPrivate->pPriorityMgmt); 523 OMX_MEMFREE_STRUCT(pComponentPrivate->pInputBufferList); 524 OMX_MEMFREE_STRUCT(pComponentPrivate->pOutputBufferList); 525 } 526 527 pComponentPrivate->bPortDefsAllocated = 0; 528 529#ifndef UNDER_CE 530 OMX_PRDSP2(pComponentPrivate->dbg, "\n\n FreeCompResources: Destroying mutexes.\n\n"); 531 pthread_mutex_destroy(&pComponentPrivate->InLoaded_mutex); 532 pthread_cond_destroy(&pComponentPrivate->InLoaded_threshold); 533 534 pthread_mutex_destroy(&pComponentPrivate->InIdle_mutex); 535 pthread_cond_destroy(&pComponentPrivate->InIdle_threshold); 536 537 pthread_mutex_destroy(&pComponentPrivate->AlloBuf_mutex); 538 pthread_cond_destroy(&pComponentPrivate->AlloBuf_threshold); 539 540 pthread_mutex_destroy(&pComponentPrivate->codecStop_mutex); 541 pthread_cond_destroy(&pComponentPrivate->codecStop_threshold); 542 543 pthread_mutex_destroy(&pComponentPrivate->codecFlush_mutex); 544 pthread_cond_destroy(&pComponentPrivate->codecFlush_threshold); 545#else 546 OMX_DestroyEvent(&(pComponentPrivate->InLoaded_event)); 547 OMX_DestroyEvent(&(pComponentPrivate->InIdle_event)); 548 OMX_DestroyEvent(&(pComponentPrivate->AlloBuf_event)); 549#endif 550 551 return eError; 552} 553 554 555/* ================================================================================= * */ 556/** 557 * @fn MP3DEC_HandleCommand() function handles the command sent by the application. 558 * All the state transitions, except from nothing to loaded state, of the 559 * component are done by this function. 560 * 561 * @param pComponentPrivate This is component's private date structure. 562 * 563 * @pre None 564 * 565 * @post None 566 * 567 * @return OMX_ErrorNone = Successful processing. 568 * OMX_ErrorInsufficientResources = Not enough memory 569 * OMX_ErrorHardware = Hardware error has occured lile LCML failed 570 * to do any said operartion. 571 * 572 * @see None 573 */ 574/* ================================================================================ * */ 575 576OMX_U32 MP3DEC_HandleCommand (MP3DEC_COMPONENT_PRIVATE *pComponentPrivate) 577{ 578 OMX_U32 i,ret = 0; 579 OMX_U16 arr[24]; 580 OMX_ERRORTYPE eError = OMX_ErrorNone; 581 char *pArgs = "damedesuStr"; 582 OMX_U32 pValues[4]; 583 OMX_U32 pValues1[4]; 584 OMX_COMPONENTTYPE *pHandle =(OMX_COMPONENTTYPE *) pComponentPrivate->pHandle; 585 OMX_COMMANDTYPE command; 586 OMX_STATETYPE commandedState; 587 OMX_U32 commandData; 588 OMX_HANDLETYPE pLcmlHandle = pComponentPrivate->pLcmlHandle; 589 590#ifdef RESOURCE_MANAGER_ENABLED 591 OMX_ERRORTYPE rm_error = OMX_ErrorNone; 592#endif 593 594 OMX_PRINT1(pComponentPrivate->dbg, ":: >>> Entering HandleCommand Function\n"); 595 596 ret = read(pComponentPrivate->cmdPipe[0], &command, sizeof (command)); 597 if(ret == -1){ 598 MP3D_OMX_ERROR_EXIT(eError, 599 OMX_ErrorHardware, 600 "Error while reading the command pipe"); 601 pComponentPrivate->cbInfo.EventHandler (pHandle, 602 pHandle->pApplicationPrivate, 603 OMX_EventError, 604 eError, 605 OMX_TI_ErrorSevere, 606 NULL); 607 } 608 ret = read(pComponentPrivate->cmdDataPipe[0], &commandData, sizeof (commandData)); 609 if(ret == -1){ 610 MP3D_OMX_ERROR_EXIT(eError, OMX_ErrorHardware, 611 "Error while reading the commandData pipe"); 612 pComponentPrivate->cbInfo.EventHandler (pHandle, 613 pHandle->pApplicationPrivate, 614 OMX_EventError, 615 eError, 616 OMX_TI_ErrorSevere, 617 NULL); 618 } 619 OMX_PRDSP2(pComponentPrivate->dbg, "---------------------------------------------\n"); 620 OMX_PRDSP2(pComponentPrivate->dbg, ":: command = %d\n",command); 621 OMX_PRDSP2(pComponentPrivate->dbg, ":: commandData = %ld\n",commandData); 622 OMX_PRDSP2(pComponentPrivate->dbg, "---------------------------------------------\n"); 623#ifdef __PERF_INSTRUMENTATION__ 624 PERF_ReceivedCommand(pComponentPrivate->pPERFcomp, 625 command, 626 commandData, 627 PERF_ModuleLLMM); 628#endif 629 if (command == OMX_CommandStateSet){ 630 commandedState = (OMX_STATETYPE)commandData; 631 if (pComponentPrivate->curState == commandedState) { 632 pComponentPrivate->cbInfo.EventHandler (pHandle, 633 pHandle->pApplicationPrivate, 634 OMX_EventError, 635 OMX_ErrorSameState, 636 OMX_TI_ErrorMinor, 637 NULL); 638 639 OMX_ERROR4(pComponentPrivate->dbg, ":: Error: Same State Given by Application\n"); 640 } else { 641 642 switch(commandedState) { 643 644 case OMX_StateIdle: 645 OMX_PRINT1(pComponentPrivate->dbg, ": HandleCommand: Cmd Idle \n"); 646 if (pComponentPrivate->curState == OMX_StateLoaded || pComponentPrivate->curState == OMX_StateWaitForResources) { 647 LCML_CALLBACKTYPE cb; 648 LCML_DSP *pLcmlDsp; 649 char *p = "damedesuStr"; 650#ifdef __PERF_INSTRUMENTATION__ 651 PERF_Boundary(pComponentPrivate->pPERFcomp,PERF_BoundaryStart | PERF_BoundarySetup); 652#endif 653 int inputPortFlag=0,outputPortFlag=0; 654 655 if (pComponentPrivate->dasfmode == 1) { 656 pComponentPrivate->pPortDef[MP3D_OUTPUT_PORT]->bEnabled= FALSE; 657 pComponentPrivate->pPortDef[MP3D_OUTPUT_PORT]->bPopulated= FALSE; 658 if(pComponentPrivate->streamID == 0) { 659 OMX_ERROR4(pComponentPrivate->dbg, "**************************************\n"); 660 OMX_ERROR4(pComponentPrivate->dbg, ":: Error = OMX_ErrorInsufficientResources\n"); 661 OMX_ERROR4(pComponentPrivate->dbg, "**************************************\n"); 662 pComponentPrivate->curState = OMX_StateInvalid; 663 eError = OMX_ErrorInsufficientResources; 664 pComponentPrivate->cbInfo.EventHandler(pHandle, 665 pHandle->pApplicationPrivate, 666 OMX_EventError, 667 eError, 668 OMX_TI_ErrorMajor, 669 "AM: No Stream ID Available"); 670 goto EXIT; 671 } 672 } 673 674 675 OMX_PRINT2(pComponentPrivate->dbg, "In while loop: IP : %p OP: %p\n",pComponentPrivate->pPortDef[MP3D_INPUT_PORT], 676 pComponentPrivate->pPortDef[MP3D_OUTPUT_PORT]); 677 OMX_PRCOMM2(pComponentPrivate->dbg, "pComponentPrivate->pPortDef[MP3D_INPUT_PORT]->bPopulated = %d\n", 678 pComponentPrivate->pPortDef[MP3D_INPUT_PORT]->bPopulated); 679 OMX_PRCOMM2(pComponentPrivate->dbg, "pComponentPrivate->pPortDef[MP3D_OUTPUT_PORT]->bPopulated = %d\n", 680 pComponentPrivate->pPortDef[MP3D_OUTPUT_PORT]->bPopulated); 681 OMX_PRCOMM2(pComponentPrivate->dbg, "pComponentPrivate->pPortDef[MP3D_INPUT_PORT]->bEnabled = %d\n", 682 pComponentPrivate->pPortDef[MP3D_INPUT_PORT]->bEnabled); 683 OMX_PRCOMM2(pComponentPrivate->dbg, "pComponentPrivate->pPortDef[MP3D_OUTPUT_PORT]->bEnabled = %d\n", 684 pComponentPrivate->pPortDef[MP3D_OUTPUT_PORT]->bEnabled); 685 686 687 if (pComponentPrivate->pPortDef[MP3D_INPUT_PORT]->bPopulated && 688 pComponentPrivate->pPortDef[MP3D_INPUT_PORT]->bEnabled) { 689 inputPortFlag = 1; 690 } 691 692 if (!pComponentPrivate->pPortDef[MP3D_INPUT_PORT]->bPopulated && 693 !pComponentPrivate->pPortDef[MP3D_INPUT_PORT]->bEnabled) { 694 inputPortFlag = 1; 695 } 696 697 if (pComponentPrivate->pPortDef[MP3D_OUTPUT_PORT]->bPopulated && 698 pComponentPrivate->pPortDef[MP3D_OUTPUT_PORT]->bEnabled) { 699 outputPortFlag = 1; 700 } 701 702 if (!pComponentPrivate->pPortDef[MP3D_OUTPUT_PORT]->bPopulated && 703 !pComponentPrivate->pPortDef[MP3D_OUTPUT_PORT]->bEnabled) { 704 outputPortFlag = 1; 705 } 706 707 if(!(inputPortFlag && outputPortFlag)) { 708 pComponentPrivate->InLoaded_readytoidle = 1; 709#ifndef UNDER_CE 710 pthread_mutex_lock(&pComponentPrivate->InLoaded_mutex); 711 pthread_cond_wait(&pComponentPrivate->InLoaded_threshold, &pComponentPrivate->InLoaded_mutex); 712 pthread_mutex_unlock(&pComponentPrivate->InLoaded_mutex); 713#else 714 OMX_WaitForEvent(&(pComponentPrivate->InLoaded_event)); 715#endif 716 } 717 718 pLcmlHandle = (OMX_HANDLETYPE) MP3DEC_GetLCMLHandle(pComponentPrivate); 719 if (pLcmlHandle == NULL) { 720 OMX_ERROR4(pComponentPrivate->dbg, ":: LCML Handle is NULL........exiting..\n"); 721 pComponentPrivate->curState = OMX_StateInvalid; 722 eError = OMX_ErrorHardware; 723 pComponentPrivate->cbInfo.EventHandler(pHandle, 724 pHandle->pApplicationPrivate, 725 OMX_EventError, 726 OMX_ErrorHardware, 727 OMX_TI_ErrorSevere, 728 "Lcml Handle NULL"); 729 goto EXIT; 730 } 731 732 pLcmlDsp = (((LCML_DSP_INTERFACE*)pLcmlHandle)->dspCodec); 733 eError = MP3DEC_Fill_LCMLInitParams(pHandle, pLcmlDsp,arr); 734 if(eError != OMX_ErrorNone) { 735 OMX_ERROR4(pComponentPrivate->dbg, ":: Error returned from Fill_LCMLInitParams()\n"); 736 pComponentPrivate->curState = OMX_StateInvalid; 737 pComponentPrivate->cbInfo.EventHandler(pHandle, 738 pHandle->pApplicationPrivate, 739 OMX_EventError, 740 eError, 741 OMX_TI_ErrorSevere, 742 NULL); 743 goto EXIT; 744 } 745 pComponentPrivate->pLcmlHandle = (LCML_DSP_INTERFACE *)pLcmlHandle; 746 cb.LCML_Callback = (void *) MP3DEC_LCML_Callback; 747 748#ifndef UNDER_CE 749 eError = LCML_InitMMCodecEx(((LCML_DSP_INTERFACE *)pLcmlHandle)->pCodecinterfacehandle, 750 p,&pLcmlHandle,(void *)p,&cb, (OMX_STRING)pComponentPrivate->sDeviceString); 751 if (eError != OMX_ErrorNone){ 752 OMX_ERROR4(pComponentPrivate->dbg, "%d :: Error : InitMMCodec failed...>>>>>> \n",__LINE__); 753 /* send an event to client */ 754 /* client should unload the component if the codec is not able to load */ 755 pComponentPrivate->cbInfo.EventHandler (pHandle, 756 pHandle->pApplicationPrivate, 757 OMX_EventError, 758 eError, 759 OMX_TI_ErrorSevere, 760 NULL); 761 goto EXIT; 762 } 763#else 764 eError = LCML_InitMMCodec(((LCML_DSP_INTERFACE *)pLcmlHandle)->pCodecinterfacehandle, 765 p,&pLcmlHandle,(void *)p,&cb); 766 if (eError != OMX_ErrorNone){ 767 OMX_ERROR4(pComponentPrivate->dbg, "%d :: Error : InitMMCodec failed...>>>>>> \n",__LINE__); 768 goto EXIT; 769 } 770 771#endif 772#ifdef HASHINGENABLE 773 /* Enable the Hashing Code */ 774 eError = LCML_SetHashingState(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle, OMX_TRUE); 775 if (eError != OMX_ErrorNone) { 776 OMX_ERROR4(pComponentPrivate->dbg, "Failed to set Mapping State\n"); 777 goto EXIT; 778 } 779#endif 780 781#ifdef RESOURCE_MANAGER_ENABLED 782 /* Need check the resource with RM */ 783 pComponentPrivate->rmproxyCallback.RMPROXY_Callback = 784 (void *) MP3_ResourceManagerCallback; 785 if (pComponentPrivate->curState != OMX_StateWaitForResources){ 786 rm_error = RMProxy_NewSendCommand(pHandle, 787 RMProxy_RequestResource, 788 OMX_MP3_Decoder_COMPONENT, 789 MP3_CPU, 790 3456, 791 &(pComponentPrivate->rmproxyCallback)); 792 if(rm_error == OMX_ErrorNone) { 793 /* resource is available */ 794#ifdef __PERF_INSTRUMENTATION__ 795 PERF_Boundary(pComponentPrivate->pPERFcomp,PERF_BoundaryComplete | PERF_BoundarySetup); 796#endif 797 pComponentPrivate->curState = OMX_StateIdle; 798 rm_error = RMProxy_NewSendCommand(pHandle, 799 RMProxy_StateSet, 800 OMX_MP3_Decoder_COMPONENT, 801 OMX_StateIdle, 802 3456, 803 NULL); 804 pComponentPrivate->cbInfo.EventHandler(pHandle, 805 pHandle->pApplicationPrivate, 806 OMX_EventCmdComplete, 807 OMX_CommandStateSet, 808 pComponentPrivate->curState, 809 NULL); 810 } 811 else if(rm_error == OMX_ErrorInsufficientResources) { 812 /* resource is not available, need set state to 813 OMX_StateWaitForResources */ 814 pComponentPrivate->curState = OMX_StateWaitForResources; 815 pComponentPrivate->cbInfo.EventHandler(pHandle, 816 pHandle->pApplicationPrivate, 817 OMX_EventCmdComplete, 818 OMX_CommandStateSet, 819 pComponentPrivate->curState, 820 NULL); 821 } 822 }else{ 823 rm_error = RMProxy_NewSendCommand(pHandle, 824 RMProxy_StateSet, 825 OMX_MP3_Decoder_COMPONENT, 826 OMX_StateIdle, 827 3456, 828 NULL); 829 830 pComponentPrivate->curState = OMX_StateIdle; 831 pComponentPrivate->cbInfo.EventHandler(pHandle, 832 pHandle->pApplicationPrivate, 833 OMX_EventCmdComplete, 834 OMX_CommandStateSet, 835 pComponentPrivate->curState, 836 NULL); 837 } 838 839#else 840#ifdef __PERF_INSTRUMENTATION__ 841 PERF_Boundary(pComponentPrivate->pPERFcomp,PERF_BoundaryComplete | PERF_BoundarySetup); 842#endif 843 pComponentPrivate->curState = OMX_StateIdle; 844 pComponentPrivate->cbInfo.EventHandler(pHandle, 845 pHandle->pApplicationPrivate, 846 OMX_EventCmdComplete, 847 OMX_CommandStateSet, 848 pComponentPrivate->curState, 849 NULL); 850#endif 851 852 OMX_PRDSP2(pComponentPrivate->dbg, ":: Control Came Here\n"); 853 OMX_PRSTATE2(pComponentPrivate->dbg, "****************** Component State Set to Idle\n\n"); 854 OMX_PRSTATE2(pComponentPrivate->dbg, "MP3DEC: State has been Set to Idle\n"); 855 } else if (pComponentPrivate->curState == OMX_StateExecuting){ 856#ifdef __PERF_INSTRUMENTATION__ 857 PERF_Boundary(pComponentPrivate->pPERFcomp,PERF_BoundaryComplete | PERF_BoundarySteadyState); 858#endif 859 pComponentPrivate->bDspStoppedWhileExecuting = OMX_TRUE; 860 OMX_PRDSP2(pComponentPrivate->dbg, ": MP3DECUTILS::About to call LCML_ControlCodec STOP %d\n", __LINE__); 861 if (pComponentPrivate->codecStop_waitingsignal == 0){ 862 pthread_mutex_lock(&pComponentPrivate->codecStop_mutex); 863 } 864 eError = LCML_ControlCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle, 865 MMCodecControlStop,(void *)pArgs); 866 if (pComponentPrivate->codecStop_waitingsignal == 0){ 867 pthread_cond_wait(&pComponentPrivate->codecStop_threshold, &pComponentPrivate->codecStop_mutex); 868 pComponentPrivate->codecStop_waitingsignal = 0; 869 pthread_mutex_unlock(&pComponentPrivate->codecStop_mutex); 870 } 871 872 873 if(eError != OMX_ErrorNone) { 874 OMX_ERROR4(pComponentPrivate->dbg, ": Error Occurred in Codec Stop..\n"); 875 pComponentPrivate->curState = OMX_StateInvalid; 876 pComponentPrivate->cbInfo.EventHandler(pHandle, 877 pHandle->pApplicationPrivate, 878 OMX_EventError, 879 eError, 880 OMX_TI_ErrorSevere, 881 NULL); 882 goto EXIT; 883 } 884#ifdef HASHINGENABLE 885 /*Hashing Change*/ 886 pLcmlHandle = (LCML_DSP_INTERFACE*)pComponentPrivate->pLcmlHandle; 887 eError = LCML_FlushHashes(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle); 888 if (eError != OMX_ErrorNone) { 889 OMX_ERROR4(pComponentPrivate->dbg, "Error occurred in Codec mapping flush!\n"); 890 break; 891 } 892#endif 893 } else if(pComponentPrivate->curState == OMX_StatePause) { 894 char *pArgs = "damedesuStr"; 895 OMX_PRCOMM2(pComponentPrivate->dbg, ":: Comp: Stop Command Received\n"); 896#ifdef HASHINGENABLE 897 /*Hashing Change*/ 898 pLcmlHandle = (LCML_DSP_INTERFACE*)pComponentPrivate->pLcmlHandle; 899 eError = LCML_FlushHashes(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle); 900 if (eError != OMX_ErrorNone) { 901 OMX_ERROR4(pComponentPrivate->dbg, "Error occurred in Codec mapping flush!\n"); 902 break; 903 } 904#endif 905#ifdef __PERF_INSTRUMENTATION__ 906 PERF_Boundary(pComponentPrivate->pPERFcomp,PERF_BoundaryComplete | PERF_BoundarySteadyState); 907#endif 908 OMX_PRDSP2(pComponentPrivate->dbg, ": MP3DECUTILS::About to call LCML_ControlCodec %d\n", __LINE__); 909 if (pComponentPrivate->codecStop_waitingsignal == 0){ 910 pthread_mutex_lock(&pComponentPrivate->codecStop_mutex); 911 } 912 eError = LCML_ControlCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle, 913 MMCodecControlStop,(void *)pArgs); 914 // lock mutex here, wait for stop ack. from lcml 915 if (pComponentPrivate->codecStop_waitingsignal == 0){ 916 pthread_cond_wait(&pComponentPrivate->codecStop_threshold, &pComponentPrivate->codecStop_mutex); 917 pComponentPrivate->codecStop_waitingsignal = 0; // reset the wait condition for next time 918 pthread_mutex_unlock(&pComponentPrivate->codecStop_mutex); 919 } 920 if(eError != OMX_ErrorNone) { 921 OMX_ERROR4(pComponentPrivate->dbg, ": Error Occurred in Codec Stop..\n"); 922 pComponentPrivate->curState = OMX_StateInvalid; 923 pComponentPrivate->cbInfo.EventHandler(pHandle, 924 pHandle->pApplicationPrivate, 925 OMX_EventError, 926 eError, 927 OMX_TI_ErrorSevere, 928 NULL); 929 goto EXIT; 930 } 931 OMX_PRSTATE2(pComponentPrivate->dbg, "****************** Component State Set to Idle\n\n"); 932 pComponentPrivate->curState = OMX_StateIdle; 933#ifdef RESOURCE_MANAGER_ENABLED 934 rm_error = RMProxy_NewSendCommand(pHandle, 935 RMProxy_StateSet, 936 OMX_MP3_Decoder_COMPONENT, 937 OMX_StateIdle, 938 3456, 939 NULL); 940#endif 941 OMX_PRDSP2(pComponentPrivate->dbg, ":: The component is stopped\n"); 942 pComponentPrivate->cbInfo.EventHandler(pHandle, 943 pHandle->pApplicationPrivate, 944 OMX_EventCmdComplete, 945 OMX_CommandStateSet, 946 pComponentPrivate->curState, 947 NULL); 948 949 } else { 950 OMX_ERROR2(pComponentPrivate->dbg, ": Comp: Sending ErrorNotification: Invalid State\n"); 951 pComponentPrivate->cbInfo.EventHandler(pHandle, 952 pHandle->pApplicationPrivate, 953 OMX_EventError, 954 OMX_ErrorIncorrectStateTransition, 955 OMX_TI_ErrorMinor, 956 "Invalid State Error"); 957 } 958 break; 959 960 case OMX_StateExecuting: 961 OMX_PRDSP2(pComponentPrivate->dbg, ": HandleCommand: Cmd Executing \n"); 962 if (pComponentPrivate->curState == OMX_StateIdle) { 963 char *pArgs = "damedesuStr"; 964 OMX_U32 pValues[4]; 965 OMX_U32 pValues1[4]; 966 967 if(!pComponentPrivate->SendAfterEOS){ 968 if(pComponentPrivate->dasfmode == 1) { 969 pComponentPrivate->pParams->unAudioFormat = (unsigned short)pComponentPrivate->mp3Params->nChannels; 970 if (pComponentPrivate->pParams->unAudioFormat == MP3D_STEREO_STREAM) { 971 pComponentPrivate->pParams->unAudioFormat = MP3D_STEREO_NONINTERLEAVED_STREAM; 972 } 973 974 pComponentPrivate->pParams->ulSamplingFreq = pComponentPrivate->mp3Params->nSampleRate; 975 pComponentPrivate->pParams->unUUID = pComponentPrivate->streamID; 976 977 OMX_PRCOMM2(pComponentPrivate->dbg, "::pParams->unAudioFormat = %ld\n",pComponentPrivate->mp3Params->nChannels); 978 OMX_PRCOMM2(pComponentPrivate->dbg, "::pParams->ulSamplingFreq = %ld\n",pComponentPrivate->mp3Params->nSampleRate); 979 980 pValues[0] = USN_STRMCMD_SETCODECPARAMS; 981 pValues[1] = (OMX_U32)pComponentPrivate->pParams; 982 pValues[2] = sizeof(USN_AudioCodecParams); 983 OMX_PRDSP2(pComponentPrivate->dbg, ": MP3DECUTILS::About to call LCML_ControlCodec %d\n", __LINE__); 984 eError = LCML_ControlCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle, 985 EMMCodecControlStrmCtrl,(void *)pValues); 986 if(eError != OMX_ErrorNone) { 987 OMX_ERROR4(pComponentPrivate->dbg, ": Error Occurred in Codec StreamControl..\n"); 988 pComponentPrivate->curState = OMX_StateInvalid; 989 pComponentPrivate->cbInfo.EventHandler(pHandle, 990 pHandle->pApplicationPrivate, 991 OMX_EventError, 992 eError, 993 OMX_TI_ErrorSevere, 994 NULL); 995 goto EXIT; 996 } 997 } 998 if(pComponentPrivate->dasfmode == 0 && 999 pComponentPrivate->pcmParams->bInterleaved) { 1000 pComponentPrivate->ptAlgDynParams->lOutputFormat = IAUDIO_INTERLEAVED; 1001 } else { 1002 pComponentPrivate->ptAlgDynParams->lOutputFormat = IAUDIO_BLOCK; 1003 } 1004 1005 pComponentPrivate->ptAlgDynParams->lMonoToStereoCopy = 0; 1006 pComponentPrivate->ptAlgDynParams->lStereoToMonoCopy = 0; 1007 pComponentPrivate->ptAlgDynParams->size = sizeof(MP3DEC_UALGParams); 1008 1009 pValues1[0] = IUALG_CMD_SETSTATUS; 1010 pValues1[1] = (OMX_U32) pComponentPrivate->ptAlgDynParams; 1011 pValues1[2] = sizeof(MP3DEC_UALGParams); 1012 OMX_PRDSP2(pComponentPrivate->dbg, ": MP3DECUTILS::About to call LCML_ControlCodec %d\n", __LINE__); 1013 eError = LCML_ControlCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle, 1014 EMMCodecControlAlgCtrl,(void *)pValues1); 1015 if(eError != OMX_ErrorNone) { 1016 OMX_ERROR4(pComponentPrivate->dbg, "Error Occurred in Codec Set Status DynParams..\n"); 1017 pComponentPrivate->curState = OMX_StateInvalid; 1018 pComponentPrivate->cbInfo.EventHandler(pHandle, 1019 pHandle->pApplicationPrivate, 1020 OMX_EventError, 1021 eError, 1022 OMX_TI_ErrorSevere, 1023 NULL); 1024 goto EXIT; 1025 } 1026 pComponentPrivate->bDspStoppedWhileExecuting = OMX_FALSE; 1027 OMX_PRDSP2(pComponentPrivate->dbg, ":: Algcontrol has been sent to DSP\n"); 1028 OMX_PRDSP2(pComponentPrivate->dbg, ": MP3DECUTILS::About to call LCML_ControlCodec START %d\n", __LINE__); 1029 eError = LCML_ControlCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle, 1030 EMMCodecControlStart,(void *)pArgs); 1031 1032 if(eError != OMX_ErrorNone) { 1033 OMX_ERROR4(pComponentPrivate->dbg, "%d: Error Occurred in Codec Start..\n", __LINE__); 1034 goto EXIT; 1035 } 1036 OMX_PRDSP2(pComponentPrivate->dbg, ": Codec Has Been Started \n"); 1037 1038 pComponentPrivate->SendAfterEOS = 1; 1039 } 1040 } else if (pComponentPrivate->curState == OMX_StatePause) { 1041 char *pArgs = "damedesuStr"; 1042 OMX_PRDSP2(pComponentPrivate->dbg, ": Comp: Resume Command Came from App\n"); 1043 OMX_PRDSP2(pComponentPrivate->dbg, ": MP3DECUTILS::About to call LCML_ControlCodec\n"); 1044 OMX_PRDSP2(pComponentPrivate->dbg, ": MP3DECUTILS::About to call LCML_ControlCodec START %d\n", __LINE__); 1045 pComponentPrivate->bDspStoppedWhileExecuting = OMX_FALSE; 1046 eError = LCML_ControlCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle, 1047 EMMCodecControlStart,(void *)pArgs); 1048 1049 if (eError != OMX_ErrorNone) { 1050 OMX_ERROR4(pComponentPrivate->dbg, "Error While Resuming the codec\n"); 1051 pComponentPrivate->curState = OMX_StateInvalid; 1052 pComponentPrivate->cbInfo.EventHandler(pHandle, 1053 pHandle->pApplicationPrivate, 1054 OMX_EventError, 1055 eError, 1056 OMX_TI_ErrorSevere, 1057 NULL); 1058 goto EXIT; 1059 } 1060 1061 for (i=0; i < pComponentPrivate->nNumInputBufPending; i++) { 1062 if (pComponentPrivate->pInputBufHdrPending[i] != NULL) { 1063 MP3D_LCML_BUFHEADERTYPE *pLcmlHdr; 1064 MP3DEC_GetCorresponding_LCMLHeader(pComponentPrivate, 1065 pComponentPrivate->pInputBufHdrPending[i]->pBuffer, OMX_DirInput, &pLcmlHdr); 1066 MP3DEC_SetPending(pComponentPrivate,pComponentPrivate->pInputBufHdrPending[i],OMX_DirInput,__LINE__); 1067 eError = LCML_QueueBuffer(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle, 1068 EMMCodecInputBuffer, 1069 pComponentPrivate->pInputBufHdrPending[i]->pBuffer, 1070 pComponentPrivate->pInputBufHdrPending[i]->nAllocLen, 1071 pComponentPrivate->pInputBufHdrPending[i]->nFilledLen, 1072 (OMX_U8 *) pLcmlHdr->pIpParam, 1073 sizeof(MP3DEC_UAlgInBufParamStruct), 1074 NULL); 1075 } 1076 } 1077 pComponentPrivate->nNumInputBufPending = 0; 1078 1079 for (i=0; i < pComponentPrivate->nNumOutputBufPending; i++) { 1080 if (pComponentPrivate->pOutputBufHdrPending[i]) { 1081 MP3D_LCML_BUFHEADERTYPE *pLcmlHdr; 1082 MP3DEC_GetCorresponding_LCMLHeader(pComponentPrivate, 1083 pComponentPrivate->pOutputBufHdrPending[i]->pBuffer, 1084 OMX_DirOutput, 1085 &pLcmlHdr); 1086 MP3DEC_SetPending(pComponentPrivate, 1087 pComponentPrivate->pOutputBufHdrPending[i], 1088 OMX_DirOutput, 1089 __LINE__); 1090 eError = LCML_QueueBuffer(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle, 1091 EMMCodecOuputBuffer, 1092 pComponentPrivate->pOutputBufHdrPending[i]->pBuffer, 1093 pComponentPrivate->pOutputBufHdrPending[i]->nAllocLen, 1094 0, 1095 (OMX_U8 *) pLcmlHdr->pOpParam, 1096 sizeof(MP3DEC_UAlgOutBufParamStruct), 1097 NULL); 1098 } 1099 } 1100 pComponentPrivate->nNumOutputBufPending = 0; 1101 }else { 1102 pComponentPrivate->cbInfo.EventHandler (pHandle, 1103 pHandle->pApplicationPrivate, 1104 OMX_EventError, 1105 OMX_ErrorIncorrectStateTransition, 1106 OMX_TI_ErrorMinor, 1107 "Invalid State"); 1108 OMX_ERROR4(pComponentPrivate->dbg, ":: Error: Invalid State Given by Application\n"); 1109 goto EXIT; 1110 } 1111 1112 OMX_PRSTATE2(pComponentPrivate->dbg, "****************** Component State Set to Executing\n\n"); 1113#ifdef RESOURCE_MANAGER_ENABLED 1114 rm_error = RMProxy_NewSendCommand(pHandle, RMProxy_StateSet, OMX_MP3_Decoder_COMPONENT, OMX_StateExecuting, 3456, NULL); 1115#endif 1116 pComponentPrivate->curState = OMX_StateExecuting; 1117 1118#ifdef __PERF_INSTRUMENTATION__ 1119 PERF_Boundary(pComponentPrivate->pPERFcomp,PERF_BoundaryStart | PERF_BoundarySteadyState); 1120#endif 1121 pComponentPrivate->cbInfo.EventHandler(pHandle, 1122 pHandle->pApplicationPrivate, 1123 OMX_EventCmdComplete, 1124 OMX_CommandStateSet, 1125 pComponentPrivate->curState, 1126 NULL); 1127 1128 break; 1129 1130 case OMX_StateLoaded: 1131 OMX_PRDSP2(pComponentPrivate->dbg, ": HandleCommand: Cmd Loaded\n"); 1132 1133 if (pComponentPrivate->curState == OMX_StateWaitForResources ){ 1134 OMX_PRSTATE2(pComponentPrivate->dbg, "****************** Component State Set to Loaded\n\n"); 1135#ifdef __PERF_INSTRUMENTATION__ 1136 PERF_Boundary(pComponentPrivate->pPERFcomp,PERF_BoundaryStart | PERF_BoundaryCleanup); 1137#endif 1138 pComponentPrivate->curState = OMX_StateLoaded; 1139#ifdef __PERF_INSTRUMENTATION__ 1140 PERF_Boundary(pComponentPrivate->pPERFcomp,PERF_BoundaryComplete | PERF_BoundaryCleanup); 1141#endif 1142 pComponentPrivate->cbInfo.EventHandler (pHandle, 1143 pHandle->pApplicationPrivate, 1144 OMX_EventCmdComplete, 1145 OMX_CommandStateSet, 1146 pComponentPrivate->curState, 1147 NULL); 1148 OMX_PRCOMM2(pComponentPrivate->dbg, ":: Transitioning from WaitFor to Loaded\n"); 1149 break; 1150 } 1151 1152 if (pComponentPrivate->curState != OMX_StateIdle) { 1153 pComponentPrivate->cbInfo.EventHandler (pHandle, 1154 pHandle->pApplicationPrivate, 1155 OMX_EventError, 1156 OMX_ErrorIncorrectStateTransition, 1157 OMX_TI_ErrorMinor, 1158 "Invalid State"); 1159 OMX_ERROR4(pComponentPrivate->dbg, ":: Error: Invalid State Given by \ 1160 Application\n"); 1161 goto EXIT; 1162 } 1163#ifdef __PERF_INSTRUMENTATION__ 1164 PERF_Boundary(pComponentPrivate->pPERFcomp,PERF_BoundaryStart | PERF_BoundaryCleanup); 1165#endif 1166 1167 OMX_PRSTATE2(pComponentPrivate->dbg, "Current State = %d\n",pComponentPrivate->curState); 1168 OMX_PRSTATE2(pComponentPrivate->dbg, "pComponentPrivate->pInputBufferList->numBuffers = %ld\n",pComponentPrivate->pInputBufferList->numBuffers); 1169 OMX_PRSTATE2(pComponentPrivate->dbg, "pComponentPrivate->pOutputBufferList->numBuffers = %ld\n",pComponentPrivate->pOutputBufferList->numBuffers); 1170 1171 if (pComponentPrivate->pInputBufferList->numBuffers || pComponentPrivate->pOutputBufferList->numBuffers) { 1172 pComponentPrivate->InIdle_goingtoloaded = 1; 1173#ifndef UNDER_CE 1174 pthread_mutex_lock(&pComponentPrivate->InIdle_mutex); 1175 pthread_cond_wait(&pComponentPrivate->InIdle_threshold, &pComponentPrivate->InIdle_mutex); 1176 pthread_mutex_unlock(&pComponentPrivate->InIdle_mutex); 1177#else 1178 OMX_WaitForEvent(&(pComponentPrivate->InIdle_event)); 1179#endif 1180 /* Send StateChangeNotification to application */ 1181 pComponentPrivate->bLoadedCommandPending = OMX_FALSE; 1182 } 1183 OMX_PRDSP2(pComponentPrivate->dbg, ": MP3DECUTILS::About to call LCML_ControlCodec DESTROY %d\n", __LINE__); 1184 eError = LCML_ControlCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle, 1185 EMMCodecControlDestroy,(void *)pArgs); 1186#ifdef UNDER_CE 1187 FreeLibrary(g_hLcmlDllHandle); 1188 g_hLcmlDllHandle = NULL; 1189#endif 1190#ifdef __PERF_INSTRUMENTATION__ 1191 PERF_SendingCommand(pComponentPrivate->pPERF, -1, 0, PERF_ModuleComponent); 1192#endif 1193 eError = EXIT_COMPONENT_THRD; 1194 pComponentPrivate->bInitParamsInitialized = 0; 1195 break; 1196 1197 case OMX_StatePause: 1198 OMX_PRSTATE2(pComponentPrivate->dbg, ": HandleCommand: Cmd Pause: Cur State = %d\n", 1199 pComponentPrivate->curState); 1200 1201 if ((pComponentPrivate->curState != OMX_StateExecuting) && 1202 (pComponentPrivate->curState != OMX_StateIdle)) { 1203 pComponentPrivate->cbInfo.EventHandler (pHandle, 1204 pHandle->pApplicationPrivate, 1205 OMX_EventError, 1206 OMX_ErrorIncorrectStateTransition, 1207 OMX_TI_ErrorMinor, 1208 "Invalid State"); 1209 OMX_ERROR4(pComponentPrivate->dbg, ":: Error: Invalid State Given by \ 1210 Application\n"); 1211 goto EXIT; 1212 } 1213#ifdef __PERF_INSTRUMENTATION__ 1214 PERF_Boundary(pComponentPrivate->pPERFcomp,PERF_BoundaryComplete | PERF_BoundarySteadyState); 1215#endif 1216 OMX_PRDSP2(pComponentPrivate->dbg, ": MP3DECUTILS::About to call LCML_ControlCodec\n"); 1217 OMX_PRDSP2(pComponentPrivate->dbg, ": MP3DECUTILS::About to call LCML_ControlCodec PAUSE %d\n", __LINE__); 1218 eError = LCML_ControlCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle, 1219 EMMCodecControlPause,(void *)pArgs); 1220 if (eError != OMX_ErrorNone) { 1221 OMX_ERROR4(pComponentPrivate->dbg, ": Error: in Pausing the codec\n"); 1222 pComponentPrivate->curState = OMX_StateInvalid; 1223 pComponentPrivate->cbInfo.EventHandler(pHandle, 1224 pHandle->pApplicationPrivate, 1225 OMX_EventError, 1226 eError, 1227 OMX_TI_ErrorSevere, 1228 NULL); 1229 goto EXIT; 1230 } 1231 OMX_PRSTATE2(pComponentPrivate->dbg, "****************** Component State Set to Pause\n\n"); 1232#ifdef RESOURCE_MANAGER_ENABLED 1233 rm_error = RMProxy_NewSendCommand(pHandle, 1234 RMProxy_StateSet, 1235 OMX_MP3_Decoder_COMPONENT, 1236 OMX_StatePause, 1237 3456, 1238 NULL); 1239#endif 1240 1241 break; 1242 1243 case OMX_StateWaitForResources: 1244 OMX_PRDSP2(pComponentPrivate->dbg, ": HandleCommand: Cmd : OMX_StateWaitForResources\n"); 1245 if (pComponentPrivate->curState == OMX_StateLoaded) { 1246#ifdef RESOURCE_MANAGER_ENABLED 1247 rm_error = RMProxy_NewSendCommand(pHandle, 1248 RMProxy_StateSet, 1249 OMX_MP3_Decoder_COMPONENT, 1250 OMX_StateWaitForResources, 1251 3456, 1252 NULL); 1253#endif 1254 1255 pComponentPrivate->curState = OMX_StateWaitForResources; 1256 OMX_PRDSP2(pComponentPrivate->dbg, ": Transitioning from Loaded to OMX_StateWaitForResources\n"); 1257 pComponentPrivate->cbInfo.EventHandler(pHandle, 1258 pHandle->pApplicationPrivate, 1259 OMX_EventCmdComplete, 1260 OMX_CommandStateSet, 1261 pComponentPrivate->curState, 1262 NULL); 1263 } else { 1264 pComponentPrivate->cbInfo.EventHandler(pHandle, 1265 pHandle->pApplicationPrivate, 1266 OMX_EventError, 1267 OMX_ErrorIncorrectStateTransition, 1268 OMX_TI_ErrorMinor, 1269 NULL); 1270 } 1271 break; 1272 1273 case OMX_StateInvalid: 1274 OMX_PRDSP2(pComponentPrivate->dbg, ": HandleCommand: Cmd OMX_StateInvalid:\n"); 1275 if (pComponentPrivate->curState != OMX_StateWaitForResources && 1276 pComponentPrivate->curState != OMX_StateLoaded && 1277 pComponentPrivate->curState != OMX_StateInvalid ) { 1278 1279 eError = LCML_ControlCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle, 1280 EMMCodecControlDestroy, (void *)pArgs); 1281 } 1282 1283 pComponentPrivate->curState = OMX_StateInvalid; 1284 pComponentPrivate->cbInfo.EventHandler(pHandle, 1285 pHandle->pApplicationPrivate, 1286 OMX_EventError, 1287 OMX_ErrorInvalidState, 1288 OMX_TI_ErrorSevere, 1289 NULL); 1290 MP3DEC_CleanupInitParams(pHandle); 1291 1292 break; 1293 1294 case OMX_StateMax: 1295 OMX_PRSTATE2(pComponentPrivate->dbg, ": HandleCommand: Cmd OMX_StateMax::\n"); 1296 break; 1297 } /* End of Switch */ 1298 } 1299 } 1300 else if (command == OMX_CommandMarkBuffer) { 1301 OMX_PRDSP2(pComponentPrivate->dbg, "command OMX_CommandMarkBuffer received\n"); 1302 if(!pComponentPrivate->pMarkBuf){ 1303 OMX_PRBUFFER2(pComponentPrivate->dbg, "command OMX_CommandMarkBuffer received \n"); 1304 pComponentPrivate->pMarkBuf = (OMX_MARKTYPE *)(commandData); 1305 } 1306 } else if (command == OMX_CommandPortDisable) { 1307 if (!pComponentPrivate->bDisableCommandPending) { 1308 if(commandData == 0x0){ 1309 /* disable port */ 1310 for (i=0; i < pComponentPrivate->pInputBufferList->numBuffers; i++) { 1311 OMX_PRBUFFER2(pComponentPrivate->dbg, "pComponentPrivate->pInputBufferList->bBufferPending[%ld] = %ld\n",i, 1312 pComponentPrivate->pInputBufferList->bBufferPending[i]); 1313 if (MP3DEC_IsPending(pComponentPrivate,pComponentPrivate->pInputBufferList->pBufHdr[i],OMX_DirInput)) { 1314 /* Real solution is flush buffers from DSP. Until we have the ability to do that 1315 we just call EmptyBufferDone() on any pending buffers */ 1316 OMX_PRBUFFER2(pComponentPrivate->dbg, "Forcing EmptyBufferDone\n"); 1317#ifdef __PERF_INSTRUMENTATION__ 1318 PERF_SendingFrame(pComponentPrivate->pPERFcomp, 1319 PREF(pComponentPrivate->pInputBufferList->pBufHdr[i], pBuffer), 1320 0, 1321 PERF_ModuleHLMM); 1322#endif 1323 pComponentPrivate->cbInfo.EmptyBufferDone (pComponentPrivate->pHandle, 1324 pComponentPrivate->pHandle->pApplicationPrivate, 1325 pComponentPrivate->pInputBufferList->pBufHdr[i]); 1326 pComponentPrivate->nEmptyBufferDoneCount++; 1327 SignalIfAllBuffersAreReturned(pComponentPrivate); 1328 } 1329 } 1330 1331 pComponentPrivate->pPortDef[MP3D_INPUT_PORT]->bEnabled = OMX_FALSE; 1332 } 1333 if(commandData == -1){ 1334 /* disable port */ 1335 pComponentPrivate->pPortDef[MP3D_INPUT_PORT]->bEnabled = OMX_FALSE; 1336 } 1337 if(commandData == 0x1 || commandData == -1){ 1338 char *pArgs = "damedesuStr"; 1339 pComponentPrivate->pPortDef[MP3D_OUTPUT_PORT]->bEnabled = OMX_FALSE; 1340 } 1341 } 1342 OMX_PRCOMM2(pComponentPrivate->dbg, "commandData = %ld\n",commandData); 1343 OMX_PRCOMM2(pComponentPrivate->dbg, "pComponentPrivate->pPortDef[MP3D_INPUT_PORT]->bPopulated = %d\n", 1344 pComponentPrivate->pPortDef[MP3D_INPUT_PORT]->bPopulated); 1345 OMX_PRCOMM2(pComponentPrivate->dbg, "pComponentPrivate->pPortDef[MP3D_OUTPUT_PORT]->bPopulated = %d\n", 1346 pComponentPrivate->pPortDef[MP3D_OUTPUT_PORT]->bPopulated); 1347 if(commandData == 0x0) { 1348 if(!pComponentPrivate->pPortDef[MP3D_INPUT_PORT]->bPopulated){ 1349 /* return cmdcomplete event if input unpopulated */ 1350 pComponentPrivate->cbInfo.EventHandler(pHandle, 1351 pHandle->pApplicationPrivate, 1352 OMX_EventCmdComplete, 1353 OMX_CommandPortDisable, 1354 MP3D_INPUT_PORT, 1355 NULL); 1356 pComponentPrivate->bDisableCommandPending = 0; 1357 } 1358 else{ 1359 pComponentPrivate->bDisableCommandPending = 1; 1360 pComponentPrivate->bDisableCommandParam = commandData; 1361 } 1362 } 1363 1364 if(commandData == 0x1) { 1365 if (!pComponentPrivate->pPortDef[MP3D_OUTPUT_PORT]->bPopulated){ 1366 /* return cmdcomplete event if output unpopulated */ 1367 OMX_PRCOMM2(pComponentPrivate->dbg, "CMD COMPLETE PORT DISABLE OUTPUT\n"); 1368 pComponentPrivate->cbInfo.EventHandler(pHandle, 1369 pHandle->pApplicationPrivate, 1370 OMX_EventCmdComplete, 1371 OMX_CommandPortDisable, 1372 MP3D_OUTPUT_PORT, 1373 NULL); 1374 pComponentPrivate->bDisableCommandPending = 0; 1375 } 1376 else { 1377 pComponentPrivate->bDisableCommandPending = 1; 1378 pComponentPrivate->bDisableCommandParam = commandData; 1379 } 1380 } 1381 1382 if(commandData == -1) { 1383 if (!pComponentPrivate->pPortDef[MP3D_INPUT_PORT]->bPopulated && 1384 !pComponentPrivate->pPortDef[MP3D_OUTPUT_PORT]->bPopulated){ 1385 1386 /* return cmdcomplete event if inout & output unpopulated */ 1387 pComponentPrivate->cbInfo.EventHandler(pHandle, 1388 pHandle->pApplicationPrivate, 1389 OMX_EventCmdComplete, 1390 OMX_CommandPortDisable, 1391 MP3D_INPUT_PORT, 1392 NULL); 1393 1394 pComponentPrivate->cbInfo.EventHandler(pHandle, 1395 pHandle->pApplicationPrivate, 1396 OMX_EventCmdComplete, 1397 OMX_CommandPortDisable, 1398 MP3D_OUTPUT_PORT, 1399 NULL); 1400 pComponentPrivate->bDisableCommandPending = 0; 1401 } 1402 else { 1403 pComponentPrivate->bDisableCommandPending = 1; 1404 pComponentPrivate->bDisableCommandParam = commandData; 1405 } 1406 } 1407 } 1408 else if (command == OMX_CommandPortEnable) { 1409 if (pComponentPrivate->bDspStoppedWhileExecuting){ 1410 // set up the codec with corrected settings 1411 // it was not done in idle->executing transition 1412 if(pComponentPrivate->dasfmode == 0 && 1413 pComponentPrivate->pcmParams->bInterleaved) { 1414 pComponentPrivate->ptAlgDynParams->lOutputFormat = IAUDIO_INTERLEAVED; 1415 } else { 1416 pComponentPrivate->ptAlgDynParams->lOutputFormat = IAUDIO_BLOCK; 1417 } 1418 pComponentPrivate->ptAlgDynParams->lMonoToStereoCopy = 0; 1419 pComponentPrivate->ptAlgDynParams->lStereoToMonoCopy = 0; 1420 pComponentPrivate->ptAlgDynParams->size = sizeof(MP3DEC_UALGParams); 1421 1422 pValues1[0] = IUALG_CMD_SETSTATUS; 1423 pValues1[1] = (OMX_U32) pComponentPrivate->ptAlgDynParams; 1424 pValues1[2] = sizeof(MP3DEC_UALGParams); 1425 OMX_PRDSP2(pComponentPrivate->dbg, ": MP3DECUTILS::About to call LCML_ControlCodec ALG %d\n", __LINE__); 1426 eError = LCML_ControlCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle, 1427 EMMCodecControlAlgCtrl,(void *)pValues1); 1428 if(eError != OMX_ErrorNone) { 1429 OMX_ERROR4(pComponentPrivate->dbg, "Error Occurred in Codec Start..\n"); 1430 pComponentPrivate->curState = OMX_StateInvalid; 1431 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 1432 pComponentPrivate->pHandle->pApplicationPrivate, 1433 OMX_EventError, 1434 eError, 1435 OMX_TI_ErrorSevere, 1436 NULL); 1437 goto EXIT; 1438 } 1439 1440 pComponentPrivate->bDspStoppedWhileExecuting = OMX_FALSE; 1441 OMX_PRDSP2(pComponentPrivate->dbg, ": MP3DECUTILS::About to call LCML_ControlCodec start %d\n", __LINE__); 1442 eError = LCML_ControlCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle, 1443 EMMCodecControlStart,(void *)pArgs); 1444 1445 if(eError != OMX_ErrorNone) { 1446 OMX_ERROR4(pComponentPrivate->dbg, "%d: Error Occurred in Codec Start..\n", __LINE__); 1447 goto EXIT; 1448 } 1449 OMX_PRDSP1(pComponentPrivate->dbg, ": Codec Has Been Started \n"); 1450 } 1451 else{ 1452 OMX_PRDSP1(pComponentPrivate->dbg, "codec was previusly started! %d\n", __LINE__); 1453 } 1454 if (!pComponentPrivate->bEnableCommandPending) { 1455 if(commandData == 0x0 || commandData == -1){ 1456 /* enable in port */ 1457 OMX_PRCOMM2(pComponentPrivate->dbg, "setting input port to enabled\n"); 1458 pComponentPrivate->pPortDef[MP3D_INPUT_PORT]->bEnabled = OMX_TRUE; 1459 OMX_PRSTATE2(pComponentPrivate->dbg, "WAKE UP!! HandleCommand: En utils setting output port to enabled. \n"); 1460 if(pComponentPrivate->AlloBuf_waitingsignal){ 1461 pComponentPrivate->AlloBuf_waitingsignal = 0; 1462 } 1463 OMX_PRCOMM2(pComponentPrivate->dbg, "pComponentPrivate->pPortDef[MP3D_INPUT_PORT]->bEnabled = %d\n", 1464 pComponentPrivate->pPortDef[MP3D_INPUT_PORT]->bEnabled); 1465 } 1466 if(commandData == 0x1 || commandData == -1){ 1467 1468 /* enable out port */ 1469 pComponentPrivate->pPortDef[MP3D_OUTPUT_PORT]->bEnabled = OMX_TRUE; 1470 OMX_PRCOMM2(pComponentPrivate->dbg, "pComponentPrivate->pPortDef[MP3D_OUTPUT_PORT]->bEnabled = %d\n", 1471 pComponentPrivate->pPortDef[MP3D_OUTPUT_PORT]->bEnabled); 1472 1473 if(pComponentPrivate->AlloBuf_waitingsignal){ 1474 pComponentPrivate->AlloBuf_waitingsignal = 0; 1475#ifndef UNDER_CE 1476 pthread_mutex_lock(&pComponentPrivate->AlloBuf_mutex); 1477 pthread_cond_signal(&pComponentPrivate->AlloBuf_threshold); 1478 pthread_mutex_unlock(&pComponentPrivate->AlloBuf_mutex); 1479#else 1480 OMX_SignalEvent(&(pComponentPrivate->AlloBuf_event)); 1481#endif 1482 } 1483 OMX_PRCOMM2(pComponentPrivate->dbg, "setting output port to enabled\n"); 1484 } 1485 } 1486 if(commandData == 0x0){ 1487 if (pComponentPrivate->curState == OMX_StateLoaded || 1488 pComponentPrivate->pPortDef[MP3D_INPUT_PORT]->bPopulated) { 1489 pComponentPrivate->cbInfo.EventHandler(pHandle, 1490 pHandle->pApplicationPrivate, 1491 OMX_EventCmdComplete, 1492 OMX_CommandPortEnable, 1493 MP3D_INPUT_PORT, 1494 NULL); 1495 1496 if(pComponentPrivate->AlloBuf_waitingsignal){ 1497 pComponentPrivate->AlloBuf_waitingsignal = 0; 1498 pthread_mutex_lock(&pComponentPrivate->AlloBuf_mutex); 1499 pthread_cond_signal(&pComponentPrivate->AlloBuf_threshold); 1500 pthread_mutex_unlock(&pComponentPrivate->AlloBuf_mutex); 1501 } 1502 1503 //MP3DECFill_LCMLInitParamsEx(pHandle, 0); 1504 // queue the pending buffers received while doing the config 1505 for (i=0; i < pComponentPrivate->nNumInputBufPending; i++) { 1506 OMX_PRCOMM2(pComponentPrivate->dbg, "in queuePending loop INPUT %d\n", __LINE__); 1507 if (pComponentPrivate->pInputBufHdrPending[i] != NULL) { 1508 MP3D_LCML_BUFHEADERTYPE *pLcmlHdr; 1509 MP3DEC_GetCorresponding_LCMLHeader(pComponentPrivate, 1510 pComponentPrivate->pInputBufHdrPending[i]->pBuffer, OMX_DirInput, &pLcmlHdr); 1511 MP3DEC_SetPending(pComponentPrivate,pComponentPrivate->pInputBufHdrPending[i],OMX_DirInput,__LINE__); 1512 OMX_PRBUFFER2(pComponentPrivate->dbg, "QueueBuffer pending port config line %d\n", __LINE__); 1513 eError = LCML_QueueBuffer(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle, 1514 EMMCodecInputBuffer, 1515 pComponentPrivate->pInputBufHdrPending[i]->pBuffer, 1516 pComponentPrivate->pInputBufHdrPending[i]->nAllocLen, 1517 pComponentPrivate->pInputBufHdrPending[i]->nFilledLen, 1518 (OMX_U8 *) pLcmlHdr->pIpParam, 1519 sizeof(MP3DEC_UAlgInBufParamStruct), 1520 NULL); 1521 OMX_PRBUFFER2(pComponentPrivate->dbg, "QueueBuffer pending port config line %d, error = %d\n", __LINE__, eError); 1522 } 1523 } 1524 pComponentPrivate->nNumInputBufPending = 0; 1525 pComponentPrivate->reconfigInputPort = 0; 1526 pComponentPrivate->bEnableCommandPending = 0; 1527 } 1528 else { 1529 pComponentPrivate->bEnableCommandPending = 1; 1530 pComponentPrivate->bEnableCommandParam = commandData; 1531 } 1532 } 1533 else if(commandData == 0x1) { 1534 if (pComponentPrivate->curState == OMX_StateLoaded || 1535 pComponentPrivate->pPortDef[MP3D_OUTPUT_PORT]->bPopulated){ 1536 pComponentPrivate->cbInfo.EventHandler( pHandle, 1537 pHandle->pApplicationPrivate, 1538 OMX_EventCmdComplete, 1539 OMX_CommandPortEnable, 1540 MP3D_OUTPUT_PORT, 1541 NULL); 1542 1543 if(pComponentPrivate->AlloBuf_waitingsignal){ 1544 pComponentPrivate->AlloBuf_waitingsignal = 0; 1545 pthread_mutex_lock(&pComponentPrivate->AlloBuf_mutex); 1546 pthread_cond_signal(&pComponentPrivate->AlloBuf_threshold); 1547 pthread_mutex_unlock(&pComponentPrivate->AlloBuf_mutex); 1548 } 1549 OMX_PRINT2(pComponentPrivate->dbg, "reconfigOut = %d!, but should be true!\n",pComponentPrivate->reconfigOutputPort); 1550 if(pComponentPrivate->reconfigOutputPort){ 1551 //make sure new VA's are used 1552 MP3DEC_CleanupInitParamsEx(pHandle,commandData); 1553 MP3DECFill_LCMLInitParamsEx(pHandle, 1); 1554 OMX_PRDSP2(pComponentPrivate->dbg, "completed MP3DEC_MapLCMLParamsEx! %d\n", __LINE__); 1555 1556 } 1557 1558 for (i=0; i < pComponentPrivate->nNumOutputBufPending; i++) { 1559 if (pComponentPrivate->pOutputBufHdrPending[i]) { 1560 MP3D_LCML_BUFHEADERTYPE *pLcmlHdr; 1561 MP3DEC_GetCorresponding_LCMLHeader(pComponentPrivate, 1562 pComponentPrivate->pOutputBufHdrPending[i]->pBuffer, 1563 OMX_DirOutput, 1564 &pLcmlHdr); 1565 MP3DEC_SetPending(pComponentPrivate, 1566 pComponentPrivate->pOutputBufHdrPending[i], 1567 OMX_DirOutput, 1568 __LINE__); 1569 OMX_PRCOMM2(pComponentPrivate->dbg, "QueueBuffer pending port config line %d\n", __LINE__); 1570 eError = LCML_QueueBuffer(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle, 1571 EMMCodecOuputBuffer, 1572 pComponentPrivate->pOutputBufHdrPending[i]->pBuffer, 1573 pComponentPrivate->pOutputBufHdrPending[i]->nAllocLen, 1574 0, 1575 (OMX_U8 *) pLcmlHdr->pOpParam, 1576 sizeof(MP3DEC_UAlgOutBufParamStruct), 1577 NULL); 1578 OMX_PRCOMM2(pComponentPrivate->dbg, "QueueBuffer pending port config line %d, error = %d\n", __LINE__, eError); 1579 } 1580 } 1581 pComponentPrivate->nNumOutputBufPending = 0; 1582 // queue the pending buffers received while doing the config 1583 for (i=0; i < pComponentPrivate->nNumInputBufPending; i++) { 1584 OMX_PRCOMM2(pComponentPrivate->dbg, "in queuePending loop INPUT %d\n", __LINE__); 1585 if (pComponentPrivate->pInputBufHdrPending[i] != NULL) { 1586 MP3D_LCML_BUFHEADERTYPE *pLcmlHdr; 1587 MP3DEC_GetCorresponding_LCMLHeader(pComponentPrivate, 1588 pComponentPrivate->pInputBufHdrPending[i]->pBuffer, OMX_DirInput, &pLcmlHdr); 1589 MP3DEC_SetPending(pComponentPrivate,pComponentPrivate->pInputBufHdrPending[i],OMX_DirInput,__LINE__); 1590 OMX_PRCOMM2(pComponentPrivate->dbg, "QueueBuffer pending port config line %d\n", __LINE__); 1591 eError = LCML_QueueBuffer(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle, 1592 EMMCodecInputBuffer, 1593 pComponentPrivate->pInputBufHdrPending[i]->pBuffer, 1594 pComponentPrivate->pInputBufHdrPending[i]->nAllocLen, 1595 pComponentPrivate->pInputBufHdrPending[i]->nFilledLen, 1596 (OMX_U8 *) pLcmlHdr->pIpParam, 1597 sizeof(MP3DEC_UAlgInBufParamStruct), 1598 NULL); 1599 OMX_PRCOMM2(pComponentPrivate->dbg, "QueueBuffer pending port config line %d, error = %d\n", __LINE__, eError); 1600 } 1601 } 1602 pComponentPrivate->nNumInputBufPending = 0; 1603 pComponentPrivate->bEnableCommandPending = 0; 1604 pComponentPrivate->reconfigOutputPort = 0; 1605 } 1606 else { 1607 pComponentPrivate->bEnableCommandPending = 1; 1608 pComponentPrivate->bEnableCommandParam = commandData; 1609 } 1610 } 1611 else if(commandData == -1) { 1612 if (pComponentPrivate->curState == OMX_StateLoaded || 1613 (pComponentPrivate->pPortDef[MP3D_INPUT_PORT]->bPopulated 1614 && pComponentPrivate->pPortDef[MP3D_OUTPUT_PORT]->bPopulated)){ 1615 pComponentPrivate->cbInfo.EventHandler(pHandle, 1616 pHandle->pApplicationPrivate, 1617 OMX_EventCmdComplete, 1618 OMX_CommandPortEnable, 1619 MP3D_INPUT_PORT, 1620 NULL); 1621 pComponentPrivate->cbInfo.EventHandler(pHandle, 1622 pHandle->pApplicationPrivate, 1623 OMX_EventCmdComplete, 1624 OMX_CommandPortEnable, 1625 MP3D_OUTPUT_PORT, 1626 NULL); 1627 1628 if(pComponentPrivate->AlloBuf_waitingsignal){ 1629 pComponentPrivate->AlloBuf_waitingsignal = 0; 1630 pthread_mutex_lock(&pComponentPrivate->AlloBuf_mutex); 1631 pthread_cond_signal(&pComponentPrivate->AlloBuf_threshold); 1632 pthread_mutex_unlock(&pComponentPrivate->AlloBuf_mutex); 1633 } 1634 MP3DEC_CleanupInitParamsEx(pHandle,commandData); 1635 MP3DECFill_LCMLInitParamsEx(pHandle, -1); 1636 1637 // queue the pending buffers received while doing the config, output then input 1638 for (i=0; i < pComponentPrivate->nNumOutputBufPending; i++) { 1639 if (pComponentPrivate->pOutputBufHdrPending[i]) { 1640 MP3D_LCML_BUFHEADERTYPE *pLcmlHdr; 1641 MP3DEC_GetCorresponding_LCMLHeader(pComponentPrivate, 1642 pComponentPrivate->pOutputBufHdrPending[i]->pBuffer, 1643 OMX_DirOutput, 1644 &pLcmlHdr); 1645 MP3DEC_SetPending(pComponentPrivate, 1646 pComponentPrivate->pOutputBufHdrPending[i], 1647 OMX_DirOutput, 1648 __LINE__); 1649 eError = LCML_QueueBuffer(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle, 1650 EMMCodecOuputBuffer, 1651 pComponentPrivate->pOutputBufHdrPending[i]->pBuffer, 1652 pComponentPrivate->pOutputBufHdrPending[i]->nAllocLen, 1653 0, 1654 (OMX_U8 *) pLcmlHdr->pOpParam, 1655 sizeof(MP3DEC_UAlgOutBufParamStruct), 1656 NULL); 1657 } 1658 } 1659 pComponentPrivate->nNumOutputBufPending = 0; 1660 for (i=0; i < pComponentPrivate->nNumInputBufPending; i++) { 1661 OMX_PRCOMM2(pComponentPrivate->dbg, "in queuePending loop INPUT %d\n", __LINE__); 1662 if (pComponentPrivate->pInputBufHdrPending[i] != NULL) { 1663 MP3D_LCML_BUFHEADERTYPE *pLcmlHdr; 1664 MP3DEC_GetCorresponding_LCMLHeader(pComponentPrivate, 1665 pComponentPrivate->pInputBufHdrPending[i]->pBuffer, OMX_DirInput, &pLcmlHdr); 1666 MP3DEC_SetPending(pComponentPrivate,pComponentPrivate->pInputBufHdrPending[i],OMX_DirInput,__LINE__); 1667 OMX_PRCOMM2(pComponentPrivate->dbg, "QueueBuffer pending port config line %d\n", __LINE__); 1668 eError = LCML_QueueBuffer(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle, 1669 EMMCodecInputBuffer, 1670 pComponentPrivate->pInputBufHdrPending[i]->pBuffer, 1671 pComponentPrivate->pInputBufHdrPending[i]->nAllocLen, 1672 pComponentPrivate->pInputBufHdrPending[i]->nFilledLen, 1673 (OMX_U8 *) pLcmlHdr->pIpParam, 1674 sizeof(MP3DEC_UAlgInBufParamStruct), 1675 NULL); 1676 OMX_PRCOMM2(pComponentPrivate->dbg, "QueueBuffer pending port config line %d, error = %d\n", __LINE__, eError); 1677 } 1678 } 1679 pComponentPrivate->nNumInputBufPending = 0; 1680 pComponentPrivate->bEnableCommandPending = 0; 1681 } 1682 else { 1683 pComponentPrivate->bEnableCommandPending = 1; 1684 pComponentPrivate->bEnableCommandParam = commandData; 1685 } 1686 } 1687 } 1688 else if (command == OMX_CommandFlush) { 1689 OMX_U32 aParam[3] = {0}; 1690 if(commandData == 0x0 || commandData == -1) { 1691 OMX_ERROR2(pComponentPrivate->dbg, "Flushing input port:: unhandled ETB's = %ld, handled ETB's = %ld\n", 1692 pComponentPrivate->nEmptyThisBufferCount, pComponentPrivate->nHandledEmptyThisBuffers); 1693 if (pComponentPrivate->nEmptyThisBufferCount == pComponentPrivate->nHandledEmptyThisBuffers) { 1694 pComponentPrivate->bFlushInputPortCommandPending = OMX_FALSE; 1695 pComponentPrivate->first_buff = 0; 1696 OMX_ERROR2(pComponentPrivate->dbg, "in flush IN:lcml_nCntApp && app_nBuf = %ld && %ld\n", pComponentPrivate->lcml_nCntApp, pComponentPrivate->app_nBuf); 1697 if (pComponentPrivate->num_Sent_Ip_Buff){ //no buffers have been sent yet, no need to flush SN 1698 aParam[0] = USN_STRMCMD_FLUSH; 1699 aParam[1] = 0x0; 1700 aParam[2] = 0x0; 1701 1702 OMX_ERROR4(pComponentPrivate->dbg, "Flushing input port\n"); 1703 OMX_ERROR2(pComponentPrivate->dbg, ": MP3DECUTILS::About to call LCML_ControlCodec FLUSH in %d\n", __LINE__); 1704 if (pComponentPrivate->codecFlush_waitingsignal == 0){ 1705 pthread_mutex_lock(&pComponentPrivate->codecFlush_mutex); 1706 } 1707 eError = LCML_ControlCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle, 1708 EMMCodecControlStrmCtrl, (void*)aParam); 1709 if (pComponentPrivate->codecFlush_waitingsignal == 0){ 1710 pthread_cond_wait(&pComponentPrivate->codecFlush_threshold, &pComponentPrivate->codecFlush_mutex); 1711 pComponentPrivate->codecFlush_waitingsignal = 0; 1712 pthread_mutex_unlock(&pComponentPrivate->codecFlush_mutex); 1713 } 1714 if (eError != OMX_ErrorNone) { 1715 goto EXIT; 1716 } 1717 } 1718 else{ 1719 OMX_PRCOMM2(pComponentPrivate->dbg, "Flushing input port %d\n",__LINE__); 1720 for (i=0; i < pComponentPrivate->nNumInputBufPending; i++) { 1721#ifdef __PERF_INSTRUMENTATION__ 1722 PERF_SendingFrame(pComponentPrivate->pPERFcomp, 1723 PREF(pComponentPrivate->pInputBufHdrPending[i],pBuffer), 1724 0, 1725 PERF_ModuleHLMM); 1726#endif 1727 1728 pComponentPrivate->cbInfo.EmptyBufferDone (pComponentPrivate->pHandle, 1729 pComponentPrivate->pHandle->pApplicationPrivate, 1730 pComponentPrivate->pInputBufHdrPending[i]); 1731 pComponentPrivate->pInputBufHdrPending[i] = NULL; 1732 pComponentPrivate->nEmptyBufferDoneCount++; 1733 SignalIfAllBuffersAreReturned(pComponentPrivate); 1734 } 1735 pComponentPrivate->nNumInputBufPending=0; 1736 pComponentPrivate->cbInfo.EventHandler(pHandle, 1737 pHandle->pApplicationPrivate, 1738 OMX_EventCmdComplete, 1739 OMX_CommandFlush, 1740 MP3D_INPUT_PORT, 1741 NULL); 1742 } 1743 }else { 1744 pComponentPrivate->bFlushInputPortCommandPending = OMX_TRUE; 1745 } 1746 } 1747 if(commandData == 0x1 || commandData == -1){ 1748 OMX_ERROR2(pComponentPrivate->dbg, "Flushing output port:: unhandled FTB's = %ld handled FTB's = %ld\n", 1749 pComponentPrivate->nFillThisBufferCount, pComponentPrivate->nHandledFillThisBuffers); 1750 if (pComponentPrivate->nFillThisBufferCount == pComponentPrivate->nHandledFillThisBuffers) { 1751 pComponentPrivate->bFlushOutputPortCommandPending = OMX_FALSE; 1752 /*pComponentPrivate->first_buff = 0;*/ 1753 OMX_PRBUFFER2(pComponentPrivate->dbg, "in flush OUT:lcml_nCntApp && app_nBuf = %ld && %ld\n", pComponentPrivate->lcml_nCntApp, pComponentPrivate->app_nBuf); 1754 OMX_PRBUFFER2(pComponentPrivate->dbg, "in flush OUT:lcml_nOpBuf = %ld \n", pComponentPrivate->lcml_nOpBuf); 1755 if (pComponentPrivate->num_Op_Issued && !pComponentPrivate->reconfigOutputPort){ //if no buffers have been sent yet, no need to flush SN 1756 aParam[0] = USN_STRMCMD_FLUSH; 1757 aParam[1] = 0x1; 1758 aParam[2] = 0x0; 1759 1760 OMX_ERROR4(pComponentPrivate->dbg, "Flushing output port\n"); 1761 OMX_PRDSP2(pComponentPrivate->dbg, ": MP3DECUTILS::About to call LCML_ControlCodec FLUSH out %d\n", __LINE__); 1762 if (pComponentPrivate->codecFlush_waitingsignal == 0){ 1763 pthread_mutex_lock(&pComponentPrivate->codecFlush_mutex); 1764 } 1765 eError = LCML_ControlCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle, 1766 EMMCodecControlStrmCtrl, (void*)aParam); 1767 if (pComponentPrivate->codecFlush_waitingsignal == 0){ 1768 pthread_cond_wait(&pComponentPrivate->codecFlush_threshold, &pComponentPrivate->codecFlush_mutex); 1769 pComponentPrivate->codecFlush_waitingsignal = 0; 1770 pthread_mutex_unlock(&pComponentPrivate->codecFlush_mutex); 1771 } 1772 if (eError != OMX_ErrorNone) { 1773 goto EXIT; 1774 } 1775 } 1776 else{ 1777 for (i=0; i < pComponentPrivate->nNumOutputBufPending; i++) { 1778#ifdef __PERF_INSTRUMENTATION__ 1779 PERF_SendingFrame(pComponentPrivate->pPERFcomp, 1780 PREF(pComponentPrivate->pOutputBufHdrPending[i],pBuffer), 1781 PREF(pComponentPrivate->pOutputBufHdrPending[i],nFilledLen), 1782 PERF_ModuleHLMM); 1783#endif 1784 1785 pComponentPrivate->cbInfo.FillBufferDone (pComponentPrivate->pHandle, 1786 pComponentPrivate->pHandle->pApplicationPrivate, 1787 pComponentPrivate->pOutputBufHdrPending[i] 1788 ); 1789 pComponentPrivate->nFillBufferDoneCount++; 1790 pComponentPrivate->pOutputBufHdrPending[i] = NULL; 1791 SignalIfAllBuffersAreReturned(pComponentPrivate); 1792 } 1793 pComponentPrivate->nNumOutputBufPending=0; 1794 1795 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 1796 pComponentPrivate->pHandle->pApplicationPrivate, 1797 OMX_EventCmdComplete, 1798 OMX_CommandFlush, 1799 MP3D_OUTPUT_PORT, 1800 NULL); 1801 } 1802 } else { 1803 pComponentPrivate->bFlushOutputPortCommandPending = OMX_TRUE; 1804 } 1805 } 1806 } 1807 EXIT: 1808 OMX_PRINT1(pComponentPrivate->dbg, ":: Exiting HandleCommand Function, error = %d\n", eError); 1809 if (eError != OMX_ErrorNone && eError != EXIT_COMPONENT_THRD) { 1810 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 1811 pComponentPrivate->pHandle->pApplicationPrivate, 1812 OMX_EventError, 1813 eError, 1814 OMX_TI_ErrorSevere, 1815 NULL); 1816 } 1817 return eError; 1818} 1819 1820 1821/* ================================================================================= * */ 1822/** 1823 * @fn MP3DEC_HandleDataBuf_FromApp() function handles the input and output buffers 1824 * that come from the application. It is not direct function wich gets called by 1825 * the application rather, it gets called eventually. 1826 * 1827 * @param *pBufHeader This is the buffer header that needs to be processed. 1828 * 1829 * @param *pComponentPrivate This is component's private date structure. 1830 * 1831 * @pre None 1832 * 1833 * @post None 1834 * 1835 * @return OMX_ErrorNone = Successful processing. 1836 * OMX_ErrorInsufficientResources = Not enough memory 1837 * OMX_ErrorHardware = Hardware error has occured lile LCML failed 1838 * to do any said operartion. 1839 * 1840 * @see None 1841 */ 1842/* ================================================================================ * */ 1843 1844OMX_ERRORTYPE MP3DEC_HandleDataBuf_FromApp(OMX_BUFFERHEADERTYPE* pBufHeader, 1845 MP3DEC_COMPONENT_PRIVATE *pComponentPrivate) 1846{ 1847 OMX_ERRORTYPE eError = OMX_ErrorNone; 1848 OMX_DIRTYPE eDir; 1849 OMX_PARAM_PORTDEFINITIONTYPE* pPortDefIn = NULL; 1850 char *pArgs = "damedesuStr"; 1851 OMX_U32 pValues[4]; 1852 OMX_U32 pValues1[4]; 1853 OMX_U32 nBitPosition = 0; 1854 OMX_U8* pHeaderStream = (OMX_U8*)pBufHeader->pBuffer; 1855 OMX_U32 temp = -1; 1856 OMX_U32 temp2 = -1; 1857 1858 OMX_PRINT1(pComponentPrivate->dbg, ":: Entering HandleDataBuf_FromApp Function\n"); 1859 OMX_PRBUFFER2(pComponentPrivate->dbg, ":: pBufHeader->pMarkData = %p\n",pBufHeader->pMarkData); 1860 1861 pBufHeader->pPlatformPrivate = pComponentPrivate; 1862 eError = MP3DEC_GetBufferDirection(pBufHeader, &eDir); 1863 OMX_PRBUFFER2(pComponentPrivate->dbg, ":: HandleDataBuf_FromApp Function\n"); 1864 if (eError != OMX_ErrorNone) { 1865 OMX_ERROR4(pComponentPrivate->dbg, ":: The pBufHeader is not found in the list\n"); 1866 goto EXIT; 1867 } 1868 1869 if (eDir == OMX_DirInput) { 1870 pComponentPrivate->nHandledEmptyThisBuffers++; 1871 if (pComponentPrivate->curState == OMX_StateIdle){ 1872 pComponentPrivate->cbInfo.EmptyBufferDone (pComponentPrivate->pHandle, 1873 pComponentPrivate->pHandle->pApplicationPrivate, 1874 pBufHeader); 1875 OMX_PRBUFFER2(pComponentPrivate->dbg, ":: %d %s In idle state return input buffers\n", __LINE__, __FUNCTION__); 1876 pComponentPrivate->nEmptyBufferDoneCount++; 1877 SignalIfAllBuffersAreReturned(pComponentPrivate); 1878 goto EXIT; 1879 } 1880 LCML_DSP_INTERFACE *pLcmlHandle = (LCML_DSP_INTERFACE *)pComponentPrivate->pLcmlHandle; 1881 MP3D_LCML_BUFHEADERTYPE *pLcmlHdr; 1882 pPortDefIn = pComponentPrivate->pPortDef[OMX_DirInput]; 1883 1884 eError = MP3DEC_GetCorresponding_LCMLHeader(pComponentPrivate, pBufHeader->pBuffer, OMX_DirInput, &pLcmlHdr); 1885 if (eError != OMX_ErrorNone) { 1886 OMX_ERROR4(pComponentPrivate->dbg, ":: Error: Invalid Buffer Came ...\n"); 1887 goto EXIT; 1888 } 1889 1890 if ((pBufHeader->nFilledLen > 0) || (pBufHeader->nFlags & OMX_BUFFERFLAG_EOS)) { 1891 pComponentPrivate->bBypassDSP = 0; 1892 OMX_PRBUFFER2(pComponentPrivate->dbg, ":: HandleDataBuf_FromApp Function\n"); 1893 OMX_PRBUFFER2(pComponentPrivate->dbg, ":::Calling LCML_QueueBuffer\n"); 1894 1895#ifdef __PERF_INSTRUMENTATION__ 1896 /*For Steady State Instumentation*/ 1897 PERF_SendingFrame(pComponentPrivate->pPERFcomp, 1898 PREF(pBufHeader,pBuffer), 1899 pPortDefIn->nBufferSize, 1900 PERF_ModuleCommonLayer); 1901#endif 1902 if(pComponentPrivate->SendAfterEOS){ 1903 if(pComponentPrivate->dasfmode == 1) { 1904 pComponentPrivate->pParams->unAudioFormat = 1905 (unsigned short)pComponentPrivate->mp3Params->nChannels; 1906 if (pComponentPrivate->pParams->unAudioFormat == MP3D_STEREO_STREAM) { 1907 pComponentPrivate->pParams->unAudioFormat = MP3D_STEREO_NONINTERLEAVED_STREAM; 1908 } 1909 1910 pComponentPrivate->pParams->ulSamplingFreq = 1911 pComponentPrivate->mp3Params->nSampleRate; 1912 pComponentPrivate->pParams->unUUID = pComponentPrivate->streamID; 1913 1914 pValues[0] = USN_STRMCMD_SETCODECPARAMS; 1915 pValues[1] = (OMX_U32)pComponentPrivate->pParams; 1916 pValues[2] = sizeof(USN_AudioCodecParams); 1917 OMX_PRDSP2(pComponentPrivate->dbg, ": MP3DECUTILS::About to call LCML_ControlCodec stream control %d\n", __LINE__); 1918 eError = LCML_ControlCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle, 1919 EMMCodecControlStrmCtrl,(void *)pValues); 1920 if(eError != OMX_ErrorNone) { 1921 OMX_ERROR4(pComponentPrivate->dbg, ": Error Occurred in Codec StreamControl..\n"); 1922 pComponentPrivate->curState = OMX_StateInvalid; 1923 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 1924 pComponentPrivate->pHandle->pApplicationPrivate, 1925 OMX_EventError, 1926 eError, 1927 OMX_TI_ErrorSevere, 1928 NULL); 1929 goto EXIT; 1930 } 1931 } 1932 1933 if(pBufHeader->nFlags & OMX_BUFFERFLAG_CODECCONFIG || pComponentPrivate->bConfigData){ 1934 OMX_PRBUFFER2(pComponentPrivate->dbg, "Detected OMX_BUFFERFLAG_CODECCONFIG\n, \tproceed with parsing config data\n"); 1935 // parse the frame header 1936 pComponentPrivate->pStreamData.nSyncWord = MP3DEC_GetBits(&nBitPosition, 11, pHeaderStream, OMX_TRUE); 1937 pComponentPrivate->pStreamData.nMpegVersion = MP3DEC_GetBits(&nBitPosition, 2, pHeaderStream, OMX_TRUE); 1938 pComponentPrivate->pStreamData.nLayer = MP3DEC_GetBits(&nBitPosition, 2, pHeaderStream, OMX_TRUE); 1939 temp = MP3DEC_GetBits(&nBitPosition, 1, pHeaderStream, OMX_TRUE); // prot. bit 1940 pComponentPrivate->pStreamData.nBitRate = MP3DEC_GetBits(&nBitPosition, 4, pHeaderStream, OMX_TRUE); 1941 pComponentPrivate->pStreamData.nFrequency = MP3DEC_GetBits(&nBitPosition, 2, pHeaderStream, OMX_TRUE); 1942 temp = MP3DEC_GetBits(&nBitPosition, 2, pHeaderStream, OMX_TRUE); // pad bit, prov. bit 1943 pComponentPrivate->pStreamData.nChannelMode = MP3DEC_GetBits(&nBitPosition, 2, pHeaderStream, OMX_TRUE); 1944 1945 //save the current value of pcmParams->nSamplingRate 1946 temp = pComponentPrivate->pcmParams->nSamplingRate; 1947 1948 // parsing completed, now compare to existing values and set port params as needed 1949 switch(pComponentPrivate->pStreamData.nFrequency){ 1950 // these frequency values are based on mpeg1 supported freqs 1951 // if the stream is actually mpeg2 or mpeg2.5, we will divide appropriately below. 1952 case 0: 1953 pComponentPrivate->pcmParams->nSamplingRate = 44100; 1954 break; 1955 case 1: 1956 pComponentPrivate->pcmParams->nSamplingRate = 48000; 1957 break; 1958 case 2: 1959 pComponentPrivate->pcmParams->nSamplingRate = 32000; 1960 break; 1961 default: 1962 OMX_ERROR4(pComponentPrivate->dbg, "Unsupported Frequency\n"); 1963 break; 1964 } 1965 if (pComponentPrivate->pStreamData.nMpegVersion == 2){ 1966 // the actual sampling frequency is dependant upon the mpeg version 1967 // if Mpeg2 is used, divide the sampling rate from above by 2 1968 pComponentPrivate->pcmParams->nSamplingRate /= 2; 1969 } 1970 else if (pComponentPrivate->pStreamData.nMpegVersion == 0){ 1971 // the actual sampling frequency is dependant upon the mpeg version 1972 // divide by 4 for mpeg 2.5 1973 pComponentPrivate->pcmParams->nSamplingRate /= 4; 1974 } 1975 // save the current value of nChannels 1976 temp2 = pComponentPrivate->pcmParams->nChannels; 1977 // value of 3 = mono 1978 if (pComponentPrivate->pStreamData.nChannelMode == 3){ 1979 pComponentPrivate->pcmParams->nChannels = 1; 1980 } 1981 else{ // if stereo,joint stereo or dual channel, then pcm channels is stereo. Otherwise pcm output will be mono 1982 pComponentPrivate->pcmParams->nChannels = MP3D_STEREO_STREAM; 1983 } 1984 // decide if dynamic reconfig is needed 1985 OMX_PRCOMM2(pComponentPrivate->dbg, ": decide on reconfig ports...\n"); 1986 if (temp != pComponentPrivate->pcmParams->nSamplingRate || 1987 temp2 != pComponentPrivate->pcmParams->nChannels){ 1988 pComponentPrivate->reconfigOutputPort = OMX_TRUE; 1989 OMX_PRCOMM2(pComponentPrivate->dbg, ": reconfif output port set to true...\n"); 1990 } 1991 else{ 1992 OMX_PRCOMM2(pComponentPrivate->dbg, ": no port config needed, skip\n"); 1993 } 1994 1995 OMX_PRINT2(pComponentPrivate->dbg, "CODEC CONFIG: \n\tsample rate = %ld\n\tchannels = %ld\n\t channel mode = %ld (0/1 = stereo, 2/3 = mono)\n", 1996 pComponentPrivate->pcmParams->nSamplingRate, 1997 pComponentPrivate->pcmParams->nChannels, 1998 pComponentPrivate->pStreamData.nChannelMode); 1999 // set up the codec with corrected settings 2000 // it was not done in idle->executing transition 2001 if(pComponentPrivate->dasfmode == 0 && 2002 pComponentPrivate->pcmParams->bInterleaved) { 2003 pComponentPrivate->ptAlgDynParams->lOutputFormat = IAUDIO_INTERLEAVED; 2004 } else { 2005 pComponentPrivate->ptAlgDynParams->lOutputFormat = IAUDIO_BLOCK; 2006 } 2007 2008 pComponentPrivate->ptAlgDynParams->lMonoToStereoCopy = 0; 2009 pComponentPrivate->ptAlgDynParams->lStereoToMonoCopy = 0; 2010 pComponentPrivate->ptAlgDynParams->size = sizeof(MP3DEC_UALGParams); 2011 2012 pValues1[0] = IUALG_CMD_SETSTATUS; 2013 pValues1[1] = (OMX_U32) pComponentPrivate->ptAlgDynParams; 2014 pValues1[2] = sizeof(MP3DEC_UALGParams); 2015 OMX_PRDSP2(pComponentPrivate->dbg, ": MP3DECUTILS::About to call LCML_ControlCodec ALG %d\n", __LINE__); 2016 eError = LCML_ControlCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle, 2017 EMMCodecControlAlgCtrl,(void *)pValues1); 2018 if(eError != OMX_ErrorNone) { 2019 OMX_ERROR4(pComponentPrivate->dbg, "Error Occurred in Codec Start..\n"); 2020 pComponentPrivate->curState = OMX_StateInvalid; 2021 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 2022 pComponentPrivate->pHandle->pApplicationPrivate, 2023 OMX_EventError, 2024 eError, 2025 OMX_TI_ErrorSevere, 2026 NULL); 2027 goto EXIT; 2028 } 2029 2030 // adding port config 2031 if(pComponentPrivate->reconfigOutputPort){ 2032 OMX_PRCOMM2(pComponentPrivate->dbg, ": send event PortSettingsChanged for ouput port...\n"); 2033 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 2034 pComponentPrivate->pHandle->pApplicationPrivate, 2035 OMX_EventPortSettingsChanged, 2036 OUTPUT_PORT_MP3DEC, 2037 0, 2038 NULL); 2039 } 2040 pComponentPrivate->bConfigData = 0; 2041 } 2042 pComponentPrivate->bDspStoppedWhileExecuting = OMX_FALSE; 2043 eError = LCML_ControlCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle, 2044 EMMCodecControlStart, 2045 (void *)pArgs); 2046 if(eError != OMX_ErrorNone) { 2047 OMX_ERROR4(pComponentPrivate->dbg, "%d: Error Occurred in Codec Start..\n", __LINE__); 2048 goto EXIT; 2049 } 2050 pComponentPrivate->SendAfterEOS = 0; 2051 //pComponentPrivate->first_buff = 0; 2052 } //end SendAfterEOS 2053 2054 pLcmlHdr->pIpParam->bLastBuffer = 0; 2055 2056 if(pBufHeader->nFlags & OMX_BUFFERFLAG_EOS) { 2057 OMX_PRBUFFER2(pComponentPrivate->dbg, ":: bLastBuffer Is Set Here....\n"); 2058 pLcmlHdr->pIpParam->bLastBuffer = 1; 2059 pComponentPrivate->bIsEOFSent = 1; 2060 pComponentPrivate->SendAfterEOS = 1; 2061 pBufHeader->nFlags = 0; 2062 } 2063 2064 /* Store time stamp information */ 2065 pComponentPrivate->arrBufIndex[pComponentPrivate->IpBufindex] = pBufHeader->nTimeStamp; 2066 /*add on: Store tic count information*/ 2067 pComponentPrivate->arrBufIndexTick[pComponentPrivate->IpBufindex] = pBufHeader->nTickCount; 2068 pComponentPrivate->IpBufindex++; 2069 pComponentPrivate->IpBufindex %= pPortDefIn->nBufferCountActual; 2070 2071 if(!pComponentPrivate->frameMode){ 2072 if(pComponentPrivate->first_buff == 0){ 2073 pComponentPrivate->first_buff = 1; 2074 pComponentPrivate->first_TS = pBufHeader->nTimeStamp; 2075 } 2076 } 2077 2078 OMX_PRCOMM2(pComponentPrivate->dbg, "Comp:: Sending Filled Input buffer = %p, %ld\ 2079 to LCML\n",pBufHeader,pBufHeader->nFilledLen); 2080 2081 if (pComponentPrivate->curState == OMX_StateExecuting) { 2082 if (!MP3DEC_IsPending(pComponentPrivate,pBufHeader,OMX_DirInput)) { 2083 if(!pComponentPrivate->bDspStoppedWhileExecuting) { 2084 if(!(pComponentPrivate->reconfigInputPort || pComponentPrivate->reconfigOutputPort)){ 2085 MP3DEC_SetPending(pComponentPrivate,pBufHeader,OMX_DirInput,__LINE__); 2086 eError = LCML_QueueBuffer(pLcmlHandle->pCodecinterfacehandle, 2087 EMMCodecInputBuffer, 2088 pBufHeader->pBuffer, 2089 pBufHeader->nAllocLen, 2090 pBufHeader->nFilledLen, 2091 (OMX_U8 *) pLcmlHdr->pIpParam, 2092 sizeof(MP3DEC_UAlgInBufParamStruct), 2093 NULL); 2094 if (eError != OMX_ErrorNone) { 2095 OMX_ERROR4(pComponentPrivate->dbg, "::Comp: SetBuff: IP: Error Occurred = %x\n", eError); 2096 eError = OMX_ErrorHardware; 2097 goto EXIT; 2098 } 2099 OMX_PRINT2(pComponentPrivate->dbg, "%d Sent IP %p, len %ld\n",__LINE__ , 2100 pBufHeader->pBuffer, 2101 pBufHeader->nFilledLen); 2102 } 2103 else{ 2104 pComponentPrivate->pInputBufHdrPending[pComponentPrivate->nNumInputBufPending++] = pBufHeader; 2105 OMX_PRBUFFER2(pComponentPrivate->dbg, "Don't queue buffers during a reconfig, num IN pending is %ld\n", pComponentPrivate->nNumInputBufPending); 2106 } 2107 }else { 2108 OMX_PRBUFFER2(pComponentPrivate->dbg, "Calling EmptyBufferDone from line %d\n",__LINE__); 2109#ifdef __PERF_INSTRUMENTATION__ 2110 PERF_SendingFrame(pComponentPrivate->pPERFcomp, 2111 PREF(pBufHeader, pBuffer), 2112 0, 2113 PERF_ModuleHLMM); 2114#endif 2115 pComponentPrivate->cbInfo.EmptyBufferDone ( 2116 pComponentPrivate->pHandle, 2117 pComponentPrivate->pHandle->pApplicationPrivate, 2118 pBufHeader); 2119 pComponentPrivate->nEmptyBufferDoneCount++; 2120 SignalIfAllBuffersAreReturned(pComponentPrivate); 2121 } 2122 pComponentPrivate->lcml_nCntIp++; 2123 pComponentPrivate->lcml_nIpBuf++; 2124 pComponentPrivate->num_Sent_Ip_Buff++; 2125 OMX_PRBUFFER2(pComponentPrivate->dbg, "Sending Input buffer to Codec\n"); 2126 } 2127 } 2128 else if (pComponentPrivate->curState == OMX_StatePause) { 2129 pComponentPrivate->pInputBufHdrPending[pComponentPrivate->nNumInputBufPending++] = pBufHeader; 2130 } 2131 }else { 2132 pComponentPrivate->bBypassDSP = 1; 2133 OMX_PRBUFFER2(pComponentPrivate->dbg, "%d :: Forcing EmptyBufferDone\n",__LINE__); 2134#ifdef __PERF_INSTRUMENTATION__ 2135 PERF_SendingFrame(pComponentPrivate->pPERFcomp, 2136 PREF(pComponentPrivate->pInputBufferList->pBufHdr[0], pBuffer), 2137 0, 2138 PERF_ModuleHLMM); 2139#endif 2140 pComponentPrivate->cbInfo.EmptyBufferDone (pComponentPrivate->pHandle, 2141 pComponentPrivate->pHandle->pApplicationPrivate, 2142 pComponentPrivate->pInputBufferList->pBufHdr[0]); 2143 pComponentPrivate->nEmptyBufferDoneCount++; 2144 SignalIfAllBuffersAreReturned(pComponentPrivate); 2145 } 2146 if(pBufHeader->pMarkData){ 2147 OMX_PRBUFFER2(pComponentPrivate->dbg, ":Detected pBufHeader->pMarkData\n"); 2148 2149 pComponentPrivate->pMarkData = pBufHeader->pMarkData; 2150 pComponentPrivate->hMarkTargetComponent = pBufHeader->hMarkTargetComponent; 2151 pComponentPrivate->pOutputBufferList->pBufHdr[0]->pMarkData = pBufHeader->pMarkData; 2152 pComponentPrivate->pOutputBufferList->pBufHdr[0]->hMarkTargetComponent = pBufHeader->hMarkTargetComponent; 2153 2154 if(pBufHeader->hMarkTargetComponent == pComponentPrivate->pHandle && pBufHeader->pMarkData){ 2155 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 2156 pComponentPrivate->pHandle->pApplicationPrivate, 2157 OMX_EventMark, 2158 0, 2159 0, 2160 pBufHeader->pMarkData); 2161 } 2162 } 2163 if (pComponentPrivate->bFlushInputPortCommandPending) { 2164 OMX_SendCommand(pComponentPrivate->pHandle,OMX_CommandFlush,0,NULL); 2165 } 2166 } 2167 else if (eDir == OMX_DirOutput) { 2168 pComponentPrivate->nHandledFillThisBuffers++; 2169 if (pComponentPrivate->curState == OMX_StateIdle){ 2170 pComponentPrivate->cbInfo.FillBufferDone (pComponentPrivate->pHandle, 2171 pComponentPrivate->pHandle->pApplicationPrivate, 2172 pBufHeader); 2173 OMX_PRBUFFER2(pComponentPrivate->dbg, ":: %d %s In idle state return output buffers\n", __LINE__, __FUNCTION__); 2174 pComponentPrivate->nFillBufferDoneCount++; 2175 SignalIfAllBuffersAreReturned(pComponentPrivate); 2176 goto EXIT; 2177 } 2178 LCML_DSP_INTERFACE *pLcmlHandle = (LCML_DSP_INTERFACE *)pComponentPrivate->pLcmlHandle; 2179 MP3D_LCML_BUFHEADERTYPE *pLcmlHdr; 2180 OMX_PRBUFFER2(pComponentPrivate->dbg, ": pComponentPrivate->lcml_nOpBuf = %ld\n",pComponentPrivate->lcml_nOpBuf); 2181 OMX_PRBUFFER2(pComponentPrivate->dbg, ": pComponentPrivate->lcml_nIpBuf = %ld\n",pComponentPrivate->lcml_nIpBuf); 2182 eError = MP3DEC_GetCorresponding_LCMLHeader(pComponentPrivate, pBufHeader->pBuffer, OMX_DirOutput, &pLcmlHdr); 2183 if (eError != OMX_ErrorNone) { 2184 OMX_ERROR4(pComponentPrivate->dbg, ":: Error: Invalid Buffer Came ...\n"); 2185 goto EXIT; 2186 } 2187 OMX_PRDSP2(pComponentPrivate->dbg, ":::Calling LCML_QueueBuffer\n"); 2188#ifdef __PERF_INSTRUMENTATION__ 2189 PERF_SendingFrame(pComponentPrivate->pPERFcomp, 2190 PREF(pBufHeader,pBuffer), 2191 0, 2192 PERF_ModuleCommonLayer); 2193#endif 2194 if (pComponentPrivate->bBypassDSP == 0) { 2195 if (pComponentPrivate->curState == OMX_StateExecuting) { 2196 if(!(pComponentPrivate->reconfigInputPort || pComponentPrivate->reconfigOutputPort)){ 2197 if (!MP3DEC_IsPending(pComponentPrivate,pBufHeader,OMX_DirOutput) && 2198 (pComponentPrivate->numPendingBuffers < pComponentPrivate->pOutputBufferList->numBuffers)){ 2199 if(!pComponentPrivate->bDspStoppedWhileExecuting){ 2200 MP3DEC_SetPending(pComponentPrivate,pBufHeader,OMX_DirOutput,__LINE__); 2201 eError = LCML_QueueBuffer(pLcmlHandle->pCodecinterfacehandle, 2202 EMMCodecOuputBuffer, 2203 pBufHeader->pBuffer, 2204 pBufHeader->nAllocLen, 2205 0, 2206 (OMX_U8 *) pLcmlHdr->pOpParam, 2207 sizeof(MP3DEC_UAlgOutBufParamStruct), 2208 pBufHeader->pBuffer); 2209 if (eError != OMX_ErrorNone ) { 2210 OMX_ERROR4(pComponentPrivate->dbg, ":: Comp:: SetBuff OP: Error Occurred = %d\n", eError); 2211 OMX_ERROR4(pComponentPrivate->dbg, "nFilledLen = %ld\n nAllocLen = %ld\n", pBufHeader->nFilledLen, pBufHeader->nAllocLen); 2212 eError = OMX_ErrorHardware; 2213 goto EXIT; 2214 } 2215 OMX_PRINT2(pComponentPrivate->dbg, "%d Sent OP %p\n",__LINE__,pBufHeader->pBuffer); 2216 pComponentPrivate->lcml_nCntOp++; 2217 pComponentPrivate->lcml_nOpBuf++; 2218 pComponentPrivate->num_Op_Issued++; 2219 } 2220 } 2221 2222 } else{ 2223 pComponentPrivate->pOutputBufHdrPending[pComponentPrivate->nNumOutputBufPending++] = pBufHeader; 2224 OMX_PRBUFFER2(pComponentPrivate->dbg, "Don't queue while doing a reconfig:: output buffer, num pending = %ld\n", pComponentPrivate->nNumOutputBufPending); 2225 } 2226 }else if (pComponentPrivate->curState == OMX_StatePause) { 2227 pComponentPrivate->pOutputBufHdrPending[pComponentPrivate->nNumOutputBufPending++] = pBufHeader; 2228 } 2229 } 2230 if (pComponentPrivate->bFlushOutputPortCommandPending) { 2231 OMX_SendCommand( pComponentPrivate->pHandle, OMX_CommandFlush, 1, NULL); 2232 } 2233 } 2234 else { 2235 OMX_ERROR4(pComponentPrivate->dbg, ": BufferHeader %p, Buffer %p Unknown ..........\n",pBufHeader, pBufHeader->pBuffer); 2236 eError = OMX_ErrorBadParameter; 2237 } 2238 EXIT: 2239 OMX_PRINT1(pComponentPrivate->dbg, ": Exiting from HandleDataBuf_FromApp: %x \n",eError); 2240 if (eError != OMX_ErrorNone ) { 2241 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 2242 pComponentPrivate->pHandle->pApplicationPrivate, 2243 OMX_EventError, 2244 eError, 2245 OMX_TI_ErrorSevere, 2246 NULL); 2247 } 2248 return eError; 2249} 2250 2251 2252/* ================================================================================= * */ 2253/** 2254 * @fn MP3DEC_GetBufferDirection() function determines whether it is input buffer or 2255 * output buffer. 2256 * 2257 * @param *pBufHeader This is pointer to buffer header whose direction needs to 2258 * be determined. 2259 * 2260 * @param *eDir This is output argument which stores the direction of buffer. 2261 * 2262 * @pre None 2263 * 2264 * @post None 2265 * 2266 * @return OMX_ErrorNone = Successful processing. 2267 * OMX_ErrorBadParameter = In case of invalid buffer 2268 * 2269 * @see None 2270 */ 2271/* ================================================================================ * */ 2272 2273OMX_ERRORTYPE MP3DEC_GetBufferDirection(OMX_BUFFERHEADERTYPE *pBufHeader, 2274 OMX_DIRTYPE *eDir) 2275{ 2276 OMX_ERRORTYPE eError = OMX_ErrorNone; 2277 MP3DEC_COMPONENT_PRIVATE *pComponentPrivate = pBufHeader->pPlatformPrivate; 2278 OMX_U32 nBuf = pComponentPrivate->pInputBufferList->numBuffers; 2279 OMX_BUFFERHEADERTYPE *pBuf = NULL; 2280 int flag = 1; 2281 OMX_U32 i=0; 2282 2283 OMX_PRINT1(pComponentPrivate->dbg, ":: Entering GetBufferDirection Function\n"); 2284 for(i=0; i<nBuf; i++) { 2285 pBuf = pComponentPrivate->pInputBufferList->pBufHdr[i]; 2286 if(pBufHeader == pBuf) { 2287 *eDir = OMX_DirInput; 2288 OMX_PRINT2(pComponentPrivate->dbg, ":: Buffer %p is INPUT BUFFER\n", pBufHeader); 2289 flag = 0; 2290 goto EXIT; 2291 } 2292 } 2293 2294 nBuf = pComponentPrivate->pOutputBufferList->numBuffers; 2295 2296 for(i=0; i<nBuf; i++) { 2297 pBuf = pComponentPrivate->pOutputBufferList->pBufHdr[i]; 2298 if(pBufHeader == pBuf) { 2299 *eDir = OMX_DirOutput; 2300 OMX_PRINT2(pComponentPrivate->dbg, ":: Buffer %p is OUTPUT BUFFER\n", pBufHeader); 2301 flag = 0; 2302 goto EXIT; 2303 } 2304 } 2305 2306 if (flag == 1) { 2307 MP3D_OMX_ERROR_EXIT(eError, OMX_ErrorBadParameter, 2308 "Buffer Not Found in List : OMX_ErrorBadParameter"); 2309 } 2310 EXIT: 2311 OMX_PRINT1(pComponentPrivate->dbg, ":: Exiting GetBufferDirection Function\n"); 2312 return eError; 2313} 2314 2315/** ================================================================================= * */ 2316/** 2317 * @fn MP3DEC_LCML_Callback() function is callback which is called by LCML whenever 2318 * there is an even generated for the component. 2319 * 2320 * @param event This is event that was generated. 2321 * 2322 * @param arg This has other needed arguments supplied by LCML like handles 2323 * etc. 2324 * 2325 * @pre None 2326 * 2327 * @post None 2328 * 2329 * @return OMX_ErrorNone = Successful processing. 2330 * OMX_ErrorInsufficientResources = Not enough memory 2331 * 2332 * @see None 2333 */ 2334/* ================================================================================ * */ 2335OMX_ERRORTYPE MP3DEC_LCML_Callback (TUsnCodecEvent event,void * args [10]) 2336{ 2337 OMX_ERRORTYPE eError = OMX_ErrorNone; 2338 OMX_U8 *pBuffer = args[1]; 2339 MP3D_LCML_BUFHEADERTYPE *pLcmlHdr; 2340 OMX_COMPONENTTYPE *pHandle; 2341 LCML_DSP_INTERFACE *pLcmlHandle; 2342 OMX_U32 i; 2343 MP3DEC_BUFDATA *OutputFrames; 2344 MP3DEC_COMPONENT_PRIVATE* pComponentPrivate = NULL; 2345#ifdef RESOURCE_MANAGER_ENABLED 2346 OMX_ERRORTYPE rm_error = OMX_ErrorNone; 2347#endif 2348 static double time_stmp = 0; 2349 2350 pComponentPrivate = (MP3DEC_COMPONENT_PRIVATE*)((LCML_DSP_INTERFACE*)args[6])->pComponentPrivate; 2351 2352 OMX_PRINT1(pComponentPrivate->dbg, ":: Entering the LCML_Callback() : event = %d\n",event); 2353 2354 switch(event) { 2355 2356 case EMMCodecDspError: 2357 OMX_PRDSP2(pComponentPrivate->dbg, "[LCML CALLBACK EVENT] EMMCodecDspError\n"); 2358 break; 2359 2360 case EMMCodecInternalError: 2361 OMX_PRDSP2(pComponentPrivate->dbg, "[LCML CALLBACK EVENT] EMMCodecInternalError\n"); 2362 break; 2363 2364 case EMMCodecInitError: 2365 OMX_PRDSP2(pComponentPrivate->dbg, "[LCML CALLBACK EVENT] EMMCodecInitError\n"); 2366 break; 2367 2368 case EMMCodecDspMessageRecieved: 2369 OMX_PRDSP2(pComponentPrivate->dbg, "[LCML CALLBACK EVENT] EMMCodecDspMessageRecieved\n"); 2370 break; 2371 2372 case EMMCodecBufferProcessed: 2373 OMX_PRDSP2(pComponentPrivate->dbg, "[LCML CALLBACK EVENT] EMMCodecBufferProcessed\n"); 2374 break; 2375 2376 case EMMCodecProcessingStarted: 2377 OMX_PRDSP2(pComponentPrivate->dbg, "[LCML CALLBACK EVENT] EMMCodecProcessingStarted\n"); 2378 break; 2379 2380 case EMMCodecProcessingPaused: 2381 OMX_PRDSP2(pComponentPrivate->dbg, "[LCML CALLBACK EVENT] EMMCodecProcessingPaused\n"); 2382 break; 2383 2384 case EMMCodecProcessingStoped: 2385 OMX_PRDSP2(pComponentPrivate->dbg, "[LCML CALLBACK EVENT] EMMCodecProcessingStoped\n"); 2386 break; 2387 2388 case EMMCodecProcessingEof: 2389 OMX_PRDSP2(pComponentPrivate->dbg, "[LCML CALLBACK EVENT] EMMCodecProcessingEof\n"); 2390 break; 2391 2392 case EMMCodecBufferNotProcessed: 2393 OMX_PRDSP2(pComponentPrivate->dbg, "[LCML CALLBACK EVENT] EMMCodecBufferNotProcessed\n"); 2394 break; 2395 2396 case EMMCodecAlgCtrlAck: 2397 OMX_PRDSP2(pComponentPrivate->dbg, "[LCML CALLBACK EVENT] EMMCodecAlgCtrlAck\n"); 2398 break; 2399 2400 case EMMCodecStrmCtrlAck: 2401 OMX_PRDSP2(pComponentPrivate->dbg, "[LCML CALLBACK EVENT] EMMCodecStrmCtrlAck\n"); 2402 break; 2403 } 2404 2405 2406 if(event == EMMCodecBufferProcessed) { 2407 if( args[0] == (void *)EMMCodecInputBuffer) { 2408 OMX_PRBUFFER2(pComponentPrivate->dbg, " :: Inside the LCML_Callback EMMCodecInputBuffer\n"); 2409 OMX_PRBUFFER2(pComponentPrivate->dbg, ":: Input: pBufferr = %p\n", pBuffer); 2410 2411 eError = MP3DEC_GetCorresponding_LCMLHeader(pComponentPrivate, pBuffer, OMX_DirInput, &pLcmlHdr); 2412 if (eError != OMX_ErrorNone) { 2413 OMX_ERROR4(pComponentPrivate->dbg, ":: Error: Invalid Buffer Came ...\n"); 2414 goto EXIT; 2415 } 2416 OMX_PRBUFFER2(pComponentPrivate->dbg, ":: Input: pLcmlHeader = %p\n", pLcmlHdr); 2417 OMX_PRBUFFER2(pComponentPrivate->dbg, ":: Input: pLcmlHdr->eDir = %d\n", pLcmlHdr->eDir); 2418 OMX_PRBUFFER2(pComponentPrivate->dbg, ":: Input: Filled Len = %ld\n", pLcmlHdr->pBufHdr->nFilledLen); 2419 pLcmlHdr->pBufHdr->nFilledLen = 0; 2420 OMX_PRINT1(pComponentPrivate->dbg, ":: Input: Filled Len = %ld\n", pLcmlHdr->pBufHdr->nFilledLen); 2421#ifdef __PERF_INSTRUMENTATION__ 2422 PERF_ReceivedFrame(pComponentPrivate->pPERFcomp, 2423 PREF(pLcmlHdr->pBufHdr,pBuffer), 2424 0, 2425 PERF_ModuleCommonLayer); 2426#endif 2427 pComponentPrivate->lcml_nCntIpRes++; 2428 2429 MP3DEC_ClearPending(pComponentPrivate,pLcmlHdr->pBufHdr,OMX_DirInput,__LINE__); 2430 2431#ifdef __PERF_INSTRUMENTATION__ 2432 PERF_SendingFrame(pComponentPrivate->pPERFcomp, 2433 PREF(pLcmlHdr->pBufHdr,pBuffer), 2434 0, 2435 PERF_ModuleHLMM); 2436#endif 2437 pComponentPrivate->cbInfo.EmptyBufferDone (pComponentPrivate->pHandle, 2438 pComponentPrivate->pHandle->pApplicationPrivate, 2439 pLcmlHdr->pBufHdr); 2440 pComponentPrivate->nEmptyBufferDoneCount++; 2441 SignalIfAllBuffersAreReturned(pComponentPrivate); 2442 pComponentPrivate->lcml_nIpBuf--; 2443 pComponentPrivate->app_nBuf++; 2444 2445 } else if (args[0] == (void *)EMMCodecOuputBuffer) { 2446 OMX_PRBUFFER2(pComponentPrivate->dbg, " :: Inside the LCML_Callback EMMCodecOuputBuffer\n"); 2447 2448 OMX_PRINT2(pComponentPrivate->dbg, "%d\t\t\t\t............ Received OP %p, \tlen %d\n", 2449 __LINE__,pBuffer,(int)args[8]); 2450 2451 OMX_PRBUFFER2(pComponentPrivate->dbg, ":: Output: pBufferr = %p\n", pBuffer); 2452 if (!MP3DEC_IsValid(pComponentPrivate,pBuffer,OMX_DirOutput)) { 2453 2454 OMX_PRBUFFER2(pComponentPrivate->dbg, "%d :: ############ FillBufferDone Invalid\n",__LINE__); 2455 /* If the buffer we get back from the DSP is not valid call FillBufferDone 2456 on a valid buffer */ 2457#ifdef __PERF_INSTRUMENTATION__ 2458 PERF_SendingFrame(pComponentPrivate->pPERFcomp, 2459 pComponentPrivate->pOutputBufferList->pBufHdr[pComponentPrivate->nInvalidFrameCount]->pBuffer, 2460 pComponentPrivate->pOutputBufferList->pBufHdr[pComponentPrivate->nInvalidFrameCount]->nFilledLen, 2461 PERF_ModuleHLMM); 2462#endif 2463 pComponentPrivate->cbInfo.FillBufferDone (pComponentPrivate->pHandle, 2464 pComponentPrivate->pHandle->pApplicationPrivate, 2465 pComponentPrivate->pOutputBufferList->pBufHdr[pComponentPrivate->nInvalidFrameCount++] 2466 ); 2467 pComponentPrivate->nFillBufferDoneCount++; 2468 pComponentPrivate->numPendingBuffers--; 2469 SignalIfAllBuffersAreReturned(pComponentPrivate); 2470 }else { 2471 eError = MP3DEC_GetCorresponding_LCMLHeader(pComponentPrivate, pBuffer, OMX_DirOutput, &pLcmlHdr); 2472 if (eError != OMX_ErrorNone) { 2473 OMX_ERROR4(pComponentPrivate->dbg, ":: Error: Invalid Buffer Came ...\n"); 2474 goto EXIT; 2475 } 2476 pLcmlHdr->pBufHdr->nFilledLen = (int)args[8]; 2477 OMX_PRCOMM2(pComponentPrivate->dbg, ":: Output: pLcmlHeader = %p\n", pLcmlHdr); 2478 OMX_PRCOMM2(pComponentPrivate->dbg, ":: Output: pLcmlHdr->eDir = %d\n", pLcmlHdr->eDir); 2479 OMX_PRCOMM2(pComponentPrivate->dbg, ":: Output: Filled Len = %ld\n", pLcmlHdr->pBufHdr->nFilledLen); 2480 /* Recover MP3DEC_UAlgOutBufParamStruct from SN*/ 2481 OutputFrames = pLcmlHdr->pBufHdr->pOutputPortPrivate; 2482 OutputFrames->nFrames = (OMX_U8)(pLcmlHdr->pOpParam->ulFrameCount); 2483 2484#ifdef __PERF_INSTRUMENTATION__ 2485 PERF_ReceivedFrame(pComponentPrivate->pPERFcomp, 2486 PREF(pLcmlHdr->pBufHdr,pBuffer), 2487 PREF(pLcmlHdr->pBufHdr,nFilledLen), 2488 PERF_ModuleCommonLayer); 2489 2490 pComponentPrivate->nLcml_nCntOpReceived++; 2491 2492 if ((pComponentPrivate->nLcml_nCntIp >= 1) && (pComponentPrivate->nLcml_nCntOpReceived == 1)) { 2493 PERF_Boundary(pComponentPrivate->pPERFcomp, 2494 PERF_BoundaryStart | PERF_BoundarySteadyState); 2495 } 2496#endif 2497 MP3DEC_ClearPending(pComponentPrivate,pLcmlHdr->pBufHdr,OMX_DirOutput,__LINE__); 2498 2499 if (pComponentPrivate->pMarkData) { 2500 pLcmlHdr->pBufHdr->pMarkData = pComponentPrivate->pMarkData; 2501 pLcmlHdr->pBufHdr->hMarkTargetComponent = pComponentPrivate->hMarkTargetComponent; 2502 } 2503 pComponentPrivate->num_Reclaimed_Op_Buff++; 2504 2505 if (pLcmlHdr->pOpParam->ulIsLastBuffer){ 2506 OMX_PRBUFFER2(pComponentPrivate->dbg, "Adding EOS flag to the output buffer\n"); 2507 pLcmlHdr->pBufHdr->nFlags |= OMX_BUFFERFLAG_EOS; 2508 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 2509 pComponentPrivate->pHandle->pApplicationPrivate, 2510 OMX_EventBufferFlag, 2511 pLcmlHdr->pBufHdr->nOutputPortIndex, 2512 pLcmlHdr->pBufHdr->nFlags, NULL); 2513 pComponentPrivate->bIsEOFSent = 0; 2514 pLcmlHdr->pOpParam->ulIsLastBuffer=0; 2515 } 2516 2517 if(pComponentPrivate->frameMode){ 2518 /* Copying time stamp information to output buffer */ 2519 pLcmlHdr->pBufHdr->nTimeStamp = (OMX_TICKS)pComponentPrivate->arrBufIndex[pComponentPrivate->OpBufindex]; 2520 }else{ 2521 if(pComponentPrivate->first_buff == 1){ 2522 pComponentPrivate->first_buff = 2; 2523 pLcmlHdr->pBufHdr->nTimeStamp = pComponentPrivate->first_TS; 2524 pComponentPrivate->temp_TS = pLcmlHdr->pBufHdr->nTimeStamp; 2525 OMX_PRBUFFER2(pComponentPrivate->dbg, "first_ts = %lld\n", 2526 pComponentPrivate->temp_TS); 2527 }else{ 2528 time_stmp = pLcmlHdr->pBufHdr->nFilledLen / (pComponentPrivate->pcmParams->nChannels * 2529 (pComponentPrivate->pcmParams->nBitPerSample / 8)); 2530 time_stmp = (time_stmp / pComponentPrivate->pcmParams->nSamplingRate) * 1000000; 2531 /* Update time stamp information */ 2532 pComponentPrivate->temp_TS += time_stmp; 2533 pLcmlHdr->pBufHdr->nTimeStamp = pComponentPrivate->temp_TS; 2534 OMX_PRBUFFER2(pComponentPrivate->dbg, "out ts = %lld\n", 2535 pComponentPrivate->temp_TS); 2536 } 2537 } 2538 /*add on: Copyint tick count information to output buffer*/ 2539 pLcmlHdr->pBufHdr->nTickCount = (OMX_U32)pComponentPrivate->arrBufIndexTick[pComponentPrivate->OpBufindex]; 2540 pComponentPrivate->OpBufindex++; 2541 pComponentPrivate->OpBufindex %= pComponentPrivate->pPortDef[OMX_DirInput]->nBufferCountActual; 2542 2543 2544#ifdef __PERF_INSTRUMENTATION__ 2545 PERF_SendingBuffer(pComponentPrivate->pPERFcomp, 2546 pLcmlHdr->pBufHdr->pBuffer, 2547 pLcmlHdr->pBufHdr->nFilledLen, 2548 PERF_ModuleHLMM); 2549#endif 2550 2551 pComponentPrivate->cbInfo.FillBufferDone (pComponentPrivate->pHandle, 2552 pComponentPrivate->pHandle->pApplicationPrivate, 2553 pLcmlHdr->pBufHdr); 2554 pComponentPrivate->lcml_nOpBuf--; 2555 pComponentPrivate->app_nBuf++; 2556 pComponentPrivate->nFillBufferDoneCount++; 2557 SignalIfAllBuffersAreReturned(pComponentPrivate); 2558 } 2559 } 2560 }else if(event == EMMCodecProcessingStoped) { 2561 for (i = 0; i < pComponentPrivate->nNumInputBufPending; i++) { 2562 pComponentPrivate->cbInfo.EmptyBufferDone (pComponentPrivate->pHandle, 2563 pComponentPrivate->pHandle->pApplicationPrivate, 2564 pComponentPrivate->pInputBufHdrPending[i]); 2565 pComponentPrivate->nEmptyBufferDoneCount++; 2566 pComponentPrivate->pInputBufHdrPending[i] = NULL; 2567 SignalIfAllBuffersAreReturned(pComponentPrivate); 2568 } 2569 pComponentPrivate->nNumInputBufPending = 0; 2570 for (i=0; i < pComponentPrivate->nNumOutputBufPending; i++) { 2571 pComponentPrivate->cbInfo.FillBufferDone (pComponentPrivate->pHandle, 2572 pComponentPrivate->pHandle->pApplicationPrivate, 2573 pComponentPrivate->pOutputBufHdrPending[i] 2574 ); 2575 pComponentPrivate->nFillBufferDoneCount++; 2576 pComponentPrivate->pOutputBufHdrPending[i] = NULL; 2577 SignalIfAllBuffersAreReturned(pComponentPrivate); 2578 } 2579 pComponentPrivate->nNumOutputBufPending=0; 2580 2581 pthread_mutex_lock(&pComponentPrivate->codecStop_mutex); 2582 if(pComponentPrivate->codecStop_waitingsignal == 0){ 2583 pComponentPrivate->codecStop_waitingsignal = 1; 2584 pthread_cond_signal(&pComponentPrivate->codecStop_threshold); 2585 OMX_ERROR4(pComponentPrivate->dbg, "stop ack. received. stop waiting for sending disable command completed\n"); 2586 } 2587 pthread_mutex_unlock(&pComponentPrivate->codecStop_mutex); 2588 if (!pComponentPrivate->bNoIdleOnStop) { 2589 pComponentPrivate->curState = OMX_StateIdle; 2590 2591#ifdef RESOURCE_MANAGER_ENABLED 2592 rm_error = RMProxy_NewSendCommand(pComponentPrivate->pHandle, 2593 RMProxy_StateSet, 2594 OMX_MP3_Decoder_COMPONENT, 2595 OMX_StateIdle, 2596 3456, 2597 NULL); 2598#endif 2599 if((pComponentPrivate->nEmptyThisBufferCount != pComponentPrivate->nEmptyBufferDoneCount) || (pComponentPrivate->nFillThisBufferCount != pComponentPrivate->nFillBufferDoneCount)) { 2600 if(pthread_mutex_lock(&bufferReturned_mutex) != 0) 2601 { 2602 OMX_ERROR4(pComponentPrivate->dbg, "%d :: UTIL: bufferReturned_mutex mutex lock error\n",__LINE__); 2603 } 2604 OMX_PRINT2(pComponentPrivate->dbg, ":: pthread_cond_waiting for OMX to return all input and outbut buffers\n"); 2605 pthread_cond_wait(&bufferReturned_condition, &bufferReturned_mutex); 2606 OMX_PRINT2(pComponentPrivate->dbg, ":: OMX has returned all input and output buffers\n"); 2607 if(pthread_mutex_unlock(&bufferReturned_mutex) != 0) 2608 { 2609 OMX_ERROR4(pComponentPrivate->dbg, "%d :: UTIL: bufferReturned_mutex mutex unlock error\n",__LINE__); 2610 } 2611 } 2612 else 2613 { 2614 OMX_PRINT2(pComponentPrivate->dbg, ":: OMX has returned all input and output buffers\n"); 2615 } 2616 if(pComponentPrivate->bPreempted==0){ 2617 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 2618 pComponentPrivate->pHandle->pApplicationPrivate, 2619 OMX_EventCmdComplete, 2620 OMX_CommandStateSet, 2621 pComponentPrivate->curState, 2622 NULL); 2623 }else{ 2624 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 2625 pComponentPrivate->pHandle->pApplicationPrivate, 2626 OMX_EventError, 2627 OMX_ErrorResourcesPreempted, 2628 OMX_TI_ErrorMajor, 2629 NULL); 2630 } 2631 }else{ 2632 pComponentPrivate->bDspStoppedWhileExecuting = OMX_TRUE; 2633 pComponentPrivate->bNoIdleOnStop = OMX_FALSE; 2634 } 2635 } 2636 else if(event == EMMCodecAlgCtrlAck) { 2637 OMX_PRDSP2(pComponentPrivate->dbg, "GOT MESSAGE USN_DSPACK_ALGCTRL \n"); 2638 } 2639 else if (event == EMMCodecDspError) { 2640 2641 OMX_PRDSP1(pComponentPrivate->dbg, ":: commandedState = %p\n",args[0]); 2642 OMX_PRINT2(pComponentPrivate->dbg, ":: arg4 = %p\n",args[4]); 2643 OMX_PRINT2(pComponentPrivate->dbg, ":: arg5 = %p\n",args[5]); 2644 switch ( (OMX_U32) args [4]) 2645 { 2646 /* USN_ERR_NONE,: Indicates that no error encountered during execution of the command and the command execution completed succesfully. 2647 * USN_ERR_WARNING,: Indicates that process function returned a warning. The exact warning is returned in Arg2 of this message. 2648 * USN_ERR_PROCESS,: Indicates that process function returned a error type. The exact error type is returnd in Arg2 of this message. 2649 * USN_ERR_PAUSE,: Indicates that execution of pause resulted in error. 2650 * USN_ERR_STOP,: Indicates that execution of stop resulted in error. 2651 * USN_ERR_ALGCTRL,: Indicates that execution of alg control resulted in error. 2652 * USN_ERR_STRMCTRL,: Indiactes the execution of STRM control command, resulted in error. 2653 * USN_ERR_UNKNOWN_MSG,: Indicates that USN received an unknown command. */ 2654 2655#ifdef _ERROR_PROPAGATION__ 2656 case USN_ERR_PAUSE: 2657 case USN_ERR_STOP: 2658 case USN_ERR_ALGCTRL: 2659 case USN_ERR_STRMCTRL: 2660 case USN_ERR_UNKNOWN_MSG: 2661 { 2662 pComponentPrivate->bIsInvalidState=OMX_TRUE; 2663 pComponentPrivate->curState = OMX_StateInvalid; 2664 pHandle = pComponentPrivate->pHandle; 2665 pComponentPrivate->cbInfo.EventHandler(pHandle, 2666 pHandle->pApplicationPrivate, 2667 OMX_EventError, 2668 OMX_ErrorInvalidState, 2669 OMX_TI_ErrorSevere, 2670 NULL); 2671 } 2672 break; 2673#endif 2674 2675 case USN_ERR_WARNING: 2676 case USN_ERR_PROCESS: 2677 MP3DEC_HandleUSNError (pComponentPrivate, (OMX_U32)args[5]); 2678 break; 2679 default: 2680 break; 2681 } 2682 } else if (event == EMMCodecStrmCtrlAck) { 2683 2684 2685 OMX_PRDSP2(pComponentPrivate->dbg, ":: GOT MESSAGE USN_DSPACK_STRMCTRL ----\n"); 2686 if (args[1] == (void *)USN_STRMCMD_FLUSH) { 2687 pHandle = pComponentPrivate->pHandle; 2688 if ( args[2] == (void *)EMMCodecInputBuffer) { 2689 if (args[0] == (void *)USN_ERR_NONE ) { 2690 OMX_PRCOMM2(pComponentPrivate->dbg, "Flushing input port %d\n",__LINE__); 2691 for (i=0; i < pComponentPrivate->nNumInputBufPending; i++) { 2692#ifdef __PERF_INSTRUMENTATION__ 2693 PERF_SendingFrame(pComponentPrivate->pPERFcomp, 2694 PREF(pComponentPrivate->pInputBufHdrPending[i],pBuffer), 2695 0, 2696 PERF_ModuleHLMM); 2697#endif 2698 2699 pComponentPrivate->cbInfo.EmptyBufferDone (pComponentPrivate->pHandle, 2700 pComponentPrivate->pHandle->pApplicationPrivate, 2701 pComponentPrivate->pInputBufHdrPending[i]); 2702 pComponentPrivate->nEmptyBufferDoneCount++; 2703 pComponentPrivate->pInputBufHdrPending[i] = NULL; 2704 SignalIfAllBuffersAreReturned(pComponentPrivate); 2705 } 2706 pComponentPrivate->nNumInputBufPending=0; 2707 2708 pthread_mutex_lock(&pComponentPrivate->codecFlush_mutex); 2709 if(pComponentPrivate->codecFlush_waitingsignal == 0){ 2710 pComponentPrivate->codecFlush_waitingsignal = 1; 2711 pthread_cond_signal(&pComponentPrivate->codecFlush_threshold); 2712 OMX_ERROR4(pComponentPrivate->dbg, "flush ack. received. for input port\n"); 2713 } 2714 pthread_mutex_unlock(&pComponentPrivate->codecFlush_mutex); 2715 2716 pComponentPrivate->cbInfo.EventHandler(pHandle, 2717 pHandle->pApplicationPrivate, 2718 OMX_EventCmdComplete, 2719 OMX_CommandFlush, 2720 MP3D_INPUT_PORT, 2721 NULL); 2722 } else { 2723 OMX_ERROR4(pComponentPrivate->dbg, "LCML reported error while flushing input port\n"); 2724 goto EXIT; 2725 } 2726 } 2727 else if ( args[2] == (void *)EMMCodecOuputBuffer) { 2728 2729 2730 2731 if (args[0] == (void *)USN_ERR_NONE ) { 2732 OMX_PRCOMM2(pComponentPrivate->dbg, "Flushing output port %d\n",__LINE__); 2733 for (i=0; i < pComponentPrivate->nNumOutputBufPending; i++) { 2734#ifdef __PERF_INSTRUMENTATION__ 2735 PERF_SendingFrame(pComponentPrivate->pPERFcomp, 2736 PREF(pComponentPrivate->pOutputBufHdrPending[i],pBuffer), 2737 PREF(pComponentPrivate->pOutputBufHdrPending[i],nFilledLen), 2738 PERF_ModuleHLMM); 2739#endif 2740 2741 pComponentPrivate->cbInfo.FillBufferDone (pComponentPrivate->pHandle, 2742 pComponentPrivate->pHandle->pApplicationPrivate, 2743 pComponentPrivate->pOutputBufHdrPending[i] 2744 ); 2745 pComponentPrivate->nFillBufferDoneCount++; 2746 pComponentPrivate->pOutputBufHdrPending[i] = NULL; 2747 SignalIfAllBuffersAreReturned(pComponentPrivate); 2748 } 2749 pComponentPrivate->nNumOutputBufPending=0; 2750 2751 pthread_mutex_lock(&pComponentPrivate->codecFlush_mutex); 2752 if(pComponentPrivate->codecFlush_waitingsignal == 0){ 2753 pComponentPrivate->codecFlush_waitingsignal = 1; 2754 pthread_cond_signal(&pComponentPrivate->codecFlush_threshold); 2755 OMX_ERROR4(pComponentPrivate->dbg, "flush ack. received. for output port\n"); 2756 } 2757 pthread_mutex_unlock(&pComponentPrivate->codecFlush_mutex); 2758 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 2759 pComponentPrivate->pHandle->pApplicationPrivate, 2760 OMX_EventCmdComplete, 2761 OMX_CommandFlush, 2762 MP3D_OUTPUT_PORT, 2763 NULL); 2764 } else { 2765 OMX_ERROR4(pComponentPrivate->dbg, "LCML reported error while flushing output port\n"); 2766 goto EXIT; 2767 } 2768 } 2769 } 2770 } 2771 else if (event == EMMCodecProcessingPaused) { 2772 2773 pComponentPrivate->curState = OMX_StatePause; 2774 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 2775 pComponentPrivate->pHandle->pApplicationPrivate, 2776 OMX_EventCmdComplete, OMX_CommandStateSet, 2777 pComponentPrivate->curState, NULL); 2778 } 2779#ifdef _ERROR_PROPAGATION__ 2780 else if (event == EMMCodecInitError){ 2781 2782 2783 /* Cheking for MMU_fault */ 2784 if((args[4] == (void*)USN_ERR_UNKNOWN_MSG) && (args[5] == (void*)NULL)) { 2785 OMX_ERROR4(pComponentPrivate->dbg, "%d :: UTIL: MMU_Fault \n",__LINE__); 2786 pComponentPrivate->bIsInvalidState = OMX_TRUE; 2787 pComponentPrivate->curState = OMX_StateInvalid; 2788 pHandle = pComponentPrivate->pHandle; 2789 pComponentPrivate->cbInfo.EventHandler(pHandle, 2790 pHandle->pApplicationPrivate, 2791 OMX_EventError, 2792 OMX_ErrorHardware, 2793 OMX_TI_ErrorSevere, 2794 NULL); 2795 } 2796 } 2797 else if (event == EMMCodecInternalError){ 2798 2799 2800 2801 /* Cheking for MMU_fault */ 2802 if((args[4] == (void*)USN_ERR_UNKNOWN_MSG) && (args[5] == (void*)NULL)) { 2803 OMX_ERROR4(pComponentPrivate->dbg, "%d :: UTIL: MMU_Fault \n",__LINE__); 2804 pComponentPrivate->bIsInvalidState = OMX_TRUE; 2805 pComponentPrivate->curState = OMX_StateInvalid; 2806 pHandle = pComponentPrivate->pHandle; 2807 pComponentPrivate->cbInfo.EventHandler(pHandle, 2808 pHandle->pApplicationPrivate, 2809 OMX_EventError, 2810 OMX_ErrorHardware, 2811 OMX_TI_ErrorSevere, 2812 NULL); 2813 } 2814 2815 } 2816#endif 2817 EXIT: 2818 OMX_PRINT1(pComponentPrivate->dbg, ":: Exiting the LCML_Callback() \n"); 2819 2820 return eError; 2821} 2822 2823 2824/* ================================================================================= * */ 2825/** 2826 * @fn MP3DEC_GetCorresponding_LCMLHeader() function gets the corresponding LCML 2827 * header from the actual data buffer for required processing. 2828 * 2829 * @param *pBuffer This is the data buffer pointer. 2830 * 2831 * @param eDir This is direction of buffer. Input/Output. 2832 * 2833 * @param *MP3D_LCML_BUFHEADERTYPE This is pointer to LCML Buffer Header. 2834 * 2835 * @pre None 2836 * 2837 * @post None 2838 * 2839 * @return OMX_ErrorNone = Successful Inirialization of the component\n 2840 * OMX_ErrorHardware = Hardware error has occured. 2841 * 2842 * @see None 2843 */ 2844/* ================================================================================ * */ 2845OMX_ERRORTYPE MP3DEC_GetCorresponding_LCMLHeader(MP3DEC_COMPONENT_PRIVATE* pComponentPrivate, 2846 OMX_U8 *pBuffer, 2847 OMX_DIRTYPE eDir, 2848 MP3D_LCML_BUFHEADERTYPE **ppLcmlHdr) 2849{ 2850 OMX_ERRORTYPE eError = OMX_ErrorNone; 2851 MP3D_LCML_BUFHEADERTYPE *pLcmlBufHeader; 2852 int nIpBuf=0, nOpBuf=0, i=0; 2853 2854 OMX_PRINT1(pComponentPrivate->dbg, ":: Entering the MP3DEC_GetCorresponding_LCMLHeader()\n"); 2855 2856 OMX_PRINT2(pComponentPrivate->dbg, ":: eDir = %d\n",eDir); 2857 2858 while (!pComponentPrivate->bInitParamsInitialized) { 2859#ifndef UNDER_CE 2860 sched_yield(); 2861#else 2862 Sleep(0); 2863#endif 2864 } 2865 2866 2867 if(eDir == OMX_DirInput) { 2868 OMX_PRDSP2(pComponentPrivate->dbg, ":: In GetCorresponding_LCMLHeader()\n"); 2869 2870 nIpBuf = pComponentPrivate->pInputBufferList->numBuffers; 2871 2872 pLcmlBufHeader = pComponentPrivate->pLcmlBufHeader[MP3D_INPUT_PORT]; 2873 2874 for(i=0; i<nIpBuf; i++) { 2875 OMX_PRBUFFER2(pComponentPrivate->dbg, "pBuffer = %p\n",pBuffer); 2876 OMX_PRBUFFER2(pComponentPrivate->dbg, "pLcmlBufHeader->pBufHdr->pBuffer = %p\n",pLcmlBufHeader->pBufHdr->pBuffer); 2877 if(pBuffer == pLcmlBufHeader->pBufHdr->pBuffer) { 2878 *ppLcmlHdr = pLcmlBufHeader; 2879 OMX_PRINT1(pComponentPrivate->dbg, "::Corresponding LCML Header Found\n"); 2880 goto EXIT; 2881 } 2882 pLcmlBufHeader++; 2883 } 2884 } else if (eDir == OMX_DirOutput) { 2885 i = 0; 2886 nOpBuf = pComponentPrivate->pOutputBufferList->numBuffers; 2887 2888 pLcmlBufHeader = pComponentPrivate->pLcmlBufHeader[MP3D_OUTPUT_PORT]; 2889 OMX_PRBUFFER2(pComponentPrivate->dbg, ":: nOpBuf = %d\n",nOpBuf); 2890 2891 for(i=0; i<nOpBuf; i++) { 2892 OMX_PRBUFFER2(pComponentPrivate->dbg, "pBuffer = %p\n",pBuffer); 2893 OMX_PRBUFFER2(pComponentPrivate->dbg, "pLcmlBufHeader->pBufHdr->pBuffer = %p\n",pLcmlBufHeader->pBufHdr->pBuffer); 2894 2895 if(pBuffer == pLcmlBufHeader->pBufHdr->pBuffer) { 2896 *ppLcmlHdr = pLcmlBufHeader; 2897 OMX_PRINT1(pComponentPrivate->dbg, "::Corresponding LCML Header Found\n"); 2898 goto EXIT; 2899 } 2900 pLcmlBufHeader++; 2901 } 2902 } else { 2903 OMX_PRBUFFER2(pComponentPrivate->dbg, ":: Invalid Buffer Type :: exiting...\n"); 2904 } 2905 2906 EXIT: 2907 OMX_PRINT1(pComponentPrivate->dbg, ":: Exiting the GetCorresponding_LCMLHeader() \n"); 2908 return eError; 2909} 2910 2911/* ================================================================================= * */ 2912/** 2913 * @fn MP3DEC_GetLCMLHandle() function gets the LCML handle and interacts with LCML 2914 * by using this LCML Handle. 2915 * 2916 * @param *pBufHeader This is the buffer header that needs to be processed. 2917 * 2918 * @param *pComponentPrivate This is component's private date structure. 2919 * 2920 * @pre None 2921 * 2922 * @post None 2923 * 2924 * @return OMX_HANDLETYPE = Successful loading of LCML library. 2925 * OMX_ErrorHardware = Hardware error has occured. 2926 * 2927 * @see None 2928 */ 2929/* ================================================================================ * */ 2930#ifndef UNDER_CE 2931OMX_HANDLETYPE MP3DEC_GetLCMLHandle(MP3DEC_COMPONENT_PRIVATE *pComponentPrivate) 2932{ 2933 /* This must be taken care by WinCE */ 2934 OMX_HANDLETYPE pHandle = NULL; 2935 OMX_ERRORTYPE eError; 2936 void *handle; 2937 OMX_ERRORTYPE (*fpGetHandle)(OMX_HANDLETYPE); 2938 char *error; 2939 2940 handle = dlopen("libLCML.so", RTLD_LAZY); 2941 if (!handle) { 2942 fputs(dlerror(), stderr); 2943 goto EXIT; 2944 } 2945 2946 fpGetHandle = dlsym (handle, "GetHandle"); 2947 if ((error = dlerror()) != NULL) { 2948 fputs(error, stderr); 2949 goto EXIT; 2950 } 2951 eError = (*fpGetHandle)(&pHandle); 2952 if(eError != OMX_ErrorNone) { 2953 eError = OMX_ErrorUndefined; 2954 OMXDBG_PRINT(stderr, ERROR, 4, 0, "eError != OMX_ErrorNone...\n"); 2955 pHandle = NULL; 2956 goto EXIT; 2957 } 2958 2959 ((LCML_DSP_INTERFACE*)pHandle)->pComponentPrivate = pComponentPrivate; 2960 2961 EXIT: 2962 return pHandle; 2963} 2964#else 2965/* WINDOWS Explicit dll load procedure */ 2966OMX_HANDLETYPE MP3DEC_GetLCMLHandle(MP3DEC_COMPONENT_PRIVATE *pComponentPrivate) 2967{ 2968 typedef OMX_ERRORTYPE (*LPFNDLLFUNC1)(OMX_HANDLETYPE); 2969 OMX_HANDLETYPE pHandle = NULL; 2970 OMX_ERRORTYPE eError; 2971 LPFNDLLFUNC1 fpGetHandle1; 2972 2973 g_hLcmlDllHandle = LoadLibraryEx(TEXT("OAF_BML.dll"), NULL,0); 2974 if (g_hLcmlDllHandle == NULL) 2975 { 2976 /* fputs(dlerror(), stderr); */ 2977 OMXDBG_PRINT(stderr, ERROR, 4, 0, "BML Load Failed!!!\n"); 2978 return pHandle; 2979 } 2980 fpGetHandle1 = (LPFNDLLFUNC1)GetProcAddress(g_hLcmlDllHandle,TEXT("GetHandle")); 2981 if (!fpGetHandle1) 2982 { 2983 /* handle the error*/ 2984 FreeLibrary(g_hLcmlDllHandle); 2985 g_hLcmlDllHandle = NULL; 2986 return pHandle; 2987 } 2988 /* call the function */ 2989 eError = fpGetHandle1(&pHandle); 2990 if(eError != OMX_ErrorNone) 2991 { 2992 eError = OMX_ErrorUndefined; 2993 OMXDBG_PRINT(stderr, ERROR, 4, 0, "eError != OMX_ErrorNone...\n"); 2994 FreeLibrary(g_hLcmlDllHandle); 2995 g_hLcmlDllHandle = NULL; 2996 pHandle = NULL; 2997 return pHandle; 2998 } 2999 3000 ((LCML_DSP_INTERFACE*)pHandle)->pComponentPrivate = pComponentPrivate; 3001 3002 return pHandle; 3003} 3004#endif 3005 3006#ifndef UNDER_CE 3007OMX_ERRORTYPE MP3DECFreeLCMLHandle(MP3DEC_COMPONENT_PRIVATE *pComponentPrivate) 3008{ 3009 3010 OMX_S16 retValue; 3011 OMX_ERRORTYPE eError = OMX_ErrorNone; 3012 3013 if (pComponentPrivate->bLcmlHandleOpened) { 3014 retValue = dlclose(pComponentPrivate->pLcmlHandle); 3015 3016 if (retValue != 0) { 3017 eError = OMX_ErrorUndefined; 3018 } 3019 pComponentPrivate->bLcmlHandleOpened = 0; 3020 } 3021 3022 return eError; 3023} 3024#else 3025OMX_ERRORTYPE MP3DECFreeLCMLHandle(MP3DEC_COMPONENT_PRIVATE *pComponentPrivate) 3026{ 3027 3028 OMX_S16 retValue; 3029 OMX_ERRORTYPE eError = OMX_ErrorNone; 3030 3031 if (pComponentPrivate->bLcmlHandleOpened) { 3032 3033 retValue = FreeLibrary(pComponentPrivate->pLcmlHandle); 3034 if (retValue == 0) { /* Zero Indicates failure */ 3035 eError = OMX_ErrorUndefined; 3036 } 3037 pComponentPrivate->bLcmlHandleOpened = 0; 3038 } 3039 3040 return eError; 3041} 3042#endif 3043 3044/* ========================================================================== */ 3045/** 3046 * @MP3DEC_CleanupInitParams() This function is called by the component during 3047 * de-init to close component thread, Command pipe, data pipe & LCML pipe. 3048 * 3049 * @param pComponent handle for this instance of the component 3050 * 3051 * @pre 3052 * 3053 * @post 3054 * 3055 * @return none 3056 */ 3057/* ========================================================================== */ 3058 3059void MP3DEC_CleanupInitParams(OMX_HANDLETYPE pComponent) 3060{ 3061 OMX_COMPONENTTYPE *pHandle = (OMX_COMPONENTTYPE *)pComponent; 3062 MP3DEC_COMPONENT_PRIVATE *pComponentPrivate = (MP3DEC_COMPONENT_PRIVATE *) 3063 pHandle->pComponentPrivate; 3064 MP3D_LCML_BUFHEADERTYPE *pTemp_lcml; 3065 3066 OMX_U32 nIpBuf = pComponentPrivate->nRuntimeInputBuffers; 3067 OMX_U32 nOpBuf = pComponentPrivate->nRuntimeOutputBuffers; 3068 3069 OMX_U32 i=0; 3070 3071 OMX_PRINT1(pComponentPrivate->dbg, ":: MP3DEC_CleanupInitParams()\n"); 3072 3073 OMX_PRBUFFER2(pComponentPrivate->dbg, ":: Freeing: pComponentPrivate->strmAttr = %p\n", pComponentPrivate->strmAttr); 3074 OMX_MEMFREE_STRUCT(pComponentPrivate->strmAttr); 3075 3076 pTemp_lcml = pComponentPrivate->pLcmlBufHeader[MP3D_INPUT_PORT]; 3077 3078 for(i=0; i<nIpBuf; i++) { 3079 OMX_PRBUFFER2(pComponentPrivate->dbg, ":: Freeing: pTemp_lcml->pIpParam = %p\n",pTemp_lcml->pIpParam); 3080 OMX_MEMFREE_STRUCT_DSPALIGN(pTemp_lcml->pIpParam, MP3DEC_UAlgInBufParamStruct); 3081 3082 pTemp_lcml++; 3083 } 3084 3085 3086 3087 OMX_PRBUFFER2(pComponentPrivate->dbg, ":: Freeing pComponentPrivate->pLcmlBufHeader[MP3D_INPUT_PORT] = %p\n", 3088 pComponentPrivate->pLcmlBufHeader[MP3D_INPUT_PORT]); 3089 OMX_MEMFREE_STRUCT(pComponentPrivate->pLcmlBufHeader[MP3D_INPUT_PORT]); 3090 3091 pTemp_lcml = pComponentPrivate->pLcmlBufHeader[MP3D_OUTPUT_PORT]; 3092 for(i=0; i<nOpBuf; i++) { 3093 OMX_PRBUFFER2(pComponentPrivate->dbg, ":: Freeing: pTemp_lcml->pOpParam = %p\n",pTemp_lcml->pOpParam); 3094 OMX_MEMFREE_STRUCT_DSPALIGN(pTemp_lcml->pOpParam, MP3DEC_UAlgOutBufParamStruct); 3095 pTemp_lcml++; 3096 } 3097 3098 OMX_PRBUFFER2(pComponentPrivate->dbg, ":: Freeing: pComponentPrivate->pLcmlBufHeader[MP3D_OUTPUT_PORT] = %p\n", 3099 pComponentPrivate->pLcmlBufHeader[MP3D_OUTPUT_PORT]); 3100 OMX_MEMFREE_STRUCT(pComponentPrivate->pLcmlBufHeader[MP3D_OUTPUT_PORT]); 3101 3102 OMX_MEMFREE_STRUCT_DSPALIGN(pComponentPrivate->pParams, USN_AudioCodecParams); 3103 3104 OMX_MEMFREE_STRUCT_DSPALIGN(pComponentPrivate->ptAlgDynParams, MP3DEC_UALGParams); 3105 3106 OMX_PRINT1(pComponentPrivate->dbg, "Exiting Successfully MP3DEC_CleanupInitParams()\n"); 3107 3108} 3109 3110/* ========================================================================== */ 3111/** 3112* @MP3DEC_CleanupInitParamsEx() This function is called by the component during 3113* portreconfiguration after port disable to free LCML buffers. 3114* 3115* @param pComponent handle for this instance of the component 3116* 3117* @pre 3118* 3119* @post 3120* 3121* @return none 3122*/ 3123/* ========================================================================== */ 3124 3125void MP3DEC_CleanupInitParamsEx(OMX_HANDLETYPE pComponent,OMX_U32 indexport) 3126{ 3127 OMX_COMPONENTTYPE *pHandle = (OMX_COMPONENTTYPE *)pComponent; 3128 MP3DEC_COMPONENT_PRIVATE *pComponentPrivate = 3129 (MP3DEC_COMPONENT_PRIVATE *)pHandle->pComponentPrivate; 3130 MP3D_LCML_BUFHEADERTYPE *pTemp_lcml; 3131 OMX_U32 nIpBuf = 0; 3132 OMX_U32 nOpBuf = 0; 3133 OMX_U32 i=0; 3134 3135 if(indexport == 0 || indexport == -1){ 3136 nIpBuf = pComponentPrivate->nRuntimeInputBuffers; 3137 pTemp_lcml = pComponentPrivate->pLcmlBufHeader[MP3D_INPUT_PORT]; 3138 for(i=0; i<nIpBuf; i++) { 3139 OMX_PRBUFFER2(pComponentPrivate->dbg, "Freeing: pIpParam = %p\n", 3140 pTemp_lcml->pIpParam); 3141 OMX_MEMFREE_STRUCT_DSPALIGN(pTemp_lcml->pIpParam, MP3DEC_UAlgInBufParamStruct); 3142 pTemp_lcml++; 3143 } 3144 3145 OMX_PRBUFFER2(pComponentPrivate->dbg, "Freeing pLcmlBufHeader[MP3D_INPUT_PORT] = %p\n", 3146 pComponentPrivate->pLcmlBufHeader[MP3D_INPUT_PORT]); 3147 OMX_MEMFREE_STRUCT(pComponentPrivate->pLcmlBufHeader[MP3D_INPUT_PORT]); 3148 3149 }else if(indexport == 1 || indexport == -1){ 3150 nOpBuf = pComponentPrivate->nRuntimeOutputBuffers; 3151 pTemp_lcml = pComponentPrivate->pLcmlBufHeader[MP3D_OUTPUT_PORT]; 3152 for(i=0; i<nOpBuf; i++) { 3153 OMX_PRBUFFER2(pComponentPrivate->dbg, "Freeing: pOpParam = %p\n", 3154 pTemp_lcml->pOpParam); 3155 OMX_MEMFREE_STRUCT_DSPALIGN(pTemp_lcml->pOpParam, MP3DEC_UAlgOutBufParamStruct); 3156 pTemp_lcml++; 3157 } 3158 3159 OMX_PRBUFFER2(pComponentPrivate->dbg, "Freeing: pLcmlBufHeader[MP3D_OUTPUT_PORT] = %p\n", 3160 pComponentPrivate->pLcmlBufHeader[MP3D_OUTPUT_PORT]); 3161 OMX_MEMFREE_STRUCT(pComponentPrivate->pLcmlBufHeader[MP3D_OUTPUT_PORT]); 3162 3163 }else{ 3164 OMX_ERROR4(pComponentPrivate->dbg, "Bad indexport!\n"); 3165 } 3166} 3167 3168/* ========================================================================== */ 3169/** 3170 * @MP3DEC_SetPending() This function marks the buffer as pending when it is sent 3171 * to DSP/ 3172 * 3173 * @param pComponentPrivate This is component's private date area. 3174 * 3175 * @param pBufHdr This is poiter to OMX Buffer header whose buffer is sent to DSP 3176 * 3177 * @param eDir This is direction of buffer i.e. input or output. 3178 * 3179 * @pre None 3180 * 3181 * @post None 3182 * 3183 * @return none 3184 */ 3185/* ========================================================================== */ 3186void MP3DEC_SetPending(MP3DEC_COMPONENT_PRIVATE *pComponentPrivate, OMX_BUFFERHEADERTYPE *pBufHdr, OMX_DIRTYPE eDir, OMX_U32 lineNumber) 3187{ 3188 OMX_U16 i; 3189 3190 if (eDir == OMX_DirInput) { 3191 for (i=0; i < pComponentPrivate->pInputBufferList->numBuffers; i++) { 3192 if (pBufHdr == pComponentPrivate->pInputBufferList->pBufHdr[i]) { 3193 pComponentPrivate->pInputBufferList->bBufferPending[i] = 1; 3194 OMX_PRBUFFER2(pComponentPrivate->dbg, "INPUT BUFFER %d IS PENDING Line %ld\n",i,lineNumber); 3195 } 3196 } 3197 } 3198 else { 3199 for (i=0; i < pComponentPrivate->pOutputBufferList->numBuffers; i++) { 3200 if (pBufHdr == pComponentPrivate->pOutputBufferList->pBufHdr[i]) { 3201 pComponentPrivate->pOutputBufferList->bBufferPending[i] = 1; 3202 OMX_PRBUFFER2(pComponentPrivate->dbg, "OUTPUT BUFFER %d IS PENDING Line %ld\n",i,lineNumber); 3203 } 3204 } 3205 } 3206} 3207 3208/* ========================================================================== */ 3209/** 3210 * @MP3DEC_ClearPending() This function clears the buffer status from pending 3211 * when it is received back from DSP. 3212 * 3213 * @param pComponentPrivate This is component's private date area. 3214 * 3215 * @param pBufHdr This is poiter to OMX Buffer header that is received from 3216 * DSP/LCML. 3217 * 3218 * @param eDir This is direction of buffer i.e. input or output. 3219 * 3220 * @pre None 3221 * 3222 * @post None 3223 * 3224 * @return none 3225 */ 3226/* ========================================================================== */ 3227 3228void MP3DEC_ClearPending(MP3DEC_COMPONENT_PRIVATE *pComponentPrivate, OMX_BUFFERHEADERTYPE *pBufHdr, OMX_DIRTYPE eDir, OMX_U32 lineNumber) 3229{ 3230 OMX_U16 i; 3231 3232 if (eDir == OMX_DirInput) { 3233 for (i=0; i < pComponentPrivate->pInputBufferList->numBuffers; i++) { 3234 if (pBufHdr == pComponentPrivate->pInputBufferList->pBufHdr[i]) { 3235 pComponentPrivate->pInputBufferList->bBufferPending[i] = 0; 3236 OMX_PRBUFFER2(pComponentPrivate->dbg, "INPUT BUFFER %d IS RECLAIMED Line %ld\n",i,lineNumber); 3237 } 3238 } 3239 } 3240 else { 3241 for (i=0; i < pComponentPrivate->pOutputBufferList->numBuffers; i++) { 3242 if (pBufHdr == pComponentPrivate->pOutputBufferList->pBufHdr[i]) { 3243 pComponentPrivate->pOutputBufferList->bBufferPending[i] = 0; 3244 OMX_PRBUFFER2(pComponentPrivate->dbg, "OUTPUT BUFFER %d IS RECLAIMED Line %ld\n",i,lineNumber); 3245 } 3246 } 3247 } 3248} 3249 3250/* ========================================================================== */ 3251/** 3252 * @MP3DEC_IsPending() This function checks whether or not a buffer is pending. 3253 * 3254 * @param pComponentPrivate This is component's private date area. 3255 * 3256 * @param pBufHdr This is poiter to OMX Buffer header of interest. 3257 * 3258 * @param eDir This is direction of buffer i.e. input or output. 3259 * 3260 * @pre None 3261 * 3262 * @post None 3263 * 3264 * @return none 3265 */ 3266/* ========================================================================== */ 3267 3268OMX_U32 MP3DEC_IsPending(MP3DEC_COMPONENT_PRIVATE *pComponentPrivate, OMX_BUFFERHEADERTYPE *pBufHdr, OMX_DIRTYPE eDir) 3269{ 3270 OMX_U16 i; 3271 3272 if (eDir == OMX_DirInput) { 3273 for (i=0; i < pComponentPrivate->pInputBufferList->numBuffers; i++) { 3274 if (pBufHdr == pComponentPrivate->pInputBufferList->pBufHdr[i]) { 3275 return pComponentPrivate->pInputBufferList->bBufferPending[i]; 3276 } 3277 } 3278 } 3279 else { 3280 for (i=0; i < pComponentPrivate->pOutputBufferList->numBuffers; i++) { 3281 if (pBufHdr == pComponentPrivate->pOutputBufferList->pBufHdr[i]) { 3282 return pComponentPrivate->pOutputBufferList->bBufferPending[i]; 3283 } 3284 } 3285 } 3286 return -1; 3287} 3288 3289 3290/* ========================================================================== */ 3291/** 3292 * @MP3DEC_IsValid() This function identifies whether or not buffer recieved from 3293 * LCML is valid. It searches in the list of input/output buffers to do this. 3294 * 3295 * @param pComponentPrivate This is component's private date area. 3296 * 3297 * @param pBufHdr This is poiter to OMX Buffer header of interest. 3298 * 3299 * @param eDir This is direction of buffer i.e. input or output. 3300 * 3301 * @pre None 3302 * 3303 * @post None 3304 * 3305 * @return status of the buffer. 3306 */ 3307/* ========================================================================== */ 3308 3309OMX_U32 MP3DEC_IsValid(MP3DEC_COMPONENT_PRIVATE *pComponentPrivate, OMX_U8 *pBuffer, OMX_DIRTYPE eDir) 3310{ 3311 OMX_U16 i; 3312 int found=0; 3313 3314 if (eDir == OMX_DirInput) { 3315 for (i=0; i < pComponentPrivate->pInputBufferList->numBuffers; i++) { 3316 if (pBuffer == pComponentPrivate->pInputBufferList->pBufHdr[i]->pBuffer) { 3317 found = 1; 3318 } 3319 } 3320 } 3321 else { 3322 for (i=0; i < pComponentPrivate->pOutputBufferList->numBuffers; i++) { 3323 if (pBuffer == pComponentPrivate->pOutputBufferList->pBufHdr[i]->pBuffer) { 3324 found = 1; 3325 } 3326 } 3327 } 3328 return found; 3329} 3330 3331/* ========================================================================== */ 3332/** 3333 * @MP3DECFill_LCMLInitParamsEx() This function initializes the init parameter of 3334 * the LCML structure when a port is enabled and component is in idle state. 3335 * 3336 * @param pComponent This is component handle. 3337 * 3338 * @pre None 3339 * 3340 * @post None 3341 * 3342 * @return appropriate OMX Error. 3343 */ 3344/* ========================================================================== */ 3345 3346OMX_ERRORTYPE MP3DECFill_LCMLInitParamsEx(OMX_HANDLETYPE pComponent, OMX_U32 indexport) 3347 3348{ 3349 OMX_ERRORTYPE eError = OMX_ErrorNone; 3350 OMX_U32 nIpBuf,nIpBufSize,nOpBuf,nOpBufSize; 3351 OMX_U16 i; 3352 OMX_BUFFERHEADERTYPE *pTemp; 3353 OMX_COMPONENTTYPE *pHandle = (OMX_COMPONENTTYPE *)pComponent; 3354 MP3DEC_COMPONENT_PRIVATE *pComponentPrivate = 3355 (MP3DEC_COMPONENT_PRIVATE *)pHandle->pComponentPrivate; 3356 MP3D_LCML_BUFHEADERTYPE *pTemp_lcml; 3357 OMX_U32 size_lcml; 3358 OMX_U8 *ptr; 3359 3360 OMX_PRINT1(pComponentPrivate->dbg, ":: Entered Fill_LCMLInitParams"); 3361 3362 nIpBuf = pComponentPrivate->pInputBufferList->numBuffers; 3363 nOpBuf = pComponentPrivate->pOutputBufferList->numBuffers; 3364 nIpBufSize = pComponentPrivate->pPortDef[MP3D_INPUT_PORT]->nBufferSize; 3365 nOpBufSize = pComponentPrivate->pPortDef[MP3D_OUTPUT_PORT]->nBufferSize; 3366 3367 OMX_PRBUFFER2(pComponentPrivate->dbg, "Input Buffer Count = %ld\n",nIpBuf); 3368 OMX_PRBUFFER2(pComponentPrivate->dbg, "Input Buffer Size = %ld\n",nIpBufSize); 3369 OMX_PRBUFFER2(pComponentPrivate->dbg, "Output Buffer Count = %ld\n",nOpBuf); 3370 OMX_PRBUFFER2(pComponentPrivate->dbg, "Output Buffer Size = %ld\n",nOpBufSize); 3371 3372 if(indexport == 0 || indexport == -1){ 3373 3374 OMX_PRBUFFER2(pComponentPrivate->dbg, ":: bufAlloced = %d\n",pComponentPrivate->bufAlloced); 3375 size_lcml = nIpBuf * sizeof(MP3D_LCML_BUFHEADERTYPE); 3376 3377 OMX_MALLOC_SIZE(ptr,size_lcml,OMX_U8); 3378 pTemp_lcml = (MP3D_LCML_BUFHEADERTYPE *)ptr; 3379 3380 pComponentPrivate->pLcmlBufHeader[MP3D_INPUT_PORT] = pTemp_lcml; 3381 3382 for (i=0; i<nIpBuf; i++) { 3383 pTemp = pComponentPrivate->pInputBufferList->pBufHdr[i]; 3384 pTemp->nSize = sizeof(OMX_BUFFERHEADERTYPE); 3385 3386 pTemp->nAllocLen = nIpBufSize; 3387 pTemp->nFilledLen = nIpBufSize; 3388 pTemp->nVersion.s.nVersionMajor = MP3DEC_MAJOR_VER; 3389 pTemp->nVersion.s.nVersionMinor = MP3DEC_MINOR_VER; 3390 3391 pTemp->pPlatformPrivate = pHandle->pComponentPrivate; 3392 pTemp->nTickCount = 0; 3393 3394 pTemp_lcml->pBufHdr = pTemp; 3395 pTemp_lcml->eDir = OMX_DirInput; 3396 pTemp_lcml->pOtherParams[i] = NULL; 3397 3398 OMX_MALLOC_SIZE_DSPALIGN(pTemp_lcml->pIpParam, 3399 sizeof(MP3DEC_UAlgInBufParamStruct), 3400 MP3DEC_UAlgInBufParamStruct); 3401 pTemp_lcml->pIpParam->bLastBuffer = 0; 3402 3403 pTemp->nFlags = NORMAL_BUFFER; 3404 ((MP3DEC_COMPONENT_PRIVATE *) pTemp->pPlatformPrivate)->pHandle = pHandle; 3405 3406 OMX_PRBUFFER2(pComponentPrivate->dbg, "::Comp: InBuffHeader[%d] = %p\n", i, pTemp); 3407 OMX_PRBUFFER2(pComponentPrivate->dbg, "::Comp: >>>> InputBuffHeader[%d]->pBuffer = %p\n", i, pTemp->pBuffer); 3408 OMX_PRBUFFER2(pComponentPrivate->dbg, "::Comp: Ip : pTemp_lcml[%d] = %p\n", i, pTemp_lcml); 3409 3410 pTemp_lcml++; 3411 } 3412 } 3413 3414 if(indexport == 1 || indexport == -1){ 3415 size_lcml = nOpBuf * sizeof(MP3D_LCML_BUFHEADERTYPE); 3416 OMX_MALLOC_SIZE(pTemp_lcml,size_lcml,MP3D_LCML_BUFHEADERTYPE); 3417 pComponentPrivate->pLcmlBufHeader[MP3D_OUTPUT_PORT] = pTemp_lcml; 3418 3419 for (i=0; i<nOpBuf; i++) { 3420 pTemp = pComponentPrivate->pOutputBufferList->pBufHdr[i]; 3421 pTemp->nSize = sizeof(OMX_BUFFERHEADERTYPE); 3422 pTemp->nAllocLen = nOpBufSize; 3423 pTemp->nFilledLen = nOpBufSize; 3424 pTemp->nVersion.s.nVersionMajor = MP3DEC_MAJOR_VER; 3425 pTemp->nVersion.s.nVersionMinor = MP3DEC_MINOR_VER; 3426 3427 pTemp->pPlatformPrivate = pHandle->pComponentPrivate; 3428 pTemp->nTickCount = 0; 3429 3430 pTemp_lcml->pBufHdr = pTemp; 3431 pTemp_lcml->eDir = OMX_DirOutput; 3432 pTemp_lcml->pOtherParams[i] = NULL; 3433 3434 OMX_MALLOC_SIZE_DSPALIGN(pTemp_lcml->pOpParam, 3435 sizeof(MP3DEC_UAlgOutBufParamStruct), 3436 MP3DEC_UAlgOutBufParamStruct); 3437 pTemp_lcml->pOpParam->ulFrameCount = DONT_CARE; 3438 pTemp_lcml->pOpParam->ulIsLastBuffer = 0; 3439 3440 pTemp->nFlags = NORMAL_BUFFER; 3441 ((MP3DEC_COMPONENT_PRIVATE *)pTemp->pPlatformPrivate)->pHandle = pHandle; 3442 OMX_PRBUFFER2(pComponentPrivate->dbg, "::Comp: >>>>>>>>>>>>> OutBuffHeader[%d] = %p\n", i, pTemp); 3443 OMX_PRBUFFER2(pComponentPrivate->dbg, "::Comp: >>>> OutBuffHeader[%d]->pBuffer = %p\n", i, pTemp->pBuffer); 3444 OMX_PRBUFFER2(pComponentPrivate->dbg, "::Comp: Op : pTemp_lcml[%d] = %p\n", i, pTemp_lcml); 3445 pTemp_lcml++; 3446 } 3447 } 3448 pComponentPrivate->bPortDefsAllocated = 1; 3449 3450 OMX_PRINT1(pComponentPrivate->dbg, ":: Exiting Fill_LCMLInitParams"); 3451 3452 pComponentPrivate->bInitParamsInitialized = 1; 3453 3454 EXIT: 3455 return eError; 3456} 3457 3458 3459OMX_U32 MP3DEC_GetBits(OMX_U32* nPosition, OMX_U8 nBits, OMX_U8* pBuffer, OMX_BOOL bIcreasePosition) 3460{ 3461 OMX_U32 nOutput; 3462 OMX_U32 nNumBitsRead = 0; 3463 OMX_U32 nBytePosition = 0; 3464 OMX_U8 nBitPosition = 0; 3465 nBytePosition = *nPosition / 8; 3466 nBitPosition = *nPosition % 8; 3467 3468 if (bIcreasePosition) 3469 *nPosition += nBits; 3470 nOutput = ((OMX_U32)pBuffer[nBytePosition] << (24+nBitPosition) ); 3471 nNumBitsRead = nNumBitsRead + (8 - nBitPosition); 3472 if (nNumBitsRead < nBits) 3473 { 3474 nOutput = nOutput | ( pBuffer[nBytePosition + 1] << (16+nBitPosition)); 3475 nNumBitsRead = nNumBitsRead + 8; 3476 } 3477 if (nNumBitsRead < nBits) 3478 { 3479 nOutput = nOutput | ( pBuffer[nBytePosition + 2] << (8+nBitPosition)); 3480 nNumBitsRead = nNumBitsRead + 8; 3481 } 3482 if (nNumBitsRead < nBits) 3483 { 3484 nOutput = nOutput | ( pBuffer[nBytePosition + 3] << (nBitPosition)); 3485 nNumBitsRead = nNumBitsRead + 8; 3486 } 3487 nOutput = nOutput >> (32 - nBits) ; 3488 return nOutput; 3489} 3490 3491/* ========================================================================== */ 3492/** 3493* @SignalIfAllBuffersAreReturned() This function send signals if OMX returned all buffers to app 3494* 3495* @param AACDEC_COMPONENT_PRIVATE *pComponentPrivate 3496* 3497* @pre None 3498* 3499* @post None 3500* 3501* @return None 3502*/ 3503/* ========================================================================== */ 3504void SignalIfAllBuffersAreReturned(MP3DEC_COMPONENT_PRIVATE *pComponentPrivate) 3505{ 3506 if((pComponentPrivate->nEmptyThisBufferCount == pComponentPrivate->nEmptyBufferDoneCount) && (pComponentPrivate->nFillThisBufferCount == pComponentPrivate->nFillBufferDoneCount)) 3507 { 3508 if(pthread_mutex_lock(&bufferReturned_mutex) != 0) 3509 { 3510 OMX_ERROR4(pComponentPrivate->dbg, "%d :: bufferReturned_mutex mutex lock error\n",__LINE__); 3511 } 3512 pthread_cond_broadcast(&bufferReturned_condition); 3513 OMX_PRINT2(pComponentPrivate->dbg, ":: Sending pthread signal that OMX has returned all buffers to app\n"); 3514 if(pthread_mutex_unlock(&bufferReturned_mutex) != 0) 3515 { 3516 OMX_ERROR4(pComponentPrivate->dbg, "%d :: bufferReturned_mutex mutex unlock error\n",__LINE__); 3517 } 3518 return; 3519 } 3520} 3521 3522/* =========================================================================*/ 3523/* func MP3DEC_HandleUSNError 3524/* 3525/* desc Handles error messages returned by the dsp 3526/* 3527/*@return n/a 3528/* 3529/* =========================================================================*/ 3530void MP3DEC_HandleUSNError (MP3DEC_COMPONENT_PRIVATE *pComponentPrivate, OMX_U32 arg) 3531{ 3532 OMX_COMPONENTTYPE *pHandle = NULL; 3533 OMX_U8 pending_buffers = OMX_FALSE; 3534 OMX_U32 i; 3535 switch (arg) 3536 { 3537 case IUALG_WARN_CONCEALED: 3538 case IUALG_WARN_UNDERFLOW: 3539 case IUALG_WARN_OVERFLOW: 3540 case IUALG_WARN_ENDOFDATA: 3541 OMX_ERROR4(pComponentPrivate->dbg, "Algorithm Error" ); 3542 /* all of these are informative messages, Algo can recover, no need to notify the 3543 * IL Client at this stage of the implementation */ 3544 break; 3545 case IUALG_WARN_PLAYCOMPLETED: 3546 3547 { 3548 OMX_ERROR4(pComponentPrivate->dbg, "IUALG_WARN_PLAYCOMPLETED!\n"); 3549#ifndef UNDER_CE 3550 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 3551 pComponentPrivate->pHandle->pApplicationPrivate, 3552 OMX_EventBufferFlag, 3553 OMX_DirOutput, 3554 OMX_BUFFERFLAG_EOS, 3555 NULL); 3556 if(pComponentPrivate->dasfmode){ 3557 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 3558 pComponentPrivate->pHandle->pApplicationPrivate, 3559 OMX_EventBufferFlag, 3560 (OMX_U32)NULL, 3561 OMX_BUFFERFLAG_EOS, 3562 NULL); 3563 } 3564 pComponentPrivate->pLcmlBufHeader[0]->pIpParam->bLastBuffer = 0; 3565#else 3566 /* add callback to application to indicate SN/USN has completed playing of current set of date */ 3567 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 3568 pComponentPrivate->pHandle->pApplicationPrivate, 3569 OMX_EventBufferFlag, 3570 (OMX_U32)NULL, 3571 OMX_BUFFERFLAG_EOS, 3572 NULL); 3573#endif 3574 } 3575 break; 3576 3577#ifdef _ERROR_PROPAGATION__ 3578 case IUALG_ERR_BAD_HANDLE: 3579 case IUALG_ERR_DATA_CORRUPT: 3580 case IUALG_ERR_NOT_SUPPORTED: 3581 case IUALG_ERR_ARGUMENT: 3582 case IUALG_ERR_NOT_READY: 3583 case IUALG_ERR_GENERAL: 3584 3585 { 3586 /* all of these are fatal messages, Algo can not recover 3587 * hence return an error */ 3588 OMX_ERROR4(pComponentPrivate->dbg, "Algorithm Error, cannot recover" ); 3589 pComponentPrivate->bIsInvalidState=OMX_TRUE; 3590 pComponentPrivate->curState = OMX_StateInvalid; 3591 pHandle = pComponentPrivate->pHandle; 3592 pComponentPrivate->cbInfo.EventHandler(pHandle, 3593 pHandle->pApplicationPrivate, 3594 OMX_EventError, 3595 OMX_ErrorInvalidState, 3596 OMX_TI_ErrorSevere, 3597 NULL); 3598 } 3599 break; 3600#endif 3601 default: 3602 break; 3603 } 3604} 3605 3606#ifdef RESOURCE_MANAGER_ENABLED 3607void MP3_ResourceManagerCallback(RMPROXY_COMMANDDATATYPE cbData) 3608{ 3609 OMX_COMMANDTYPE Cmd = OMX_CommandStateSet; 3610 OMX_STATETYPE state = OMX_StateIdle; 3611 OMX_COMPONENTTYPE *pHandle = (OMX_COMPONENTTYPE *)cbData.hComponent; 3612 MP3DEC_COMPONENT_PRIVATE *pCompPrivate = NULL; 3613 3614 pCompPrivate = (MP3DEC_COMPONENT_PRIVATE *)pHandle->pComponentPrivate; 3615 3616 if (*(cbData.RM_Error) == OMX_RmProxyCallback_ResourcesPreempted) { 3617 if (pCompPrivate->curState == OMX_StateExecuting || 3618 pCompPrivate->curState == OMX_StatePause) { 3619 write (pCompPrivate->cmdPipe[1], &Cmd, sizeof(Cmd)); 3620 write (pCompPrivate->cmdDataPipe[1], &state ,sizeof(OMX_U32)); 3621 pCompPrivate->bPreempted = 1; 3622 } 3623 } 3624 else if (*(cbData.RM_Error) == OMX_RmProxyCallback_ResourcesAcquired){ 3625 pCompPrivate->cbInfo.EventHandler (pHandle, 3626 pHandle->pApplicationPrivate, 3627 OMX_EventResourcesAcquired, 0,0, 3628 NULL); 3629 } 3630} 3631#endif 3632