diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2008-10-26 02:04:44 +0200 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2008-10-26 02:04:44 +0200 |
commit | f0fc782355d3cf567694e096828a9c6bf177837e (patch) | |
tree | 99c8765af81ca8b7d78e43cca5e46c2c35d96a41 /sbc/sbcdec.c | |
parent | 0242f1216747b69686ae11fdb1de6f6badfc1f3a (diff) |
Let the decoder write Sun/NeXT audio S16_BE files
Diffstat (limited to 'sbc/sbcdec.c')
-rw-r--r-- | sbc/sbcdec.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/sbc/sbcdec.c b/sbc/sbcdec.c index 5029d317..555ace54 100644 --- a/sbc/sbcdec.c +++ b/sbc/sbcdec.c @@ -37,6 +37,7 @@ #include <sys/soundcard.h> #include "sbc.h" +#include "formats.h" #define BUF_SIZE 8192 @@ -120,12 +121,28 @@ static void decode(char *filename, char *output, int tofile) } printf("%d Hz, %d channels\n", frequency, channels); - if (!tofile) { + if (tofile) { + struct au_header au_hdr; + + au_hdr.magic = AU_MAGIC; + au_hdr.hdr_size = BE_INT(24); + au_hdr.data_size = BE_INT(0); + au_hdr.encoding = BE_INT(AU_FMT_LIN16); + au_hdr.sample_rate = BE_INT(frequency); + au_hdr.channels = BE_INT(channels); + + written = write(ad, &au_hdr, sizeof(au_hdr)); + if (written < sizeof(au_hdr)) { + fprintf(stderr, "Failed to write header\n"); + goto close; + } + } else { if (ioctl(ad, SNDCTL_DSP_SETFMT, &format) < 0) { fprintf(stderr, "Can't set audio format on %s: %s\n", output, strerror(errno)); goto close; } + if (ioctl(ad, SNDCTL_DSP_CHANNELS, &channels) < 0) { fprintf(stderr, "Can't set number of channels on %s: %s\n", |