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.

104 lines
4.1KB

  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. typedef jack_nframes_t nframes_t;
  21. typedef float sample_t;
  22. #include <list>
  23. namespace JACK
  24. {
  25. class Port;
  26. class Client
  27. {
  28. std::list <JACK::Port*> _active_ports;
  29. jack_client_t *_client;
  30. static nframes_t _sample_rate;
  31. volatile int _xruns;
  32. volatile bool _freewheeling;
  33. volatile bool _zombified;
  34. static void shutdown ( void *arg );
  35. virtual void shutdown ( void ) = 0;
  36. static int process ( nframes_t nframes, void *arg );
  37. virtual int process ( nframes_t nframes ) = 0;
  38. static int sync ( jack_transport_state_t state, jack_position_t *pos, void *arg );
  39. virtual int sync ( jack_transport_state_t, jack_position_t * ) { return 1; }
  40. static int xrun ( void *arg );
  41. virtual int xrun ( void ) = 0;
  42. static void timebase ( jack_transport_state_t state, jack_nframes_t nframes, jack_position_t *pos, int new_pos, void *arg );
  43. virtual void timebase ( jack_transport_state_t, jack_nframes_t, jack_position_t *, int ) { }
  44. static void freewheel ( int yes, void *arg );
  45. virtual void freewheel ( bool yes ) = 0;
  46. static int buffer_size ( nframes_t nframes, void *arg );
  47. virtual int buffer_size ( nframes_t nframes ) = 0;
  48. static void thread_init ( void *arg );
  49. virtual void thread_init ( void ) = 0;
  50. Client ( const Client &rhs );
  51. Client & operator = ( const Client &rhs );
  52. void freeze_ports ( void );
  53. void thaw_ports ( void );
  54. protected:
  55. void deactivate ( void );
  56. private:
  57. friend class Port;
  58. friend class Transport;
  59. public:
  60. enum options { DEFAULT = 0,
  61. SLOW_SYNC = 1 << 0,
  62. TIMEBASE_MASTER = 1 << 1 };
  63. jack_client_t * jack_client ( void ) { return _client; }
  64. void port_added ( JACK::Port * p );
  65. void port_removed ( JACK::Port *p );
  66. Client ( );
  67. virtual ~Client ( );
  68. const char * init ( const char *client_name, unsigned int opts = 0 );
  69. const char * name ( const char * );
  70. nframes_t nframes ( void ) const { return jack_get_buffer_size( _client ); }
  71. float frame_rate ( void ) const { return jack_get_sample_rate( _client ); }
  72. static nframes_t sample_rate ( void ) { return _sample_rate; }
  73. int xruns ( void ) const { return _xruns; };
  74. bool freewheeling ( void ) const { return _freewheeling; }
  75. void freewheeling ( bool yes );
  76. bool zombified ( void ) const { return _zombified; }
  77. float cpu_load ( void ) const { return jack_cpu_load( _client ); }
  78. static int maximum_name_length ( void ) { return jack_client_name_size(); }
  79. };
  80. }