diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/qmpmidioutrtmidi.cpp | 17 | ||||
-rw-r--r-- | core/qmpmidioutrtmidi.hpp | 7 |
2 files changed, 7 insertions, 17 deletions
diff --git a/core/qmpmidioutrtmidi.cpp b/core/qmpmidioutrtmidi.cpp index c37fadc..fba8e03 100644 --- a/core/qmpmidioutrtmidi.cpp +++ b/core/qmpmidioutrtmidi.cpp @@ -312,26 +312,19 @@ void qmpMidiOutRtMidi::setInitializerFile(const char* path) devinit=qmpDeviceInitializer::parse(path); } -RtMidiOut* qmpRtMidiManager::dummy=nullptr; -void qmpRtMidiManager::createDevices() +std::vector<std::pair<qmpMidiOutRtMidi*,std::string>> qmpRtMidiManager::devices; +std::vector<std::pair<qmpMidiOutRtMidi*,std::string>> qmpRtMidiManager::getDevices() { + if(devices.size())return devices; + RtMidiOut *dummy; try{dummy=new RtMidiOut();} catch(RtMidiError &e) { printf("Failed to initialize the dummy device: %s\n",e.what()); - dummy=nullptr;return; + return{}; } for(unsigned i=0;i<dummy->getPortCount();++i) devices.push_back(std::make_pair(new qmpMidiOutRtMidi(i),dummy->getPortName(i))); -} -void qmpRtMidiManager::deleteDevices() -{ - for(size_t i=0;i<devices.size();++i) - delete devices[i].first; - devices.clear(); delete dummy; -} -std::vector<std::pair<qmpMidiOutRtMidi*,std::string>> qmpRtMidiManager::getDevices() -{ return devices; } diff --git a/core/qmpmidioutrtmidi.hpp b/core/qmpmidioutrtmidi.hpp index 0a4fd60..ee9a7d2 100644 --- a/core/qmpmidioutrtmidi.hpp +++ b/core/qmpmidioutrtmidi.hpp @@ -48,11 +48,8 @@ public: class qmpRtMidiManager { private: - static RtMidiOut* dummy; - std::vector<std::pair<qmpMidiOutRtMidi*,std::string>> devices; + static std::vector<std::pair<qmpMidiOutRtMidi*,std::string>> devices; public: - void createDevices(); - void deleteDevices(); - std::vector<std::pair<qmpMidiOutRtMidi*,std::string>> getDevices(); + static std::vector<std::pair<qmpMidiOutRtMidi*,std::string>> getDevices(); }; #endif // QMPMIDIMAPPERS_H |