File: zombie.c

package info (click to toggle)
jackd2 1.9.12~dfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 8,632 kB
  • sloc: cpp: 50,117; ansic: 29,194; python: 11,637; sh: 88; makefile: 68; objc: 39
file content (95 lines) | stat: -rw-r--r-- 2,262 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
    Copyright (C) 2002 Jeremy Hall

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

    $Id: zombie.c,v 1.1 2005/08/18 11:42:08 letz Exp $
*/

#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <jack/jack.h>

int running = 1;
int count = 0;
jack_port_t* output_port;

static int
process(jack_nframes_t nframes, void* arg)
{
	if (count++ == 1000) {
        printf("process block\n");
        //while (1) {}
#if WIN32
	Sleep(1*1000);
#else
	sleep(1);
#endif
    }

    return 0;
}

static void
shutdown_handler (void *arg)
{
    printf("shutdown \n");
    running = 0;
}

int
main (int argc, char *argv[])
{
	jack_client_t* client = NULL;
    /* try to become a client of the JACK server */
	if ((client = jack_client_open ("zombie", JackNullOption, NULL)) == 0) {
		fprintf (stderr, "JACK server not running?\n");
		goto error;
	}

    jack_set_process_callback (client, process, NULL);
    jack_on_shutdown(client, shutdown_handler, NULL);
    output_port = jack_port_register (client, "port1", JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0);

	/* tell the JACK server that we are ready to roll */
	if (jack_activate (client)) {
		fprintf (stderr, "cannot activate client");
		goto error;
	}

    jack_connect(client, jack_port_name(output_port), "coreaudio:Built-in Audio:in2");

    while (running) {
#if WIN32
        Sleep(1*1000);
#else
        sleep(1);
#endif
        printf ("run\n");
    }

    jack_deactivate (client);
	jack_client_close (client);
	return 0;

error:
    if (client)
        jack_client_close (client);
    return 1;
}