From cb19aa7c129d3635b5a918e5744c283eb5fb17f7 Mon Sep 17 00:00:00 2001 From: Martin Storsjo Date: Fri, 7 Feb 2014 14:51:06 +0200 Subject: Allow reading wav files with a 0 bytes RIFF chunk This is required in order to read streamed wav files produced by the libavformat wav muxer. --- wavreader.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'wavreader.c') diff --git a/wavreader.c b/wavreader.c index 69b3b57..194046b 100644 --- a/wavreader.c +++ b/wavreader.c @@ -83,6 +83,10 @@ void* wav_read_open(const char *filename) { if (feof(wr->wav)) break; length = read_int32(wr); + if (!length) { + wr->streamed = 1; + length = ~0; + } if (tag != TAG('R', 'I', 'F', 'F') || length < 4) { fseek(wr->wav, length, SEEK_CUR); continue; @@ -118,7 +122,7 @@ void* wav_read_open(const char *filename) { } else if (subtag == TAG('d', 'a', 't', 'a')) { data_pos = ftell(wr->wav); wr->data_length = sublength; - if (!wr->data_length) { + if (!wr->data_length || wr->streamed) { wr->streamed = 1; return wr; } -- cgit v1.2.3