diff options
author | Chris Xiong <chirs241097@gmail.com> | 2017-06-21 16:28:03 +0800 |
---|---|---|
committer | Chris Xiong <chirs241097@gmail.com> | 2017-06-21 16:28:03 +0800 |
commit | fd3fc10798fb4c8d63f6f3e538018774741f2b15 (patch) | |
tree | 6c4eb78f9af49e11eb71454ee29cc022c80fc118 /core/qmpmidioutrtmidi.cpp | |
parent | 0c3fe540e925829022d9d8aa567c2dc2bd3d33d5 (diff) | |
download | QMidiPlayer-fd3fc10798fb4c8d63f6f3e538018774741f2b15.tar.xz |
Fixed a bunch of bugs and crashes in the RtMidi output device.
Diffstat (limited to 'core/qmpmidioutrtmidi.cpp')
-rw-r--r-- | core/qmpmidioutrtmidi.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/core/qmpmidioutrtmidi.cpp b/core/qmpmidioutrtmidi.cpp index 776eb6b..295e87b 100644 --- a/core/qmpmidioutrtmidi.cpp +++ b/core/qmpmidioutrtmidi.cpp @@ -37,6 +37,7 @@ void qmpMidiOutRtMidi::basicMessage(uint8_t type,uint8_t p1,uint8_t p2) std::vector<unsigned char>msg; msg.push_back(type); msg.push_back(p1); + if(((type&0xF0)!=0xC0)&&((type&0xF0)!=0xD0)) msg.push_back(p2); outport->sendMessage(&msg); } @@ -71,9 +72,10 @@ void qmpMidiOutRtMidi::reset(uint8_t ch) basicMessage(0xB0|ch,120,0); basicMessage(0xB0|ch,121,0); } -void qmpMidiOutRtMidi::onMapped(uint8_t,int refcnt) +void qmpMidiOutRtMidi::onMapped(uint8_t,int) { - if(!outport||outport->isPortOpen()||refcnt)return; + if(!outport)deviceInit(); + if(outport->isPortOpen())return; try { outport->openPort(portid); @@ -87,7 +89,7 @@ void qmpMidiOutRtMidi::onMapped(uint8_t,int refcnt) void qmpMidiOutRtMidi::onUnmapped(uint8_t ch,int refcnt) { panic(ch); - if(!refcnt)outport->closePort(); + if(!refcnt&&outport)outport->closePort(); } RtMidiOut* qmpRtMidiManager::dummy=NULL; |