diff options
author | Tim Mayberry <mojofunk@gmail.com> | 2015-10-19 14:52:48 +1000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2015-10-22 11:51:03 -0400 |
commit | 689862cafb0333978268e21b08670d07255ccb99 (patch) | |
tree | 368e980e3cc1cccd360da468919ed24865e602a0 /libs/ardour/ardour/midi_patch_manager.h | |
parent | 3bd928591b62443631b373a2c8a2481aa3cff764 (diff) |
Decouple Session from MidiPatchManager and reduce parsing of midnam xml files
The MidiPatchManager only requires a reference to the session to get the path
to the Session midnam directory so change it so that the path is passed to
MidiPatchManager::add_search_path on Session construction and removed on
Session Destruction. This will also make it easier to test and reduce compile
times etc.
For the common case where the Session doesn't have a Session specific midnam
patch files directory(for instance a new session) it won't cause a refresh and
reparsing of all the midnam files. This saves about 2 seconds to load a Session
on my machine(fast machine with SSD), or about half the time spent in the
Session constructor for a new session.
There is still going to be that initial cost of parsing the midnam files when
the first session is created after starting Ardour. Options to remove that
would be to parse the files asynchronously and or use a faster xml
parser(eventually), neither of which seem worth doing at this stage.
This change will cause a performance regression for the uncommon case where a
Session with Session specific midnam files is unloaded and then another Session
with Session specific midnam files is loaded as it will cause the common midnam
files in midi_patch_path to be parsed twice(unload and load).
Diffstat (limited to 'libs/ardour/ardour/midi_patch_manager.h')
-rw-r--r-- | libs/ardour/ardour/midi_patch_manager.h | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/libs/ardour/ardour/midi_patch_manager.h b/libs/ardour/ardour/midi_patch_manager.h index 97f9060a5d..c7154c49a6 100644 --- a/libs/ardour/ardour/midi_patch_manager.h +++ b/libs/ardour/ardour/midi_patch_manager.h @@ -22,12 +22,11 @@ #define MIDI_PATCH_MANAGER_H_ #include "midi++/midnam_patch.h" + #include "pbd/signals.h" -#include "ardour/session_handle.h" +#include "pbd/search_path.h" -namespace ARDOUR { - class Session; -} +#include "ardour/libardour_visibility.h" namespace MIDI { @@ -35,7 +34,7 @@ namespace MIDI namespace Name { -class LIBARDOUR_API MidiPatchManager : public PBD::ScopedConnectionList, public ARDOUR::SessionHandlePtr +class LIBARDOUR_API MidiPatchManager { /// Singleton private: @@ -58,7 +57,9 @@ public: return *_manager; } - void set_session (ARDOUR::Session*); + void add_search_path (const PBD::Searchpath& search_path); + + void remove_search_path (const PBD::Searchpath& search_path); boost::shared_ptr<MIDINameDocument> document_by_model(std::string model_name) { return _documents[model_name]; } @@ -138,12 +139,13 @@ public: const DeviceNamesByMaker& devices_by_manufacturer() const { return _devices_by_manufacturer; } private: - void session_going_away(); void refresh(); - void add_session_patches(); bool add_midi_name_document(const std::string& file_path); +private: + PBD::Searchpath _search_path; + MidiNameDocuments _documents; MIDINameDocument::MasterDeviceNamesList _master_devices_by_model; DeviceNamesByMaker _devices_by_manufacturer; |