OpenMAX Bellagio 0.9.3
omx_audiomixer_component.c
Go to the documentation of this file.
1
27#include <omxcore.h>
28#include <omx_base_audio_port.h>
30#include<OMX_Audio.h>
31
32/* Gain value */
33#define GAIN_VALUE 100.0f
34
37 omx_audio_mixer_component_PrivateType* omx_audio_mixer_component_Private;
38 omx_audio_mixer_component_PortType *pPort;//,*inPort1, *outPort;
39 OMX_U32 i;
40
42 if (!openmaxStandComp->pComponentPrivate) {
43 DEBUG(DEB_LEV_FUNCTION_NAME, "In %s, allocating component\n",__func__);
44 openmaxStandComp->pComponentPrivate = calloc(1, sizeof(omx_audio_mixer_component_PrivateType));
45 if(openmaxStandComp->pComponentPrivate == NULL) {
47 }
48 } else {
49 DEBUG(DEB_LEV_FUNCTION_NAME, "In %s, Error Component %p Already Allocated\n", __func__, openmaxStandComp->pComponentPrivate);
50 }
51
52 omx_audio_mixer_component_Private = openmaxStandComp->pComponentPrivate;
53 omx_audio_mixer_component_Private->ports = NULL;
54
56 err = omx_base_filter_Constructor(openmaxStandComp, cComponentName);
57
58 /*Assuming 4 input and 1 output ports*/
59 omx_audio_mixer_component_Private->sPortTypesParam[OMX_PortDomainAudio].nStartPortNumber = 0;
60 omx_audio_mixer_component_Private->sPortTypesParam[OMX_PortDomainAudio].nPorts = MAX_PORTS;
61
63 if (omx_audio_mixer_component_Private->sPortTypesParam[OMX_PortDomainAudio].nPorts && !omx_audio_mixer_component_Private->ports) {
64 omx_audio_mixer_component_Private->ports = calloc(omx_audio_mixer_component_Private->sPortTypesParam[OMX_PortDomainAudio].nPorts, sizeof(omx_base_PortType *));
65 if (!omx_audio_mixer_component_Private->ports) {
67 }
68 for (i=0; i < omx_audio_mixer_component_Private->sPortTypesParam[OMX_PortDomainAudio].nPorts; i++) {
69 omx_audio_mixer_component_Private->ports[i] = calloc(1, sizeof(omx_audio_mixer_component_PortType));
70 if (!omx_audio_mixer_component_Private->ports[i]) {
72 }
73 }
74 }
75
76 /* construct all input ports */
77 for(i=0;i<omx_audio_mixer_component_Private->sPortTypesParam[OMX_PortDomainAudio].nPorts-1;i++) {
78 base_audio_port_Constructor(openmaxStandComp, &omx_audio_mixer_component_Private->ports[i], i, OMX_TRUE);
79 }
80
81 /* construct one output port */
82 base_audio_port_Constructor(openmaxStandComp, &omx_audio_mixer_component_Private->ports[omx_audio_mixer_component_Private->sPortTypesParam[OMX_PortDomainAudio].nPorts-1], omx_audio_mixer_component_Private->sPortTypesParam[OMX_PortDomainAudio].nPorts-1, OMX_FALSE);
83
85 for(i=0;i<omx_audio_mixer_component_Private->sPortTypesParam[OMX_PortDomainAudio].nPorts;i++) {
86 pPort = (omx_audio_mixer_component_PortType *) omx_audio_mixer_component_Private->ports[i];
87
88 pPort->sPortParam.nBufferSize = DEFAULT_OUT_BUFFER_SIZE;
89 pPort->gain = GAIN_VALUE; //100.0f; // default gain
90
91 setHeader(&pPort->pAudioPcmMode,sizeof(OMX_AUDIO_PARAM_PCMMODETYPE));
92 pPort->pAudioPcmMode.nPortIndex = i;
93 pPort->pAudioPcmMode.nChannels = 2;
94 pPort->pAudioPcmMode.eNumData = OMX_NumericalDataSigned;
95 pPort->pAudioPcmMode.eEndian = OMX_EndianBig;
96 pPort->pAudioPcmMode.bInterleaved = OMX_TRUE;
97 pPort->pAudioPcmMode.nBitPerSample = 16;
98 pPort->pAudioPcmMode.nSamplingRate = 44100;
99 pPort->pAudioPcmMode.ePCMMode = OMX_AUDIO_PCMModeLinear;
100
101 setHeader(&pPort->sVolume,sizeof(OMX_AUDIO_CONFIG_VOLUMETYPE));
102 pPort->sVolume.nPortIndex = i;
103 pPort->sVolume.bLinear = OMX_TRUE;
105 pPort->sVolume.sVolume.nValue = (OMX_S32)GAIN_VALUE;
106 pPort->sVolume.sVolume.nMin = 0;
107 pPort->sVolume.sVolume.nMax = (OMX_S32)GAIN_VALUE;
108 }
109
110 omx_audio_mixer_component_Private->destructor = omx_audio_mixer_component_Destructor;
115 omx_audio_mixer_component_Private->BufferMgmtCallback = omx_audio_mixer_component_BufferMgmtCallback;
116 omx_audio_mixer_component_Private->BufferMgmtFunction = omx_audio_mixer_BufferMgmtFunction;
117
118 /* resource management special section */
119 omx_audio_mixer_component_Private->nqualitylevels = MIXER_QUALITY_LEVELS;
120 omx_audio_mixer_component_Private->currentQualityLevel = 1;
121 omx_audio_mixer_component_Private->multiResourceLevel = malloc(sizeof(multiResourceDescriptor *) * MIXER_QUALITY_LEVELS);
122 for (i = 0; i<MIXER_QUALITY_LEVELS; i++) {
123 omx_audio_mixer_component_Private->multiResourceLevel[i] = malloc(sizeof(multiResourceDescriptor));
124 omx_audio_mixer_component_Private->multiResourceLevel[i]->CPUResourceRequested = mixerQualityLevels[i * 2];
125 omx_audio_mixer_component_Private->multiResourceLevel[i]->MemoryResourceRequested = mixerQualityLevels[i * 2 + 1];
126 }
127
128 return err;
129}
130
131
135
136 omx_audio_mixer_component_PrivateType* omx_audio_mixer_component_Private = openmaxStandComp->pComponentPrivate;
137 OMX_U32 i;
138
139 DEBUG(DEB_LEV_FUNCTION_NAME, "In %s\n", __func__);
140 /* frees port/s */
141 if (omx_audio_mixer_component_Private->ports) {
142 for (i=0; i < omx_audio_mixer_component_Private->sPortTypesParam[OMX_PortDomainAudio].nPorts; i++) {
143 if(omx_audio_mixer_component_Private->ports[i])
144 omx_audio_mixer_component_Private->ports[i]->PortDestructor(omx_audio_mixer_component_Private->ports[i]);
145 }
146 free(omx_audio_mixer_component_Private->ports);
147 omx_audio_mixer_component_Private->ports=NULL;
148 }
149
150 omx_base_filter_Destructor(openmaxStandComp);
151
152 DEBUG(DEB_LEV_FUNCTION_NAME, "Out of %s\n", __func__);
153
154 return OMX_ErrorNone;
155}
156
160 OMX_S32 denominator=0;
161 OMX_U32 i,sampleCount = pInBuffer->nFilledLen / 2; // signed 16 bit samples assumed
162 omx_audio_mixer_component_PrivateType* omx_audio_mixer_component_Private = openmaxStandComp->pComponentPrivate;
163 omx_audio_mixer_component_PortType* pPort;
164
165 for(i=0;i<omx_audio_mixer_component_Private->sPortTypesParam[OMX_PortDomainAudio].nPorts-1;i++) {
166 pPort = (omx_audio_mixer_component_PortType*)omx_audio_mixer_component_Private->ports[i];
167 if(PORT_IS_ENABLED(pPort)){
168 denominator+=pPort->sVolume.sVolume.nValue;
169 }
170 }
171
172 pPort = (omx_audio_mixer_component_PortType*)omx_audio_mixer_component_Private->ports[pInBuffer->nInputPortIndex];
173
174 /*Copy the first buffer with appropriate gain*/
175 if(pOutBuffer->nFilledLen == 0) {
176 memset(pOutBuffer->pBuffer,0,pInBuffer->nFilledLen);
177
178 for (i = 0; i < sampleCount; i++) {
179 ((OMX_S16*) pOutBuffer->pBuffer)[i] = (OMX_S16)
180 ((((OMX_S16*) pInBuffer->pBuffer)[i] * pPort->sVolume.sVolume.nValue ) / denominator);
181 }
182 } else { // For the second buffer add with the first buffer with gain
183 for (i = 0; i < sampleCount; i++) {
184 ((OMX_S16*) pOutBuffer->pBuffer)[i] += (OMX_S16)
185 ((((OMX_S16*) pInBuffer->pBuffer)[i] * pPort->sVolume.sVolume.nValue ) / denominator);
186 }
187 }
188
189 pOutBuffer->nFilledLen = pInBuffer->nFilledLen;
190 pInBuffer->nFilledLen=0;
191}
192
195 OMX_HANDLETYPE hComponent,
196 OMX_INDEXTYPE nIndex,
197 OMX_PTR pComponentConfigStructure) {
198
200 OMX_COMPONENTTYPE *openmaxStandComp = (OMX_COMPONENTTYPE *)hComponent;
201 omx_audio_mixer_component_PrivateType* omx_audio_mixer_component_Private = openmaxStandComp->pComponentPrivate;
202 omx_audio_mixer_component_PortType * pPort;
204
205 switch (nIndex) {
207 pVolume = (OMX_AUDIO_CONFIG_VOLUMETYPE*) pComponentConfigStructure;
208 if(pVolume->sVolume.nValue > 100) {
210 break;
211 }
212
213 if (pVolume->nPortIndex <= omx_audio_mixer_component_Private->sPortTypesParam[OMX_PortDomainAudio].nPorts) {
214 pPort= (omx_audio_mixer_component_PortType *)omx_audio_mixer_component_Private->ports[pVolume->nPortIndex];
215 DEBUG(DEB_LEV_SIMPLE_SEQ, "Port %i Gain=%d\n",(int)pVolume->nPortIndex,(int)pVolume->sVolume.nValue);
216 memcpy(&pPort->sVolume, pVolume, sizeof(OMX_AUDIO_CONFIG_VOLUMETYPE));
217 } else {
219 }
220 break;
221 default: // delegate to superclass
222 err = omx_base_component_SetConfig(hComponent, nIndex, pComponentConfigStructure);
223 }
224 return err;
225}
226
228 OMX_HANDLETYPE hComponent,
229 OMX_INDEXTYPE nIndex,
230 OMX_PTR pComponentConfigStructure) {
232 OMX_COMPONENTTYPE *openmaxStandComp = (OMX_COMPONENTTYPE *)hComponent;
233 omx_audio_mixer_component_PrivateType *omx_audio_mixer_component_Private = openmaxStandComp->pComponentPrivate;
234 omx_audio_mixer_component_PortType *pPort;
236
237 switch (nIndex) {
239 pVolume = (OMX_AUDIO_CONFIG_VOLUMETYPE*) pComponentConfigStructure;
240 if (pVolume->nPortIndex <= omx_audio_mixer_component_Private->sPortTypesParam[OMX_PortDomainAudio].nPorts) {
241 pPort= (omx_audio_mixer_component_PortType *)omx_audio_mixer_component_Private->ports[pVolume->nPortIndex];
242 memcpy(pVolume,&pPort->sVolume,sizeof(OMX_AUDIO_CONFIG_VOLUMETYPE));
243 } else {
245 }
246 break;
247 default :
248 err = omx_base_component_GetConfig(hComponent, nIndex, pComponentConfigStructure);
249 }
250 return err;
251}
252
254 OMX_HANDLETYPE hComponent,
255 OMX_INDEXTYPE nParamIndex,
256 OMX_PTR ComponentParameterStructure) {
257
259 OMX_AUDIO_PARAM_PORTFORMATTYPE *pAudioPortFormat;
260 OMX_PARAM_COMPONENTROLETYPE *pComponentRole;
261 OMX_U32 portIndex;
262 omx_audio_mixer_component_PortType *port;
263
264 /* Check which structure we are being fed and make control its header */
265 OMX_COMPONENTTYPE *openmaxStandComp = (OMX_COMPONENTTYPE *)hComponent;
266 omx_audio_mixer_component_PrivateType* omx_audio_mixer_component_Private = openmaxStandComp->pComponentPrivate;
267 if (ComponentParameterStructure == NULL) {
269 }
270
271 DEBUG(DEB_LEV_SIMPLE_SEQ, " Setting parameter %i\n", nParamIndex);
272 switch(nParamIndex) {
274 pAudioPortFormat = (OMX_AUDIO_PARAM_PORTFORMATTYPE*)ComponentParameterStructure;
275 portIndex = pAudioPortFormat->nPortIndex;
276 err = omx_base_component_ParameterSanityCheck(hComponent, portIndex, pAudioPortFormat, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE));
277 if(err!=OMX_ErrorNone) {
278 DEBUG(DEB_LEV_ERR, "In %s Parameter Check Error=%x\n",__func__,err);
279 break;
280 }
281 if (portIndex <= omx_audio_mixer_component_Private->sPortTypesParam[OMX_PortDomainAudio].nPorts) {
282 port= (omx_audio_mixer_component_PortType *)omx_audio_mixer_component_Private->ports[portIndex];
283 memcpy(&port->sAudioParam, pAudioPortFormat, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE));
284 } else {
286 }
287 break;
289 pComponentRole = (OMX_PARAM_COMPONENTROLETYPE*)ComponentParameterStructure;
290
291 if (omx_audio_mixer_component_Private->state != OMX_StateLoaded && omx_audio_mixer_component_Private->state != OMX_StateWaitForResources) {
292 DEBUG(DEB_LEV_ERR, "In %s Incorrect State=%x lineno=%d\n",__func__,omx_audio_mixer_component_Private->state,__LINE__);
294 }
295
296 if ((err = checkHeader(ComponentParameterStructure, sizeof(OMX_PARAM_COMPONENTROLETYPE))) != OMX_ErrorNone) {
297 break;
298 }
299
300 if (strcmp( (char*) pComponentRole->cRole, MIXER_COMP_ROLE)) {
302 }
303 break;
304 default:
305 err = omx_base_component_SetParameter(hComponent, nParamIndex, ComponentParameterStructure);
306 }
307 return err;
308}
309
311 OMX_HANDLETYPE hComponent,
312 OMX_INDEXTYPE nParamIndex,
313 OMX_PTR ComponentParameterStructure) {
314
315 OMX_AUDIO_PARAM_PORTFORMATTYPE *pAudioPortFormat;
316 OMX_AUDIO_PARAM_PCMMODETYPE *pAudioPcmMode;
317 OMX_PARAM_COMPONENTROLETYPE *pComponentRole;
319 omx_audio_mixer_component_PortType *port;
320 OMX_COMPONENTTYPE *openmaxStandComp = (OMX_COMPONENTTYPE *)hComponent;
321 omx_audio_mixer_component_PrivateType *omx_audio_mixer_component_Private = openmaxStandComp->pComponentPrivate;
322 if (ComponentParameterStructure == NULL) {
324 }
325 DEBUG(DEB_LEV_SIMPLE_SEQ, " Getting parameter %i\n", nParamIndex);
326 /* Check which structure we are being fed and fill its header */
327 switch(nParamIndex) {
329 if ((err = checkHeader(ComponentParameterStructure, sizeof(OMX_PORT_PARAM_TYPE))) != OMX_ErrorNone) {
330 break;
331 }
332 memcpy(ComponentParameterStructure, &omx_audio_mixer_component_Private->sPortTypesParam[OMX_PortDomainAudio], sizeof(OMX_PORT_PARAM_TYPE));
333 break;
335 pAudioPortFormat = (OMX_AUDIO_PARAM_PORTFORMATTYPE*)ComponentParameterStructure;
336 if ((err = checkHeader(ComponentParameterStructure, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE))) != OMX_ErrorNone) {
337 break;
338 }
339 if (pAudioPortFormat->nPortIndex <= omx_audio_mixer_component_Private->sPortTypesParam[OMX_PortDomainAudio].nPorts) {
340 port= (omx_audio_mixer_component_PortType *)omx_audio_mixer_component_Private->ports[pAudioPortFormat->nPortIndex];
341 memcpy(pAudioPortFormat, &port->sAudioParam, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE));
342 } else {
344 }
345 break;
347 pAudioPcmMode = (OMX_AUDIO_PARAM_PCMMODETYPE*)ComponentParameterStructure;
348 if ((err = checkHeader(ComponentParameterStructure, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE))) != OMX_ErrorNone) {
349 break;
350 }
351
352 if (pAudioPcmMode->nPortIndex <= omx_audio_mixer_component_Private->sPortTypesParam[OMX_PortDomainAudio].nPorts) {
353 port= (omx_audio_mixer_component_PortType *)omx_audio_mixer_component_Private->ports[pAudioPcmMode->nPortIndex];
354 memcpy(pAudioPcmMode, &port->pAudioPcmMode, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE));
355 } else {
357 }
358 break;
360 pComponentRole = (OMX_PARAM_COMPONENTROLETYPE*)ComponentParameterStructure;
361 if ((err = checkHeader(ComponentParameterStructure, sizeof(OMX_PARAM_COMPONENTROLETYPE))) != OMX_ErrorNone) {
362 break;
363 }
364 strcpy( (char*) pComponentRole->cRole, MIXER_COMP_ROLE);
365 break;
366 default:
367 err = omx_base_component_GetParameter(hComponent, nParamIndex, ComponentParameterStructure);
368 }
369 return err;
370}
371
372int checkAnyPortBeingFlushed(omx_audio_mixer_component_PrivateType* omx_audio_mixer_component_Private) {
373 omx_base_PortType *pPort;
374 int ret = OMX_FALSE,i;
375
376 if(omx_audio_mixer_component_Private->state == OMX_StateLoaded ||
377 omx_audio_mixer_component_Private->state == OMX_StateInvalid) {
378 return 0;
379 }
380
381 pthread_mutex_lock(&omx_audio_mixer_component_Private->flush_mutex);
382 for (i=0; i < omx_audio_mixer_component_Private->sPortTypesParam[OMX_PortDomainAudio].nPorts; i++) {
383 pPort = omx_audio_mixer_component_Private->ports[i];
384 if(PORT_IS_BEING_FLUSHED(pPort)) {
385 ret = OMX_TRUE;
386 break;
387 }
388 }
389 pthread_mutex_unlock(&omx_audio_mixer_component_Private->flush_mutex);
390
391 return ret;
392}
393
400 OMX_COMPONENTTYPE* openmaxStandComp = (OMX_COMPONENTTYPE*)param;
401 omx_audio_mixer_component_PrivateType* omx_audio_mixer_component_Private = (omx_audio_mixer_component_PrivateType*)openmaxStandComp->pComponentPrivate;
402
404 tsem_t* pSem[MAX_PORTS];
405 queue_t* pQueue[MAX_PORTS];
407 OMX_BOOL isBufferNeeded[MAX_PORTS];
408 OMX_COMPONENTTYPE* target_component;
409 OMX_U32 nOutputPortIndex,i;
410
411 for(i=0;i<omx_audio_mixer_component_Private->sPortTypesParam[OMX_PortDomainAudio].nPorts;i++){
412 pPort[i] = omx_audio_mixer_component_Private->ports[i];
413 pSem[i] = pPort[i]->pBufferSem;
414 pQueue[i] = pPort[i]->pBufferQueue;
415 pBuffer[i] = NULL;
416 isBufferNeeded[i] = OMX_TRUE;
417 }
418
419 nOutputPortIndex = omx_audio_mixer_component_Private->sPortTypesParam[OMX_PortDomainAudio].nPorts - 1;
420
421
422 DEBUG(DEB_LEV_FUNCTION_NAME, "In %s\n", __func__);
423 while(omx_audio_mixer_component_Private->state == OMX_StateIdle || omx_audio_mixer_component_Private->state == OMX_StateExecuting || omx_audio_mixer_component_Private->state == OMX_StatePause ||
424 omx_audio_mixer_component_Private->transientState == OMX_TransStateLoadedToIdle) {
425
426 /*Wait till the ports are being flushed*/
427 while( checkAnyPortBeingFlushed(omx_audio_mixer_component_Private) ) {
428
429 DEBUG(DEB_LEV_FULL_SEQ, "In %s 1 signalling flush all cond iF=%d,oF=%d iSemVal=%d,oSemval=%d\n",
430 __func__,isBufferNeeded[0],isBufferNeeded[nOutputPortIndex],pSem[0]->semval,pSem[nOutputPortIndex]->semval);
431
432 for(i=0;i<omx_audio_mixer_component_Private->sPortTypesParam[OMX_PortDomainAudio].nPorts;i++){
433 if(isBufferNeeded[i]==OMX_FALSE && PORT_IS_BEING_FLUSHED(pPort[i])) {
434 pPort[i]->ReturnBufferFunction(pPort[i],pBuffer[i]);
435 pBuffer[i]=NULL;
436 isBufferNeeded[i]=OMX_TRUE;
437 DEBUG(DEB_LEV_FULL_SEQ, "Ports are flushing,so returning buffer %i\n",(int)i);
438 }
439 }
440
441 DEBUG(DEB_LEV_FULL_SEQ, "In %s 2 signalling flush all cond iF=%d,oF=%d iSemVal=%d,oSemval=%d\n",
442 __func__,isBufferNeeded[0],isBufferNeeded[nOutputPortIndex],pSem[0]->semval,pSem[nOutputPortIndex]->semval);
443
444 tsem_up(omx_audio_mixer_component_Private->flush_all_condition);
445 tsem_down(omx_audio_mixer_component_Private->flush_condition);
446 }
447
448 if(omx_audio_mixer_component_Private->state == OMX_StateLoaded || omx_audio_mixer_component_Private->state == OMX_StateInvalid) {
449 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s Buffer Management Thread is exiting\n",__func__);
450 break;
451 }
452
453 /*No buffer to process. So wait here*/
454 for(i=0;i<omx_audio_mixer_component_Private->sPortTypesParam[OMX_PortDomainAudio].nPorts;i++){
455 if((isBufferNeeded[i]==OMX_TRUE && pSem[i]->semval==0) &&
456 (omx_audio_mixer_component_Private->state != OMX_StateLoaded && omx_audio_mixer_component_Private->state != OMX_StateInvalid) &&
457 PORT_IS_ENABLED(pPort[i]) && !PORT_IS_BEING_FLUSHED(pPort[i])) {
458 //Signalled from EmptyThisBuffer or FillThisBuffer or some thing else
459 DEBUG(DEB_LEV_FULL_SEQ, "Waiting for next input/output buffer\n");
460 tsem_down(omx_audio_mixer_component_Private->bMgmtSem);
461
462 }
463 /*Don't wait for buffers, if any port is flushing*/
464 if(checkAnyPortBeingFlushed(omx_audio_mixer_component_Private)) {
465 break;
466 }
467 if(omx_audio_mixer_component_Private->state == OMX_StateLoaded || omx_audio_mixer_component_Private->state == OMX_StateInvalid) {
468 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s Buffer Management Thread is exiting\n",__func__);
469 break;
470 }
471 }
472
473 for(i=0;i<omx_audio_mixer_component_Private->sPortTypesParam[OMX_PortDomainAudio].nPorts;i++){
474 DEBUG(DEB_LEV_SIMPLE_SEQ, "Waiting for buffer %i semval=%d \n",(int)i,pSem[i]->semval);
475 if(pSem[i]->semval>0 && isBufferNeeded[i]==OMX_TRUE && PORT_IS_ENABLED(pPort[i])) {
476 tsem_down(pSem[i]);
477 if(pQueue[i]->nelem>0){
478 isBufferNeeded[i]=OMX_FALSE;
479 pBuffer[i] = dequeue(pQueue[i]);
480 if(pBuffer[i] == NULL){
481 DEBUG(DEB_LEV_ERR, "Had NULL input buffer!!\n");
482 break;
483 }
484 }
485 }
486 }
487
488 if(isBufferNeeded[nOutputPortIndex]==OMX_FALSE) {
489
490 if(omx_audio_mixer_component_Private->pMark.hMarkTargetComponent != NULL){
491 pBuffer[nOutputPortIndex]->hMarkTargetComponent = omx_audio_mixer_component_Private->pMark.hMarkTargetComponent;
492 pBuffer[nOutputPortIndex]->pMarkData = omx_audio_mixer_component_Private->pMark.pMarkData;
493 omx_audio_mixer_component_Private->pMark.hMarkTargetComponent = NULL;
494 omx_audio_mixer_component_Private->pMark.pMarkData = NULL;
495 }
496 for(i=0;i<omx_audio_mixer_component_Private->sPortTypesParam[OMX_PortDomainAudio].nPorts-1;i++){
497 if(isBufferNeeded[i]==OMX_FALSE && PORT_IS_ENABLED(pPort[i])) {
498
499 if(isBufferNeeded[i]==OMX_FALSE) {
500 target_component=(OMX_COMPONENTTYPE*)pBuffer[i]->hMarkTargetComponent;
501 if(target_component==(OMX_COMPONENTTYPE *)openmaxStandComp) {
502 /*Clear the mark and generate an event*/
503 (*(omx_audio_mixer_component_Private->callbacks->EventHandler))
504 (openmaxStandComp,
505 omx_audio_mixer_component_Private->callbackData,
506 OMX_EventMark, /* The command was completed */
507 1, /* The commands was a OMX_CommandStateSet */
508 0, /* The state has been changed in message->messageParam2 */
509 pBuffer[i]->pMarkData);
510 } else if(pBuffer[i]->hMarkTargetComponent!=NULL){
511 /*If this is not the target component then pass the mark*/
512 pBuffer[nOutputPortIndex]->hMarkTargetComponent = pBuffer[i]->hMarkTargetComponent;
513 pBuffer[nOutputPortIndex]->pMarkData = pBuffer[i]->pMarkData;
514 pBuffer[i]->pMarkData=NULL;
515 }
516 pBuffer[nOutputPortIndex]->nTimeStamp = pBuffer[i]->nTimeStamp;
517 }
518
519 if((pBuffer[i]->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS && pBuffer[i]->nFilledLen==0) {
520 DEBUG(DEB_LEV_FULL_SEQ, "Detected EOS flags in input buffer %p of %i filled len=%d\n", pBuffer[i], (int)i, (int)pBuffer[i]->nFilledLen);
521 pBuffer[nOutputPortIndex]->nFlags = pBuffer[i]->nFlags;
522 pBuffer[i]->nFlags=0;
523 (*(omx_audio_mixer_component_Private->callbacks->EventHandler))
524 (openmaxStandComp,
525 omx_audio_mixer_component_Private->callbackData,
526 OMX_EventBufferFlag, /* The command was completed */
527 nOutputPortIndex, /* The commands was a OMX_CommandStateSet */
528 pBuffer[nOutputPortIndex]->nFlags, /* The state has been changed in message->messageParam2 */
529 NULL);
530 }
531
532 //TBD: To be verified
533 if(omx_audio_mixer_component_Private->state == OMX_StateExecuting) {
534 if (omx_audio_mixer_component_Private->BufferMgmtCallback && pBuffer[i]->nFilledLen != 0) {
535 (*(omx_audio_mixer_component_Private->BufferMgmtCallback))(openmaxStandComp, pBuffer[i], pBuffer[nOutputPortIndex]);
536 } else {
537 /*It no buffer management call back the explicitly consume input buffer*/
538 pBuffer[i]->nFilledLen = 0;
539 }
540 } else {
541 DEBUG(DEB_LEV_ERR, "In %s Received Buffer in non-Executing State(%x)\n", __func__, (int)omx_audio_mixer_component_Private->state);
542 if(OMX_TransStateExecutingToIdle == omx_audio_mixer_component_Private->transientState ||
543 OMX_TransStatePauseToIdle == omx_audio_mixer_component_Private->transientState) {
544 pBuffer[i]->nFilledLen = 0;
545 }
546 }
547
548 /*Input Buffer has been completely consumed. So, get new input buffer*/
549 if(pBuffer[i]->nFilledLen==0) {
550 isBufferNeeded[i] = OMX_TRUE;
551 }
552 }
553 }
554
555 if(omx_audio_mixer_component_Private->state==OMX_StatePause &&
556 !(checkAnyPortBeingFlushed(omx_audio_mixer_component_Private))) {
557 /*Waiting at paused state*/
558 tsem_wait(omx_audio_mixer_component_Private->bStateSem);
559 }
560
561 /*If EOS and Input buffer Filled Len Zero then Return output buffer immediately*/
562 if(pBuffer[nOutputPortIndex]->nFilledLen!=0 || (pBuffer[nOutputPortIndex]->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS){
563 DEBUG(DEB_LEV_SIMPLE_SEQ, "Returning output buffer \n");
564 pPort[nOutputPortIndex]->ReturnBufferFunction(pPort[nOutputPortIndex],pBuffer[nOutputPortIndex]);
565 pBuffer[nOutputPortIndex]=NULL;
566 isBufferNeeded[nOutputPortIndex]=OMX_TRUE;
567 }
568 }
569
570 DEBUG(DEB_LEV_FULL_SEQ, "Input buffer arrived\n");
571
572 if(omx_audio_mixer_component_Private->state==OMX_StatePause &&
573 !(checkAnyPortBeingFlushed(omx_audio_mixer_component_Private))) {
574 /*Waiting at paused state*/
575 tsem_wait(omx_audio_mixer_component_Private->bStateSem);
576 }
577
578 /*Input Buffer has been completely consumed. So, return input buffer*/
579 for(i=0;i<omx_audio_mixer_component_Private->sPortTypesParam[OMX_PortDomainAudio].nPorts-1;i++){
580 if(isBufferNeeded[i] == OMX_TRUE && pBuffer[i]!=NULL && PORT_IS_ENABLED(pPort[i])) {
581 pPort[i]->ReturnBufferFunction(pPort[i],pBuffer[i]);
582 pBuffer[i]=NULL;
583 }
584 }
585 }
586 DEBUG(DEB_LEV_SIMPLE_SEQ,"Exiting Buffer Management Thread\n");
587 return NULL;
588}
589
OMX_ERRORTYPE
Definition OMX_Core.h:127
@ OMX_ErrorInsufficientResources
Definition OMX_Core.h:131
@ OMX_ErrorBadPortIndex
Definition OMX_Core.h:224
@ OMX_ErrorNone
Definition OMX_Core.h:128
@ OMX_ErrorBadParameter
Definition OMX_Core.h:147
@ OMX_ErrorIncorrectStateOperation
Definition OMX_Core.h:215
OMX_INDEXTYPE
Definition OMX_Index.h:60
@ OMX_IndexParamAudioPortFormat
Definition OMX_Index.h:94
@ OMX_IndexParamAudioInit
Definition OMX_Index.h:64
@ OMX_IndexParamStandardComponentRole
Definition OMX_Index.h:85
@ OMX_IndexConfigAudioVolume
Definition OMX_Index.h:128
@ OMX_IndexParamAudioPcm
Definition OMX_Index.h:95
unsigned long OMX_U32
Definition OMX_Types.h:145
char * OMX_STRING
Definition OMX_Types.h:206
@ OMX_EndianBig
Definition OMX_Types.h:236
OMX_BOOL
Definition OMX_Types.h:189
@ OMX_TRUE
Definition OMX_Types.h:191
@ OMX_FALSE
Definition OMX_Types.h:190
void * OMX_PTR
Definition OMX_Types.h:199
@ OMX_NumericalDataSigned
Definition OMX_Types.h:247
void * OMX_HANDLETYPE
Definition OMX_Types.h:295
signed long OMX_S32
Definition OMX_Types.h:148
signed short OMX_S16
Definition OMX_Types.h:142
@ OMX_AUDIO_PCMModeLinear
Definition OMX_Audio.h:130
#define OMX_BUFFERFLAG_EOS
Definition OMX_Core.h:299
@ OMX_PortDomainAudio
@ OMX_StateExecuting
Definition OMX_Core.h:105
@ OMX_StateWaitForResources
Definition OMX_Core.h:108
@ OMX_StateLoaded
Definition OMX_Core.h:97
@ OMX_StateInvalid
Definition OMX_Core.h:94
@ OMX_StateIdle
Definition OMX_Core.h:102
@ OMX_StatePause
Definition OMX_Core.h:107
@ OMX_EventMark
Definition OMX_Core.h:483
@ OMX_EventBufferFlag
Definition OMX_Core.h:485
OMX_ERRORTYPE omx_audio_mixer_component_GetParameter(OMX_HANDLETYPE hComponent, OMX_INDEXTYPE nParamIndex, OMX_PTR ComponentParameterStructure)
int checkAnyPortBeingFlushed(omx_audio_mixer_component_PrivateType *omx_audio_mixer_component_Private)
#define GAIN_VALUE
void omx_audio_mixer_component_BufferMgmtCallback(OMX_COMPONENTTYPE *openmaxStandComp, OMX_BUFFERHEADERTYPE *pInBuffer, OMX_BUFFERHEADERTYPE *pOutBuffer)
OMX_ERRORTYPE omx_audio_mixer_component_SetParameter(OMX_HANDLETYPE hComponent, OMX_INDEXTYPE nParamIndex, OMX_PTR ComponentParameterStructure)
OMX_ERRORTYPE omx_audio_mixer_component_GetConfig(OMX_HANDLETYPE hComponent, OMX_INDEXTYPE nIndex, OMX_PTR pComponentConfigStructure)
OMX_ERRORTYPE omx_audio_mixer_component_Constructor(OMX_COMPONENTTYPE *openmaxStandComp, OMX_STRING cComponentName)
OMX_ERRORTYPE omx_audio_mixer_component_SetConfig(OMX_HANDLETYPE hComponent, OMX_INDEXTYPE nIndex, OMX_PTR pComponentConfigStructure)
OMX_ERRORTYPE omx_audio_mixer_component_Destructor(OMX_COMPONENTTYPE *openmaxStandComp)
void * omx_audio_mixer_BufferMgmtFunction(void *param)
#define MAX_PORTS
#define MIXER_QUALITY_LEVELS
#define MIXER_COMP_NAME
#define MIXER_COMP_ROLE
#define MAX_MIXER_COMPONENTS
OMX_ERRORTYPE base_audio_port_Constructor(OMX_COMPONENTTYPE *openmaxStandComp, omx_base_PortType **openmaxStandPort, OMX_U32 nPortIndex, OMX_BOOL isInput)
The base constructor for the generic OpenMAX ST Audio port.
OMX_ERRORTYPE omx_base_component_SetParameter(OMX_HANDLETYPE hComponent, OMX_INDEXTYPE nParamIndex, OMX_PTR ComponentParameterStructure)
Part of the standard OpenMAX function.
OMX_ERRORTYPE omx_base_component_ParameterSanityCheck(OMX_HANDLETYPE hComponent, OMX_U32 nPortIndex, OMX_PTR pStructure, size_t size)
void setHeader(OMX_PTR header, OMX_U32 size)
Simply fills the first two fields in any OMX structure with the size and the version.
OMX_ERRORTYPE omx_base_component_GetParameter(OMX_HANDLETYPE hComponent, OMX_INDEXTYPE nParamIndex, OMX_PTR ComponentParameterStructure)
Part of the standard OpenMAX function.
OMX_ERRORTYPE omx_base_component_SetConfig(OMX_HANDLETYPE hComponent, OMX_INDEXTYPE nIndex, OMX_PTR pComponentConfigStructure)
base SetConfig function
OMX_ERRORTYPE omx_base_component_GetConfig(OMX_HANDLETYPE hComponent, OMX_INDEXTYPE nIndex, OMX_PTR pComponentConfigStructure)
base GetConfig function
OMX_ERRORTYPE checkHeader(OMX_PTR header, OMX_U32 size)
Checks the header of a structure for consistency with size and spec version.
#define DEFAULT_OUT_BUFFER_SIZE
@ OMX_TransStateExecutingToIdle
@ OMX_TransStatePauseToIdle
@ OMX_TransStateLoadedToIdle
OMX_ERRORTYPE omx_base_filter_Constructor(OMX_COMPONENTTYPE *openmaxStandComp, OMX_STRING cComponentName)
The base filter contructor for the OpenMAX ST components.
OMX_ERRORTYPE omx_base_filter_Destructor(OMX_COMPONENTTYPE *openmaxStandComp)
the base filter destructor for ST OpenMAX components
#define PORT_IS_ENABLED(pPort)
#define PORT_IS_BEING_FLUSHED(pPort)
#define DEB_LEV_FUNCTION_NAME
#define DEB_LEV_ERR
#define DEB_LEV_SIMPLE_SEQ
#define DEB_LEV_FULL_SEQ
#define DEBUG(n, fmt, args...)
OMX_ERRORTYPE RM_RegisterComponent(char *name, int max_components)
OMX_ERRORTYPE err
void * dequeue(queue_t *queue)
Definition queue.c:122
OMX_S32 nValue
Definition OMX_Types.h:263
OMX_U32 nInputPortIndex
Definition OMX_Core.h:441
OMX_TICKS nTimeStamp
Definition OMX_Core.h:431
OMX_HANDLETYPE hMarkTargetComponent
Definition OMX_Core.h:417
OMX_ERRORTYPE(* GetConfig)(OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_INDEXTYPE nIndex, OMX_INOUT OMX_PTR pComponentConfigStructure)
OMX_ERRORTYPE(* SetConfig)(OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_INDEXTYPE nIndex, OMX_IN OMX_PTR pComponentConfigStructure)
OMX_ERRORTYPE(* SetParameter)(OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_INDEXTYPE nIndex, OMX_IN OMX_PTR pComponentParameterStructure)
OMX_ERRORTYPE(* GetParameter)(OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_INDEXTYPE nParamIndex, OMX_INOUT OMX_PTR pComponentParameterStructure)
OMX_ERRORTYPE(* ReturnBufferFunction)(omx_base_PortType *openmaxStandPort, OMX_BUFFERHEADERTYPE *pBuffer)
void tsem_up(tsem_t *tsem)
Definition tsemaphore.c:110
void tsem_down(tsem_t *tsem)
Definition tsemaphore.c:97
void tsem_wait(tsem_t *tsem)
Definition tsemaphore.c:131

Generated for OpenMAX Bellagio rel. 0.9.3 by  doxygen 1.5.1
SourceForge.net Logo