aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/qmpmidiplay.hpp1
-rw-r--r--core/qmpmidiread.cpp13
2 files changed, 13 insertions, 1 deletions
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 <utility>
#include <vector>
#include <fluidsynth.h>
+#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))
{