basics of threaded MIDNAM loading
This commit is contained in:
parent
ecdbd1df92
commit
63ba8da3e1
@ -146,6 +146,8 @@ public:
|
||||
|
||||
const DeviceNamesByMaker& devices_by_manufacturer() const { return _devices_by_manufacturer; }
|
||||
|
||||
void load_midnams_in_thread ();
|
||||
|
||||
private:
|
||||
bool load_midi_name_document(const std::string& file_path);
|
||||
bool add_midi_name_document(boost::shared_ptr<MIDINameDocument>);
|
||||
@ -161,6 +163,11 @@ private:
|
||||
MIDINameDocument::MasterDeviceNamesList _master_devices_by_model;
|
||||
DeviceNamesByMaker _devices_by_manufacturer;
|
||||
MasterDeviceNames::Models _all_models;
|
||||
|
||||
bool no_patch_changed_messages;
|
||||
pthread_t _midnam_load_thread;
|
||||
static void* _midnam_load (void *);
|
||||
void load_midnams ();
|
||||
};
|
||||
|
||||
} // namespace Name
|
||||
@ -168,3 +175,4 @@ private:
|
||||
} // namespace MIDI
|
||||
|
||||
#endif /* MIDI_PATCH_MANAGER_H_ */
|
||||
|
||||
|
@ -24,8 +24,10 @@
|
||||
|
||||
#include <glibmm/fileutils.h>
|
||||
|
||||
#include "pbd/file_utils.h"
|
||||
#include "pbd/error.h"
|
||||
#include "pbd/file_utils.h"
|
||||
#include "pbd/pthread_utils.h"
|
||||
#include "pbd/unwind.h"
|
||||
|
||||
#include "ardour/midi_patch_manager.h"
|
||||
|
||||
@ -42,8 +44,9 @@ using namespace PBD;
|
||||
MidiPatchManager* MidiPatchManager::_manager = 0;
|
||||
|
||||
MidiPatchManager::MidiPatchManager ()
|
||||
: no_patch_changed_messages (false)
|
||||
{
|
||||
add_search_path(midi_patch_search_path ());
|
||||
add_search_path (midi_patch_search_path ());
|
||||
}
|
||||
|
||||
void
|
||||
@ -64,8 +67,6 @@ MidiPatchManager::add_search_path (const Searchpath& search_path)
|
||||
continue;
|
||||
}
|
||||
|
||||
add_midnam_files_from_directory (*i);
|
||||
|
||||
_search_path.add_directory (*i);
|
||||
}
|
||||
}
|
||||
@ -112,10 +113,7 @@ MidiPatchManager::add_midnam_files_from_directory(const std::string& directory_p
|
||||
vector<std::string> result;
|
||||
find_files_matching_pattern (result, directory_path, "*.midnam");
|
||||
|
||||
info << string_compose(
|
||||
P_("Loading %1 MIDI patch from %2", "Loading %1 MIDI patches from %2", result.size()),
|
||||
result.size(), directory_path)
|
||||
<< endmsg;
|
||||
info << string_compose (P_("Loading %1 MIDI patch from %2", "Loading %1 MIDI patches from %2", result.size()), result.size(), directory_path) << endmsg;
|
||||
|
||||
for (vector<std::string>::const_iterator i = result.begin(); i != result.end(); ++i) {
|
||||
load_midi_name_document (*i);
|
||||
@ -212,9 +210,10 @@ MidiPatchManager::add_midi_name_document (boost::shared_ptr<MIDINameDocument> do
|
||||
assert(_master_devices_by_model.count(device->first) == 1);
|
||||
}
|
||||
|
||||
if (added) {
|
||||
if (added && !no_patch_changed_messages) {
|
||||
PatchesChanged(); /* EMIT SIGNAL */
|
||||
}
|
||||
|
||||
return added;
|
||||
}
|
||||
|
||||
@ -254,3 +253,30 @@ MidiPatchManager::remove_midi_name_document (const std::string& file_path, bool
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
|
||||
void*
|
||||
MidiPatchManager::_midnam_load (void* arg)
|
||||
{
|
||||
MidiPatchManager* mpm = (MidiPatchManager *) arg;
|
||||
mpm->load_midnams ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
MidiPatchManager::load_midnams ()
|
||||
{
|
||||
{
|
||||
PBD::Unwinder<bool> npc (no_patch_changed_messages, true);
|
||||
for (Searchpath::const_iterator i = _search_path.begin(); i != _search_path.end(); ++i) {
|
||||
add_midnam_files_from_directory (*i);
|
||||
}
|
||||
}
|
||||
|
||||
PatchesChanged (); /* EMIT SIGNAL */
|
||||
}
|
||||
|
||||
void
|
||||
MidiPatchManager::load_midnams_in_thread ()
|
||||
{
|
||||
pthread_create_and_store (X_("midnam"), &_midnam_load_thread, _midnam_load, this);
|
||||
}
|
||||
|
@ -397,9 +397,8 @@ Session::post_engine_init ()
|
||||
|
||||
ltc_tx_initialize();
|
||||
|
||||
BootMessage (_("Loading MIDNAM Patch files"));
|
||||
|
||||
MIDI::Name::MidiPatchManager::instance().add_search_path (session_directory().midi_patch_path() );
|
||||
MIDI::Name::MidiPatchManager::instance().load_midnams_in_thread ();
|
||||
/* initial program change will be delivered later; see ::config_changed() */
|
||||
|
||||
_state_of_the_state = Clean;
|
||||
|
Loading…
Reference in New Issue
Block a user