diff --git a/audio/playfile.c b/audio/playfile.c index 2ae97d8..cc8641a 100644 --- a/audio/playfile.c +++ b/audio/playfile.c @@ -17,7 +17,7 @@ extern int verbosity; -#define T_BUFF_WAVES 16384 +#define T_BUFF_WAVES 16384*2 /* --------------------------------------------------------------------- */ @@ -32,6 +32,12 @@ short *buffer; fprintf(stderr, ">>> %s ( '%s' %p %d )\n", __func__, fname, dev, loop); #endif +buffer = calloc(T_BUFF_WAVES, sizeof(short)*2); +if (NULL == buffer) { + fprintf(stderr, "ALLOC FAIL, ABEND in %s\n", __func__); + abort(); + } + sndf = sf_open(fname, SFM_READ, &sfinfo); if (NULL==sndf) { @@ -52,16 +58,12 @@ while ((lus = sf_read_short(sndf, buffer, T_BUFF_WAVES))) { #if DEBUG_LEVEL fprintf(stderr, "%s : %d bytes read\n", fname, lus); #endif - foo = ao_play(dev, buffer, T_BUFF_WAVES*2); -#if DEBUG_LEVEL - fprintf(stderr, "%s : %d played\n", fname, foo); -#endif - + ao_play(dev, buffer, lus*2); } /* do some cleanup */ -free(buffer); sf_close(sndf); +free(buffer); return 0; } diff --git a/audio/t.c b/audio/t.c index fa2822d..619c11c 100644 --- a/audio/t.c +++ b/audio/t.c @@ -14,14 +14,30 @@ int verbosity; +/* --------------------------------------------------------------------- */ +void help(int k) +{ +} /* --------------------------------------------------------------------- */ int main(int argc, char *argv[]) { int foo; ao_device *device; +int opt; +while ((opt = getopt(argc, argv, "hv")) != -1) { + switch(opt) { + case 'h': help(0); break; + case 'v': verbosity++; break; + } + } + +#if DEBUG_LEVEL +fprintf(stderr, "argc = %d, optind = %d\n", argc, optind); +#endif + device = init_ao_output(44100); fprintf(stderr, "AO init -> %p\n", device);