From 293b7b88f2394b64afc4e3c27f3c0dce81c3cca7 Mon Sep 17 00:00:00 2001 From: ratchov Date: Fri, 13 Jan 2023 15:14:24 +0000 Subject: [PATCH] Use extended header format for .wav files. According to Microsoft docs, it is needed if bits > 16 or if there are more than 2 channels, which aucat supports and is the defaut. Fixes errors reported by audio/sox port when trying to play .wav files generated by aucat. Reported by John Rigg and others on misc@ --- usr.bin/aucat/afile.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/usr.bin/aucat/afile.c b/usr.bin/aucat/afile.c index f8aa2ca8fd1..46b434e6b56 100644 --- a/usr.bin/aucat/afile.c +++ b/usr.bin/aucat/afile.c @@ -432,12 +432,17 @@ afile_wav_writehdr(struct afile *f) le32_set(&hdr.riff.size, f->endpos - sizeof(hdr.riff)); memcpy(hdr.fmt_hdr.id, wav_id_fmt, 4); le32_set(&hdr.fmt_hdr.size, sizeof(hdr.fmt)); - le16_set(&hdr.fmt.fmt, 1); + le16_set(&hdr.fmt.fmt, WAV_FMT_EXT); le16_set(&hdr.fmt.nch, f->nch); le32_set(&hdr.fmt.rate, f->rate); le32_set(&hdr.fmt.byterate, f->rate * f->par.bps * f->nch); le16_set(&hdr.fmt.blkalign, f->par.bps * f->nch); le16_set(&hdr.fmt.bits, f->par.bits); + le16_set(&hdr.fmt.extsize, + WAV_FMT_EXT_SIZE - WAV_FMT_SIZE - sizeof(hdr.fmt.extsize)); + le16_set(&hdr.fmt.valbits, f->par.bits); + le16_set(&hdr.fmt.extfmt, 1); + memcpy(&hdr.fmt.guid, wav_guid, sizeof(hdr.fmt.guid)); memcpy(hdr.data_hdr.id, wav_id_data, 4); le32_set(&hdr.data_hdr.size, f->endpos - f->startpos); return afile_writehdr(f, &hdr, sizeof(struct wav_hdr)); -- 2.20.1