From f82510410d6025a0577a593de6feeaf1c256c81c Mon Sep 17 00:00:00 2001 From: Martin Storsjo Date: Wed, 12 Mar 2014 15:23:13 +0200 Subject: [PATCH] Add support for waveformatex files This is used for multichannel wave files. --- wavreader.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/wavreader.c b/wavreader.c index 182b3eb..898eb9c 100644 --- a/wavreader.c +++ b/wavreader.c @@ -124,7 +124,17 @@ void* wav_read_open(const char *filename) { wr->byte_rate = read_int32(wr); wr->block_align = read_int16(wr); wr->bits_per_sample = read_int16(wr); - skip(wr->wav, sublength - 16); + if (wr->format == 0xfffe) { + if (sublength < 28) { + // Insufficient data for waveformatex + break; + } + skip(wr->wav, 8); + wr->format = read_int32(wr); + skip(wr->wav, sublength - 28); + } else { + skip(wr->wav, sublength - 16); + } } else if (subtag == TAG('d', 'a', 't', 'a')) { data_pos = ftell(wr->wav); wr->data_length = sublength;