54 printf(
"Usage: omxvolcontroltest [-o outfile] [-g gain] filename\n");
56 printf(
" -o outfile: If this option is specified, the output stream is written to outfile\n");
57 printf(
" otherwise redirected to std output\n");
58 printf(
" -g: Gain of PCM data [0...100]\n");
59 printf(
" -h: Displays this help\n");
72 int main(
int argc,
char** argv) {
89 flagIsOutputExpected = 0;
90 flagOutputReceived = 0;
91 flagInputReceived = 0;
95 while (argn_dec<argc) {
96 if (*(argv[argn_dec]) ==
'-') {
97 if (flagIsOutputExpected) {
100 switch (*(argv[argn_dec]+1)) {
105 flagIsOutputExpected = 1;
115 gain = (int)atoi(argv[argn_dec]);
121 }
else if (flagIsOutputExpected) {
122 output_file = malloc(strlen(argv[argn_dec]) + 1);
123 strcpy(output_file,argv[argn_dec]);
124 flagIsOutputExpected = 0;
125 flagOutputReceived = 1;
127 input_file = malloc(strlen(argv[argn_dec]) + 1);
128 strcpy(input_file,argv[argn_dec]);
129 flagInputReceived = 1;
134 if (!flagInputReceived) {
139 if (flagOutputReceived) {
145 fd = open(input_file, O_RDONLY);
147 perror(
"Error opening input file\n");
151 if (flagOutputReceived) {
152 outfile = fopen(output_file,
"wb");
153 if(outfile == NULL) {
162 pthread_cond_init(&appPriv->
condition, NULL);
163 pthread_mutex_init(&appPriv->
mutex, NULL);
198 if((gain >= 0) && (gain <100)) {
242 inBuffer1 = inBuffer2 = outBuffer1 = outBuffer2 = NULL;
323 if (flagOutputReceived) {
324 if(fclose(outfile) != 0) {
350 switch ((
int)Data2) {
394 static int iBufferDropped=0;
401 if (data_read <= 0) {
404 if(iBufferDropped>=2) {
436 if(pBuffer != NULL) {
438 DEBUG(
DEB_LEV_ERR,
"Ouch! In %s: no data in the output buffer!\n", __func__);
441 if (flagOutputReceived) {
447 putchar(*(
char*)(pBuffer->
pBuffer + i));
452 DEBUG(
DEB_LEV_ERR,
"Ouch! In %s: had NULL buffer to output...\n", __func__);
465 static int getFileSize(
int fd) {
467 struct stat input_file_stat;
471 err = fstat(fd, &input_file_stat);
476 return input_file_stat.st_size;