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 * 2;
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 err = OMX_SendCommand(appPriv->alsasink_handle, OMX_CommandPortDisable, 1, NULL);
00434 if(err != OMX_ErrorNone) {
00435 DEBUG(DEB_LEV_ERR,"audiosink clock port disable failed err=%x \n",err);
00436 exit(1);
00437 }
00438 tsem_down(appPriv->alsasinkEventSem);
00439 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s Audio Sink Clock Port Disabled\n", __func__);
00440 }
00441 }
00442
00443 if(rate >0 || channel >0) {
00444 setHeader(&sPCMModeParam, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE));
00445 err = OMX_GetParameter(appPriv->audiosrchandle,OMX_IndexParamAudioPcm,&sPCMModeParam);
00446 if (err != OMX_ErrorNone) {
00447 DEBUG(DEB_LEV_ERR, "Err in GetParameter OMX_AUDIO_PARAM_PCMMODETYPE in AlsaSrc. Exiting...\n");
00448 exit(1);
00449 }
00450 sPCMModeParam.nChannels = (channel >0 ) ? channel:sPCMModeParam.nChannels;
00451 sPCMModeParam.nSamplingRate = (rate >0 ) ? rate:sPCMModeParam.nSamplingRate;
00452 err = OMX_SetParameter(appPriv->audiosrchandle,OMX_IndexParamAudioPcm,&sPCMModeParam);
00453 if (err != OMX_ErrorNone) {
00454 DEBUG(DEB_LEV_ERR, "Err in SetParameter OMX_AUDIO_PARAM_PCMMODETYPE in AlsaSrc. Exiting...\n");
00455 exit(1);
00456 }
00457 if(flagIsSinkRequested) {
00458 err = OMX_SetParameter(appPriv->alsasink_handle,OMX_IndexParamAudioPcm,&sPCMModeParam);
00459 if (err != OMX_ErrorNone) {
00460 DEBUG(DEB_LEV_ERR, "Err in SetParameter OMX_AUDIO_PARAM_PCMMODETYPE in AlsaSink. Exiting...\n");
00461 exit(1);
00462 }
00463 }
00464 } else if(flagIsSinkRequested) {
00465 setHeader(&sPCMModeParam, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE));
00466 err = OMX_GetParameter(appPriv->audiosrchandle,OMX_IndexParamAudioPcm,&sPCMModeParam);
00467 if (err != OMX_ErrorNone) {
00468 DEBUG(DEB_LEV_ERR, "Err in GetParameter OMX_AUDIO_PARAM_PCMMODETYPE in AlsaSrc. Exiting...\n");
00469 exit(1);
00470 }
00471 err = OMX_SetParameter(appPriv->alsasink_handle,OMX_IndexParamAudioPcm,&sPCMModeParam);
00472 if (err != OMX_ErrorNone) {
00473 DEBUG(DEB_LEV_ERR, "Err in SetParameter OMX_AUDIO_PARAM_PCMMODETYPE in AlsaSink. Exiting...\n");
00474 exit(1);
00475 }
00476 }
00477
00479 DEBUG(DEB_LEV_SIMPLE_SEQ, "\n buffer_out_size : %d \n", (int)buffer_out_size);
00480
00482 if (flagSetupTunnel) {
00483 DEBUG(DEB_LEV_SIMPLE_SEQ, "Setting up Tunnel\n");
00484 err = OMX_SetupTunnel(appPriv->audiosrchandle, 0, appPriv->volume_handle, 0);
00485 if(err != OMX_ErrorNone) {
00486 DEBUG(DEB_LEV_ERR, "Set up Tunnel between audio src & volume component Failed\n");
00487 exit(1);
00488 }
00489 err = OMX_SetupTunnel(appPriv->volume_handle, 1, appPriv->alsasink_handle, 0);
00490 if(err != OMX_ErrorNone) {
00491 DEBUG(DEB_LEV_ERR, "Set up Tunnel between volume component & audio sink Failed\n");
00492 exit(1);
00493 }
00494 DEBUG(DEFAULT_MESSAGES, "Set up Tunnel Completed\n");
00495 }
00496
00498 err = OMX_SendCommand(appPriv->audiosrchandle, OMX_CommandStateSet, OMX_StateIdle, NULL);
00499
00501 if(flagIsVolCompRequested && flagSetupTunnel) {
00502 err = OMX_SendCommand(appPriv->volume_handle, OMX_CommandStateSet, OMX_StateIdle, NULL);
00503 if(flagIsSinkRequested && flagSetupTunnel) {
00504 err = OMX_SendCommand(appPriv->alsasink_handle, OMX_CommandStateSet, OMX_StateIdle, NULL);
00505 }
00506 }
00507
00508 if(flagSetupTunnel) {
00509 if(flagIsSinkRequested) {
00510 tsem_down(appPriv->alsasinkEventSem);
00511 }
00512 if(flagIsVolCompRequested) {
00513 tsem_down(appPriv->volumeEventSem);
00514 }
00515 }
00516
00518 if (!flagSetupTunnel) {
00519 pOutBuffer[0] = pOutBuffer[1] = NULL;
00520 err = OMX_AllocateBuffer(appPriv->audiosrchandle, &pOutBuffer[0], 0, NULL, buffer_out_size);
00521 err = OMX_AllocateBuffer(appPriv->audiosrchandle, &pOutBuffer[1], 0, NULL, buffer_out_size);
00522 }
00523
00524 DEBUG(DEB_LEV_SIMPLE_SEQ, "Before locking on idle wait semaphore\n");
00525 tsem_down(appPriv->sourceEventSem);
00526 DEBUG(DEB_LEV_SIMPLE_SEQ, "source Sem free\n");
00527
00528 if(!flagSetupTunnel) {
00529 if(flagIsVolCompRequested == 1) {
00530 pOutBufferVolc[0] = pOutBufferVolc[1] = NULL;
00531 err = OMX_SendCommand(appPriv->volume_handle, OMX_CommandStateSet, OMX_StateIdle, NULL);
00532
00534 err = OMX_UseBuffer(appPriv->volume_handle, &pInBufferVolc[0], 0, NULL, buffer_out_size, pOutBuffer[0]->pBuffer);
00535 if(err != OMX_ErrorNone) {
00536 DEBUG(DEB_LEV_ERR, "Unable to use the volume component comp allocate buffer\n");
00537 exit(1);
00538 }
00539 err = OMX_UseBuffer(appPriv->volume_handle, &pInBufferVolc[1], 0, NULL, buffer_out_size, pOutBuffer[1]->pBuffer);
00540 if(err != OMX_ErrorNone) {
00541 DEBUG(DEB_LEV_ERR, "Unable to use the volume component comp allocate buffer\n");
00542 exit(1);
00543 }
00544
00547 err = OMX_AllocateBuffer(appPriv->volume_handle, &pOutBufferVolc[0], 1, NULL, buffer_out_size);
00548 if(err != OMX_ErrorNone) {
00549 DEBUG(DEB_LEV_ERR, "Unable to allocate buffer in volume component\n");
00550 exit(1);
00551 }
00552 err = OMX_AllocateBuffer(appPriv->volume_handle, &pOutBufferVolc[1], 1, NULL, buffer_out_size);
00553 if(err != OMX_ErrorNone) {
00554 DEBUG(DEB_LEV_ERR, "Unable to allocate buffer in colro conv\n");
00555 exit(1);
00556 }
00557
00558 DEBUG(DEB_LEV_SIMPLE_SEQ, "Before locking on idle wait semaphore\n");
00559 tsem_down(appPriv->volumeEventSem);
00560 DEBUG(DEFAULT_MESSAGES, "volume Event Sem free\n");
00561
00562 if(flagIsSinkRequested == 1) {
00563 err = OMX_SendCommand(appPriv->alsasink_handle, OMX_CommandStateSet, OMX_StateIdle, NULL);
00564 err = OMX_UseBuffer(appPriv->alsasink_handle, &pInBufferSink[0], 0, NULL, buffer_out_size, pOutBufferVolc[0]->pBuffer);
00565 if(err != OMX_ErrorNone) {
00566 DEBUG(DEB_LEV_ERR, "Unable to use the alsasink_handle comp allocate buffer\n");
00567 exit(1);
00568 }
00569 err = OMX_UseBuffer(appPriv->alsasink_handle, &pInBufferSink[1], 0, NULL, buffer_out_size, pOutBufferVolc[1]->pBuffer);
00570 if(err != OMX_ErrorNone) {
00571 DEBUG(DEB_LEV_ERR, "Unable to use the alsasink_handle comp allocate buffer\n");
00572 exit(1);
00573 }
00574
00575 DEBUG(DEB_LEV_SIMPLE_SEQ, "Before locking on idle wait semaphore\n");
00576 tsem_down(appPriv->alsasinkEventSem);
00577 DEBUG(DEB_LEV_SIMPLE_SEQ, "audio sink comp Sem free\n");
00578 }
00579 }
00580
00581 if(flagIsVolCompRequested == 1) {
00582 err = OMX_SendCommand(appPriv->volume_handle, OMX_CommandStateSet, OMX_StateExecuting, NULL);
00583 tsem_down(appPriv->volumeEventSem);
00584 if(flagIsSinkRequested == 1) {
00585 err = OMX_SendCommand(appPriv->alsasink_handle, OMX_CommandStateSet, OMX_StateExecuting, NULL);
00586 tsem_down(appPriv->alsasinkEventSem);
00587 }
00588 }
00589 }
00590
00592 if(flagIsVolCompRequested == 1 && flagSetupTunnel) {
00593 err = OMX_SendCommand(appPriv->volume_handle, OMX_CommandStateSet, OMX_StateExecuting, NULL);
00594 tsem_down(appPriv->volumeEventSem);
00595 if(flagIsSinkRequested == 1) {
00596 err = OMX_SendCommand(appPriv->alsasink_handle, OMX_CommandStateSet, OMX_StateExecuting, NULL);
00597 tsem_down(appPriv->alsasinkEventSem);
00598 }
00599 }
00600
00602 err = OMX_SendCommand(appPriv->audiosrchandle, OMX_CommandStateSet, OMX_StateExecuting, NULL);
00603 tsem_down(appPriv->sourceEventSem);
00604
00605 if(flagIsVolCompRequested == 1 && !flagSetupTunnel) {
00606 err = OMX_FillThisBuffer(appPriv->volume_handle, pOutBufferVolc[0]);
00607 err = OMX_FillThisBuffer(appPriv->volume_handle, pOutBufferVolc[1]);
00608 DEBUG(DEFAULT_MESSAGES, "---> After fill this buffer function calls to the volume component output buffers\n");
00609 }
00610 if (!flagSetupTunnel) {
00611 err = OMX_FillThisBuffer(appPriv->audiosrchandle, pOutBuffer[0]);
00612 err = OMX_FillThisBuffer(appPriv->audiosrchandle, pOutBuffer[1]);
00613 }
00614
00615 DEBUG(DEB_LEV_SIMPLE_SEQ, "---> Before locking on condition and sourceMutex\n");
00616
00617 DEBUG(DEFAULT_MESSAGES,"Enter 'q' or 'Q' to exit\n");
00618
00619 while(1) {
00620 if('Q' == toupper(getchar())) {
00621 DEBUG(DEFAULT_MESSAGES,"Stoping capture\n");
00622 bEOS = OMX_TRUE;
00623 usleep(10000);
00624 break;
00625 }
00626 }
00627
00628 DEBUG(DEFAULT_MESSAGES, "The execution of the audio decoding process is terminated\n");
00629
00631 err = OMX_SendCommand(appPriv->audiosrchandle, OMX_CommandStateSet, OMX_StateIdle, NULL);
00632 if(flagIsVolCompRequested == 1) {
00633 err = OMX_SendCommand(appPriv->volume_handle, OMX_CommandStateSet, OMX_StateIdle, NULL);
00634 if(flagIsSinkRequested == 1) {
00635 err = OMX_SendCommand(appPriv->alsasink_handle, OMX_CommandStateSet, OMX_StateIdle, NULL);
00636 }
00637 }
00638
00639 tsem_down(appPriv->sourceEventSem);
00640 if(flagIsVolCompRequested == 1) {
00641 tsem_down(appPriv->volumeEventSem);
00642 if(flagIsSinkRequested == 1) {
00643 tsem_down(appPriv->alsasinkEventSem);
00644 }
00645 }
00646
00647 DEBUG(DEFAULT_MESSAGES, "All audio components Transitioned to Idle\n");
00648
00650 err = OMX_SendCommand(appPriv->audiosrchandle, OMX_CommandStateSet, OMX_StateLoaded, NULL);
00651 if(flagIsVolCompRequested == 1) {
00652 err = OMX_SendCommand(appPriv->volume_handle, OMX_CommandStateSet, OMX_StateLoaded, NULL);
00653 if(flagIsSinkRequested == 1) {
00654 err = OMX_SendCommand(appPriv->alsasink_handle, OMX_CommandStateSet, OMX_StateLoaded, NULL);
00655 }
00656 }
00657
00659 if(flagIsVolCompRequested == 1 && !flagSetupTunnel) {
00660
00661 DEBUG(DEB_LEV_SIMPLE_SEQ, "volume component to loaded\n");
00662 err = OMX_FreeBuffer(appPriv->volume_handle, 0, pInBufferVolc[0]);
00663 err = OMX_FreeBuffer(appPriv->volume_handle, 0, pInBufferVolc[1]);
00664
00665 err = OMX_FreeBuffer(appPriv->volume_handle, 1, pOutBufferVolc[0]);
00666 err = OMX_FreeBuffer(appPriv->volume_handle, 1, pOutBufferVolc[1]);
00667
00668 if(flagIsSinkRequested == 1) {
00669 DEBUG(DEB_LEV_SIMPLE_SEQ, "Audio sink to loaded\n");
00670 err = OMX_FreeBuffer(appPriv->alsasink_handle, 0, pInBufferSink[0]);
00671 err = OMX_FreeBuffer(appPriv->alsasink_handle, 0, pInBufferSink[1]);
00672 }
00673 }
00674
00676 DEBUG(DEB_LEV_SIMPLE_SEQ, "Audio dec to loaded\n");
00677 if(!flagSetupTunnel) {
00678 DEBUG(DEB_LEV_PARAMS, "Free Audio dec output ports\n");
00679 err = OMX_FreeBuffer(appPriv->audiosrchandle, 0, pOutBuffer[0]);
00680 err = OMX_FreeBuffer(appPriv->audiosrchandle, 0, pOutBuffer[1]);
00681 }
00682
00683 if(flagIsVolCompRequested == 1) {
00684 if(flagIsSinkRequested == 1) {
00685 tsem_down(appPriv->alsasinkEventSem);
00686 }
00687 tsem_down(appPriv->volumeEventSem);
00688 }
00689 tsem_down(appPriv->sourceEventSem);
00690 DEBUG(DEB_LEV_SIMPLE_SEQ, "All components released\n");
00691
00692 OMX_FreeHandle(appPriv->audiosrchandle);
00693 if(flagIsVolCompRequested == 1) {
00694 if(flagIsSinkRequested == 1) {
00695 OMX_FreeHandle(appPriv->alsasink_handle);
00696 }
00697 OMX_FreeHandle(appPriv->volume_handle);
00698 }
00699 DEBUG(DEB_LEV_SIMPLE_SEQ, "audio dec freed\n");
00700
00701 OMX_Deinit();
00702
00703 DEBUG(DEFAULT_MESSAGES, "All components freed. Closing...\n");
00704 free(appPriv->sourceEventSem);
00705 if(flagIsVolCompRequested == 1) {
00706 if(flagIsSinkRequested == 1) {
00707 free(appPriv->alsasinkEventSem);
00708 }
00709 free(appPriv->volumeEventSem);
00710 }
00711 free(appPriv->eofSem);
00712 free(appPriv);
00713
00714 free(full_component_name);
00715
00717 if(!flagIsSinkRequested) {
00718 fclose(outfile);
00719 }
00720 if(output_file) {
00721 free(output_file);
00722 }
00723
00724 return 0;
00725 }
00726
00728 OMX_ERRORTYPE alsasinkEventHandler(
00729 OMX_OUT OMX_HANDLETYPE hComponent,
00730 OMX_OUT OMX_PTR pAppData,
00731 OMX_OUT OMX_EVENTTYPE eEvent,
00732 OMX_OUT OMX_U32 Data1,
00733 OMX_OUT OMX_U32 Data2,
00734 OMX_OUT OMX_PTR pEventData) {
00735
00736 DEBUG(DEB_LEV_SIMPLE_SEQ, "Hi there, I am in the %s callback\n", __func__);
00737 if(eEvent == OMX_EventCmdComplete) {
00738 if (Data1 == OMX_CommandStateSet) {
00739 DEBUG(DEB_LEV_SIMPLE_SEQ, "State changed in ");
00740 switch ((int)Data2) {
00741 case OMX_StateInvalid:
00742 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateInvalid\n");
00743 break;
00744 case OMX_StateLoaded:
00745 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateLoaded\n");
00746 break;
00747 case OMX_StateIdle:
00748 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateIdle ---- fbsink\n");
00749 break;
00750 case OMX_StateExecuting:
00751 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateExecuting\n");
00752 break;
00753 case OMX_StatePause:
00754 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StatePause\n");
00755 break;
00756 case OMX_StateWaitForResources:
00757 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateWaitForResources\n");
00758 break;
00759 }
00760 tsem_up(appPriv->alsasinkEventSem);
00761 }
00762 else if (OMX_CommandPortEnable || OMX_CommandPortDisable) {
00763 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s Received Port Enable/Disable Event\n",__func__);
00764 tsem_up(appPriv->alsasinkEventSem);
00765 }
00766 } else if(eEvent == OMX_EventBufferFlag) {
00767 DEBUG(DEB_LEV_ERR, "In %s OMX_BUFFERFLAG_EOS\n", __func__);
00768 if((int)Data2 == OMX_BUFFERFLAG_EOS) {
00769 tsem_up(appPriv->eofSem);
00770 }
00771 } else {
00772 DEBUG(DEB_LEV_SIMPLE_SEQ, "Param1 is %i\n", (int)Data1);
00773 DEBUG(DEB_LEV_SIMPLE_SEQ, "Param2 is %i\n", (int)Data2);
00774 }
00775 return OMX_ErrorNone;
00776 }
00777
00778
00779 OMX_ERRORTYPE alsasinkEmptyBufferDone(
00780 OMX_OUT OMX_HANDLETYPE hComponent,
00781 OMX_OUT OMX_PTR pAppData,
00782 OMX_OUT OMX_BUFFERHEADERTYPE* pBuffer) {
00783
00784 OMX_ERRORTYPE err;
00785 static int inputBufferDropped = 0;
00786 if(pBuffer != NULL) {
00787 if(!bEOS) {
00788 if(pOutBufferVolc[0]->pBuffer == pBuffer->pBuffer) {
00789 pOutBufferVolc[0]->nFilledLen = pBuffer->nFilledLen;
00790 err = OMX_FillThisBuffer(appPriv->volume_handle, pOutBufferVolc[0]);
00791 } else {
00792 pOutBufferVolc[1]->nFilledLen = pBuffer->nFilledLen;
00793 err = OMX_FillThisBuffer(appPriv->volume_handle, pOutBufferVolc[1]);
00794 }
00795 if(err != OMX_ErrorNone) {
00796 DEBUG(DEB_LEV_ERR, "In %s Error %08x Calling FillThisBuffer\n", __func__,err);
00797 }
00798 } else {
00799 DEBUG(DEB_LEV_ERR, "In %s: eos=%x Dropping Fill This Buffer\n", __func__,(int)pBuffer->nFlags);
00800 inputBufferDropped++;
00801 if(inputBufferDropped == 2) {
00802 tsem_up(appPriv->eofSem);
00803 }
00804 }
00805 } else {
00806 if(!bEOS) {
00807 tsem_up(appPriv->eofSem);
00808 }
00809 DEBUG(DEB_LEV_ERR, "Ouch! In %s: had NULL buffer to output...\n", __func__);
00810 }
00811 return OMX_ErrorNone;
00812 }
00813
00814
00815
00816 OMX_ERRORTYPE volumeEventHandler(
00817 OMX_OUT OMX_HANDLETYPE hComponent,
00818 OMX_OUT OMX_PTR pAppData,
00819 OMX_OUT OMX_EVENTTYPE eEvent,
00820 OMX_OUT OMX_U32 Data1,
00821 OMX_OUT OMX_U32 Data2,
00822 OMX_OUT OMX_PTR pEventData) {
00823
00824 DEBUG(DEB_LEV_SIMPLE_SEQ, "\nHi there, I am in the %s callback\n", __func__);
00825 if(eEvent == OMX_EventCmdComplete) {
00826 if (Data1 == OMX_CommandStateSet) {
00827 DEBUG(DEB_LEV_SIMPLE_SEQ, "\nState changed in ");
00828 switch ((int)Data2) {
00829 case OMX_StateInvalid:
00830 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateInvalid\n");
00831 break;
00832 case OMX_StateLoaded:
00833 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateLoaded\n");
00834 break;
00835 case OMX_StateIdle:
00836 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateIdle\n");
00837 break;
00838 case OMX_StateExecuting:
00839 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateExecuting\n");
00840 break;
00841 case OMX_StatePause:
00842 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StatePause\n");
00843 break;
00844 case OMX_StateWaitForResources:
00845 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateWaitForResources\n");
00846 break;
00847 }
00848 tsem_up(appPriv->volumeEventSem);
00849 }
00850 else if (OMX_CommandPortEnable || OMX_CommandPortDisable) {
00851 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s Received Port Enable/Disable Event\n",__func__);
00852 tsem_up(appPriv->volumeEventSem);
00853 }
00854 } else if(eEvent == OMX_EventBufferFlag) {
00855 DEBUG(DEB_LEV_ERR, "In %s OMX_BUFFERFLAG_EOS\n", __func__);
00856 if((int)Data2 == OMX_BUFFERFLAG_EOS) {
00857 tsem_up(appPriv->eofSem);
00858 }
00859 } else {
00860 DEBUG(DEB_LEV_SIMPLE_SEQ, "Param1 is %i\n", (int)Data1);
00861 DEBUG(DEB_LEV_SIMPLE_SEQ, "Param2 is %i\n", (int)Data2);
00862 }
00863 return OMX_ErrorNone;
00864 }
00865
00866
00867 OMX_ERRORTYPE volumeEmptyBufferDone(
00868 OMX_OUT OMX_HANDLETYPE hComponent,
00869 OMX_OUT OMX_PTR pAppData,
00870 OMX_OUT OMX_BUFFERHEADERTYPE* pBuffer) {
00871
00872 OMX_ERRORTYPE err;
00873 static int iBufferDropped = 0;
00874
00875 if(pBuffer != NULL) {
00876 if(!bEOS) {
00877 if(pOutBuffer[0]->pBuffer == pBuffer->pBuffer) {
00878 pOutBuffer[0]->nFilledLen = pBuffer->nFilledLen;
00879 err = OMX_FillThisBuffer(appPriv->audiosrchandle, pOutBuffer[0]);
00880 } else {
00881 pOutBuffer[1]->nFilledLen = pBuffer->nFilledLen;
00882 err = OMX_FillThisBuffer(appPriv->audiosrchandle, pOutBuffer[1]);
00883 }
00884 if(err != OMX_ErrorNone) {
00885 DEBUG(DEB_LEV_ERR, "In %s Error %08x Calling FillThisBuffer\n", __func__,err);
00886 }
00887 } else {
00888 DEBUG(DEB_LEV_ERR, "In %s: eos=%x Dropping Fill This Buffer\n", __func__,(int)pBuffer->nFlags);
00889 iBufferDropped++;
00890 if(iBufferDropped == 2) {
00891 tsem_up(appPriv->eofSem);
00892 }
00893 }
00894 } else {
00895 if(!bEOS) {
00896 tsem_up(appPriv->eofSem);
00897 }
00898 DEBUG(DEB_LEV_ERR, "Ouch! In %s: had NULL buffer to output...\n", __func__);
00899 }
00900 return OMX_ErrorNone;
00901 }
00902
00903
00904 OMX_ERRORTYPE volumeFillBufferDone(
00905 OMX_OUT OMX_HANDLETYPE hComponent,
00906 OMX_OUT OMX_PTR pAppData,
00907 OMX_OUT OMX_BUFFERHEADERTYPE* pBuffer) {
00908
00909 OMX_ERRORTYPE err;
00910 if(pBuffer != NULL) {
00911 if(!bEOS) {
00915 if(flagIsSinkRequested && (!flagSetupTunnel)) {
00916 if(pInBufferSink[0]->pBuffer == pBuffer->pBuffer) {
00917 pInBufferSink[0]->nFilledLen = pBuffer->nFilledLen;
00918 err = OMX_EmptyThisBuffer(appPriv->alsasink_handle, pInBufferSink[0]);
00919 } else {
00920 pInBufferSink[1]->nFilledLen = pBuffer->nFilledLen;
00921 err = OMX_EmptyThisBuffer(appPriv->alsasink_handle, pInBufferSink[1]);
00922 }
00923 if(err != OMX_ErrorNone) {
00924 DEBUG(DEB_LEV_ERR, "In %s Error %08x Calling FillThisBuffer\n", __func__,err);
00925 }
00926 } else if((pBuffer->nFilledLen > 0) && (!flagSetupTunnel)) {
00927 fwrite(pBuffer->pBuffer, 1, pBuffer->nFilledLen, outfile);
00928 pBuffer->nFilledLen = 0;
00929 }
00930 if(pBuffer->nFlags == OMX_BUFFERFLAG_EOS) {
00931 DEBUG(DEB_LEV_ERR, "In %s: eos=%x Calling Empty This Buffer\n", __func__, (int)pBuffer->nFlags);
00932 bEOS = OMX_TRUE;
00933 }
00934 if(!bEOS && !flagIsSinkRequested && (!flagSetupTunnel)) {
00935 err = OMX_FillThisBuffer(hComponent, pBuffer);
00936 }
00937 } else {
00938 DEBUG(DEB_LEV_ERR, "In %s: eos=%x Dropping Empty This Buffer\n", __func__,(int)pBuffer->nFlags);
00939 }
00940 } else {
00941 DEBUG(DEB_LEV_ERR, "Ouch! In %s: had NULL buffer to output...\n", __func__);
00942 }
00943 return OMX_ErrorNone;
00944 }
00945
00947 OMX_ERRORTYPE audiosrcEventHandler(
00948 OMX_OUT OMX_HANDLETYPE hComponent,
00949 OMX_OUT OMX_PTR pAppData,
00950 OMX_OUT OMX_EVENTTYPE eEvent,
00951 OMX_OUT OMX_U32 Data1,
00952 OMX_OUT OMX_U32 Data2,
00953 OMX_OUT OMX_PTR pEventData) {
00954
00955 OMX_ERRORTYPE err = OMX_ErrorNone;
00956
00957 DEBUG(DEB_LEV_SIMPLE_SEQ, "Hi there, I am in the %s callback\n", __func__);
00958 if(eEvent == OMX_EventCmdComplete) {
00959 if (Data1 == OMX_CommandStateSet) {
00960 DEBUG(DEB_LEV_SIMPLE_SEQ, "State changed in ");
00961 switch ((int)Data2) {
00962 case OMX_StateInvalid:
00963 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateInvalid\n");
00964 break;
00965 case OMX_StateLoaded:
00966 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateLoaded\n");
00967 break;
00968 case OMX_StateIdle:
00969 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateIdle\n");
00970 break;
00971 case OMX_StateExecuting:
00972 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateExecuting\n");
00973 break;
00974 case OMX_StatePause:
00975 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StatePause\n");
00976 break;
00977 case OMX_StateWaitForResources:
00978 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateWaitForResources\n");
00979 break;
00980 }
00981 tsem_up(appPriv->sourceEventSem);
00982 }
00983 else if (OMX_CommandPortEnable || OMX_CommandPortDisable) {
00984 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s Received Port Enable/Disable Event\n",__func__);
00985 tsem_up(appPriv->sourceEventSem);
00986 }
00987 } else if(eEvent == OMX_EventPortSettingsChanged) {
00988 DEBUG(DEB_LEV_SIMPLE_SEQ, "\n port settings change event handler in %s \n", __func__);
00989 } else if(eEvent == OMX_EventBufferFlag) {
00990 DEBUG(DEB_LEV_ERR, "In %s OMX_BUFFERFLAG_EOS\n", __func__);
00991 if((int)Data2 == OMX_BUFFERFLAG_EOS) {
00992 tsem_up(appPriv->eofSem);
00993 }
00994 } else {
00995 DEBUG(DEB_LEV_SIMPLE_SEQ, "Param1 is %i\n", (int)Data1);
00996 DEBUG(DEB_LEV_SIMPLE_SEQ, "Param2 is %i\n", (int)Data2);
00997 }
00998 return err;
00999 }
01000
01001 OMX_ERRORTYPE audiosrcFillBufferDone(
01002 OMX_OUT OMX_HANDLETYPE hComponent,
01003 OMX_OUT OMX_PTR pAppData,
01004 OMX_OUT OMX_BUFFERHEADERTYPE* pBuffer) {
01005
01006 OMX_ERRORTYPE err;
01007 OMX_STATETYPE eState;
01008
01009 if(pBuffer != NULL){
01010 if(!bEOS) {
01014 if(flagIsVolCompRequested && (!flagSetupTunnel)) {
01015 OMX_GetState(appPriv->volume_handle,&eState);
01016 if(eState == OMX_StateExecuting || eState == OMX_StatePause) {
01017 if(pInBufferVolc[0]->pBuffer == pBuffer->pBuffer) {
01018 pInBufferVolc[0]->nFilledLen = pBuffer->nFilledLen;
01019 err = OMX_EmptyThisBuffer(appPriv->volume_handle, pInBufferVolc[0]);
01020 } else {
01021 pInBufferVolc[1]->nFilledLen = pBuffer->nFilledLen;
01022 err = OMX_EmptyThisBuffer(appPriv->volume_handle, pInBufferVolc[1]);
01023 }
01024 if(err != OMX_ErrorNone) {
01025 DEBUG(DEB_LEV_ERR, "In %s Error %08x Calling FillThisBuffer\n", __func__,err);
01026 }
01027 } else {
01028 err = OMX_FillThisBuffer(hComponent, pBuffer);
01029 }
01030 } else if((pBuffer->nFilledLen > 0) && (!flagSetupTunnel)) {
01031 fwrite(pBuffer->pBuffer, 1, pBuffer->nFilledLen, outfile);
01032 pBuffer->nFilledLen = 0;
01033 }
01034 if(pBuffer->nFlags == OMX_BUFFERFLAG_EOS) {
01035 DEBUG(DEB_LEV_ERR, "In %s: eos=%x Calling Empty This Buffer\n", __func__, (int)pBuffer->nFlags);
01036 bEOS = OMX_TRUE;
01037 }
01038 if(!bEOS && !flagIsVolCompRequested && (!flagSetupTunnel)) {
01039 err = OMX_FillThisBuffer(hComponent, pBuffer);
01040 }
01041 } else {
01042 DEBUG(DEB_LEV_ERR, "In %s: eos=%x Dropping Empty This Buffer\n", __func__,(int)pBuffer->nFlags);
01043 }
01044 } else {
01045 DEBUG(DEB_LEV_ERR, "Ouch! In %s: had NULL buffer to output...\n", __func__);
01046 }
01047 return OMX_ErrorNone;
01048 }
01049
01050