jack2 codebase
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

121 lines
3.5KB

  1. // ----------------------------------------------------------------------------
  2. //
  3. // Copyright (C) 2012-2018 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. #ifndef __JACKCLIENT_H
  20. #define __JACKCLIENT_H
  21. #include <zita-resampler/vresampler.h>
  22. #include "jack/jack.h"
  23. #include "lfqueue.h"
  24. class Jackclient
  25. {
  26. public:
  27. Jackclient (jack_client_t*, const char *jserv, int mode, int nchan, bool sync, void *arg);
  28. virtual ~Jackclient (void);
  29. enum { PLAY, CAPT, MAXCHAN = 64 };
  30. enum { INIT, TERM, WAIT, SYNC0, SYNC1, SYNC2, PROC1, PROC2 };
  31. void start (Lfq_audio *audioq,
  32. Lfq_int32 *commq,
  33. Lfq_adata *alsaq,
  34. Lfq_jdata *infoq,
  35. double ratio,
  36. int delay,
  37. int ltcor,
  38. int rqual);
  39. const char *jname (void) const { return _jname; }
  40. int fsamp (void) const { return _fsamp; }
  41. int bsize (void) const { return _bsize; }
  42. int rprio (void) const { return _rprio; }
  43. void *getarg(void) const { return _arg; }
  44. private:
  45. bool init (const char *jserv);
  46. void fini (void);
  47. void initwait (int nwait);
  48. void initsync (void);
  49. void setloop (double bw);
  50. void silence (int nframes);
  51. void playback (int nframes);
  52. void capture (int nframes);
  53. void sendinfo (int state, double error, double ratio);
  54. virtual void thr_main (void) {}
  55. void jack_freewheel (int state);
  56. void jack_latency (jack_latency_callback_mode_t jlcm);
  57. int jack_process (int nframes);
  58. jack_client_t *_client;
  59. jack_port_t *_ports [MAXCHAN];
  60. void *_arg;
  61. const char *_jname;
  62. int _mode;
  63. int _nchan;
  64. int _state;
  65. int _count;
  66. int _fsamp;
  67. int _bsize;
  68. int _rprio;
  69. bool _freew;
  70. float *_buff;
  71. Lfq_audio *_audioq;
  72. Lfq_int32 *_commq;
  73. Lfq_adata *_alsaq;
  74. Lfq_jdata *_infoq;
  75. double _ratio;
  76. int _ppsec;
  77. int _bstat;
  78. jack_nframes_t _ft;
  79. double _t_a0;
  80. double _t_a1;
  81. int _k_a0;
  82. int _k_a1;
  83. double _delay;
  84. int _ltcor;
  85. double _w0;
  86. double _w1;
  87. double _w2;
  88. double _z1;
  89. double _z2;
  90. double _z3;
  91. double _rcorr;
  92. VResampler *_resamp;
  93. static void jack_static_shutdown (void *arg);
  94. static int jack_static_buffsize (jack_nframes_t nframes, void *arg);
  95. static void jack_static_freewheel (int state, void *arg);
  96. static void jack_static_latency (jack_latency_callback_mode_t jlcm, void *arg);
  97. static int jack_static_process (jack_nframes_t nframes, void *arg);
  98. };
  99. #endif