diff options
author | Antoine Soulier <asoulier@google.com> | 2023-11-08 15:26:33 -0800 |
---|---|---|
committer | Antoine Soulier <asoulier@google.com> | 2023-11-08 15:26:33 -0800 |
commit | 59cfa0527430d11533147b52d898c5806276827d (patch) | |
tree | b767b1f269e5de23016abba3686c322897cf30ef | |
parent | 7552605dd0cc8930c293b004c32a2659d2c0ac37 (diff) | |
download | liblc3-59cfa0527430d11533147b52d898c5806276827d.tar.gz |
tools: Add support of reading WAV file with metadata
-rw-r--r-- | tools/wave.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/tools/wave.c b/tools/wave.c index bdff777..3478e11 100644 --- a/tools/wave.c +++ b/tools/wave.c @@ -112,9 +112,11 @@ int wave_read_header(FILE *fp, int *bitdepth, int *samplesize, fseek(fp, sizeof(format) - (8 + format.size), SEEK_CUR); - if (fread(&data, sizeof(data), 1, fp) != 1 - || data.id != WAVE_DATA_ID) - return -1; + for ( ; fread(&data, sizeof(data), 1, fp) == 1 && data.id != WAVE_DATA_ID + ; fseek(fp, data.size, SEEK_CUR) ); + + if (feof(fp)) + return -1; *bitdepth = format.bitdepth; *samplesize = format.framesize / format.channels; |