waf: configure option for enforcing autostart method
[jack2.git] / example-clients / zombie.c
blobc982cfa8f0cdad25e37dfbfc25f0688b6d1a90a8
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;
55 /* try to become a client of the JACK server */
56 if ((client = jack_client_open ("zombie", JackNullOption, NULL)) == 0) {
57 fprintf (stderr, "JACK server not running?\n");
58 goto error;
61 jack_set_process_callback (client, process, NULL);
62 jack_on_shutdown(client, shutdown, NULL);
63 output_port = jack_port_register (client, "port1", JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0);
65 /* tell the JACK server that we are ready to roll */
66 if (jack_activate (client)) {
67 fprintf (stderr, "cannot activate client");
68 goto error;
71 jack_connect(client, jack_port_name(output_port), "coreaudio:Built-in Audio:in2");
73 while (running) {
74 sleep(1);
75 printf ("run\n");
78 jack_deactivate (client);
79 jack_client_close (client);
80 return 0;
82 error:
83 if (client)
84 jack_client_close (client);
85 return 1;