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.

94 lines
2.3KB

  1. /*
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License as published by
  4. the Free Software Foundation; either version 2 of the License, or
  5. (at your option) any later version.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. GNU General Public License for more details.
  10. You should have received a copy of the GNU General Public License
  11. along with this program; if not, write to the Free Software
  12. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  13. */
  14. #include <string.h>
  15. #include <stdlib.h>
  16. #include <stdio.h>
  17. #include <jack/jack.h>
  18. #include <jack/intclient.h>
  19. int
  20. main (int argc, char *argv[])
  21. {
  22. char *my_name;
  23. char *client_name;
  24. jack_client_t *client;
  25. jack_status_t status;
  26. jack_intclient_t intclient;
  27. /* validate args */
  28. if ((argc < 2) || (argc > 3)) {
  29. fprintf (stderr, "usage: %s client-name [ server-name ]]\n",
  30. argv[0]);
  31. return 1;
  32. }
  33. /* use `basename $0` for my own client name */
  34. my_name = strrchr(argv[0], '/');
  35. if (my_name == 0) {
  36. my_name = argv[0];
  37. } else {
  38. my_name++;
  39. }
  40. /* first, become a JACK client */
  41. if (argc > 2) {
  42. client = jack_client_open (my_name,
  43. (JackServerName|JackNoStartServer),
  44. &status, argv[2]);
  45. } else {
  46. client = jack_client_open (my_name, JackNoStartServer, &status);
  47. }
  48. if (client == NULL) {
  49. if (status & JackServerFailed) {
  50. fprintf (stderr, "JACK server not running.\n");
  51. } else {
  52. fprintf (stderr, "JACK open failed, "
  53. "status = 0x%2.0x\n", status);
  54. }
  55. exit (1);
  56. }
  57. /* then, get the internal client handle */
  58. client_name = argv[1];
  59. intclient = jack_internal_client_handle (client, client_name, &status);
  60. if (status & JackFailure) {
  61. fprintf (stderr, "client %s not found.\n", client_name);
  62. exit (2);
  63. }
  64. /* now, unload the internal client */
  65. status = jack_internal_client_unload (client, intclient);
  66. if (status & JackFailure) {
  67. if (status & JackNoSuchClient) {
  68. fprintf (stderr, "client %s is gone.\n",
  69. client_name);
  70. } else {
  71. fprintf (stderr, "could not unload %s, "
  72. "returns 0x%2.0x\n", client_name, status);
  73. }
  74. exit (3);
  75. } else {
  76. fprintf (stdout, "%s unloaded.\n", client_name);
  77. }
  78. jack_client_close(client);
  79. return 0;
  80. }