JACK tools
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.

128 lines
3.5KB

  1. // ----------------------------------------------------------------------------
  2. //
  3. // Copyright (C) 2012 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);
  28. virtual ~Jackclient (void);
  29. enum { PLAY, CAPT };
  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. private:
  44. void init (const char *jserv);
  45. void fini (void);
  46. double modtime (double d)
  47. {
  48. if (d < -200) d += _quant;
  49. if (d > 200) d -= _quant;
  50. return d;
  51. }
  52. void initwait (int nwait);
  53. void initsync (void);
  54. void setloop (double bw);
  55. void silence (int nframes);
  56. void playback (int nframes);
  57. void capture (int nframes);
  58. void sendinfo (int state, double error, double ratio);
  59. virtual void thr_main (void) {}
  60. void jack_freewheel (int state);
  61. void jack_latency (jack_latency_callback_mode_t jlcm);
  62. int jack_process (int nframes);
  63. jack_client_t *_client;
  64. jack_port_t *_ports [64];
  65. const char *_jname;
  66. int _mode;
  67. int _nchan;
  68. int _state;
  69. int _count;
  70. int _fsamp;
  71. int _bsize;
  72. int _rprio;
  73. bool _freew;
  74. float *_buff;
  75. Lfq_audio *_audioq;
  76. Lfq_int32 *_commq;
  77. Lfq_adata *_alsaq;
  78. Lfq_jdata *_infoq;
  79. double _ratio;
  80. double _quant;
  81. int _ppsec;
  82. jack_nframes_t _ft;
  83. double _t_a0;
  84. double _t_a1;
  85. int _k_a0;
  86. int _k_a1;
  87. int _k_j0;
  88. double _delay;
  89. int _ltcor;
  90. double _w0;
  91. double _w1;
  92. double _w2;
  93. double _z1;
  94. double _z2;
  95. double _z3;
  96. double _rcorr;
  97. VResampler _resamp;
  98. static void jack_static_shutdown (void *arg);
  99. static int jack_static_buffsize (jack_nframes_t nframes, void *arg);
  100. static void jack_static_freewheel (int state, void *arg);
  101. static void jack_static_latency (jack_latency_callback_mode_t jlcm, void *arg);
  102. static int jack_static_process (jack_nframes_t nframes, void *arg);
  103. };
  104. #endif