aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2017-06-21 16:28:03 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2017-06-21 16:28:03 +0800
commitfd3fc10798fb4c8d63f6f3e538018774741f2b15 (patch)
tree6c4eb78f9af49e11eb71454ee29cc022c80fc118
parent0c3fe540e925829022d9d8aa567c2dc2bd3d33d5 (diff)
downloadQMidiPlayer-fd3fc10798fb4c8d63f6f3e538018774741f2b15.tar.xz
Fixed a bunch of bugs and crashes in the RtMidi output device.
-rw-r--r--ChangeLog4
-rw-r--r--core/qmpmidioutrtmidi.cpp8
-rw-r--r--core/qmpmidiplay.cpp4
3 files changed, 11 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index c7108b1..c1f7dca 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,8 @@
2017-06-21 0.8.6 indev
+Fixed a bunch of bugs and crashes in the RtMidi
+output device.
+
+2017-06-21 0.8.6 indev
Code refactoring:
Complete rewrite of the MIDI mapper. The new
architecture allows implementation of custom MIDI
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;
diff --git a/core/qmpmidiplay.cpp b/core/qmpmidiplay.cpp
index cca77d0..e758457 100644
--- a/core/qmpmidiplay.cpp
+++ b/core/qmpmidiplay.cpp
@@ -256,7 +256,8 @@ CMidiPlayer::CMidiPlayer()
memset(eventReaderCBuserdata,0,sizeof(eventReaderCBuserdata));
memset(fileReadFinishCB,0,sizeof(fileReadFinishCB));
memset(fileReadFinishCBuserdata,0,sizeof(fileReadFinishCBuserdata));
- memset(mappedoutput,0xFF,sizeof(mappedoutput));
+ memset(mappedoutput,0,sizeof(mappedoutput));
+ mididev[0].refcnt=16;
memset(chstatus,0,sizeof(chstatus));
for(int i=0;i<16;++i)
chstatus[i][7]=100,chstatus[i][11]=127,
@@ -484,7 +485,6 @@ void CMidiPlayer::setChannelOutput(int ch,int outid)
{
SMidiDev& dold=mididev[origoutput];
dold.dev->onUnmapped(ch,--dold.refcnt);
-
}
}
uint8_t* CMidiPlayer::getChstates(){return chstate;}