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.

88 lines
2.1KB

  1. /*
  2. Copyright (C) 2002 Jeremy Hall
  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. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  14. $Id: zombie.c,v 1.1 2005/08/18 11:42:08 letz Exp $
  15. */
  16. #include <stdio.h>
  17. #include <errno.h>
  18. #include <unistd.h>
  19. #include <string.h>
  20. #include <stdlib.h>
  21. #include <jack/jack.h>
  22. int running = 1;
  23. int count = 0;
  24. jack_port_t* output_port;
  25. static int
  26. process(jack_nframes_t nframes, void* arg)
  27. {
  28. if (count++ == 1000) {
  29. printf("process block\n");
  30. //while (1) {}
  31. sleep(1);
  32. }
  33. return 0;
  34. }
  35. static void
  36. shutdown (void *arg)
  37. {
  38. printf("shutdown \n");
  39. running = 0;
  40. }
  41. int
  42. main (int argc, char *argv[])
  43. {
  44. jack_client_t* client = NULL;
  45. /* try to become a client of the JACK server */
  46. if ((client = jack_client_open ("zombie", JackNullOption, NULL)) == 0) {
  47. fprintf (stderr, "jack server not running?\n");
  48. goto error;
  49. }
  50. jack_set_process_callback (client, process, NULL);
  51. jack_on_shutdown(client, shutdown, NULL);
  52. output_port = jack_port_register (client, "port1", JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0);
  53. /* tell the JACK server that we are ready to roll */
  54. if (jack_activate (client)) {
  55. fprintf (stderr, "cannot activate client");
  56. goto error;
  57. }
  58. jack_connect(client, jack_port_name(output_port), "coreaudio:Built-in Audio:in2");
  59. while (running) {
  60. sleep(1);
  61. printf ("run\n");
  62. }
  63. jack_deactivate (client);
  64. jack_client_close (client);
  65. return 0;
  66. error:
  67. if (client)
  68. jack_client_close (client);
  69. return 1;
  70. }