blurpped sound, wtf ?

This commit is contained in:
tth 2019-10-23 19:01:22 +02:00
parent 1bd06fb67b
commit ad54bac3f7
2 changed files with 25 additions and 7 deletions

View File

@ -17,7 +17,7 @@
extern int verbosity; 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); fprintf(stderr, ">>> %s ( '%s' %p %d )\n", __func__, fname, dev, loop);
#endif #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); sndf = sf_open(fname, SFM_READ, &sfinfo);
if (NULL==sndf) if (NULL==sndf)
{ {
@ -52,16 +58,12 @@ while ((lus = sf_read_short(sndf, buffer, T_BUFF_WAVES))) {
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "%s : %d bytes read\n", fname, lus); fprintf(stderr, "%s : %d bytes read\n", fname, lus);
#endif #endif
foo = ao_play(dev, buffer, T_BUFF_WAVES*2); ao_play(dev, buffer, lus*2);
#if DEBUG_LEVEL
fprintf(stderr, "%s : %d played\n", fname, foo);
#endif
} }
/* do some cleanup */ /* do some cleanup */
free(buffer);
sf_close(sndf); sf_close(sndf);
free(buffer);
return 0; return 0;
} }

View File

@ -14,14 +14,30 @@
int verbosity; int verbosity;
/* --------------------------------------------------------------------- */
void help(int k)
{
}
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int foo; int foo;
ao_device *device; 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); device = init_ao_output(44100);
fprintf(stderr, "AO init -> %p\n", device); fprintf(stderr, "AO init -> %p\n", device);