summaryrefslogtreecommitdiff
path: root/libs/ardour/midi_patch_manager.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2019-12-23 10:26:05 -0700
committerPaul Davis <paul@linuxaudiosystems.com>2019-12-23 10:27:00 -0700
commit61aeb05f2ee244a2af2c5656fe73391f1209b138 (patch)
treee5e4431b4b2c347ddfc85f3b6acdce3e05666ad5 /libs/ardour/midi_patch_manager.cc
parent63ba8da3e12ab6a1a1a0118fbffceb3881b26a85 (diff)
add a mechanism to use existing MIDNAM info and connect to PatchesChanged in future, atomically
The atomically is with respect to the initial thread-based MIDNAM loading
Diffstat (limited to 'libs/ardour/midi_patch_manager.cc')
-rw-r--r--libs/ardour/midi_patch_manager.cc29
1 files changed, 28 insertions, 1 deletions
diff --git a/libs/ardour/midi_patch_manager.cc b/libs/ardour/midi_patch_manager.cc
index c0bdd28419..9a5f45029b 100644
--- a/libs/ardour/midi_patch_manager.cc
+++ b/libs/ardour/midi_patch_manager.cc
@@ -265,13 +265,20 @@ MidiPatchManager::_midnam_load (void* arg)
void
MidiPatchManager::load_midnams ()
{
+ /* really there's only going to be one x-thread request/signal before
+ this thread exits but we'll say 8 just to be sure.
+ */
+
+ PBD::notify_event_loops_about_thread_creation (pthread_self(), "midi-patch-manager", 8);
+
{
+ Glib::Threads::Mutex::Lock lm (_lock);
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 */
}
@@ -280,3 +287,23 @@ MidiPatchManager::load_midnams_in_thread ()
{
pthread_create_and_store (X_("midnam"), &_midnam_load_thread, _midnam_load, this);
}
+
+void
+MidiPatchManager::maybe_use (PBD::ScopedConnectionList& cl,
+ PBD::EventLoop::InvalidationRecord* ir,
+ const boost::function<void()> & midnam_info_method,
+ PBD::EventLoop* event_loop)
+{
+ {
+ Glib::Threads::Mutex::Lock lm (_lock);
+
+ if (!_documents.empty()) {
+ /* already have documents loaded, so call closure to use them */
+ midnam_info_method ();
+ }
+
+ /* if/when they ever change, call the closure (maybe multiple times) */
+
+ PatchesChanged.connect (cl, ir, midnam_info_method, event_loop);
+ }
+}