+void
+setup_hardware_optimization (bool try_optimization)
+{
+ bool generic_mix_functions = true;
+
+ if (try_optimization) {
+
+ FPU fpu;
+
+#if defined (ARCH_X86) && defined (BUILD_SSE_OPTIMIZATIONS)
+
+ if (fpu.has_sse()) {
+
+ info << "Using SSE optimized routines" << endmsg;
+
+ // SSE SET
+ compute_peak = x86_sse_compute_peak;
+ find_peaks = x86_sse_find_peaks;
+ apply_gain_to_buffer = x86_sse_apply_gain_to_buffer;
+ mix_buffers_with_gain = x86_sse_mix_buffers_with_gain;
+ mix_buffers_no_gain = x86_sse_mix_buffers_no_gain;
+
+ generic_mix_functions = false;
+
+ }
+
+#elif defined (__APPLE__) && defined (BUILD_VECLIB_OPTIMIZATIONS)
+ long sysVersion = 0;
+
+ if (noErr != Gestalt(gestaltSystemVersion, &sysVersion))
+ sysVersion = 0;
+
+ if (sysVersion >= 0x00001040) { // Tiger at least
+ compute_peak = veclib_compute_peak;
+ find_peaks = veclib_find_peaks;
+ apply_gain_to_buffer = veclib_apply_gain_to_buffer;
+ mix_buffers_with_gain = veclib_mix_buffers_with_gain;
+ mix_buffers_no_gain = veclib_mix_buffers_no_gain;
+
+ generic_mix_functions = false;
+
+ info << "Apple VecLib H/W specific optimizations in use" << endmsg;
+ }
+#endif
+
+ /* consider FPU denormal handling to be "h/w optimization" */
+
+ setup_fpu ();
+ }
+
+ if (generic_mix_functions) {
+
+ compute_peak = default_compute_peak;
+ find_peaks = default_find_peaks;
+ apply_gain_to_buffer = default_apply_gain_to_buffer;
+ mix_buffers_with_gain = default_mix_buffers_with_gain;
+ mix_buffers_no_gain = default_mix_buffers_no_gain;
+
+ info << "No H/W specific optimizations in use" << endmsg;
+ }
+}
+
+static void
+lotsa_files_please ()
+{
+ struct rlimit rl;
+
+ if (getrlimit (RLIMIT_NOFILE, &rl) == 0) {
+
+ rl.rlim_cur = rl.rlim_max;
+
+ if (setrlimit (RLIMIT_NOFILE, &rl) != 0) {
+ if (rl.rlim_cur == RLIM_INFINITY) {
+ error << _("Could not set system open files limit to \"unlimited\"") << endmsg;
+ } else {
+ error << string_compose (_("Could not set system open files limit to %1"), rl.rlim_cur) << endmsg;
+ }
+ } else {
+ if (rl.rlim_cur == RLIM_INFINITY) {
+ info << _("Removed open file count limit. Excellent!") << endmsg;
+ } else {
+ info << string_compose (_("Ardour will be limited to %1 open files"), rl.rlim_cur) << endmsg;
+ }
+ }
+ } else {
+ error << string_compose (_("Could not get system open files limit (%1)"), strerror (errno)) << endmsg;
+ }
+}
+