From 22a407fb6b4dac1c88bf757832998c6d8ed8f6f2 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 13 Feb 2008 01:56:33 +0000 Subject: [PATCH] allow ardour to use the (hard) maximum number of open files (this one's for you essej) git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@3044 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/ardour/insert.h | 2 +- libs/ardour/ardour/io.h | 5 ++++- libs/ardour/ardour/route.h | 2 +- libs/ardour/audio_track.cc | 2 +- libs/ardour/globals.cc | 32 ++++++++++++++++++++++++++++++++ libs/ardour/insert.cc | 2 +- libs/ardour/io.cc | 16 ++++++---------- libs/ardour/route.cc | 14 +++++++++----- 8 files changed, 55 insertions(+), 20 deletions(-) diff --git a/libs/ardour/ardour/insert.h b/libs/ardour/ardour/insert.h index 9d063ca54b..dd2d06c06f 100644 --- a/libs/ardour/ardour/insert.h +++ b/libs/ardour/ardour/insert.h @@ -146,7 +146,7 @@ class PluginInsert : public Insert nframes_t latency(); void transport_stopped (nframes_t now); - void automation_snapshot (nframes_t now); + void automation_snapshot (nframes_t now, bool force); private: diff --git a/libs/ardour/ardour/io.h b/libs/ardour/ardour/io.h index db0a097490..2c7b8a3f7e 100644 --- a/libs/ardour/ardour/io.h +++ b/libs/ardour/ardour/io.h @@ -258,7 +258,10 @@ class IO : public PBD::StatefulDestructible sigc::signal gain_automation_style_changed; virtual void transport_stopped (nframes_t now); - void automation_snapshot (nframes_t now); + bool should_snapshot (nframes_t now) { + return (last_automation_snapshot > now || (now - last_automation_snapshot) > _automation_interval); + } + virtual void automation_snapshot (nframes_t now, bool force); ARDOUR::Curve& gain_automation_curve () { return _gain_automation_curve; } diff --git a/libs/ardour/ardour/route.h b/libs/ardour/ardour/route.h index e4fb003e09..49ced51f88 100644 --- a/libs/ardour/ardour/route.h +++ b/libs/ardour/ardour/route.h @@ -234,7 +234,7 @@ class Route : public IO return _mute_control; } - void automation_snapshot (nframes_t now); + void automation_snapshot (nframes_t now, bool force); void protect_automation (); void set_remote_control_id (uint32_t id); diff --git a/libs/ardour/audio_track.cc b/libs/ardour/audio_track.cc index c2f76f339d..50f688d2b2 100644 --- a/libs/ardour/audio_track.cc +++ b/libs/ardour/audio_track.cc @@ -539,7 +539,7 @@ AudioTrack::roll (nframes_t nframes, nframes_t start_frame, nframes_t end_frame, if (lm.locked()) { // automation snapshot can also be called from the non-rt context // and it uses the redirect list, so we take the lock out here - automation_snapshot (start_frame); + automation_snapshot (start_frame, false); } } diff --git a/libs/ardour/globals.cc b/libs/ardour/globals.cc index 422ed16786..dc22d6ede2 100644 --- a/libs/ardour/globals.cc +++ b/libs/ardour/globals.cc @@ -20,6 +20,8 @@ #include // Needed so that libraptor (included in lrdf) won't complain #include #include +#include +#include #include #include #include @@ -249,6 +251,33 @@ setup_hardware_optimization (bool try_optimization) } +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; + } +} + int ARDOUR::init (bool use_vst, bool try_optimization) { @@ -258,6 +287,9 @@ ARDOUR::init (bool use_vst, bool try_optimization) setup_enum_writer (); + // allow ardour the absolute maximum number of open files + lotsa_files_please (); + lrdf_init(); Library = new AudioLibrary; diff --git a/libs/ardour/insert.cc b/libs/ardour/insert.cc index 8724c5011e..73538cc3e4 100644 --- a/libs/ardour/insert.cc +++ b/libs/ardour/insert.cc @@ -320,7 +320,7 @@ PluginInsert::connect_and_run (vector& bufs, uint32_t nbufs, nframes_t } void -PluginInsert::automation_snapshot (nframes_t now) +PluginInsert::automation_snapshot (nframes_t now, bool force) { map::iterator li; diff --git a/libs/ardour/io.cc b/libs/ardour/io.cc index 4f74b70e57..7b2838d8fe 100644 --- a/libs/ardour/io.cc +++ b/libs/ardour/io.cc @@ -2604,18 +2604,14 @@ IO::end_pan_touch (uint32_t which) } void -IO::automation_snapshot (nframes_t now) +IO::automation_snapshot (nframes_t now, bool force) { - if (last_automation_snapshot > now || (now - last_automation_snapshot) > _automation_interval) { - - if (gain_automation_recording()) { - _gain_automation_curve.rt_add (now, gain()); - } - - _panner->snapshot (now); - - last_automation_snapshot = now; + if (gain_automation_recording()) { + _gain_automation_curve.rt_add (now, gain()); } + + _panner->snapshot (now); + last_automation_snapshot = now; } void diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index 95571bd3da..0ff6a02799 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -2194,7 +2194,7 @@ Route::handle_transport_stopped (bool abort_ignored, bool did_locate, bool can_f Glib::RWLock::ReaderLock lm (redirect_lock); if (!did_locate) { - automation_snapshot (now); + automation_snapshot (now, true); } for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ++i) { @@ -2301,7 +2301,7 @@ Route::roll (nframes_t nframes, nframes_t start_frame, nframes_t end_frame, nfra if (lm.locked()) { // automation snapshot can also be called from the non-rt context // and it uses the redirect list, so we take the lock out here - automation_snapshot (_session.transport_frame()); + automation_snapshot (_session.transport_frame(), false); } } @@ -2442,12 +2442,16 @@ Route::set_latency_delay (nframes_t longest_session_latency) } void -Route::automation_snapshot (nframes_t now) +Route::automation_snapshot (nframes_t now, bool force) { - IO::automation_snapshot (now); + if (!force && !should_snapshot(now)) { + return; + } + + IO::automation_snapshot (now, force); for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ++i) { - (*i)->automation_snapshot (now); + (*i)->automation_snapshot (now, force); } }