Merge branch 'cairocanvas'
[ardour.git] / libs / ardour / globals.cc
index 2cd886b03ea9f95858f56da1eef6de3915b90b0b..48abda8cfcb8367a18bdfa6962823aff2cad581b 100644 (file)
 #include "libardour-config.h"
 #endif
 
+#ifdef interface
+#undef interface
+#endif
+
 #include <cstdio> // Needed so that libraptor (included in lrdf) won't complain
 #include <cstdlib>
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <sys/time.h>
+#ifndef PLATFORM_WINDOWS
 #include <sys/resource.h>
+#endif
 #include <unistd.h>
 #include <fcntl.h>
 #include <errno.h>
@@ -43,7 +49,7 @@
 #include "ardour/audio_unit.h"
 #endif
 
-#ifdef __SSE__
+#if defined(__SSE__) || defined(USE_XMMINTRIN)
 #include <xmmintrin.h>
 #endif
 
@@ -54,7 +60,9 @@
 #include <glibmm/fileutils.h>
 #include <glibmm/miscutils.h>
 
+#ifdef HAVE_LRDF
 #include <lrdf.h>
+#endif
 
 #include "pbd/cpus.h"
 #include "pbd/error.h"
@@ -81,6 +89,7 @@
 #include "ardour/midi_region.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/process_thread.h"
@@ -117,6 +126,8 @@ mix_buffers_with_gain_t ARDOUR::mix_buffers_with_gain = 0;
 mix_buffers_no_gain_t   ARDOUR::mix_buffers_no_gain = 0;
 
 PBD::Signal1<void,std::string> ARDOUR::BootMessage;
+PBD::Signal3<void,std::string,std::string,bool> ARDOUR::PluginScanMessage;
+PBD::Signal1<void,int> ARDOUR::PluginScanTimeout;
 PBD::Signal0<void> ARDOUR::GUIIdle;
 
 namespace ARDOUR {
@@ -196,6 +207,7 @@ setup_hardware_optimization (bool try_optimization)
 static void
 lotsa_files_please ()
 {
+#ifndef PLATFORM_WINDOWS
        struct rlimit rl;
 
        if (getrlimit (RLIMIT_NOFILE, &rl) == 0) {
@@ -216,6 +228,7 @@ lotsa_files_please ()
        } else {
                error << string_compose (_("Could not get system open files limit (%1)"), strerror (errno)) << endmsg;
        }
+#endif
 }
 
 bool
@@ -229,10 +242,12 @@ ARDOUR::init (bool use_windows_vst, bool try_optimization, const char* localedir
 
 #ifdef ENABLE_NLS
        (void) bindtextdomain(PACKAGE, localedir);
+       (void) bind_textdomain_codeset (PACKAGE, "UTF-8");
 #endif
 
        SessionEvent::init_event_pool ();
 
+       Operations::make_operations_quarks ();
        SessionObject::make_property_quarks ();
        Region::make_property_quarks ();
        MidiRegion::make_property_quarks ();
@@ -262,7 +277,9 @@ ARDOUR::init (bool use_windows_vst, bool try_optimization, const char* localedir
        // allow ardour the absolute maximum number of open files
        lotsa_files_please ();
 
+#ifdef HAVE_LRDF
        lrdf_init();
+#endif
        Library = new AudioLibrary;
 
        BootMessage (_("Loading configuration"));
@@ -351,7 +368,7 @@ ARDOUR::init_post_engine ()
 
        /* find plugins */
 
-       ARDOUR::PluginManager::instance().refresh ();
+       ARDOUR::PluginManager::instance().refresh (!Config->get_discover_vst_on_start());
 }
 
 void
@@ -364,7 +381,9 @@ ARDOUR::cleanup ()
        ARDOUR::AudioEngine::destroy ();
 
        delete Library;
+#ifdef HAVE_LRDF
        lrdf_cleanup ();
+#endif
        delete &ControlProtocolManager::instance();
 #ifdef WINDOWS_VST_SUPPORT
        fst_exit ();
@@ -373,6 +392,8 @@ ARDOUR::cleanup ()
 #ifdef LXVST_SUPPORT
        vstfx_exit();
 #endif
+       delete &PluginManager::instance();
+       delete Config;
        PBD::cleanup ();
 
        return;
@@ -382,14 +403,12 @@ void
 ARDOUR::find_bindings_files (map<string,string>& files)
 {
        vector<std::string> found;
-       SearchPath spath = ardour_config_search_path();
+       Searchpath spath = ardour_config_search_path();
 
        if (getenv ("ARDOUR_SAE")) {
-               Glib::PatternSpec pattern("*SAE-*.bindings");
-               find_matching_files_in_search_path (spath, pattern, found);
+               find_files_matching_pattern (found, spath, "*SAE-*.bindings");
        } else {
-               Glib::PatternSpec pattern("*.bindings");
-               find_matching_files_in_search_path (spath, pattern, found);
+               find_files_matching_pattern (found, spath, "*.bindings");
        }
 
        if (found.empty()) {
@@ -581,10 +600,21 @@ clock_gettime (int /*clk_id*/, struct timespec *t)
 microseconds_t
 ARDOUR::get_microseconds ()
 {
+#ifdef PLATFORM_WINDOWS
+       microseconds_t ret = 0;
+       LARGE_INTEGER freq, time;
+
+       if (QueryPerformanceFrequency(&freq))
+               if (QueryPerformanceCounter(&time))
+                       ret = (microseconds_t)((time.QuadPart * 1000000) / freq.QuadPart);
+
+       return ret;
+#else
        struct timespec ts;
        if (clock_gettime (CLOCK_MONOTONIC, &ts) != 0) {
                /* EEEK! */
                return 0;
        }
        return (microseconds_t) ts.tv_sec * 1000000 + (ts.tv_nsec/1000);
+#endif
 }