00001
00030 #include <omxcore.h>
00031 #include <omx_base_audio_port.h>
00032 #include <omx_audiomixer_component.h>
00033 #include<OMX_Audio.h>
00034
00035 #define OMX_AUDIO_MIXER_INPUTPORT_INDEX 0
00036 #define OMX_AUDIO_MIXER_INPUTPORT_INDEX_1 1
00037 #define OMX_AUDIO_MIXER_OUTPUTPORT_INDEX 2
00038
00039
00040 #define GAIN_VALUE 100.0f
00041
00042
00043 #define MAX_COMPONENT_AUDIO_MIXER 1
00044
00046 static OMX_U32 noAudioMixerCompInstance = 0;
00047
00048
00049 OMX_ERRORTYPE omx_audio_mixer_component_Constructor(OMX_COMPONENTTYPE *openmaxStandComp, OMX_STRING cComponentName) {
00050 OMX_ERRORTYPE err = OMX_ErrorNone;
00051 omx_audio_mixer_component_PrivateType* omx_audio_mixer_component_Private;
00052 omx_audio_mixer_component_PortType *pPort;
00053 OMX_U32 i;
00054
00055 if (!openmaxStandComp->pComponentPrivate) {
00056 DEBUG(DEB_LEV_FUNCTION_NAME, "In %s, allocating component\n",__func__);
00057 openmaxStandComp->pComponentPrivate = calloc(1, sizeof(omx_audio_mixer_component_PrivateType));
00058 if(openmaxStandComp->pComponentPrivate == NULL) {
00059 return OMX_ErrorInsufficientResources;
00060 }
00061 } else {
00062 DEBUG(DEB_LEV_FUNCTION_NAME, "In %s, Error Component %x Already Allocated\n", __func__, (int)openmaxStandComp->pComponentPrivate);
00063 }
00064
00065 omx_audio_mixer_component_Private = openmaxStandComp->pComponentPrivate;
00066 omx_audio_mixer_component_Private->ports = NULL;
00067
00069 err = omx_base_filter_Constructor(openmaxStandComp, cComponentName);
00070
00071
00072 omx_audio_mixer_component_Private->sPortTypesParam.nPorts = MAX_PORTS;
00073
00075 if (omx_audio_mixer_component_Private->sPortTypesParam.nPorts && !omx_audio_mixer_component_Private->ports) {
00076 omx_audio_mixer_component_Private->ports = calloc(omx_audio_mixer_component_Private->sPortTypesParam.nPorts, sizeof(omx_base_PortType *));
00077 if (!omx_audio_mixer_component_Private->ports) {
00078 return OMX_ErrorInsufficientResources;
00079 }
00080 for (i=0; i < omx_audio_mixer_component_Private->sPortTypesParam.nPorts; i++) {
00081 omx_audio_mixer_component_Private->ports[i] = calloc(1, sizeof(omx_audio_mixer_component_PortType));
00082 if (!omx_audio_mixer_component_Private->ports[i]) {
00083 return OMX_ErrorInsufficientResources;
00084 }
00085 }
00086 }
00087
00088
00089 for(i=0;i<omx_audio_mixer_component_Private->sPortTypesParam.nPorts-1;i++) {
00090 base_audio_port_Constructor(openmaxStandComp, &omx_audio_mixer_component_Private->ports[i], i, OMX_TRUE);
00091 }
00092
00093
00094 base_audio_port_Constructor(openmaxStandComp, &omx_audio_mixer_component_Private->ports[omx_audio_mixer_component_Private->sPortTypesParam.nPorts-1], omx_audio_mixer_component_Private->sPortTypesParam.nPorts-1, OMX_FALSE);
00095
00097 for(i=0;i<omx_audio_mixer_component_Private->sPortTypesParam.nPorts;i++) {
00098 pPort = (omx_audio_mixer_component_PortType *) omx_audio_mixer_component_Private->ports[i];
00099
00100 pPort->sPortParam.nBufferSize = DEFAULT_OUT_BUFFER_SIZE;
00101 pPort->gain = GAIN_VALUE;
00102
00103 setHeader(&pPort->pAudioPcmMode,sizeof(OMX_AUDIO_PARAM_PCMMODETYPE));
00104 pPort->pAudioPcmMode.nPortIndex = i;
00105 pPort->pAudioPcmMode.nChannels = 2;
00106 pPort->pAudioPcmMode.eNumData = OMX_NumericalDataSigned;
00107 pPort->pAudioPcmMode.eEndian = OMX_EndianBig;
00108 pPort->pAudioPcmMode.bInterleaved = OMX_TRUE;
00109 pPort->pAudioPcmMode.nBitPerSample = 16;
00110 pPort->pAudioPcmMode.nSamplingRate = 44100;
00111 pPort->pAudioPcmMode.ePCMMode = OMX_AUDIO_PCMModeLinear;
00112
00113 setHeader(&pPort->sVolume,sizeof(OMX_AUDIO_CONFIG_VOLUMETYPE));
00114 pPort->sVolume.nPortIndex = i;
00115 pPort->sVolume.bLinear = OMX_TRUE;
00117 pPort->sVolume.sVolume.nValue = (OMX_S32)GAIN_VALUE;
00118 pPort->sVolume.sVolume.nMin = 0;
00119 pPort->sVolume.sVolume.nMax = (OMX_S32)GAIN_VALUE;
00120 }
00121
00122 omx_audio_mixer_component_Private->destructor = omx_audio_mixer_component_Destructor;
00123 openmaxStandComp->SetParameter = omx_audio_mixer_component_SetParameter;
00124 openmaxStandComp->GetParameter = omx_audio_mixer_component_GetParameter;
00125 openmaxStandComp->GetConfig = omx_audio_mixer_component_GetConfig;
00126 openmaxStandComp->SetConfig = omx_audio_mixer_component_SetConfig;
00127 omx_audio_mixer_component_Private->BufferMgmtCallback = omx_audio_mixer_component_BufferMgmtCallback;
00128 omx_audio_mixer_component_Private->BufferMgmtFunction = omx_audio_mixer_BufferMgmtFunction;
00129
00130 noAudioMixerCompInstance++;
00131 if(noAudioMixerCompInstance > MAX_COMPONENT_AUDIO_MIXER) {
00132 return OMX_ErrorInsufficientResources;
00133 }
00134
00135 return err;
00136 }
00137
00138
00141 OMX_ERRORTYPE omx_audio_mixer_component_Destructor(OMX_COMPONENTTYPE *openmaxStandComp) {
00142
00143 omx_audio_mixer_component_PrivateType* omx_audio_mixer_component_Private = openmaxStandComp->pComponentPrivate;
00144 OMX_U32 i;
00145
00146
00147 if (omx_audio_mixer_component_Private->ports) {
00148 for (i=0; i < omx_audio_mixer_component_Private->sPortTypesParam.nPorts; i++) {
00149 if(omx_audio_mixer_component_Private->ports[i])
00150 omx_audio_mixer_component_Private->ports[i]->PortDestructor(omx_audio_mixer_component_Private->ports[i]);
00151 }
00152 free(omx_audio_mixer_component_Private->ports);
00153 omx_audio_mixer_component_Private->ports=NULL;
00154 }
00155
00156 DEBUG(DEB_LEV_FUNCTION_NAME, "Destructor of audiodecoder component is called\n");
00157 omx_base_filter_Destructor(openmaxStandComp);
00158 noAudioMixerCompInstance--;
00159
00160 return OMX_ErrorNone;
00161 }
00162
00165 void omx_audio_mixer_component_BufferMgmtCallback(OMX_COMPONENTTYPE *openmaxStandComp, OMX_BUFFERHEADERTYPE* pInBuffer, OMX_BUFFERHEADERTYPE* pOutBuffer) {
00166 OMX_S32 denominator=0;
00167 OMX_U32 i,sampleCount = pInBuffer->nFilledLen / 2;
00168 omx_audio_mixer_component_PrivateType* omx_audio_mixer_component_Private = openmaxStandComp->pComponentPrivate;
00169 omx_audio_mixer_component_PortType* pPort;
00170
00171 for(i=0;i<omx_audio_mixer_component_Private->sPortTypesParam.nPorts-1;i++) {
00172 pPort = (omx_audio_mixer_component_PortType*)omx_audio_mixer_component_Private->ports[i];
00173 if(PORT_IS_ENABLED(pPort)){
00174 denominator+=pPort->sVolume.sVolume.nValue;
00175 }
00176 }
00177
00178 pPort = (omx_audio_mixer_component_PortType*)omx_audio_mixer_component_Private->ports[pInBuffer->nInputPortIndex];
00179
00180
00181 if(pOutBuffer->nFilledLen == 0) {
00182 memset(pOutBuffer->pBuffer,0,pInBuffer->nFilledLen);
00183
00184 for (i = 0; i < sampleCount; i++) {
00185 ((OMX_S16*) pOutBuffer->pBuffer)[i] = (OMX_S16)
00186 ((((OMX_S16*) pInBuffer->pBuffer)[i] * pPort->sVolume.sVolume.nValue ) / denominator);
00187 }
00188 } else {
00189 for (i = 0; i < sampleCount; i++) {
00190 ((OMX_S16*) pOutBuffer->pBuffer)[i] += (OMX_S16)
00191 ((((OMX_S16*) pInBuffer->pBuffer)[i] * pPort->sVolume.sVolume.nValue ) / denominator);
00192 }
00193 }
00194
00195 pOutBuffer->nFilledLen = pInBuffer->nFilledLen;
00196 pInBuffer->nFilledLen=0;
00197 }
00198
00200 OMX_ERRORTYPE omx_audio_mixer_component_SetConfig(
00201 OMX_IN OMX_HANDLETYPE hComponent,
00202 OMX_IN OMX_INDEXTYPE nIndex,
00203 OMX_IN OMX_PTR pComponentConfigStructure) {
00204
00205 OMX_AUDIO_CONFIG_VOLUMETYPE* pVolume;
00206 OMX_COMPONENTTYPE *openmaxStandComp = (OMX_COMPONENTTYPE *)hComponent;
00207 omx_audio_mixer_component_PrivateType* omx_audio_mixer_component_Private = openmaxStandComp->pComponentPrivate;
00208 omx_audio_mixer_component_PortType * pPort;
00209 OMX_ERRORTYPE err = OMX_ErrorNone;
00210
00211 switch (nIndex) {
00212 case OMX_IndexConfigAudioVolume :
00213 pVolume = (OMX_AUDIO_CONFIG_VOLUMETYPE*) pComponentConfigStructure;
00214 if(pVolume->sVolume.nValue > 100) {
00215 err = OMX_ErrorBadParameter;
00216 break;
00217 }
00218
00219 if (pVolume->nPortIndex <= omx_audio_mixer_component_Private->sPortTypesParam.nPorts) {
00220 pPort= (omx_audio_mixer_component_PortType *)omx_audio_mixer_component_Private->ports[pVolume->nPortIndex];
00221 DEBUG(DEB_LEV_SIMPLE_SEQ, "Port %i Gain=%d\n",(int)pVolume->nPortIndex,(int)pVolume->sVolume.nValue);
00222 memcpy(&pPort->sVolume, pVolume, sizeof(OMX_AUDIO_CONFIG_VOLUMETYPE));
00223 } else {
00224 err = OMX_ErrorBadPortIndex;
00225 }
00226 break;
00227 default:
00228 err = omx_base_component_SetConfig(hComponent, nIndex, pComponentConfigStructure);
00229 }
00230 return err;
00231 }
00232
00233 OMX_ERRORTYPE omx_audio_mixer_component_GetConfig(
00234 OMX_IN OMX_HANDLETYPE hComponent,
00235 OMX_IN OMX_INDEXTYPE nIndex,
00236 OMX_INOUT OMX_PTR pComponentConfigStructure) {
00237 OMX_AUDIO_CONFIG_VOLUMETYPE* pVolume;
00238 OMX_COMPONENTTYPE *openmaxStandComp = (OMX_COMPONENTTYPE *)hComponent;
00239 omx_audio_mixer_component_PrivateType* omx_audio_mixer_component_Private = openmaxStandComp->pComponentPrivate;
00240 omx_audio_mixer_component_PortType * pPort;
00241 OMX_ERRORTYPE err = OMX_ErrorNone;
00242
00243 switch (nIndex) {
00244 case OMX_IndexConfigAudioVolume :
00245 pVolume = (OMX_AUDIO_CONFIG_VOLUMETYPE*) pComponentConfigStructure;
00246 if (pVolume->nPortIndex <= omx_audio_mixer_component_Private->sPortTypesParam.nPorts) {
00247 pPort= (omx_audio_mixer_component_PortType *)omx_audio_mixer_component_Private->ports[pVolume->nPortIndex];
00248 memcpy(pVolume,&pPort->sVolume,sizeof(OMX_AUDIO_CONFIG_VOLUMETYPE));
00249 } else {
00250 err = OMX_ErrorBadPortIndex;
00251 }
00252 break;
00253 default :
00254 err = omx_base_component_GetConfig(hComponent, nIndex, pComponentConfigStructure);
00255 }
00256 return err;
00257 }
00258
00259 OMX_ERRORTYPE omx_audio_mixer_component_SetParameter(
00260 OMX_IN OMX_HANDLETYPE hComponent,
00261 OMX_IN OMX_INDEXTYPE nParamIndex,
00262 OMX_IN OMX_PTR ComponentParameterStructure) {
00263
00264 OMX_ERRORTYPE err = OMX_ErrorNone;
00265 OMX_AUDIO_PARAM_PORTFORMATTYPE *pAudioPortFormat;
00266 OMX_U32 portIndex;
00267 omx_audio_mixer_component_PortType *port;
00268
00269
00270 OMX_COMPONENTTYPE *openmaxStandComp = (OMX_COMPONENTTYPE *)hComponent;
00271 omx_audio_mixer_component_PrivateType* omx_audio_mixer_component_Private = openmaxStandComp->pComponentPrivate;
00272 if (ComponentParameterStructure == NULL) {
00273 return OMX_ErrorBadParameter;
00274 }
00275
00276 DEBUG(DEB_LEV_SIMPLE_SEQ, " Setting parameter %i\n", nParamIndex);
00277 switch(nParamIndex) {
00278 case OMX_IndexParamAudioPortFormat:
00279 pAudioPortFormat = (OMX_AUDIO_PARAM_PORTFORMATTYPE*)ComponentParameterStructure;
00280 portIndex = pAudioPortFormat->nPortIndex;
00281 err = omx_base_component_ParameterSanityCheck(hComponent, portIndex, pAudioPortFormat, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE));
00282 if(err!=OMX_ErrorNone) {
00283 DEBUG(DEB_LEV_ERR, "In %s Parameter Check Error=%x\n",__func__,err);
00284 break;
00285 }
00286 if (portIndex <= omx_audio_mixer_component_Private->sPortTypesParam.nPorts) {
00287 port= (omx_audio_mixer_component_PortType *)omx_audio_mixer_component_Private->ports[portIndex];
00288 memcpy(&port->sAudioParam, pAudioPortFormat, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE));
00289 } else {
00290 err = OMX_ErrorBadPortIndex;
00291 }
00292 break;
00293 default:
00294 err = omx_base_component_SetParameter(hComponent, nParamIndex, ComponentParameterStructure);
00295 }
00296 return err;
00297 }
00298
00299 OMX_ERRORTYPE omx_audio_mixer_component_GetParameter(
00300 OMX_IN OMX_HANDLETYPE hComponent,
00301 OMX_IN OMX_INDEXTYPE nParamIndex,
00302 OMX_INOUT OMX_PTR ComponentParameterStructure) {
00303
00304 OMX_AUDIO_PARAM_PORTFORMATTYPE *pAudioPortFormat;
00305 OMX_AUDIO_PARAM_PCMMODETYPE *pAudioPcmMode;
00306 OMX_ERRORTYPE err = OMX_ErrorNone;
00307 omx_audio_mixer_component_PortType *port;
00308 OMX_COMPONENTTYPE *openmaxStandComp = (OMX_COMPONENTTYPE *)hComponent;
00309 omx_audio_mixer_component_PrivateType* omx_audio_mixer_component_Private = openmaxStandComp->pComponentPrivate;
00310 if (ComponentParameterStructure == NULL) {
00311 return OMX_ErrorBadParameter;
00312 }
00313 DEBUG(DEB_LEV_SIMPLE_SEQ, " Getting parameter %i\n", nParamIndex);
00314
00315 switch(nParamIndex) {
00316 case OMX_IndexParamAudioInit:
00317 if ((err = checkHeader(ComponentParameterStructure, sizeof(OMX_PORT_PARAM_TYPE))) != OMX_ErrorNone) {
00318 break;
00319 }
00320 memcpy(ComponentParameterStructure, &omx_audio_mixer_component_Private->sPortTypesParam, sizeof(OMX_PORT_PARAM_TYPE));
00321 break;
00322 case OMX_IndexParamAudioPortFormat:
00323 pAudioPortFormat = (OMX_AUDIO_PARAM_PORTFORMATTYPE*)ComponentParameterStructure;
00324 if ((err = checkHeader(ComponentParameterStructure, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE))) != OMX_ErrorNone) {
00325 break;
00326 }
00327 if (pAudioPortFormat->nPortIndex <= 1) {
00328 port= (omx_audio_mixer_component_PortType *)omx_audio_mixer_component_Private->ports[pAudioPortFormat->nPortIndex];
00329 memcpy(pAudioPortFormat, &port->sAudioParam, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE));
00330 } else {
00331 err = OMX_ErrorBadPortIndex;
00332 }
00333 break;
00334 case OMX_IndexParamAudioPcm:
00335 pAudioPcmMode = (OMX_AUDIO_PARAM_PCMMODETYPE*)ComponentParameterStructure;
00336 if ((err = checkHeader(ComponentParameterStructure, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE))) != OMX_ErrorNone) {
00337 break;
00338 }
00339
00340 if (pAudioPcmMode->nPortIndex <= omx_audio_mixer_component_Private->sPortTypesParam.nPorts) {
00341 port= (omx_audio_mixer_component_PortType *)omx_audio_mixer_component_Private->ports[pAudioPcmMode->nPortIndex];
00342 memcpy(pAudioPcmMode, &port->pAudioPcmMode, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE));
00343 } else {
00344 err = OMX_ErrorBadPortIndex;
00345 }
00346 break;
00347 default:
00348 err = omx_base_component_GetParameter(hComponent, nParamIndex, ComponentParameterStructure);
00349 }
00350 return err;
00351 }
00352
00358 void* omx_audio_mixer_BufferMgmtFunction (void* param) {
00359 OMX_COMPONENTTYPE* openmaxStandComp = (OMX_COMPONENTTYPE*)param;
00360 omx_audio_mixer_component_PrivateType* omx_audio_mixer_component_Private = (omx_audio_mixer_component_PrivateType*)openmaxStandComp->pComponentPrivate;
00361
00362 omx_base_PortType *pPort[MAX_PORTS];
00363 tsem_t* pSem[MAX_PORTS];
00364 queue_t* pQueue[MAX_PORTS];
00365 OMX_BUFFERHEADERTYPE* pBuffer[MAX_PORTS];
00366 OMX_BOOL isBufferNeeded[MAX_PORTS];
00367 OMX_COMPONENTTYPE* target_component;
00368 OMX_U32 nOutputPortIndex,i;
00369
00370 for(i=0;i<omx_audio_mixer_component_Private->sPortTypesParam.nPorts;i++){
00371 pPort[i] = omx_audio_mixer_component_Private->ports[i];
00372 pSem[i] = pPort[i]->pBufferSem;
00373 pQueue[i] = pPort[i]->pBufferQueue;
00374 pBuffer[i] = NULL;
00375 isBufferNeeded[i] = OMX_TRUE;
00376 }
00377
00378 nOutputPortIndex = omx_audio_mixer_component_Private->sPortTypesParam.nPorts - 1;
00379
00380
00381 DEBUG(DEB_LEV_FUNCTION_NAME, "In %s\n", __func__);
00382 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 ||
00383 omx_audio_mixer_component_Private->transientState == OMX_TransStateLoadedToIdle){
00384
00385
00386 pthread_mutex_lock(&omx_audio_mixer_component_Private->flush_mutex);
00387 while( PORT_IS_BEING_FLUSHED(pPort[0]) ||
00388 PORT_IS_BEING_FLUSHED(pPort[1]) ||
00389 PORT_IS_BEING_FLUSHED(pPort[2]) ||
00390 PORT_IS_BEING_FLUSHED(pPort[3]) ||
00391 PORT_IS_BEING_FLUSHED(pPort[nOutputPortIndex])) {
00392 pthread_mutex_unlock(&omx_audio_mixer_component_Private->flush_mutex);
00393
00394 DEBUG(DEB_LEV_FULL_SEQ, "In %s 1 signalling flush all cond iF=%d,oF=%d iSemVal=%d,oSemval=%d\n",
00395 __func__,isBufferNeeded[0],isBufferNeeded[nOutputPortIndex],pSem[0]->semval,pSem[nOutputPortIndex]->semval);
00396
00397 for(i=0;i<omx_audio_mixer_component_Private->sPortTypesParam.nPorts;i++){
00398 if(isBufferNeeded[i]==OMX_FALSE && PORT_IS_BEING_FLUSHED(pPort[i])) {
00399 pPort[i]->ReturnBufferFunction(pPort[i],pBuffer[i]);
00400 pBuffer[i]=NULL;
00401 isBufferNeeded[i]=OMX_TRUE;
00402 DEBUG(DEB_LEV_FULL_SEQ, "Ports are flushing,so returning buffer %i\n",(int)i);
00403 }
00404 }
00405
00406 DEBUG(DEB_LEV_FULL_SEQ, "In %s 2 signalling flush all cond iF=%d,oF=%d iSemVal=%d,oSemval=%d\n",
00407 __func__,isBufferNeeded[0],isBufferNeeded[nOutputPortIndex],pSem[0]->semval,pSem[nOutputPortIndex]->semval);
00408
00409 pthread_mutex_lock(&omx_audio_mixer_component_Private->flush_mutex);
00410 pthread_cond_signal(&omx_audio_mixer_component_Private->flush_all_condition);
00411 pthread_cond_wait(&omx_audio_mixer_component_Private->flush_condition,&omx_audio_mixer_component_Private->flush_mutex);
00412 }
00413 pthread_mutex_unlock(&omx_audio_mixer_component_Private->flush_mutex);
00414
00415
00416 for(i=0;i<omx_audio_mixer_component_Private->sPortTypesParam.nPorts;i++){
00417 if((isBufferNeeded[i]==OMX_TRUE && pSem[i]->semval==0) &&
00418 (omx_audio_mixer_component_Private->state != OMX_StateLoaded && omx_audio_mixer_component_Private->state != OMX_StateInvalid) &&
00419 PORT_IS_ENABLED(pPort[i]) && !PORT_IS_BEING_FLUSHED(pPort[i])) {
00420
00421 DEBUG(DEB_LEV_FULL_SEQ, "Waiting for next input/output buffer\n");
00422 tsem_down(omx_audio_mixer_component_Private->bMgmtSem);
00423
00424 }
00425
00426 if(PORT_IS_BEING_FLUSHED(pPort[0]) ||
00427 PORT_IS_BEING_FLUSHED(pPort[1]) ||
00428 PORT_IS_BEING_FLUSHED(pPort[2]) ||
00429 PORT_IS_BEING_FLUSHED(pPort[3]) ||
00430 PORT_IS_BEING_FLUSHED(pPort[nOutputPortIndex])){
00431 break;
00432 }
00433 if(omx_audio_mixer_component_Private->state == OMX_StateLoaded || omx_audio_mixer_component_Private->state == OMX_StateInvalid) {
00434 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s Buffer Management Thread is exiting\n",__func__);
00435 break;
00436 }
00437 }
00438
00439 for(i=0;i<omx_audio_mixer_component_Private->sPortTypesParam.nPorts;i++){
00440 DEBUG(DEB_LEV_SIMPLE_SEQ, "Waiting for buffer %i semval=%d \n",(int)i,pSem[i]->semval);
00441 if(pSem[i]->semval>0 && isBufferNeeded[i]==OMX_TRUE && PORT_IS_ENABLED(pPort[i])) {
00442 tsem_down(pSem[i]);
00443 if(pQueue[i]->nelem>0){
00444 isBufferNeeded[i]=OMX_FALSE;
00445 pBuffer[i] = dequeue(pQueue[i]);
00446 if(pBuffer[i] == NULL){
00447 DEBUG(DEB_LEV_ERR, "Had NULL input buffer!!\n");
00448 break;
00449 }
00450 }
00451 }
00452 }
00453
00454 if(isBufferNeeded[nOutputPortIndex]==OMX_FALSE) {
00455
00456 if(omx_audio_mixer_component_Private->pMark!=NULL){
00457 pBuffer[nOutputPortIndex]->hMarkTargetComponent=omx_audio_mixer_component_Private->pMark->hMarkTargetComponent;
00458 pBuffer[nOutputPortIndex]->pMarkData=omx_audio_mixer_component_Private->pMark->pMarkData;
00459 omx_audio_mixer_component_Private->pMark=NULL;
00460 }
00461
00462 for(i=0;i<omx_audio_mixer_component_Private->sPortTypesParam.nPorts-1;i++){
00463 if(isBufferNeeded[i]==OMX_FALSE && PORT_IS_ENABLED(pPort[i])) {
00464
00465 if(isBufferNeeded[i]==OMX_FALSE) {
00466 target_component=(OMX_COMPONENTTYPE*)pBuffer[i]->hMarkTargetComponent;
00467 if(target_component==(OMX_COMPONENTTYPE *)openmaxStandComp) {
00468
00469 (*(omx_audio_mixer_component_Private->callbacks->EventHandler))
00470 (openmaxStandComp,
00471 omx_audio_mixer_component_Private->callbackData,
00472 OMX_EventMark,
00473 1,
00474 0,
00475 pBuffer[i]->pMarkData);
00476 } else if(pBuffer[i]->hMarkTargetComponent!=NULL){
00477
00478 pBuffer[nOutputPortIndex]->hMarkTargetComponent = pBuffer[i]->hMarkTargetComponent;
00479 pBuffer[nOutputPortIndex]->pMarkData = pBuffer[i]->pMarkData;
00480 pBuffer[i]->pMarkData=NULL;
00481 }
00482 pBuffer[nOutputPortIndex]->nTimeStamp = pBuffer[i]->nTimeStamp;
00483 }
00484
00485 if(pBuffer[i]->nFlags==OMX_BUFFERFLAG_EOS && pBuffer[i]->nFilledLen==0) {
00486 DEBUG(DEB_LEV_FULL_SEQ, "Detected EOS flags in input buffer filled len=%d\n", (int)pBuffer[i]->nFilledLen);
00487
00488 pBuffer[i]->nFlags=0;
00489 (*(omx_audio_mixer_component_Private->callbacks->EventHandler))
00490 (openmaxStandComp,
00491 omx_audio_mixer_component_Private->callbackData,
00492 OMX_EventBufferFlag,
00493 nOutputPortIndex,
00494 pBuffer[nOutputPortIndex]->nFlags,
00495 NULL);
00496 }
00497
00498 if (omx_audio_mixer_component_Private->BufferMgmtCallback && pBuffer[i]->nFilledLen != 0) {
00499 (*(omx_audio_mixer_component_Private->BufferMgmtCallback))(openmaxStandComp, pBuffer[i], pBuffer[nOutputPortIndex]);
00500 } else {
00501
00502 pBuffer[i]->nFilledLen = 0;
00503 }
00504
00505 if(pBuffer[i]->nFilledLen==0) {
00506 isBufferNeeded[i] = OMX_TRUE;
00507 }
00508 }
00509 }
00510
00511 if(omx_audio_mixer_component_Private->state==OMX_StatePause &&
00512 !(PORT_IS_BEING_FLUSHED(pPort[0]) ||
00513 PORT_IS_BEING_FLUSHED(pPort[1]) ||
00514 PORT_IS_BEING_FLUSHED(pPort[2]) ||
00515 PORT_IS_BEING_FLUSHED(pPort[3]) ||
00516 PORT_IS_BEING_FLUSHED(pPort[nOutputPortIndex]))) {
00517
00518 tsem_wait(omx_audio_mixer_component_Private->bStateSem);
00519 }
00520
00521
00522 if(pBuffer[nOutputPortIndex]->nFilledLen!=0 || pBuffer[nOutputPortIndex]->nFlags==OMX_BUFFERFLAG_EOS){
00523 DEBUG(DEB_LEV_SIMPLE_SEQ, "Returning output buffer \n");
00524 pPort[nOutputPortIndex]->ReturnBufferFunction(pPort[nOutputPortIndex],pBuffer[nOutputPortIndex]);
00525 pBuffer[nOutputPortIndex]=NULL;
00526 isBufferNeeded[nOutputPortIndex]=OMX_TRUE;
00527 }
00528 }
00529
00530 DEBUG(DEB_LEV_FULL_SEQ, "Input buffer arrived\n");
00531
00532 if(omx_audio_mixer_component_Private->state==OMX_StatePause &&
00533 !(PORT_IS_BEING_FLUSHED(pPort[0]) ||
00534 PORT_IS_BEING_FLUSHED(pPort[1]) ||
00535 PORT_IS_BEING_FLUSHED(pPort[2]) ||
00536 PORT_IS_BEING_FLUSHED(pPort[3]) ||
00537 PORT_IS_BEING_FLUSHED(pPort[nOutputPortIndex]))) {
00538
00539 tsem_wait(omx_audio_mixer_component_Private->bStateSem);
00540 }
00541
00542
00543 for(i=0;i<omx_audio_mixer_component_Private->sPortTypesParam.nPorts-1;i++){
00544 if(isBufferNeeded[i] == OMX_TRUE && pBuffer[i]!=NULL && PORT_IS_ENABLED(pPort[i])) {
00545 pPort[i]->ReturnBufferFunction(pPort[i],pBuffer[i]);
00546 pBuffer[i]=NULL;
00547 }
00548 }
00549 }
00550 DEBUG(DEB_LEV_SIMPLE_SEQ,"Exiting Buffer Management Thread\n");
00551 return NULL;
00552 }
00553