1
// -----------------------------------------------------------------------------
3
// Copyright (C) 2006-2009 Fons Adriaensen <fons@kokkinizita.net>
5
// This program is free software; you can redistribute it and/or modify
6
// it under the terms of the GNU General Public License as published by
7
// the Free Software Foundation; either version 2 of the License, or
8
// (at your option) any later version.
10
// This program is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
// GNU General Public License for more details.
15
// You should have received a copy of the GNU General Public License
16
// along with this program; if not, write to the Free Software
17
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19
// -----------------------------------------------------------------------------
33
static const char *options = "hL:MN:v";
34
static const char *N_val = "jconvolver";
35
static unsigned int L_val = 0;
36
static bool M_opt = false;
37
static bool v_opt = false;
38
static bool stop = false;
43
unsigned int rate = 0;
44
unsigned int frag = 0;
45
unsigned int part = 0;
46
unsigned int ninp = 0;
47
unsigned int nout = 0;
48
unsigned int size = 0;
51
static void help (void)
53
fprintf (stderr, "\nJconvolver %s\n", VERSION);
54
fprintf (stderr, "(C) 2006-2009 Fons Adriaensen <fons@kokkinizita.net>\n\n");
55
fprintf (stderr, "Usage: jconvolver <options> <config file> {<connect file>}\n");
56
fprintf (stderr, "Options:\n");
57
fprintf (stderr, " -h Display this text\n");
58
fprintf (stderr, " -v Print partition list to stdout [off]\n");
59
fprintf (stderr, " -L <nframes> Try to compensate <nframes> latency\n");
60
fprintf (stderr, " -M Use the FFTW_MEASURE option [off]\n");
61
fprintf (stderr, " -N <name> Name to use as JACK client [jconvolver]\n");
66
static void procoptions (int ac, char *av [], const char *where)
72
while ((k = getopt (ac, av, (char *) options)) != -1)
74
if (optarg && (*optarg == '-'))
76
fprintf (stderr, "\n%s\n", where);
77
fprintf (stderr, " Missing argument for '-%c' option.\n", k);
78
fprintf (stderr, " Use '-h' to see all options.\n");
83
case 'h' : help (); exit (0);
84
case 'v' : v_opt = true; break;
85
case 'L' : L_val = atoi (optarg); break;
86
case 'M' : M_opt = true; break;
87
case 'N' : N_val = optarg; break;
89
fprintf (stderr, "\n%s\n", where);
90
if (optopt != ':' && strchr (options, optopt))
92
fprintf (stderr, " Missing argument for '-%c' option.\n", optopt);
94
else if (isprint (optopt))
96
fprintf (stderr, " Unknown option '-%c'.\n", optopt);
100
fprintf (stderr, " Unknown option character '0x%02x'.\n", optopt & 255);
102
fprintf (stderr, " Use '-h' to see all options.\n");
111
static void sigint_handler (int)
117
int main (int ac, char *av [])
121
if (mlockall (MCL_CURRENT | MCL_FUTURE))
123
fprintf (stderr, "Warning: ");
124
perror ("mlockall:");
127
procoptions (ac, av, "On command line:");
128
if (ac <= optind) help ();
131
jclient = new Jclient (N_val, conv);
132
rate = jclient->rate ();
133
frag = jclient->frag ();
135
if (M_opt) conv->set_fftwopt (FFTW_MEASURE);
136
if (config (av [optind], L_val))
141
if (v_opt) conv->print ();
146
signal (SIGINT, sigint_handler);
150
flags = jclient->flags ();
152
if (flags & Jclient::FL_EXIT)
157
if (flags & Convproc::FL_LOAD)
159
puts ("CPU OVERLOAD");
162
if (flags & Convproc::FL_LATE)
164
printf ("Processing can't keep up (%04x)\n", flags & Convproc::FL_LATE);
169
while (conv->state () != Convproc::ST_STOP) usleep (100000);