player/main.c
changeset 0 06dd3b8d90ad
equal deleted inserted replaced
-1:000000000000 0:06dd3b8d90ad
       
     1 /**
       
     2  *  $Id: main.c 53 2008-01-10 00:19:41Z mbroeker $
       
     3  * $URL: http://localhost/svn/c/VirtualReader/trunk/player/main.c $
       
     4  */
       
     5 
       
     6 #include <audioplayer.h>
       
     7 #include <stdlib.h>
       
     8 #include <getopt.h>
       
     9 
       
    10 #define TIMEOUT 186
       
    11 
       
    12 void help (char *prgname)
       
    13 {
       
    14     printf ("Usage: %s [-h] sndfile1,[sndfile2,...]\n", prgname);
       
    15     printf ("\t sndfile\t: a valid wave file\n");
       
    16     printf ("\t-h help \t: shows this screen\n");
       
    17 }
       
    18 
       
    19 int main (int argc, char **argv)
       
    20 {
       
    21     int i;
       
    22 
       
    23     while ((i = getopt (argc, argv, "h")) > 0) {
       
    24         switch (i) {
       
    25         case 'h':
       
    26             help (argv[0]);
       
    27             exit (0);
       
    28             break;
       
    29         default:
       
    30             printf ("Unknown Option %c\n", i);
       
    31             help (argv[0]);
       
    32             exit (0);
       
    33         }
       
    34     }
       
    35 
       
    36     if (argc == optind) {
       
    37         help (argv[0]);
       
    38         exit (0);
       
    39     }
       
    40 
       
    41     audio_init ();
       
    42 
       
    43     for (i = optind; i < argc; i++) {
       
    44         audioplayer (argv[i], TIMEOUT);
       
    45         audioplayer_stop ();
       
    46     }
       
    47 
       
    48     audio_shutdown ();
       
    49     return 0;
       
    50 }