jack2 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.

90 lines
2.2KB

  1. // u/* -*- Mode: C++ ; c-basic-offset: 4 -*- */
  2. /*
  3. JACK control API implementation
  4. Copyright (C) 2008 Nedko Arnaudov
  5. Copyright (C) 2008 Grame
  6. Copyright (C) 2013 Samsung Electronics
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; version 2 of the License.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. */
  18. #ifndef WIN32
  19. #include <stdint.h>
  20. #include <dirent.h>
  21. #include <pthread.h>
  22. #endif
  23. #include "types.h"
  24. #include <string.h>
  25. #include <errno.h>
  26. #include <stdio.h>
  27. #include <assert.h>
  28. #include <signal.h>
  29. #include "JackControlAPIAndroid.h"
  30. #include "JackConstants.h"
  31. #include "JackServerGlobals.h"
  32. using namespace Jack;
  33. struct jackctl_sigmask
  34. {
  35. sigset_t signals;
  36. };
  37. static jackctl_sigmask sigmask;
  38. SERVER_EXPORT int
  39. jackctl_wait_signals_and_return(jackctl_sigmask_t * sigmask)
  40. {
  41. int sig;
  42. bool waiting = true;
  43. while (waiting) {
  44. #if defined(sun) && !defined(__sun__) // SUN compiler only, to check
  45. sigwait(&sigmask->signals);
  46. #else
  47. sigwait(&sigmask->signals, &sig);
  48. #endif
  49. fprintf(stderr, "Jack main caught signal %d\n", sig);
  50. switch (sig) {
  51. case SIGUSR1:
  52. //jack_dump_configuration(engine, 1);
  53. break;
  54. case SIGUSR2:
  55. // driver exit
  56. waiting = false;
  57. break;
  58. case SIGTTOU:
  59. break;
  60. default:
  61. waiting = false;
  62. break;
  63. }
  64. }
  65. if (sig != SIGSEGV) {
  66. // unblock signals so we can see them during shutdown.
  67. // this will help prod developers not to lose sight of
  68. // bugs that cause segfaults etc. during shutdown.
  69. sigprocmask(SIG_UNBLOCK, &sigmask->signals, 0);
  70. }
  71. return sig;
  72. }