1 // ----------------------------------------------------------------------------- 2 // 3 // Copyright (C) 2006-2011 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 2 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, write to the Free Software 17 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 // 19 // ----------------------------------------------------------------------------- 20 21 22 #ifndef __JCLIENT_H 23 #define __JCLIENT_H 24 25 26 #include <jack/jack.h> 27 #include "zita-convolver.h" 28 #define NDEBUG 29 #include "prbsgen.h" 30 31 32 class Jclient 33 { 34 public: 35 36 Jclient (const char *jname, const char *jserv, Convproc *convproc); 37 ~Jclient (void); 38 39 enum { FL_EXIT = 0x80000000, FL_BUFF = 0x40000000 }; 40 jname(void)41 const char *jname (void) const { return _jname; } fsamp(void)42 unsigned int fsamp (void) const { return _fsamp; } fragm(void)43 unsigned int fragm (void) const { return _fragm; } state(void)44 unsigned int state (void) { return _convproc->state (); } 45 flags(void)46 unsigned int flags (void) { _clear = true; return _flags; } 47 48 int delete_ports (void); 49 int add_input_port (const char *name, const char *conn = 0); 50 int add_output_port (const char *name, const char *conn = 0); denorm_protect(bool v)51 void denorm_protect (bool v) { _addnoise = v; } 52 start(void)53 void start (void) { _convproc->start_process (_abspri, _policy); } stop(void)54 void stop (void) { _convproc->stop_process (); } 55 56 private: 57 58 void init_jack (const char *jname, const char *jserv); 59 void close_jack (void); 60 void jack_process (void); 61 62 jack_client_t *_jack_client; 63 jack_port_t *_jack_inppp [Convproc::MAXINP]; 64 jack_port_t *_jack_outpp [Convproc::MAXOUT]; 65 const char *_jname; 66 int _abspri; 67 int _policy; 68 unsigned int _fsamp; 69 unsigned int _fragm; 70 unsigned int _flags; 71 bool _clear; 72 unsigned int _ninp; 73 unsigned int _nout; 74 Convproc *_convproc; 75 bool _convsync; 76 bool _addnoise; 77 Prbsgen _prbsgen; 78 79 static void jack_static_shutdown (void *arg); 80 static void jack_static_freewheel (int state, void *arg); 81 static int jack_static_buffsize (jack_nframes_t nframes, void *arg); 82 static int jack_static_process (jack_nframes_t nframes, void *arg); 83 }; 84 85 86 #endif 87