Assists music production by grouping standalone programs into sessions. Community version of "Non Session Manager".
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.

131 lines
5.2KB

  1. /*******************************************************************************/
  2. /* Copyright (C) 2008 Jonathan Moore Liles */
  3. /* */
  4. /* This program is free software; you can redistribute it and/or modify it */
  5. /* under the terms of the GNU General Public License as published by the */
  6. /* Free Software Foundation; either version 2 of the License, or (at your */
  7. /* option) any later version. */
  8. /* */
  9. /* This program is distributed in the hope that it will be useful, but WITHOUT */
  10. /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
  11. /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */
  12. /* more details. */
  13. /* */
  14. /* You should have received a copy of the GNU General Public License along */
  15. /* with This program; see the file COPYING. If not,write to the Free Software */
  16. /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
  17. /*******************************************************************************/
  18. #pragma once
  19. #include <jack/jack.h>
  20. #include <jack/midiport.h>
  21. #ifdef HAVE_JACK_METADATA
  22. # include <jack/metadata.h>
  23. #endif
  24. #include <Mutex.H>
  25. typedef jack_nframes_t nframes_t;
  26. typedef jack_default_audio_sample_t sample_t;
  27. #include <list>
  28. namespace JACK
  29. {
  30. class Port;
  31. class Client
  32. {
  33. std::list <JACK::Port*> _active_ports;
  34. Mutex _frozen;
  35. jack_client_t *_client;
  36. // nframes_t _sample_rate;
  37. volatile int _xruns;
  38. volatile bool _freewheeling;
  39. volatile bool _zombified;
  40. volatile bool _active;
  41. static int sample_rate_changed ( nframes_t srate, void *arg );
  42. virtual int sample_rate_changed ( nframes_t srate ) { return 0; }
  43. static void port_connect ( jack_port_id_t a, jack_port_id_t b, int connect, void *arg );
  44. virtual void port_connect ( jack_port_id_t a, jack_port_id_t b, int connect ) { }
  45. static void shutdown ( void *arg );
  46. virtual void shutdown ( void ) = 0;
  47. static int process ( nframes_t nframes, void *arg );
  48. virtual int process ( nframes_t nframes ) = 0;
  49. static int sync ( jack_transport_state_t state, jack_position_t *pos, void *arg );
  50. virtual int sync ( jack_transport_state_t, jack_position_t * ) { return 1; }
  51. static int xrun ( void *arg );
  52. virtual int xrun ( void ) = 0;
  53. static void timebase ( jack_transport_state_t state, jack_nframes_t nframes, jack_position_t *pos, int new_pos, void *arg );
  54. virtual void timebase ( jack_transport_state_t, jack_nframes_t, jack_position_t *, int ) { }
  55. static void freewheel ( int yes, void *arg );
  56. virtual void freewheel ( bool yes ) = 0;
  57. static int buffer_size ( nframes_t nframes, void *arg );
  58. virtual int buffer_size ( nframes_t nframes ) = 0;
  59. static void thread_init ( void *arg );
  60. virtual void thread_init ( void ) = 0;
  61. static void latency ( jack_latency_callback_mode_t mode, void *arg );
  62. virtual void latency ( jack_latency_callback_mode_t mode ) { }
  63. Client ( const Client &rhs );
  64. Client & operator = ( const Client &rhs );
  65. void freeze_ports ( void );
  66. void thaw_ports ( void );
  67. protected:
  68. bool active ( void ) const { return _active; }
  69. void deactivate ( void );
  70. void activate ( void );
  71. private:
  72. friend class Port;
  73. friend class Transport;
  74. public:
  75. enum options { DEFAULT = 0,
  76. SLOW_SYNC = 1 << 0,
  77. TIMEBASE_MASTER = 1 << 1 };
  78. jack_client_t * jack_client ( void ) const { return _client; }
  79. void port_added ( JACK::Port * p );
  80. void port_removed ( JACK::Port *p );
  81. Client ( );
  82. virtual ~Client ( );
  83. const char * init ( const char *client_name, unsigned int opts = 0 );
  84. const char * name ( const char * );
  85. const char *jack_name ( void ) const;
  86. void close ( void );
  87. nframes_t nframes ( void ) const { return jack_get_buffer_size( _client ); }
  88. // float frame_rate ( void ) const { return jack_get_sample_rate( _client ); }
  89. nframes_t sample_rate ( void ) const { return jack_get_sample_rate( _client ); }
  90. int xruns ( void ) const { return _xruns; };
  91. bool freewheeling ( void ) const { return _freewheeling; }
  92. void freewheeling ( bool yes );
  93. bool zombified ( void ) const { return _zombified; }
  94. float cpu_load ( void ) const { return jack_cpu_load( _client ); }
  95. void transport_stop ( void );
  96. void transport_start ( void );
  97. void transport_locate ( nframes_t frame );
  98. jack_transport_state_t transport_query ( jack_position_t *pos );
  99. void recompute_latencies ( void );
  100. static int maximum_name_length ( void ) { return jack_client_name_size(); }
  101. };
  102. }