1 // ----------------------------------------------------------------------------
2 //
3 //  Copyright (C) 2010-2020 Fons Adriaensen <fons@linuxaudio.org>
4 //
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 3 of the License, or
8 //  (at your option) any later version.
9 //
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.
14 //
15 //  You should have received a copy of the GNU General Public License
16 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 //
18 // ----------------------------------------------------------------------------
19 
20 
21 #ifndef __JCLIENT_H
22 #define __JCLIENT_H
23 
24 
25 #include <jack/jack.h>
26 #include "denseconv.h"
27 
28 
29 class Jclient
30 {
31 public:
32 
33     Jclient (const char *jname, const char *jserv);
34     ~Jclient (void);
35 
36     enum { INIT, PROC, TERM };
37 
jname(void)38     const char  *jname (void) const { return _jname; }
fsamp(void)39     unsigned int fsamp (void) const { return _fsamp; }
fragm(void)40     unsigned int fragm (void) const { return _fragm; }
41 
42     int add_input_port  (const char *name, const char *conn = 0);
43     int add_output_port (const char *name, const char *conn = 0);
44     int delete_ports (void);
45 
46     void start (Denseconv *dconv);
47     void stop (void);
state(void)48     int state (void) const { return _actstate; }
49 
50 private:
51 
52     void  init_jack (const char *jname, const char *jserv);
53     void  close_jack (void);
54     void  jack_process (void);
55 
56     jack_client_t  *_jack_client;
57     jack_port_t    *_jack_inppp [Denseconv::MAXINP];
58     jack_port_t    *_jack_outpp [Denseconv::MAXOUT];
59     int             _abspri;
60     int             _policy;
61     volatile int    _comstate;
62     volatile int    _actstate;
63     const char     *_jname;
64     unsigned int    _fsamp;
65     unsigned int    _fragm;
66     unsigned int    _flags;
67     unsigned int    _ninp;
68     unsigned int    _nout;
69     Denseconv      *_dconv;
70 
71     static void jack_static_shutdown (void *arg);
72     static int  jack_static_buffsize (jack_nframes_t nframes, void *arg);
73     static int  jack_static_process (jack_nframes_t nframes, void *arg);
74 };
75 
76 
77 #endif
78