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.

86 lines
2.0KB

  1. /*
  2. * smaplerate.c -- get current samplerate
  3. *
  4. * Copyright (C) 2003 Jack O'Quin.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. */
  20. #include <stdio.h>
  21. #include <errno.h>
  22. #include <unistd.h>
  23. #include <signal.h>
  24. #include <stdlib.h>
  25. #include <string.h>
  26. #include <jack/jack.h>
  27. #include <jack/transport.h>
  28. char *package; /* program name */
  29. jack_client_t *client;
  30. void jack_shutdown(void *arg)
  31. {
  32. fprintf(stderr, "JACK shut down, exiting ...\n");
  33. exit(1);
  34. }
  35. void signal_handler(int sig)
  36. {
  37. jack_client_close(client);
  38. fprintf(stderr, "signal received, exiting ...\n");
  39. exit(0);
  40. }
  41. void parse_arguments(int argc, char *argv[])
  42. {
  43. /* basename $0 */
  44. package = strrchr(argv[0], '/');
  45. if (package == 0)
  46. package = argv[0];
  47. else
  48. package++;
  49. if (argc==1) {
  50. return;
  51. }
  52. fprintf(stderr, "usage: %s [bufsize]\n", package);
  53. exit(9);
  54. }
  55. int main(int argc, char *argv[])
  56. {
  57. parse_arguments(argc, argv);
  58. /* become a JACK client */
  59. if ((client = jack_client_open(package, JackNullOption, NULL)) == 0) {
  60. fprintf(stderr, "JACK server not running?\n");
  61. exit(1);
  62. }
  63. signal(SIGQUIT, signal_handler);
  64. signal(SIGTERM, signal_handler);
  65. signal(SIGHUP, signal_handler);
  66. signal(SIGINT, signal_handler);
  67. jack_on_shutdown(client, jack_shutdown, 0);
  68. fprintf(stdout, "%d\n", jack_get_sample_rate( client ) );
  69. jack_client_close(client);
  70. return 0;
  71. }