For later use..
[jack2.git] / example-clients / zombie.c
blob0d3943c4f7f98b67014a553815f22ab92462134e
1 /*
2 Copyright (C) 2002 Jeremy Hall
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 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.
18 $Id: zombie.c,v 1.1 2005/08/18 11:42:08 letz Exp $
21 #include <stdio.h>
22 #include <errno.h>
23 #include <unistd.h>
24 #include <string.h>
25 #include <stdlib.h>
26 #include <jack/jack.h>
28 int running = 1;
29 int count = 0;
30 jack_port_t* output_port;
32 static int
33 process(jack_nframes_t nframes, void* arg)
35 if (count++ == 1000) {
36 printf("process block\n");
37 //while (1) {}
38 sleep(1);
41 return 0;
44 static void
45 shutdown (void *arg)
47 printf("shutdown \n");
48 running = 0;
51 int
52 main (int argc, char *argv[])
54 jack_client_t* client = NULL;
56 /* try to become a client of the JACK server */
57 if ((client = jack_client_new ("zombie")) == 0) {
58 fprintf (stderr, "jack server not running?\n");
59 goto error;
62 jack_set_process_callback (client, process, NULL);
63 jack_on_shutdown(client, shutdown, NULL);
64 output_port = jack_port_register (client, "port1", JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0);
66 /* tell the JACK server that we are ready to roll */
67 if (jack_activate (client)) {
68 fprintf (stderr, "cannot activate client");
69 goto error;
72 jack_connect(client, jack_port_name(output_port), "coreaudio:Built-in Audio:in2");
74 while (running) {
75 sleep(1);
76 printf ("run\n");
79 jack_deactivate (client);
80 jack_client_close (client);
81 return 0;
83 error:
84 if (client)
85 jack_client_close (client);
86 return 1;