summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2007-02-28 18:55:46 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2007-02-28 18:55:46 +0000
commit161b8b92a2df18073f5f7c22e35269287b0523d0 (patch)
tree47a2fddf37cab9b3433f275e82c9eecea7e39dee /gtk2_ardour
parent9c1e0194f7e7c253b1cf3c83086daf7209503591 (diff)
"Sampo's Delight" - add "do not show this window again" to memory warning; check physical RAM on linux and only warn if limit is less than 75% of total RAM; do nothing on OSX since there is no mlockall there
git-svn-id: svn://localhost/ardour2/trunk@1534 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/ardour_ui.cc62
-rw-r--r--gtk2_ardour/ardour_ui.h3
2 files changed, 56 insertions, 9 deletions
diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc
index c6db2716c5..c11175fe27 100644
--- a/gtk2_ardour/ardour_ui.cc
+++ b/gtk2_ardour/ardour_ui.cc
@@ -437,27 +437,71 @@ ARDOUR_UI::save_ardour_state ()
void
ARDOUR_UI::startup ()
{
- if (engine->is_realtime()) {
+ check_memory_locking();
+}
+
+void
+ARDOUR_UI::no_memory_warning ()
+{
+ XMLNode node (X_("no-memory-warning"));
+ Config->add_instant_xml (node, get_user_ardour_path());
+}
+
+void
+ARDOUR_UI::check_memory_locking ()
+{
+#ifdef __APPLE__
+ /* OS X doesn't support mlockall(2), and so testing for memory locking capability there is pointless */
+ return;
+#endif
+
+ XMLNode* memory_warning_node = Config->instant_xml (X_("no-memory-warning"), get_user_ardour_path());
+
+ if (engine->is_realtime() && memory_warning_node == 0) {
struct rlimit limits;
-
+ int64_t ram;
+ long pages, page_size;
+
+ if ((page_size = sysconf (_SC_PAGESIZE)) < 0 ||(pages = sysconf (_SC_PHYS_PAGES)) < 0) {
+ ram = 0;
+ } else {
+ ram = (int64_t) pages * (int64_t) page_size;
+ }
+
if (getrlimit (RLIMIT_MEMLOCK, &limits)) {
return;
}
if (limits.rlim_cur != RLIM_INFINITY) {
- MessageDialog msg (_("WARNING: Your system has a limit for maximum amount of locked memory. "
- "This might cause Ardour to run out of memory before your system "
- "runs out of memory. \n\n"
- "You can view the memory limit with 'ulimit -l', "
- "and it is normally controlled by /etc/security/limits.conf"));
+
+ if (ram == 0 || ((double) limits.rlim_cur / ram) < 0.75) {
- editor->ensure_float (msg);
- msg.run ();
+
+ MessageDialog msg (_("WARNING: Your system has a limit for maximum amount of locked memory. "
+ "This might cause Ardour to run out of memory before your system "
+ "runs out of memory. \n\n"
+ "You can view the memory limit with 'ulimit -l', "
+ "and it is normally controlled by /etc/security/limits.conf"));
+
+ VBox* vbox = msg.get_vbox();
+ HBox hbox;
+ CheckButton cb (_("Do not show this window again"));
+
+ cb.signal_toggled().connect (mem_fun (*this, &ARDOUR_UI::no_memory_warning));
+
+ hbox.pack_start (cb, true, false);
+ vbox->pack_start (hbox);
+ hbox.show_all ();
+
+ editor->ensure_float (msg);
+ msg.run ();
+ }
}
}
}
+
void
ARDOUR_UI::finish()
{
diff --git a/gtk2_ardour/ardour_ui.h b/gtk2_ardour/ardour_ui.h
index 00d8deacbf..a8bd1517f1 100644
--- a/gtk2_ardour/ardour_ui.h
+++ b/gtk2_ardour/ardour_ui.h
@@ -697,6 +697,9 @@ class ARDOUR_UI : public Gtkmm2ext::UI
bool can_save_keybindings;
bool first_idle ();
+
+ void no_memory_warning ();
+ void check_memory_locking ();
};
#endif /* __ardour_gui_h__ */