00001
00031 #include "omxaudiocapnplay.h"
00032
00034 #define COMPONENT_NAME_BASE "OMX.st.alsa.alsasrc"
00035 #define BASE_ROLE "alsa.alsasrc"
00036 #define COMPONENT_NAME_BASE_LEN 20
00037
00038 OMX_CALLBACKTYPE audiosrccallbacks = { .EventHandler = audiosrcEventHandler,
00039 .EmptyBufferDone = NULL,
00040 .FillBufferDone = audiosrcFillBufferDone
00041 };
00042
00043 OMX_CALLBACKTYPE volume_callbacks = { .EventHandler = volumeEventHandler,
00044 .EmptyBufferDone = volumeEmptyBufferDone,
00045 .FillBufferDone = volumeFillBufferDone
00046 };
00047
00048 OMX_CALLBACKTYPE alsasink_callbacks = { .EventHandler = alsasinkEventHandler,
00049 .EmptyBufferDone = alsasinkEmptyBufferDone,
00050 .FillBufferDone = NULL
00051 };
00052
00053
00055 appPrivateType* appPriv;
00056
00058 OMX_BUFFERHEADERTYPE *pOutBuffer[2];
00060 OMX_BUFFERHEADERTYPE *pInBufferVolc[2], *pOutBufferVolc[2];
00061 OMX_BUFFERHEADERTYPE *pInBufferSink[2];
00062
00063 OMX_U32 buffer_out_size = 16384;
00064
00065 int rate = 0,channel=0;
00066 char *output_file;
00067 FILE *outfile;
00068
00069 int flagIsOutputExpected;
00070 int flagDecodedOutputReceived;
00071 int flagIsVolCompRequested;
00072 int flagIsSinkRequested;
00073 int flagSetupTunnel;
00074
00075 static OMX_BOOL bEOS = OMX_FALSE;
00076
00077 static void setHeader(OMX_PTR header, OMX_U32 size) {
00078 OMX_VERSIONTYPE* ver = (OMX_VERSIONTYPE*)(header + sizeof(OMX_U32));
00079 *((OMX_U32*)header) = size;
00080
00081 ver->s.nVersionMajor = VERSIONMAJOR;
00082 ver->s.nVersionMinor = VERSIONMINOR;
00083 ver->s.nRevision = VERSIONREVISION;
00084 ver->s.nStep = VERSIONSTEP;
00085 }
00086
00087
00089 void display_help() {
00090 printf("\n");
00091 printf("Usage: omxaudiocapnplay -o outputfile.pcm [-t] [-h] [-s]\n");
00092 printf("\n");
00093 printf(" -o outfile.pcm: If this option is specified, the output is written to user specified outfile\n");
00094 printf(" If the volume component option (-c) is specified then outfile will be .rgb file\n");
00095 printf(" Else outfile will be in .yuv format \n");
00096 printf(" N.B : This option is not needed if you use the sink component\n");
00097 printf("\n");
00098 printf(" -h: Displays this help\n");
00099 printf("\n");
00100 printf("\n");
00101 printf(" -r 8000 : sample rate[range 8000....48000]\n");
00102 printf(" -n 2 : number of channel\n");
00103 printf(" -s : Uses the audio sink component to play\n");
00104 printf(" -v : Volume Component Requested\n");
00105 printf("\n");
00106 printf(" -t : Use Tunneling \n");
00107 printf("\n");
00108 exit(1);
00109 }
00110
00111
00112 OMX_ERRORTYPE test_OMX_ComponentNameEnum() {
00113 char * name;
00114 int index;
00115
00116 OMX_ERRORTYPE err = OMX_ErrorNone;
00117
00118 DEBUG(DEFAULT_MESSAGES, "GENERAL TEST %s\n", __func__);
00119 name = malloc(OMX_MAX_STRINGNAME_SIZE);
00120 index = 0;
00121 while(1) {
00122 err = OMX_ComponentNameEnum (name, OMX_MAX_STRINGNAME_SIZE, index);
00123 if ((name != NULL) && (err == OMX_ErrorNone)) {
00124 DEBUG(DEFAULT_MESSAGES, "component %i is %s\n", index, name);
00125 } else break;
00126 if (err != OMX_ErrorNone) break;
00127 index++;
00128 }
00129 free(name);
00130 name = NULL;
00131 DEBUG(DEFAULT_MESSAGES, "GENERAL TEST %s result %i\n", __func__, err);
00132 return err;
00133 }
00134
00135 OMX_ERRORTYPE test_OMX_RoleEnum(OMX_STRING component_name) {
00136 OMX_U32 no_of_roles;
00137 OMX_U8 **string_of_roles;
00138 OMX_ERRORTYPE err = OMX_ErrorNone;
00139 int index;
00140
00141 DEBUG(DEFAULT_MESSAGES, "GENERAL TEST %s\n", __func__);
00142 DEBUG(DEB_LEV_SIMPLE_SEQ, "Getting roles of %s. Passing Null first...\n", component_name);
00143 err = OMX_GetRolesOfComponent(component_name, &no_of_roles, NULL);
00144 if (err != OMX_ErrorNone) {
00145 DEBUG(DEB_LEV_ERR, "Not able to retrieve the number of roles of the given component\n");
00146 DEBUG(DEFAULT_MESSAGES, "GENERAL TEST %s result %i\n", __func__, err);
00147 return err;
00148 }
00149 DEBUG(DEFAULT_MESSAGES, "The number of roles for the component %s is: %i\n", component_name, (int)no_of_roles);
00150
00151 if(no_of_roles == 0) {
00152 DEBUG(DEB_LEV_ERR, "The Number or roles is 0.\nThe component selected is not correct for the purpose of this test.\nExiting...\n");
00153 err = OMX_ErrorInvalidComponentName;
00154 } else {
00155 string_of_roles = malloc(no_of_roles * sizeof(OMX_STRING));
00156 for (index = 0; index < no_of_roles; index++) {
00157 *(string_of_roles + index) = malloc(no_of_roles * OMX_MAX_STRINGNAME_SIZE);
00158 }
00159 DEBUG(DEB_LEV_SIMPLE_SEQ, "...then buffers\n");
00160
00161 err = OMX_GetRolesOfComponent(component_name, &no_of_roles, string_of_roles);
00162 if (err != OMX_ErrorNone) {
00163 DEBUG(DEB_LEV_ERR, "Not able to retrieve the roles of the given component\n");
00164 } else if(string_of_roles != NULL) {
00165 for (index = 0; index < no_of_roles; index++) {
00166 DEBUG(DEFAULT_MESSAGES, "The role %i for the component: %s \n", (index + 1), *(string_of_roles+index));
00167 }
00168 } else {
00169 DEBUG(DEB_LEV_ERR, "role string is NULL!!! Exiting...\n");
00170 err = OMX_ErrorInvalidComponentName;
00171 }
00172 }
00173 DEBUG(DEFAULT_MESSAGES, "GENERAL TEST %s result %i\n", __func__, err);
00174 return err;
00175 }
00176
00177 OMX_ERRORTYPE test_OMX_ComponentEnumByRole(OMX_STRING role_name) {
00178 OMX_U32 no_of_comp_per_role;
00179 OMX_U8 **string_of_comp_per_role;
00180 OMX_ERRORTYPE err;
00181 int index;
00182
00183 DEBUG(DEFAULT_MESSAGES, "GENERAL TEST %s\n", __func__);
00184 string_of_comp_per_role = malloc (10 * sizeof(OMX_STRING));
00185 for (index = 0; index < 10; index++) {
00186 string_of_comp_per_role[index] = malloc(OMX_MAX_STRINGNAME_SIZE);
00187 }
00188
00189 DEBUG(DEFAULT_MESSAGES, "Getting number of components per role for %s\n", role_name);
00190
00191 err = OMX_GetComponentsOfRole(role_name, &no_of_comp_per_role, NULL);
00192 if (err != OMX_ErrorNone) {
00193 DEBUG(DEB_LEV_ERR, "Not able to retrieve the number of components of a given role\n");
00194 DEBUG(DEFAULT_MESSAGES, "GENERAL TEST %s result %i\n", __func__, err);
00195 return err;
00196 }
00197 DEBUG(DEFAULT_MESSAGES, "Number of components per role for %s is %i\n", role_name, (int)no_of_comp_per_role);
00198
00199 err = OMX_GetComponentsOfRole(role_name, &no_of_comp_per_role, string_of_comp_per_role);
00200 if (err != OMX_ErrorNone) {
00201 DEBUG(DEB_LEV_ERR, "Not able to retrieve the components of a given role\n");
00202 DEBUG(DEFAULT_MESSAGES, "GENERAL TEST %s result %i\n",__func__, err);
00203 return err;
00204 }
00205
00206 DEBUG(DEFAULT_MESSAGES, " The components are:\n");
00207 for (index = 0; index < no_of_comp_per_role; index++) {
00208 DEBUG(DEFAULT_MESSAGES, "%s\n", string_of_comp_per_role[index]);
00209 }
00210 for (index = 0; index<10; index++) {
00211 if(string_of_comp_per_role[index]) {
00212 free(string_of_comp_per_role[index]);
00213 string_of_comp_per_role[index] = NULL;
00214 }
00215 }
00216
00217 if(string_of_comp_per_role) {
00218 free(string_of_comp_per_role);
00219 string_of_comp_per_role = NULL;
00220 }
00221 DEBUG(DEFAULT_MESSAGES, "GENERAL TEST %s result OMX_ErrorNone\n", __func__);
00222 return OMX_ErrorNone;
00223 }
00224
00225 OMX_ERRORTYPE test_OpenClose(OMX_STRING component_name) {
00226 OMX_ERRORTYPE err = OMX_ErrorNone;
00227
00228 DEBUG(DEFAULT_MESSAGES, "GENERAL TEST %s\n",__func__);
00229 err = OMX_GetHandle(&appPriv->audiosrchandle, component_name, NULL, &audiosrccallbacks);
00230 if(err != OMX_ErrorNone) {
00231 DEBUG(DEB_LEV_ERR, "No component found\n");
00232 } else {
00233 err = OMX_FreeHandle(appPriv->audiosrchandle);
00234 }
00235 DEBUG(DEFAULT_MESSAGES, "GENERAL TEST %s result %i\n", __func__, err);
00236 return err;
00237 }
00238
00239
00240 int main(int argc, char** argv) {
00241
00242 OMX_ERRORTYPE err;
00243 int argn_dec;
00244 OMX_STRING full_component_name;
00245 int isRate=0,isChannel=0;
00246 OMX_AUDIO_PARAM_PCMMODETYPE sPCMModeParam;
00247 if(argc < 2){
00248 display_help();
00249 } else {
00250 flagIsOutputExpected = 0;
00251 flagDecodedOutputReceived = 0;
00252 flagIsVolCompRequested = 0;
00253 flagSetupTunnel = 0;
00254 flagIsSinkRequested = 0;
00255
00256 argn_dec = 1;
00257 while (argn_dec < argc) {
00258 if (*(argv[argn_dec]) == '-') {
00259 if (flagIsOutputExpected) {
00260 display_help();
00261 }
00262 switch (*(argv[argn_dec] + 1)) {
00263 case 'h' :
00264 display_help();
00265 break;
00266 case 't' :
00267 flagSetupTunnel = 1;
00268 flagIsSinkRequested = 1;
00269 flagIsVolCompRequested = 1;
00270 break;
00271 case 's':
00272 flagIsSinkRequested = 1;
00273 break;
00274 case 'o':
00275 flagIsOutputExpected = 1;
00276 break;
00277 case 'v':
00278 flagIsVolCompRequested = 1;
00279 break;
00280 case 'r' :
00281 isRate = 1;
00282 break;
00283 case 'n' :
00284 isChannel = 1;
00285 break;
00286 default:
00287 display_help();
00288 }
00289 } else {
00290 if (flagIsOutputExpected) {
00291 if(strstr(argv[argn_dec], ".pcm") == NULL) {
00292 output_file = malloc(strlen(argv[argn_dec]) + 5);
00293 strcpy(output_file,argv[argn_dec]);
00294 strcat(output_file, ".pcm");
00295 } else {
00296 output_file = malloc(strlen(argv[argn_dec]) + 1);
00297 strcpy(output_file,argv[argn_dec]);
00298 }
00299 flagIsOutputExpected = 0;
00300 flagDecodedOutputReceived = 1;
00301 } else if(isRate) {
00302 rate=atoi(argv[argn_dec]);
00303 isRate=0;
00304 if(rate <0 || rate >48000) {
00305 DEBUG(DEB_LEV_ERR, "Bad Parameter rate\n");
00306 display_help();
00307 }
00308 } else if(isChannel) {
00309 channel=atoi(argv[argn_dec]);
00310 isChannel = 0;
00311 if(channel <0 || channel >6) {
00312 DEBUG(DEB_LEV_ERR, "Bad Parameter channel\n");
00313 display_help();
00314 }
00315 }
00316 }
00317 argn_dec++;
00318 }
00319
00321 if(!flagIsVolCompRequested && flagIsSinkRequested) {
00322 DEBUG(DEB_LEV_ERR, "You requested for sink - not producing any output file\n");
00323 flagIsVolCompRequested = 1;
00324 flagDecodedOutputReceived = 0;
00325 }
00326
00328
00329 if(!flagIsOutputExpected && !flagDecodedOutputReceived && !flagIsSinkRequested) {
00330 DEBUG(DEB_LEV_ERR,"\n you did not enter any output file name");
00331 output_file = malloc(20);
00332 strcpy(output_file,"output.pcm");
00333 DEBUG(DEB_LEV_ERR,"\n the decoded output file name will be %s \n", output_file);
00334 } else if(flagDecodedOutputReceived) {
00335 if(flagIsSinkRequested || flagSetupTunnel) {
00336 flagDecodedOutputReceived = 0;
00337 DEBUG(DEB_LEV_ERR, "Sink Requested or Components are tunneled. No FILE Output will be produced\n");
00338 } else {
00339
00340 if(flagIsVolCompRequested && strstr(output_file, ".pcm") == NULL) {
00341 output_file[strlen(output_file) - strlen(strstr(output_file, "."))] = '\0';
00342 strcat(output_file, ".rgb");
00343 DEBUG(DEB_LEV_ERR,"\n volume component option is selected - so the output file is %s \n", output_file);
00344 }
00345 }
00346 }
00347 if(flagSetupTunnel) {
00348 DEBUG(DEFAULT_MESSAGES,"The components are tunneled between themselves\n");
00349 }
00350 }
00351
00352 if(!flagIsSinkRequested) {
00353 outfile = fopen(output_file, "wb");
00354 if(outfile == NULL) {
00355 DEBUG(DEB_LEV_ERR, "Error in opening output file %s\n", output_file);
00356 exit(1);
00357 }
00358 }
00359
00360
00361 appPriv = malloc(sizeof(appPrivateType));
00362 appPriv->sourceEventSem = malloc(sizeof(tsem_t));
00363 if(flagIsVolCompRequested == 1) {
00364 if(flagIsSinkRequested == 1) {
00365 appPriv->alsasinkEventSem = malloc(sizeof(tsem_t));
00366 }
00367 appPriv->volumeEventSem = malloc(sizeof(tsem_t));
00368 }
00369 appPriv->eofSem = malloc(sizeof(tsem_t));
00370 tsem_init(appPriv->sourceEventSem, 0);
00371 if(flagIsVolCompRequested == 1) {
00372 if(flagIsSinkRequested == 1) {
00373 tsem_init(appPriv->alsasinkEventSem, 0);
00374 }
00375 tsem_init(appPriv->volumeEventSem, 0);
00376 }
00377 tsem_init(appPriv->eofSem, 0);
00378
00379 DEBUG(DEB_LEV_SIMPLE_SEQ, "Init the Omx core\n");
00380 err = OMX_Init();
00381 if (err != OMX_ErrorNone) {
00382 DEBUG(DEB_LEV_ERR, "The OpenMAX core can not be initialized. Exiting...\n");
00383 exit(1);
00384 } else {
00385 DEBUG(DEB_LEV_SIMPLE_SEQ, "Omx core is initialized \n");
00386 }
00387
00388 DEBUG(DEFAULT_MESSAGES, "------------------------------------\n");
00389 test_OMX_ComponentNameEnum();
00390 DEBUG(DEFAULT_MESSAGES, "------------------------------------\n");
00391 test_OMX_RoleEnum(COMPONENT_NAME_BASE);
00392 DEBUG(DEFAULT_MESSAGES, "------------------------------------\n");
00393 test_OMX_ComponentEnumByRole(BASE_ROLE);
00394 DEBUG(DEFAULT_MESSAGES, "------------------------------------\n");
00395 test_OpenClose(COMPONENT_NAME_BASE);
00396 DEBUG(DEFAULT_MESSAGES, "------------------------------------\n");
00397
00398
00399 full_component_name = malloc(OMX_MAX_STRINGNAME_SIZE);
00400 strcpy(full_component_name, "OMX.st.alsa.alsasrc");
00401
00402 DEBUG(DEFAULT_MESSAGES, "The component selected for decoding is %s\n", full_component_name);
00403
00405 err = OMX_GetHandle(&appPriv->audiosrchandle, full_component_name, NULL, &audiosrccallbacks);
00406 if(err != OMX_ErrorNone){
00407 DEBUG(DEB_LEV_ERR, "No audio source component found. Exiting...\n");
00408 exit(1);
00409 } else {
00410 DEBUG(DEFAULT_MESSAGES, "Found The component for capturing is %s\n", full_component_name);
00411 }
00412
00414 if(flagIsVolCompRequested == 1) {
00415 err = OMX_GetHandle(&appPriv->volume_handle, "OMX.st.volume.component", NULL, &volume_callbacks);
00416 if(err != OMX_ErrorNone){
00417 DEBUG(DEB_LEV_ERR, "No volume componenterter component found. Exiting...\n");
00418 exit(1);
00419 } else {
00420 DEBUG(DEFAULT_MESSAGES, "Found The component for volume componenterter \n");
00421 }
00422
00424 if(flagIsSinkRequested == 1) {
00425 err = OMX_GetHandle(&appPriv->alsasink_handle, "OMX.st.alsa.alsasink", NULL, &alsasink_callbacks);
00426 if(err != OMX_ErrorNone){
00427 DEBUG(DEB_LEV_ERR, "No audio sink component component found. Exiting...\n");
00428 exit(1);
00429 } else {
00430 DEBUG(DEFAULT_MESSAGES, "Found The audio sink component for volume componenterter \n");
00431 }
00432 }
00433 }
00434
00435 if(rate >0 || channel >0) {
00436 setHeader(&sPCMModeParam, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE));
00437 err = OMX_GetParameter(appPriv->audiosrchandle,OMX_IndexParamAudioPcm,&sPCMModeParam);
00438 if (err != OMX_ErrorNone) {
00439 DEBUG(DEB_LEV_ERR, "Err in GetParameter OMX_AUDIO_PARAM_PCMMODETYPE in AlsaSrc. Exiting...\n");
00440 exit(1);
00441 }
00442 sPCMModeParam.nChannels = (channel >0 ) ? channel:sPCMModeParam.nChannels;
00443 sPCMModeParam.nSamplingRate = (rate >0 ) ? rate:sPCMModeParam.nSamplingRate;
00444 err = OMX_SetParameter(appPriv->audiosrchandle,OMX_IndexParamAudioPcm,&sPCMModeParam);
00445 if (err != OMX_ErrorNone) {
00446 DEBUG(DEB_LEV_ERR, "Err in SetParameter OMX_AUDIO_PARAM_PCMMODETYPE in AlsaSrc. Exiting...\n");
00447 exit(1);
00448 }
00449 if(flagIsSinkRequested) {
00450 err = OMX_SetParameter(appPriv->alsasink_handle,OMX_IndexParamAudioPcm,&sPCMModeParam);
00451 if (err != OMX_ErrorNone) {
00452 DEBUG(DEB_LEV_ERR, "Err in SetParameter OMX_AUDIO_PARAM_PCMMODETYPE in AlsaSink. Exiting...\n");
00453 exit(1);
00454 }
00455 }
00456 } else if(flagIsSinkRequested) {
00457 setHeader(&sPCMModeParam, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE));
00458 err = OMX_GetParameter(appPriv->audiosrchandle,OMX_IndexParamAudioPcm,&sPCMModeParam);
00459 if (err != OMX_ErrorNone) {
00460 DEBUG(DEB_LEV_ERR, "Err in GetParameter OMX_AUDIO_PARAM_PCMMODETYPE in AlsaSrc. Exiting...\n");
00461 exit(1);
00462 }
00463 err = OMX_SetParameter(appPriv->alsasink_handle,OMX_IndexParamAudioPcm,&sPCMModeParam);
00464 if (err != OMX_ErrorNone) {
00465 DEBUG(DEB_LEV_ERR, "Err in SetParameter OMX_AUDIO_PARAM_PCMMODETYPE in AlsaSink. Exiting...\n");
00466 exit(1);
00467 }
00468 }
00469
00471 DEBUG(DEB_LEV_SIMPLE_SEQ, "\n buffer_out_size : %d \n", (int)buffer_out_size);
00472
00474 if (flagSetupTunnel) {
00475 DEBUG(DEB_LEV_SIMPLE_SEQ, "Setting up Tunnel\n");
00476 err = OMX_SetupTunnel(appPriv->audiosrchandle, 0, appPriv->volume_handle, 0);
00477 if(err != OMX_ErrorNone) {
00478 DEBUG(DEB_LEV_ERR, "Set up Tunnel between audio src & volume component Failed\n");
00479 exit(1);
00480 }
00481 err = OMX_SetupTunnel(appPriv->volume_handle, 1, appPriv->alsasink_handle, 0);
00482 if(err != OMX_ErrorNone) {
00483 DEBUG(DEB_LEV_ERR, "Set up Tunnel between volume component & audio sink Failed\n");
00484 exit(1);
00485 }
00486 DEBUG(DEFAULT_MESSAGES, "Set up Tunnel Completed\n");
00487 }
00488
00490 err = OMX_SendCommand(appPriv->audiosrchandle, OMX_CommandStateSet, OMX_StateIdle, NULL);
00491
00493 if(flagIsVolCompRequested && flagSetupTunnel) {
00494 err = OMX_SendCommand(appPriv->volume_handle, OMX_CommandStateSet, OMX_StateIdle, NULL);
00495 if(flagIsSinkRequested && flagSetupTunnel) {
00496 err = OMX_SendCommand(appPriv->alsasink_handle, OMX_CommandStateSet, OMX_StateIdle, NULL);
00497 }
00498 }
00499
00500 if(flagSetupTunnel) {
00501 if(flagIsSinkRequested) {
00502 tsem_down(appPriv->alsasinkEventSem);
00503 }
00504 if(flagIsVolCompRequested) {
00505 tsem_down(appPriv->volumeEventSem);
00506 }
00507 }
00508
00510 if (!flagSetupTunnel) {
00511 pOutBuffer[0] = pOutBuffer[1] = NULL;
00512 err = OMX_AllocateBuffer(appPriv->audiosrchandle, &pOutBuffer[0], 0, NULL, buffer_out_size);
00513 err = OMX_AllocateBuffer(appPriv->audiosrchandle, &pOutBuffer[1], 0, NULL, buffer_out_size);
00514 }
00515
00516 DEBUG(DEB_LEV_SIMPLE_SEQ, "Before locking on idle wait semaphore\n");
00517 tsem_down(appPriv->sourceEventSem);
00518 DEBUG(DEB_LEV_SIMPLE_SEQ, "source Sem free\n");
00519
00520 if(!flagSetupTunnel) {
00521 if(flagIsVolCompRequested == 1) {
00522 pOutBufferVolc[0] = pOutBufferVolc[1] = NULL;
00523 err = OMX_SendCommand(appPriv->volume_handle, OMX_CommandStateSet, OMX_StateIdle, NULL);
00524
00526 err = OMX_UseBuffer(appPriv->volume_handle, &pInBufferVolc[0], 0, NULL, buffer_out_size, pOutBuffer[0]->pBuffer);
00527 if(err != OMX_ErrorNone) {
00528 DEBUG(DEB_LEV_ERR, "Unable to use the volume component comp allocate buffer\n");
00529 exit(1);
00530 }
00531 err = OMX_UseBuffer(appPriv->volume_handle, &pInBufferVolc[1], 0, NULL, buffer_out_size, pOutBuffer[1]->pBuffer);
00532 if(err != OMX_ErrorNone) {
00533 DEBUG(DEB_LEV_ERR, "Unable to use the volume component comp allocate buffer\n");
00534 exit(1);
00535 }
00536
00539 err = OMX_AllocateBuffer(appPriv->volume_handle, &pOutBufferVolc[0], 1, NULL, buffer_out_size);
00540 if(err != OMX_ErrorNone) {
00541 DEBUG(DEB_LEV_ERR, "Unable to allocate buffer in volume component\n");
00542 exit(1);
00543 }
00544 err = OMX_AllocateBuffer(appPriv->volume_handle, &pOutBufferVolc[1], 1, NULL, buffer_out_size);
00545 if(err != OMX_ErrorNone) {
00546 DEBUG(DEB_LEV_ERR, "Unable to allocate buffer in colro conv\n");
00547 exit(1);
00548 }
00549
00550 DEBUG(DEB_LEV_SIMPLE_SEQ, "Before locking on idle wait semaphore\n");
00551 tsem_down(appPriv->volumeEventSem);
00552 DEBUG(DEFAULT_MESSAGES, "volume Event Sem free\n");
00553
00554 if(flagIsSinkRequested == 1) {
00555 err = OMX_SendCommand(appPriv->alsasink_handle, OMX_CommandStateSet, OMX_StateIdle, NULL);
00556 err = OMX_UseBuffer(appPriv->alsasink_handle, &pInBufferSink[0], 0, NULL, buffer_out_size, pOutBufferVolc[0]->pBuffer);
00557 if(err != OMX_ErrorNone) {
00558 DEBUG(DEB_LEV_ERR, "Unable to use the alsasink_handle comp allocate buffer\n");
00559 exit(1);
00560 }
00561 err = OMX_UseBuffer(appPriv->alsasink_handle, &pInBufferSink[1], 0, NULL, buffer_out_size, pOutBufferVolc[1]->pBuffer);
00562 if(err != OMX_ErrorNone) {
00563 DEBUG(DEB_LEV_ERR, "Unable to use the alsasink_handle comp allocate buffer\n");
00564 exit(1);
00565 }
00566
00567 DEBUG(DEB_LEV_SIMPLE_SEQ, "Before locking on idle wait semaphore\n");
00568 tsem_down(appPriv->alsasinkEventSem);
00569 DEBUG(DEB_LEV_SIMPLE_SEQ, "audio sink comp Sem free\n");
00570 }
00571 }
00572
00573 if(flagIsVolCompRequested == 1) {
00574 err = OMX_SendCommand(appPriv->volume_handle, OMX_CommandStateSet, OMX_StateExecuting, NULL);
00575 tsem_down(appPriv->volumeEventSem);
00576 if(flagIsSinkRequested == 1) {
00577 err = OMX_SendCommand(appPriv->alsasink_handle, OMX_CommandStateSet, OMX_StateExecuting, NULL);
00578 tsem_down(appPriv->alsasinkEventSem);
00579 }
00580 }
00581 }
00582
00584 if(flagIsVolCompRequested == 1 && flagSetupTunnel) {
00585 err = OMX_SendCommand(appPriv->volume_handle, OMX_CommandStateSet, OMX_StateExecuting, NULL);
00586 tsem_down(appPriv->volumeEventSem);
00587 if(flagIsSinkRequested == 1) {
00588 err = OMX_SendCommand(appPriv->alsasink_handle, OMX_CommandStateSet, OMX_StateExecuting, NULL);
00589 tsem_down(appPriv->alsasinkEventSem);
00590 }
00591 }
00592
00594 err = OMX_SendCommand(appPriv->audiosrchandle, OMX_CommandStateSet, OMX_StateExecuting, NULL);
00595 tsem_down(appPriv->sourceEventSem);
00596
00597 if(flagIsVolCompRequested == 1 && !flagSetupTunnel) {
00598 err = OMX_FillThisBuffer(appPriv->volume_handle, pOutBufferVolc[0]);
00599 err = OMX_FillThisBuffer(appPriv->volume_handle, pOutBufferVolc[1]);
00600 DEBUG(DEFAULT_MESSAGES, "---> After fill this buffer function calls to the volume component output buffers\n");
00601 }
00602 if (!flagSetupTunnel) {
00603 err = OMX_FillThisBuffer(appPriv->audiosrchandle, pOutBuffer[0]);
00604 err = OMX_FillThisBuffer(appPriv->audiosrchandle, pOutBuffer[1]);
00605 }
00606
00607 DEBUG(DEB_LEV_SIMPLE_SEQ, "---> Before locking on condition and sourceMutex\n");
00608
00609 DEBUG(DEFAULT_MESSAGES,"Enter 'q' or 'Q' to exit\n");
00610
00611 while(1) {
00612 if('Q' == toupper(getchar())) {
00613 DEBUG(DEFAULT_MESSAGES,"Stoping capture\n");
00614 bEOS = OMX_TRUE;
00615 usleep(10000);
00616 break;
00617 }
00618 }
00619
00620 DEBUG(DEFAULT_MESSAGES, "The execution of the audio decoding process is terminated\n");
00621
00623 err = OMX_SendCommand(appPriv->audiosrchandle, OMX_CommandStateSet, OMX_StateIdle, NULL);
00624 if(flagIsVolCompRequested == 1) {
00625 err = OMX_SendCommand(appPriv->volume_handle, OMX_CommandStateSet, OMX_StateIdle, NULL);
00626 if(flagIsSinkRequested == 1) {
00627 err = OMX_SendCommand(appPriv->alsasink_handle, OMX_CommandStateSet, OMX_StateIdle, NULL);
00628 }
00629 }
00630
00631 tsem_down(appPriv->sourceEventSem);
00632 if(flagIsVolCompRequested == 1) {
00633 tsem_down(appPriv->volumeEventSem);
00634 if(flagIsSinkRequested == 1) {
00635 tsem_down(appPriv->alsasinkEventSem);
00636 }
00637 }
00638
00639 DEBUG(DEFAULT_MESSAGES, "All audio components Transitioned to Idle\n");
00640
00642 err = OMX_SendCommand(appPriv->audiosrchandle, OMX_CommandStateSet, OMX_StateLoaded, NULL);
00643 if(flagIsVolCompRequested == 1) {
00644 err = OMX_SendCommand(appPriv->volume_handle, OMX_CommandStateSet, OMX_StateLoaded, NULL);
00645 if(flagIsSinkRequested == 1) {
00646 err = OMX_SendCommand(appPriv->alsasink_handle, OMX_CommandStateSet, OMX_StateLoaded, NULL);
00647 }
00648 }
00649
00651 if(flagIsVolCompRequested == 1 && !flagSetupTunnel) {
00652
00653 DEBUG(DEB_LEV_SIMPLE_SEQ, "volume component to loaded\n");
00654 err = OMX_FreeBuffer(appPriv->volume_handle, 0, pInBufferVolc[0]);
00655 err = OMX_FreeBuffer(appPriv->volume_handle, 0, pInBufferVolc[1]);
00656
00657 err = OMX_FreeBuffer(appPriv->volume_handle, 1, pOutBufferVolc[0]);
00658 err = OMX_FreeBuffer(appPriv->volume_handle, 1, pOutBufferVolc[1]);
00659
00660 if(flagIsSinkRequested == 1) {
00661 DEBUG(DEB_LEV_SIMPLE_SEQ, "Audio sink to loaded\n");
00662 err = OMX_FreeBuffer(appPriv->alsasink_handle, 0, pInBufferSink[0]);
00663 err = OMX_FreeBuffer(appPriv->alsasink_handle, 0, pInBufferSink[1]);
00664 }
00665 }
00666
00668 DEBUG(DEB_LEV_SIMPLE_SEQ, "Audio dec to loaded\n");
00669 if(!flagSetupTunnel) {
00670 DEBUG(DEB_LEV_PARAMS, "Free Audio dec output ports\n");
00671 err = OMX_FreeBuffer(appPriv->audiosrchandle, 0, pOutBuffer[0]);
00672 err = OMX_FreeBuffer(appPriv->audiosrchandle, 0, pOutBuffer[1]);
00673 }
00674
00675 if(flagIsVolCompRequested == 1) {
00676 if(flagIsSinkRequested == 1) {
00677 tsem_down(appPriv->alsasinkEventSem);
00678 }
00679 tsem_down(appPriv->volumeEventSem);
00680 }
00681 tsem_down(appPriv->sourceEventSem);
00682 DEBUG(DEB_LEV_SIMPLE_SEQ, "All components released\n");
00683
00684 OMX_FreeHandle(appPriv->audiosrchandle);
00685 if(flagIsVolCompRequested == 1) {
00686 if(flagIsSinkRequested == 1) {
00687 OMX_FreeHandle(appPriv->alsasink_handle);
00688 }
00689 OMX_FreeHandle(appPriv->volume_handle);
00690 }
00691 DEBUG(DEB_LEV_SIMPLE_SEQ, "audio dec freed\n");
00692
00693 OMX_Deinit();
00694
00695 DEBUG(DEFAULT_MESSAGES, "All components freed. Closing...\n");
00696 free(appPriv->sourceEventSem);
00697 if(flagIsVolCompRequested == 1) {
00698 if(flagIsSinkRequested == 1) {
00699 free(appPriv->alsasinkEventSem);
00700 }
00701 free(appPriv->volumeEventSem);
00702 }
00703 free(appPriv->eofSem);
00704 free(appPriv);
00705
00706 free(full_component_name);
00707
00709 if(!flagIsSinkRequested) {
00710 fclose(outfile);
00711 }
00712 if(output_file) {
00713 free(output_file);
00714 }
00715
00716 return 0;
00717 }
00718
00720 OMX_ERRORTYPE alsasinkEventHandler(
00721 OMX_OUT OMX_HANDLETYPE hComponent,
00722 OMX_OUT OMX_PTR pAppData,
00723 OMX_OUT OMX_EVENTTYPE eEvent,
00724 OMX_OUT OMX_U32 Data1,
00725 OMX_OUT OMX_U32 Data2,
00726 OMX_OUT OMX_PTR pEventData) {
00727
00728 DEBUG(DEB_LEV_SIMPLE_SEQ, "Hi there, I am in the %s callback\n", __func__);
00729 if(eEvent == OMX_EventCmdComplete) {
00730 if (Data1 == OMX_CommandStateSet) {
00731 DEBUG(DEB_LEV_SIMPLE_SEQ, "State changed in ");
00732 switch ((int)Data2) {
00733 case OMX_StateInvalid:
00734 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateInvalid\n");
00735 break;
00736 case OMX_StateLoaded:
00737 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateLoaded\n");
00738 break;
00739 case OMX_StateIdle:
00740 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateIdle ---- fbsink\n");
00741 break;
00742 case OMX_StateExecuting:
00743 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateExecuting\n");
00744 break;
00745 case OMX_StatePause:
00746 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StatePause\n");
00747 break;
00748 case OMX_StateWaitForResources:
00749 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateWaitForResources\n");
00750 break;
00751 }
00752 tsem_up(appPriv->alsasinkEventSem);
00753 }
00754 else if (OMX_CommandPortEnable || OMX_CommandPortDisable) {
00755 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s Received Port Enable/Disable Event\n",__func__);
00756 tsem_up(appPriv->alsasinkEventSem);
00757 }
00758 } else if(eEvent == OMX_EventBufferFlag) {
00759 DEBUG(DEB_LEV_ERR, "In %s OMX_BUFFERFLAG_EOS\n", __func__);
00760 if((int)Data2 == OMX_BUFFERFLAG_EOS) {
00761 tsem_up(appPriv->eofSem);
00762 }
00763 } else {
00764 DEBUG(DEB_LEV_SIMPLE_SEQ, "Param1 is %i\n", (int)Data1);
00765 DEBUG(DEB_LEV_SIMPLE_SEQ, "Param2 is %i\n", (int)Data2);
00766 }
00767 return OMX_ErrorNone;
00768 }
00769
00770
00771 OMX_ERRORTYPE alsasinkEmptyBufferDone(
00772 OMX_OUT OMX_HANDLETYPE hComponent,
00773 OMX_OUT OMX_PTR pAppData,
00774 OMX_OUT OMX_BUFFERHEADERTYPE* pBuffer) {
00775
00776 OMX_ERRORTYPE err;
00777 static int inputBufferDropped = 0;
00778 if(pBuffer != NULL) {
00779 if(!bEOS) {
00780 if(pOutBufferVolc[0]->pBuffer == pBuffer->pBuffer) {
00781 pOutBufferVolc[0]->nFilledLen = pBuffer->nFilledLen;
00782 err = OMX_FillThisBuffer(appPriv->volume_handle, pOutBufferVolc[0]);
00783 } else {
00784 pOutBufferVolc[1]->nFilledLen = pBuffer->nFilledLen;
00785 err = OMX_FillThisBuffer(appPriv->volume_handle, pOutBufferVolc[1]);
00786 }
00787 if(err != OMX_ErrorNone) {
00788 DEBUG(DEB_LEV_ERR, "In %s Error %08x Calling FillThisBuffer\n", __func__,err);
00789 }
00790 } else {
00791 DEBUG(DEB_LEV_ERR, "In %s: eos=%x Dropping Fill This Buffer\n", __func__,(int)pBuffer->nFlags);
00792 inputBufferDropped++;
00793 if(inputBufferDropped == 2) {
00794 tsem_up(appPriv->eofSem);
00795 }
00796 }
00797 } else {
00798 if(!bEOS) {
00799 tsem_up(appPriv->eofSem);
00800 }
00801 DEBUG(DEB_LEV_ERR, "Ouch! In %s: had NULL buffer to output...\n", __func__);
00802 }
00803 return OMX_ErrorNone;
00804 }
00805
00806
00807
00808 OMX_ERRORTYPE volumeEventHandler(
00809 OMX_OUT OMX_HANDLETYPE hComponent,
00810 OMX_OUT OMX_PTR pAppData,
00811 OMX_OUT OMX_EVENTTYPE eEvent,
00812 OMX_OUT OMX_U32 Data1,
00813 OMX_OUT OMX_U32 Data2,
00814 OMX_OUT OMX_PTR pEventData) {
00815
00816 DEBUG(DEB_LEV_SIMPLE_SEQ, "\nHi there, I am in the %s callback\n", __func__);
00817 if(eEvent == OMX_EventCmdComplete) {
00818 if (Data1 == OMX_CommandStateSet) {
00819 DEBUG(DEB_LEV_SIMPLE_SEQ, "\nState changed in ");
00820 switch ((int)Data2) {
00821 case OMX_StateInvalid:
00822 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateInvalid\n");
00823 break;
00824 case OMX_StateLoaded:
00825 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateLoaded\n");
00826 break;
00827 case OMX_StateIdle:
00828 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateIdle\n");
00829 break;
00830 case OMX_StateExecuting:
00831 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateExecuting\n");
00832 break;
00833 case OMX_StatePause:
00834 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StatePause\n");
00835 break;
00836 case OMX_StateWaitForResources:
00837 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateWaitForResources\n");
00838 break;
00839 }
00840 tsem_up(appPriv->volumeEventSem);
00841 }
00842 else if (OMX_CommandPortEnable || OMX_CommandPortDisable) {
00843 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s Received Port Enable/Disable Event\n",__func__);
00844 tsem_up(appPriv->volumeEventSem);
00845 }
00846 } else if(eEvent == OMX_EventBufferFlag) {
00847 DEBUG(DEB_LEV_ERR, "In %s OMX_BUFFERFLAG_EOS\n", __func__);
00848 if((int)Data2 == OMX_BUFFERFLAG_EOS) {
00849 tsem_up(appPriv->eofSem);
00850 }
00851 } else {
00852 DEBUG(DEB_LEV_SIMPLE_SEQ, "Param1 is %i\n", (int)Data1);
00853 DEBUG(DEB_LEV_SIMPLE_SEQ, "Param2 is %i\n", (int)Data2);
00854 }
00855 return OMX_ErrorNone;
00856 }
00857
00858
00859 OMX_ERRORTYPE volumeEmptyBufferDone(
00860 OMX_OUT OMX_HANDLETYPE hComponent,
00861 OMX_OUT OMX_PTR pAppData,
00862 OMX_OUT OMX_BUFFERHEADERTYPE* pBuffer) {
00863
00864 OMX_ERRORTYPE err;
00865 static int iBufferDropped = 0;
00866
00867 if(pBuffer != NULL) {
00868 if(!bEOS) {
00869 if(pOutBuffer[0]->pBuffer == pBuffer->pBuffer) {
00870 pOutBuffer[0]->nFilledLen = pBuffer->nFilledLen;
00871 err = OMX_FillThisBuffer(appPriv->audiosrchandle, pOutBuffer[0]);
00872 } else {
00873 pOutBuffer[1]->nFilledLen = pBuffer->nFilledLen;
00874 err = OMX_FillThisBuffer(appPriv->audiosrchandle, pOutBuffer[1]);
00875 }
00876 if(err != OMX_ErrorNone) {
00877 DEBUG(DEB_LEV_ERR, "In %s Error %08x Calling FillThisBuffer\n", __func__,err);
00878 }
00879 } else {
00880 DEBUG(DEB_LEV_ERR, "In %s: eos=%x Dropping Fill This Buffer\n", __func__,(int)pBuffer->nFlags);
00881 iBufferDropped++;
00882 if(iBufferDropped == 2) {
00883 tsem_up(appPriv->eofSem);
00884 }
00885 }
00886 } else {
00887 if(!bEOS) {
00888 tsem_up(appPriv->eofSem);
00889 }
00890 DEBUG(DEB_LEV_ERR, "Ouch! In %s: had NULL buffer to output...\n", __func__);
00891 }
00892 return OMX_ErrorNone;
00893 }
00894
00895
00896 OMX_ERRORTYPE volumeFillBufferDone(
00897 OMX_OUT OMX_HANDLETYPE hComponent,
00898 OMX_OUT OMX_PTR pAppData,
00899 OMX_OUT OMX_BUFFERHEADERTYPE* pBuffer) {
00900
00901 OMX_ERRORTYPE err;
00902 if(pBuffer != NULL) {
00903 if(!bEOS) {
00907 if(flagIsSinkRequested && (!flagSetupTunnel)) {
00908 if(pInBufferSink[0]->pBuffer == pBuffer->pBuffer) {
00909 pInBufferSink[0]->nFilledLen = pBuffer->nFilledLen;
00910 err = OMX_EmptyThisBuffer(appPriv->alsasink_handle, pInBufferSink[0]);
00911 } else {
00912 pInBufferSink[1]->nFilledLen = pBuffer->nFilledLen;
00913 err = OMX_EmptyThisBuffer(appPriv->alsasink_handle, pInBufferSink[1]);
00914 }
00915 if(err != OMX_ErrorNone) {
00916 DEBUG(DEB_LEV_ERR, "In %s Error %08x Calling FillThisBuffer\n", __func__,err);
00917 }
00918 } else if((pBuffer->nFilledLen > 0) && (!flagSetupTunnel)) {
00919 fwrite(pBuffer->pBuffer, 1, pBuffer->nFilledLen, outfile);
00920 pBuffer->nFilledLen = 0;
00921 }
00922 if(pBuffer->nFlags == OMX_BUFFERFLAG_EOS) {
00923 DEBUG(DEB_LEV_ERR, "In %s: eos=%x Calling Empty This Buffer\n", __func__, (int)pBuffer->nFlags);
00924 bEOS = OMX_TRUE;
00925 }
00926 if(!bEOS && !flagIsSinkRequested && (!flagSetupTunnel)) {
00927 err = OMX_FillThisBuffer(hComponent, pBuffer);
00928 }
00929 } else {
00930 DEBUG(DEB_LEV_ERR, "In %s: eos=%x Dropping Empty This Buffer\n", __func__,(int)pBuffer->nFlags);
00931 }
00932 } else {
00933 DEBUG(DEB_LEV_ERR, "Ouch! In %s: had NULL buffer to output...\n", __func__);
00934 }
00935 return OMX_ErrorNone;
00936 }
00937
00939 OMX_ERRORTYPE audiosrcEventHandler(
00940 OMX_OUT OMX_HANDLETYPE hComponent,
00941 OMX_OUT OMX_PTR pAppData,
00942 OMX_OUT OMX_EVENTTYPE eEvent,
00943 OMX_OUT OMX_U32 Data1,
00944 OMX_OUT OMX_U32 Data2,
00945 OMX_OUT OMX_PTR pEventData) {
00946
00947 OMX_ERRORTYPE err = OMX_ErrorNone;
00948
00949 DEBUG(DEB_LEV_SIMPLE_SEQ, "Hi there, I am in the %s callback\n", __func__);
00950 if(eEvent == OMX_EventCmdComplete) {
00951 if (Data1 == OMX_CommandStateSet) {
00952 DEBUG(DEB_LEV_SIMPLE_SEQ, "State changed in ");
00953 switch ((int)Data2) {
00954 case OMX_StateInvalid:
00955 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateInvalid\n");
00956 break;
00957 case OMX_StateLoaded:
00958 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateLoaded\n");
00959 break;
00960 case OMX_StateIdle:
00961 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateIdle\n");
00962 break;
00963 case OMX_StateExecuting:
00964 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateExecuting\n");
00965 break;
00966 case OMX_StatePause:
00967 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StatePause\n");
00968 break;
00969 case OMX_StateWaitForResources:
00970 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateWaitForResources\n");
00971 break;
00972 }
00973 tsem_up(appPriv->sourceEventSem);
00974 }
00975 else if (OMX_CommandPortEnable || OMX_CommandPortDisable) {
00976 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s Received Port Enable/Disable Event\n",__func__);
00977 tsem_up(appPriv->sourceEventSem);
00978 }
00979 } else if(eEvent == OMX_EventPortSettingsChanged) {
00980 DEBUG(DEB_LEV_SIMPLE_SEQ, "\n port settings change event handler in %s \n", __func__);
00981 } else if(eEvent == OMX_EventBufferFlag) {
00982 DEBUG(DEB_LEV_ERR, "In %s OMX_BUFFERFLAG_EOS\n", __func__);
00983 if((int)Data2 == OMX_BUFFERFLAG_EOS) {
00984 tsem_up(appPriv->eofSem);
00985 }
00986 } else {
00987 DEBUG(DEB_LEV_SIMPLE_SEQ, "Param1 is %i\n", (int)Data1);
00988 DEBUG(DEB_LEV_SIMPLE_SEQ, "Param2 is %i\n", (int)Data2);
00989 }
00990 return err;
00991 }
00992
00993 OMX_ERRORTYPE audiosrcFillBufferDone(
00994 OMX_OUT OMX_HANDLETYPE hComponent,
00995 OMX_OUT OMX_PTR pAppData,
00996 OMX_OUT OMX_BUFFERHEADERTYPE* pBuffer) {
00997
00998 OMX_ERRORTYPE err;
00999 OMX_STATETYPE eState;
01000
01001 if(pBuffer != NULL){
01002 if(!bEOS) {
01006 if(flagIsVolCompRequested && (!flagSetupTunnel)) {
01007 OMX_GetState(appPriv->volume_handle,&eState);
01008 if(eState == OMX_StateExecuting || eState == OMX_StatePause) {
01009 if(pInBufferVolc[0]->pBuffer == pBuffer->pBuffer) {
01010 pInBufferVolc[0]->nFilledLen = pBuffer->nFilledLen;
01011 err = OMX_EmptyThisBuffer(appPriv->volume_handle, pInBufferVolc[0]);
01012 } else {
01013 pInBufferVolc[1]->nFilledLen = pBuffer->nFilledLen;
01014 err = OMX_EmptyThisBuffer(appPriv->volume_handle, pInBufferVolc[1]);
01015 }
01016 if(err != OMX_ErrorNone) {
01017 DEBUG(DEB_LEV_ERR, "In %s Error %08x Calling FillThisBuffer\n", __func__,err);
01018 }
01019 } else {
01020 err = OMX_FillThisBuffer(hComponent, pBuffer);
01021 }
01022 } else if((pBuffer->nFilledLen > 0) && (!flagSetupTunnel)) {
01023 fwrite(pBuffer->pBuffer, 1, pBuffer->nFilledLen, outfile);
01024 pBuffer->nFilledLen = 0;
01025 }
01026 if(pBuffer->nFlags == OMX_BUFFERFLAG_EOS) {
01027 DEBUG(DEB_LEV_ERR, "In %s: eos=%x Calling Empty This Buffer\n", __func__, (int)pBuffer->nFlags);
01028 bEOS = OMX_TRUE;
01029 }
01030 if(!bEOS && !flagIsVolCompRequested && (!flagSetupTunnel)) {
01031 err = OMX_FillThisBuffer(hComponent, pBuffer);
01032 }
01033 } else {
01034 DEBUG(DEB_LEV_ERR, "In %s: eos=%x Dropping Empty This Buffer\n", __func__,(int)pBuffer->nFlags);
01035 }
01036 } else {
01037 DEBUG(DEB_LEV_ERR, "Ouch! In %s: had NULL buffer to output...\n", __func__);
01038 }
01039 return OMX_ErrorNone;
01040 }
01041
01042