From c518996f6211e7f360fac1b4c57bcbbf9fd57386 Mon Sep 17 00:00:00 2001 From: Steven Smith Date: Wed, 2 Mar 2016 17:05:11 -0800 Subject: [PATCH] Search for WAV chunk headers from each byte. --- source/pc/wav.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/source/pc/wav.cpp b/source/pc/wav.cpp index 6ab7861..1d1be60 100644 --- a/source/pc/wav.cpp +++ b/source/pc/wav.cpp @@ -6,9 +6,10 @@ bool wav_find_chunk(FILE* fd, const char* magic) { char curr[5] = {0}; - while(strcmp(curr, magic) != 0) { - u32 read = (u32) fread(curr, 1, 4, fd); - if(read == 0) { + for(long pos = ftell(fd); strcmp(curr, magic) != 0; pos++) { + fseek(fd, pos, SEEK_SET); + size_t read = fread(curr, 1, 4, fd); + if(read <= 0) { return false; } } @@ -62,4 +63,4 @@ void wav_free(WAV* wav) { free(wav->data.data); free(wav); } -} \ No newline at end of file +}