jack1 codebase
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

86 lines
3.4KB

  1. /**
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation; either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program; if not, write to the Free Software
  15. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. *
  17. * @author Florian Faber
  18. *
  19. **/
  20. #include <stdio.h>
  21. #include "systemtest.h"
  22. #include "sanitycheck.h"
  23. int sanitycheck (int care_about_realtime,
  24. int care_about_freqscaling)
  25. {
  26. int errors = 0;
  27. int warnings = 0;
  28. int relogin = 0;
  29. if (care_about_realtime && !system_user_can_rtprio ()) {
  30. errors++;
  31. relogin++;
  32. fprintf (stderr, "\nJACK is running in realtime mode, but you are not allowed to use realtime scheduling.\n");
  33. if (!system_has_rtprio_limits_conf ()) {
  34. errors++;
  35. relogin++;
  36. fprintf (stderr, "Please check your /etc/security/limits.conf for the following line\n");
  37. fprintf (stderr, "and correct/add it if necessary:\n\n");
  38. fprintf (stderr, " @audio - rtprio 99\n");
  39. } else if (!system_has_audiogroup ()) {
  40. errors++;
  41. relogin++;
  42. fprintf (stderr, "\nYour system has no audio group. Please add it by executing (as root):\n");
  43. fprintf (stderr, " groupadd -r audio\n");
  44. fprintf (stderr, " usermod -a -G audio %s\n", system_get_username ());
  45. } else if (!system_user_in_audiogroup ()) {
  46. errors++;
  47. relogin++;
  48. fprintf (stderr, "\nYour system has an audio group, but you are not a member of it.\n");
  49. fprintf (stderr, "Please add yourself to the audio group by executing (as root):\n");
  50. fprintf (stderr, " usermod -a -G audio %s\n", system_get_username ());
  51. }
  52. }
  53. if (care_about_freqscaling && system_has_frequencyscaling () && system_uses_frequencyscaling ()) {
  54. warnings++;
  55. fprintf (stderr, "\n--------------------------------------------------------------------------------\n");
  56. fprintf (stderr, "WARNING: Your system seems to use frequency scaling.\n\n");
  57. fprintf (stderr, " This can have a serious impact on audio latency. You have two choices:\n");
  58. fprintf (stderr, "\t(1)turn it off, e.g. by chosing the 'performance' governor.\n");
  59. fprintf (stderr, "\t(2)Use the HPET clocksource by passing \"-c h\" to JACK\n");
  60. fprintf (stderr, "\t (this second option only works on relatively recent computers)\n");
  61. fprintf (stderr, "--------------------------------------------------------------------------------\n\n");
  62. }
  63. if (0 == system_memlock_amount ()) {
  64. errors++;
  65. relogin++;
  66. fprintf (stderr, "\nYou are not allowed to lock memory. Please add a line\n");
  67. fprintf (stderr, " @audio - memlock %llu\n", (system_available_physical_mem () * 3) / 4096);
  68. fprintf (stderr, "in your /etc/limits.conf.\n");
  69. }
  70. if (0 < relogin) {
  71. fprintf (stderr, "\nAfter applying these changes, please re-login in order for them to take effect.\n");
  72. }
  73. if (0 < errors) {
  74. fprintf (stderr, "\nYou don't appear to have a sane system configuration. It is very likely that you\n");
  75. fprintf (stderr, "encounter xruns. Please apply all the above mentioned changes and start jack again!\n");
  76. }
  77. return errors;
  78. }