player/main.c
author Markus Bröker <mbroeker@largo.dyndns.tv>
Mon, 09 Sep 2013 15:54:09 +0200
changeset 4 be4de85337e5
parent 0 06dd3b8d90ad
permissions -rw-r--r--
Small changes committer: Markus Bröker <mbroeker@largo.homelinux.org>

/**
 *  $Id: main.c 53 2008-01-10 00:19:41Z mbroeker $
 * $URL: http://localhost/svn/c/VirtualReader/trunk/player/main.c $
 */

#include <audioplayer.h>
#include <stdlib.h>
#include <getopt.h>

#define TIMEOUT 186

void help (char *prgname)
{
    printf ("Usage: %s [-h] sndfile1,[sndfile2,...]\n", prgname);
    printf ("\t sndfile\t: a valid wave file\n");
    printf ("\t-h help \t: shows this screen\n");
}

int main (int argc, char **argv)
{
    int i;

    while ((i = getopt (argc, argv, "h")) > 0) {
        switch (i) {
        case 'h':
            help (argv[0]);
            exit (0);
            break;
        default:
            printf ("Unknown Option %c\n", i);
            help (argv[0]);
            exit (0);
        }
    }

    if (argc == optind) {
        help (argv[0]);
        exit (0);
    }

    audio_init ();

    for (i = optind; i < argc; i++) {
        audioplayer (argv[i], TIMEOUT);
        audioplayer_stop ();
    }

    audio_shutdown ();
    return 0;
}