mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-06 23:05:04 +01:00
"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
This commit is contained in:
parent
9c1e0194f7
commit
161b8b92a2
2 changed files with 56 additions and 9 deletions
|
|
@ -437,27 +437,71 @@ ARDOUR_UI::save_ardour_state ()
|
||||||
void
|
void
|
||||||
ARDOUR_UI::startup ()
|
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;
|
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)) {
|
if (getrlimit (RLIMIT_MEMLOCK, &limits)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (limits.rlim_cur != RLIM_INFINITY) {
|
if (limits.rlim_cur != RLIM_INFINITY) {
|
||||||
|
|
||||||
|
if (ram == 0 || ((double) limits.rlim_cur / ram) < 0.75) {
|
||||||
|
|
||||||
|
|
||||||
MessageDialog msg (_("WARNING: Your system has a limit for maximum amount of locked memory. "
|
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 "
|
"This might cause Ardour to run out of memory before your system "
|
||||||
"runs out of memory. \n\n"
|
"runs out of memory. \n\n"
|
||||||
"You can view the memory limit with 'ulimit -l', "
|
"You can view the memory limit with 'ulimit -l', "
|
||||||
"and it is normally controlled by /etc/security/limits.conf"));
|
"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);
|
editor->ensure_float (msg);
|
||||||
msg.run ();
|
msg.run ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ARDOUR_UI::finish()
|
ARDOUR_UI::finish()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -697,6 +697,9 @@ class ARDOUR_UI : public Gtkmm2ext::UI
|
||||||
|
|
||||||
bool can_save_keybindings;
|
bool can_save_keybindings;
|
||||||
bool first_idle ();
|
bool first_idle ();
|
||||||
|
|
||||||
|
void no_memory_warning ();
|
||||||
|
void check_memory_locking ();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* __ardour_gui_h__ */
|
#endif /* __ardour_gui_h__ */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue