Search for WAV chunk headers from each byte.
This commit is contained in:
parent
08aea4bf61
commit
c518996f62
1 changed files with 5 additions and 4 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue