diff options
author | Chris Xiong <chirs241097@gmail.com> | 2017-10-18 11:40:51 +0800 |
---|---|---|
committer | Chris Xiong <chirs241097@gmail.com> | 2017-10-18 11:40:51 +0800 |
commit | d985112164bd2bfeca0c895abb523d45f0e065bb (patch) | |
tree | 3a44ae92001c2a8cac89eb46fe74248249d6e0ea /core | |
parent | 48dd5f9fb11f0a2e69291271d9140ebcec640117 (diff) | |
download | QMidiPlayer-d985112164bd2bfeca0c895abb523d45f0e065bb.tar.xz |
API changes and crash fixes.
Details in the changelog.
Diffstat (limited to 'core')
-rw-r--r-- | core/qmpmidioutrtmidi.cpp | 2 | ||||
-rw-r--r-- | core/qmpmidiplay.cpp | 10 | ||||
-rw-r--r-- | core/qmpmidiplay.hpp | 24 | ||||
-rw-r--r-- | core/qmpmidiread.cpp | 4 |
4 files changed, 20 insertions, 20 deletions
diff --git a/core/qmpmidioutrtmidi.cpp b/core/qmpmidioutrtmidi.cpp index 7f75fda..1b897df 100644 --- a/core/qmpmidioutrtmidi.cpp +++ b/core/qmpmidioutrtmidi.cpp @@ -99,7 +99,7 @@ void qmpRtMidiManager::createDevices() catch(RtMidiError &e) { printf("Failed to initialize the dummy device: %s\n",e.what()); - dummy=NULL; + dummy=NULL;return; } for(unsigned i=0;i<dummy->getPortCount();++i) devices.push_back(std::make_pair(new qmpMidiOutRtMidi(i),dummy->getPortName(i))); diff --git a/core/qmpmidiplay.cpp b/core/qmpmidiplay.cpp index 55b3959..15e1331 100644 --- a/core/qmpmidiplay.cpp +++ b/core/qmpmidiplay.cpp @@ -276,7 +276,7 @@ bool CMidiPlayer::playerLoadFile(const char* fn) { notes=0;if(midiFile)delete midiFile; midiFile=midiReaders->readFile(fn); - if(!midiFile->valid)return false; + if(!midiFile||!midiFile->valid)return false; divs=midiFile->divs;maxtk=ecnt=0; for(CMidiTrack& i:midiFile->tracks) { @@ -481,7 +481,7 @@ void CMidiPlayer::setChannelOutput(int ch,int outid) } } uint8_t* CMidiPlayer::getChstates(){return chstate;} -int CMidiPlayer::setEventHandlerCB(IMidiCallBack *cb,void *userdata) +int CMidiPlayer::setEventHandlerCB(ICallBack *cb,void *userdata) { for(int i=0;i<16;++i) { @@ -496,7 +496,7 @@ int CMidiPlayer::setEventHandlerCB(IMidiCallBack *cb,void *userdata) } void CMidiPlayer::unsetEventHandlerCB(int id) {eventHandlerCB[id]=NULL;eventHandlerCBuserdata[id]=NULL;} -int CMidiPlayer::setEventReaderCB(IMidiCallBack *cb,void *userdata) +int CMidiPlayer::setEventReaderCB(ICallBack *cb,void *userdata) { for(int i=0;i<16;++i) { @@ -511,7 +511,7 @@ int CMidiPlayer::setEventReaderCB(IMidiCallBack *cb,void *userdata) } void CMidiPlayer::unsetEventReaderCB(int id) {eventReaderCB[id]=NULL;eventReaderCBuserdata[id]=NULL;} -int CMidiPlayer::setFileReadFinishedCB(IMidiCallBack *cb,void *userdata) +int CMidiPlayer::setFileReadFinishedCB(ICallBack *cb,void *userdata) { for(int i=0;i<16;++i) { @@ -526,7 +526,7 @@ int CMidiPlayer::setFileReadFinishedCB(IMidiCallBack *cb,void *userdata) } void CMidiPlayer::unsetFileReadFinishedCB(int id) {fileReadFinishCB[id]=NULL;fileReadFinishCBuserdata[id]=NULL;} -void CMidiPlayer::registerReader(IMidiFileReader *reader,std::string name) +void CMidiPlayer::registerReader(qmpFileReader *reader,std::string name) {midiReaders->registerReader(reader,name);} void CMidiPlayer::unregisterReader(std::string name) {midiReaders->unregisterReader(name);} diff --git a/core/qmpmidiplay.hpp b/core/qmpmidiplay.hpp index c935084..99e0d07 100644 --- a/core/qmpmidiplay.hpp +++ b/core/qmpmidiplay.hpp @@ -10,7 +10,7 @@ #include "qmpmidioutrtmidi.hpp" #include "qmpmidioutfluid.hpp" class CMidiPlayer; -class CSMFReader:public IMidiFileReader +class CSMFReader:public qmpFileReader { private: CMidiFile* ret; @@ -37,15 +37,15 @@ class CSMFReader:public IMidiFileReader }; class CMidiFileReaderCollection{ private: - std::vector<std::pair<IMidiFileReader*,std::string>> readers; - IMidiFileReader* currentReader; + std::vector<std::pair<qmpFileReader*,std::string>> readers; + qmpFileReader* currentReader; public: CMidiFileReaderCollection(); ~CMidiFileReaderCollection(); - void registerReader(IMidiFileReader* reader,std::string name); + void registerReader(qmpFileReader* reader,std::string name); void unregisterReader(std::string name); CMidiFile* readFile(const char* fn); - IMidiFileReader* getCurrentReader(); + qmpFileReader* getCurrentReader(); }; class CMidiPlayer { @@ -77,9 +77,9 @@ class CMidiPlayer }; std::vector<SMidiDev> mididev; int mappedoutput[16]; - IMidiCallBack* eventHandlerCB[16]; - IMidiCallBack* eventReaderCB[16]; - IMidiCallBack* fileReadFinishCB[16]; + ICallBack* eventHandlerCB[16]; + ICallBack* eventReaderCB[16]; + ICallBack* fileReadFinishCB[16]; void* eventHandlerCBuserdata[16]; void* eventReaderCBuserdata[16]; void* fileReadFinishCBuserdata[16]; @@ -145,13 +145,13 @@ class CMidiPlayer int getChannelOutput(int ch); void setChannelOutput(int ch,int outid); uint8_t* getChstates(); - int setEventHandlerCB(IMidiCallBack *cb,void *userdata); + int setEventHandlerCB(ICallBack *cb,void *userdata); void unsetEventHandlerCB(int id); - int setEventReaderCB(IMidiCallBack *cb,void *userdata); + int setEventReaderCB(ICallBack *cb,void *userdata); void unsetEventReaderCB(int id); - int setFileReadFinishedCB(IMidiCallBack *cb,void *userdata); + int setFileReadFinishedCB(ICallBack *cb,void *userdata); void unsetFileReadFinishedCB(int id); - void registerReader(IMidiFileReader* reader,std::string name); + void registerReader(qmpFileReader* reader,std::string name); void unregisterReader(std::string name); void callEventReaderCB(SEventCallBackData d); diff --git a/core/qmpmidiread.cpp b/core/qmpmidiread.cpp index 6089ac5..42cb88a 100644 --- a/core/qmpmidiread.cpp +++ b/core/qmpmidiread.cpp @@ -250,7 +250,7 @@ CMidiFileReaderCollection::~CMidiFileReaderCollection() { delete readers[0].first; } -void CMidiFileReaderCollection::registerReader(IMidiFileReader* reader,std::string name) +void CMidiFileReaderCollection::registerReader(qmpFileReader* reader,std::string name) { for(unsigned i=0;i<readers.size();++i) if(readers[i].second==name)return; @@ -279,5 +279,5 @@ CMidiFile* CMidiFileReaderCollection::readFile(const char* fn) currentReader=NULL; return file; } -IMidiFileReader* CMidiFileReaderCollection::getCurrentReader() +qmpFileReader* CMidiFileReaderCollection::getCurrentReader() {return currentReader;} |