aboutsummaryrefslogtreecommitdiff
path: root/core/qmpmidiread.cpp
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2017-02-08 23:45:18 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2017-02-08 23:45:18 +0800
commit1976c49f835267d33ef88bd3fc20d18363e12c0b (patch)
treee1eaca367a37238c1b2a5fc0f4ff7cb29a723a86 /core/qmpmidiread.cpp
parent1afedc4cc39c1dcbe49f8c99843a1732bf22fa28 (diff)
downloadQMidiPlayer-1976c49f835267d33ef88bd3fc20d18363e12c0b.tar.xz
Add API version verification. This breaks compatibility
with old versions of plugins. Add RIFF MIDI support to the SMF reader. Documentation.
Diffstat (limited to 'core/qmpmidiread.cpp')
-rw-r--r--core/qmpmidiread.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/core/qmpmidiread.cpp b/core/qmpmidiread.cpp
index 4ac2ac8..b36fffc 100644
--- a/core/qmpmidiread.cpp
+++ b/core/qmpmidiread.cpp
@@ -203,10 +203,21 @@ void CSMFReader::headerChunkReader()
int CSMFReader::chunkReader(int hdrXp)
{
char hdr[6];
- if(!fgets(hdr,5,f))error(1,"E: Unexpected EOF.");
+ fread(hdr,1,4,f);
+ if(feof(f))error(1,"E: Unexpected EOF.");
if(hdrXp)
+ {
+ if(!strncmp(hdr,"RIFF",4))
+ {
+ fseek(f,4,SEEK_CUR);
+ fread(hdr,1,4,f);
+ if(strncmp(hdr,"RMID",4)){error(1,"E: Wrong file type in RIFF container.");throw std::runtime_error("Wrong file type in RIFF container");}
+ fseek(f,8,SEEK_CUR);
+ fread(hdr,1,4,f);
+ }
if(strncmp(hdr,"MThd",4)){error(1,"E: Wrong MIDI header.");throw std::runtime_error("Wrong MIDI header");}
else return headerChunkReader(),0;
+ }
else
if(strncmp(hdr,"MTrk",4))
{