Merge branch 'develop' of github.com:jackaudio/jack2 into develop
[jack2.git] / example-clients / zombie.c
blob4ba96925446a80979547bad7b4ac99300393144f
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 #if WIN32
39 Sleep(1*1000);
40 #else
41 sleep(1);
42 #endif
45 return 0;
48 static void
49 shutdown_handler (void *arg)
51 printf("shutdown \n");
52 running = 0;
55 int
56 main (int argc, char *argv[])
58 jack_client_t* client = NULL;
59 /* try to become a client of the JACK server */
60 if ((client = jack_client_open ("zombie", JackNullOption, NULL)) == 0) {
61 fprintf (stderr, "JACK server not running?\n");
62 goto error;
65 jack_set_process_callback (client, process, NULL);
66 jack_on_shutdown(client, shutdown_handler, NULL);
67 output_port = jack_port_register (client, "port1", JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0);
69 /* tell the JACK server that we are ready to roll */
70 if (jack_activate (client)) {
71 fprintf (stderr, "cannot activate client");
72 goto error;
75 jack_connect(client, jack_port_name(output_port), "coreaudio:Built-in Audio:in2");
77 while (running) {
78 #if WIN32
79 Sleep(1*1000);
80 #else
81 sleep(1);
82 #endif
83 printf ("run\n");
86 jack_deactivate (client);
87 jack_client_close (client);
88 return 0;
90 error:
91 if (client)
92 jack_client_close (client);
93 return 1;