aboutsummaryrefslogtreecommitdiff
path: root/core/qmpmidimapperrtmidi.cpp
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2017-06-02 21:12:27 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2017-06-02 21:12:27 +0800
commit37ba9dd1ce449bc2c2f422dd04225bc68bd89c59 (patch)
treeceecc9d6a28fc892a2a922771aefb4881b0e562a /core/qmpmidimapperrtmidi.cpp
parent844ddb2e0a6cdddf183ca3ecf08d1cedece27c71 (diff)
downloadQMidiPlayer-37ba9dd1ce449bc2c2f422dd04225bc68bd89c59.tar.xz
Some changes from earlier this year. Read ChangeLog for details.
Diffstat (limited to 'core/qmpmidimapperrtmidi.cpp')
-rw-r--r--core/qmpmidimapperrtmidi.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/core/qmpmidimapperrtmidi.cpp b/core/qmpmidimapperrtmidi.cpp
index 2d4fc26..263cada 100644
--- a/core/qmpmidimapperrtmidi.cpp
+++ b/core/qmpmidimapperrtmidi.cpp
@@ -6,20 +6,26 @@
RtMidiOut* qmpMidiMapperRtMidi::dummy=NULL;
qmpMidiMapperRtMidi::qmpMidiMapperRtMidi()
{
- dummy=new RtMidiOut();
+ try{dummy=new RtMidiOut();}
+ catch(RtMidiError &e)
+ {
+ printf("Failed to initialize the dummy device: %s\n",e.what());
+ dummy=NULL;
+ }
memset(ports,0,sizeof(ports));
}
qmpMidiMapperRtMidi::~qmpMidiMapperRtMidi()
{
- delete dummy;for(int i=0;i<16;++i)if(ports[i])delete ports[i];
+ delete dummy;dummy=NULL;
+ for(int i=0;i<16;++i)if(ports[i])delete ports[i];
}
int qmpMidiMapperRtMidi::enumDevices()
{
- return dummy->getPortCount();
+ return dummy?dummy->getPortCount():0;
}
std::string qmpMidiMapperRtMidi::deviceName(int id)
{
- return dummy->getPortName(id);
+ return dummy?dummy->getPortName(id):"";
}
int qmpMidiMapperRtMidi::deviceInit(int id)
{