Search for WAV chunk headers from each byte.

This commit is contained in:
Steven Smith 2016-03-02 17:05:11 -08:00
parent 08aea4bf61
commit c518996f62

View file

@ -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);
}
}
}