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.

96 lines
2.2KB

  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. #if WIN32
  32. Sleep(1*1000);
  33. #else
  34. sleep(1);
  35. #endif
  36. }
  37. return 0;
  38. }
  39. static void
  40. shutdown_handler (void *arg)
  41. {
  42. printf("shutdown \n");
  43. running = 0;
  44. }
  45. int
  46. main (int argc, char *argv[])
  47. {
  48. jack_client_t* client = NULL;
  49. /* try to become a client of the JACK server */
  50. if ((client = jack_client_open ("zombie", JackNullOption, NULL)) == 0) {
  51. fprintf (stderr, "JACK server not running?\n");
  52. goto error;
  53. }
  54. jack_set_process_callback (client, process, NULL);
  55. jack_on_shutdown(client, shutdown_handler, NULL);
  56. output_port = jack_port_register (client, "port1", JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0);
  57. /* tell the JACK server that we are ready to roll */
  58. if (jack_activate (client)) {
  59. fprintf (stderr, "cannot activate client");
  60. goto error;
  61. }
  62. jack_connect(client, jack_port_name(output_port), "coreaudio:Built-in Audio:in2");
  63. while (running) {
  64. #if WIN32
  65. Sleep(1*1000);
  66. #else
  67. sleep(1);
  68. #endif
  69. printf ("run\n");
  70. }
  71. jack_deactivate (client);
  72. jack_client_close (client);
  73. return 0;
  74. error:
  75. if (client)
  76. jack_client_close (client);
  77. return 1;
  78. }