From 1976c49f835267d33ef88bd3fc20d18363e12c0b Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Wed, 8 Feb 2017 23:45:18 +0800 Subject: Add API version verification. This breaks compatibility with old versions of plugins. Add RIFF MIDI support to the SMF reader. Documentation. --- core/qmpmidiplay.hpp | 1 + core/qmpmidiread.cpp | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'core') diff --git a/core/qmpmidiplay.hpp b/core/qmpmidiplay.hpp index 8d78c4e..b911844 100644 --- a/core/qmpmidiplay.hpp +++ b/core/qmpmidiplay.hpp @@ -6,6 +6,7 @@ #include #include #include +#define QMP_MAIN #include "../include/qmpcorepublic.hpp" #include "qmpmidimappers.hpp" class CMidiPlayer; 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)) { -- cgit v1.2.3