/* * NcLooper fonctions audio output */ #include #include #include #include #include #include #include #include "ao_output.h" /* --------------------------------------------------------------------- */ extern int verbosity; #define T_BUFF_WAVES 16384 /* --------------------------------------------------------------------- */ int blast_this_file(char *fname, ao_device *dev, int loop) { SNDFILE *sndf; SF_INFO sfinfo; int foo, lus; short *buffer; #if DEBUG_LEVEL fprintf(stderr, ">>> %s ( '%s' %p %d )\n", __func__, fname, dev, loop); #endif sndf = sf_open(fname, SFM_READ, &sfinfo); if (NULL==sndf) { perror("sf_open"); abort(); } buffer = calloc(T_BUFF_WAVES, sizeof(short)*2); #if DEBUG_LEVEL fprintf(stderr, "samplerate : %d\n", sfinfo.samplerate); fprintf(stderr, "frames : %ld\n", sfinfo.frames); fprintf(stderr, "seekable : %d\n", sfinfo.seekable); #endif 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 } /* do some cleanup */ free(buffer); sf_close(sndf); return 0; } /* --------------------------------------------------------------------- */