root/trunk/jack/tools/freewheel.c

Revision 1148, 2.0 kB (checked in by marco, 2 years ago)

* Moved the tools to the tools directory. Only examples remain in the example-clients directory
* Updated Makefile.am and configure.ac files accordingly

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 /*
2  *  freewheel - start/stop JACK "freewheeling" mode
3  *
4  *  Copyright (C) 2003 Paul Davis.
5  * 
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2 of the License, or
9  *  (at your option) any later version.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  */
20
21 #include <stdio.h>
22 #include <errno.h>
23 #include <unistd.h>
24 #include <signal.h>
25 #include <stdlib.h>
26 #include <string.h>
27 #include <jack/jack.h>
28 #include <jack/transport.h>
29
30 char *package;                          /* program name */
31 jack_client_t *client;
32 int onoff;
33
34 void jack_shutdown(void *arg)
35 {
36         fprintf(stderr, "JACK shut down, exiting ...\n");
37         exit(1);
38 }
39
40 void signal_handler(int sig)
41 {
42         jack_client_close(client);
43         fprintf(stderr, "signal received, exiting ...\n");
44         exit(0);
45 }
46
47 void parse_arguments(int argc, char *argv[])
48 {
49         if (argc < 2) {
50                 fprintf(stderr, "usage: %s y|n\n", package);
51                 exit(9);
52         }
53
54         if (argv[1][0] == 'y' || argv[1][0] == 'Y' || argv[1][0] == '1') {
55                 onoff = 1;
56         } else {
57                 onoff = 0;
58         }
59 }
60
61 int
62 main (int argc, char *argv[])
63 {
64         parse_arguments (argc, argv);
65
66         /* become a JACK client */
67         if ((client = jack_client_new ("freewheel")) == 0) {
68                 fprintf (stderr, "JACK server not running?\n");
69                 exit(1);
70         }
71
72         signal (SIGQUIT, signal_handler);
73         signal (SIGTERM, signal_handler);
74         signal (SIGHUP, signal_handler);
75         signal (SIGINT, signal_handler);
76
77         jack_on_shutdown (client, jack_shutdown, 0);
78
79         if (jack_set_freewheel (client, onoff)) {
80                 fprintf (stderr, "failed to reset freewheel mode\n");
81         }
82
83         jack_client_close(client);
84
85         return 0;
86 }
Note: See TracBrowser for help on using the browser.