OpenMAXBellagio  0.9.3
omxaudiomixertest.c
Go to the documentation of this file.
1 
28 #include "omxaudiomixertest.h"
29 
30 #define BUFFER_COUNT_ACTUAL 2
31 #define FRAME_SIZE 1152*2*2 // 1152 samples* 2 channels * 2byte/16bits per channel
32 
34  .EmptyBufferDone = audiomixerEmptyBufferDone,
35  .FillBufferDone = audiomixerFillBufferDone,
36 };
37 
38 static void setHeader(OMX_PTR header, OMX_U32 size) {
39  OMX_VERSIONTYPE* ver = (OMX_VERSIONTYPE*)(header + sizeof(OMX_U32));
40  *((OMX_U32*)header) = size;
41 
45  ver->s.nStep = VERSIONSTEP;
46 }
47 
48 void display_help() {
49  printf("\n");
50  printf("Usage: omxaudiomixertest [-o outfile] [-gi gain] -t -r 44100 -n 2 filename0 [filename1 filename2 filename3]\n");
51  printf("\n");
52  printf(" -o outfile: If this option is specified, the output stream is written to outfile\n");
53  printf(" otherwise redirected to std output\n");
54  printf(" -gi : Gain of stream i[0..3] data [0...100]\n");
55  printf(" -r 44100 : Sample Rate [Default 44100]\n");
56  printf(" -n 2 : Number of channel [Default 2]\n\n");
57  printf(" -h : Displays this help\n");
58  printf("\n");
59  exit(1);
60 }
61 
62 /* Application private date: should go in the component field (segs...) */
64 int fd[4];
65 unsigned int filesize[4];
69 int flagIsGain[4];
74 FILE *outfile;
75 
77 static OMX_BOOL isPortDisabled[4];
78 static int iBufferDropped[4];
79 
80 int main(int argc, char** argv) {
81 
82  OMX_PORT_PARAM_TYPE sParam;
83  OMX_U32 data_read;
84  int j;
85  int i=0;
88  int gain[4];
89  int argn_dec;
90  int index_files = 0, index_gain = 0;
91  OMX_U32 srate=0,nchannel=0;
93  char c;
94 
95  gain[0]=gain[1]=gain[2]=gain[3]=100;
96  fd[0] = fd[1] = fd[2] = fd[3] = 0;
97  bEOS[0] = bEOS[1] = bEOS[2] = bEOS[3] = OMX_FALSE;
98  /* Obtain file descriptor */
99  if(argc < 2){
100  display_help();
101  } else {
102  flagIsOutputExpected = 0;
103  flagOutputReceived = 0;
104  flagInputReceived = 0;
105  flagIsGain[0] = 0;
106  flagIsGain[1] = 0;
107  flagIsGain[2] = 0;
108  flagIsGain[3] = 0;
109  flagSampleRate = 0;
110  flagChannel = 0;
111 
112  argn_dec = 1;
113  while (argn_dec<argc) {
114  if (*(argv[argn_dec]) =='-') {
115  if (flagIsOutputExpected) {
116  display_help();
117  }
118  switch (*(argv[argn_dec]+1)) {
119  case 'h':
120  display_help();
121  break;
122  case 'o':
123  flagIsOutputExpected = 1;
124  break;
125  case 'g':
126  index_gain = atoi(argv[argn_dec]+2);
127  if(index_gain > 3) {
128  DEBUG(DEFAULT_MESSAGES, "-g%i is not valid\n", index_gain);
129  index_gain = 0;
130  }
131  flagIsGain[index_gain] = 1;
132  break;
133  case 'r':
134  flagSampleRate = 1;
135  break;
136  case 'n':
137  flagChannel = 1;
138  break;
139  default:
140  display_help();
141  }
142  } else {
143  if (flagIsGain[index_gain]) {
144  gain[index_gain] = (int)atoi(argv[argn_dec]);
145  DEBUG(DEFAULT_MESSAGES, "gain[%d]=%d\n", index_gain, gain[index_gain]);
146  flagIsGain[index_gain] = 0;
147  if(gain[index_gain] > 100) {
148  DEBUG(DEFAULT_MESSAGES, "Gain of stream %i should be between [0..100]\n", index_gain);
149  gain[index_gain] = 100;
150  }
151  index_gain = 0;
152  } else if (flagIsOutputExpected) {
153  output_file = malloc(strlen(argv[argn_dec]) * sizeof(char) + 1);
154  strcpy(output_file,argv[argn_dec]);
155  flagIsOutputExpected = 0;
156  flagOutputReceived = 1;
157  } else if (flagSampleRate) {
158  srate = (int)atoi(argv[argn_dec]);
159  flagSampleRate = 0;
160  } else if (flagChannel) {
161  nchannel = (int)atoi(argv[argn_dec]);
162  flagChannel = 0;
163  } else {
164  if (index_files>3) {
165  DEBUG(DEB_LEV_ERR, "Too many input files. Only first four are accepted\n");
166  } else {
167  input_file[index_files] = malloc(strlen(argv[argn_dec]) * sizeof(char) + 1);
168  strcpy(input_file[index_files],argv[argn_dec]);
169  flagInputReceived = 1;
170  index_files++;
171  }
172  }
173  }
174  argn_dec++;
175  }
176  if (!flagInputReceived) {
177  display_help();
178  }
179  DEBUG(DEFAULT_MESSAGES, "Input files %s %s %s %s \n", input_file[0], input_file[1], input_file[2], input_file[3]);
180  DEBUG(DEFAULT_MESSAGES, " to ");
181  if (flagOutputReceived) {
182  DEBUG(DEFAULT_MESSAGES, " %s\n", output_file);
183  } else {
184  DEBUG(DEFAULT_MESSAGES, " Audio Sink\n");
185  }
186  }
187 
188  if(input_file[0]== NULL) {
189  DEBUG(DEB_LEV_ERR, "Provide at least an input file\n");
190  exit(1);
191  }
192 
193  for (i = 0; i<index_files; i++) {
194  fd[i] = open(input_file[i], O_RDONLY);
195  if(fd[i] < 0){
196  DEBUG(DEB_LEV_ERR, "Error opening input file %i\n", i);
197  exit(1);
198  }
199  }
200 
201  if (flagOutputReceived) {
202  outfile = fopen(output_file,"wb");
203  if(outfile == NULL) {
204  DEBUG(DEB_LEV_ERR, "Error at opening the output file");
205  exit(1);
206  }
207  }
208 
209 
210  for (i = 0; i<index_files; i++) {
211  filesize[i] = getFileSize(fd[i]);
212  }
213 
214  /* Initialize application private data */
215  appPriv = malloc(sizeof(appPrivateType));
216  pthread_cond_init(&appPriv->condition, NULL);
217  pthread_mutex_init(&appPriv->mutex, NULL);
218  appPriv->eventSem = malloc(sizeof(tsem_t));
219  tsem_init(appPriv->eventSem, 0);
220  appPriv->eofSem = malloc(sizeof(tsem_t));
221  tsem_init(appPriv->eofSem, 0);
222  iBufferDropped[0] = 0;
223  iBufferDropped[1] = 0;
224  iBufferDropped[2] = 0;
225  iBufferDropped[3] = 0;
226 
227  err = OMX_Init();
228  if(err != OMX_ErrorNone) {
229  DEBUG(DEB_LEV_ERR, "OMX_Init() failed\n");
230  exit(1);
231  }
233  err = OMX_GetHandle(&appPriv->handle, "OMX.st.audio.mixer", NULL , &callbacks);
234  if(err != OMX_ErrorNone) {
235  DEBUG(DEB_LEV_ERR, "Audio Mixer OMX_GetHandle failed\n");
236  exit(1);
237  }
238 
239  /*Max 4 input stream*/
240  for(j=0;j<4;j++) {
241  isPortDisabled[j] = OMX_FALSE;
242  if((gain[j] >= 0) && (gain[j] <100)) {
243  sVolume.nPortIndex = j;
244  err = OMX_GetConfig(appPriv->handle, OMX_IndexConfigAudioVolume, &sVolume);
245  if(err!=OMX_ErrorNone) {
246  DEBUG(DEB_LEV_ERR,"Error %08x In OMX_GetConfig %i \n",err, j);
247  }
248  sVolume.sVolume.nValue = gain[j];
249  DEBUG(DEFAULT_MESSAGES, "Setting Gain[%i] %d \n",(int)j, gain[j]);
250  err = OMX_SetConfig(appPriv->handle, OMX_IndexConfigAudioVolume, &sVolume);
251  if(err!=OMX_ErrorNone) {
252  DEBUG(DEB_LEV_ERR,"Error %08x In OMX_SetConfig %i \n",err, j);
253  }
254  }
255  }
256 
258  setHeader(&sParam, sizeof(OMX_PORT_PARAM_TYPE));
259  err = OMX_GetParameter(appPriv->handle, OMX_IndexParamAudioInit, &sParam);
260  if(err != OMX_ErrorNone){
261  DEBUG(DEB_LEV_ERR, "Error in getting OMX_PORT_PARAM_TYPE parameter\n");
262  exit(1);
263  }
264  DEBUG(DEFAULT_MESSAGES, "Audio Mixer has %d ports\n",(int)sParam.nPorts);
265 
266 // disable unused ports
267  for (j = index_files; j<4; j++) {
268  isPortDisabled[j] = OMX_TRUE;
269  err = OMX_SendCommand(appPriv->handle, OMX_CommandPortDisable, j, NULL);
270  tsem_down(appPriv->eventSem);
271  DEBUG(DEFAULT_MESSAGES, "Port %i disabled\n", j);
272  }
273  for (j = 0; j < index_files; j++) {
274  setHeader(&sPortDef, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
275  sPortDef.nPortIndex = j;
276  err = OMX_GetParameter(appPriv->handle, OMX_IndexParamPortDefinition, &sPortDef);
277 
278  sPortDef.nBufferCountActual = 2;
279  err = OMX_SetParameter(appPriv->handle, OMX_IndexParamPortDefinition, &sPortDef);
280  if(err != OMX_ErrorNone){
281  DEBUG(DEB_LEV_ERR, "Error in getting OMX_PORT_PARAM_TYPE parameter\n");
282  exit(1);
283  }
284  }
285 
287 
288  for (j=0; j<8; j++) {
289  inBuffer[j] = 0;
290  }
291  outBuffer[0] = outBuffer[1] = NULL;
292 
293 
294  for(j=0; j<index_files; j++) {
295  err = OMX_AllocateBuffer(appPriv->handle, &inBuffer[j*2], j, NULL, BUFFER_IN_SIZE);
296  if (err != OMX_ErrorNone) {
297  DEBUG(DEB_LEV_ERR, "Error on AllocateBuffer %i %p on port %i\n", j*2, inBuffer[j*2], j);
298  exit(1);
299  }
300  err = OMX_AllocateBuffer(appPriv->handle, &inBuffer[j * 2 + 1], j, NULL, BUFFER_IN_SIZE);
301  if (err != OMX_ErrorNone) {
302  DEBUG(DEB_LEV_ERR, "Error on AllocateBuffer %i %p on port %i\n", j*2+1, inBuffer[j*2+1], j);
303  exit(1);
304  }
305  }
306 
307  err = OMX_AllocateBuffer(appPriv->handle, &outBuffer[0], 4, NULL, BUFFER_IN_SIZE);
308  if (err != OMX_ErrorNone) {
309  DEBUG(DEB_LEV_ERR, "Error on AllocateBuffer 0 %p on port 4\n", outBuffer[0]);
310  exit(1);
311  }
312  err = OMX_AllocateBuffer(appPriv->handle, &outBuffer[1], 4, NULL, BUFFER_IN_SIZE);
313  if (err != OMX_ErrorNone) {
314  DEBUG(DEB_LEV_ERR, "Error on AllocateBuffer 1 %p on port 4\n", outBuffer[1]);
315  exit(1);
316  }
317 
318  tsem_down(appPriv->eventSem);
319 
321 
322  /* Wait for commands to complete */
323  tsem_down(appPriv->eventSem);
324 
325  for (i = 0; i<index_files; i++) {
326  data_read = read(fd[i], inBuffer[i*2]->pBuffer, FRAME_SIZE);
327  inBuffer[i*2]->nFilledLen = data_read;
328  filesize[i] -= data_read;
329  data_read = read(fd[i], inBuffer[i*2+1]->pBuffer, FRAME_SIZE);
330  inBuffer[i*2+1]->nFilledLen = data_read;
331  filesize[i] -= data_read;
332  }
333 
334 
335  for (i = 0; i<index_files; i++) {
336  err = OMX_EmptyThisBuffer(appPriv->handle, inBuffer[i*2]);
337  err = OMX_EmptyThisBuffer(appPriv->handle, inBuffer[i*2+1]);
338  }
339 
343  err = OMX_FillThisBuffer(appPriv->handle, outBuffer[0]);
344  err = OMX_FillThisBuffer(appPriv->handle, outBuffer[1]);
345 
346  /*Port Disable option available in case of direct play out only*/
347  if(!flagOutputReceived) {
348  DEBUG(DEFAULT_MESSAGES, "\nIf you want to disabled port enter port number[0..3]: else Enter 'q' \n\n");
349  while(!bEOS[0] || !bEOS[1] || !bEOS[2] || !bEOS[3]) {
350  DEBUG(DEFAULT_MESSAGES, "Port status 0=%i, 1=%i, 2=%i, 3=%i\n",isPortDisabled[0], isPortDisabled[1], isPortDisabled[2], isPortDisabled[3]);
351  DEBUG(DEFAULT_MESSAGES, "Port play 0=%i, 1=%i, 2=%i, 3=%i\n",bEOS[0], bEOS[1], bEOS[2], bEOS[3]);
352  DEBUG(DEFAULT_MESSAGES, "Entry : ");
353  c = getchar();
354  if(c=='\n') {
355  continue;
356  } else if(c == 'q') {
357  DEBUG(DEFAULT_MESSAGES,"No port to disable\n");
358  break;
359  } else {
360  i= (int)atoi(&c);
361  if(i>=0 && i<4) {
362  DEBUG(DEFAULT_MESSAGES,"Disabling/Enabling Port %i\n", i);
363  if (isPortDisabled[i] == OMX_TRUE) {
364  err = OMX_SendCommand(appPriv->handle, OMX_CommandPortEnable, i, NULL);
365  err = OMX_AllocateBuffer(appPriv->handle, &inBuffer[i*2], i, NULL, BUFFER_IN_SIZE);
366  err = OMX_AllocateBuffer(appPriv->handle, &inBuffer[i*2+1], i, NULL, BUFFER_IN_SIZE);
367  tsem_down(appPriv->eventSem);
368  isPortDisabled[i] = OMX_FALSE;
369  data_read = read(fd[i], inBuffer[i*2]->pBuffer, FRAME_SIZE);
370  inBuffer[i*2]->nFilledLen = data_read;
371  data_read = read(fd[i], inBuffer[i*2+1]->pBuffer, FRAME_SIZE);
372  inBuffer[i*2+1]->nFilledLen = data_read;
373  //Sending Empty buffer
374  err = OMX_EmptyThisBuffer(appPriv->handle, inBuffer[i*2]);
375  err = OMX_EmptyThisBuffer(appPriv->handle, inBuffer[i*2+1]);
376  } else {
377  isPortDisabled[i] = OMX_TRUE;
378  err = OMX_SendCommand(appPriv->handle, OMX_CommandPortDisable, i, NULL);
379  while(iBufferDropped[i]!=2) {
380  usleep(10000);
381  }
382  for(j=0;j<BUFFER_COUNT_ACTUAL;j++) {
383  err = OMX_FreeBuffer(appPriv->handle, i, inBuffer[j+i]);
384  }
385  tsem_down(appPriv->eventSem);
386  iBufferDropped[i] = 0;
387  }
388  } else {
389  DEBUG(DEFAULT_MESSAGES,"Either Port %i is already disabled or not valid\n",i);
390  }
391  }
392  }
393  }
394 
395  DEBUG(DEFAULT_MESSAGES, "Waiting for EOS\n");
396  if(isPortDisabled[0] == OMX_FALSE) {
397  tsem_down(appPriv->eofSem);
398  DEBUG(DEFAULT_MESSAGES, "Received EOS 1\n");
399  }
400  if(isPortDisabled[1] == OMX_FALSE) {
401  tsem_down(appPriv->eofSem);
402  DEBUG(DEFAULT_MESSAGES, "Received EOS 2\n");
403  }
404  if(isPortDisabled[2] == OMX_FALSE) {
405  tsem_down(appPriv->eofSem);
406  DEBUG(DEFAULT_MESSAGES, "Received EOS 3\n");
407  }
408  if(isPortDisabled[3] == OMX_FALSE) {
409  tsem_down(appPriv->eofSem);
410  DEBUG(DEFAULT_MESSAGES, "Received EOS 4\n");
411  }
412 
414  /* Wait for commands to complete */
415  tsem_down(appPriv->eventSem);
416 
418  for(j=0; j<index_files; j++) {
419  if(isPortDisabled[j] == OMX_FALSE) {
420  err = OMX_FreeBuffer(appPriv->handle, j, inBuffer[j*2]);
421  err = OMX_FreeBuffer(appPriv->handle, j, inBuffer[j*2+1]);
422  }
423  }
424 
425  for(j=0;j<BUFFER_COUNT_ACTUAL;j++) {
426  err = OMX_FreeBuffer(appPriv->handle, 4, outBuffer[j]);
427  }
428 
429  /* Wait for commands to complete */
430  tsem_down(appPriv->eventSem);
431 
432  OMX_FreeHandle(appPriv->handle);
433 
434  free(appPriv->eventSem);
435  free(appPriv);
436 
437  if (flagOutputReceived) {
438  if(fclose(outfile) != 0) {
439  DEBUG(DEB_LEV_ERR,"Error in closing output file\n");
440  exit(1);
441  }
442  free(output_file);
443  }
444  for (i = 0; i<index_files; i++) {
445  close(fd[i]);
446  free(input_file[i]);
447  }
448 
449  return 0;
450 }
451 
452 /* Callbacks implementation */
454  OMX_HANDLETYPE hComponent,
455  OMX_PTR pAppData,
456  OMX_EVENTTYPE eEvent,
457  OMX_U32 Data1,
458  OMX_U32 Data2,
459  OMX_PTR pEventData) {
460 
461  DEBUG(DEB_LEV_SIMPLE_SEQ, "Hi there, I am in the %s callback\n", __func__);
462  if(eEvent == OMX_EventCmdComplete) {
463  if (Data1 == OMX_CommandStateSet) {
464  DEBUG(DEB_LEV_SIMPLE_SEQ, "Volume Component State changed in ");
465  switch ((int)Data2) {
466  case OMX_StateInvalid:
467  DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateInvalid\n");
468  break;
469  case OMX_StateLoaded:
470  DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateLoaded\n");
471  break;
472  case OMX_StateIdle:
473  DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateIdle\n");
474  break;
475  case OMX_StateExecuting:
476  DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateExecuting\n");
477  break;
478  case OMX_StatePause:
479  DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StatePause\n");
480  break;
482  DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateWaitForResources\n");
483  break;
484  }
485  tsem_up(appPriv->eventSem);
486  } else if (Data1 == OMX_CommandPortEnable){
487  tsem_up(appPriv->eventSem);
488  } else if (Data1 == OMX_CommandPortDisable){
489  tsem_up(appPriv->eventSem);
490  }
491  } else if(eEvent == OMX_EventBufferFlag) {
492  DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_EventBufferFlag\n");
493  if((int)Data2 == OMX_BUFFERFLAG_EOS) {
494  tsem_up(appPriv->eofSem);
495  }
496  } else {
497  DEBUG(DEB_LEV_SIMPLE_SEQ, "Param1 is %i\n", (int)Data1);
498  DEBUG(DEB_LEV_SIMPLE_SEQ, "Param2 is %i\n", (int)Data2);
499  }
500 
501  return OMX_ErrorNone;
502 }
503 
505  OMX_HANDLETYPE hComponent,
506  OMX_PTR pAppData,
507  OMX_BUFFERHEADERTYPE* pBuffer) {
508 
510  int data_read;
511 
512 
513  DEBUG(DEB_LEV_FULL_SEQ, "Hi there, I am in the %s callback from the port %i\n", __func__, (int)pBuffer->nInputPortIndex);
514 
515  if(isPortDisabled[pBuffer->nInputPortIndex] == OMX_FALSE) {
516  data_read = read(fd[pBuffer->nInputPortIndex], pBuffer->pBuffer, FRAME_SIZE);
517  pBuffer->nFilledLen = data_read;
518  pBuffer->nOffset = 0;
519  filesize[pBuffer->nInputPortIndex] -= data_read;
520  DEBUG(DEB_LEV_SIMPLE_SEQ, "Sending from file %i data read=%d\n", (int)pBuffer->nInputPortIndex, data_read);
521  if (data_read <= 0) {
522  DEBUG(DEB_LEV_SIMPLE_SEQ, "In the %s no more input data available\n", __func__);
523  ++iBufferDropped[pBuffer->nInputPortIndex];
524  if(iBufferDropped[pBuffer->nInputPortIndex]==2) {
525  DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s Dropping Empty This buffer to Audio Mixer Stream %i\n", __func__, (int)pBuffer->nInputPortIndex);
526  return OMX_ErrorNone;
527  } else if(iBufferDropped[pBuffer->nInputPortIndex]>2) {
528  DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s Dropping Empty This buffer to Audio Mixer Stream %i\n", __func__, (int)pBuffer->nInputPortIndex);
529  return OMX_ErrorNone;
530  }
531  pBuffer->nFilledLen=0;
532  pBuffer->nFlags = OMX_BUFFERFLAG_EOS;
533  bEOS[pBuffer->nInputPortIndex]=OMX_TRUE;
534  DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s Sending EOS for Stream %i\n", __func__, (int)pBuffer->nInputPortIndex);
535  err = OMX_EmptyThisBuffer(hComponent, pBuffer);
536  return OMX_ErrorNone;
537  }
538  } else {
539  ++iBufferDropped[pBuffer->nInputPortIndex];
540  return OMX_ErrorNone;
541  }
542  if(!bEOS[pBuffer->nInputPortIndex]) {
543  DEBUG(DEB_LEV_FULL_SEQ, "Empty buffer %p\n", pBuffer);
544  err = OMX_EmptyThisBuffer(hComponent, pBuffer);
545  }else {
546  DEBUG(DEB_LEV_FULL_SEQ, "In %s Dropping Empty This buffer to Audio Mixer\n", __func__);
547  }
548 
549  return OMX_ErrorNone;
550 }
551 
553  OMX_HANDLETYPE hComponent,
554  OMX_PTR pAppData,
555  OMX_BUFFERHEADERTYPE* pBuffer) {
556 
558  int i;
559 
560  DEBUG(DEB_LEV_FULL_SEQ, "Hi there, I am in the %s callback. Got buflen %i for buffer at 0x%p\n",
561  __func__, (int)pBuffer->nFilledLen, pBuffer);
562 
563  /* Output data to standard output */
564  if(pBuffer != NULL) {
565  if (pBuffer->nFilledLen == 0) {
566  DEBUG(DEB_LEV_ERR, "Ouch! In %s: no data in the output buffer!\n", __func__);
567  return OMX_ErrorNone;
568  }
569  if (flagOutputReceived) {
570  if(pBuffer->nFilledLen > 0) {
571  fwrite(pBuffer->pBuffer, 1, pBuffer->nFilledLen, outfile);
572  }
573  } else {
574  for(i=0;i<pBuffer->nFilledLen;i++) {
575  putchar(*(char*)(pBuffer->pBuffer + i));
576  }
577  }
578  pBuffer->nFilledLen = 0;
579  /* Reschedule the fill buffer request */
580  if(!bEOS[0] || !bEOS[1] || !bEOS[2] || !bEOS[3]) {
581  err = OMX_FillThisBuffer(hComponent, pBuffer);
582  } else {
583  DEBUG(DEB_LEV_FULL_SEQ, "In %s Dropping Fill This buffer to Audio Mixer\n", __func__);
584  }
585  } else {
586  DEBUG(DEB_LEV_ERR, "Ouch! In %s: had NULL buffer to output...\n", __func__);
587  }
588  return OMX_ErrorNone;
589 }
590 
595 static int getFileSize(int fd) {
596 
597  struct stat input_file_stat;
598  int err;
599 
600  /* Obtain input file length */
601  err = fstat(fd, &input_file_stat);
602  if(err){
603  DEBUG(DEB_LEV_ERR, "fstat failed");
604  exit(-1);
605  }
606  return input_file_stat.st_size;
607 }
void * OMX_HANDLETYPE
Definition: OMX_Types.h:295
#define FRAME_SIZE
#define OMX_EmptyThisBuffer(hComponent,pBuffer)
Definition: OMX_Core.h:1096
OMX_HANDLETYPE handle
int flagIsGain[4]
#define VERSIONMAJOR
unsigned long OMX_U32
Definition: OMX_Types.h:145
#define OMX_GetConfig(hComponent,nConfigIndex,pComponentConfigStructure)
Definition: OMX_Core.h:861
#define DEB_LEV_SIMPLE_SEQ
OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_Init(void)
The OMX_Init standard function.
Definition: omxcore.c:94
OMX_BOOL bEOS[4]
#define DEBUG(n, fmt, args...)
struct OMX_VERSIONTYPE::@1 s
char * input_file[4]
pthread_mutex_t mutex
int flagSampleRate
unsigned int filesize[4]
#define DEFAULT_MESSAGES
appPrivateType * appPriv
void * OMX_PTR
Definition: OMX_Types.h:199
OMX_BOOL
Definition: OMX_Types.h:189
OMX_S32 nValue
Definition: OMX_Types.h:263
#define DEB_LEV_ERR
OMX_BUFFERHEADERTYPE * inBufferSink[2]
OMX_EVENTTYPE
Definition: OMX_Core.h:479
OMX_ERRORTYPE(* EventHandler)(OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_PTR pAppData, OMX_IN OMX_EVENTTYPE eEvent, OMX_IN OMX_U32 nData1, OMX_IN OMX_U32 nData2, OMX_IN OMX_PTR pEventData)
Definition: OMX_Core.h:530
void tsem_up(tsem_t *tsem)
Definition: tsemaphore.c:110
void setHeader(OMX_PTR header, OMX_U32 size)
Simply fills the first two fields in any OMX structure with the size and the version.
OMX_BUFFERHEADERTYPE * inBuffer[8]
void tsem_down(tsem_t *tsem)
Definition: tsemaphore.c:97
#define OMX_GetParameter(hComponent,nParamIndex,pComponentParameterStructure)
Definition: OMX_Core.h:786
OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_GetHandle(OMX_OUT OMX_HANDLETYPE *pHandle, OMX_IN OMX_STRING cComponentName, OMX_IN OMX_PTR pAppData, OMX_IN OMX_CALLBACKTYPE *pCallBacks)
void display_help()
OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_FreeHandle(OMX_IN OMX_HANDLETYPE hComponent)
OMX_U32 nInputPortIndex
Definition: OMX_Core.h:441
#define OMX_BUFFERFLAG_EOS
Definition: OMX_Core.h:299
#define OMX_SetParameter(hComponent,nParamIndex,pComponentParameterStructure)
Definition: OMX_Core.h:825
#define OMX_SendCommand(hComponent,Cmd,nParam,pCmdData)
Definition: OMX_Core.h:745
#define OMX_AllocateBuffer(hComponent,ppBuffer,nPortIndex,pAppPrivate,nSizeBytes)
Definition: OMX_Core.h:1028
#define OMX_FreeBuffer(hComponent,nPortIndex,pBuffer)
Definition: OMX_Core.h:1064
int flagChannel
FILE * outfile
OMX_ERRORTYPE err
#define VERSIONMINOR
OMX_ERRORTYPE audiomixerFillBufferDone(OMX_HANDLETYPE hComponent, OMX_PTR pAppData, OMX_BUFFERHEADERTYPE *pBuffer)
OMX_U8 nVersionMinor
Definition: OMX_Types.h:333
OMX_ERRORTYPE audiomixerEmptyBufferDone(OMX_HANDLETYPE hComponent, OMX_PTR pAppData, OMX_BUFFERHEADERTYPE *pBuffer)
OMX_U8 nVersionMajor
Definition: OMX_Types.h:332
#define BUFFER_IN_SIZE
#define DEB_LEV_FULL_SEQ
int flagIsOutputExpected
int tsem_init(tsem_t *tsem, unsigned int val)
Definition: tsemaphore.c:39
#define OMX_SetConfig(hComponent,nConfigIndex,pComponentConfigStructure)
Definition: OMX_Core.h:897
OMX_ERRORTYPE audiomixerEventHandler(OMX_HANDLETYPE hComponent, OMX_PTR pAppData, OMX_EVENTTYPE eEvent, OMX_U32 Data1, OMX_U32 Data2, OMX_PTR pEventData)
pthread_cond_t condition
#define VERSIONREVISION
int fd[4]
#define OMX_FillThisBuffer(hComponent,pBuffer)
Definition: OMX_Core.h:1126
int main(int argc, char **argv)
OMX_BUFFERHEADERTYPE * outBuffer[2]
#define BUFFER_COUNT_ACTUAL
int flagOutputReceived
OMX_CALLBACKTYPE callbacks
#define VERSIONSTEP
int flagInputReceived
OMX_ERRORTYPE
Definition: OMX_Core.h:126
OMX_U8 nRevision
Definition: OMX_Types.h:334
char * output_file

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