fix crash when copy'ing latent plugins
[ardour.git] / libs / ardour / globals.cc
index b2ad67d0538ccce16a2c25464274cae3e7df7057..974247aef57cb08d26daebf280485cee9bc1da8e 100644 (file)
@@ -80,7 +80,6 @@
 #include "pbd/fpu.h"
 #include "pbd/file_utils.h"
 #include "pbd/enumwriter.h"
-#include "pbd/basename.h"
 
 #include "midi++/port.h"
 #include "midi++/mmc.h"
 #include "ardour/event_type_map.h"
 #include "ardour/filesystem_paths.h"
 #include "ardour/midi_region.h"
+#include "ardour/midi_ui.h"
 #include "ardour/midiport_manager.h"
 #include "ardour/mix.h"
 #include "ardour/operations.h"
 #include "ardour/panner_manager.h"
 #include "ardour/plugin_manager.h"
+#include "ardour/presentation_info.h"
 #include "ardour/process_thread.h"
 #include "ardour/profile.h"
 #include "ardour/rc_configuration.h"
 #include "audiographer/routines.h"
 
 #if defined (__APPLE__)
-       #include <Carbon/Carbon.h> // For Gestalt
+#include <CoreFoundation/CoreFoundation.h>
 #endif
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 ARDOUR::RCConfiguration* ARDOUR::Config = 0;
 ARDOUR::RuntimeProfile* ARDOUR::Profile = 0;
@@ -205,12 +206,8 @@ setup_hardware_optimization (bool try_optimization)
                }
 
 #elif defined (__APPLE__) && defined (BUILD_VECLIB_OPTIMIZATIONS)
-               SInt32 sysVersion = 0;
 
-               if (noErr != Gestalt(gestaltSystemVersion, &sysVersion))
-                       sysVersion = 0;
-
-               if (sysVersion >= 0x00001040) { // Tiger at least
+               if (floor (kCFCoreFoundationVersionNumber) > kCFCoreFoundationVersionNumber10_4) { /* at least Tiger */
                        compute_peak           = veclib_compute_peak;
                        find_peaks             = veclib_find_peaks;
                        apply_gain_to_buffer   = veclib_apply_gain_to_buffer;
@@ -304,7 +301,7 @@ copy_configuration_files (string const & old_dir, string const & new_dir, int ol
                return -1;
        }
 
-       if (old_version == 3) {
+       if (old_version >= 3) {
 
                old_name = Glib::build_filename (old_dir, X_("recent"));
                new_name = Glib::build_filename (new_dir, X_("recent"));
@@ -442,6 +439,7 @@ ARDOUR::init (bool use_windows_vst, bool try_optimization, const char* localedir
        RouteGroup::make_property_quarks ();
         Playlist::make_property_quarks ();
         AudioPlaylist::make_property_quarks ();
+        PresentationInfo::make_property_quarks ();
 
        /* this is a useful ready to use PropertyChange that many
           things need to check. This avoids having to compose
@@ -513,6 +511,22 @@ ARDOUR::init (bool use_windows_vst, bool try_optimization, const char* localedir
 #endif
        (void) EventTypeMap::instance();
 
+       ControlProtocolManager::instance().discover_control_protocols ();
+
+       /* for each control protocol, check for a request buffer factory method
+          and if it exists, store it in the EventLoop list of such
+          methods. This allows the relevant threads to register themselves
+          with EventLoops so that signal emission can be RT-safe.
+       */
+
+       ControlProtocolManager::instance().register_request_buffer_factories ();
+       /* it would be nice if this could auto-register itself in the
+          constructor, since MidiControlUI is a singleton, but it can't be
+          created until after the engine is running. Therefore we have to
+          explicitly register it here.
+       */
+       EventLoop::register_request_buffer_factory (X_("midiUI"), MidiControlUI::request_factory);
+
         ProcessThread::init ();
        /* the + 4 is a bit of a handwave. i don't actually know
           how many more per-thread buffer sets we need above
@@ -553,8 +567,6 @@ ARDOUR::init (bool use_windows_vst, bool try_optimization, const char* localedir
 void
 ARDOUR::init_post_engine ()
 {
-       ControlProtocolManager::instance().discover_control_protocols ();
-
        XMLNode* node;
        if ((node = Config->control_protocol_state()) != 0) {
                ControlProtocolManager::instance().set_state (*node, Stateful::loading_state_version);
@@ -593,31 +605,6 @@ ARDOUR::cleanup ()
        return;
 }
 
-void
-ARDOUR::find_bindings_files (map<string,string>& files)
-{
-       vector<std::string> found;
-       Searchpath spath = ardour_config_search_path();
-
-       if (getenv ("ARDOUR_SAE")) {
-               find_files_matching_pattern (found, spath, "*SAE-*.bindings");
-       } else {
-               find_files_matching_pattern (found, spath, "*.bindings");
-       }
-
-       if (found.empty()) {
-               return;
-       }
-
-       for (vector<std::string>::iterator x = found.begin(); x != found.end(); ++x) {
-               std::string path(*x);
-               pair<string,string> namepath;
-               namepath.second = path;
-               namepath.first = PBD::basename_nosuffix (path);
-               files.insert (namepath);
-       }
-}
-
 bool
 ARDOUR::no_auto_connect()
 {