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.

81 lines
3.3KB

  1. /**
  2. * GPL etc.
  3. *
  4. * @author Florian Faber
  5. *
  6. * @version 0.1 (2009-01-17) [FF]
  7. * - initial version
  8. **/
  9. #include <stdio.h>
  10. #include <jack/systemtest.h>
  11. #include <jack/sanitycheck.h>
  12. int sanitycheck (int care_about_realtime,
  13. int care_about_freqscaling)
  14. {
  15. int errors = 0;
  16. int warnings = 0;
  17. int relogin = 0;
  18. if (care_about_realtime && !system_user_can_rtprio()) {
  19. errors++;
  20. relogin++;
  21. fprintf(stderr, "\nJACK is running in realtime mode, but you are not allowed to use realtime scheduling.\n");
  22. if (!system_has_rtprio_limits_conf()) {
  23. errors++;
  24. relogin++;
  25. fprintf (stderr, "Please check your /etc/security/limits.conf for the following lines\n");
  26. fprintf (stderr, "and correct/add them:\n\n");
  27. fprintf(stderr, " @audio - rtprio 100\n");
  28. fprintf(stderr, " @audio - nice -10\n");
  29. } else if (!system_has_audiogroup()) {
  30. errors++;
  31. relogin++;
  32. fprintf(stderr, "\nYour system has no audio group. Please add it by executing (as root):\n");
  33. fprintf(stderr, " groupadd -r audio\n");
  34. fprintf(stderr, " usermod -a -G audio %s\n", system_get_username());
  35. } else if (!system_user_in_audiogroup()) {
  36. errors++;
  37. relogin++;
  38. fprintf(stderr, "\nYour system has an audio group, but you are not a member of it.\n");
  39. fprintf(stderr, "Please add yourself to the audio group by executing (as root):\n");
  40. fprintf(stderr, " usermod -a -G audio %s\n", system_get_username());
  41. }
  42. }
  43. if (care_about_freqscaling && system_has_frequencyscaling() && system_uses_frequencyscaling()) {
  44. warnings++;
  45. fprintf(stderr, "\n--------------------------------------------------------------------------------\n");
  46. fprintf(stderr, "WARNING: Your system seems to use frequency scaling.\n\n");
  47. fprintf(stderr, " This can have a serious impact on audio latency. You have two choices:\n");
  48. fprintf(stderr, "\t(1)turn it off, e.g. by chosing the 'performance' governor.\n");
  49. fprintf(stderr, "\t(2)Use the HPET clocksource by passing \"-c h\" to JACK\n");
  50. fprintf(stderr, "\t (this second option only works on relatively recent computers)\n");
  51. fprintf(stderr, "--------------------------------------------------------------------------------\n\n");
  52. }
  53. if (system_memlock_is_unlimited()) {
  54. fprintf(stderr, "\nMemory locking is unlimited - this is dangerous. Please alter the line");
  55. fprintf(stderr, " @audio - memlock unlimited");
  56. fprintf(stderr, "in your /etc/limits.conf to");
  57. fprintf(stderr, " @audio - memlock %llu\n", (system_available_physical_mem()*3)/4096);
  58. } else if (0==system_memlock_amount()) {
  59. errors++;
  60. relogin++;
  61. fprintf(stderr, "\nYou are not allowed to lock memory. Please add a line\n");
  62. fprintf(stderr, " @audio - memlock %llu\n", (system_available_physical_mem()*3)/4096);
  63. fprintf(stderr, "in your /etc/limits.conf.\n");
  64. }
  65. if (0<relogin) {
  66. fprintf(stderr, "\nAfter applying these changes, please re-login in order for them to take effect.\n");
  67. }
  68. if (0<errors) {
  69. fprintf(stderr, "\nYou don't appear to have a sane system configuration. It is very likely that you\n");
  70. fprintf(stderr, "encounter xruns. Please apply all the above mentioned changes and start jack again!\n");
  71. }
  72. return errors;
  73. }