import exynos 7570 bsp
[GitHub/LineageOS/android_hardware_samsung_slsi_openmax.git] / component / audio / seiren_dec / aac / Exynos_OMX_Aacdec.c
1 /*
2 *
3 * Copyright 2012 Samsung Electronics S.LSI Co. LTD
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 /*
19 * @file Exynos_OMX_Aacdec.c
20 * @brief
21 * @author Sungyeon Kim (sy85.kim@samsung.com)
22 * @version 1.0.0
23 * @history
24 * 2012.12.22 : Create
25 */
26
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <string.h>
30
31 #include "Exynos_OMX_Macros.h"
32 #include "Exynos_OMX_Basecomponent.h"
33 #include "Exynos_OMX_Baseport.h"
34 #include "Exynos_OMX_Adec.h"
35 #include "Exynos_OSAL_ETC.h"
36 #include "Exynos_OSAL_Semaphore.h"
37 #include "Exynos_OSAL_Thread.h"
38 #include "library_register.h"
39 #include "Exynos_OMX_Aacdec.h"
40
41 #undef EXYNOS_LOG_TAG
42 #define EXYNOS_LOG_TAG "EXYNOS_AAC_DEC"
43 #define EXYNOS_LOG_OFF
44 #include "Exynos_OSAL_Log.h"
45
46 //#define Seiren_DUMP_TO_FILE
47 #ifdef Seiren_DUMP_TO_FILE
48 #include "stdio.h"
49
50 FILE *inFile;
51 FILE *outFile;
52 #endif
53
54 OMX_ERRORTYPE Exynos_Seiren_AacDec_GetParameter(
55 OMX_IN OMX_HANDLETYPE hComponent,
56 OMX_IN OMX_INDEXTYPE nParamIndex,
57 OMX_INOUT OMX_PTR pComponentParameterStructure)
58 {
59 OMX_ERRORTYPE ret = OMX_ErrorNone;
60 OMX_COMPONENTTYPE *pOMXComponent = NULL;
61 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
62
63 FunctionIn();
64
65 if (hComponent == NULL || pComponentParameterStructure == NULL) {
66 ret = OMX_ErrorBadParameter;
67 goto EXIT;
68 }
69 pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
70 ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
71 if (ret != OMX_ErrorNone) {
72 goto EXIT;
73 }
74 if (pOMXComponent->pComponentPrivate == NULL) {
75 ret = OMX_ErrorBadParameter;
76 goto EXIT;
77 }
78
79 pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
80 if (pExynosComponent->currentState == OMX_StateInvalid ) {
81 ret = OMX_ErrorInvalidState;
82 goto EXIT;
83 }
84
85 switch (nParamIndex) {
86 case OMX_IndexParamAudioAac:
87 {
88 OMX_AUDIO_PARAM_AACPROFILETYPE *pDstAacParam = (OMX_AUDIO_PARAM_AACPROFILETYPE *)pComponentParameterStructure;
89 OMX_AUDIO_PARAM_AACPROFILETYPE *pSrcAacParam = NULL;
90 EXYNOS_AAC_HANDLE *pAacDec = NULL;
91
92 ret = Exynos_OMX_Check_SizeVersion(pDstAacParam, sizeof(OMX_AUDIO_PARAM_AACPROFILETYPE));
93 if (ret != OMX_ErrorNone) {
94 goto EXIT;
95 }
96
97 if (pDstAacParam->nPortIndex >= ALL_PORT_NUM) {
98 ret = OMX_ErrorBadPortIndex;
99 goto EXIT;
100 }
101
102 pAacDec = (EXYNOS_AAC_HANDLE *)((EXYNOS_OMX_AUDIODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
103 pSrcAacParam = &pAacDec->aacParam;
104
105 Exynos_OSAL_Memcpy(pDstAacParam, pSrcAacParam, sizeof(OMX_AUDIO_PARAM_AACPROFILETYPE));
106 }
107 break;
108 case OMX_IndexParamAudioPcm:
109 {
110 OMX_AUDIO_PARAM_PCMMODETYPE *pDstPcmParam = (OMX_AUDIO_PARAM_PCMMODETYPE *)pComponentParameterStructure;
111 OMX_AUDIO_PARAM_PCMMODETYPE *pSrcPcmParam = NULL;
112 EXYNOS_AAC_HANDLE *pAacDec = NULL;
113
114 ret = Exynos_OMX_Check_SizeVersion(pDstPcmParam, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE));
115 if (ret != OMX_ErrorNone) {
116 goto EXIT;
117 }
118
119 if (pDstPcmParam->nPortIndex >= ALL_PORT_NUM) {
120 ret = OMX_ErrorBadPortIndex;
121 goto EXIT;
122 }
123
124 pAacDec = (EXYNOS_AAC_HANDLE *)((EXYNOS_OMX_AUDIODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
125 pSrcPcmParam = &pAacDec->pcmParam;
126
127 Exynos_OSAL_Memcpy(pDstPcmParam, pSrcPcmParam, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE));
128 }
129 break;
130 case OMX_IndexParamStandardComponentRole:
131 {
132 OMX_S32 codecType;
133 OMX_PARAM_COMPONENTROLETYPE *pComponentRole = (OMX_PARAM_COMPONENTROLETYPE *)pComponentParameterStructure;
134
135 ret = Exynos_OMX_Check_SizeVersion(pComponentRole, sizeof(OMX_PARAM_COMPONENTROLETYPE));
136 if (ret != OMX_ErrorNone) {
137 goto EXIT;
138 }
139
140 Exynos_OSAL_Strcpy((char *)pComponentRole->cRole, EXYNOS_OMX_COMPONENT_AAC_DEC_ROLE);
141 }
142 break;
143 default:
144 ret = Exynos_OMX_AudioDecodeGetParameter(hComponent, nParamIndex, pComponentParameterStructure);
145 break;
146 }
147 EXIT:
148 FunctionOut();
149
150 return ret;
151 }
152
153 OMX_ERRORTYPE Exynos_Seiren_AacDec_SetParameter(
154 OMX_IN OMX_HANDLETYPE hComponent,
155 OMX_IN OMX_INDEXTYPE nIndex,
156 OMX_IN OMX_PTR pComponentParameterStructure)
157 {
158 OMX_ERRORTYPE ret = OMX_ErrorNone;
159 OMX_COMPONENTTYPE *pOMXComponent = NULL;
160 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
161
162 FunctionIn();
163
164 if (hComponent == NULL || pComponentParameterStructure == NULL) {
165 ret = OMX_ErrorBadParameter;
166 goto EXIT;
167 }
168 pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
169 ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
170 if (ret != OMX_ErrorNone) {
171 goto EXIT;
172 }
173 if (pOMXComponent->pComponentPrivate == NULL) {
174 ret = OMX_ErrorBadParameter;
175 goto EXIT;
176 }
177
178 pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
179 if (pExynosComponent->currentState == OMX_StateInvalid ) {
180 ret = OMX_ErrorInvalidState;
181 goto EXIT;
182 }
183
184 switch (nIndex) {
185 case OMX_IndexParamAudioAac:
186 {
187 OMX_AUDIO_PARAM_AACPROFILETYPE *pDstAacParam = NULL;
188 OMX_AUDIO_PARAM_AACPROFILETYPE *pSrcAacParam = (OMX_AUDIO_PARAM_AACPROFILETYPE *)pComponentParameterStructure;
189 EXYNOS_AAC_HANDLE *pAacDec = NULL;
190
191 ret = Exynos_OMX_Check_SizeVersion(pSrcAacParam, sizeof(OMX_AUDIO_PARAM_AACPROFILETYPE));
192 if (ret != OMX_ErrorNone) {
193 goto EXIT;
194 }
195
196 if (pSrcAacParam->nPortIndex >= ALL_PORT_NUM) {
197 ret = OMX_ErrorBadPortIndex;
198 goto EXIT;
199 }
200
201 pAacDec = (EXYNOS_AAC_HANDLE *)((EXYNOS_OMX_AUDIODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
202 pDstAacParam = &pAacDec->aacParam;
203
204 Exynos_OSAL_Memcpy(pDstAacParam, pSrcAacParam, sizeof(OMX_AUDIO_PARAM_AACPROFILETYPE));
205 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "\e[1;33;46m nSize : %d \e[0m", pDstAacParam->nSize);
206 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "\e[1;33;46m nPortIndex : %d \e[0m", pDstAacParam->nPortIndex);
207 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "\e[1;33;46m nChannels : %d \e[0m", pDstAacParam->nChannels);
208 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "\e[1;33;46m nSampleRate : %d \e[0m", pDstAacParam->nSampleRate);
209 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "\e[1;33;46m nBitRate : %d \e[0m", pDstAacParam->nBitRate);
210 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "\e[1;33;46m nAudioBandWidth : %d \e[0m", pDstAacParam->nAudioBandWidth);
211 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "\e[1;33;46m nFrameLength : %d \e[0m", pDstAacParam->nFrameLength);
212 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "\e[1;33;46m nAACtools : %d \e[0m", pDstAacParam->nAACtools);
213 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "\e[1;33;46m nAACERtools : %d \e[0m", pDstAacParam->nAACERtools);
214 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "\e[1;33;46m eAACProfile : %d \e[0m", pDstAacParam->eAACProfile);
215 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "\e[1;33;46m eAACStreamFormat : %d \e[0m", pDstAacParam->eAACStreamFormat);
216 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "\e[1;33;46m eChannelMode : %d \e[0m", pDstAacParam->eChannelMode);
217 }
218 break;
219 case OMX_IndexParamAudioPcm:
220 {
221 OMX_AUDIO_PARAM_PCMMODETYPE *pDstPcmParam = NULL;
222 OMX_AUDIO_PARAM_PCMMODETYPE *pSrcPcmParam = (OMX_AUDIO_PARAM_PCMMODETYPE *)pComponentParameterStructure;
223 EXYNOS_AAC_HANDLE *pAacDec = NULL;
224
225 ret = Exynos_OMX_Check_SizeVersion(pSrcPcmParam, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE));
226 if (ret != OMX_ErrorNone) {
227 goto EXIT;
228 }
229
230 if (pSrcPcmParam->nPortIndex >= ALL_PORT_NUM) {
231 ret = OMX_ErrorBadPortIndex;
232 goto EXIT;
233 }
234
235 pAacDec = (EXYNOS_AAC_HANDLE *)((EXYNOS_OMX_AUDIODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
236 pDstPcmParam = &pAacDec->pcmParam;
237
238 Exynos_OSAL_Memcpy(pDstPcmParam, pSrcPcmParam, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE));
239 }
240 break;
241 case OMX_IndexParamStandardComponentRole:
242 {
243 OMX_PARAM_COMPONENTROLETYPE *pComponentRole = (OMX_PARAM_COMPONENTROLETYPE*)pComponentParameterStructure;
244
245 ret = Exynos_OMX_Check_SizeVersion(pComponentRole, sizeof(OMX_PARAM_COMPONENTROLETYPE));
246 if (ret != OMX_ErrorNone) {
247 goto EXIT;
248 }
249
250 if ((pExynosComponent->currentState != OMX_StateLoaded) && (pExynosComponent->currentState != OMX_StateWaitForResources)) {
251 ret = OMX_ErrorIncorrectStateOperation;
252 goto EXIT;
253 }
254
255 if (!Exynos_OSAL_Strcmp((char*)pComponentRole->cRole, EXYNOS_OMX_COMPONENT_AAC_DEC_ROLE)) {
256 pExynosComponent->pExynosPort[INPUT_PORT_INDEX].portDefinition.format.audio.eEncoding = OMX_AUDIO_CodingAAC;
257 } else {
258 ret = OMX_ErrorBadParameter;
259 goto EXIT;
260 }
261 }
262 break;
263 default:
264 ret = Exynos_OMX_AudioDecodeSetParameter(hComponent, nIndex, pComponentParameterStructure);
265 break;
266 }
267 EXIT:
268 FunctionOut();
269
270 return ret;
271 }
272
273 OMX_ERRORTYPE Exynos_Seiren_AacDec_GetConfig(
274 OMX_IN OMX_HANDLETYPE hComponent,
275 OMX_IN OMX_INDEXTYPE nIndex,
276 OMX_IN OMX_PTR pComponentConfigStructure)
277 {
278 OMX_ERRORTYPE ret = OMX_ErrorNone;
279 OMX_COMPONENTTYPE *pOMXComponent = NULL;
280 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
281
282 FunctionIn();
283
284 if (hComponent == NULL || pComponentConfigStructure == NULL) {
285 ret = OMX_ErrorBadParameter;
286 goto EXIT;
287 }
288 pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
289 ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
290 if (ret != OMX_ErrorNone) {
291 goto EXIT;
292 }
293 if (pOMXComponent->pComponentPrivate == NULL) {
294 ret = OMX_ErrorBadParameter;
295 goto EXIT;
296 }
297
298 pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
299 if (pExynosComponent->currentState == OMX_StateInvalid) {
300 ret = OMX_ErrorInvalidState;
301 goto EXIT;
302 }
303
304 switch (nIndex) {
305 default:
306 ret = Exynos_OMX_AudioDecodeGetConfig(hComponent, nIndex, pComponentConfigStructure);
307 break;
308 }
309
310 EXIT:
311 FunctionOut();
312
313 return ret;
314 }
315
316 OMX_ERRORTYPE Exynos_Seiren_AacDec_SetConfig(
317 OMX_IN OMX_HANDLETYPE hComponent,
318 OMX_IN OMX_INDEXTYPE nIndex,
319 OMX_IN OMX_PTR pComponentConfigStructure)
320 {
321 OMX_ERRORTYPE ret = OMX_ErrorNone;
322 OMX_COMPONENTTYPE *pOMXComponent = NULL;
323 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
324
325 FunctionIn();
326
327 if (hComponent == NULL || pComponentConfigStructure == NULL) {
328 ret = OMX_ErrorBadParameter;
329 goto EXIT;
330 }
331 pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
332 ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
333 if (ret != OMX_ErrorNone) {
334 goto EXIT;
335 }
336 if (pOMXComponent->pComponentPrivate == NULL) {
337 ret = OMX_ErrorBadParameter;
338 goto EXIT;
339 }
340
341 pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
342 if (pExynosComponent->currentState == OMX_StateInvalid) {
343 ret = OMX_ErrorInvalidState;
344 goto EXIT;
345 }
346
347 switch (nIndex) {
348 default:
349 ret = Exynos_OMX_AudioDecodeSetConfig(hComponent, nIndex, pComponentConfigStructure);
350 break;
351 }
352
353 EXIT:
354 FunctionOut();
355
356 return ret;
357 }
358
359 OMX_ERRORTYPE Exynos_Seiren_AacDec_GetExtensionIndex(
360 OMX_IN OMX_HANDLETYPE hComponent,
361 OMX_IN OMX_STRING cParameterName,
362 OMX_OUT OMX_INDEXTYPE *pIndexType)
363 {
364 OMX_ERRORTYPE ret = OMX_ErrorNone;
365 OMX_COMPONENTTYPE *pOMXComponent = NULL;
366 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
367
368 FunctionIn();
369
370 if (hComponent == NULL) {
371 ret = OMX_ErrorBadParameter;
372 goto EXIT;
373 }
374 pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
375 ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
376 if (ret != OMX_ErrorNone) {
377 goto EXIT;
378 }
379
380 if (pOMXComponent->pComponentPrivate == NULL) {
381 ret = OMX_ErrorBadParameter;
382 goto EXIT;
383 }
384 pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
385
386 if ((cParameterName == NULL) || (pIndexType == NULL)) {
387 ret = OMX_ErrorBadParameter;
388 goto EXIT;
389 }
390 if (pExynosComponent->currentState == OMX_StateInvalid) {
391 ret = OMX_ErrorInvalidState;
392 goto EXIT;
393 }
394
395 ret = Exynos_OMX_AudioDecodeGetExtensionIndex(hComponent, cParameterName, pIndexType);
396
397 EXIT:
398 FunctionOut();
399
400 return ret;
401 }
402
403 OMX_ERRORTYPE Exynos_Seiren_AacDec_ComponentRoleEnum(
404 OMX_IN OMX_HANDLETYPE hComponent,
405 OMX_OUT OMX_U8 *cRole,
406 OMX_IN OMX_U32 nIndex)
407 {
408 OMX_ERRORTYPE ret = OMX_ErrorNone;
409 OMX_COMPONENTTYPE *pOMXComponent = NULL;
410 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
411 OMX_S32 codecType;
412
413 FunctionIn();
414
415 if ((hComponent == NULL) || (cRole == NULL)) {
416 ret = OMX_ErrorBadParameter;
417 goto EXIT;
418 }
419 if (nIndex != (MAX_COMPONENT_ROLE_NUM - 1)) {
420 ret = OMX_ErrorNoMore;
421 goto EXIT;
422 }
423 pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
424 ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
425 if (ret != OMX_ErrorNone) {
426 goto EXIT;
427 }
428 if (pOMXComponent->pComponentPrivate == NULL) {
429 ret = OMX_ErrorBadParameter;
430 goto EXIT;
431 }
432
433 pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
434 if (pExynosComponent->currentState == OMX_StateInvalid ) {
435 ret = OMX_ErrorInvalidState;
436 goto EXIT;
437 }
438
439 Exynos_OSAL_Strcpy((char *)cRole, EXYNOS_OMX_COMPONENT_AAC_DEC_ROLE);
440
441 EXIT:
442 FunctionOut();
443
444 return ret;
445 }
446
447 OMX_ERRORTYPE Exynos_Seiren_AacDec_Init(OMX_COMPONENTTYPE *pOMXComponent)
448 {
449 OMX_ERRORTYPE ret = OMX_ErrorNone;
450 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
451 EXYNOS_OMX_AUDIODEC_COMPONENT *pAudioDec = (EXYNOS_OMX_AUDIODEC_COMPONENT *)pExynosComponent->hComponentHandle;
452 EXYNOS_AAC_HANDLE *pAacDec = (EXYNOS_AAC_HANDLE *)pAudioDec->hCodecHandle;
453
454 FunctionIn();
455
456 INIT_ARRAY_TO_VAL(pExynosComponent->timeStamp, DEFAULT_TIMESTAMP_VAL, MAX_TIMESTAMP);
457 Exynos_OSAL_Memset(pExynosComponent->nFlags, 0, sizeof(OMX_U32) * MAX_FLAGS);
458 pExynosComponent->bUseFlagEOF = OMX_TRUE; /* Aac extractor should parse into frame unit. */
459 pExynosComponent->bSaveFlagEOS = OMX_FALSE;
460 pAacDec->hSeirenAacHandle.bConfiguredSeiren = OMX_FALSE;
461 pAacDec->hSeirenAacHandle.bSeirenSendEOS = OMX_FALSE;
462 pExynosComponent->getAllDelayBuffer = OMX_FALSE;
463
464 #ifdef Seiren_DUMP_TO_FILE
465 inFile = fopen("/data/InFile.aac", "w+");
466 outFile = fopen("/data/OutFile.pcm", "w+");
467 #endif
468
469 EXIT:
470 FunctionOut();
471
472 return ret;
473 }
474
475 OMX_ERRORTYPE Exynos_Seiren_AacDec_Terminate(OMX_COMPONENTTYPE *pOMXComponent)
476 {
477 OMX_ERRORTYPE ret = OMX_ErrorNone;
478 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
479
480 FunctionIn();
481
482 #ifdef Seiren_DUMP_TO_FILE
483 fclose(inFile);
484 fclose(outFile);
485 #endif
486
487 EXIT:
488 FunctionOut();
489
490 return ret;
491 }
492
493 OMX_ERRORTYPE Exynos_Seiren_Aac_Decode_Block(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pInputData, EXYNOS_OMX_DATA *pOutputData)
494 {
495 OMX_ERRORTYPE ret = OMX_ErrorNone;
496 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
497 EXYNOS_OMX_AUDIODEC_COMPONENT *pAudioDec = (EXYNOS_OMX_AUDIODEC_COMPONENT *)pExynosComponent->hComponentHandle;
498 EXYNOS_AAC_HANDLE *pAacDec = (EXYNOS_AAC_HANDLE *)pAudioDec->hCodecHandle;
499 int returnCodec = 0;
500 unsigned long isSeirenStopped = 0;
501 OMX_BOOL isSeirenIbufOverflow = OMX_FALSE;
502
503 u32 fd = pAacDec->hSeirenAacHandle.hSeirenHandle;
504 audio_mem_info_t input_mem_pool = pAacDec->hSeirenAacHandle.input_mem_pool;
505 audio_mem_info_t output_mem_pool = pAacDec->hSeirenAacHandle.output_mem_pool;
506 unsigned long sample_rate, channels;
507 int consumed_size = 0;
508 sample_rate = channels = 0;
509
510 FunctionIn();
511
512 #ifdef Seiren_DUMP_TO_FILE
513 if (pExynosComponent->reInputData == OMX_FALSE) {
514 fwrite(pInputData->multiPlaneBuffer.dataBuffer[AUDIO_DATA_PLANE], pInputData->dataLen, 1, inFile);
515 }
516 #endif
517
518 /* Save timestamp and flags of input data */
519 pOutputData->timeStamp = pInputData->timeStamp;
520 pOutputData->nFlags = pInputData->nFlags & (~OMX_BUFFERFLAG_EOS);
521
522 /* Decoding aac frames by Seiren */
523 if (pExynosComponent->getAllDelayBuffer == OMX_FALSE) {
524 input_mem_pool.data_size = pInputData->dataLen;
525 char* pt = input_mem_pool.virt_addr;
526 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "\e[1;33m %02X %02X %02X %02X %02X %02X %lld \e[0m", *pt,*(pt+1),*(pt+2),*(pt+3),*(pt+4), *(pt+5), pInputData->timeStamp);
527
528 if (pInputData->nFlags & OMX_BUFFERFLAG_CODECCONFIG) {
529 if (pAacDec->hSeirenAacHandle.bConfiguredSeiren == OMX_TRUE)
530 goto EXIT;
531
532 ADec_ConfigSignal(fd);
533 unsigned char sample_rate_index = ((*(pt+1)) >> 7 & 0x01) |
534 ((*pt) << 1 & 0x0e);
535 unsigned char num_of_channel = ((*(pt+1)) >> 3 & 0x07);
536 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "index %x ", sample_rate_index);
537 ADec_SetParams(fd, PCM_PARAM_SAMPLE_RATE, aac_sample_rates[sample_rate_index]);
538 ADec_SetParams(fd, PCM_PARAM_NUM_OF_CH, num_of_channel);
539
540 /* AAC setup-data(or DSI) could be various length. But it only needs 2byte */
541 input_mem_pool.data_size = 2;
542 ADec_SendStream(fd, &input_mem_pool, &consumed_size);
543 goto EXIT;
544 }
545 returnCodec = ADec_SendStream(fd, &input_mem_pool, &consumed_size);
546
547 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "ProcessedSize : %d return : %d", consumed_size, returnCodec);
548 if (pInputData->nFlags & OMX_BUFFERFLAG_EOS)
549 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "EOS!!");
550 if (returnCodec >= 0) {
551 if (pInputData->nFlags & OMX_BUFFERFLAG_EOS) {
552 ADec_SendEOS(fd);
553 pAacDec->hSeirenAacHandle.bSeirenSendEOS = OMX_TRUE;
554 }
555 } else if (returnCodec < 0) {
556 ret = OMX_ErrorCodecDecode;
557 goto EXIT;
558 }
559 }
560
561 if (pAacDec->hSeirenAacHandle.bConfiguredSeiren == OMX_FALSE) {
562 if ((pInputData->dataLen <= 0) && (pInputData->nFlags & OMX_BUFFERFLAG_EOS)) {
563 pOutputData->nFlags |= OMX_BUFFERFLAG_EOS;
564 pAacDec->hSeirenAacHandle.bSeirenSendEOS = OMX_FALSE;
565 ret = OMX_ErrorNone;
566 goto EXIT;
567 }
568
569 returnCodec = ADec_GetParams(fd, PCM_PARAM_SAMPLE_RATE, &sample_rate);
570 returnCodec = returnCodec | ADec_GetParams(fd, PCM_PARAM_NUM_OF_CH, &channels);
571
572 if (returnCodec < 0) {
573 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Seiren_ADec_GetParams failed: %d", returnCodec);
574 ret = OMX_ErrorHardware;
575 goto EXIT;
576 }
577
578 if (!sample_rate || !channels) {
579 if (pAacDec->hSeirenAacHandle.bSeirenSendEOS == OMX_TRUE) {
580 pOutputData->dataLen = 0;
581 pExynosComponent->getAllDelayBuffer = OMX_TRUE;
582 } else {
583 pExynosComponent->getAllDelayBuffer = OMX_FALSE;
584 }
585 ret = OMX_ErrorNone;
586 goto EXIT;//
587 }
588
589 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "numChannels(%d), samplingRate(%d)",
590 channels, sample_rate);
591
592 if (pAacDec->pcmParam.nChannels != channels ||
593 pAacDec->pcmParam.nSamplingRate != sample_rate) {
594 /* Change channel count and sampling rate information */
595 pAacDec->pcmParam.nChannels = channels;
596 pAacDec->pcmParam.nSamplingRate = sample_rate;
597
598 /* Send Port Settings changed call back */
599 (*(pExynosComponent->pCallbacks->EventHandler))
600 (pOMXComponent,
601 pExynosComponent->callbackData,
602 OMX_EventPortSettingsChanged, /* The command was completed */
603 OMX_DirOutput, /* This is the port index */
604 0,
605 NULL);
606 }
607
608 pAacDec->hSeirenAacHandle.bConfiguredSeiren = OMX_TRUE;
609
610 if (pAacDec->hSeirenAacHandle.bSeirenSendEOS == OMX_TRUE) {
611 pOutputData->dataLen = 0;
612 pExynosComponent->getAllDelayBuffer = OMX_TRUE;
613 ret = OMX_ErrorInputDataDecodeYet;
614 } else {
615 pExynosComponent->getAllDelayBuffer = OMX_FALSE;
616 ret = OMX_ErrorNone;
617 }
618 goto EXIT;
619 }
620
621 /* Get decoded data from Seiren */
622 ADec_RecvPCM(fd, &output_mem_pool);
623 if (output_mem_pool.data_size > 0) {
624 pOutputData->dataLen = output_mem_pool.data_size;
625 Exynos_OSAL_Memcpy(pOutputData->multiPlaneBuffer.dataBuffer[AUDIO_DATA_PLANE],
626 output_mem_pool.virt_addr, output_mem_pool.data_size);
627 } else {
628 pOutputData->dataLen = 0;
629 }
630
631 #ifdef Seiren_DUMP_TO_FILE
632 if (pOutputData->dataLen > 0)
633 fwrite(pOutputData->multiPlaneBuffer.dataBuffer[AUDIO_DATA_PLANE], pOutputData->dataLen, 1, outFile);
634 #endif
635
636 /* Delay EOS signal until all the PCM is returned from the Seiren driver. */
637 if (pAacDec->hSeirenAacHandle.bSeirenSendEOS == OMX_TRUE) {
638 if (pInputData->nFlags & OMX_BUFFERFLAG_EOS) {
639 returnCodec = ADec_GetParams(fd, ADEC_PARAM_GET_OUTPUT_STATUS, &isSeirenStopped);
640 if (returnCodec != 0)
641 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Fail Seiren_STOP_EOS_STATE");
642 if (isSeirenStopped == 1) {
643 pOutputData->nFlags |= OMX_BUFFERFLAG_EOS;
644 pExynosComponent->getAllDelayBuffer = OMX_FALSE;
645 pAacDec->hSeirenAacHandle.bSeirenSendEOS = OMX_FALSE; /* for repeating one song */
646 ret = OMX_ErrorNone;
647 } else {
648 pExynosComponent->getAllDelayBuffer = OMX_TRUE;
649 ret = OMX_ErrorInputDataDecodeYet;
650 }
651 } else { /* Flush after EOS */
652 pAacDec->hSeirenAacHandle.bSeirenSendEOS = OMX_FALSE;
653 }
654 }
655 EXIT:
656 FunctionOut();
657
658 return ret;
659 }
660
661 OMX_ERRORTYPE Exynos_Seiren_AacDec_bufferProcess(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pInputData, EXYNOS_OMX_DATA *pOutputData)
662 {
663 OMX_ERRORTYPE ret = OMX_ErrorNone;
664 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
665 EXYNOS_OMX_BASEPORT *pInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
666 EXYNOS_OMX_BASEPORT *pOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
667
668 FunctionIn();
669
670 if ((!CHECK_PORT_ENABLED(pInputPort)) || (!CHECK_PORT_ENABLED(pOutputPort)) ||
671 (!CHECK_PORT_POPULATED(pInputPort)) || (!CHECK_PORT_POPULATED(pOutputPort))) {
672 if (pInputData->nFlags & OMX_BUFFERFLAG_EOS)
673 ret = OMX_ErrorInputDataDecodeYet;
674 else
675 ret = OMX_ErrorNone;
676
677 goto EXIT;
678 }
679 if (OMX_FALSE == Exynos_Check_BufferProcess_State(pExynosComponent)) {
680 if (pInputData->nFlags & OMX_BUFFERFLAG_EOS)
681 ret = OMX_ErrorInputDataDecodeYet;
682 else
683 ret = OMX_ErrorNone;
684
685 goto EXIT;
686 }
687
688 ret = Exynos_Seiren_Aac_Decode_Block(pOMXComponent, pInputData, pOutputData);
689
690 if (ret != OMX_ErrorNone) {
691 if (ret == (OMX_ERRORTYPE)OMX_ErrorInputDataDecodeYet) {
692 pOutputData->usedDataLen = 0;
693 pOutputData->remainDataLen = pOutputData->dataLen;
694 } else {
695 pExynosComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent,
696 pExynosComponent->callbackData,
697 OMX_EventError, ret, 0, NULL);
698 }
699 } else {
700 pInputData->usedDataLen += pInputData->dataLen;
701 pInputData->remainDataLen = pInputData->dataLen - pInputData->usedDataLen;
702 pInputData->dataLen -= pInputData->usedDataLen;
703 pInputData->usedDataLen = 0;
704
705 pOutputData->usedDataLen = 0;
706 pOutputData->remainDataLen = pOutputData->dataLen;
707 }
708
709 EXIT:
710 FunctionOut();
711
712 return ret;
713 }
714
715 OMX_ERRORTYPE Exynos_Seiren_AacDec_flushSeiren(OMX_COMPONENTTYPE *pOMXComponent, SEIREN_PORTTYPE type)
716 {
717 OMX_ERRORTYPE ret = OMX_ErrorNone;
718 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
719 EXYNOS_OMX_AUDIODEC_COMPONENT *pAudioDec = (EXYNOS_OMX_AUDIODEC_COMPONENT *)pExynosComponent->hComponentHandle;
720 EXYNOS_AAC_HANDLE *pAacDec = (EXYNOS_AAC_HANDLE *)pAudioDec->hCodecHandle;
721
722 int fd = pAacDec->hSeirenAacHandle.hSeirenHandle;
723 return ADec_Flush(fd, type);
724 }
725
726 OSCL_EXPORT_REF OMX_ERRORTYPE Exynos_OMX_ComponentInit(OMX_HANDLETYPE hComponent, OMX_STRING componentName)
727 {
728 OMX_ERRORTYPE ret = OMX_ErrorNone;
729 OMX_COMPONENTTYPE *pOMXComponent = NULL;
730 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
731 EXYNOS_OMX_BASEPORT *pExynosPort = NULL;
732 EXYNOS_OMX_AUDIODEC_COMPONENT *pAudioDec = NULL;
733 EXYNOS_AAC_HANDLE *pAacDec = NULL;
734 audio_mem_info_t input_mem_pool;
735 audio_mem_info_t output_mem_pool;
736 OMX_S32 fd;
737
738 int i = 0;
739
740 FunctionIn();
741
742 if ((hComponent == NULL) || (componentName == NULL)) {
743 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s: parameters are null, ret: %X", __FUNCTION__, ret);
744 ret = OMX_ErrorBadParameter;
745 goto EXIT;
746 }
747 if (Exynos_OSAL_Strcmp(EXYNOS_OMX_COMPONENT_AAC_DEC, componentName) != 0) {
748 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s: componentName(%s) error, ret: %X", __FUNCTION__, componentName, ret);
749 ret = OMX_ErrorBadParameter;
750 goto EXIT;
751 }
752
753 pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
754 ret = Exynos_OMX_AudioDecodeComponentInit(pOMXComponent);
755 if (ret != OMX_ErrorNone) {
756 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s: Exynos_OMX_AudioDecodeComponentInit error, ret: %X", __FUNCTION__, ret);
757 goto EXIT;
758 }
759 pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
760 pExynosComponent->codecType = HW_AUDIO_DEC_CODEC;
761
762 pExynosComponent->componentName = (OMX_STRING)Exynos_OSAL_Malloc(MAX_OMX_COMPONENT_NAME_SIZE);
763 if (pExynosComponent->componentName == NULL) {
764 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s: componentName alloc error, ret: %X", __FUNCTION__, ret);
765 ret = OMX_ErrorInsufficientResources;
766 goto EXIT_ERROR_1;
767 }
768 Exynos_OSAL_Memset(pExynosComponent->componentName, 0, MAX_OMX_COMPONENT_NAME_SIZE);
769 Exynos_OSAL_Strcpy(pExynosComponent->componentName, EXYNOS_OMX_COMPONENT_AAC_DEC);
770
771 pAacDec = Exynos_OSAL_Malloc(sizeof(EXYNOS_AAC_HANDLE));
772 if (pAacDec == NULL) {
773 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s: EXYNOS_AAC_HANDLE alloc error, ret: %X", __FUNCTION__, ret);
774 ret = OMX_ErrorInsufficientResources;
775 goto EXIT_ERROR_2;
776 }
777 Exynos_OSAL_Memset(pAacDec, 0, sizeof(EXYNOS_AAC_HANDLE));
778 pAudioDec = (EXYNOS_OMX_AUDIODEC_COMPONENT *)pExynosComponent->hComponentHandle;
779 pAudioDec->hCodecHandle = (OMX_HANDLETYPE)pAacDec;
780
781 /* Create and Init Seiren */
782 pAacDec->hSeirenAacHandle.bSeirenLoaded = OMX_FALSE;
783 fd = ADec_Create(0, ADEC_AAC, NULL);
784
785 if (fd < 0) {
786 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Seiren_ADec_Create failed: %d", fd);
787 ret = OMX_ErrorHardware;
788 goto EXIT_ERROR_3;
789 }
790 pAacDec->hSeirenAacHandle.hSeirenHandle = fd; /* Seiren's fd */
791 pAacDec->hSeirenAacHandle.bSeirenLoaded = OMX_TRUE;
792
793 /* Get input buffer info from Seiren */
794 Exynos_OSAL_Memset(&pAacDec->hSeirenAacHandle.input_mem_pool, 0, sizeof(audio_mem_info_t));
795 ADec_GetIMemPoolInfo(fd, &pAacDec->hSeirenAacHandle.input_mem_pool);
796 input_mem_pool = pAacDec->hSeirenAacHandle.input_mem_pool;
797
798 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "eiren_Adec_GetIMemPoolInfo : %d", input_mem_pool.mem_size);
799
800 if (input_mem_pool.virt_addr == NULL) {
801 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Seiren_Adec_GetIMemPoolInfo failed: %d", fd);
802 ret = OMX_ErrorHardware;
803 goto EXIT_ERROR_5;
804 }
805
806 pExynosPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
807 pExynosPort->processData.allocSize = input_mem_pool.mem_size;
808 pExynosPort->processData.multiPlaneBuffer.dataBuffer[AUDIO_DATA_PLANE] = input_mem_pool.virt_addr;
809
810 /* Get output buffer info from Seiren */
811 Exynos_OSAL_Memset(&pAacDec->hSeirenAacHandle.output_mem_pool, 0, sizeof(audio_mem_info_t));
812 ADec_GetOMemPoolInfo(fd, &pAacDec->hSeirenAacHandle.output_mem_pool);
813 output_mem_pool = pAacDec->hSeirenAacHandle.output_mem_pool;
814 if (output_mem_pool.virt_addr == NULL) {
815 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Seiren_ADec_GetOMemPoolInfo failed: %d", fd);
816 ret = OMX_ErrorHardware;
817 goto EXIT_ERROR_6;
818 }
819
820 /* Set componentVersion */
821 pExynosComponent->componentVersion.s.nVersionMajor = VERSIONMAJOR_NUMBER;
822 pExynosComponent->componentVersion.s.nVersionMinor = VERSIONMINOR_NUMBER;
823 pExynosComponent->componentVersion.s.nRevision = REVISION_NUMBER;
824 pExynosComponent->componentVersion.s.nStep = STEP_NUMBER;
825
826 /* Set specVersion */
827 pExynosComponent->specVersion.s.nVersionMajor = VERSIONMAJOR_NUMBER;
828 pExynosComponent->specVersion.s.nVersionMinor = VERSIONMINOR_NUMBER;
829 pExynosComponent->specVersion.s.nRevision = REVISION_NUMBER;
830 pExynosComponent->specVersion.s.nStep = STEP_NUMBER;
831
832 /* Input port */
833 pExynosPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
834 pExynosPort->portDefinition.nBufferCountActual = input_mem_pool.block_count;
835 pExynosPort->portDefinition.nBufferCountMin = input_mem_pool.block_count;
836 pExynosPort->portDefinition.nBufferSize = input_mem_pool.mem_size;
837 pExynosPort->portDefinition.bEnabled = OMX_TRUE;
838 Exynos_OSAL_Memset(pExynosPort->portDefinition.format.audio.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE);
839 Exynos_OSAL_Strcpy(pExynosPort->portDefinition.format.audio.cMIMEType, "audio/aac");
840 pExynosPort->portDefinition.format.audio.pNativeRender = 0;
841 pExynosPort->portDefinition.format.audio.bFlagErrorConcealment = OMX_FALSE;
842 pExynosPort->portDefinition.format.audio.eEncoding = OMX_AUDIO_CodingAAC;
843 pExynosPort->portWayType = WAY1_PORT;
844
845 /* Output port */
846 pExynosPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
847 pExynosPort->portDefinition.nBufferCountActual = output_mem_pool.block_count;
848 pExynosPort->portDefinition.nBufferCountMin = output_mem_pool.block_count;
849 pExynosPort->portDefinition.nBufferSize = output_mem_pool.mem_size;
850 pExynosPort->portDefinition.bEnabled = OMX_TRUE;
851 Exynos_OSAL_Memset(pExynosPort->portDefinition.format.audio.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE);
852 Exynos_OSAL_Strcpy(pExynosPort->portDefinition.format.audio.cMIMEType, "audio/raw");
853 pExynosPort->portDefinition.format.audio.pNativeRender = 0;
854 pExynosPort->portDefinition.format.audio.bFlagErrorConcealment = OMX_FALSE;
855 pExynosPort->portDefinition.format.audio.eEncoding = OMX_AUDIO_CodingPCM;
856 pExynosPort->portWayType = WAY1_PORT;
857
858 /* Default values for Aac audio param */
859 INIT_SET_SIZE_VERSION(&pAacDec->aacParam, OMX_AUDIO_PARAM_AACPROFILETYPE);
860 pAacDec->aacParam.nPortIndex = INPUT_PORT_INDEX;
861 pAacDec->aacParam.nChannels = DEFAULT_AUDIO_CHANNELS_NUM;
862 pAacDec->aacParam.nBitRate = 0;
863 pAacDec->aacParam.nSampleRate = DEFAULT_AUDIO_SAMPLING_FREQ;
864 pAacDec->aacParam.nAudioBandWidth = 0;
865 pAacDec->aacParam.eChannelMode = OMX_AUDIO_ChannelModeStereo;
866 pAacDec->aacParam.eAACProfile = OMX_AUDIO_AACObjectNull;
867 pAacDec->aacParam.eAACStreamFormat = OMX_AUDIO_AACStreamFormatMP2ADTS;
868
869 /* Default values for PCM audio param */
870 INIT_SET_SIZE_VERSION(&pAacDec->pcmParam, OMX_AUDIO_PARAM_PCMMODETYPE);
871 pAacDec->pcmParam.nPortIndex = OUTPUT_PORT_INDEX;
872 pAacDec->pcmParam.nChannels = DEFAULT_AUDIO_CHANNELS_NUM;
873 pAacDec->pcmParam.eNumData = OMX_NumericalDataSigned;
874 pAacDec->pcmParam.eEndian = OMX_EndianLittle;
875 pAacDec->pcmParam.bInterleaved = OMX_TRUE;
876 pAacDec->pcmParam.nBitPerSample = DEFAULT_AUDIO_BIT_PER_SAMPLE;
877 pAacDec->pcmParam.nSamplingRate = DEFAULT_AUDIO_SAMPLING_FREQ;
878 pAacDec->pcmParam.ePCMMode = OMX_AUDIO_PCMModeLinear;
879 pAacDec->pcmParam.eChannelMapping[0] = OMX_AUDIO_ChannelLF;
880 pAacDec->pcmParam.eChannelMapping[1] = OMX_AUDIO_ChannelRF;
881
882 pOMXComponent->GetParameter = &Exynos_Seiren_AacDec_GetParameter;
883 pOMXComponent->SetParameter = &Exynos_Seiren_AacDec_SetParameter;
884 pOMXComponent->GetConfig = &Exynos_Seiren_AacDec_GetConfig;
885 pOMXComponent->SetConfig = &Exynos_Seiren_AacDec_SetConfig;
886 pOMXComponent->GetExtensionIndex = &Exynos_Seiren_AacDec_GetExtensionIndex;
887 pOMXComponent->ComponentRoleEnum = &Exynos_Seiren_AacDec_ComponentRoleEnum;
888 pOMXComponent->ComponentDeInit = &Exynos_OMX_ComponentDeinit;
889
890 /* ToDo: Change the function name associated with a specific codec */
891 pExynosComponent->exynos_codec_componentInit = &Exynos_Seiren_AacDec_Init;
892 pExynosComponent->exynos_codec_componentTerminate = &Exynos_Seiren_AacDec_Terminate;
893 pAudioDec->exynos_codec_bufferProcess = &Exynos_Seiren_AacDec_bufferProcess;
894 pAudioDec->exynos_codec_flushSeiren = &Exynos_Seiren_AacDec_flushSeiren;
895 pAudioDec->exynos_checkInputFrame = NULL;
896
897 pExynosComponent->currentState = OMX_StateLoaded;
898
899 ret = OMX_ErrorNone;
900 goto EXIT; /* This function is performed successfully. */
901
902 EXIT_ERROR_6:
903 pExynosPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
904 pExynosPort->processData.multiPlaneBuffer.dataBuffer[AUDIO_DATA_PLANE] = NULL;
905 pExynosPort->processData.allocSize = 0;
906 EXIT_ERROR_5:
907 EXIT_ERROR_4:
908 ADec_Destroy(pAacDec->hSeirenAacHandle.hSeirenHandle);
909 EXIT_ERROR_3:
910 Exynos_OSAL_Free(pAacDec);
911 pAudioDec->hCodecHandle = NULL;
912 EXIT_ERROR_2:
913 Exynos_OSAL_Free(pExynosComponent->componentName);
914 pExynosComponent->componentName = NULL;
915 EXIT_ERROR_1:
916 Exynos_OMX_AudioDecodeComponentDeinit(pOMXComponent);
917 EXIT:
918 FunctionOut();
919
920 return ret;
921 }
922
923 OMX_ERRORTYPE Exynos_OMX_ComponentDeinit(OMX_HANDLETYPE hComponent)
924 {
925 OMX_ERRORTYPE ret = OMX_ErrorNone;
926 OMX_COMPONENTTYPE *pOMXComponent = NULL;
927 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
928 EXYNOS_AAC_HANDLE *pAacDec = NULL;
929 EXYNOS_OMX_BASEPORT *pExynosPort = NULL;
930
931 FunctionIn();
932
933 if (hComponent == NULL) {
934 ret = OMX_ErrorBadParameter;
935 goto EXIT;
936 }
937 pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
938 pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
939
940 Exynos_OSAL_Free(pExynosComponent->componentName);
941 pExynosComponent->componentName = NULL;
942
943 pAacDec = (EXYNOS_AAC_HANDLE *)((EXYNOS_OMX_AUDIODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
944 if (pAacDec != NULL) {
945 if (pAacDec->hSeirenAacHandle.bSeirenLoaded == OMX_TRUE) {
946 ADec_Destroy(pAacDec->hSeirenAacHandle.hSeirenHandle);
947 }
948 Exynos_OSAL_Free(pAacDec);
949 ((EXYNOS_OMX_AUDIODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle = NULL;
950 }
951
952 ret = Exynos_OMX_AudioDecodeComponentDeinit(pOMXComponent);
953 if (ret != OMX_ErrorNone) {
954 goto EXIT;
955 }
956
957 ret = OMX_ErrorNone;
958
959 EXIT:
960 FunctionOut();
961
962 return ret;
963 }