Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/audio
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2011-04-16 14:51:20 +0000
committerStijn Buys <ingar@osirion.org>2011-04-16 14:51:20 +0000
commit1e68f51dc0a135872040d2455e5f4ae0fdd1a733 (patch)
treebb7e6c926dccae8201efb94fb1d396534dc88734 /src/audio
parenta10dd370e31bd3fbd370a4677d0d0b426421d153 (diff)
Skip WAV file metadata (original patch by Thorn)
Diffstat (limited to 'src/audio')
-rw-r--r--src/audio/wav.cc18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/audio/wav.cc b/src/audio/wav.cc
index b6ca710..0f86a65 100644
--- a/src/audio/wav.cc
+++ b/src/audio/wav.cc
@@ -37,14 +37,14 @@ PCM *Wav::load(std::string const & name)
return 0;
}
- unsigned char header[44];
+ unsigned char header[44];
memset(header, 0, sizeof(header));
if (!wav_file->read(header, 44)) {
con_warn << "Error reading " << filename << std::endl;
filesystem::close(wav_file);
return 0;
}
-
+
// header RIFF
if (strncmp((char *)header, "RIFF", 4)) {
con_warn << "Error reading " << filename << ": invalid RIFF header!" << std::endl;
@@ -89,6 +89,20 @@ PCM *Wav::load(std::string const & name)
//size_t byterate = header[28] + (header[29] << 8) + (header[30] << 16) + (header[31] << 24);
//size_t blockalign = header[32] + (header[33] << 8);
size_t bitspersample = header[34] + (header[35] << 8);
+
+ if (strncmp((char *)header + 36, "LIST", 4) == 0) {
+ // this wav file contains meta data (author, title, ..)
+ // byte 40 through 43 contains the metadata length instead of the datasize
+ size_t metasize = header[40] + (header[41] << 8) + (header[42] << 16) + (header[43] << 24);
+ wav_file->skip(metasize);
+
+ // the data header follows the meta data, we overwrite the original metadata header
+ if (!wav_file->read(header + 36, 8)) {
+ con_warn << "Error reading " << filename << ": unexpected end of file!" << std::endl;
+ filesystem::close(wav_file);
+ return 0;
+ }
+ }
if (strncmp((char *)header + 36, "data", 4) != 0) {
con_warn << "Error reading " << filename << ": invalid data header!" << std::endl;