New LockAllMemory and UnlockAllMemory functions.
[jack2.git] / example-clients / zombie.c
blob970306bf0d7e755bd31956e65c0e7dfa62ea0af6
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>
27 #include "jack.h"
29 int running = 1;
30 int count = 0;
31 jack_port_t* output_port;
33 int
34 process(jack_nframes_t nframes, void* arg)
36 if (count++ == 1000) {
37 printf("process block\n");
38 //while (1) {}
39 sleep(1);
42 return 0;
45 void
46 shutdown (void *arg)
48 printf("shutdown \n");
49 running = 0;
52 int
53 main (int argc, char *argv[])
55 jack_client_t* client = NULL;
57 /* try to become a client of the JACK server */
58 if ((client = jack_client_new ("zombie")) == 0) {
59 fprintf (stderr, "jack server not running?\n");
60 goto error;
63 jack_set_process_callback (client, process, NULL);
64 jack_on_shutdown(client, shutdown, NULL);
65 output_port = jack_port_register (client, "port1", JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0);
67 /* tell the JACK server that we are ready to roll */
68 if (jack_activate (client)) {
69 fprintf (stderr, "cannot activate client");
70 goto error;
73 jack_connect(client, jack_port_name(output_port), "coreaudio:Built-in Audio:in2");
75 while (running) {
76 sleep(1);
77 printf ("run\n");
80 jack_deactivate (client);
81 jack_client_close (client);
82 return 0;
84 error:
85 if (client)
86 jack_client_close (client);
87 return 1;