20 #include "libardour-config.h"
30 #include <sys/types.h>
32 #ifndef PLATFORM_WINDOWS
33 #include <sys/resource.h>
40 #ifdef PLATFORM_WINDOWS
44 #ifdef WINDOWS_VST_SUPPORT
52 #ifdef AUDIOUNIT_SUPPORT
56 #if defined(__SSE__) || defined(USE_XMMINTRIN)
57 #include <xmmintrin.h>
64 #include <glibmm/fileutils.h>
65 #include <glibmm/miscutils.h>
81 #include "midi++/port.h"
82 #include "midi++/mmc.h"
111 #include "audiographer/routines.h"
113 #if defined (__APPLE__)
114 #include <Carbon/Carbon.h>
155 bool generic_mix_functions =
true;
157 if (try_optimization) {
161 #if defined (ARCH_X86) && defined (BUILD_SSE_OPTIMIZATIONS)
165 info <<
"Using SSE optimized routines" <<
endmsg;
174 generic_mix_functions =
false;
178 #elif defined (__APPLE__) && defined (BUILD_VECLIB_OPTIMIZATIONS)
179 SInt32 sysVersion = 0;
181 if (noErr != Gestalt(gestaltSystemVersion, &sysVersion))
184 if (sysVersion >= 0x00001040) {
191 generic_mix_functions =
false;
193 info <<
"Apple VecLib H/W specific optimizations in use" <<
endmsg;
202 if (generic_mix_functions) {
210 info <<
"No H/W specific optimizations in use" <<
endmsg;
213 AudioGrapher::Routines::override_compute_peak (
compute_peak);
220 #ifndef PLATFORM_WINDOWS
223 if (getrlimit (RLIMIT_NOFILE, &rl) == 0) {
227 rl.rlim_cur = min ((rlim_t) OPEN_MAX, rl.rlim_max);
229 rl.rlim_cur = rl.rlim_max;
232 if (setrlimit (RLIMIT_NOFILE, &rl) != 0) {
233 if (rl.rlim_cur == RLIM_INFINITY) {
234 error <<
_(
"Could not set system open files limit to \"unlimited\"") <<
endmsg;
239 if (rl.rlim_cur != RLIM_INFINITY) {
240 info <<
string_compose (
_(
"Your system is configured to limit %1 to only %2 open files"), PROGRAM_NAME, rl.rlim_cur) <<
endmsg;
257 if (g_mkdir_with_parents (new_dir.c_str(), 0755)) {
261 if (old_version == 3) {
263 old_name = Glib::build_filename (old_dir,
X_(
"recent"));
264 new_name = Glib::build_filename (new_dir,
X_(
"recent"));
268 old_name = Glib::build_filename (old_dir,
X_(
"sfdb"));
269 new_name = Glib::build_filename (new_dir,
X_(
"sfdb"));
281 string old_name = Glib::build_filename (old_dir,
X_(
"config"));
283 if (!Glib::file_test (old_name, Glib::FILE_TEST_EXISTS)) {
284 old_name = Glib::build_filename (old_dir,
X_(
"ardour.rc"));
287 new_name = Glib::build_filename (new_dir,
X_(
"config"));
293 old_name = Glib::build_filename (old_dir,
X_(
"templates"));
294 new_name = Glib::build_filename (new_dir,
X_(
"templates"));
298 old_name = Glib::build_filename (old_dir,
X_(
"route_templates"));
299 new_name = Glib::build_filename (new_dir,
X_(
"route_templates"));
305 old_name = Glib::build_filename (old_dir,
X_(
"presets"));
306 new_name = Glib::build_filename (new_dir,
X_(
"presets"));
312 old_name = Glib::build_filename (old_dir,
X_(
"plugin_statuses"));
313 new_name = Glib::build_filename (new_dir,
X_(
"plugin_statuses"));
322 vector<string> export_formats;
325 for (vector<string>::iterator i = export_formats.begin(); i != export_formats.end(); ++i) {
326 std::string from = *i;
327 std::string to = Glib::build_filename (new_name, Glib::path_get_basename (*i));
338 int current_version =
atoi (
X_(PROGRAM_VERSION));
340 if (current_version <= 1) {
344 int old_version = current_version - 1;
350 if (!Glib::file_test (current_config_dir, Glib::FILE_TEST_IS_DIR)) {
351 if (Glib::file_test (old_config_dir, Glib::FILE_TEST_IS_DIR)) {
361 int current_version =
atoi (
X_(PROGRAM_VERSION));
362 assert (current_version > 1);
363 int old_version = current_version - 1;
367 if (ui_handler (old_config_dir, current_config_dir, old_version)) {
434 Config->set_use_windows_vst (use_windows_vst);
436 Config->set_use_lxvst(
true);
442 #ifdef WINDOWS_VST_SUPPORT
443 if (
Config->get_use_windows_vst() && fst_init (0)) {
454 #ifdef AUDIOUNIT_SUPPORT
515 #ifdef WINDOWS_VST_SUPPORT
532 vector<std::string> found;
535 if (getenv (
"ARDOUR_SAE")) {
545 for (vector<std::string>::iterator x = found.begin(); x != found.end(); ++x) {
546 std::string path(*x);
547 pair<string,string> namepath;
548 namepath.second = path;
550 files.insert (namepath);
557 return getenv (
"ARDOUR_NO_AUTOCONNECT") != 0;
564 if (getenv (
"ARDOUR_RUNNING_UNDER_VALGRIND")) {
570 #if defined(ARCH_X86) && defined(USE_XMMINTRIN)
583 MXCSR = _mm_getcsr();
585 #ifdef DEBUG_DENORMAL_EXCEPTION
587 MXCSR &= ~_MM_MASK_DENORM;
590 switch (
Config->get_denormal_model()) {
592 MXCSR &= ~(_MM_FLUSH_ZERO_ON | 0x40);
597 MXCSR |= _MM_FLUSH_ZERO_ON;
602 MXCSR &= ~_MM_FLUSH_ZERO_ON;
611 MXCSR |= _MM_FLUSH_ZERO_ON | 0x40;
613 MXCSR |= _MM_FLUSH_ZERO_ON;
647 if (::read (fd, &c, 1) == 1 && c ==
'1') {
660 int fd = ::open (i18n_enabler.c_str(), O_WRONLY|O_CREAT|O_TRUNC, 0644);
674 (void) ::write (fd, &c, 1);
684 vector<SyncSource> ret;
687 if (backend && backend->
name() ==
"JACK") {
705 #include <mach/mach_time.h>
706 #define CLOCK_REALTIME 0
707 #define CLOCK_MONOTONIC 0
709 clock_gettime (
int ,
struct timespec *t)
711 static bool initialized =
false;
712 static mach_timebase_info_data_t timebase;
714 mach_timebase_info(&timebase);
718 time = mach_absolute_time();
719 double nseconds = ((double)time * (
double)timebase.numer)/((
double)timebase.denom);
720 double seconds = ((double)time * (
double)timebase.numer)/((
double)timebase.denom * 1e9);
722 t->tv_nsec = nseconds;
730 #ifdef PLATFORM_WINDOWS
732 LARGE_INTEGER freq, time;
734 if (QueryPerformanceFrequency(&freq))
735 if (QueryPerformanceCounter(&time))
736 ret = (
microseconds_t)((time.QuadPart * 1000000) / freq.QuadPart);
741 if (clock_gettime (CLOCK_MONOTONIC, &ts) != 0) {
static void init_event_pool()
virtual std::string name() const =0
int format_data_width(ARDOUR::SampleFormat)
int atoi(const string &s)
LIBARDOUR_API const char *const export_formats_dir_name
LIBARDOUR_API void find_bindings_files(std::map< std::string, std::string > &)
LIBARDOUR_API void setup_fpu()
LIBARDOUR_API void vstfx_exit()
int set_state(const XMLNode &, int version)
#define bind_textdomain_codeset(Domainname, Codeset)
LIBARDOUR_API PBD::Signal3< bool, std::string, std::string, int > CopyConfigurationFiles
bool has_flush_to_zero() const
static void make_property_quarks()
boost::shared_ptr< AudioBackend > current_backend() const
LIBARDOUR_API PBD::Signal1< void, int > PluginScanTimeout
LIBARDOUR_API compute_peak_t compute_peak
LIBARDOUR_API int handle_old_configuration_files(boost::function< bool(std::string const &, std::string const &, int)> ui_handler)
LIBPBD_API Transmitter error
static ControlProtocolManager & instance()
LIBARDOUR_API bool translations_are_enabled()
LIBARDOUR_API void default_mix_buffers_with_gain(ARDOUR::Sample *dst, const ARDOUR::Sample *src, ARDOUR::pframes_t nframes, float gain)
LIBARDOUR_API std::string translation_enable_path()
std::ostream & endmsg(std::ostream &ostr)
XMLNode * control_protocol_state()
static URIMap & instance()
static const bool translate_by_default
LIBARDOUR_API PBD::PropertyDescriptor< framepos_t > start
static AudioEngine * instance()
static bool have_old_configuration_files
LIBARDOUR_API PBD::Signal0< void > GUIIdle
static int load_cached_info()
void setup_hardware_optimization(bool try_optimization)
void(* mix_buffers_no_gain_t)(ARDOUR::Sample *, const ARDOUR::Sample *, pframes_t)
LIBARDOUR_API microseconds_t get_microseconds()
void(* find_peaks_t)(const ARDOUR::Sample *, pframes_t, float *, float *)
LIBARDOUR_API void default_find_peaks(const ARDOUR::Sample *buf, ARDOUR::pframes_t nsamples, float *min, float *max)
void copy_recurse(const std::string &from_path, const std::string &to_dir)
LIBARDOUR_API mix_buffers_with_gain_t mix_buffers_with_gain
LIBARDOUR_API std::string user_config_directory(int version=-1)
LIBARDOUR_API bool no_auto_connect()
bool copy_file(const std::string &from_path, const std::string &to_path)
static int current_state_version
void find_files_matching_pattern(vector< string > &result, const Searchpath &paths, const Glib::PatternSpec &pattern)
LIBARDOUR_API void init_post_engine()
LIBARDOUR_API RCConfiguration * Config
static const char * localedir
static AudioEngine * create()
LIBARDOUR_API void check_for_old_configuration_files()
static void make_property_quarks()
LIBARDOUR_API int vstfx_init(void *)
void(* apply_gain_to_buffer_t)(ARDOUR::Sample *, pframes_t, float)
static void make_property_quarks()
void x86_sse_find_peaks(const ARDOUR::Sample *buf, ARDOUR::pframes_t nframes, float *min, float *max)
static void make_property_quarks()
static EventTypeMap & instance()
uint32_t hardware_concurrency()
static int loading_state_version
LIBARDOUR_API PBD::Searchpath ardour_config_search_path()
LIBPBD_API Transmitter info
LIBARDOUR_API RuntimeProfile * Profile
LIBARDOUR_API void default_mix_buffers_no_gain(ARDOUR::Sample *dst, const ARDOUR::Sample *src, ARDOUR::pframes_t nframes)
#define bindtextdomain(Domainname, Dirname)
LIBARDOUR_API void default_apply_gain_to_buffer(ARDOUR::Sample *buf, ARDOUR::pframes_t nframes, float gain)
void discover_control_protocols()
LIBARDOUR_API float default_compute_peak(const ARDOUR::Sample *buf, ARDOUR::pframes_t nsamples, float current)
LIBPBD_API Glib::ustring basename_nosuffix(Glib::ustring)
LIBARDOUR_API std::vector< SyncSource > get_available_sync_options()
LIBARDOUR_API find_peaks_t find_peaks
float(* compute_peak_t)(const ARDOUR::Sample *, pframes_t, float)
static PluginManager & instance()
LIBARDOUR_API void cleanup()
bool libardour_initialized
LIBARDOUR_API bool set_translations_enabled(bool)
LIBARDOUR_API PBD::PropertyDescriptor< framepos_t > position
LIBARDOUR_API PBD::Signal1< void, std::string > BootMessage
LIBARDOUR_API mix_buffers_no_gain_t mix_buffers_no_gain
LIBARDOUR_API AudioLibrary * Library
static int copy_configuration_files(string const &old_dir, string const &new_dir, int old_version)
LIBARDOUR_API PBD::Signal3< void, std::string, std::string, bool > PluginScanMessage
LIBPBD_API void cleanup()
static PannerManager & instance()
LIBARDOUR_API apply_gain_to_buffer_t apply_gain_to_buffer
static void make_property_quarks()
LIBARDOUR_API void make_operations_quarks()
static void init(uint32_t)
static void make_property_quarks()
LIBARDOUR_API bool init(bool with_vst, bool try_optimization, const char *localedir)
bool has_denormals_are_zero() const
static void lotsa_files_please()
LIBARDOUR_API PBD::PropertyChange bounds_change
std::string string_compose(const std::string &fmt, const T1 &o1)
LIBARDOUR_API PBD::PropertyDescriptor< framecnt_t > length
void(* mix_buffers_with_gain_t)(ARDOUR::Sample *, const ARDOUR::Sample *, pframes_t, float)
void refresh(bool cache_only=false)